OSDN Git Service

[VM][STATE][MZ2500][MZ700][MZ80K] Apply new state framework to some VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz80k / printer.cpp
1 /*
2         SHARP MZ-80K/C Emulator 'EmuZ-80K'
3         SHARP MZ-1200 Emulator 'EmuZ-1200'
4         SHARP MZ-80A Emulator 'EmuZ-80A'
5
6         Author : Hideki Suga
7         Date   : 2016.03.18-
8
9         [ printer ]
10 */
11
12 #include "printer.h"
13
14 void PRINTER::write_io8(uint32_t addr, uint32_t data)
15 {
16         switch(addr & 0xff) {
17         case 0xfe:
18                 d_prn->write_signal(SIG_PRINTER_STROBE, data, 0x80);
19                 d_prn->write_signal(SIG_PRINTER_RESET, data, 0x40);
20                 break;
21         case 0xff:
22 #if defined(_MZ1200) || defined(_MZ80K)
23                 out_ch = data & 0xff;
24 #endif
25                 d_prn->write_signal(SIG_PRINTER_DATA, data, 0xff);
26                 break;
27         }
28 }
29
30 uint32_t PRINTER::read_io8(uint32_t addr)
31 {
32         switch(addr & 0xff) {
33         case 0xfe:
34 #if defined(_MZ1200) || defined(_MZ80K)
35                 if(out_ch == 0x05) {
36                         return 0xf0 | (d_prn->read_signal(SIG_PRINTER_BUSY) ? 1 : 0);
37                 } else
38 #endif
39                 return 0xf2 | (d_prn->read_signal(SIG_PRINTER_BUSY) ? 1 : 0);
40         }
41         return 0xff;
42 }
43
44 #if defined(_MZ1200) || defined(_MZ80K)
45 #define STATE_VERSION   1
46
47 #include "../../statesub.h"
48
49 void PRINTER::decl_state()
50 {
51         enter_decl_state(STATE_VERSION);
52
53         DECL_STATE_ENTRY_UINT8(out_ch);
54         
55         leave_decl_state();
56 }
57
58 void PRINTER::save_state(FILEIO* state_fio)
59 {
60         if(state_entry != NULL) {
61                 state_entry->save_state(state_fio);
62         }
63 //      state_fio->FputUint32(STATE_VERSION);
64 //      state_fio->FputInt32(this_device_id);
65         
66 //      state_fio->FputUint8(out_ch);
67 }
68
69 bool PRINTER::load_state(FILEIO* state_fio)
70 {
71         bool mb = false;
72         if(state_entry != NULL) {
73                 mb = state_entry->load_state(state_fio);
74         }
75         if(!mb) {
76                 return false;
77         }
78 //      if(state_fio->FgetUint32() != STATE_VERSION) {
79 //              return false;
80 //      }
81 //      if(state_fio->FgetInt32() != this_device_id) {
82 //              return false;
83 //      }
84 //      out_ch = state_fio->FgetUint8();
85         return true;
86 }
87 #endif
88