Skip to content

Instantly share code, notes, and snippets.

@tsutsui
Last active December 2, 2018 13:28
Show Gist options
  • Save tsutsui/be54f9bda8c0ae51e73f85f7775c1aa4 to your computer and use it in GitHub Desktop.
Save tsutsui/be54f9bda8c0ae51e73f85f7775c1aa4 to your computer and use it in GitHub Desktop.
PC6001VX でテープのストップビット長を環境設定で変更できるようにしてみるテスト。p6t2.cpp は処置してません (20181202ちょっと更新)
diff --git a/src/Qt/configdialog.cpp b/src/Qt/configdialog.cpp
index deed58e..9e53b62 100644
--- a/src/Qt/configdialog.cpp
+++ b/src/Qt/configdialog.cpp
@@ -313,6 +313,9 @@ void ConfigDialog::readConfig()
// Turbo TAPE
ui->checkBoxTurboTape->setChecked(config->GetTurboTAPE());
+ // TAPEストップビット数
+ ui->lineEditStopBit->setText(QString::number(qMin(qMax(2, config->GetStopBit()), 10)));
+
// Boost Up
ui->groupBoxBoostUp->setChecked(config->GetBoostUp());
@@ -537,6 +540,12 @@ void ConfigDialog::writeConfig()
// Turbo TAPE
config->SetTurboTAPE(ui->checkBoxTurboTape->isChecked());
+ // TAPEストップビット数
+ iVal = ui->lineEditStopBit->text().toInt(&conv);
+ if(conv){
+ config->SetStopBit(min(max(2, iVal), 10));
+ }
+
// Boost Up
config->SetBoostUp(ui->groupBoxBoostUp->isChecked());
diff --git a/src/Qt/configdialog.ui b/src/Qt/configdialog.ui
index 8b740cf..cc9b310 100644
--- a/src/Qt/configdialog.ui
+++ b/src/Qt/configdialog.ui
@@ -33,7 +33,7 @@
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
- <number>0</number>
+ <number>8</number>
</property>
<widget class="QWidget" name="tabBasic">
<attribute name="title">
@@ -3427,6 +3427,59 @@ border-radius: 1;</string>
</property>
</widget>
</item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_17">
+ <item>
+ <widget class="QLabel" name="label_101">
+ <property name="text">
+ <string>テープストップビット数:</string>
+ </property>
+ <property name="buddy">
+ <cstring>lineEditStopBit</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineEditStopBit">
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="inputMethodHints">
+ <set>Qt::ImhDigitsOnly</set>
+ </property>
+ <property name="inputMask">
+ <string>99</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_102">
+ <property name="text">
+ <string>(2-10)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_13">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
<item>
<widget class="QCheckBox" name="checkBoxTurboTape">
<property name="text">
@@ -3613,6 +3666,7 @@ border-radius: 1;</string>
<tabstop>lineEditClockRatio</tabstop>
<tabstop>checkBoxRomCRC</tabstop>
<tabstop>checkBoxRomPatch</tabstop>
+ <tabstop>lineEditStopBit</tabstop>
<tabstop>checkBoxTurboTape</tabstop>
<tabstop>lineEditBoost60</tabstop>
<tabstop>lineEditBoost66</tabstop>
diff --git a/src/Qt/osdQt.cpp b/src/Qt/osdQt.cpp
index 6dc682d..fdc8fac 100644
--- a/src/Qt/osdQt.cpp
+++ b/src/Qt/osdQt.cpp
@@ -251,6 +251,7 @@ const char *MsgIni[] = {
QT_TRANSLATE_NOOP("PC6001VX", "FDD接続台数 (0-2)"),
QT_TRANSLATE_NOOP("PC6001VX", "拡張RAM使用"),
QT_TRANSLATE_NOOP("PC6001VX", "Turbo TAPE Yes:有効 No:無効"),
+ QT_TRANSLATE_NOOP("PC6001VX", "TAPEストップビット数 (2-10)"),
QT_TRANSLATE_NOOP("PC6001VX", "BoostUp Yes:有効 No:無効"),
QT_TRANSLATE_NOOP("PC6001VX", "BoostUp 最大倍率(N60モード)"),
QT_TRANSLATE_NOOP("PC6001VX", "BoostUp 最大倍率(N60m/N66モード)"),
diff --git a/src/config.cpp b/src/config.cpp
index 5a72ac4..d0046c3 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -920,6 +920,20 @@ void CFG6::SetCmtVol( int data )
Ini->PutEntry( "SOUND", MSINI_TapeVolume, "TapeVolume", "%d", data );
}
+// TAPEストップビット数取得
+int CFG6::GetStopBit( void )
+{
+ int bits = DEFAULT_STOPBIT;
+ Ini->GetInt( "CONFIG", "TapeStopBit", &bits, bits );
+ return bits;
+}
+
+// TAPEストップビット数設定
+void CFG6::SetStopBit( int bits )
+{
+ Ini->PutEntry( "CONFIG", MSINI_StopBit, "TapeStopBit", "%d", bits );
+}
+
// Turbo TAPE 有効フラグ取得
bool CFG6::GetTurboTAPE( void )
{
@@ -1381,6 +1395,10 @@ void CFG6::InitIni( cIni *ini, bool over )
if( over || !ini->GetString( "CONFIG", "ExtRam", str, str ) )
SetUseExtRam( DEFAULT_EXTRAM );
+ // TAPEストップビット数
+ if( over || !ini->GetString( "CONFIG", "TapeStopBit", str, str ) )
+ SetStopBit( DEFAULT_STOPBIT );
+
// Turbo TAPE
if( over || !ini->GetString( "CONFIG", "TurboTAPE", str, str ) )
SetTurboTAPE( DEFAULT_TURBO );
diff --git a/src/config.h b/src/config.h
index cd29309..dd3c51b 100644
--- a/src/config.h
+++ b/src/config.h
@@ -113,6 +113,8 @@ public:
void SetTapeFile( const char * ); // 設定
int GetCmtVol(); // TAPEモニタ音量取得
void SetCmtVol( int ); // 設定
+ int GetStopBit(); // TAPEストップビット数取得
+ void SetStopBit( int ); // 設定
bool GetTurboTAPE(); // Turbo TAPE 有効フラグ取得
void SetTurboTAPE( bool ); // 設定
bool GetBoostUp(); // BoostUp 有効フラグ取得
diff --git a/src/osd.h b/src/osd.h
index a5c5c90..7381a6c 100644
--- a/src/osd.h
+++ b/src/osd.h
@@ -232,56 +232,57 @@ extern const char *MsgIni[];
#define MSINI_FDD MsgIni[2] // " FDD接続台数 (0-2)"
#define MSINI_ExtRam MsgIni[3] // " 拡張RAM使用"
#define MSINI_TurboTAPE MsgIni[4] // " Turbo TAPE Yes:有効 No:無効"
-#define MSINI_BoostUp MsgIni[5] // " BoostUp Yes:有効 No:無効"
-#define MSINI_MaxBoost60 MsgIni[6] // " BoostUp 最大倍率(N60モード)
-#define MSINI_MaxBoost62 MsgIni[7] // " BoostUp 最大倍率(N60m/N66モード)
-#define MSINI_OverClock MsgIni[8] // " オーバークロック率 (1-1000)%"
-#define MSINI_CheckCRC MsgIni[9] // " CRCチェック Yes:有効 No:無効"
-#define MSINI_RomPatch MsgIni[10] // " ROMパッチ Yes:あてる No:あてない"
-#define MSINI_FDDWait MsgIni[11] // " FDDウェイト Yes:有効 No:無効"
+#define MSINI_StopBit MsgIni[5] // " TAPEストップビット数 (2-10)"
+#define MSINI_BoostUp MsgIni[6] // " BoostUp Yes:有効 No:無効"
+#define MSINI_MaxBoost60 MsgIni[7] // " BoostUp 最大倍率(N60モード)
+#define MSINI_MaxBoost62 MsgIni[8] // " BoostUp 最大倍率(N60m/N66モード)
+#define MSINI_OverClock MsgIni[9] // " オーバークロック率 (1-1000)%"
+#define MSINI_CheckCRC MsgIni[10] // " CRCチェック Yes:有効 No:無効"
+#define MSINI_RomPatch MsgIni[11] // " ROMパッチ Yes:あてる No:あてない"
+#define MSINI_FDDWait MsgIni[12] // " FDDウェイト Yes:有効 No:無効"
// [DISPLAY]
-#define MSINI_Mode4Color MsgIni[12] // " MODE4カラーモード 0:モノクロ 1:赤/青 2:青/赤 3:ピンク/緑 4:緑/ピンク"
-#define MSINI_ScanLine MsgIni[13] // " スキャンライン Yes:あり No:なし"
-#define MSINI_ScanLineBr MsgIni[14] // " スキャンライン輝度 (0-100)%"
-#define MSINI_DispNTSC MsgIni[15] // " 4:3表示 Yes:有効 No:無効"
-#define MSINI_FullScreen MsgIni[16] // " フルスクリーンモード Yes:有効 No:無効"
-#define MSINI_DispStatus MsgIni[17] // " ステータスバー Yes:表示 No:非表示"
-#define MSINI_FrameSkip MsgIni[18] // " フレームスキップ"
+#define MSINI_Mode4Color MsgIni[13] // " MODE4カラーモード 0:モノクロ 1:赤/青 2:青/赤 3:ピンク/緑 4:緑/ピンク"
+#define MSINI_ScanLine MsgIni[14] // " スキャンライン Yes:あり No:なし"
+#define MSINI_ScanLineBr MsgIni[15] // " スキャンライン輝度 (0-100)%"
+#define MSINI_DispNTSC MsgIni[16] // " 4:3表示 Yes:有効 No:無効"
+#define MSINI_FullScreen MsgIni[17] // " フルスクリーンモード Yes:有効 No:無効"
+#define MSINI_DispStatus MsgIni[18] // " ステータスバー Yes:表示 No:非表示"
+#define MSINI_FrameSkip MsgIni[19] // " フレームスキップ"
// [SOUND]
-#define MSINI_SampleRate MsgIni[19] // " サンプリングレート (44100/22050/11025)Hz"
-#define MSINI_SoundBuffer MsgIni[20] // " サウンドバッファサイズ"
-#define MSINI_MasterVolume MsgIni[21] // " マスター音量 (0-100)"
-#define MSINI_PsgVolume MsgIni[22] // " PSG音量 (0-100)"
-#define MSINI_VoiceVolume MsgIni[23] // " 音声合成音量 (0-100)"
-#define MSINI_TapeVolume MsgIni[24] // " TAPEモニタ音量 (0-100)"
-#define MSINI_PsgLPF MsgIni[25] // " PSG LPFカットオフ周波数(0で無効)"
+#define MSINI_SampleRate MsgIni[20] // " サンプリングレート (44100/22050/11025)Hz"
+#define MSINI_SoundBuffer MsgIni[21] // " サウンドバッファサイズ"
+#define MSINI_MasterVolume MsgIni[22] // " マスター音量 (0-100)"
+#define MSINI_PsgVolume MsgIni[23] // " PSG音量 (0-100)"
+#define MSINI_VoiceVolume MsgIni[24] // " 音声合成音量 (0-100)"
+#define MSINI_TapeVolume MsgIni[25] // " TAPEモニタ音量 (0-100)"
+#define MSINI_PsgLPF MsgIni[26] // " PSG LPFカットオフ周波数(0で無効)"
// [MOVIE]
-#define MSINI_AviBpp MsgIni[26] // " ビデオキャプチャ色深度 (16,24,32)"
+#define MSINI_AviBpp MsgIni[27] // " ビデオキャプチャ色深度 (16,24,32)"
// [FILES]
-#define MSINI_ExtRom MsgIni[27] // " 拡張ROMファイル名"
-#define MSINI_tape MsgIni[28] // " TAPE(LODE)ファイル名(起動時に自動マウント)"
-#define MSINI_save MsgIni[29] // " TAPE(SAVE)ファイル名(SAVE時に自動マウント)"
-#define MSINI_disk1 MsgIni[30] // " DISK1ファイル名(起動時に自動マウント)"
-#define MSINI_disk2 MsgIni[31] // " DISK2ファイル名(起動時に自動マウント)"
-#define MSINI_printer MsgIni[32] // " プリンタ出力ファイル名"
-#define MSINI_fontz MsgIni[33] // " 全角フォントファイル名"
-#define MSINI_fonth MsgIni[34] // " 半角フォントファイル名"
+#define MSINI_ExtRom MsgIni[28] // " 拡張ROMファイル名"
+#define MSINI_tape MsgIni[29] // " TAPE(LODE)ファイル名(起動時に自動マウント)"
+#define MSINI_save MsgIni[30] // " TAPE(SAVE)ファイル名(SAVE時に自動マウント)"
+#define MSINI_disk1 MsgIni[31] // " DISK1ファイル名(起動時に自動マウント)"
+#define MSINI_disk2 MsgIni[32] // " DISK2ファイル名(起動時に自動マウント)"
+#define MSINI_printer MsgIni[33] // " プリンタ出力ファイル名"
+#define MSINI_fontz MsgIni[34] // " 全角フォントファイル名"
+#define MSINI_fonth MsgIni[35] // " 半角フォントファイル名"
// [PATH]
-#define MSINI_RomPath MsgIni[35] // " ROMイメージ格納パス"
-#define MSINI_TapePath MsgIni[36] // " TAPEイメージ格納パス"
-#define MSINI_DiskPath MsgIni[37] // " DISKイメージ格納パス"
-#define MSINI_ExtRomPath MsgIni[38] // " 拡張ROMイメージ格納パス"
-#define MSINI_ImgPath MsgIni[39] // " スナップショット格納パス"
-#define MSINI_WavePath MsgIni[40] // " WAVEファイル格納パス"
-#define MSINI_FontPath MsgIni[41] // " FONT格納パス"
-#define MSINI_DokoSavePath MsgIni[42] // " どこでもSAVE格納パス"
+#define MSINI_RomPath MsgIni[36] // " ROMイメージ格納パス"
+#define MSINI_TapePath MsgIni[37] // " TAPEイメージ格納パス"
+#define MSINI_DiskPath MsgIni[38] // " DISKイメージ格納パス"
+#define MSINI_ExtRomPath MsgIni[39] // " 拡張ROMイメージ格納パス"
+#define MSINI_ImgPath MsgIni[40] // " スナップショット格納パス"
+#define MSINI_WavePath MsgIni[41] // " WAVEファイル格納パス"
+#define MSINI_FontPath MsgIni[42] // " FONT格納パス"
+#define MSINI_DokoSavePath MsgIni[43] // " どこでもSAVE格納パス"
// [CHECK]
-#define MSINI_CkQuit MsgIni[43] // " 終了時確認 Yes:する No:しない"
-#define MSINI_SaveQuit MsgIni[44] // " 終了時INIファイルを保存 Yes:する No:しない"
+#define MSINI_CkQuit MsgIni[44] // " 終了時確認 Yes:する No:しない"
+#define MSINI_SaveQuit MsgIni[45] // " 終了時INIファイルを保存 Yes:する No:しない"
// [KEY]
-#define MSINI_KeyRepeat MsgIni[45] // " キーリピートの間隔(単位:ms 0で無効)"
+#define MSINI_KeyRepeat MsgIni[46] // " キーリピートの間隔(単位:ms 0で無効)"
// [OPTION]
-#define MSINI_UseSoldier MsgIni[46] // " 戦士のカートリッジ Yes:有効 No:無効"
+#define MSINI_UseSoldier MsgIni[47] // " 戦士のカートリッジ Yes:有効 No:無効"
// どこでもSAVE用メッセージ ------
diff --git a/src/p6vm.cpp b/src/p6vm.cpp
index ff3e0ce..e1af01c 100644
--- a/src/p6vm.cpp
+++ b/src/p6vm.cpp
@@ -1120,6 +1120,7 @@ bool VM6::Init( CFG6 *cnfg )
cmtl->SetLPF( DEFAULT_TAPELPF ); // ローパスフィルタ カットオフ周波数設定
cmtl->SetBoost( cnfg->GetBoostUp() );
cmtl->SetMaxBoost( cnfg->GetMaxBoost1(), cnfg->GetMaxBoost2() );
+ cmtl->SetStopBit( cnfg->GetStopBit() ); // テープストップビット数
// CMT(SAVE) -----
if( !cmts->Init( cnfg->GetSaveFile() ) ) return false;
diff --git a/src/pc6001v.h b/src/pc6001v.h
index 8d3cbfe..3758617 100644
--- a/src/pc6001v.h
+++ b/src/pc6001v.h
@@ -70,7 +70,8 @@
#define VSYNC_HZ (60) /* VSYNC周波数 */
#define DEFAULT_BAUD (1200) /* CMTボーレート 初期値 */
-#define DEFAULT_CMT_HZ (DEFAULT_BAUD/12) /* CMT割込み周波数 初期値 (1byte -> StartBit:1 + DataBit:8 + StopBit:3 = 12bits とする) */
+#define DEFAULT_CMT_HZ (DEFAULT_BAUD/12) /* XXX FIXME for P6T format */
+#define DEFAULT_STOPBIT (3) /* TAPEストップビット数 初期値 3bit */
//#define DEFAULT_FPS_CNT (true) /* FPSカウンタ true:表示 false:非表示 */
diff --git a/src/tape.cpp b/src/tape.cpp
index 7ca65b9..ca6f8d6 100644
--- a/src/tape.cpp
+++ b/src/tape.cpp
@@ -48,12 +48,18 @@
#define PG_HI (0)
#define PG_LO (1)
+// テープデータ 1バイトあたりのビット数
+#define BitsPerByte() ( 1+8+StopBit )
+// 1秒毎のテープデータ送信バイト数
+#define CMT_hz() ( DEFAULT_BAUD/BitsPerByte() )
+
////////////////////////////////////////////////////////////////
// コンストラクタ
////////////////////////////////////////////////////////////////
CMTL::CMTL( VM6 *vm, const ID& id ) : Device(vm,id),
p6t(NULL), Relay(false), stron(false), Boost(DEFAULT_BOOST),
- MaxBoost60(DEFAULT_MAXBOOST60), MaxBoost62(DEFAULT_MAXBOOST62)
+ MaxBoost60(DEFAULT_MAXBOOST60), MaxBoost62(DEFAULT_MAXBOOST62),
+ StopBit(DEFAULT_STOPBIT)
{
INITARRAY( FilePath, '\0' );
}
@@ -113,7 +119,7 @@ bool CMTL::Remote( bool relay )
// SRはmk2/66と同じにしてみる
int bst = Boost ? ( vm->VdgGetWinSize() ? MaxBoost60 : MaxBoost62 ) : 1;
- if( !vm->EventAdd( this, EID_TAPE, DEFAULT_CMT_HZ * bst, EV_LOOP|EV_HZ ) ) return false;
+ if( !vm->EventAdd( this, EID_TAPE, CMT_hz() * bst, EV_LOOP|EV_HZ ) ) return false;
}else{ // OFF
if( !vm->EventDel( this, EID_TAPE ) ) return false;
}
@@ -322,6 +328,26 @@ bool CMTL::IsBoostUp( void ) const
}
+////////////////////////////////////////////////////////////////
+// テープストップビット数設定
+////////////////////////////////////////////////////////////////
+void CMTL::SetStopBit( int bits )
+{
+ if( StopBit != bits ){
+ StopBit = bits;
+ }
+}
+
+
+////////////////////////////////////////////////////////////////
+// テープストップビット数取得
+////////////////////////////////////////////////////////////////
+int CMTL::GetStopBit( void ) const
+{
+ return StopBit;
+}
+
+
////////////////////////////////////////////////////////////////
// オートスタート情報取得
////////////////////////////////////////////////////////////////
@@ -343,7 +369,7 @@ WORD CMTL::Update( void )
// TAPEイメージオープン?
if( p6t ){
// 1byte分のデータを作る 10ms(基本)
- int length = SndDev::SampleRate / DEFAULT_CMT_HZ;
+ int length = SndDev::SampleRate / CMT_hz();
int bdata;
rd = CmtRead(); // CMT 1文字読込み
@@ -362,9 +388,9 @@ WORD CMTL::Update( void )
case PG_D: // データの場合
// スタートビット 1bit
// データビット 8bits
- // ストップビット 3bits
+ // ストップビット 2-10bits (default:3bits)
- bdata = length/12; // 1bitあたりのデータ数
+ bdata = length/BitsPerByte(); // 1bitあたりのデータ数
// スタートビット
for( int i=0; i<bdata; i++ ){
SndDev::cRing::Put( GetSinCurve( PG_LO ) );
@@ -573,7 +599,8 @@ bool CMTL::DokoSave( cIni *Ini )
Ini->PutEntry( "TAPE", NULL, "Relay", "%s", Relay ? "Yes" : "No" );
Ini->PutEntry( "TAPE", NULL, "BoostUp", "%s", Boost ? "Yes" : "No" );
-
+ Ini->PutEntry( "TAPE", NULL, "StopBit", "%d", StopBit );
+
// TAPEがマウントされてなければ何もしないで戻る
if( !p6t ) return true;
@@ -596,6 +623,7 @@ bool CMTL::DokoLoad( cIni *Ini )
Ini->GetTruth( "TAPE", "Relay", &Relay, Relay );
Ini->GetTruth( "TAPE", "BoostUp", &Boost, Boost );
+ Ini->GetInt( "TAPE", "StopBit", &StopBit, StopBit );
Ini->GetPath( "TAPE", "FilePath", FilePath, "" );
if( *FilePath ){
diff --git a/src/tape.h b/src/tape.h
index 6ceab79..8f1d7f1 100644
--- a/src/tape.h
+++ b/src/tape.h
@@ -27,6 +27,8 @@ private:
bool Boost; // BoostUp使う? true:使う false:使わない
int MaxBoost60; // BoostUp 最大倍率(N60モード)
int MaxBoost62; // BoostUp 最大倍率(N60m/N66モード)
+
+ int StopBit; // テープストップビット数
bool Remote( bool ); // リモート制御(PLAY,STOP)
WORD CmtRead(); // CMT 1文字読込み
@@ -68,6 +70,9 @@ public:
void SetBoost( bool ); // BoostUp設定
void SetMaxBoost( int, int ); // BoostUp最大倍率設定
bool IsBoostUp() const; // BoostUp状態取得
+
+ void SetStopBit( int ); // テープストップビット数設定
+ int GetStopBit() const; // テープストップビット数取得
const P6TAUTOINFO *GetAutoStartInfo() const; // オートスタート情報取得
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment