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; }
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; }
void adpcm_reset(ADPCM ad) { ZeroMemory(ad, sizeof(_ADPCM)); ad->mask = 0; // (UINT8)~0x1c; ad->delta = 127; STOREINTELWORD(ad->reg.stop, 0x0002); STOREINTELWORD(ad->reg.limit, 0xffff); ad->stop = 0x000060; ad->limit = 0x200000; adpcm_update(ad); }
static void store_srch(INTRST is) { SRCHREC srchrec; // SDA内のSRCHRECにセット srchrec = is->srchrec_ptr; srchrec->drive_no = 0xc0 | hostdrv.stat.drive_no; CopyMemory(srchrec->srch_mask, is->fcbname_ptr, 11); srchrec->attr_mask = *is->srch_attr_ptr; STOREINTELWORD(srchrec->dir_entry_no, ((UINT16)-1)); STOREINTELWORD(srchrec->dir_sector, ((UINT16)-1)); }
/** * 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; }
void newdisk_thd(const OEMCHAR *fname, UINT hddsize) { FILEH fh; UINT8 work[256]; UINT size; BRESULT r; if ((fname == NULL) || (hddsize < 5) || (hddsize > 256)) { goto ndthd_err; } fh = file_create(fname); if (fh == FILEH_INVALID) { goto ndthd_err; } ZeroMemory(work, 256); size = hddsize * 15; STOREINTELWORD(work, size); r = (file_write(fh, work, 256) == 256) ? SUCCESS : FAILURE; r |= writehddipl(fh, 256, 0); file_close(fh); if (r != SUCCESS) { file_delete(fname); } ndthd_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); }
void MEMCALL memvgaf_wr16(UINT32 address, REG16 value) { UINT8 bit; address = address & 0x7ffff; STOREINTELWORD(vramex + address, value); bit = (address & 0x40000)?2:1; vramupdate[LOW15((address + 0) >> 3)] |= bit; vramupdate[LOW15((address + 1) >> 3)] |= bit; gdcs.grphdisp |= bit; }
BOOL timemng_gettime(_SYSTIME *systime) { time_t long_time; struct tm *now_time; time(&long_time); now_time = localtime(&long_time); if (now_time != NULL) { STOREINTELWORD(systime->year, now_time->tm_year + 1900); STOREINTELWORD(systime->month, now_time->tm_mon + 1); STOREINTELWORD(systime->week, now_time->tm_wday); STOREINTELWORD(systime->day, now_time->tm_mday); STOREINTELWORD(systime->hour, now_time->tm_hour); STOREINTELWORD(systime->minute, now_time->tm_min); STOREINTELWORD(systime->second, now_time->tm_sec); STOREINTELWORD(systime->milli, 0); return(SUCCESS); } else { return(FAILURE); } }
static void fail(INTRST intrst, UINT16 err_code) { intrst->r.b.flag_l |= C_FLAG; STOREINTELWORD(intrst->r.w.ax, err_code); }
static void succeed(INTRST intrst) { intrst->r.b.flag_l &= ~C_FLAG; STOREINTELWORD(intrst->r.w.ax, ERR_NOERROR); }
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); }