VOGONS


First post, by fr500

User metadata
Rank Newbie
Rank
Newbie

Hello

Yet another issue with my custom code...
So I have a function that automounts the overlay filesystem here:

https://git.retromods.org/dev/dosbox-svn/blob … bretro.cpp#L206

I call it before the game is run and mostly everything works fine with one exception.
Batch files don't CD into the proper dir.

For instance loading duke 3d I have this batch:

@echo off C: cd \DUKE3D DUKE3D.exe […]
Show full quote

@echo off
C:
cd \DUKE3D
DUKE3D.exe

So if my overlay autload code is enabled I end up with this:
ofUYqNU.png

If it's disabled it works fine.

The kicker is that if it's enabled and I run the bat again manually from the prompt it works.
Now if I load the exe directly.. it all just works fine, saves are redirected and everything...
But I intend this to work properly for eXoDOS sets so I'd like to solve this.

Maybe I'm mounting "too late" or is there any other way.
I was thinking I could populate an autoexec line and install it with InstallBefore instead of the code I'm referencing.
Would that be better/safer?

Reply 1 of 7, by Kisai

User metadata
Rank Member
Rank
Member

Well if it's launching, it's clearly CD'ing in to the directory with the exe, though it looks like it's trying to mount a CD image as C since there's no cfg file being seen.

If the patch itself is something that is applied to the file system, then you need to test that it's completed before trying it. In which case I'm still wondering why you're trying to run "the CD" and not a local file system.

Reply 2 of 7, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

The return prompt might indicate that the CD\DUKE3D line failed. Does that line work ?

Water flows down the stream
How to ask questions the smart way!

Reply 3 of 7, by dreamer_

User metadata
Rank Member
Rank
Member

@fr500 I haven't touched overlay functionality yet, so I am not 100% sure if it's the problem here, but when working on resolving DOSBox imgmount issues in Boxtron, I discovered that DOSBox mount points are very sensitive to commands preceding mounts, current working dir and some parts of UI use case-sensitive paths, even though it is counterintuitive for a DOS emulator (Windows users don't care, as it affects only Linux and Mac users). I suggest trying:

- using `cd DUKE3D` instead of `cd \DUKE3D`
- double-checking that DUKE3D directory and DUKE3D.exe use exact same paths (case-sensitive!) as the files on the actual filesystem

Aside of that, I took a peak in your dosbox-svn Git repo - would you be interested in cooperating with us on dosbox-staging?

| ← Ceci n'est pas une pipe
dosbox-staging

Reply 4 of 7, by fr500

User metadata
Rank Newbie
Rank
Newbie
Qbix wrote:

The return prompt might indicate that the CD\DUKE3D line failed. Does that line work ?

Yes it works, if I run it manually afterwards immediately after the failure.
So maybe as Kisai said mounting is happening too late or at the same time (I run dosbox in a thread of sorts)

I'll have to figure a way to run the mount in a way that it happens right before "call program-name"

dreamer_ wrote:
@fr500 I haven't touched overlay functionality yet, so I am not 100% sure if it's the problem here, but when working on resolvin […]
Show full quote

@fr500 I haven't touched overlay functionality yet, so I am not 100% sure if it's the problem here, but when working on resolving DOSBox imgmount issues in Boxtron, I discovered that DOSBox mount points are very sensitive to commands preceding mounts, current working dir and some parts of UI use case-sensitive paths, even though it is counterintuitive for a DOS emulator (Windows users don't care, as it affects only Linux and Mac users). I suggest trying:

- using `cd DUKE3D` instead of `cd \DUKE3D`
- double-checking that DUKE3D directory and DUKE3D.exe use exact same paths (case-sensitive!) as the files on the actual filesystem

Aside of that, I took a peak in your dosbox-svn Git repo - would you be interested in cooperating with us on dosbox-staging?

Well, actually the whole idea is not touching the batch files that work fine otherwise, but I'll try the changes none-the-less.

Regarding the repo, sure, but in what capacity?, I see you're maintaining a set of branches, patches, etc.
What would be the workflow? I strive to keep my core untouched as much as possible.

Reply 5 of 7, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author
fr500 wrote:
Yes it works, if I run it manually afterwards immediately after the failure. So maybe as Kisai said mounting is happening too la […]
Show full quote
Qbix wrote:

The return prompt might indicate that the CD\DUKE3D line failed. Does that line work ?

Yes it works, if I run it manually afterwards immediately after the failure.
So maybe as Kisai said mounting is happening too late or at the same time (I run dosbox in a thread of sorts)

I'll have to figure a way to run the mount in a way that it happens right before "call program-name"

can you add a pause command before executing the main executable ?
(and check the contents of z:\autoexec.bat)

Water flows down the stream
How to ask questions the smart way!

Reply 7 of 7, by fr500

User metadata
Rank Newbie
Rank
Newbie

Maybe I should try to convert these lines in autoexec commands programatically? I figure that could solve the issue and also prevent me from duplicating this kind of code:

bool mount_overlay_filesystem(char drive, const char* path)
{
Bit16u sizes[4];
Bit8u mediaid;
Bit8u o_error = 0;
std::string str_size;
str_size="512,32,32765,16000";
mediaid=0xF8;
Bit8u bit8size=(Bit8u) sizes[1];

DOS_Drive * overlay;

localDrive* ldp = dynamic_cast<localDrive*>(Drives[drive-'A']);
cdromDrive* cdp = dynamic_cast<cdromDrive*>(Drives[drive-'A']);

if (log_cb)
log_cb(RETRO_LOG_INFO, "[dosbox] mounting %s in %c as overlay\n", path, drive);

struct stat path_stat;

if (stat(path, &path_stat) == 0 && S_ISDIR(path_stat.st_mode))
{
if (log_cb)
log_cb(RETRO_LOG_INFO, "[dosbox] save directory already exists %s\n", path);
}
else
{
if (log_cb)
log_cb(RETRO_LOG_INFO, "[dosbox] creating save directory %s\n", path);
#if (WIN32)
if (mkdir(path) == -1)
#else
if (mkdir(path, 0700) == -1)
#endif
{
if (log_cb)
log_cb(RETRO_LOG_INFO, "[dosbox] error creating save directory %s\n", path);
return false;
}
}
if (!Drives[drive-'A'])
{
if (log_cb)
log_cb(RETRO_LOG_INFO, "[dosbox] base drive %c is not mounted\n", drive);
write_out("No basedrive mounted yet!");
return false;
}

if (!ldp || cdp)
{
if (log_cb)
log_cb(RETRO_LOG_INFO, "[dosbox] base drive %c is not compatible\n", drive);
return false;
}
std::string base = ldp->getBasedir();
overlay = new Overlay_Drive(base.c_str(), path, sizes[0], bit8size, sizes[2], sizes[3], mediaid, o_error);


if (overlay)
{
Show last 36 lines
        if (o_error)
{
if (o_error == 1)
{
if (log_cb)
log_cb(RETRO_LOG_INFO, "[dosbox] can't mix absolute and relative paths");
}
else if (o_error == 2)
{
if (log_cb)
log_cb(RETRO_LOG_INFO, "[dosbox] overlay can't be in the same underlying file system");
}
else
{
if (log_cb)
log_cb(RETRO_LOG_INFO, "[dosbox] something went wrong");
}
delete overlay;
return false;
}
delete Drives[drive-'A'];
Drives[drive-'A'] = 0;
}
else
{
if (log_cb)
log_cb(RETRO_LOG_INFO, "[dosbox] overlay construction failed");
return false;
}
Drives[drive - 'A'] = overlay;
mem_writeb(Real2Phys(dos.tables.mediaid) + (drive-'A') * 9, overlay->GetMediaByte());
std::string label;
label = drive; label += "_OVERLAY";
overlay->dirCache.SetLabel(label.c_str(), false, false);
return true;
}

That said, it would be nice to have functions that wrap mount, imgmount and config commands, it would make it a lot easier for people working in alternate GUIs (excuse me if such helper exist already, I just couldn{t figure it out).
I had to do some wacky stuff to update config varialbes:

bool update_dosbox_variable(std::string section_string, std::string var_string, std::string val_string)
{
bool ret = false;
if (!dosbox_initialiazed)
return false;
else if (compare_dosbox_variable(section_string, var_string, val_string))
return false;

Section* section = control->GetSection(section_string);
Section_prop *secprop = static_cast <Section_prop*>(section);
if (secprop)
{
section->ExecuteDestroy(false);
std::string inputline = var_string + "=" + val_string;
ret = section->HandleInputline(inputline.c_str());
section->ExecuteInit(false);
}
log_cb(RETRO_LOG_INFO, "[dosbox] variable %s::%s updated\n", section_string.c_str(), var_string.c_str(), val_string.c_str());
return ret;
}