void newdisk_nhd(const OEMCHAR *fname, UINT hddsize) { FILEH fh; NHDHDR nhd; UINT size; BRESULT r; if ((fname == NULL) || (hddsize < 5) || (hddsize > 512)) { goto ndnhd_err; } fh = file_create(fname); if (fh == FILEH_INVALID) { goto ndnhd_err; } ZeroMemory(&nhd, sizeof(nhd)); CopyMemory(&nhd.sig, sig_nhd, 15); STOREINTELDWORD(nhd.headersize, sizeof(nhd)); size = hddsize * 15; STOREINTELDWORD(nhd.cylinders, size); STOREINTELWORD(nhd.surfaces, 8); STOREINTELWORD(nhd.sectors, 17); STOREINTELWORD(nhd.sectorsize, 512); r = (file_write(fh, &nhd, sizeof(nhd)) == sizeof(nhd)) ? SUCCESS : FAILURE; r |= writehddipl(fh, 512, size * 8 * 17 * 512); file_close(fh); if (r != SUCCESS) { file_delete(fname); } ndnhd_err: return; }
static BOOL savever2header(FILEH fh, SAVEISF isf) { BYTE *ptr; UINT wsize; ptr = (BYTE *)_MALLOC(isf->headsize, "SAVE ISF ver2"); if (ptr == NULL) { goto sv2h_err1; } STOREINTELDWORD(ptr + 0, isf->headsize); STOREINTELDWORD(ptr + 4, isf->files); FillMemory(ptr + 0x008, 0xb40, 0xff); ZeroMemory(ptr + 0xb48, isf->headsize - 0xb48); // STOREINTELDWORD(ptr + 8 + 0x060, 6); // STOREINTELDWORD(ptr + 8 + 0x240, 1); // STOREINTELDWORD(ptr + 8 + 0x244, 1); // STOREINTELDWORD(ptr + 8 + 0x248, 1); wsize = file_write(fh, ptr, isf->headsize); _MFREE(ptr); if (wsize == isf->headsize) { return(SUCCESS); } sv2h_err1: return(FAILURE); }
BRESULT S98_open(const OEMCHAR *filename) { UINT i; S98HDR hdr; // ファイルのオープン s98log.fh = file_create(filename); if (s98log.fh == FILEH_INVALID) { return(FAILURE); } // 初期化 s98log.clock = pccore.realclock / 1000; s98log.p = 0; // ヘッダの保存 ZeroMemory(&hdr, sizeof(hdr)); hdr.magic[0] = 'S'; hdr.magic[1] = '9'; hdr.magic[2] = '8'; hdr.formatversion = '1'; STOREINTELDWORD(hdr.timerinfo, 1); STOREINTELDWORD(hdr.offset, offsetof(S98HDR, title)); STOREINTELDWORD(hdr.dumpdata, sizeof(S98HDR)); for (i=0; i<sizeof(hdr); i++) { S98_putc(*(((UINT8 *)&hdr) + i)); } #if 1 // FM for (i = 0x30; i < 0xb8; i++) { if ((i & 3) != 3) { S98_putc(NORMAL2608); S98_putc((REG8)i); S98_putc(g_opna[0].s.reg[i]); S98_putc(EXTEND2608); S98_putc((REG8)i); S98_putc(g_opna[0].s.reg[i+0x100]); } } // PSG for (i = 0x00; i < 0x0e; i++) { S98_putc(NORMAL2608); S98_putc((REG8)i); S98_putc(g_opna[0].s.reg[i]); } #endif // 一応パディング s98log.intcount = 10; sets98event(NEVENT_ABSOLUTE); return(SUCCESS); }
/** * Write the header * @param[in] hWave The handle of wave * @retval SUCCESS If succeeded * @retval FAILURE If failed */ static BRESULT WriteHeader(WAVEFILEH hWave) { struct TagRiffChunk riff; struct tagChunk chunk; struct TagWaveFormat format; UINT nFileSize; UINT nBlockAlign; UINT nAvgBytesPerSec; nFileSize = hWave->nDataSize; nFileSize += 4 + sizeof(chunk) + sizeof(format) + sizeof(chunk); riff.riff = MAKEID('R', 'I', 'F', 'F'); STOREINTELDWORD(riff.fileSize, nFileSize); riff.fileType = MAKEID('W', 'A', 'V', 'E'); if (file_write(hWave->fh, &riff, sizeof(riff)) != sizeof(riff)) { return FAILURE; } chunk.id = MAKEID('f', 'm', 't', ' '); STOREINTELDWORD(chunk.size, sizeof(format)); if (file_write(hWave->fh, &chunk, sizeof(chunk)) != sizeof(chunk)) { return FAILURE; } nBlockAlign = hWave->nChannels * (hWave->nBits / 8); nAvgBytesPerSec = nBlockAlign * hWave->nRate; STOREINTELWORD(format.formatTag, WAVE_FORMAT_PCM); STOREINTELWORD(format.channels, hWave->nChannels); STOREINTELDWORD(format.samplePerSec, hWave->nRate); STOREINTELDWORD(format.avgBytesPerSec, nAvgBytesPerSec); STOREINTELWORD(format.blockAlign, nBlockAlign); STOREINTELWORD(format.bitsPerSample, hWave->nBits); if (file_write(hWave->fh, &format, sizeof(format)) != sizeof(format)) { return FAILURE; } chunk.id = MAKEID('d', 'a', 't', 'a'); STOREINTELDWORD(chunk.size, hWave->nDataSize); if (file_write(hWave->fh, &chunk, sizeof(chunk)) != sizeof(chunk)) { return FAILURE; } return SUCCESS; }
BOOL variant_set(void *val, int num, SINT32 value) { if ((val == NULL) || (num < 0) || (((_VARIANT *)val)->max <= num)) { return(FAILURE); } switch(((_VARIANT *)val)->type) { case VARIANT_BIT: { BYTE *p = (BYTE *)&((_VARIANT *)val)[1]; BYTE bit = 1 << (num & 7); if (!value) { p[num / 8] &= ~bit; } else { p[num / 8] |= bit; } } break; case VARIANT_SINT32: { BYTE *p; p = (BYTE *)&((_VARIANT *)val)[1]; p += num * 4; STOREINTELDWORD(p, value); } break; } return(SUCCESS); }
void newdisk_vhd(const OEMCHAR *fname, UINT hddsize) { FILEH fh; VHDHDR vhd; UINT tmp; BRESULT r; if ((fname == NULL) || (hddsize < 2) || (hddsize > 512)) { goto ndvhd_err; } fh = file_create(fname); if (fh == FILEH_INVALID) { goto ndvhd_err; } ZeroMemory(&vhd, sizeof(vhd)); CopyMemory(&vhd.sig, sig_vhd, 7); STOREINTELWORD(vhd.mbsize, (UINT16)hddsize); STOREINTELWORD(vhd.sectorsize, 256); vhd.sectors = 32; vhd.surfaces = 8; tmp = hddsize * 16; // = * 1024 * 1024 / (8 * 32 * 256); STOREINTELWORD(vhd.cylinders, (UINT16)tmp); tmp *= 8 * 32; STOREINTELDWORD(vhd.totals, tmp); r = (file_write(fh, &vhd, sizeof(vhd)) == sizeof(vhd)) ? SUCCESS : FAILURE; r |= writehddipl(fh, 256, 0); file_close(fh); if (r != SUCCESS) { file_delete(fname); } ndvhd_err: return; }
static BRESULT headwrite(WAVEWR hdl) { RIFF_HEADER rif; WAVE_HEADER hdr; WAVE_INFOS inf; UINT filesize; UINT blk; UINT rps; filesize = hdl->size; filesize += 4 + (sizeof(WAVE_HEADER) * 2) + sizeof(WAVE_INFOS); rif.sig = WAVE_SIG('R', 'I', 'F', 'F'); STOREINTELDWORD(rif.size, filesize); rif.fmt = WAVE_SIG('W', 'A', 'V', 'E'); if (file_write((FILEH)hdl->fh, &rif, sizeof(rif)) != sizeof(rif)) { return(FAILURE); } blk = hdl->ch * (hdl->bits / 8); rps = blk * hdl->rate; hdr.sig = WAVE_SIG('f', 'm', 't', ' '); STOREINTELDWORD(hdr.size, sizeof(inf)); if (file_write((FILEH)hdl->fh, &hdr, sizeof(hdr)) != sizeof(hdr)) { return(FAILURE); } STOREINTELWORD(inf.format, 1); STOREINTELWORD(inf.channel, hdl->ch); STOREINTELDWORD(inf.rate, hdl->rate); STOREINTELDWORD(inf.rps, rps); STOREINTELWORD(inf.block, blk); STOREINTELWORD(inf.bit, hdl->bits); if (file_write((FILEH)hdl->fh, &inf, sizeof(inf)) != sizeof(inf)) { return(FAILURE); } hdr.sig = WAVE_SIG('d', 'a', 't', 'a'); STOREINTELDWORD(hdr.size, hdl->size); if (file_write((FILEH)hdl->fh, &hdr, sizeof(hdr)) != sizeof(hdr)) { return(FAILURE); } return(SUCCESS); }
static void savesetpos(SAVEISF isf, int num, UINT pos) { BYTE *p; p = (BYTE *)(isf + 1); if (isf->savever <= 1) { p += num * 4; } else { p += (isf->headsize - ((isf->files - num) * 0x40)); } STOREINTELDWORD(p, pos); }
void newdisk_fdd(const OEMCHAR *fname, REG8 type, const OEMCHAR *label) { _D88HEAD d88head; FILEH fh; ZeroMemory(&d88head, sizeof(d88head)); STOREINTELDWORD(d88head.fd_size, sizeof(d88head)); #if defined(OSLANG_UTF8) || defined(OSLANG_UCS2) oemtext_oemtosjis((char *)d88head.fd_name, NELEMENTS(d88head.fd_name), label, (UINT)-1); #else milstr_ncpy((char *)d88head.fd_name, label, NELEMENTS(d88head.fd_name)); #endif d88head.fd_type = type; fh = file_create(fname); if (fh != FILEH_INVALID) { file_write(fh, &d88head, sizeof(d88head)); file_close(fh); } }
// hddtype = 0:5MB / 1:10MB / 2:15MB / 3:20MB / 5:30MB / 6:40MB void newdisk_hdi(const OEMCHAR *fname, UINT hddtype) { const SASIHDD *sasi; FILEH fh; HDIHDR hdi; UINT32 size; BRESULT r; hddtype &= 7; if ((fname == NULL) || (hddtype == 7)) { goto ndhdi_err; } sasi = sasihdd + hddtype; fh = file_create(fname); if (fh == FILEH_INVALID) { goto ndhdi_err; } ZeroMemory(&hdi, sizeof(hdi)); size = 256 * sasi->sectors * sasi->surfaces * sasi->cylinders; // STOREINTELDWORD(hdi.hddtype, 0); STOREINTELDWORD(hdi.headersize, 4096); STOREINTELDWORD(hdi.hddsize, size); STOREINTELDWORD(hdi.sectorsize, 256); STOREINTELDWORD(hdi.sectors, sasi->sectors); STOREINTELDWORD(hdi.surfaces, sasi->surfaces); STOREINTELDWORD(hdi.cylinders, sasi->cylinders); r = (file_write(fh, &hdi, sizeof(hdi)) == sizeof(hdi)) ? SUCCESS : FAILURE; r |= writezero(fh, 4096 - sizeof(hdi)); r |= writehddipl(fh, 256, size); file_close(fh); if (r != SUCCESS) { file_delete(fname); } ndhdi_err: return; }
void vramdraw_savebmp(int num, const char *dir, const char *name, int pos, const char *credit0, const char *credit1) { int i; char path[MAX_PATH]; char work[32]; BMPDATA inf; VRAMHDL vram; UINT tmp; UINT bmpsize; BMPFILE bf; BMPINFO bi; BYTE *dat; FILEH fh; if ((num < 0) || (num >= GAMECORE_MAXVRAM) || (name == NULL)) { goto vdsb_err1; } if (dir == NULL) { dir = ""; } for (i=0; i<100; i++) { milstr_ncpy(path, dir, sizeof(path)); milstr_ncat(path, name, sizeof(path)); sprintf(work, "%02u.bmp", i); milstr_ncat(path, work, sizeof(path)); if (file_attr(path) == -1) { break; } taskmng_rol(); } if (i >= 100) { goto vdsb_err1; } vram = vram_copy(gamecore.vram[num]); if (vram == NULL) { goto vdsb_err1; } creditmix(vram, pos, credit1, 0x000000); creditmix(vram, pos, credit0, 0xffffff); inf.width = vram->width; inf.height = vram->height; inf.bpp = 24; bmpdata_setinfo(&bi, &inf, TRUE); bmpsize = bmpdata_getdatasize(&bi); ZeroMemory(&bf, sizeof(bf)); bf.bfType[0] = 'B'; bf.bfType[1] = 'M'; tmp = sizeof(BMPFILE) + sizeof(BMPINFO); STOREINTELDWORD(bf.bfOffBits, tmp); tmp += bmpsize; STOREINTELDWORD(bf.bfSize, tmp); dat = bmpdata_bmp24cnv(&bi, vram); if (dat == NULL) { goto vdsb_err2; } fh = file_create(path); if (fh == FILEH_INVALID) { goto vdsb_err3; } file_write(fh, &bf, sizeof(bf)); file_write(fh, &bi, sizeof(bi)); file_write(fh, dat, bmpsize); file_close(fh); vdsb_err3: _MFREE(dat); vdsb_err2: vram_destroy(vram); vdsb_err1: return; }
void bios_initialize(void) { BOOL biosrom; OEMCHAR path[MAX_PATH]; FILEH fh; UINT i; UINT32 tmp; UINT pos; biosrom = FALSE; getbiospath(path, str_biosrom, NELEMENTS(path)); fh = file_open_rb(path); if (fh != FILEH_INVALID) { biosrom = (file_read(fh, mem + 0x0e8000, 0x18000) == 0x18000); file_close(fh); } if (biosrom) { TRACEOUT(("load bios.rom")); pccore.rom |= PCROM_BIOS; // PnP BIOSを潰す for (i=0; i<0x10000; i+=0x10) { tmp = LOADINTELDWORD(mem + 0xf0000 + i); if (tmp == 0x506e5024) { TRACEOUT(("found PnP BIOS at %.5x", 0xf0000 + i)); mem[0xf0000 + i] = 0x6e; mem[0xf0002 + i] = 0x24; break; } } } else { CopyMemory(mem + 0x0e8000, nosyscode, sizeof(nosyscode)); if ((!biosrom) && (!(pccore.model & PCMODEL_EPSON))) { CopyMemory(mem + 0xe8dd8, neccheck, 0x25); pos = LOADINTELWORD(itfrom + 2); CopyMemory(mem + 0xf538e, itfrom + pos, 0x27); } setbiosseed(mem + 0x0e8000, 0x10000, 0xb1f0); } #if defined(SUPPORT_PC9821) getbiospath(path, OEMTEXT("bios9821.rom"), sizeof(path)); fh = file_open_rb(path); if (fh != FILEH_INVALID) { if (file_read(fh, mem + 0x0d8000, 0x2000) == 0x2000) { // IDE BIOSを潰す TRACEOUT(("load bios9821.rom")); STOREINTELWORD(mem + 0x0d8009, 0); } file_close(fh); } #if defined(BIOS_SIMULATE) mem[0xf8e80] = 0x98; mem[0xf8e81] = 0x21; mem[0xf8e82] = 0x1f; mem[0xf8e83] = 0x20; // Model Number? mem[0xf8e84] = 0x2c; mem[0xf8e85] = 0xb0; // mem[0xf8eaf] = 0x21; // <- これって何だっけ? #endif #endif #if defined(BIOS_SIMULATE) CopyMemory(mem + BIOS_BASE, biosfd80, sizeof(biosfd80)); if (!biosrom) { lio_initialize(); } for (i=0; i<8; i+=2) { STOREINTELWORD(mem + 0xfd800 + 0x1aaf + i, 0x1ab7); STOREINTELWORD(mem + 0xfd800 + 0x1ad7 + i, 0x1adf); STOREINTELWORD(mem + 0xfd800 + 0x2361 + i, 0x1980); } CopyMemory(mem + 0xfd800 + 0x1ab7, fdfmt2hd, sizeof(fdfmt2hd)); CopyMemory(mem + 0xfd800 + 0x1adf, fdfmt2dd, sizeof(fdfmt2dd)); CopyMemory(mem + 0xfd800 + 0x1980, fdfmt144, sizeof(fdfmt144)); SETBIOSMEM16(0xfffe8, 0xcb90); SETBIOSMEM16(0xfffec, 0xcb90); mem[0xffff0] = 0xea; STOREINTELDWORD(mem + 0xffff1, 0xfd800000); CopyMemory(mem + 0x0fd800 + 0x0e00, keytable[0], 0x300); CopyMemory(mem + ITF_ADRS, itfrom, sizeof(itfrom)); mem[ITF_ADRS + 0x7ff0] = 0xea; STOREINTELDWORD(mem + ITF_ADRS + 0x7ff1, 0xf8000000); if (pccore.model & PCMODEL_EPSON) { mem[ITF_ADRS + 0x7ff1] = 0x04; } else if ((pccore.model & PCMODELMASK) == PCMODEL_VM) { mem[ITF_ADRS + 0x7ff1] = 0x08; } setbiosseed(mem + 0x0f8000, 0x08000, 0x7ffe); #else fh = file_open_c("itf.rom"); if (fh != FILEH_INVALID) { file_read(fh, mem + ITF_ADRS, 0x8000); file_close(fh); TRACEOUT(("load itf.rom")); } #endif CopyMemory(mem + 0x1c0000, mem + ITF_ADRS, 0x08000); CopyMemory(mem + 0x1e8000, mem + 0x0e8000, 0x10000); }