CMOS clock patch (dates not changing when left overnight)

Here you can discuss the development of patches.

Re: DOSBox CMOS clock patch (dates not changing when left overnight)

Postby jal » 2006-8-16 @ 14:10

wd wrote: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).


FCBwrite uses the dos structure's date, I'll change that (probably remove de date-field), otherwise I couldn't find anything. I tested the CMOS clock, it works now, I'll have to check BIOS RTC support (int 1ah), and have DOS int 21h call the BIOS functions. Possibly finished this evening, but more likely next week.


JAL
User avatar
jal
Member
 
Posts: 495
Joined: 2004-1-02 @ 15:30
Location: Amersfoort, Netherlands

Re: DOSBox CMOS clock patch (dates not changing when left overnight)

Postby wd » 2006-8-16 @ 15:47

> otherwise I couldn't find anything.

Well the regular dos file creation functions use fopen on the host level,
and for querying the time (findfirst i think) stat returns that time/date.
If the dos time/date is set (in dosbox) to a different value, this should
maybe modified accordingly. Packers/unpackers use that stuff iirc.
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: DOSBox CMOS clock patch (dates not changing when left overnight)

Postby jal » 2006-8-18 @ 07:21

wd wrote:> otherwise I couldn't find anything.

Well the regular dos file creation functions use fopen on the host level,
and for querying the time (findfirst i think) stat returns that time/date.
If the dos time/date is set (in dosbox) to a different value, this should
maybe modified accordingly. Packers/unpackers use that stuff iirc.


Yes, I agree that may remain problematic, I'll have to look into that. Otherwise, the CMOS and BIOS are done now (a few tests to be performed yet). CMOS RTC is now almost completely emulated, including correct am/pm and non-BCD modes, 'lock' bit (bit 7 of statreg B) and 'update in progress' bit (bit 7 of statreg A). Both reading/writing possible, after writing an offset is kept from UTC to determine 'DOSbox time'.


JAL
User avatar
jal
Member
 
Posts: 495
Joined: 2004-1-02 @ 15:30
Location: Amersfoort, Netherlands

Re: DOSBox CMOS clock patch (dates not changing when left overnight)

Postby jal » 2006-9-12 @ 08:16

Ok, time for a small update. I sent Qbix my alterations to bios.cpp, dos.cpp and cmos.cpp to check. I tested them, though not as extensively as I would like, and everything seems to function fine. I did not alter any routines that use the dos.date field (FCB routines), that's for another exercise. It would be nice to have commandline date/time functions, but unfortunately I have no time to implement that. I included the latest version of the above mentioned files. They are based on the 0.65 sources, not the CVS.


JAL
You do not have the required permissions to view the files attached to this post.
User avatar
jal
Member
 
Posts: 495
Joined: 2004-1-02 @ 15:30
Location: Amersfoort, Netherlands

Re: DOSBox CMOS clock patch (dates not changing when left overnight)

Postby ykhwong » 2006-10-05 @ 05:27

This really slow downs a software that has a clock.
(for example, using a IMS/OPL player)

Code: Select all
static bool RtcUpdateDone ()
{
   while ((ReadCmosByte(0x0a) & 0x80) != 0);
   return true;         // cannot fail in DOSbox
}
ykhwong
Oldbie
 
Posts: 627
Joined: 2004-3-17 @ 15:35

Re: DOSBox CMOS clock patch (dates not changing when left overnight)

Postby jal » 2006-10-05 @ 07:25

ykhwong wrote:This really slow downs a software that has a clock.
(for example, using a IMS/OPL player)

Code: Select all
static bool RtcUpdateDone ()
{
   while ((ReadCmosByte(0x0a) & 0x80) != 0);
   return true;         // cannot fail in DOSbox
}


I'm not entirely sure whether I understand what you mean, can you elaborate a bit more? Do you have specific software in mind?


JAL
User avatar
jal
Member
 
Posts: 495
Joined: 2004-1-02 @ 15:30
Location: Amersfoort, Netherlands

Re: DOSBox CMOS clock patch (dates not changing when left overnight)

Postby ykhwong » 2006-10-05 @ 14:25

I attached a midi software ocplay. Another one is a patch that I applied for cvs .
Run play/ocp10/ocplay.exe in dosbox then move your mouse cursor or play midi file. Mouse cursor stops moving, and playing sound is stuttering every second.
You do not have the required permissions to view the files attached to this post.
Last edited by ykhwong on 2006-10-05 @ 14:56, edited 1 time in total.
ykhwong
Oldbie
 
Posts: 627
Joined: 2004-3-17 @ 15:35

Re: DOSBox CMOS clock patch (dates not changing when left overnight)

Postby h-a-l-9000 » 2006-10-05 @ 14:49

Maybe like this? (didn't test it though)

Code: Select all
static bool RtcUpdateDone ()
{
   while ((ReadCmosByte(0x0a) & 0x80) != 0) CALLBACK_Idle();
   return true;         // cannot fail in DOSbox
}
1+1=10
h-a-l-9000
DOSBox Author
 
Posts: 4512
Joined: 2005-2-23 @ 00:14

Re: DOSBox CMOS clock patch (dates not changing when left overnight)

Postby ykhwong » 2006-10-05 @ 15:22

That fixes the bug. I will do more tests.
[EDIT] There's no problem playing song,
but the song graph is being drawn intermittently.
ykhwong
Oldbie
 
Posts: 627
Joined: 2004-3-17 @ 15:35

Re: DOSBox CMOS clock patch (dates not changing when left overnight)

Postby jal » 2006-10-10 @ 12:11

ykhwong wrote:That fixes the bug. I will do more tests.
[EDIT] There's no problem playing song,
but the song graph is being drawn intermittently.


Thank you for looking at it. I'll await Qbix final verdict :).


JAL
User avatar
jal
Member
 
Posts: 495
Joined: 2004-1-02 @ 15:30
Location: Amersfoort, Netherlands

Re: CMOS clock patch (dates not changing when left overnight)

Postby Sleepwalker » 2007-9-30 @ 14:44

Has this patch been incorporated in the current (or any) releases? I am currently using .72, and I am having problems similar to other users in this thread.

Thanks!
Sleepwalker
Newbie
 
Posts: 1
Joined: 2007-9-30 @ 14:37

Re: CMOS clock patch (dates not changing when left overnight)

Postby wd » 2007-9-30 @ 16:25

nope
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: CMOS clock patch (dates not changing when left overnight)

Postby jal » 2007-10-01 @ 09:10

wd wrote:nope


Heh, I almost forgot I've made that one. My only contribution to DOSbox, never to be incorporated :). O well, I had fun making it.


JAL
User avatar
jal
Member
 
Posts: 495
Joined: 2004-1-02 @ 15:30
Location: Amersfoort, Netherlands

Re: CMOS clock patch (dates not changing when left overnight)

Postby SocietalEclipse » 2007-11-25 @ 12:51

Syndicate Wars:
Research progress is accomplished through two time measurements:
1. The amount of time taken to accomplish a mission and
2. Your computer's internal clock.
That is, once your computer's internal clock strikes 12 o'clock, a new day begins and research progresses.


There you have it. Games need it too. :P
SocietalEclipse
Newbie
 
Posts: 6
Joined: 2004-9-08 @ 21:13
Location: Fairfax, VA, USA

Re: CMOS clock patch (dates not changing when left overnight)

Postby wd » 2007-11-25 @ 13:10

There you have it.

Uhhhhhhm that's the regular clock, works fine. Get facts straight BEFORE posting.
wd
DOSBox Author
 
Posts: 10818
Joined: 2003-12-03 @ 21:23

Re: Dates do not change when left running overnight.

Postby nyh » 2010-3-05 @ 09:40

jal wrote: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?

I think so. I was running an old MS DOS punch clock program on my Linux server using Dosemu. I switched to FreeBSD and had the problem Dosemu isn't ported to FreeBSD.

DosBox runs fine but has the date problem. I patched dos.cpp to return the server time:
Code: Select all
        case 0x2a:              /* Get System Date */
                {
                        struct timeval tv;
                        struct timezone tz;
                        struct tm *loctime;

                        gettimeofday(&tv, &tz);
                        loctime=localtime(&tv.tv_sec);

                        reg_al=loctime->tm_wday;
                        reg_cx=1900+loctime->tm_year;
                        reg_dh=1+loctime->tm_mon;
                        reg_dl=loctime->tm_mday;

//                      int a = (14 - dos.date.month)/12;
//                      int y = dos.date.year - a;
//                      int m = dos.date.month + 12*a - 2;
//                      reg_al=(dos.date.day+y+(y/4)-(y/100)+(y/400)+(31*m)/12) % 7;
//                      reg_cx=dos.date.year;
//                      reg_dh=dos.date.month;
//                      reg_dl=dos.date.day;
                }

and
Code: Select all
        case 0x2c:              /* Get System Time */
//TODO Get time through bios calls date is fixed
                {
                        struct timeval tv;
                        struct timezone tz;
                        struct tm *loctime;

                        gettimeofday(&tv, &tz);
                        loctime=localtime(&tv.tv_sec);

                        reg_ch=(Bit8u)(loctime->tm_hour);
                        reg_cl=(Bit8u)(loctime->tm_min);
                        reg_dh=(Bit8u)(loctime->tm_sec);
                        reg_dl=(Bit8u)(tv.tv_usec/10000);
/*      Calculate how many miliseconds have passed */
//                      Bitu ticks=5*mem_readd(BIOS_TIMER);
//                      ticks = ((ticks / 59659u) << 16) + ((ticks % 59659u) << 16) / 59659u;
//                      Bitu seconds=(ticks/100);
//                      reg_ch=(Bit8u)(seconds/3600);
//                      reg_cl=(Bit8u)((seconds % 3600)/60);
//                      reg_dh=(Bit8u)(seconds % 60);
//                      reg_dl=(Bit8u)(ticks % 100);
                }

Now my application runs fine. I hope the code is useful for someone else too.

Nyh
nyh
Newbie
 
Posts: 1
Joined: 2010-3-04 @ 10:43
Location: Netherlands

Previous

Return to DOSBox Patches

Who is online

Users browsing this forum: No registered users and 4 guests