DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/hardware/pc98.cpp
00001 
00002 #include "dosbox.h"
00003 #include "setup.h"
00004 #include "video.h"
00005 #include "pic.h"
00006 #include "vga.h"
00007 #include "regs.h"
00008 #include "menu.h"
00009 #include "programs.h"
00010 #include "support.h"
00011 #include "setup.h"
00012 #include "timer.h"
00013 #include "mem.h"
00014 #include "callback.h"
00015 #include "util_units.h"
00016 #include "control.h"
00017 #include "mixer.h"
00018 
00019 #include <string.h>
00020 #include <stdlib.h>
00021 #include <string>
00022 #include <stdio.h>
00023 
00024 using namespace std;
00025 
00026 extern bool gdc_5mhz_mode_initial;
00027 extern bool gdc_5mhz_mode;
00028 extern bool enable_pc98_egc;
00029 extern bool enable_pc98_grcg;
00030 
00031 void gdc_5mhz_mode_update_vars(void);
00032 void gdc_egc_enable_update_vars(void);
00033 void gdc_grcg_enable_update_vars(void);
00034 
00035 /* ====================== PC98UTIL.COM ====================== */
00036 class PC98UTIL : public Program {
00037 public:
00038         void Run(void) {
00039         string arg;
00040                 bool got_opt=false;
00041                 
00042         cmd->BeginOpt();
00043         while (cmd->GetOpt(/*&*/arg)) {
00044                         got_opt=true;
00045             if (arg == "?" || arg == "help") {
00046                 doHelp();
00047                 break;
00048             }
00049             else if (arg == "egc") {
00050                 enable_pc98_egc = true;
00051                 WriteOut("EGC graphics functions enabled\n");
00052                 gdc_egc_enable_update_vars();
00053                                 if (!enable_pc98_grcg) { //Enable GRCG if not enabled
00054                                         enable_pc98_grcg = true;
00055                                         gdc_grcg_enable_update_vars();
00056                                 }
00057 #if defined(WIN32) && !defined(C_SDL2)
00058                                 int Reflect_Menu(void);
00059                                 Reflect_Menu();
00060 #endif
00061             }
00062             else if (arg == "noegc") {
00063                 enable_pc98_egc = false;
00064                 WriteOut("EGC graphics functions disabled\n");
00065                 gdc_egc_enable_update_vars();
00066 #if defined(WIN32) && !defined(C_SDL2)
00067                                 int Reflect_Menu(void);
00068                                 Reflect_Menu();
00069 #endif
00070             }
00071             else if (arg == "gdc25") {
00072                 gdc_5mhz_mode_initial = gdc_5mhz_mode = false;
00073                 gdc_5mhz_mode_update_vars();
00074                 LOG_MSG("PC-98: GDC is running at %.1fMHz.",gdc_5mhz_mode ? 5.0 : 2.5);
00075                 WriteOut("GDC is now running at 2.5MHz\n");
00076 #if defined(WIN32) && !defined(C_SDL2)
00077                                 int Reflect_Menu(void);
00078                                 Reflect_Menu();
00079 #endif
00080                 mainMenu.get_item("pc98_5mhz_gdc").check(gdc_5mhz_mode).refresh_item(mainMenu);
00081             }
00082             else if (arg == "gdc50") {
00083                 gdc_5mhz_mode_initial = gdc_5mhz_mode = true;
00084                 gdc_5mhz_mode_update_vars();
00085                 LOG_MSG("PC-98: GDC is running at %.1fMHz.",gdc_5mhz_mode ? 5.0 : 2.5);
00086                 WriteOut("GDC is now running at 5MHz\n");
00087 #if defined(WIN32) && !defined(C_SDL2)
00088                 int Reflect_Menu(void);
00089                 Reflect_Menu();
00090 #endif
00091                 mainMenu.get_item("pc98_5mhz_gdc").check(gdc_5mhz_mode).refresh_item(mainMenu);
00092             }
00093             else if (arg == "24khz") {
00094                 // use the BIOS INT 18h
00095                 reg_ah = 0x31;//get
00096                 CALLBACK_RunRealInt(0x18);
00097 
00098                 reg_ah = 0x30;//set
00099                 reg_al &= ~(3u << 2u);// clear bits [3:2]
00100                 reg_al |=   0x08;//24khz  bits [3:2] = 10
00101                 CALLBACK_RunRealInt(0x18);
00102 
00103                 reg_ah = 0x0c;//show text layer
00104                 CALLBACK_RunRealInt(0x18);
00105 
00106                 reg_ah = 0x11;//show cursor
00107                 CALLBACK_RunRealInt(0x18);
00108 
00109                 WriteOut("Hsync is now 24khz");
00110             }
00111             else if (arg == "31khz") {
00112                 // use the BIOS INT 18h
00113                 reg_ah = 0x31;//get
00114                 CALLBACK_RunRealInt(0x18);
00115 
00116                 reg_ah = 0x30;//set
00117                 reg_al |= 0x0C;//31khz  bits [3:2] = 11
00118                 CALLBACK_RunRealInt(0x18);
00119 
00120                 reg_ah = 0x0c;//show text layer
00121                 CALLBACK_RunRealInt(0x18);
00122 
00123                 reg_ah = 0x11;//show cursor
00124                 CALLBACK_RunRealInt(0x18);
00125 
00126                 WriteOut("Hsync is now 31khz");
00127             }
00128             else {
00129                 WriteOut("Unknown switch %s",arg.c_str());
00130                 break;
00131             }
00132         }
00133         cmd->EndOpt();
00134                 if(!got_opt) doHelp();
00135         }
00136     void doHelp(void) {
00137         WriteOut("PC98UTIL PC-98 emulation utility\n");
00138         WriteOut("  /gdc25     Set GDC to 2.5MHz\n");
00139         WriteOut("  /gdc50     Set GDC to 5.0MHz\n");
00140         WriteOut("  /egc       Enable EGC\n");
00141         WriteOut("  /noegc     Disable EGC\n");
00142         WriteOut("  /24khz     Set hsync to 24KHz\n");
00143         WriteOut("  /31khz     Set hsync to 31KHz\n");
00144     }
00145 };
00146 
00147 void PC98UTIL_ProgramStart(Program * * make) {
00148         *make=new PC98UTIL;
00149 }
00150 /*==============================================*/
00151 
00152 /* wait-delay I/O port of some kind */
00153 void pc98_wait_write(Bitu port,Bitu val,Bitu iolen) {
00154     (void)iolen;//UNUSED
00155     (void)port;//UNUSED
00156     (void)val;//UNUSED
00157     unsigned int wait_cycles = (unsigned int)(CPU_CycleMax * 0.0006); /* 0.6us = 0.0006ms */
00158 
00159     CPU_Cycles -= (cpu_cycles_count_t)wait_cycles;
00160 }
00161