forked from n5ac/mmsstv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
14464 lines (14054 loc) · 401 KB
/
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//Copyright+LGPL
//-----------------------------------------------------------------------------------------------------------------------------------------------
// Copyright 2000-2013 Makoto Mori, Nobuyuki Oba
//-----------------------------------------------------------------------------------------------------------------------------------------------
// This file is part of MMSSTV.
// MMSSTV is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
// MMSSTV is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public License along with MMTTY. If not, see
// <http://www.gnu.org/licenses/>.
//-----------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <SHELLAPI.H>
#include <io.h>
#include "Clipbrd.hpp"
#include "Main.h"
#include "Scope.h"
#include "PlayDlg.h"
#include "Option.h"
#include "LogFile.h"
#include "LogList.h"
#include "LogConv.h"
#include "LogLink.h"
#include "country.h"
#include "Qsodlg.h"
#include "Mmcg.h"
#include "VerDsp.h"
#include "LogSet.h"
#include "PicRect.h"
#include "ZoomView.h"
#include "TextEdit.h"
#include "ListText.h"
#include "PicFilte.h"
#include "ExtCmd.h"
#include "PerSpect.h"
#include "RepSet.h"
#include "MmcgDlg.h"
#include "radioset.h"
#include "RMenuDlg.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TMmsstv *Mmsstv;
#define MEASCWSPEED FALSE
#define FSKIDMAX 32
//ウインドウメッセージのハンドラ---------------------------------------------
void __fastcall TMmsstv::WndProc(TMessage &Message)
{
switch(Message.Msg){
case WM_COPYDATA:
WndCopyData(Message);
break;
default:
TForm::WndProc(Message);
break;
}
}
//---------------------------------------------------------------------------
// WM_COPYDATAの処理
void __fastcall TMmsstv::WndCopyData(TMessage &Message)
{
COPYDATASTRUCT *cp = (COPYDATASTRUCT *)Message.LParam;
if( LogLink.IsCopyData() ){
Message.Result = LogLink.m_pLink->OnCopyData(HWND(Message.WParam), cp);
return;
}
switch(cp->dwData){
case 0:
case 1: // Hamlogからの返信
if( sys.m_LogLink != 1 ) return;
switch(LogLink.AnaData(&Log.m_sd, cp)){
case 115:
UpdateTextData();
break;
case 106:
LogFreq->Text = Log.GetFreqString(Log.m_sd.band, Log.m_sd.fq);
break;
}
Message.Result = TRUE;
break;
case 0x80001212: // 周波数データの指定
if( cp->cbData && (cp->lpData != NULL) ){
char bf[16];
int len = cp->cbData;
if( len > 15 ) len = 15;
memcpy(bf, cp->lpData, len);
bf[len] = 0;
LogFreq->Text = bf;
}
Message.Result = TRUE;
break;
case 0x80001213: // クリップボードからのロード
KESClick(NULL);
Message.Result = TRUE;
break;
case 0x80001214: // 画像サイズの問い合わせ
Message.Result = m_TXW + (m_TXH << 16);
break;
case 0x80001215: // 履歴画像のコピー
SBCopyClick(NULL);
Message.Result = TRUE;
break;
case 0x80001216: // 受信画像のコピー
KERClick(NULL);
Message.Result = TRUE;
break;
case 0x80001217: // 送信/受信の切り替え
if( cp->cbData && (cp->lpData != NULL) ){
if( *(const BYTE *)(cp->lpData) ){
if( !SBTX->Down ){
AdjustPage(pgTX);
ToTX();
}
}
else if( SBTX->Down ){
ToRX();
}
}
Message.Result = TRUE;
break;
case 0x80001218:
m_ChangeTemp = 1;
SBULog->Enabled = TRUE;
UpdateUI();
Message.Result = TRUE;
break;
case 0x80001219: // REMデータの指定
if( cp->cbData && (cp->lpData != NULL) ){
EditNote->Text = (LPCSTR)cp->lpData;
EditNoteChange(NULL);
}
Message.Result = TRUE;
break;
case 0x8000121a: // PTT
if( cp->cbData && (cp->lpData != NULL) ){
BOOL bPTT = *(const BYTE *)(cp->lpData);
if( pRadio != NULL ) pRadio->SetPTT(bPTT);
if( pComm != NULL ) pComm->SetPTT(bPTT);
}
break;
case 0x8000121b: // status
{
DWORD dw = SBTX->Down ? 1 : 0;
dw |= SBTune->Down ? 2 : 0;
dw |= pDem->m_Sync ? 4 : 0;
Message.Result = dw;
}
break;
default:
Message.Result = FALSE;
break;
}
}
//---------------------------------------------------------------------------
void __fastcall TMmsstv::OnMSG(tagMSG &Msg, bool &Handled)
{
/*
Msg.hwnd := Handle;
Msg.message := WM_KEYDOWN;
Msg.wParam := Message.WParam;
Msg.lParam := Message.LParam;
*/
if( Msg.message != WM_DROPFILES ) return;
DropFile(Msg);
Handled = true;
}
//---------------------------------------------------------------------------
void __fastcall TMmsstv::OnMini(TObject *Sender)
{
if( pSound != NULL ){
if( pSound->m_susp ){
pSound->m_susp = 1;
}
}
}
//---------------------------------------------------------------------------
// アプリケーション例外
void __fastcall TMmsstv::AppException(TObject *Sender, Exception *E)
{
if( m_AppErr < 3 ){
m_AppErr++;
ErrorMB(MsgEng?
"The indistinct error was detected.":
"原因不明のエラーが発生しました."
);
}
ResDisPaint();
}
//---------------------------------------------------------------------------
__fastcall TMmsstv::TMmsstv(TComponent* Owner)
: TForm(Owner)
{
::VirtualLock(this, sizeof(TMmsstv));
::VirtualLock(&sys, sizeof(sys));
m_AppErr = 0;
m_InitFirst = TRUE;
m_DisEvent = 1;
SampFreq = 11025.0;
pDraw = NULL;
pPaste = NULL;
pRxView = NULL;
pSyncView = NULL;
pHistView = NULL;
pPreView = NULL;
pCalibration = NULL;
pUndo = NULL;
pCtrBtn = NULL;
pStockView = NULL;
pWaterView = NULL;
pLogView = NULL;
int i;
for( i = 0; i < 8; i++ ){
pFileView[i] = NULL;
}
m_TimerRXV = 0;
m_TimerRXS = 0;
m_FileViewClose = 0;
m_ClientHeight[0] = m_ClientHeight[1] = 0;
m_ClientWidth[0] = m_ClientWidth[1] = 0;
m_SpecDown = 0;
m_dwVersion = ::GetVersion();
if( m_dwVersion < 0x80000000 ){
WinNT = TRUE; // NT,2000,XP,Vista
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
if (osvi.dwMajorVersion == 5) {
WinVista=FALSE;
}
else {
WinVista=TRUE;
}
}
else { // win95/98/ME
WinNT = FALSE;
WinVista=FALSE;
}
#if 0
// Get major and minor version numbers of Windows
dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwWindowsMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
// Get build numbers for Windows NT or Win32s
if (dwVersion < 0x80000000) // Windows NT
dwBuild = (DWORD)(HIWORD(dwVersion));
else if (dwWindowsMajorVersion < 4) // Win32s
dwBuild = (DWORD)(HIWORD(dwVersion) & ~0x8000);
else // Windows 95 -- No build numbers provided
dwBuild = 0;
#endif
InitFFT();
EntryAlign();
lcid = GetThreadLocale() & 0x00ff;
if( lcid != LANG_JAPANESE ){ // English
sys.m_WinFontName = "Times New Roman";
sys.m_WinFontCharset = ANSI_CHARSET;
Log.m_LogSet.m_TimeZone = 'Z';
sys.m_LogLink = 0;
MsgEng = 1;
}
else { // Japanese
sys.m_WinFontName = "MS Pゴシック";
sys.m_WinFontCharset = SHIFTJIS_CHARSET;
sys.m_LogLink = 1;
MsgEng = 0;
}
SetMBCP();
sys.m_WinFontStyle = 0;
LogLink.SetHandle(Handle, CM_CMML);
sys.m_BitPixel = ::GetDeviceCaps(Canvas->Handle, BITSPIXEL);
sys.m_Palette = sys.m_BitPixel < 16 ? 1 : 0;
sys.m_DivMode = 0;
sys.m_UseB24 = 0;
sys.m_DisFontSmooth = WinNT;
sys.m_TempDelay = 3;
pBitmapNearest = NULL;
if( sys.m_BitPixel < 24 ){
pBitmapNearest = new Graphics::TBitmap;
pBitmapNearest->Width = 1;
pBitmapNearest->Height = 1;
}
pBitmapFFT = new Graphics::TBitmap();
pBitmapFFT->Width = PBoxFFT->Width;
pBitmapFFT->Height = PBoxFFT->Height;
pBitmapWater = new Graphics::TBitmap();
pBitmapWater->PixelFormat = pf24bit;
pBitmapWater->Width = PBoxWater->Width;
pBitmapWater->Height = PBoxWater->Height;
PBoxRX->Width = 320;
PBoxRX->Height = 256;
PBoxHist->Width = 320;
PBoxHist->Height = 256;
PBoxTX->Width = 320;
PBoxTX->Height = 256;
PBoxTemp->Width = 320;
PBoxTemp->Height = 256;
pBitmapSS = NULL;
for( i = 0; i < STOCKPAGE; i++ ){
pBitmapST[i] = NULL;
}
m_TXW = m_RXW = 320; m_TXH = m_TXPH = m_RXH = m_RXPH = 256;
m_SMax = 6;
pBitmapD12 = CreateBitmap(PBoxD12->Width, PBoxD12->Height, pf24bit);
pBitmapLvl = new Graphics::TBitmap();
pBitmapLvl->Width = PBoxLvl->Width;
pBitmapLvl->Height = PBoxLvl->Height;
SBDPaste->Glyph->Assign(SBPaste->Glyph);
SBRView->Glyph->Assign(SBHView->Glyph);
SBTView->Glyph->Assign(SBHView->Glyph);
SBTXFil->Glyph->Assign(SBHistFil->Glyph);
SBRXFil->Glyph->Assign(SBHistFil->Glyph);
m_Slant = 0;
// m_Timer1S = 0;
m_DSEL = 0;
m_Dupe = 0;
m_DrawTrans = 0;
// m_DrawCmd = -1;
m_DrawCmd = CM_SELECT;
SBDSel->Down = TRUE;
m_DragNo = 0;
m_DragDataNo = 0;
m_DragPMax = 50;
m_TxSPage = -1;
m_PSPage = m_APSPage = 0;
for( i = 0; i < STOCKPAGE; i++ ){
m_TSPage[i] = m_ATSPage[i] = 0;
}
m_ReqSampChg = 0;
m_TuneTimer = 0;
m_pRowBuf = NULL;
m_ReqHistF = 0;
m_SyncAccuracy = 1;
m_TempTimer = 0;
m_TempHold = 0;
m_SuspMinimized = 0;
InitProfile();
for( i = 0; i < 9; i++ ){
m_ModeAssignTX[i] = m_ModeAssignRX[i] = i;
}
for( i = 0; i < 8; i++ ){
sys.m_ExtMode[i] = 0;
sys.m_ExtName[i] = "";
sys.m_ExtCmd[i] = "";
}
char bf[256];
::GetWindowsDirectory(bf, sizeof(bf));
char drv = bf[0];
sprintf(bf, "%c:\\Program Files\\SSTV-PAL\\SSTV-Pal.exe", drv);
sys.m_ExtName[0] = "SSTV-PAL";
sys.m_ExtCmd[0] = bf;
sys.m_ExtMode[0] = 1;
sprintf(bf, "%c:\\Program Files\\MMTTY\\MMTTY.EXE", drv);
if( !IsFile(bf) ){
sprintf(bf, "%c:\\MMTTY\\MMTTY.EXE", drv);
}
sys.m_ExtName[7] = "MMTTY";
sys.m_ExtCmd[7] = bf;
sys.m_ExtMode[7] = 2;
pComm = NULL;
pRadio = NULL;
#if 1
StartOption();
#else
if( ParamCount() >= 0 ){
SetDirName(BgnDir, ParamStr(0).c_str());
}
else {
SetCurDir(BgnDir, sizeof(BgnDir));
}
strcpy(BitmapDir, BgnDir);
strcpy(SBitmapDir, BgnDir);
strcpy(TemplateDir, BgnDir);
strcpy(RecDir, BgnDir);
strcpy(ExtLogDir, BgnDir);
sprintf(HistDir, "%sHistory\\", BgnDir);
sprintf(StockDir, "%sStock\\", BgnDir);
#endif
Caption = VERTTL2;
InitSampType();
InitCOMMPara();
InitRADIOPara();
sys.m_Priority = 0;
sys.m_SoundFifoRX = 12;
sys.m_SoundFifoTX = 8;
sys.m_SoundPriority = 1;
sys.m_SoundDevice = "-1";
sys.m_SoundStereo = 0;
sys.m_StereoTX = 0;
sys.m_FFTType = 2;
sys.m_FFTGain = 5;
sys.m_FFTResp = 0;
sys.m_FFTStg = 1;
sys.m_FFTAGC = 1;
sys.m_FFTWidth = 1;
sys.m_FFTPriority = 0;
sys.m_Call = "NOCALL";
sys.m_TxRxName = "NONE";
sys.m_TxRxLock = 1;
sys.m_RTSonRX = 0;
sys.m_ColorLow = clBlack;
sys.m_ColorHigh = clWhite;
sys.m_ColorFFTB = TColor(4227327);
sys.m_ColorFFT = clYellow;
sys.m_ColorFFTStg = clBlue;
sys.m_ColorFFTSync = clLime;
sys.m_ColorFFTFreq = clYellow;
sys.m_LogName = "Temp.mdt";
sys.m_WindowState = wsNormal;
sys.m_TestDem = 0;
sys.m_TuneTXTime = -1;
sys.m_TuneSat = 0;
sys.m_ColorRXB = clWhite;
sys.m_HDDSize = 2;
sys.m_VOX = 0;
// sys.m_VOXSound = "1100,300,1500,100,1900,200,1500,200";
sys.m_VOXSound = "1500,100,1700,100,2300,100,2100,100,1900,100,1500,100";
sys.m_Sharp2D = 0;
sys.m_Differentiator = 0;
sys.m_DiffLevelP = 1.0;
sys.m_DiffLevelM = sys.m_DiffLevelP / 3;
sys.m_ColText[0] = TColor(255);
sys.m_ColText[1] = TColor(16711935);
sys.m_ColText[2] = TColor(65535);
sys.m_ColText[3] = TColor(16776960);
sys.m_ColText[4] = clBlack;
sys.m_ColText[5] = clBlack;
sys.m_TextGrade = 0;
sys.m_TextShadow = 2;
sys.m_TextZero = 0;
sys.m_TextRot = 0;
sys.m_TextVert = 0;
sys.m_TextVertH = -6;
sys.m_TextStack = 0x0000fc04;
sys.m_PicShape = 0;
sys.m_PicAdjust = 0;
sys.m_PicLineStyle = 5;
sys.m_PicLineColor = clWhite;
sys.m_ColBar[0] = clBlack;
sys.m_ColBar[1] = TColor(0x00f0f0f0);
sys.m_ColBar[2] = clRed;
sys.m_ColBar[3] = clGreen;
sys.m_PicSelCurCol = clWhite;
sys.m_PicSelSmooz = 0;
sys.m_PicSelRTM = 1;
const DWORD _tbl[]={
16776960, 65535, 16711935, 255,
255, 16711935, 65535, 16776960,
12615935, 8454143, 16776960, 65280,
16776960, 4259584, 65535, 16711935,
255, 16711935, 65535, 65280,
255, 4227327, 65535, 16777088,
16776960, 65535, 4227327, 255,
65280, 65535, 33023, 255,
};
for( i = 0; i < 32; i++ ){
sys.m_ColorSet[i] = TColor(_tbl[i]);
}
sys.m_DemOff = 0;
sys.m_DemWhite = 128.0/16384.0;
sys.m_DemBlack = 128.0/16384.0;
sys.m_DemCalibration = 0;
for( i = 0; i < 17; i++ ){
sys.m_Dem17[i] = m_DemPro[8].Dem17[i];
}
sys.m_ShowSizeRX = 0;
sys.m_ShowSizeHist = 0;
sys.m_ShowSizeTX = 0;
sys.m_ShowSizeTemp = 0;
sys.m_ShowSizeStock = 0;
sys.m_PicClipType = 0;
sys.m_PicClipRatio = 1;
sys.m_PicClipMode = 0;
sys.m_PicClipView = 1;
sys.m_PicClipColor = clBlack;
sys.m_Way240 = 1;
sys.m_HistMax = 32;
sys.m_UseRxBuff = 1;
sys.m_AutoStop = 0;
sys.m_AutoSync = 1;
sys.m_CWID = 0;
sys.m_TXFSKID = 0;
sys.m_CWIDSpeed = 10;
sys.m_CWIDWPM = 28;
sys.m_CWIDText = "DE %m";
sys.m_CWIDFreq = 1000;
sys.m_MMVID = "";
sys.m_UseJPEG = 0;
sys.m_JPEGQuality = 80;
sys.m_CWText = "%m";
sys.m_nCWMenu = 7;
sys.m_CWMenu[0] = "QSL 73 TU";
sys.m_CWMenu[1] = "NR? AGN";
sys.m_CWMenu[2] = "QRZ?";
sys.m_CWMenu[3] = "UR %N %N";
sys.m_CWMenu[4] = "%c de %m";
sys.m_CWMenu[5] = "73 TU";
sys.m_CWMenu[6] = "VVV";
sys.m_FixedTxMode = 1;
sys.m_TextList[0] = "CQ SSTV";
sys.m_TextList[1] = "%c";
sys.m_TextList[2] = "ur %r";
sys.m_TextList[3] = "ur %R-%N";
sys.m_TextList[4] = "73";
sys.m_TextList[5] = "de %m";
sys.m_TextList[6] = "%D %tZ";
sys.m_TextList[7] = "%L %u Local";
for( i = 0; i < 4; i++ ) sys.m_RegFont[i].m_Height = 0;
sys.m_Temp24 = TRUE;
sys.m_MaskUserPage = 0;
sys.m_MaskCol1 = clYellow;
sys.m_MaskCol2 = clBlack;
m_nRadioMenu = 5;
m_RadioMenu[0].strTTL = "7.033 LSB (FT847)";
m_RadioMenu[0].strCMD = "\\$0070330001\\w10\\$0000000007\\w10";
m_RadioMenu[1].strTTL = "14.230 USB (FT847)";
m_RadioMenu[1].strCMD = "\\$0142300001\\w10\\$0100000007\\w10";
m_RadioMenu[2].strTTL = "21.340 USB (FT847)";
m_RadioMenu[2].strCMD = "\\$0213400001\\w10\\$0100000007\\w10";
m_RadioMenu[3].strTTL = "28.680 USB (FT847)";
m_RadioMenu[3].strCMD = "\\$0286800001\\w10\\$0100000007\\w10";
m_RadioMenu[4].strTTL = "144.450 USB (FT847)";
m_RadioMenu[4].strCMD = "\\$1444500001\\w10\\$0100000007\\w10";
ReadSampFreq();
pSound = NULL;
pSound = new TSound(TRUE);
pDem = &pSound->SSTVDEM;
pMod = &pSound->SSTVMOD;
pMod->m_vco.SetSampleFreq(sys.m_SampFreq + sys.m_TxSampOff);
pSound->fftIN.m_Handle = Handle;
ReadRegister();
pBitmapRX = CreateBitmap(PBoxRX->Width, PBoxRX->Height, pf24bit);
pBitmapHist = CreateBitmap(PBoxHist->Width, PBoxHist->Height, -1);
pBitmapHistF = pBitmapHist;
pBitmapTemp = CreateBitmap(PBoxTemp->Width, PBoxTemp->Height, -1);
pBitmapTX = CreateBitmap(PBoxTX->Width, PBoxTX->Height, -1);
pBitmapTXM = CreateBitmap(PBoxTX->Width, PBoxTX->Height, -1);
PanelFFT->Color = sys.m_ColorFFTB;
PanelWater->Color = sys.m_ColorLow;
FillBitmap(pBitmapRX, sys.m_ColorRXB);
FillBitmap(pBitmapHist, sys.m_ColorRXB);
sprintf(bf, "%s"HISTNAME, HistDir);
if( !IsFile(bf) ){
strcpy(bf, HistDir);
if( *lastp(bf) == '\\' ) *lastp(bf) = 0;
mkdir(bf);
}
sprintf(bf, "%sCurrent.bmp", StockDir);
if( !IsFile(bf) ){
strcpy(bf, StockDir);
if( *lastp(bf) == '\\' ) *lastp(bf) = 0;
mkdir(bf);
}
UpdateSystemFont();
InitColorTable(sys.m_ColorLow, sys.m_ColorHigh);
DrawFFT(1);
if( KVW->Checked ) DrawWater(1);
UpdateRecentMenu();
UpdateModeBtn();
DispSyncStat();
RxHist.Open();
UpdateHist();
UpdateTxClip();
Application->OnMessage = OnMSG;
Application->OnMinimize = OnMini;
#if !DEBUG
Application->OnException = AppException;
#endif
m_DisEvent = 0;
if( int(WindowState) != sys.m_WindowState ) WindowState = TWindowState(sys.m_WindowState);
pSound->fftIN.m_Handle = Handle;
SBTX->Font->Color = clRed;
sprintf(bf, "%sMmsstv.chm", BgnDir);
if( IsFile(bf) ){
JanHelp = "MMSSTV.CHM";
}
else {
sprintf(bf, "%sMmsstv.hlp", BgnDir);
if( IsFile(bf) ) JanHelp = "MMSSTV.HLP";
}
if( !JanHelp.IsEmpty() ){
TMenuItem *pm = new TMenuItem (this);
sprintf(bf, "MMSSTV &Help (%s)", JanHelp.c_str());
pm->Caption = bf;
pm->OnClick = KHlpMainClick;
KHelp->Insert(0, pm);
}
UpdateProFileMenu();
::DragAcceptFiles(PanelTX->Handle, TRUE);
::DragAcceptFiles(PanelTemp->Handle, TRUE);
m_hClipNext = ::SetClipboardViewer(Handle);
MakeCalibrationTable();
m_FFTWINDOW = (3010 * FFT_SIZE / FFTSamp);
m_OrgTop = Top;
m_OrgLeft = Left;
DivControl(sys.m_DivMode);
m_RepBeaconCount = 0;
m_RepBeaconPos = m_RepTXPos = 0;
if( sys.m_Repeater ) SetBeaconTick();
if( sys.m_Priority ) UpdatePriority();
LoadCurrentTemp();
ChangeTxMode(SSTVSET.m_TxMode);
}
//---------------------------------------------------------------------------
void __fastcall TMmsstv::StartOption(void)
{
AnsiString as;
if( ParamCount() >= 0 ){
as = ParamStr(0).c_str();
SetDirName(BgnDir, as.c_str());
}
else {
SetCurDir(BgnDir, sizeof(BgnDir));
}
strcpy(BitmapDir, BgnDir);
strcpy(SBitmapDir, BgnDir);
strcpy(TemplateDir, BgnDir);
strcpy(MMLogDir, BgnDir);
strcpy(RecDir, BgnDir);
strcpy(ExtLogDir, BgnDir);
sprintf(HistDir, "%sHistory\\", BgnDir);
sprintf(StockDir, "%sStock\\", BgnDir);
sys.m_bCQ100 = FALSE;
g_dblToneOffset = 0.0;
sys.m_Repeater = 0;
for( int i = 0; i <= ParamCount(); i++ ){
as = ParamStr(i);
if( as == "-r" ){
sys.m_Repeater = 1;
}
else if( as == "-i" ){
sys.m_bCQ100 = TRUE;
g_dblToneOffset = -1000.0;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TMmsstv::FormCloseQuery(TObject *Sender, bool &CanClose)
{
Application->OnException = NULL;
::DragAcceptFiles(PanelS->Handle, FALSE); //ja7ude 0521
::DragAcceptFiles(PanelTX->Handle, FALSE); //ja7ude 0521
::ChangeClipboardChain(Handle, m_hClipNext);
if( SBTX->Down ) ToRX();
Timer->Enabled = FALSE;
Application->OnIdle = NULL;
if( pRadio != NULL ){
pRadio->ReqClose();
}
int DivMode = sys.m_DivMode;
KVSDClick(NULL);
DivControl(0);
sys.m_DivMode = DivMode;
KVR->Checked = pRxView != NULL;
if( pRxView != NULL ){
pRxView->GetViewPos(sys.m_RxViewLeft, sys.m_RxViewTop, sys.m_RxViewWidth, sys.m_RxViewHeight);
delete pRxView;
pRxView = NULL;
}
KVS->Checked = pSyncView != NULL;
if( pSyncView != NULL ){
pSyncView->GetViewPos(sys.m_SyncViewLeft, sys.m_SyncViewTop, sys.m_SyncViewWidth, sys.m_SyncViewHeight);
delete pSyncView;
pSyncView = NULL;
}
KVH->Checked = pHistView != NULL;
if( pHistView != NULL ){
CloseHistView();
}
KVC->Checked = pCtrBtn != NULL;
if( pCtrBtn != NULL ){
if( pCtrBtn->SBLock->Down ){
pCtrBtn->SBLock->Down = FALSE;
pCtrBtn->SBLockClick(NULL);
}
pCtrBtn->GetViewPos(sys.m_CtrBtnLeft, sys.m_CtrBtnTop, sys.m_CtrBtnWidth, sys.m_CtrBtnHeight);
delete pCtrBtn;
pCtrBtn = NULL;
}
int i;
for( i = 0; i < 8; i++ ){
if( pFileView[i] != NULL ){
int Flag = (pFileView[i]->Visible || pFileView[i]->m_Suspend) ? pFileView[i]->m_TitleBar ? 1 : 2 : 0;
CloseFileView(i);
sys.m_FileViewFlag[i] = Flag;
}
else {
sys.m_FileViewFlag[i] = 0;
}
}
if( pSound != NULL ){
pSound->ReqStop();
Log.Close();
WriteRegister();
WaveStg.Close();
Log.DoBackup();
}
DeleteUndo();
DrawMain.FreeItem();
DrawText.FreeItem();
DrawPara.FreeItem();
DrawTemp.FreeItem();
delete pBitmapFFT;
pBitmapFFT = NULL;
if( pBitmapWater != NULL ){
delete pBitmapWater;
pBitmapWater = NULL;
}
if( pBitmapSS != NULL ){
delete pBitmapSS;
pBitmapSS = NULL;
}
for( i = 0; i < STOCKPAGE; i++ ){
if( pBitmapST[i] != NULL ){
delete pBitmapST[i];
pBitmapST[i] = NULL;
}
}
delete pBitmapRX;
pBitmapRX = NULL;
if( (pBitmapHistF != NULL) && (pBitmapHistF != pBitmapHist) ){
delete pBitmapHistF;
pBitmapHistF = NULL;
}
delete pBitmapHist;
pBitmapHist = NULL;
delete pBitmapTX;
pBitmapTX = NULL;
delete pBitmapTXM;
pBitmapTXM = NULL;
delete pBitmapTemp;
pBitmapTemp = NULL;
delete pBitmapD12;
pBitmapD12 = NULL;
delete pBitmapLvl;
pBitmapLvl = NULL;
if( pBitmapNearest != NULL ) delete pBitmapNearest;
if( pPaste != NULL ){
delete pPaste;
pPaste = NULL;
}
if( pComm != NULL ){
pComm->SetScan(0);
pComm->Close();
delete pComm;
pComm = NULL;
}
if( pCalibration != NULL ){
delete pCalibration;
pCalibration = NULL;
}
::VirtualUnlock(&sys, sizeof(sys));
::VirtualUnlock(this, sizeof(TMmsstv));
CanClose = TRUE;
}
//---------------------------------------------------------------------------
void __fastcall TMmsstv::FormDestroy(TObject *Sender)
{
if( pSound != NULL ){
pSound->WaitStop();
delete pSound;
pSound = NULL;
}
if( pRadio != NULL ){
pRadio->WaitClose();
delete pRadio;
pRadio = NULL;
}
}
//---------------------------------------------------------------------------
void __fastcall TMmsstv::UpdateToneFreq(void)
{
int fq = pMod->m_TuneFreq;
char bf[128];
sprintf(bf, MsgEng ? "Send %uHz tone" : "%uHzトーンの送信", fq);
SBTune->Hint = bf;
SBTune->Caption = fq;
}
//---------------------------------------------------------------------------
void __fastcall TMmsstv::UpdateSystemFont(void)
{
TFontStyles fsw = Code2FontStyle(sys.m_WinFontStyle);
if( (sys.m_WinFontName != Font->Name)||
(sys.m_WinFontCharset != Font->Charset)||
(fsw != Font->Style)
){
Font->Name = sys.m_WinFontName;
Font->Charset = sys.m_WinFontCharset;
Font->Style = fsw;
GBMode->Font->Name = sys.m_WinFontName;
GBMode->Font->Charset = sys.m_WinFontCharset;
GBMode->Font->Style = fsw;
GB1->Font->Name = sys.m_WinFontName;
GB1->Font->Charset = sys.m_WinFontCharset;
GB1->Font->Style = fsw;
GBLog->Font->Name = sys.m_WinFontName;
GBLog->Font->Charset = sys.m_WinFontCharset;
GBLog->Font->Style = fsw;
AlignPCS.NewFont(sys.m_WinFontName, sys.m_WinFontCharset, fsw);
SBTX->Font->Name = sys.m_WinFontName;
SBTX->Font->Charset = sys.m_WinFontCharset;
SBTX->Font->Style = fsw;
}
if( Font->Charset != SHIFTJIS_CHARSET ){
MsgEng = 1;
KFile->Caption = "&File";
KView->Caption = "&View";
KOpt->Caption = "&Option";
// KExtCmd->Caption = "Program(&P)";
KHelp->Caption = "&Help";
// File Nenu for english
KLogOpen->Caption = "Open &Log file...";
KLogFlush->Caption = "Save data now(&F)";
KFRecTim->Caption = "Record sound to the file with a time stamp(&A)";
KFRec->Caption = "Record sound to the file(&W)...";
KFPlay->Caption = "&Play sound from the file...";
KFPlayPos->Caption = "Play positsion";
KFRecRew->Caption = "Rewind";
KFRecStop->Caption = "Close Record / Play";
KExit->Caption = "Exit MMSSTV(&X)";
KEdit->Caption = "&Edit";
KEC->Caption = "&Copy from history window";
KEE->Caption = "&Edit TX image...";
KER->Caption = "Copy from &RX window";
KEA->Caption = "&Auto copy";
KEP->Caption = "&Paste to TX window...";
KES->Caption = "&Stretch paste to TX window";
KEX->Caption = "Paste via Clipper...";
KEW->Caption = "Handling of 320x240";
KEW1->Caption = "Vertical stretching";
KEW2->Caption = "Auto stretching";
KEW3->Caption = "No stretching";
KEW4->Caption = "Shift picture for the header";
KVR->Caption = "Always show RX viewer";
KVS->Caption = "Always show Sync viewer";
KVH->Caption = "Always show thumbnails of history";
KVF->Caption = "Always show thumbnails of files folder";
KVC->Caption = "Always show control buttons";
KVSD->Caption = "Design";
KVSD1->Caption = "Standard";
KVSD2->Caption = "Separate stock view";
KVSD3->Caption = "Separate all views";
KRCD->Caption = "Child of a desktop window";
KVL->Caption = "Level indicator";
KVLSG->Caption = "Receipt signals";
KVLSY->Caption = "Sync signals";
KVSE1->Caption = "Stock view";
KVSE2->Caption = "Tuning view";
KVSE3->Caption = "Log view";
KS->Caption = "Spectral display";
KSFQ->Caption = "FM demodulator";
KFFTW->Caption = "Spectral display range";
KFFTS->Caption = "Spectral trail";
KFSQ->Caption = "Quick";
KFSS->Caption = "Short";
KFSL->Caption = "Long";
KF->Caption = "Spectral sensitivity";
KR->Caption = "Spectral response";
KRS->Caption = "Slow";
KRM->Caption = "Medium";
KRF->Caption = "Fast";
KFTD->Caption = "Calculation priority";
KFTD1->Caption = "Lower";
KFTD2->Caption = "Normal";
KFTD3->Caption = "A little higher";
KFTD4->Caption = "Higher";
KFTD5->Caption = "Highest";
KOSC->Caption = "&Oscilloscope...";
KVOut->Caption = "Soundcard output level(&V)...";
KVIn->Caption = "Soundcard &Input level...";
KORep->Caption = "Setup repeater...";
KOL->Caption = "Setup &Logging...";
KOM->Caption = "Setup MMSSTV(&O)...";
KP->Caption = "P&Rofiles";
KPDef->Caption = "MMSSTV Default";
KPInit->Caption = "Initialize all menus as MMSSTV default";
KPA->Caption = "Assign profile";
KPD->Caption = "Delete profile";
KX->Caption = "&Program";
KXP->Caption = "MS &Paint";
KXA->Caption = "Assign program";
KXD->Caption = "Delete program";
KXR->Caption = "Restore";
KXS->Caption = "&Suspend";
KXSM->Caption = "Suspend+&Minimize";
KRadio->Caption = "Radio&Command";
KRadioS->Caption = "Edit menu";
KRLoad->Caption = "&Load...";
KRSet->Caption = "&Setup...";
KRadioAdd->Caption = "&Add menu...";
KHlpUp->Caption = "Version-up information...";
KHlpPad->Caption = "Use NotePad";
KHJ->Caption = "JASTA Activity Contest (August)";
KHN->Caption = "NVCG Contest (July)";
KVer->Caption = "Version information(&A)...";
TabSync->Caption = "Sync";
TabRX->Caption = "RX";
TabHist->Caption = "History";
TabTX->Caption = "TX";
TabTemp->Caption = "Template";
SBPhase->Caption = "Phase";
SBSlant->Caption = "Slant";