VOGONS

Common searches


First post, by merlin128

User metadata
Rank Newbie
Rank
Newbie

I used DOSBox to run Foxpro v2.6 for DOS on a new pc with windows xp.
The application was locking up.. now it works.. however, if I leave the app up all night long.. the next day is still shows the previous date.. the date does not update unless I close the app.. and reopen it..
This causes a problem because the app is scheduled to run reports over the weekend when nobody is here..

is there anyway to get DOSBox to see the date change..

Reply 2 of 35, by jal

User metadata
Rank Oldbie
Rank
Oldbie
Qbix wrote:

code it in. at the moment dosbox doesn't check this.

Shouldn't be that hard? Presumably the app just calls int 21h to check the date, why can't DOSbox return the current date then? Does it cache it somewhere? (Same goes for the RTC.)

JAL

Reply 3 of 35, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

well dosbox it's dos uses the 18.2 hz timer to keep track of the time. (it reads that bios value and converts it).

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

Reply 4 of 35, by merlin128

User metadata
Rank Newbie
Rank
Newbie

I tried the DOSBOX CVS.. this does have a date and time command.. but still. the app only sees the date that it was launched.. when left running overnight it still thinks its the previous day..

Reply 5 of 35, by dvwjr

User metadata
Rank Member
Rank
Member

Probably the best solution would be for you to pay a C coder to modify the DOSBOX v0.65 source to include the functionality you desire. This was a problem with PC/MS-DOS back in the day...

Since you are using DOSBOX for a legacy commercial application written in FoxPro for DOS (v2.60) then you realise that the developers target games, not commercial applications. It would be great if the functionality you desire were already there - but think of this as an opportunity to add to DOSBOX and solve your legacy app problem quite easily.

Here is the technical information you need:

Technical Notes Database […]
Show full quote

Technical Notes Database

TN839C.txt :How does DOS update the Date at Midnight ?
Category :DEBUG TOOLS
Platform :All
Product :TD 2.0

Description:

MIDNIGHT UPDATE: How does DOS update the DATE at Midnight ?
-----------------------------------------------------------
When BIOS detects that it is midnight, it clears out the tick-counter (unsigned long at location 0x40:0x6C) to start a new day and sets the midnight flag (unsigned int at location 0x40:0x70) to 1. The calendar of the PC, however, is maintained by the CLOCK$ device. When one asks DOS for the time or date (i.e. at the DOS prompt or via INT 0x21, Func. 0x2A/0x2Ch), the latter passes the request to the CLOCK$ device. The device uses the BIOS Function 0x1A to fulfill the request. When called upon, BIOS always returns the contents of the midnight flag in register AL and then resets the flag to zero if necessary. The CLOCK$ device verifies the value in register AL after calling BIOS and adjusts the calendar date if necessary. Then DOS merely returns to the user the answer received from the CLOCK$ device.

However, the above scenario has two major loopholes:

(i) What if somebody other than the CLOCK$ device (i.e. Other than DOS) were to call the BIOS function 0x1A just after midnight?

(ii) What if a machine were to remain running but unattended for two days or more with no requests for the date/time being made to DOS?

Both of the above would result in an incorrect date on the computer. In the first case mentioned above, the caller of INT 0x1A will be notified that Midnight just passed by but the calendar will not be updated since the CLOCK$ device is out of the loop.

BIOS does not treat the Midnight Flag as a counter which must be incremented for each midnight passed by. It merely sets the flag to 1 for each midnight passed. Therefore in the second case above, the CLOCK$ device (if eventually called upon) will be unable to properly identify the actual number of midnights gone by.

What are the solutions ?
------------------------
For the first case mentioned above, direct calls to BIOS for the current date/time should be avoided and DOS should be called instead. This is unfortunately easier said than done. For example, applications performing asynchronous processing must constantly monitor the time which is, at best, difficult to do via DOS calls given the non-reentrant nature of the latter.

For the second case mentioned above, one workaround would be to use a TSR which constantly monitors the Midnight Flag. Once the latter is set, a call to DOS for the current Date is made by the TSR after determining that it is safe to do so. This would ensure that the calendar gets updated when the PC is running but left unattended.

What if my TSR makes calls to BIOS INT 0x1A in the background ?
----------------------------------------------------------------
(According to a message posted in the IBMPRO Forum on CIS, there is a commercial utility which sends faxes at regular intervals and uses BIOS to monitor the time ) ?

In this case the TSR may intercept every call to the BIOS INT 0x1A and determine (via the DOS BUSY FLAG ?) whether the call is actually being made via a DOS call [ To be absolutely certain, the TSR could also TRAP INT 21h ] and if the call is not done via DOS, the TSR can verify the Midnight Flag and take appropriate steps by calling DOS if necessary.

NOTE: The current version of the Borland C++' startup code makes a call to the BIOS Interrupt 0x1A. Running a BC++ application just after midnight may prevent the Calendar Date from being properly updated. Users which do not call any of the C/C++ clock() related functions, can safely comment out lines 264-267 from c0.asm and create a new copy of the startup code object if necessary.

Reference:

7/2/98 10:42:13 AM

Source: Borland Developer Network "How does DOS update the Date at Midnight?"

Best of luck,

dvwjr

Reply 6 of 35, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

our timer function (which increases the tick-counter) doesn't take in account (yet) the passing of midnight. Hence the 1 in AL is never set.
Futher our DOS functions which query the time don't use int 1A.
Futher We don't have a CLOCK device.

The smallist (possibly working) solution would be to add the checking of passing after midnight in the timer-tick increase function.
and to make our dos functions which query the time/date check for the passing after midnight.

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

Reply 8 of 35, by jal

User metadata
Rank Oldbie
Rank
Oldbie
ykhwong wrote:

You can change date by using my cvs build. (usage : date [day] [month] [year])
However, that's not exactly an ultimate solution.

Wouldn't it be a lot easier to just read the system time (with e.g. time()), and convert that to the right value (with e.g. localtime()) at the int 21h call, not using the BIOS values? The fact that 'real' DOS does it this way shouldn't stop DOSbox from doing a better job?

JAL

Reply 10 of 35, by DosFreak

User metadata
Rank l33t++
Rank
l33t++

I think this may affect games as well.....I wish I could remember where that post was that mentioned their problem. 🙁

How To Ask Questions The Smart Way
Make your games work offline

Reply 12 of 35, by jal

User metadata
Rank Oldbie
Rank
Oldbie
wd wrote:

> The fact that 'real' DOS does it this way shouldn't stop DOSbox from doing a better job?

It's just that nobody cares about it, so if you want it you got to code it yourself.

I should, if only I had the time to do it...

JAL

Reply 15 of 35, by jal

User metadata
Rank Oldbie
Rank
Oldbie
wd wrote:

> I should, if only I had the time to do it...

That's exactly the point.

Well, I couldn't resist, so I'm working on a patch (enhancement?) that makes changes to the CMOS clock, using an offset to the real time reported by time() and the time set by changing the CMOS clock. Also, the DOS date/time calls then set and retrieve the CMOS clock. Thus, one could set the DOS date/time to any value and it actually works. I'll post it as soon as I have done some thorough bug testing, which may not be before the end of this week...

B.t.w., I noticed the 12h/24h bit is set by DOSbox upon intialization to 24h, but changing it afterwards doesn't change the way the time is reported back. I also fixed that.

JAL

P.S. This should really be in the developers forum...

Reply 17 of 35, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

> Thus, one could set the DOS date/time to any value and it actually works.

That'd be cool, was thinking about using offsets for a set time
function myself, but quite a bunch of functions depend on it.

Reply 18 of 35, by jal

User metadata
Rank Oldbie
Rank
Oldbie
wd wrote:

> Thus, one could set the DOS date/time to any value and it actually works.

That'd be cool, was thinking about using offsets for a set time
function myself, but quite a bunch of functions depend on it.

I'll have to scan the DOSbox sources to see if time() and/or localtime() and alike functions are used for other low-level functions. Do you have any specific functions in mind I should pay special attention to (apart from the DOS int 21h time/date functions)?

JAL

Reply 19 of 35, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Don't know, at the moment the dos time/bios time/cmos time/ticks
are consistent, but i'm not sure in what way they are really dependent
under dos. Maybe the file create times might be a problem (afair
dosbox leaves the current system time set on them).