Skip to content

Commit

Permalink
Merge pull request #139 from bcc2528/master
Browse files Browse the repository at this point in the history
Enable scanline when 15khz screen mode from GUI, and fix frame drops.
  • Loading branch information
captainys authored Jan 3, 2025
2 parents 7cd0b28 + cebeba8 commit 98f8090
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 14 deletions.
12 changes: 7 additions & 5 deletions gui/src/main_gui/profiledlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,16 @@ void ProfileDialog::Make(void)
CPUFreqTxt=AddTextBox(0,FSKEY_NULL,FsGuiTextBox::HORIZONTAL,"CPU Speed (MHz)",4,YSTRUE);
CPUFreqTxt->SetInteger(25);
AddStaticText(0,FSKEY_NULL,"(Too-fast frequency rather slows down VM)",YSFALSE);
FPUBtn=AddTextButton(0,FSKEY_NULL,FSGUI_CHECKBOX,"Enable 80387 FPU",YSFALSE);
RAMSizeTxt=AddTextBox(0,FSKEY_NULL,FsGuiTextBox::HORIZONTAL,"RAM (MB)",4,YSFALSE);
RAMSizeTxt->SetInteger(4);
FPUBtn=AddTextButton(0,FSKEY_NULL,FSGUI_CHECKBOX,"Enable 80387 FPU",YSFALSE);

AddStaticText(0,FSKEY_NULL,"CPU Fidelity:",YSTRUE);
CPUFidelityDrp=AddEmptyDropList(0,FSKEY_NULL,"",8,20,20,YSFALSE);
CPUFidelityDrp->AddString(i486DXCommon::FidelityLevelToStr(i486DXCommon::MID_FIDELITY).c_str(),YSTRUE);
CPUFidelityDrp->AddString(i486DXCommon::FidelityLevelToStr(i486DXCommon::HIGH_FIDELITY).c_str(),YSFALSE);
CPUFidelityHelpBtn=AddTextButton(0,FSKEY_NULL,FSGUI_PUSHBUTTON,"What's this?",YSFALSE);
pretend386DXBtn=AddTextButton(0,FSKEY_NULL,FSGUI_CHECKBOX,"Pretend 80386DX (for TownsOS V2.1 L10 etc.)",YSFALSE);

CDImgBtn=AddTextButton(0,FSKEY_NULL,FSGUI_PUSHBUTTON,"CD Image:",YSTRUE);
CDImgTxt=AddTextBox(0,FSKEY_NULL,FsGuiTextBox::HORIZONTAL,"",nShowPath,YSFALSE);
Expand Down Expand Up @@ -203,9 +204,7 @@ void ProfileDialog::Make(void)
townsTypeDrp->AddString(TownsTypeToStr(TOWNSTYPE_2_HC).c_str(),YSFALSE);
townsTypeDrp->AddString(TownsTypeToStr(TOWNSTYPE_MARTY).c_str(),YSFALSE);


pretend386DXBtn=AddTextButton(0,FSKEY_NULL,FSGUI_CHECKBOX,"Pretend 80386DX",YSFALSE);

scanLineEffectIn15KHzBtn=AddTextButton(0,FSKEY_NULL,FSGUI_CHECKBOX,"Scanline Effect(Only 15khz Screen)",YSFALSE);
damperWireLineBtn=AddTextButton(0,FSKEY_NULL,FSGUI_CHECKBOX,"Render Damper-Wire Line (to make you nostalgic)",YSFALSE);

startUpStateFNameBtn=AddTextButton(0,FSKEY_NULL,FSGUI_PUSHBUTTON,"Load VM State",YSTRUE);
Expand Down Expand Up @@ -1294,6 +1293,7 @@ TownsProfile ProfileDialog::GetProfile(void) const
}


profile.scanLineEffectIn15KHz=(YSTRUE==scanLineEffectIn15KHzBtn->GetCheck());
profile.damperWireLine=(YSTRUE==damperWireLineBtn->GetCheck());
profile.separateProcess=(YSTRUE==separateProcBtn->GetCheck());

Expand Down Expand Up @@ -1535,6 +1535,8 @@ void ProfileDialog::SetProfile(const TownsProfile &profile)
strikeCommanderThrottleAxisDrp->Disable();
}

scanLineEffectIn15KHzBtn->SetCheck(profile.scanLineEffectIn15KHz ? YSTRUE : YSFALSE);

damperWireLineBtn->SetCheck(profile.damperWireLine ? YSTRUE : YSFALSE);

keyboardModeDrp->SelectByString(TownsKeyboardModeToStr(profile.keyboardMode).c_str());
Expand Down Expand Up @@ -1676,7 +1678,7 @@ void ProfileDialog::ExplainCPUFidelity(void)
L"Since High-Fidelity CPU needs to check and handle more exceptions, it is slower than Medium-Fidelity\n"
L"CPU core.\n"
L"\n"
L"Windows 3.1 requires High-Fidelity CPU core.\n",
L"Windows 3.1, Windows 95, Linux, and OSASK requires High-Fidelity CPU core.\n",
L"OK",nullptr);
AttachModalDialog(dlg);
}
1 change: 1 addition & 0 deletions gui/src/main_gui/profiledlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ProfileDialog : public FsGuiDialog

FsGuiButton *ROMDirBtn,*CDImgBtn,*FDImgBtn[TownsProfile::NUM_FDDRIVES],*HDImgBtn[TownsProfile::MAX_NUM_SCSI_DEVICES];
FsGuiButton *FDWriteProtBtn[TownsProfile::NUM_FDDRIVES];
FsGuiButton *scanLineEffectIn15KHzBtn;
FsGuiButton *damperWireLineBtn;
FsGuiTextBox *ROMDirTxt,*CDImgTxt,*FDImgTxt[TownsProfile::NUM_FDDRIVES],*HDImgTxt[TownsProfile::MAX_NUM_SCSI_DEVICES];
FsGuiDropList *CDSpeedDrp;
Expand Down
16 changes: 16 additions & 0 deletions gui/src/profile/townsprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ std::vector <std::string> TownsProfile::Serialize(void) const
sstream << "DAMPWIRE " << (damperWireLine ? 1 : 0);
text.push_back(sstream.str());

sstream.str("");
sstream << "SCANLINE15K " << (scanLineEffectIn15KHz ? 1 : 0);
text.push_back(sstream.str());

for(auto vk : virtualKeys)
{
if(""!=vk.townsKey && 0<=vk.physicalId)
Expand Down Expand Up @@ -706,6 +710,13 @@ bool TownsProfile::Deserialize(const std::vector <std::string> &text)
damperWireLine=(0!=argv[1].Atoi());
}
}
else if (0 == argv[0].STRCMP("SCANLINE15K"))
{
if(2<=argv.size())
{
scanLineEffectIn15KHz=(0!=argv[1].Atoi());
}
}
else if(0==argv[0].STRCMP("FMVOLUME"))
{
if(2<=argv.size())
Expand Down Expand Up @@ -1083,6 +1094,11 @@ std::vector <std::string> TownsProfile::MakeArgv(void) const
argv.push_back("-DAMPERWIRELINE");
}

if(true==scanLineEffectIn15KHz)
{
argv.push_back("-SCANLINE15K");
}

for(auto vk : virtualKeys)
{
if(0<=vk.physicalId && ""!=vk.townsKey)
Expand Down
2 changes: 1 addition & 1 deletion src/towns/crtc/crtc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ bool TownsCRTC::InHSYNC(const unsigned long long int townsTime) const
bool TownsCRTC::First1msOfVerticalPeriod(const unsigned long long int townsTime) const
{
unsigned int intoFrame=((unsigned long long)townsTime)%VSYNC_CYCLE;
return intoFrame<1000000;
return 1000000<intoFrame;
}

bool TownsCRTC::InSinglePageMode(void) const
Expand Down
11 changes: 5 additions & 6 deletions src/towns/render/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,14 @@ void TownsRender::BuildImage(const unsigned char VRAM[],const TownsCRTC::AnalogP

if(true==scanLineEffectIn15KHz && 15==frequency)
{
auto dy=((scanLineCounter++)&2)>>1;
for(int y=0; y+dy<hei; y+=2)
for(int y=0; y<hei; y+=2)
{
auto linePtr=rgba.data()+(y+dy)*wid*4;
auto linePtr=rgba.data()+y*wid*4;
for(int x=0; x<wid; ++x)
{
linePtr[0]=(unsigned char)((unsigned int)linePtr[0]*7/8);
linePtr[1]=(unsigned char)((unsigned int)linePtr[1]*7/8);
linePtr[2]=(unsigned char)((unsigned int)linePtr[2]*7/8);
linePtr[0]=(unsigned char)((unsigned int)(linePtr[0]>>3)*4.7);
linePtr[1]=(unsigned char)((unsigned int)(linePtr[1]>>3)*4.7);
linePtr[2]=(unsigned char)((unsigned int)(linePtr[2]>>3)*4.7);
linePtr+=4;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/towns/townsthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ void TownsThread::VMMainLoopTemplate(
}
break;
}

CheckRenderingTimer(*townsPtr,*window,outside_world->ImageNeedsFlip());
}
}
townsPtr->ProcessSound(outside_world);
townsPtr->cdrom.UpdateCDDAState(townsPtr->state.townsTime);

CheckRenderingTimer(*townsPtr,*window,outside_world->ImageNeedsFlip());

outside_world->ProcessAppSpecific(*townsPtr);
if(townsPtr->state.nextDevicePollingTime<townsPtr->state.townsTime)
{
Expand Down

0 comments on commit 98f8090

Please sign in to comment.