OSDN Git Service

[VM][FM7] Add PRINTER ; output to file(s) and Dempa shimbun-sha Joy stick.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 7 Jan 2016 06:37:28 +0000 (15:37 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Thu, 7 Jan 2016 06:37:28 +0000 (15:37 +0900)
source/build-cmake/cmake/config_emufm7.cmake
source/src/qt/gui/mainwidget.h
source/src/qt/machines/fm7/MainWindow.cpp
source/src/vm/fm7/fm7.cpp
source/src/vm/fm7/fm7.h
source/src/vm/fm7/fm7_common.h
source/src/vm/fm7/fm7_mainio.cpp
source/src/vm/fm7/fm7_mainio.h
source/src/vm/fm7/joystick.cpp
source/src/vm/fm7/joystick.h

index 0010302..0f647ce 100644 (file)
@@ -23,6 +23,7 @@ set(VMFILES
                   ym2203.cpp
                   dummydevice.cpp
                   
+                  prnfile.cpp
                   datarec.cpp
                   disk.cpp
                   event.cpp
index 42f0ee9..874330e 100644 (file)
@@ -513,9 +513,6 @@ public slots:
        void set_freq(int);
        void set_latency(int);
        void set_sound_device(int);
-#if defined(USE_PRINTER)       
-       void set_printer_device(int);
-#endif 
        void set_monitor_type(int);
        void message_status_bar(QString);
        void resize_statusbar(int w, int h);
@@ -546,6 +543,9 @@ public slots:
                return true;
        }
 #endif
+#if defined(USE_PRINTER)       
+       void set_printer_device(int);
+#endif 
        void do_show_about(void);
        void do_browse_document(QString);
 signals:
index f87be5f..3ee79cf 100644 (file)
@@ -122,7 +122,10 @@ void META_MainWindow::retranslateUi(void)
        this->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0));
        
        actionCapture_Screen->setText(QApplication::translate("MainWindow", "Capture Screen", 0));
-       
+#if defined(USE_PRINTER_TYPE)
+       actionPrintDevice[1]->setText(QApplication::translate("MainWindow", "Dempa Joystick with #1", 0));
+       actionPrintDevice[2]->setText(QApplication::translate("MainWindow", "Dempa Joystick with #2", 0));
+#endif
 #ifdef USE_DEBUGGER
        actionDebugger_1->setText(QApplication::translate("MainWindow", "Debug Main CPU", 0));
        actionDebugger_2->setText(QApplication::translate("MainWindow", "Debug Sub  CPU", 0));
index 26301e3..09731dd 100644 (file)
@@ -12,6 +12,8 @@
 #include "../device.h"
 #include "../event.h"
 #include "../memory.h"
+#include "../prnfile.h"
+
 #ifdef USE_DEBUGGER
 #include "../debugger.h"
 #endif
@@ -95,7 +97,8 @@ VM::VM(EMU* parent_emu): emu(parent_emu)
        keyboard_beep = new BEEP(this, emu);
 #endif 
        keyboard = new KEYBOARD(this, emu);
-       display = new DISPLAY(this, emu);
+       display = new DISPLAY(this, emu);       
+       printer = new PRNFILE(this, emu);
        mainio  = new FM7_MAINIO(this, emu);
        mainmem = new FM7_MAINMEM(this, emu);
 
@@ -230,6 +233,7 @@ void VM::connect_bus(void)
        mainio->set_context_kanjirom_class1(kanjiclass1);
        mainio->set_context_mainmem(mainmem);
        mainio->set_context_keyboard(keyboard);
+       mainio->set_context_printer(printer);
    
 #if defined(CAPABLE_KANJI_CLASS2)
         mainio->set_context_kanjirom_class2(kanjiclass2);
index 2653564..6c959d6 100644 (file)
 #define USE_MINIMUM_RENDERING 1
 #define USE_MOUSE
 #define USE_JOYSTICK
+#define USE_PRINTER
+#define USE_PRINTER_TYPE 4
 
-//#undef  HAS_YM2608
-//#define SUPPORT_YM2203_PORT
-//#define HAS_AY_3_8910
 // 4:3
 #define SCREEN_WIDTH_ASPECT 640 
 #define SCREEN_HEIGHT_ASPECT 400
 #define USE_AUTO_KEY_RELEASE   6
 #define USE_CRT_FILTER
 #define USE_ACCESS_LAMP
-//#define USE_DISK_WRITE_PROTECT
 #define USE_STATE
 #define USE_DEBUGGER
-//#define USE_DIG_RESOLUTION 1
-//#define _DEBUG_LOG
-
-//#define _FDC_DEBUG_LOG
 
 
 #if defined(_FM8)
index 5d61ace..e4d9df8 100644 (file)
@@ -56,6 +56,7 @@ enum {
 #define FM7_DIPSW_FRAMESKIP      0x30000000
 #define FM7_DIPSW_SYNC_TO_HSYNC  0x80000000
 
+
 #define MAINCLOCK_NORMAL    1798000
 #define MAINCLOCK_MMR       1565000
 #define MAINCLOCK_FAST_MMR  2016000
index 21a1ac4..445f123 100644 (file)
@@ -37,12 +37,12 @@ FM7_MAINIO::FM7_MAINIO(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, paren
        // FD02
        cmt_indat = false; // bit7
        cmt_invert = false; // Invert signal
-       lpt_det2 = false;
-       lpt_det1 = false;
+       lpt_det2 = true;
+       lpt_det1 = true;
        lpt_pe = false;
        lpt_ackng_inv = false;
        lpt_error_inv = false;
-       lpt_busy = false;
+       lpt_busy = true;
        // FD04
 #if defined(_FM77AV40) || defined(_FM77AV40EX) || defined(_FM77AV40SX) || \
        defined(_FM77AV20) || defined(_FM77AV20EX) || defined(_FM77AV20SX) 
@@ -199,6 +199,13 @@ void FM7_MAINIO::reset()
        sub_cancel_bak = sub_cancel; // bit6 : '1' Cancel req.
        sub_halt_bak = sub_halt; // bit6 : '1' Cancel req.
        //sub_busy = false;
+       // FD02
+       //lpt_det2 = true;
+       //lpt_det1 = true;
+       //lpt_pe = false;
+       //lpt_ackng_inv = false;
+       //lpt_error_inv = false;
+       //lpt_busy = true;
    
        extdet_neg = false;
    
@@ -314,13 +321,39 @@ void FM7_MAINIO::set_port_fd00(uint8 data)
 {
        drec->write_signal(SIG_DATAREC_MIC, data, 0x01);
        drec->write_signal(SIG_DATAREC_REMOTE, data, 0x02);
+          lpt_slctin = ((data & 0x80) != 0);
+          lpt_strobe = ((data & 0x40) != 0);
+          printer->write_signal(SIG_PRINTER_STROBE, lpt_strobe ? 0xff : 0x00, 0xff);
 }
    
 uint8 FM7_MAINIO::get_port_fd02(void)
 {
        uint8 ret;
        // Still unimplemented printer.
-       ret = (cmt_indat) ? 0xff : 0x7f; // CMT 
+       ret = (cmt_indat) ? 0xff : 0x7f; // CMT
+       
+       if(config.printer_device_type == 0) {
+               lpt_busy = (printer->read_signal(SIG_PRINTER_BUSY) != 0);
+               lpt_error_inv = false;
+               lpt_ackng_inv = false;
+               lpt_pe = false;
+       } else if((config.printer_device_type == 1) || (config.printer_device_type == 2)) {
+               lpt_pe = (joystick->read_data8(config.printer_device_type + 1) != 0); // check joy port;
+               lpt_busy = true;
+               lpt_error_inv = false;
+               lpt_ackng_inv = false;
+       } else {
+               lpt_busy = true;
+               lpt_error_inv = false;
+               lpt_ackng_inv = false;
+               lpt_pe = true;
+       }
+       ret &= (lpt_busy) ? 0xff : ~0x01;
+       ret &= (lpt_error_inv) ? ~0x02 : 0xff;
+       ret &= (lpt_ackng_inv) ? ~0x04 : 0xff;
+       ret &= (lpt_pe) ? 0xff : ~0x08;
+       ret &= (lpt_det1) ? 0xff : ~0x10;
+       ret &= (lpt_det2) ? 0xff : ~0x20;
        return ret;
 }
 
@@ -472,7 +505,7 @@ void FM7_MAINIO::set_irq_printer(bool flag)
                irqstat_reg0 |= 0x02;
                irqstat_printer = false;           
        }
-       if(backup != irqstat_reg0) do_irq();
+       do_irq();
 }
 
 void FM7_MAINIO::set_irq_keyboard(bool flag)
@@ -1211,7 +1244,17 @@ void FM7_MAINIO::write_data8(uint32 addr, uint32 data)
                        return;
                        break;
                case 0x01: // FD01
-                       // set_lptdata_fd01((uint8)data);
+                       switch(config.printer_device_type) {
+                       case 0: // Write to file
+                               printer->write_signal(SIG_PRINTER_DATA, data, 0xff);
+                               set_irq_printer(lpt_strobe & lpt_slctin);                                       
+                               break;
+                       case 1:
+                       case 2:
+                               joystick->write_data8(0x01, data);
+                               //set_irq_printer(lpt_strobe & lpt_slctin);                                     
+                               break;
+                       }
                        break;
                case 0x02: // FD02
                        set_port_fd02((uint8)data);
index 395ce4b..7f12fbf 100644 (file)
@@ -329,7 +329,7 @@ class FM7_MAINIO : public DEVICE {
        YM2203* opn[4]; // 0=OPN 1=WHG 2=THG 3=PSG
        
        DEVICE* drec;
-        DEVICE* pcm1bit;
+       DEVICE* pcm1bit;
        DEVICE* joystick;
        
         //DEVICE* beep;
@@ -337,7 +337,7 @@ class FM7_MAINIO : public DEVICE {
 #if defined(HAS_DMA)
        HD6844* dmac;
 #endif
-       //FM7_PRINTER *printer;
+       DEVICE *printer;
        //FM7_RS232C *rs232c;
        /* */
        DEVICE *kanjiclass1;
@@ -381,6 +381,10 @@ class FM7_MAINIO : public DEVICE {
                return _T("FM7_MAIN_IO");
        }
 
+       void set_context_printer(DEVICE *p)
+       {
+               printer = p;
+       }
        void set_context_kanjirom_class1(DEVICE *p)
        {
                kanjiclass1 = p;
index 3092751..c1ab43e 100644 (file)
@@ -36,18 +36,25 @@ void JOYSTICK::initialize()
        mouse_timeout_event = -1;
        port_a_val = 0;
        port_b_val = 0;
+       lpmask = 0x00;
 }
 
 void JOYSTICK::reset()
 {
+       int i;
        joydata[0] = joydata[1] = 0xff;
        dx = dy = 0;
        lx = ly = 0;
        mouse_phase = 0;
        mouse_strobe = false;
        mouse_type = config.device_type;
-       if(mouse_type == 1) emulate_mouse[0] = true;
-       if(mouse_type == 2) emulate_mouse[1] = true;
+       for(i = 0; i < 2; i++) {
+               if(mouse_type  == (i + 1)) {
+                       emulate_mouse[i] = true;
+               } else {
+                       emulate_mouse[i] = false;
+               }
+       }       
        mouse_state = p_emu->mouse_buffer();
 }
 
@@ -94,7 +101,6 @@ void JOYSTICK::event_frame()
                        retval |= 0xc0;
                        joydata[ch] = retval;
                } else { // MOUSE
-                  
                }
        }
 }
@@ -157,7 +163,7 @@ uint32 JOYSTICK::read_data8(uint32 addr)
        //if(opn == NULL) return 0xff;
        
        switch(addr) {
-               case 0:
+       case 0: // OPN
                        //opn->write_io8(0, 0x0f);
                        //opnval = opn->read_io8(1);
                        opnval = port_b_val;
@@ -170,22 +176,42 @@ uint32 JOYSTICK::read_data8(uint32 addr)
                                        return update_mouse((opnval & 0x0c) << 2);
                                }
                        }
-                       
                        switch(opnval & 0xf0) {
                                case 0x20:
-                                       val = joydata[0];
+                                       if(config.printer_device_type != 1) val = joydata[0];
                                        break;
                                case 0x50:
-                                       val = joydata[1];
+                                       if(config.printer_device_type != 2) val = joydata[1];
                                        break;
                        }
                        break;
+       case 2: // Get Printer Joystick (CH0)
+       case 3: // Get Printer Joystick (CH1)
+               int ch = addr - 1;
+               if(config.printer_device_type == ch) {
+                       uint8 raw = rawdata[ch - 1];
+                       bool f = false;
+                       f |= ((raw & 0x08) && !(lpmask & 0x01));        
+                       f |= ((raw & 0x04) && !(lpmask & 0x02));        
+                       f |= ((raw & 0x01) && !(lpmask & 0x04));        
+                       f |= ((raw & 0x02) && !(lpmask & 0x08));        
+                       f |= ((raw & 0x20) && !(lpmask & 0x10));        
+                       f |= ((raw & 0x10) && !(lpmask & 0x20));
+                       if(f) val = 0x00;
+               }
        }
        return val;
 }
 
 void JOYSTICK::write_data8(uint32 addr, uint32 data)
 {
+       switch(addr & 0x00ff) {
+       case 1: // JOYSTICK PRINTER(ch1)
+               if((config.printer_device_type == 1) || (config.printer_device_type == 2)) {
+                       lpmask = data & 0x3f;
+               }
+               break;
+       }               
 }
 
 void JOYSTICK::write_signal(int id, uint32 data, uint32 mask)
@@ -207,15 +233,15 @@ void JOYSTICK::write_signal(int id, uint32 data, uint32 mask)
                                update_strobe(((data & 0x20) != 0));
                        }
                        break;
-          
        }
 }
 
 void JOYSTICK::update_config(void)
 {
+       int i;
        if(mouse_type == config.device_type) return;
        mouse_type = config.device_type;
-       switch(config.device_type){
+       switch(mouse_type & 0x03){
        case 1:
                emulate_mouse[0] = true;
                emulate_mouse[1] = false;
@@ -233,7 +259,7 @@ void JOYSTICK::update_config(void)
                break;
        }
 }
-#define STATE_VERSION 2
+#define STATE_VERSION 3
 void JOYSTICK::save_state(FILEIO *state_fio)
 {
        int ch;
@@ -255,6 +281,7 @@ void JOYSTICK::save_state(FILEIO *state_fio)
        state_fio->FputUint32_BE(mouse_data);
        //state_fio->FputInt32(mouse_timeout_event);
        // Version 3
+       state_fio->FputUint8(lpmask);
 }
 
 bool JOYSTICK::load_state(FILEIO *state_fio)
@@ -281,7 +308,8 @@ bool JOYSTICK::load_state(FILEIO *state_fio)
        mouse_phase = state_fio->FgetUint32_BE();
        mouse_data = state_fio->FgetUint32_BE();
        //mouse_timeout_event = state_fio->FgetInt32();
-       if(version == 2) stat = true; 
+       lpmask = state_fio->FgetUint8();
+       if(version == 3) stat = true; 
        return stat;
 }
                
index cdf6949..3bff19c 100644 (file)
@@ -30,6 +30,7 @@ class JOYSTICK : public DEVICE {
        int mouse_timeout_event;
        uint32 port_a_val;
        uint32 port_b_val;
+       uint8 lpmask;
  protected:
        VM* p_vm;
        EMU* p_emu;