//----------------------------------- // Destructor //----------------------------------- CSystem_IniFile::~CSystem_IniFile( void ) { if( !m_dirtyFlag || m_fileName == "" ) return; // Write via osd_fwrite, as it's buffered osd_file *file = osd_fopen( FILETYPE_MAMEOX_FULLPATH, 0, m_fileName.c_str(), "w" ); if( !file ) return; std::map< std::string, std::vector<std::string> >::iterator i = m_data.begin(); for( ; i != m_data.end(); ++i ) { osd_fwrite( file, (*i).first.c_str(), (*i).first.length() ); osd_fwrite( file, "\n", 1 ); std::vector<std::string>::iterator j = (*i).second.begin(); for( ; j != (*i).second.end(); ++j ) { osd_fwrite( file, (*j).c_str(), (*j).length() ); osd_fwrite( file, "\n", 1 ); } osd_fwrite( file, "\n\n", 2 ); } osd_fclose( file ); }
static void jackrabt_hisave(void) { void *f; unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region]; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f,&RAM[0x73ba],8*6); osd_fwrite(f,&RAM[0x73ea],8*3); osd_fclose(f); } }
static void gemini_hisave(void) { void *f; unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region]; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f,&RAM[0xc026],3); osd_fwrite(f,&RAM[0xcf41],3*10+4*10); osd_fclose(f); } }
static void fantasy_hisave(void) { void *f; unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region]; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f,&RAM[0x0025],3); osd_fwrite(f,&RAM[0x0220],3*16); osd_fclose(f); } }
void mixer_write_config(void *f) { UINT8 default_levels[MIXER_MAX_CHANNELS]; UINT8 mixing_levels[MIXER_MAX_CHANNELS]; int i; for (i = 0; i < MIXER_MAX_CHANNELS; i++) { default_levels[i] = mixer_channel[i].default_mixing_level; mixing_levels[i] = mixer_channel[i].mixing_level; } osd_fwrite(f, default_levels, MIXER_MAX_CHANNELS); osd_fwrite(f, mixing_levels, MIXER_MAX_CHANNELS); }
static void hisave(void) { void *f; unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region]; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f,&RAM[0x8BC5],15); osd_fwrite(f,&RAM[0x8BE4],16); osd_fwrite(f,&RAM[0x885C],4); osd_fwrite(f,&RAM[0x8060],8); osd_fclose(f); } }
static void silkworm_hisave(void) { void *f; unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region]; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f,&RAM[0xd262],10*10); osd_fwrite(f,&RAM[0xd54e],4); osd_fwrite(f,&RAM[0xd572],4); osd_fclose(f); } }
static void gsword_hisave(void) { /* get RAM pointer (this game is multiCPU, we can't assume the global */ /* RAM pointer is pointing to the right place) */ unsigned char *RAM = Machine->memory_region[0]; void *f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1); if (f) { osd_fwrite(f,&RAM[0x9c00],3*10); osd_fwrite(f,&RAM[0x9c78],6*10); osd_fclose(f); } }
static void hs_save (void) { void *f = osd_fopen (Machine->gamedrv->name, 0, OSD_FILETYPE_HIGHSCORE, 1); LOG(("hs_save\n")); if (f) { struct mem_range *mem_range = state.mem_range; LOG(("saving...\n")); while (mem_range) { UINT8 *data = (UINT8*)malloc(mem_range->num_bytes); if (data) { /* this buffer will almost certainly be small enough to be dynamically allocated, but let's avoid memory trashing just in case */ copy_from_memory (mem_range->cpu, mem_range->addr, data, mem_range->num_bytes); osd_fwrite(f, data, mem_range->num_bytes); free(data); } mem_range = mem_range->next; } osd_fclose(f); } }
int osd_fwrite_swap(void *file,const void *buffer,int length) { int i; unsigned char *buf; unsigned char temp; int res; buf = (unsigned char *)buffer; for (i = 0;i < length;i+=2) { temp = buf[i]; buf[i] = buf[i+1]; buf[i+1] = temp; } res = osd_fwrite(file,buffer,length); for (i = 0;i < length;i+=2) { temp = buf[i]; buf[i] = buf[i+1]; buf[i+1] = temp; } return res; }
static void hisave(void) { void *f; unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region]; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f,&RAM[0x4014],5); osd_fwrite(f,&RAM[0x417d],12); osd_fclose(f); fast_memset(&RAM[0x4014],0xff,5); /* hi score */ fast_memset(&RAM[0x417d],0xff,12); /* name */ } }
/*----------------------------------------------------------------------*/ static int save_snapshot_xpm( OSD_FILE *fp ) { unsigned char buf[80]; int i, j, c; char *p = screen_snapshot; if( fp==NULL ) return 0; sprintf( buf, "/* XPM */\n" "static char * quasi88_xpm[] = {\n" "\"640 400 16 1\",\n" ); osd_fwrite( buf, sizeof(char), strlen(buf), fp ); for( i=0; i<16; i++ ){ sprintf( buf, "\"%1X c #%04X%04X%04X\",\n", i, (unsigned short)pal[i].red << 8, (unsigned short)pal[i].green << 8, (unsigned short)pal[i].blue << 8 ); osd_fwrite( buf, sizeof(char), strlen(buf), fp ); } for( i=0; i<400; i++ ){ osd_fputc( '\"', fp ); for( j=0; j<640; j++ ){ c = *p++; if( c < 10 ) c += '0'; else c += 'A' - 10; osd_fputc( c, fp ); } sprintf( buf, "\",\n" ); osd_fwrite( buf, sizeof(char), strlen(buf), fp ); } sprintf( buf, "};\n" ); osd_fwrite( buf, sizeof(char), strlen(buf), fp ); return 1; }
/*----------------------------------------------------------------------*/ static int save_snapshot_bmp( OSD_FILE *fp ) { static const char header[] = { 'B', 'M', /* BM */ 0x36, 0xb8, 0x0b, 0x00, /* ファイルサイズ 0xbb836 */ 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, /* 画像データオフセット 0x36 */ 0x28, 0x00, 0x00, 0x00, /* 情報サイズ 0x28 */ 0x80, 0x02, 0x00, 0x00, /* 幅 0x280 */ 0x90, 0x01, 0x00, 0x00, /* 高さ 0x190 */ 0x01, 0x00, 0x18, 0x00, /* 色深度 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 画像サイズ? 0xbb800 */ 0x00, 0x00, 0x00, 0x00, /* 横方向解像度? */ 0x00, 0x00, 0x00, 0x00, /* 縦方向解像度? */ 0x00, 0x00, 0x00, 0x00, /* 使用パレット数 */ 0x00, 0x00, 0x00, 0x00, /* 重要? */ }; unsigned char buf[4]; int i, j; char *p; if( fp==NULL ) return 0; osd_fwrite( header, sizeof(char), sizeof(header), fp ); for( i=0; i<400; i++ ){ p = screen_snapshot + (399-i)*640; for( j=0; j<640; j++ ){ buf[0] = pal[ (int)*p ].blue; buf[1] = pal[ (int)*p ].green; buf[2] = pal[ (int)*p ].red; osd_fwrite( buf, sizeof(char), 3, fp ); p++; } } return 1; }
static void nvram_handler(void *file,int read_or_write) { if (read_or_write) osd_fwrite(file, nvram, nvram_size); else if (file) osd_fread(file, nvram, nvram_size); else memset(nvram, 0, nvram_size); }
static void nvram_handler(void *file, int read_or_write) { if (read_or_write) osd_fwrite(file, wms_cmos_ram, 0x4000); else if (file) osd_fread(file, wms_cmos_ram, 0x4000); else memset(wms_cmos_ram, 0, 0x4000); }
static void berzerk_nvram_handler(void *file,int read_or_write) { if (read_or_write) osd_fwrite(file,nvram,nvram_size); else { if (file) osd_fread(file,nvram,nvram_size); } }
static void hisave(void) { void *f; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f,&ram[0x6B66],180); osd_fclose(f); } }
static void dangar_hisave(void) { void *f; unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region]; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f, &RAM[0xe209], 10*13); osd_fclose(f); } }
static void galivan_hisave(void) { unsigned char *RAM = Machine->memory_region[0]; void *f; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f, &RAM[0xe14f], 13*10); osd_fclose(f); } }
UINT32 mame_fwrite(mame_file *file, const void *buffer, size_t length) { /* switch off the file type */ switch (file->type) { case PLAIN_FILE: return osd_fwrite(file->file, buffer, length); } return 0; }
void namcos2_hisave(void) { void *f; f = osd_fopen (Machine->gamedrv->name, 0, OSD_FILETYPE_HIGHSCORE, 1); if (f) { osd_fwrite (f, namcos2_eeprom, namcos2_eeprom_size); osd_fclose (f); } }
static void novram_save(void) { void *f; unsigned char *RAM = Machine->memory_region[0]; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f,&RAM[0x1200],256); osd_fclose(f); } }
static void wanted_hisave(void) { void *f; unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region]; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f,&RAM[0x81b4], 16*5); /* HS table */ osd_fclose(f); } }
static void nvram_handler(void *file, int read_or_write) { if (read_or_write) osd_fwrite(file,eeprom,eeprom_size); else { if (file) osd_fread(file,eeprom,eeprom_size); else memset(eeprom,0,eeprom_size); } }
static void arkanoi2_hisave(void) { unsigned char *RAM = Machine->memory_region[0]; void *f; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f, &RAM[0xec81], 8*5); osd_fclose(f); RAM[0xeca5] = 0; } }
static void asteroid_hisave(void) { void *f; unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[0].memory_region]; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f,&RAM[0x001d],2*10+3*11); osd_fclose(f); } }
static void mcr2_hisave(int addr, int len) { unsigned char *RAM = Machine->memory_region[0]; void *f; f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1); if (f) { osd_fwrite(f,&RAM[addr],len); osd_fclose (f); } }
void foodf_nvram_handler(void *file,int read_or_write) { if (read_or_write) osd_fwrite(file,nvram,128); else { if (file) osd_fread(file,nvram,128); else memset(nvram,0xff,128); } }
static void ringking_hisave(void) { void *f; unsigned char *RAM = Machine->memory_region[Machine->drv->cpu[1].memory_region]; if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_HIGHSCORE,1)) != 0) { osd_fwrite(f,&RAM[0x8049],140); osd_fclose(f); } }
static void nvram_handler(void *file,int read_or_write) { if (read_or_write) osd_fwrite(file,nvram,nvram_size); else { if (file) osd_fread(file,nvram,nvram_size); else { /* fill in the default values */ memset(nvram,0,nvram_size); nvram[0x0d] = nvram[0x0f] = nvram[0x11] = nvram[0x13] = nvram[0x15] = nvram[0x19] = 1; nvram[0x17] = 3; } } }