Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) (03/04/90)
Submitted-by: mjl@alison.at (Martin J. Laubach) Posting-number: Volume 90, Issue 090 Archive-name: util/qt [ uuencoded binary enclosed. ...tad ] This is one of my favorite toys -- though it's only about 400 bytes, it's a working "can anybody tell me what time it is?" tool. Perfect for anybody's startup-sequence. #!/bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 1)." # Contents: Makefile qt.asm qt.doc qt.uu # Wrapped by tadguy@xanth on Sat Mar 3 16:04:11 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(187 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' XALL = qt XOBJ = qt.o XLFLAGS = sc sd nd verbose XINCLUDE = inc:include.i X X X$(ALL): $(OBJ) X blink $(OBJ) $(LFLAGS) lib lib:amiga.lib X Xqt.o: qt.asm X casm -a qt.asm -o qt.o -c v -i $(INCLUDE) END_OF_FILE if test 187 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'qt.asm' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'qt.asm'\" else echo shar: Extracting \"'qt.asm'\" \(3761 characters\) sed "s/^X//" >'qt.asm' <<'END_OF_FILE' X; Qt -- What time is it? X; X; Original version (c) 1989 by Martin Laubach X; Heavy modifications (c) Jim Butterfield Jan 31, 1990 X; Beautified by mjl X; X; :ts=12 X X include "exec/types.i" X include "libraries/dos.i" X X optimon X X;----------------------------------------------------------------- Xcall macro X xref _LVO\1 X jsr _LVO\1(a6) X endm X Xvector macro X dc.b \1-Hr12 X endm X X;----------------------------------------------------------------- X; Local variables X XLocal_SIZE: equ ds_SIZEOF ; I need a local DateStamp X XToday: equ -Local_SIZE X X;----------------------------------------------------------------- X section Qt,code X XMain: link a4,#-Local_SIZE X X move.l 4,a6 X X lea DosName(pc),a1 X moveq #33,d0 X call OpenLibrary X move.l d0,a6 X X call Output X move.l d0,a5 X X lea Today(a4),a0 X move.l a0,d1 X call DateStamp X X move.l Today+ds_Minute(a4),d6 X moveq #27,d7 X add.l d7,d6 X X divu #60,d6 X move.w d6,d7 ; hours (quotient) X X moveq #12,d4 X divu d4,d7 ; X X clr.w d7 X swap d7 ; hours (0-11) X X clr.w d6 X swap d6 ; mins (remainder) X X moveq #It.vec-Hr.vecs,d0 X bsr.s PutStr X X divu #5,d6 ; clock divisions X swap d6 ; 'almost' adjustment X moveq #Ny.vecs-Hr.vecs,d0 X add.w d6,d0 X bsr.s PutStr X X swap d6 ; clock divisions X moveq #Ps.vec-Hr.vecs,d5 X subq.w #5,d6 ; adjust to hour X beq.s Exact X bpl.s GotToP X X moveq #To.vec-Hr.vecs,d5 X neg.w d6 X XGotToP: moveq #Ft.vecs-Hr.vecs,d0 X add.w d6,d0 X bsr.s PutStr X X move.l d5,d0 X bsr.s PutStr X XExact: moveq #Hr.vecs-Hr.vecs,d0 X add.w d7,d0 X bsr.s PutStr X X moveq #OC.vec-Hr.vecs,d0 X tst.w d6 X bne.s NoOclk X bsr.s PutStr X XNoOclk: lea NewLine.CHR(pc),a3 X bsr.s Prt1 X X X move.l a6,a1 X move.l 4,a6 X call CloseLibrary X X unlk a4 X rts X X;----------------------------------------------------------------- X; Print item from table (Hr.vecs) X; D0 = String number X; --> X; Nil X XPutStr: lea Hr.vecs(pc),a0 X moveq #0,d2 X moveq #0,d3 X X move.b 0(a0,d0.w),d2 ; Get buffer offset X move.b 1(a0,d0.w),d3 ; Get next item offset X sub.w d2,d3 ; Length of string X X beq.s Exit ; No string X X lea Hr12(pc),a3 ; Begin of string table X add.l a3,d2 ; Begin of string X X;----------------------------------------------------------------- X; Print something + space X; D2 = Pointer to something X; D3 = Length of something X; --> X; Nil X XPrtItem: bsr.s Put1 X X lea Space.CHR(pc),a3 X XPrt1: move.l a3,d2 X moveq #1,d3 X XPut1: move.l a5,d1 ; handle XGotstr: call Write X XExit: moveq #0,d0 X rts X X X;----------------------------------------------------------------- X; String vector table X XHr.vecs: vector Hr12 X vector Hr01 X vector Hr02 X vector Hr03 X vector Hr04 X vector Hr05 X vector Hr06 X vector Hr07 X vector Hr08 X vector Hr09 X vector Hr10 XFt.vecs: vector Hr11 X vector Mn05 X vector Mn10 X vector Mn15 X vector Mn20 X vector Mn25 X vector Mn30 XNy.vecs: vector nearly X vector almost X vector justpast X vector justpast X vector after XIt.vec: vector Itis XPs.vec: vector Past XTo.vec: vector UpTo XOC.vec: vector OClock X vector Space.CHR X X;----------------------------------------------------------------- X; Strings X XHr12: dc.b 'twelve' XHr01: dc.b 'one' XHr02: dc.b 'two' XHr03: dc.b 'three' XHr04: dc.b 'four' XHr05: dc.b 'five' XHr06: dc.b 'six' XHr07: dc.b 'seven' XHr08: dc.b 'eight' XHr09: dc.b 'nine' XHr10: dc.b 'ten' XHr11: dc.b 'eleven' XMn05: dc.b 'five' XMn10: dc.b 'ten' XMn15: dc.b 'a quarter' XMn20: dc.b 'twenty' XMn25: dc.b 'twenty-five' XMn30: dc.b 'half' Xnearly: dc.b 'nearly' Xalmost: dc.b 'almost' Xjustpast: dc.b 'just after' Xafter: dc.b 'after' XItis: dc.b 'It''s' XPast: dc.b 'past' XUpTo: dc.b 'to' XOClock: dc.b 'o''clock' XSpace.CHR: dc.b ' ' XNewLine.CHR: dc.b 10 XDosName: dc.b 'dos.library',0 X X end X END_OF_FILE if test 3761 -ne `wc -c <'qt.asm'`; then echo shar: \"'qt.asm'\" unpacked with wrong size! fi # end of 'qt.asm' fi if test -f 'qt.doc' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'qt.doc'\" else echo shar: Extracting \"'qt.doc'\" \(5132 characters\) sed "s/^X//" >'qt.doc' <<'END_OF_FILE' X X X Page 1 Qt's Documentation Page 1 X X X X X X X X X X X X X X X X X X Qt X (c) Copyright 1989 by Martin J. Laubach X (c) Copyright 1990 by Jim Butterfield X All rights reserved X X X X X X X X X 1. Introduction X X This is one of my favorite toys -- though it's only about 400 X bytes, it's a working "can anybody tell me what time it is?" X tool. Perfect for anybody's startup-sequence. X X 2. Internals X X 2.1. Background X X Please don't yell at me because you don't like the look of the X source -- I know I do some not-so-nice things (like putting data X in the code hunk). It was my explicit aim to shorten the X program as much as possible, so I might not always have used the X most elegant solution. However, this version is much more X elegant than my first one -- kudos to Jim Butterfield. X X 2.2. History X X It all began when I saw a similar tool on a PC (shame on me). X I really loved it. So I tried to implement it in C -- the first X version had about 4K. I really didn't like that since the PC X version had only 512 bytes. So I began rewriting it in X assembler, and after some code bumming, I ended up with 408 X bytes. I then posted it to alt.sources.amiga, and, though I X thought my code pretty dense, I got mail from Jim Butterfield, X telling me he succeeded in shortening the code -- with, at the X X X Internals History X X X Page 2 Qt's Documentation Page 2 X X X same time, making it pure, more readable, and not X self-modifying. He really had an interesting idea of how to X store and access the string table (see the code), an idea I X would never had thought about. X X 2.3. Challenge X X We are now down at a whopping 392 bytes. See if you can do X better! X X 3. What X X In this archive, you should find the following files: X X qt.doc .... What you are reading right now. X qt.asm .... The source for rm. X makefile .. Guess what. X qt ........ The executable X X 4. Where X X If you have any comments, ideas what could or should be X improved, bug reports or just like to chat a bit, please feel X free to contact me at one of the following addresses... I just X *love* receiving mail! X X Usenet: mjl@alison.at X ..!uunet!mcsun!tuvie!alison!mjl X X or X X FidoNet: "Martin Laubach" at 2:310/3.14 X X X Looking forward to reading from you, X X mjl X X X Jim Butterfield, who did not a small part of this, can also be X reached on Usenet: X X jb@cbmtor.uucp X ..!uunet!cbmtor!jb. X X X X 5. License X X This material is (c) Copyright 1989 by Martin J. Laubach and (c) X Copyright 1990 by Jim Butterfield -- All rights reserved. X X It may be distributed freely as long as the following X restrictions are met: X X X License X X X Page 3 Qt's Documentation Page 3 X X X X The distributor may charge a fee to recover distribution X costs. The fee for diskette distribution should not be more than X the cost to obtain the same diskette from Fred Fish. X X The distributor agrees to cease distributing the programs and X data involved if requested to do so by the author. X X You may copy and distribute verbatim copies of the program's X executable code and documentation as you receive it, in any X medium, provided that you conspicuously and appropriately X publish only the original, unmodified program, with all X copyright notices and disclaimers of warranty intact and X including all the accompanying documentation, example files and X anything else that came with the original. X X The author will not be liable for any damage arising from the X failure of this program to perform as described, or any X destruction of other programs or data residing on a system X attempting to run the program. While I know of no damaging X errors, the user of this program uses it at his or her own X risk. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X License X X X Page 4 Qt's Documentation Page 4 X X X 6. Road Map X X X X 1. Introduction .................................... 1 X 2. Internals ....................................... 1 X 2.1. Background ................................... 1 X 2.2. History ...................................... 1 X 2.3. Challenge .................................... 2 X 3. What ............................................ 2 X 4. Where ........................................... 2 X 5. License ......................................... 2 X 6. Road Map ......................................... 4 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Road Map X END_OF_FILE if test 5132 -ne `wc -c <'qt.doc'`; then echo shar: \"'qt.doc'\" unpacked with wrong size! fi # end of 'qt.doc' fi if test -f 'qt.uu' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'qt.uu'\" else echo shar: Extracting \"'qt.uu'\" \(580 characters\) sed "s/^X//" >'qt.uu' <<'END_OF_FILE' Xbegin 664 qt XM```#\P`````````!``````````````!9```#Z0```%E.5/_T+'@`!$/Z`4YP. XM(4ZN_=@L0$ZN_\0J0$'L__0B"$ZN_T`L+/_X?AO<AXS\`#P^!G@,CL1"1TA'- XM0D9(1G`784:,_``%2$9P$M!&83I(1GH86T9G$&H$>AE$1G`+T$9A)B`%82)P% XM`-!'81QP&DI&9@)A%$?Z`.%A+B).+'@`!$ZN_F).7$YU0?H`+'0`=@`4,```R XM%C```99"9Q9'^@`TU(MA"$?Z`+`D"W8!(@U.KO_0<`!.=0`&"0P1%1D<(28J$ XM+3,W.D-)5%A>9&1N<W=[?81T=V5L=F5O;F5T=V]T:')E969O=7)F:79E<VEX( XM<V5V96YE:6=H=&YI;F5T96YE;&5V96YF:79E=&5N82!Q=6%R=&5R='=E;G1Y# XM='=E;G1Y+69I=F5H86QF;F5A<FQY86QM;W-T:G5S="!A9G1E<F%F=&5R270GF X@<W!A<W1T;V\G8VQO8VL@"F1O<RYL:6)R87)Y`````_)A9 X`` Xend Xsize 392 END_OF_FILE if test 580 -ne `wc -c <'qt.uu'`; then echo shar: \"'qt.uu'\" unpacked with wrong size! fi # end of 'qt.uu' fi echo shar: End of archive 1 \(of 1\). cp /dev/null ark1isdone MISSING="" for I in 1 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have the archive. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Mail submissions (sources or binaries) to <amiga@cs.odu.edu>. Mail comments to the moderator at <amiga-request@cs.odu.edu>. Post requests for sources, and general discussion to comp.sys.amiga.