Skip to content

Commit

Permalink
Mouse Integration for Operation Wolf.
Browse files Browse the repository at this point in the history
  • Loading branch information
captainys committed Jan 26, 2021
1 parent f74a60b commit 31a88da
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 6 deletions.
1 change: 1 addition & 0 deletions gui/src/main_gui/profiledlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ void ProfileDialog::Make(void)
appSpecificAugDrp->AddString(TownsAppToStr(TOWNS_APPSPECIFIC_AMARANTH3).c_str(),YSFALSE);
appSpecificAugDrp->AddString(TownsAppToStr(TOWNS_APPSPECIFIC_LEMMINGS).c_str(),YSFALSE);
appSpecificAugDrp->AddString(TownsAppToStr(TOWNS_APPSPECIFIC_LEMMINGS2).c_str(),YSFALSE);
appSpecificAugDrp->AddString(TownsAppToStr(TOWNS_APPSPECIFIC_OPERATIONWOLF).c_str(),YSFALSE);
appSpecificAugDrp->AddString(TownsAppToStr(TOWNS_APPSPECIFIC_STRIKECOMMANDER).c_str(),YSFALSE);
appSpecificAugDrp->AddString(TownsAppToStr(TOWNS_APPSPECIFIC_SUPERDAISEN).c_str(),YSFALSE);
appSpecificAugDrp->AddString(TownsAppToStr(TOWNS_APPSPECIFIC_ULTIMAUNDERWORLD).c_str(),YSFALSE);
Expand Down
12 changes: 11 additions & 1 deletion scripts/RUN2F.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,20 @@ def ExeExtension():
return ""



def TsugaruExe():
if os.path.isfile("./main_cui/Tsugaru_CUI"+ExeExtension()):
return "./main_cui/Tsugaru_CUI"+ExeExtension()
if os.path.isfile("./main_cui/Release/Tsugaru_CUI"+ExeExtension()):
return "./main_cui/Release/Tsugaru_CUI"+ExeExtension()
throw



def Run(argv):
os.chdir(BUILDDIR)
subprocess.Popen([
"./main_cui/Tsugaru_CUI"+ExeExtension(),
TsugaruExe(),
ROMDIR,
"-SYM",
"../symtables/RUN"+TOWNSTYPE+".txt",
Expand Down
23 changes: 23 additions & 0 deletions scripts/buildgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@


def Run():
if True!=os.path.isdir(PUBLICSRCDIR):
os.chdir(SRCDIR)
proc=subprocess.Popen([
"git","clone","https://github.com/captainys/public.git"
])
proc.communicate();
if proc.returncode!=0:
print("Build Error! (git clone)")
quit()

os.chdir(PUBLICSRCDIR)
proc=subprocess.Popen([
"git","pull"
Expand All @@ -21,6 +31,19 @@ def Run():
print("Build Error! (git pull)")
quit()

if True!=os.path.isdir(BUILDDIR):
os.mkdir(BUILDDIR)

if True!=os.path.isfile(os.path.join(BUILDDIR,"CMakeCache.txt")):
os.chdir(BUILDDIR)
proc=subprocess.Popen([
"cmake","../src","-DCMAKE_BUILD_TYPE=Release"
])
proc.communicate();
if proc.returncode!=0:
print("CMake Error!")
quit()

os.chdir(BUILDDIR)
proc=subprocess.Popen([
"cmake","--build",".","--config","Release","--target","Tsugaru_GUI"
Expand Down
28 changes: 25 additions & 3 deletions scripts/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,32 @@ def ExeExtension():
return ""


def TsugaruCUIExe():
relpath=os.path.join(BUILDDIR,"main_cui","Tsugaru_CUI"+ExeExtension())
if os.path.isfile(relpath):
return relpath;
relpath=os.path.join(BUILDDIR,"main_cui","Release","Tsugaru_CUI"+ExeExtension())
if os.path.isfile(relpath):
return relpath;
raise


def GUISubdir():
subdir=os.path.join(BUILDGUIDIR,"main_gui")
ful=os.path.join(subdir,"Tsugaru_GUI"+ExeExtension())
if os.path.isfile(ful):
return subdir;
subdir=os.path.join(BUILDGUIDIR,"main_gui","Release")
ful=os.path.join(subdir,"Tsugaru_GUI"+ExeExtension())
if os.path.isfile(ful):
return subdir;
raise


def Run(argv):
os.chdir(BUILDGUIDIR)
subprocess.Popen([
"./main_gui/Tsugaru_GUI"+ExeExtension()
os.path.join(GUISubdir(),"Tsugaru_GUI"+ExeExtension())
]+argv).wait()


Expand All @@ -34,7 +56,7 @@ def Run(argv):
build.Run()
buildgui.Run()
shutil.copyfile(
os.path.join(BUILDDIR,"main_cui","Tsugaru_CUI"+ExeExtension()),
os.path.join(BUILDGUIDIR,"main_gui","Tsugaru_CUI"+ExeExtension())
TsugaruCUIExe(),
os.path.join(GUISubdir(),"Tsugaru_CUI"+ExeExtension())
)
Run(sys.argv[1:])
31 changes: 29 additions & 2 deletions src/towns/tbiosid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,19 @@ void FMTowns::OnCRTC_HST_Write(void)
std::cout << " MousePointerY Physical Base=" << cpputil::Uitox(state.appSpecific_MousePtrY) << std::endl;
}
break;
case TOWNS_APPSPECIFIC_OPERATIONWOLF:
{
i486DX::SegmentRegister DS;
unsigned int exceptionType,exceptionCode;
cpu.DebugLoadSegmentRegister(DS,0x0014,mem,false);

state.appSpecific_MousePtrX=cpu.LinearAddressToPhysicalAddress(exceptionType,exceptionCode,DS.baseLinearAddr+0x5E420,mem);
state.appSpecific_MousePtrY=cpu.LinearAddressToPhysicalAddress(exceptionType,exceptionCode,DS.baseLinearAddr+0x5E422,mem);

std::cout << " MousePointerX Physical Base=" << cpputil::Uitox(state.appSpecific_MousePtrX) << std::endl;
std::cout << " MousePointerY Physical Base=" << cpputil::Uitox(state.appSpecific_MousePtrY) << std::endl;
}
break;
case TOWNS_APPSPECIFIC_STRIKECOMMANDER:
{
i486DX::SegmentRegister DS;
Expand Down Expand Up @@ -601,8 +614,14 @@ bool FMTowns::ControlMouse(int &diffX,int &diffY,int hostMouseX,int hostMouseY,u
diffY/=8;
}

auto dx=ScaleStep(ClampStep(diffX),state.mouseIntegrationSpeed);
auto dy=ScaleStep(ClampStep(diffY),state.mouseIntegrationSpeed);
int speed=state.mouseIntegrationSpeed;
if(TOWNS_APPSPECIFIC_OPERATIONWOLF==state.appSpecificSetting)
{
speed*=2;
}

auto dx=ScaleStep(ClampStep(diffX),speed);
auto dy=ScaleStep(ClampStep(diffY),speed);
if(-slowDownRange<=dx && dx<=slowDownRange)
{
if(dx<0)
Expand Down Expand Up @@ -912,6 +931,14 @@ bool FMTowns::GetMouseCoordinate(int &mx,int &my,unsigned int tbiosid) const
debugger.stop=debugStop;
}
return true;
case TOWNS_APPSPECIFIC_OPERATIONWOLF:
{
auto debugStop=debugger.stop; // FetchWord may break due to MEMR.
mx=(int)mem.FetchWord(state.appSpecific_MousePtrX);
my=(int)mem.FetchWord(state.appSpecific_MousePtrY);
debugger.stop=debugStop;
}
return true;
case TOWNS_APPSPECIFIC_AMARANTH3:
{
// Observed:
Expand Down
6 changes: 6 additions & 0 deletions src/towns/townsdef/townsdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,10 @@ unsigned int TownsStrToApp(std::string str)
{
return TOWNS_APPSPECIFIC_ULTIMAUNDERWORLD;
}
if("OPERATIONWOLF"==str || "OPERATION_WOLF"==str)
{
return TOWNS_APPSPECIFIC_OPERATIONWOLF;
}
return TOWNS_APPSPECIFIC_NONE;
}
std::string TownsAppToStr(unsigned int i)
Expand All @@ -582,6 +586,8 @@ std::string TownsAppToStr(unsigned int i)
return "AMARANTH3";
case TOWNS_APPSPECIFIC_ULTIMAUNDERWORLD:
return "ULTIMAUNDERWORLD";
case TOWNS_APPSPECIFIC_OPERATIONWOLF:
return "OPERATIONWOLF";
}
}

Expand Down
1 change: 1 addition & 0 deletions src/towns/townsdef/townsdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ enum
TOWNS_APPSPECIFIC_STRIKECOMMANDER,
TOWNS_APPSPECIFIC_AMARANTH3,
TOWNS_APPSPECIFIC_ULTIMAUNDERWORLD,
TOWNS_APPSPECIFIC_OPERATIONWOLF,
};

#ifdef __cplusplus
Expand Down

0 comments on commit 31a88da

Please sign in to comment.