OSDN Git Service

3cd872b70e8d471abd4083d417db8ac12e13c6aa
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz5500 / sysport.cpp
1 /*
2         SHARP MZ-5500 Emulator 'EmuZ-5500'
3
4         Author : Takeda.Toshiya
5         Date   : 2008.04.10 -
6
7         [ system port ]
8 */
9
10 #include "sysport.h"
11
12 void SYSPORT::initialize()
13 {
14         rst = 0;
15         register_frame_event(this);
16 }
17
18 void SYSPORT::write_io8(uint32_t addr, uint32_t data)
19 {
20         switch(addr & 0x3f0) {
21         case 0x70:
22                 // port-c
23                 if(data & 8) {
24                         d_fdc->reset();
25                 }
26 #if defined(_MZ6500) || defined(_MZ6550)
27                 highden = data & 4;
28 #endif
29                 break;
30         case 0x260:
31                 // z80ctc reti
32                 if(data == 0x4d) {
33                         d_ctc->notify_intr_reti();
34                 }
35                 break;
36         }
37 }
38
39 uint32_t SYSPORT::read_io8(uint32_t addr)
40 {
41         switch(addr & 0x3ff) {
42         case 0x60:
43                 // port-a
44 #if defined(_MZ6500) || defined(_MZ6550)
45                 return 0xfc | (rst ? 0 : 2) | (highden ? 1 : 0);
46 #else
47                 return 0xfd | (rst ? 0 : 2);
48 #endif
49         case 0x240:
50                 // z80ctc vector
51                 return d_ctc->get_intr_ack();
52         case 0x250:
53                 // z80sio vector
54                 return d_sio->get_intr_ack();
55         case 0x270:
56                 // port-b
57                 return 0xff;
58         }
59         return 0xff;
60 }
61
62 void SYSPORT::event_frame()
63 {
64         if(rst) {
65                 rst--;
66         }
67 }
68
69 #define STATE_VERSION   1
70
71 #include "../../statesub.h"
72
73 void SYSPORT::decl_state()
74 {
75
76         enter_decl_state(STATE_VERSION);
77         
78         DECL_STATE_ENTRY_INT32(rst);
79         DECL_STATE_ENTRY_INT32(highden);
80
81         leave_decl_state();
82 }
83
84 void SYSPORT::save_state(FILEIO* state_fio)
85 {
86         if(state_entry != NULL) {
87                 state_entry->save_state(state_fio);
88         }
89 //      state_fio->FputUint32(STATE_VERSION);
90 //      state_fio->FputInt32(this_device_id);
91         
92 //      state_fio->FputInt32(rst);
93 //      state_fio->FputInt32(highden);
94 }
95
96 bool SYSPORT::load_state(FILEIO* state_fio)
97 {
98         bool mb = false;
99         if(state_entry != NULL) {
100                 mb = state_entry->load_state(state_fio);
101         }
102         if(!mb) {
103                 return false;
104         }
105 //      if(state_fio->FgetUint32() != STATE_VERSION) {
106 //              return false;
107 //      }
108 //      if(state_fio->FgetInt32() != this_device_id) {
109 //              return false;
110 //      }
111 //      rst = state_fio->FgetInt32();
112 //      highden = state_fio->FgetInt32();
113         return true;
114 }
115