2 Skelton for retropc emulator
4 Author : Takeda.Toshiya
12 void PRNFILE::initialize()
15 register_frame_event(this);
17 value = wait_frames = -1;
21 void PRNFILE::release()
34 void PRNFILE::event_frame()
36 if(fio->IsOpened() && --wait_frames == 0) {
41 void PRNFILE::write_signal(int id, uint32 data, uint32 mask)
43 if(id == SIG_PRINTER_DATA) {
45 } else if(id == SIG_PRINTER_STROBE) {
46 bool new_strobe = ((data & mask) != 0);
47 bool falling = (strobe && !new_strobe);
50 if(falling && value != -1) {
51 if(!fio->IsOpened()) {
56 #ifdef SUPPORT_VARIABLE_TIMING
57 wait_frames = (int)(vm->frame_rate() * 10.0 + 0.5);
59 wait_frames = (int)(FRAMES_PER_SEC * 10.0 + 0.5);
65 uint32 PRNFILE::read_signal(int ch)
67 if(ch == SIG_PRINTER_BUSY) {
73 void PRNFILE::open_file()
75 create_date_file_path(file_path, _MAX_PATH, _T("txt"));
76 fio->Fopen(file_path, FILEIO_WRITE_BINARY);
79 void PRNFILE::close_file()
82 // remove if the file size is less than 2 bytes
83 bool remove = (fio->Ftell() < 2);
86 FILEIO::RemoveFile(file_path);
91 #define STATE_VERSION 1
93 void PRNFILE::save_state(FILEIO* state_fio)
95 state_fio->FputUint32(STATE_VERSION);
96 state_fio->FputInt32(this_device_id);
98 state_fio->FputInt32(value);
99 state_fio->FputBool(strobe);
102 bool PRNFILE::load_state(FILEIO* state_fio)
106 if(state_fio->FgetUint32() != STATE_VERSION) {
109 if(state_fio->FgetInt32() != this_device_id) {
112 value = state_fio->FgetInt32();
113 strobe = state_fio->FgetBool();