#define HEADER_BLOCK_ID 0
#define DATA_BLOCK_ID 1
+namespace MZ700 {
+
void QUICKDISK::initialize()
{
insert = protect = false;
} \
}
-void QUICKDISK::write_signal(int id, uint32 data, uint32 mask)
+void QUICKDISK::write_signal(int id, uint32_t data, uint32_t mask)
{
bool next = ((data & mask) != 0);
}
}
-uint32 QUICKDISK::read_signal(int ch)
+uint32_t QUICKDISK::read_signal(int ch)
{
// access lamp signal
if(accessed) {
while(remain >= MZT_HEADER_SIZE) {
// load header
- uint8 header[MZT_HEADER_SIZE], ram[0x20000];
+ uint8_t header[MZT_HEADER_SIZE], ram[0x20000];
fio->Fread(header, MZT_HEADER_SIZE, 1);
remain -= MZT_HEADER_SIZE;
if(header[0x40] == 'P' && header[0x41] == 'A' && header[0x42] == 'T' && header[0x43] == ':') {
int patch_ofs = 0x44;
for(; patch_ofs < 0x80; ) {
- uint16 patch_addr = header[patch_ofs] | (header[patch_ofs + 1] << 8);
+ uint16_t patch_addr = header[patch_ofs] | (header[patch_ofs + 1] << 8);
patch_ofs += 2;
if(patch_addr == 0xffff) {
break;
buffer[buffer_ptr++] = DATA_SYNC;
buffer[buffer_ptr++] = DATA_MARK;
buffer[buffer_ptr++] = DATA_BLOCK_ID;
- buffer[buffer_ptr++] = (uint8)(size & 0xff);
- buffer[buffer_ptr++] = (uint8)(size >> 8);
+ buffer[buffer_ptr++] = (uint8_t)(size & 0xff);
+ buffer[buffer_ptr++] = (uint8_t)(size >> 8);
for(int i = 0; i < size; i++) {
buffer[buffer_ptr++] = ram[offs + i];
}
}
} else {
// check header
- uint8 header[16];
+ uint8_t header[16];
fio->Fread(header, sizeof(header), 1);
if(memcmp(header, "-QD format-", 11) != 0) {
fio->Fseek(0, FILEIO_SEEK_SET);
// save blocks as mzt file
FILEIO* fio = new FILEIO();
if(!fio->Fopen(file_path_tmp, FILEIO_WRITE_BINARY)) {
- fio->Fopen(emu->bios_path(_T("temporary_saved_quick_disk.mzt")), FILEIO_WRITE_BINARY);
+ fio->Fopen(create_local_path(_T("temporary_saved_quick_disk.mzt")), FILEIO_WRITE_BINARY);
}
if(fio->IsOpened()) {
int block_num = buffer[4];
if(id == HEADER_BLOCK_ID) {
// create mzt header
- uint8 header[MZT_HEADER_SIZE];
+ uint8_t header[MZT_HEADER_SIZE];
memset(header, 0, sizeof(header));
- header[0x00] = (uint8)buffer[buffer_ptr + 0]; // attribute
+ header[0x00] = (uint8_t)buffer[buffer_ptr + 0]; // attribute
for(int i = 1; i <= 17; i++) {
- header[i] = (uint8)buffer[buffer_ptr + i]; // file name
+ header[i] = (uint8_t)buffer[buffer_ptr + i]; // file name
}
- header[0x3e] = (uint8)buffer[buffer_ptr + 18]; // lock
- header[0x3f] = (uint8)buffer[buffer_ptr + 19]; // lock
- header[0x12] = (uint8)buffer[buffer_ptr + 20]; // file size
- header[0x13] = (uint8)buffer[buffer_ptr + 21];
- header[0x14] = (uint8)buffer[buffer_ptr + 22]; // load addr
- header[0x15] = (uint8)buffer[buffer_ptr + 23];
- header[0x16] = (uint8)buffer[buffer_ptr + 24]; // exec addr
- header[0x17] = (uint8)buffer[buffer_ptr + 25];
+ header[0x3e] = (uint8_t)buffer[buffer_ptr + 18]; // lock
+ header[0x3f] = (uint8_t)buffer[buffer_ptr + 19]; // lock
+ header[0x12] = (uint8_t)buffer[buffer_ptr + 20]; // file size
+ header[0x13] = (uint8_t)buffer[buffer_ptr + 21];
+ header[0x14] = (uint8_t)buffer[buffer_ptr + 22]; // load addr
+ header[0x15] = (uint8_t)buffer[buffer_ptr + 23];
+ header[0x16] = (uint8_t)buffer[buffer_ptr + 24]; // exec addr
+ header[0x17] = (uint8_t)buffer[buffer_ptr + 25];
fio->Fwrite(header, MZT_HEADER_SIZE, 1);
} else {
// data
#define STATE_VERSION 1
-void QUICKDISK::save_state(FILEIO* state_fio)
+bool QUICKDISK::process_state(FILEIO* state_fio, bool loading)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
- state_fio->Fwrite(file_path, sizeof(file_path), 1);
- state_fio->FputBool(insert);
- state_fio->FputBool(protect);
- state_fio->FputBool(home);
- state_fio->FputBool(modified);
- state_fio->FputBool(accessed);
- state_fio->Fwrite(buffer, sizeof(buffer), 1);
- state_fio->FputInt32(buffer_ptr);
- state_fio->FputInt32(write_ptr);
- state_fio->FputBool(first_data);
- state_fio->FputBool(send_break);
- state_fio->FputBool(wrga);
- state_fio->FputBool(mton);
- state_fio->FputBool(sync);
- state_fio->FputBool(motor_on);
- state_fio->FputInt32(restore_id);
- state_fio->FputInt32(end_id);
-}
-
-bool QUICKDISK::load_state(FILEIO* state_fio)
-{
- if(state_fio->FgetUint32() != STATE_VERSION) {
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
- state_fio->Fread(file_path, sizeof(file_path), 1);
- insert = state_fio->FgetBool();
- protect = state_fio->FgetBool();
- home = state_fio->FgetBool();
- modified = state_fio->FgetBool();
- accessed = state_fio->FgetBool();
- state_fio->Fread(buffer, sizeof(buffer), 1);
- buffer_ptr = state_fio->FgetInt32();
- write_ptr = state_fio->FgetInt32();
- first_data = state_fio->FgetBool();
- send_break = state_fio->FgetBool();
- wrga = state_fio->FgetBool();
- mton = state_fio->FgetBool();
- sync = state_fio->FgetBool();
- motor_on = state_fio->FgetBool();
- restore_id = state_fio->FgetInt32();
- end_id = state_fio->FgetInt32();
+ state_fio->StateBuffer(file_path, sizeof(file_path), 1);
+ state_fio->StateBool(insert);
+ state_fio->StateBool(protect);
+ state_fio->StateBool(home);
+ state_fio->StateBool(modified);
+ state_fio->StateBool(accessed);
+ //state_fio->StateBuffer(buffer, sizeof(buffer), 1);
+ for(int i = 0; i < QUICKDISK_BUFFER_SIZE; i++) {
+ state_fio->StateUint16(buffer[i]);
+ }
+ state_fio->StateInt32(buffer_ptr);
+ state_fio->StateInt32(write_ptr);
+ state_fio->StateBool(first_data);
+ state_fio->StateBool(send_break);
+ state_fio->StateBool(wrga);
+ state_fio->StateBool(mton);
+ state_fio->StateBool(sync);
+ state_fio->StateBool(motor_on);
+ state_fio->StateInt32(restore_id);
+ state_fio->StateInt32(end_id);
return true;
}
+}