From mboxrd@z Thu Jan 1 00:00:00 1970 From: James Courtier-Dutton Subject: [Patch] Fix DOS get time function. Date: Fri, 16 Nov 2007 02:56:32 +0000 Message-ID: <473D06E0.1030507@superbug.co.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020904070103040101090507" Return-path: Sender: linux-msdos-owner@vger.kernel.org List-Id: To: linux-msdos@vger.kernel.org This is a multi-part message in MIME format. --------------020904070103040101090507 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, The current DOS INT 21 AH=2C get time function returns incorrect results, and is sometimes hours off. The attached patch fixes the problem. It should patch against DOSBOX 0.72 the (X * 500 / 91) is the same as X * 100 / 18.2 Signed-off-by: James@superbug.co.uk James --------------020904070103040101090507 Content-Type: text/x-patch; name="time-fix.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="time-fix.diff" --- src/dos/dos.cpp.org 2007-11-16 02:46:35.000000000 +0000 +++ src/dos/dos.cpp 2007-11-16 02:54:50.000000000 +0000 @@ -348,8 +348,9 @@ //TODO Get time through bios calls date is fixed { /* Calculate how many miliseconds have passed */ - Bitu ticks=5*mem_readd(BIOS_TIMER); - ticks = ((ticks / 59659u) << 16) + ((ticks % 59659u) << 16) / 59659u; + /* seconds = ticks / 18.2 */ + Bitu ticks=500 * mem_readd(BIOS_TIMER); + ticks = ticks / 91; Bitu seconds=(ticks/100); reg_ch=(Bit8u)(seconds/3600); reg_cl=(Bit8u)((seconds % 3600)/60); --------------020904070103040101090507--