OSDN Git Service

[VM][STATE] Use namespace {VMNAME} to separate per VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pasopia7 / floppy.cpp
1 /*
2         TOSHIBA PASOPIA 7 Emulator 'EmuPIA7'
3
4         Author : Takeda.Toshiya
5         Date   : 2006.09.20 -
6
7         [ floppy ]
8 */
9
10 #include "floppy.h"
11 #include "../upd765a.h"
12
13 namespace PASOPIA7 {
14
15 void FLOPPY::initialize()
16 {
17         intr = false;
18 }
19
20 void FLOPPY::write_io8(uint32_t addr, uint32_t data)
21 {
22         switch(addr & 0xff) {
23         case 0xe0:
24                 // tc off
25                 d_fdc->write_signal(SIG_UPD765A_TC, 0, 1);
26                 break;
27         case 0xe2:
28                 // tc on
29                 d_fdc->write_signal(SIG_UPD765A_TC, 1, 1);
30                 break;
31         case 0xe6:
32                 // fdc reset
33                 if(data & 0x80) {
34                         d_fdc->reset();
35                 }
36                 // motor on/off
37                 d_fdc->write_signal(SIG_UPD765A_MOTOR, data, 0x40);
38                 break;
39         }
40 }
41
42 uint32_t FLOPPY::read_io8(uint32_t addr)
43 {
44         switch(addr & 0xff) {
45         case 0xe6:
46                 // fdc intr
47                 return intr ? 0x80 : 0;
48         }
49         return 0xff;
50 }
51
52 void FLOPPY::write_signal(int id, uint32_t data, uint32_t mask)
53 {
54         if(id == SIG_FLOPPY_INTR) {
55                 intr = ((data & mask) != 0);
56         }
57 }
58
59 #define STATE_VERSION   1
60
61 bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
62 {
63         if(!state_fio->StateCheckUint32(STATE_VERSION)) {
64                 return false;
65         }
66         if(!state_fio->StateCheckInt32(this_device_id)) {
67                 return false;
68         }
69         state_fio->StateBool(intr);
70         return true;
71 }
72
73 }