学研TV BOYエミュレータをつくる その1

まずはSource Code Archive (4/6/2020)をダウンロードします。

http://takeda-toshiya.my.coocan.jp/common/index.html

好きなディレクトリに展開して、以下のプロジェクトを開きます。

source\vc++2008\pc6001.vcproj

追加のインクルードディレクトリとライブラリディレクトリを指定してビルドできるはずです。

C:\Program Files (x86)\Microsoft DirectX 9.0 SDK (December 2004)\include
C:\Program Files (x86)\Microsoft DirectX 9.0 SDK (December 2004)\lib\x86

Common Source Code Projectのpc6001をコピーして編集していきます。

source\vc++2008\pc6001.vcproj
source\src\res\pc6001.rc
              \pc6001.ico
source\src\vm\vm.h
source\src\vm\pc6001\display.cpp
                    display.h
                    floppy.cpp
                    floppy.h
                    joystick.cpp
                    joystick.h
                    memory.cpp
                    memory.h
                    memory_draw.cpp
                    pc6001.cpp
                    pc6001.h
                    psub.cpp
                    psub.h
                    sub.cpp
                    sub.h
                    timer.cpp
                    timer.h

ディレクトリ構成は以下のようになります。

source\vc++2008\tvboy.vcproj
source\src\res\tvboy.rc
                tvboy.ico
source\src\vm\vm.h
source\src\vm\event.cpp
                event.h
                mc6800.cpp
                mc6800.h
                mc6847.cpp
                mc6847.h
                pcm1bit.cpp
                pcm1bit.h
source\src\vm\tvboy\memory.cpp
                    memory.h
                    tvboy.cpp
                    tvboy.h

tvboy.rc

// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
// Japanese resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN)
#ifdef _WIN32
LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
#pragma code_page(932)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE DISCARDABLE 
BEGIN
    "resource.h\0"
END

2 TEXTINCLUDE DISCARDABLE 
BEGIN
    "#include ""afxres.h""\r\n"
    "\0"
END

3 TEXTINCLUDE DISCARDABLE 
BEGIN
    "\r\n"
    "\0"
END

#endif    // APSTUDIO_INVOKED

#endif    // Japanese resources
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//

IDR_ACCELERATOR1 ACCELERATORS DISCARDABLE 
BEGIN
    VK_RETURN,      ID_ACCEL_SCREEN,        VIRTKEY, ALT, NOINVERT
    VK_APPS,        ID_ACCEL_SPEED,         VIRTKEY, NOINVERT
    VK_APPS,        ID_ACCEL_ROMAJI,        VIRTKEY, CONTROL, NOINVERT
END


/////////////////////////////////////////////////////////////////////////////
//
// Menu
//

IDR_MENU1 MENU DISCARDABLE 
BEGIN
    POPUP "Control"
    BEGIN
        MENUITEM "Reset",                       ID_RESET
        MENUITEM SEPARATOR
        MENUITEM "CPU x1",                      ID_CPU_POWER0
        MENUITEM "CPU x2",                      ID_CPU_POWER1
        MENUITEM "CPU x4",                      ID_CPU_POWER2
        MENUITEM "CPU x8",                      ID_CPU_POWER3
        MENUITEM "CPU x16",                     ID_CPU_POWER4
        MENUITEM "Full Speed",                  ID_FULL_SPEED
        MENUITEM SEPARATOR
        MENUITEM "Paste",                       ID_AUTOKEY_START
        MENUITEM "Stop",                        ID_AUTOKEY_STOP
        MENUITEM "Romaji to Kana",              ID_ROMAJI_TO_KANA
        MENUITEM SEPARATOR
        POPUP "Save State"
        BEGIN
            MENUITEM "State 0",                 ID_SAVE_STATE0
            MENUITEM "State 1",                 ID_SAVE_STATE1
            MENUITEM "State 2",                 ID_SAVE_STATE2
            MENUITEM "State 3",                 ID_SAVE_STATE3
            MENUITEM "State 4",                 ID_SAVE_STATE4
            MENUITEM "State 5",                 ID_SAVE_STATE5
            MENUITEM "State 6",                 ID_SAVE_STATE6
            MENUITEM "State 7",                 ID_SAVE_STATE7
            MENUITEM "State 8",                 ID_SAVE_STATE8
            MENUITEM "State 9",                 ID_SAVE_STATE9
        END
        POPUP "Load State"
        BEGIN
            MENUITEM "State 0",                 ID_LOAD_STATE0
            MENUITEM "State 1",                 ID_LOAD_STATE1
            MENUITEM "State 2",                 ID_LOAD_STATE2
            MENUITEM "State 3",                 ID_LOAD_STATE3
            MENUITEM "State 4",                 ID_LOAD_STATE4
            MENUITEM "State 5",                 ID_LOAD_STATE5
            MENUITEM "State 6",                 ID_LOAD_STATE6
            MENUITEM "State 7",                 ID_LOAD_STATE7
            MENUITEM "State 8",                 ID_LOAD_STATE8
            MENUITEM "State 9",                 ID_LOAD_STATE9
        END
        MENUITEM SEPARATOR
        MENUITEM "Debug Main CPU",              ID_OPEN_DEBUGGER0
        MENUITEM "Close Debugger",              ID_CLOSE_DEBUGGER
        MENUITEM SEPARATOR
        MENUITEM "Exit",                        ID_EXIT
    END
    POPUP "Cart"
    BEGIN
        MENUITEM "Insert",                      ID_OPEN_CART1
        MENUITEM "Eject",                       ID_CLOSE_CART1
        MENUITEM SEPARATOR
        MENUITEM "Recent",                      ID_RECENT_CART1
    END
    POPUP "Host"
    BEGIN
        MENUITEM "Rec Movie 60fps",             ID_HOST_REC_MOVIE_60FPS
        MENUITEM "Rec Movie 30fps",             ID_HOST_REC_MOVIE_30FPS
        MENUITEM "Rec Movie 15fps",             ID_HOST_REC_MOVIE_15FPS
        MENUITEM "Rec Sound",                   ID_HOST_REC_SOUND
        MENUITEM "Stop",                        ID_HOST_REC_STOP
        MENUITEM "Capture Screen",              ID_HOST_CAPTURE_SCREEN
        MENUITEM SEPARATOR
        POPUP "Screen"
        BEGIN
            MENUITEM "Window x1",               ID_SCREEN_WINDOW
            MENUITEM "Fullscreen 640x400",      ID_SCREEN_FULLSCREEN
            MENUITEM SEPARATOR
            MENUITEM "Fullscreen Stretch 1",    ID_SCREEN_FULLSCREEN_DOTBYDOT
            MENUITEM "Fullscreen Stretch 2",    ID_SCREEN_FULLSCREEN_STRETCH
            MENUITEM "Fullscreen Stretch 4",    ID_SCREEN_FULLSCREEN_FILL
            MENUITEM SEPARATOR
            MENUITEM "Rotate 0deg",             ID_SCREEN_ROTATE_0
            MENUITEM "Rotate +90deg",           ID_SCREEN_ROTATE_90
            MENUITEM "Rotate 180deg",           ID_SCREEN_ROTATE_180
            MENUITEM "Rotate -90deg",           ID_SCREEN_ROTATE_270
        END
        POPUP "Sound"
        BEGIN
            MENUITEM "2000Hz",                  ID_SOUND_FREQ0
            MENUITEM "4000Hz",                  ID_SOUND_FREQ1
            MENUITEM "8000Hz",                  ID_SOUND_FREQ2
            MENUITEM "11025Hz",                 ID_SOUND_FREQ3
            MENUITEM "22050Hz",                 ID_SOUND_FREQ4
            MENUITEM "44100Hz",                 ID_SOUND_FREQ5
            MENUITEM "48000Hz",                 ID_SOUND_FREQ6
            MENUITEM "96000Hz",                 ID_SOUND_FREQ7
            MENUITEM SEPARATOR
            MENUITEM "50msec",                  ID_SOUND_LATE0
            MENUITEM "100msec",                 ID_SOUND_LATE1
            MENUITEM "200msec",                 ID_SOUND_LATE2
            MENUITEM "300msec",                 ID_SOUND_LATE3
            MENUITEM "400msec",                 ID_SOUND_LATE4
            MENUITEM SEPARATOR
            MENUITEM "Realtime Mix",            ID_SOUND_STRICT_RENDER
            MENUITEM "Light Weight Mix",        ID_SOUND_LIGHT_RENDER
            MENUITEM SEPARATOR
            MENUITEM "Volume",                  ID_SOUND_VOLUME
        END
        MENUITEM SEPARATOR
        MENUITEM "Use Direct3D9",               ID_HOST_USE_D3D9
        MENUITEM "Wait Vsync",                  ID_HOST_WAIT_VSYNC
        MENUITEM "Use DirectInput",             ID_HOST_USE_DINPUT
        MENUITEM "Disable Windows 8 DWM",       ID_HOST_DISABLE_DWM
        MENUITEM "Show Status Bar",             ID_HOST_SHOW_STATUS_BAR
    END
END


/////////////////////////////////////////////////////////////////////////////
//
// Icon
//

// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1               ICON    DISCARDABLE     "phc20.ico"
#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_VOLUME DIALOG DISCARDABLE  0, 0, 250, 90
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Volume"
FONT 9, "MS PGothic"
BEGIN
    LTEXT           "Sound Device #1",IDC_VOLUME_CAPTION0,6,6,60,8
    CONTROL         "",IDC_VOLUME_PARAM_L0,"msctls_trackbar32",TBS_AUTOTICKS | WS_TABSTOP,70,6,175,12
    CONTROL         "",IDC_VOLUME_PARAM_R0,"msctls_trackbar32",TBS_AUTOTICKS | WS_TABSTOP,70,21,175,12
    LTEXT           "Sound Device #2",IDC_VOLUME_CAPTION1,6,36,60,8
    CONTROL         "",IDC_VOLUME_PARAM_L1,"msctls_trackbar32",TBS_AUTOTICKS | WS_TABSTOP,70,36,175,12
    CONTROL         "",IDC_VOLUME_PARAM_R1,"msctls_trackbar32",TBS_AUTOTICKS | WS_TABSTOP,70,51,175,12
    DEFPUSHBUTTON   "OK",IDOK,70,70,50,14
    DEFPUSHBUTTON   "Reset",IDC_VOLUME_RESET,130,70,50,14
END



#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED