home *** CD-ROM | disk | FTP | other *** search
- From: jac@yoko.rutgers.edu (Jonathan A. Chandross)
- Newsgroups: comp.sources.apple2
- Subject: v001SRC049: time -- Print Current Time
- Message-ID: <May.31.11.34.39.1991.7166@yoko.rutgers.edu>
- Date: 31 May 91 15:34:39 GMT
- Approved: jac@paul.rutgers.edu
-
-
- Submitted-by: Andy Werner (st6934@siucvmb.bitnet)
- Posting-number: Volume 1, Source:49
- Archive-name: util/hyperc/time/time
- Architecture: ANY_2
- Version-number: 1.00
-
- Print out the time under HyperC. No-frills, shows how to use
- ProDOS MLI calls under HyperC.
-
- Enjoy.
-
- =Read.Me
- -
- -time
- -Version 1.00
- -
- -Time Utility for HyperC
- -This is freeware. It's also a learning tool to see how HyperC works.
- -The included files are :
- -
- -cclib : Script file to compile unlinked C files
- -time.c : C source for time utility
- -getime.a : Assembly source for ProDOS MLI time call
- -date.a : Assembly source to unpack date after calling ProDOS MLI time
- -mk : pseudo-make script to link compiled but unlinked files
- -
- -Use cclib to compile time.c and use asm65 to compile the assembler files.
- -
- -For example, to compile getime.a, type :
- -
- -asm65 -o time.o time.a
- -
- -Use mk to link all the files ending with .o. Type mk.
- -
- -Examine the script files to see if they point to the correct subdirectories.
- -Adjust them to suit your setup. You can compile time.c down to native code
- -(or emulated for you IIgs people...) by editing ccn and deleting the lnk
- -phase at the end of that script and renaming the edited file ccnlib for ex-
- -ample. I have not tried this at this time but I assume it will work.
- -
- -The time file as it stands can be placed in your bin subdirectory. When you
- -type time at the keyboard, the program will respond by displaying the time
- -and date. This program assumes you have a clock-calendar attached to your
- -system. This program attempts to mimic the time() function of UNIX and ANSI C.
- -As I'm not on a UNIX site I'd like to get feedback from those of you who are.
- -I'm also interested in writing an asctime() function and mimicing clk_tck.
- -
- -You can send your comments to me at:
- -
- - Andy Werner
- - st6934@siucvmb.bitnet
- - March 18, 1991.
- -
- -ProDOS is a trademark of Apple Computer, Inc.
- -UNIX is a trademark(?) of A.T.T.
- -HyperC is a trademark of the WSM Group, Inc.
- -
- =Manifest
- -
- -Read.Me
- -cclib
- -date.a
- -getime.a
- -mk
- -time.c
- -
- =cclib
- -;
- -; batch file for compiling C programs...
- -; NOTE: Do NOT specify the ".c" ending the source filename!
- -;
- -/csys/bin/ppf -i |/csys/hdrs/ -o $1.p $1.c
- -/csys/bin/hyperc -o $1.s $1.p
- -rm $1.p
- -/csys/bin/asmcp -o $1.o $1.s
- -
- -
- -
- =date.a
- -;
- -; unpack date
- -; by Andy Werner
- -; march 12,1991
- -;
- -
- -.entry _unpack_date
- - _unpack_date:
- - lda 0xbf90
- - and #0x1f ; mask : 0001 1111
- - sta _day
- - lda 0xbf91
- - lsr a
- - sta _year
- - lda 0xbf90
- - and #0xe0 ; mask : 1110 0000
- - lsr a
- - lsr a
- - lsr a
- - lsr a
- - lsr a
- - sta _month
- - lda 0xbf91
- - and #0xfe ; mask : 1111 1110
- - asl a
- - asl a
- - asl a
- - clc
- - adc #_month
- - sta _month
- - rts
- -
- - .data
- - .entry _year
- -_year:
- - .byte 00
- -
- - .entry _month
- -_month:
- - .byte 00
- -
- - .entry _day
- -_day:
- - .byte 00
- -
- =getime.a
- -
- -; time.a
- -; prodos mli call to set the time
- -;
- -prodos = 0xbf00
- -time = 0x82
- -
- -.entry _get_time
- -
- -_get_time:
- -
- - jsr prodos
- - .byte time
- - .word 0000
- - rts
- -
- -
- -
- -
- =mk
- -;
- -; Script file to make time utility.
- -; examine the script to make sure that your utilities and libraries
- -; can be found by this script. Adjust accordingly.
- -;
- -/csys/bin/lnk -l |/csys/libs/ -a -o time &s.o time.o getime.o date.o &libc
- -
- =time.c
- -
- -/* time.cc
- - * call prodos time
- - * use anchored variables to print time
- - * this is a test
- - */
- -
- -#include <std.h>
- -
- -EXTERN VOID get_time();
- -EXTERN VOID pack_date();
- -
- -EXTERN CHAR year;
- -EXTERN CHAR month;
- -EXTERN CHAR day;
- -
- -CHAR hour @0xbf93;
- -CHAR minute @0xbf92;
- -
- -VOID main()
- -
- -{
- -
- - get_time();
- - printf("The time is %02d:%02d\n",hour,minute);
- - unpack_date();
- - printf("The date is %02d/%02d/%02d\n",month, day, year);
- - exit();
- -
- -}
- + END OF ARCHIVE
-