Permalink
Browse files

Merge pull request #623 from yksoft1/test-menu-yksoft1

PC-98: Add switching EGC/GRCG/16-colors video options to menu.
  • Loading branch information...
joncampbell123 committed Mar 18, 2018
2 parents 581d310 + f4c4495 commit 67723a0328253d0ff8f1e83d45ebb9556b00234f
Showing with 125 additions and 3 deletions.
  1. +3 −1 include/resource.h
  2. +74 −1 src/gui/menu.cpp
  3. +18 −1 src/hardware/pc98.cpp
  4. +26 −0 src/ints/bios.cpp
  5. +4 −0 src/winres.rc
View
@@ -731,7 +731,9 @@
#define ID_CPUTYPE_486_PREFETCH 838
#define ID_CPUTYPE_PENTIUM_PRO 839
#define ID_SHOWCONSOLE 840
#define ID_PC98_ENABLEEGC 841
#define ID_PC98_ENABLEGRCG 842
#define ID_PC98_ENABLE16COLORS 843
#if defined(WIN32)
# define ID_WIN_SYSMENU_RESTOREMENU 0x0F00
# define ID_WIN_SYSMENU_TOGGLEMENU 0x0F01
View
@@ -975,6 +975,9 @@ int Reflect_Menu(void) {
EnableMenuItem(m_handle, ID_PC98_FOURPARTITIONSGRAPHICS, (!IS_PC98_ARCH) ? MF_DISABLED : MF_ENABLED);
EnableMenuItem(m_handle, ID_PC98_200SCANLINEEFFECT, (!IS_PC98_ARCH) ? MF_DISABLED : MF_ENABLED);
EnableMenuItem(m_handle, ID_PC98_GDC5MHZ, (!IS_PC98_ARCH) ? MF_DISABLED : MF_ENABLED);
EnableMenuItem(m_handle, ID_PC98_ENABLEEGC, (!IS_PC98_ARCH) ? MF_DISABLED : MF_ENABLED);
EnableMenuItem(m_handle, ID_PC98_ENABLEGRCG, (!IS_PC98_ARCH) ? MF_DISABLED : MF_ENABLED);
EnableMenuItem(m_handle, ID_PC98_ENABLE16COLORS, (!IS_PC98_ARCH) ? MF_DISABLED : MF_ENABLED);
EnableMenuItem(m_handle, ID_RESTART_DOS, (dos_kernel_disabled || dos_shell_running_program) ? MF_DISABLED : MF_ENABLED);
EnableMenuItem(m_handle, ID_CPU_ADVANCED, GFX_GetPreventFullscreen() ? MF_DISABLED : MF_ENABLED);
EnableMenuItem(m_handle, ID_DOS_ADVANCED, GFX_GetPreventFullscreen() ? MF_DISABLED : MF_ENABLED);
@@ -1303,7 +1306,10 @@ int Reflect_Menu(void) {
extern bool gdc_5mhz_mode;
extern bool pc98_allow_scanline_effect;
extern bool pc98_allow_4_display_partitions;
extern bool enable_pc98_egc;
extern bool enable_pc98_grcg;
extern bool enable_pc98_16color;
Section_prop * dosbox_section = static_cast<Section_prop *>(control->GetSection("dosbox"));
int pc98rate = dosbox_section->Get_int("pc-98 timer master frequency");
@@ -1317,6 +1323,9 @@ int Reflect_Menu(void) {
CheckMenuItem(m_handle, ID_PC98_FOURPARTITIONSGRAPHICS, (IS_PC98_ARCH && pc98_allow_4_display_partitions) ? MF_CHECKED : MF_STRING);
CheckMenuItem(m_handle, ID_PC98_200SCANLINEEFFECT, (IS_PC98_ARCH && pc98_allow_scanline_effect) ? MF_CHECKED : MF_STRING);
CheckMenuItem(m_handle, ID_PC98_GDC5MHZ, (IS_PC98_ARCH && gdc_5mhz_mode) ? MF_CHECKED : MF_STRING);
CheckMenuItem(m_handle, ID_PC98_ENABLEEGC, (IS_PC98_ARCH && enable_pc98_egc) ? MF_CHECKED : MF_STRING);
CheckMenuItem(m_handle, ID_PC98_ENABLEGRCG, (IS_PC98_ARCH && enable_pc98_grcg) ? MF_CHECKED : MF_STRING);
CheckMenuItem(m_handle, ID_PC98_ENABLE16COLORS, (IS_PC98_ARCH && enable_pc98_16color) ? MF_CHECKED : MF_STRING);
CheckMenuItem(m_handle, ID_MOUSE, Mouse_Drv ? MF_CHECKED : MF_STRING);
CheckMenuItem(m_handle, ID_AUTOCYCLE, (CPU_CycleAutoAdjust) ? MF_CHECKED : MF_STRING);
CheckMenuItem(m_handle, ID_AUTODETER, (CPU_AutoDetermineMode&CPU_AUTODETERMINE_CYCLES) ? MF_CHECKED : MF_STRING);
@@ -2783,6 +2792,70 @@ void MSG_WM_COMMAND_handle(SDL_SysWMmsg &Message) {
if (IS_PC98_ARCH) pc98_clear_graphics();
break;
}
case ID_PC98_ENABLEEGC: {
void gdc_egc_enable_update_vars(void);
extern bool enable_pc98_egc;
extern bool enable_pc98_grcg;
extern bool enable_pc98_16color;
if(IS_PC98_ARCH) {
enable_pc98_egc = !enable_pc98_egc;
gdc_egc_enable_update_vars();
Section_prop * dosbox_section = static_cast<Section_prop *>(control->GetSection("dosbox"));
if (enable_pc98_egc) {
dosbox_section->HandleInputline("pc-98 enable egc=1");
if(!enable_pc98_grcg) { //Also enable GRCG if GRCG is disabled when enabling EGC
enable_pc98_grcg = !enable_pc98_grcg;
mem_writeb(0x54C,(enable_pc98_grcg ? 0x02 : 0x00) | (enable_pc98_16color ? 0x04 : 0x00));
dosbox_section->HandleInputline("pc-98 enable grcg=1");
}
}
else
dosbox_section->HandleInputline("pc-98 enable egc=0");
}
break;
}
case ID_PC98_ENABLEGRCG: {
extern bool enable_pc98_grcg;
extern bool enable_pc98_egc;
void gdc_grcg_enable_update_vars(void);
if(IS_PC98_ARCH) {
enable_pc98_grcg = !enable_pc98_grcg;
gdc_grcg_enable_update_vars();
Section_prop * dosbox_section = static_cast<Section_prop *>(control->GetSection("dosbox"));
if (enable_pc98_grcg)
dosbox_section->HandleInputline("pc-98 enable grcg=1");
else
dosbox_section->HandleInputline("pc-98 enable grcg=0");
if ((!enable_pc98_grcg) && enable_pc98_egc) { // Also disable EGC if switching off GRCG
void gdc_egc_enable_update_vars(void);
enable_pc98_egc = !enable_pc98_egc;
gdc_egc_enable_update_vars();
dosbox_section->HandleInputline("pc-98 enable egc=0");
}
}
break;
}
case ID_PC98_ENABLE16COLORS: {
//NOTE: I thought that even later PC-9801s and some PC-9821s could use EGC features in digital 8-colors mode?
extern bool enable_pc98_16color;
void gdc_16color_enable_update_vars(void);
if(IS_PC98_ARCH) {
enable_pc98_16color = !enable_pc98_16color;
gdc_16color_enable_update_vars();
Section_prop * dosbox_section = static_cast<Section_prop *>(control->GetSection("dosbox"));
if (enable_pc98_16color)
dosbox_section->HandleInputline("pc-98 enable 16-color=1");
else
dosbox_section->HandleInputline("pc-98 enable 16-color=0");
}
break;
}
}
Reflect_Menu();
View
@@ -22,18 +22,22 @@ using namespace std;
extern bool gdc_5mhz_mode;
extern bool enable_pc98_egc;
extern bool enable_pc98_grcg;
void gdc_5mhz_mode_update_vars(void);
void gdc_egc_enable_update_vars(void);
void gdc_grcg_enable_update_vars(void);
/* ====================== PC98UTIL.COM ====================== */
class PC98UTIL : public Program {
public:
void Run(void) {
string arg;
bool got_opt=false;
cmd->BeginOpt();
while (cmd->GetOpt(/*&*/arg)) {
got_opt=true;
if (arg == "?" || arg == "help") {
doHelp();
break;
@@ -42,11 +46,23 @@ class PC98UTIL : public Program {
enable_pc98_egc = true;
WriteOut("EGC graphics functions enabled\n");
gdc_egc_enable_update_vars();
if (!enable_pc98_grcg) { //Enable GRCG if not enabled
enable_pc98_grcg = true;
gdc_grcg_enable_update_vars();
}
#if defined(WIN32) && !defined(C_SDL2)
int Reflect_Menu(void);
Reflect_Menu();
#endif
}
else if (arg == "noegc") {
enable_pc98_egc = false;
WriteOut("EGC graphics functions disabled\n");
gdc_egc_enable_update_vars();
#if defined(WIN32) && !defined(C_SDL2)
int Reflect_Menu(void);
Reflect_Menu();
#endif
}
else if (arg == "gdc25") {
gdc_5mhz_mode = false;
@@ -74,6 +90,7 @@ class PC98UTIL : public Program {
}
}
cmd->EndOpt();
if(!got_opt) doHelp();
}
void doHelp(void) {
WriteOut("PC98UTIL PC-98 emulation utility\n");
View
@@ -4782,6 +4782,32 @@ void gdc_egc_enable_update_vars(void) {
pc98_gdc_vramop &= ~(1 << VOPBIT_EGC);
}
void gdc_grcg_enable_update_vars(void) {
unsigned char b;
b = mem_readb(0x54C);
b &= ~0x02;
if (enable_pc98_grcg) b |= 0x02;
mem_writeb(0x54C,b);
//TODO: How to reset GRCG?
}
void gdc_16color_enable_update_vars(void) {
unsigned char b;
b = mem_readb(0x54C);
b &= ~0x04;
if (enable_pc98_16color) b |= 0x04;
mem_writeb(0x54C,b);
if(!enable_pc98_16color) {//force switch to 8-colors mode
void pc98_port6A_command_write(unsigned char b);
pc98_port6A_command_write(0x00);
}
}
class BIOS:public Module_base{
private:
static Bitu cb_bios_post__func(void) {
View
@@ -183,6 +183,10 @@ BEGIN
MENUITEM "Allow 200-line scanline effect", ID_PC98_200SCANLINEEFFECT
MENUITEM "Allow 4 display partitions in graphics layer", ID_PC98_FOURPARTITIONSGRAPHICS
MENUITEM SEPARATOR
MENUITEM "Enable EGC", ID_PC98_ENABLEEGC
MENUITEM "Enable GRCG", ID_PC98_ENABLEGRCG
MENUITEM "Enable analog display", ID_PC98_ENABLE16COLORS
MENUITEM SEPARATOR
MENUITEM "Clear text layer", ID_PC98_CLEAR_TEXT_LAYER
MENUITEM "Clear graphics layer", ID_PC98_CLEAR_GRAPHICS_LAYER
END

0 comments on commit 67723a0

Please sign in to comment.