2 SHARP MZ-80B Emulator 'EmuZ-80B'
3 SHARP MZ-2200 Emulator 'EmuZ-2200'
5 Author : Takeda.Toshiya
8 [ MZ-1R12 (32KB SRAM) ]
13 void MZ1R12::initialize()
15 memset(sram, 0, sizeof(sram));
18 FILEIO* fio = new FILEIO();
20 if(fio->Fopen(create_local_path(_T("MZ-1E18.ROM")), FILEIO_READ_BINARY)) {
21 fio->Fread(sram, sizeof(sram), 1);
26 if(fio->Fopen(create_local_path(_T("MZ-1R12.BIN")), FILEIO_READ_BINARY)) {
27 fio->Fread(sram, sizeof(sram), 1);
33 crc32 = get_crc32(sram, sizeof(sram));
36 void MZ1R12::release()
38 if(!read_only && crc32 != get_crc32(sram, sizeof(sram))) {
39 FILEIO* fio = new FILEIO();
40 if(fio->Fopen(create_local_path(_T("MZ-1R12.BIN")), FILEIO_WRITE_BINARY)) {
41 fio->Fwrite(sram, sizeof(sram), 1);
48 void MZ1R12::write_io8(uint32 addr, uint32 data)
52 address = (address & 0x00ff) | (data << 8);
55 address = (address & 0xff00) | (data << 0);
59 sram[address & 0x7fff] = data;
66 uint32 MZ1R12::read_io8(uint32 addr)
73 return sram[(address++) & 0x7fff];
78 #define STATE_VERSION 1
80 void MZ1R12::save_state(FILEIO* state_fio)
82 state_fio->FputUint32(STATE_VERSION);
83 state_fio->FputInt32(this_device_id);
85 state_fio->Fwrite(sram, sizeof(sram), 1);
86 state_fio->FputBool(read_only);
87 state_fio->FputUint16(address);
88 state_fio->FputUint32(crc32);
91 bool MZ1R12::load_state(FILEIO* state_fio)
93 if(state_fio->FgetUint32() != STATE_VERSION) {
96 if(state_fio->FgetInt32() != this_device_id) {
99 state_fio->Fread(sram, sizeof(sram), 1);
100 read_only = state_fio->FgetBool();
101 address = state_fio->FgetUint16();
102 crc32 = state_fio->FgetUint32();