Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!phri!dasys1!manes From: manes@dasys1.UUCP (Steve Manes) Newsgroups: comp.sys.ibm.pc Subject: Re: Help with delay funct for MSC Message-ID: <2120@dasys1.UUCP> Date: Tue, 1-Dec-87 13:32:53 EST Article-I.D.: dasys1.2120 Posted: Tue Dec 1 13:32:53 1987 Date-Received: Sat, 5-Dec-87 04:25:13 EST References: <9394@shemp.UCLA.EDU> <2056@crash.cts.com> Reply-To: manes@dasys1.UUCP (Steve Manes) Organization: Datamerica Systems, NYC Lines: 38 Keywords: sleep function, tic, DELAY routine for MS-C In article <2056@crash.cts.com> crash!crash.CTS.COM!paul (Paul Palacios) writes: >In article <9394@shemp.UCLA.EDU> claus@CS.UCLA.EDU () writes: >>I am writing an application in MSC 4.0, and I wish to incorporate time >>delays that are independed of the speed of the machine on which the >>application is run. I couldn't find any appropriate routine in the >>MSC documentation (yes I do have the manual). A less involved solution is simply to read the BIOS timer variables directly via a 'peek' function (I know it's not in the MSC4 library but there are dozens to be found on just about any respectable programmer- oriented BBS so I'll not duplicate one here). void ticks(snooze) long snooze; /* make this a long for longer delay values */ { unsigned count; while (snooze--) { count = peek(0x40, 0x6C); while (count == peek(0x40, 0x6C) ); } } Simply call 'ticks' with the number of clock cycles you want to pause. You can set up some global defines, like #define ONESEC 18L #define ONEMIN (ONESEC * 60) etc... The one problem with the (very well-written!) Assy approach submitted earlier is that it calls Int 1Ah, which produces that date rollover bug for a lot of folks. -- +----------------------------------------------------------------------- + Steve Manes Roxy Recorders, Inc. NYC + decvax!philabs!cmcl2!hombre!magpie!manes Magpie BBS: 212-420-0527 + uunet!iuvax!bsu-cs!zoo-hq!magpie!manes 300/1200/2400