OSDN Git Service

28fdf6f0be85a68cf09537149b89f6e6eff922c0
[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 void FLOPPY::initialize()
14 {
15         intr = false;
16 }
17
18 void FLOPPY::write_io8(uint32_t addr, uint32_t data)
19 {
20         switch(addr & 0xff) {
21         case 0xe0:
22                 // tc off
23                 d_fdc->write_signal(SIG_UPD765A_TC, 0, 1);
24                 break;
25         case 0xe2:
26                 // tc on
27                 d_fdc->write_signal(SIG_UPD765A_TC, 1, 1);
28                 break;
29         case 0xe6:
30                 // fdc reset
31                 if(data & 0x80) {
32                         d_fdc->reset();
33                 }
34                 // motor on/off
35                 d_fdc->write_signal(SIG_UPD765A_MOTOR, data, 0x40);
36                 break;
37         }
38 }
39
40 uint32_t FLOPPY::read_io8(uint32_t addr)
41 {
42         switch(addr & 0xff) {
43         case 0xe6:
44                 // fdc intr
45                 return intr ? 0x80 : 0;
46         }
47         return 0xff;
48 }
49
50 void FLOPPY::write_signal(int id, uint32_t data, uint32_t mask)
51 {
52         if(id == SIG_FLOPPY_INTR) {
53                 intr = ((data & mask) != 0);
54         }
55 }
56
57 #define STATE_VERSION   1
58
59 bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
60 {
61         if(!state_fio->StateCheckUint32(STATE_VERSION)) {
62                 return false;
63         }
64         if(!state_fio->StateCheckInt32(this_device_id)) {
65                 return false;
66         }
67         state_fio->StateBool(intr);
68         return true;
69 }