home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / prog-asm / assemtls.lzh / ASSEMTOOLS / ASOURCE / DCLOCK.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-08-16  |  5.5 KB  |  280 lines

  1. ;
  2. ; ### DigiClock by JM & TM v 1.51 ###
  3. ;
  4. ; - Created 880612 by JM & TM -
  5. ;
  6. ;
  7. ; Program written for the 'C' Magazine.  Segment drawing by TM.
  8. ; Code is not very beautiful but we wanted to keep it as short as
  9. ; possible.
  10. ;
  11. ; Bugs: None alive.
  12. ;
  13. ;
  14. ; Edited:
  15. ;
  16. ; - 880612 by JM,TM -> v0.50    - Works.
  17. ; - 880613 by JM    -> v1.00    - Code compressed.
  18. ; - 880613 by JM    -> v1.10    - Close button added; code compressed.
  19. ; - 880613 by JM,TM -> v1.40    - Code still compressed.  Length was 952
  20. ;                  bytes but was then cut down to 816 bytes.
  21. ; - 880725 by JM    -> v1.41    - IDCMP corrected.  CLOSEWINDOW must be
  22. ;                  checked with CMP.L!
  23. ; - 881106 by JM    -> v1.50    - Re-run enabled (doesn't modify itself)
  24. ; - 890312 by JM    -> v1.51    - Short branches, A68k compatibility
  25. ;
  26. ;
  27.  
  28.  
  29.  
  30.         xref    _LVOOpenLibrary
  31.         xref    _LVOCloseLibrary
  32.         xref    _LVOAllocMem
  33.         xref    _LVOFreeMem
  34.         xref    _LVODisable
  35.         xref    _LVOEnable
  36.         xref    _LVOWait
  37.         xref    _LVOGetMsg
  38.         xref    _LVOReplyMsg
  39.  
  40.         xref    _LVOExecute
  41.         xref    _LVOOpen
  42.         xref    _LVOClose
  43.         xref    _LVOOutput
  44.         xref    _LVORead
  45.         xref    _LVOWrite
  46.         xref    _LVODelay
  47.         xref    _LVODateStamp
  48.  
  49.         xref    _LVOMove
  50.         xref    _LVODraw
  51.         xref    _LVOText
  52.         xref    _LVOSetAPen
  53.         xref    _LVOSetBPen
  54.         xref    _LVOSetDrMd
  55.         xref    _LVOSetRast
  56.         xref    _LVOLoadRGB4
  57.         xref    _LVOVBeamPos
  58.  
  59.         xref    _LVOScreenToFront
  60.         xref    _LVOScreenToBack
  61.         xref    _LVOOpenScreen
  62.         xref    _LVOCloseScreen
  63.         xref    _LVOOpenWindow
  64.         xref    _LVOCloseWindow
  65.         xref    _LVOMoveScreen
  66.         xref    _LVOOpenFont
  67.         xref    _LVOCloseFont
  68.         xref    _LVOOpenDiskFont
  69.         xref    _LVORectFill
  70.  
  71.         xdef    main
  72.  
  73.         include "JMPLibs.i"
  74.         include "intuition.i"
  75.  
  76.         BITDEF    MEM,PUBLIC,0
  77.         BITDEF    MEM,CHIP,1
  78.         BITDEF    MEM,FAST,2
  79.         BITDEF    MEM,CLEAR,16
  80.         BITDEF    MEM,LARGEST,17
  81.  
  82. LF        equ    10
  83.  
  84.  
  85. tool_dclock
  86. main        openlib Dos,cleanup_dos        open Dos library
  87.         openlib    Gfx,cleanup_gfx
  88.         openlib    Intuition,cleanup_int
  89.  
  90.         clr.l    oldtime
  91.  
  92.         lea    ClWindow(pc),a0
  93.         lib    Intuition,OpenWindow
  94.         move.l    d0,d6            window ptr
  95.         beq    cleanup
  96.         move.l    d0,a0
  97.         move.l    wd_RPort(a0),a5        rastport
  98.  
  99.         moveq.l    #2,d0            Fill background
  100.         move.l    a5,a1
  101.         lib    Gfx,SetAPen
  102.         move.l    a5,a1
  103.         moveq.l    #2,d0
  104.         moveq.l    #10,d1
  105.         move.l    #311,d2
  106.         moveq.l    #77,d3
  107.         flib    Gfx,RectFill
  108.  
  109. Colon        moveq.l    #2,d0            Toggle colon color
  110.         bchg    #0,col_col
  111.         beq.s    Colon_off
  112.         addq.l    #1,d0
  113. Colon_off    move.l    a5,a1            Set color black/orange
  114.         lib    Gfx,SetAPen
  115.         move.l    a5,a1            Draw colon (upper dot)
  116.         move.l    #152,d0
  117.         moveq.l    #30,d1
  118.         move.l    d0,d2
  119.         addq.w    #8,d2
  120.         moveq.l    #34,d3
  121.         flib    Gfx,RectFill
  122.  
  123.         move.l    a5,a1            Draw colon (lower dot)
  124.         move.l    #152,d0
  125.         moveq.l    #52,d1
  126.         moveq.l    #56,d3
  127.         flib    Gfx,RectFill
  128.  
  129. Main        lea    TimeBuf(pc),a0        read time
  130.         move.l    a0,d1
  131.         lib    Dos,DateStamp
  132.  
  133.         move.l    TimeBuf+4(pc),d2
  134.         cmp.w    oldtime(pc),d2
  135.         beq.s    Sleep
  136.         move.w    d2,oldtime
  137.         divu.w    #60,d2            convert to hours/minutes
  138.         move.l    d2,d3            save minutes
  139.         moveq.l    #-68,d0            reset x-coord
  140.         bsr    draw2
  141.         swap    d3
  142.         move.l    d3,d2
  143.         bsr.s    draw2
  144.  
  145. Sleep        moveq.l    #24,d4
  146. WaitTicks    moveq.l    #1,d1            Sleep for a while
  147.         lib    Dos,Delay
  148.         move.l    d6,a0            windowptr
  149.         move.l    wd_UserPort(a0),a4
  150.         move.l    a4,a0            port*
  151.         lib    Exec,GetMsg        Check if a message received
  152. GetMsgLoop    move.l    d0,d2            message*
  153.         beq.s    Colonize        No msg received
  154.         move.l    d2,a1            IntuiMessage *
  155.         move.l    im_Class(a1),d3        Class
  156.         lib    Exec,ReplyMsg
  157.         move.l    a4,a0            port
  158.         flib    Exec,GetMsg
  159.         tst.l    d0
  160.         bne    GetMsgLoop
  161.         cmp.l    #CLOSEWINDOW,d3
  162.         beq.s    cleanup
  163. Colonize    dbf    d4,WaitTicks
  164.         bra    Colon
  165.  
  166.  
  167. cleanup        move.l    d6,d0
  168.         beq.s    clean90
  169.         move.l    d0,a0
  170.         lib    Intuition,CloseWindow
  171.  
  172. clean90        closl    Intuition
  173. cleanup_int    closl    Gfx
  174. cleanup_gfx    closl    Dos
  175. cleanup_dos    rts
  176.  
  177.  
  178. draw2        and.l    #$ffff,d2
  179.         divu.w    #10,d2
  180.         move.b    d2,d1        10 hours
  181.         add.w    #88,d0        xcoord
  182.         bsr.s    drawdigit
  183.         swap    d2        get hours
  184.         move.b    d2,d1
  185.         add.w    #68,d0        inc x
  186.  
  187. drawdigit    push    all        save registers
  188.         move.l    d0,d2        x-coordinate of the digit
  189.         lea    digitdata(pc),a0
  190.         ext.w    d1
  191.         move.b    0(a0,d1.w),d3    segment data
  192.         lsl.b    #1,d3
  193.         moveq.l    #6,d4
  194.         lea    segment(pc),a2
  195. drawdigit1    moveq.l    #2,d0
  196.         lsl.b    #1,d3
  197.         bcc.s    drawsegment1
  198.         moveq.l    #3,d0
  199. drawsegment1    move.l    a5,a1
  200.         lib    Gfx,SetAPen
  201.         moveq.l    #3,d7
  202. drawsegment2    moveq.l    #0,d0
  203.         move.l    d0,d1
  204.         move.b    (a2)+,d0
  205.         bmi.s    drawline1
  206.         move.b    (a2)+,d1
  207.         add.w    d2,d0
  208.         move.l    a5,a1
  209.         flib    Gfx,Move
  210.         moveq.l    #0,d0
  211.         move.l    d0,d1
  212.         move.b    (a2)+,d0
  213.         move.b    (a2)+,d1
  214.         add.w    d2,d0
  215.         move.l    a5,a1
  216.         flib    Gfx,Draw
  217. drawline1    dbf    d7,drawsegment2
  218.         dbf    d4,drawdigit1
  219.         pull    all        restore registers
  220.         rts
  221.  
  222. segment                ; segment coordinates
  223.         dc.b    2,20,45,20,3,21,44,21,4,22,43,22,-1
  224.                 ; segment A
  225.         dc.b    47,22,47,41,46,23,46,40,45,24,45,39,44,25,44,38
  226.                 ; segment B
  227.         dc.b    47,45,47,65,46,46,46,64,45,47,45,63,44,48,44,62
  228.                 ; segment C
  229.         dc.b    2,67,45,67,3,66,44,66,4,65,43,65,-1
  230.                 ; segment D
  231.         dc.b    0,45,0,65,1,46,1,64,2,47,2,63,3,48,3,62
  232.                 ; segment E
  233.         dc.b    0,22,0,41,1,23,1,40,2,24,2,39,3,25,3,38
  234.                 ; segment F
  235.         dc.b    4,42,43,42,2,43,45,43,4,44,43,44,-1
  236.                 ; segment G
  237.  
  238. digitdata    dc.b    %1111110    ; maaritellaan 7-segmenttinayton
  239.         dc.b    %0110000    ; numeroissa palavat segmentit
  240.         dc.b    %1101101
  241.         dc.b    %1111001
  242.         dc.b    %0110011
  243.         dc.b    %1011011
  244.         dc.b    %1011111
  245.         dc.b    %1110000
  246.         dc.b    %1111111
  247.         dc.b    %1111011
  248.  
  249.  
  250.         cnop    0,4            osoite 4:lla jaolliseksi
  251.  
  252. TimeBuf        dc.l    0
  253.         dc.l    0
  254.         dc.l    0
  255.  
  256. oldtime        dc.l    0
  257.         dc.l    0
  258.         dc.l    0
  259.  
  260. col_col        dc.w    0
  261.  
  262. ClWindow    dc.w    0,0,314,79        upper x,y , x,y-size
  263.         dc.b    2,1            detailpen, blockpen
  264.         dc.l    CLOSEWINDOW        IDCMPFlags
  265.         dc.l    WINDOWDRAG!WINDOWDEPTH!WINDOWCLOSE    Flags
  266.         dc.l    0            gadgets
  267.         dc.l    0            checkmark
  268.         dc.l    MyWinTitle        title
  269.         dc.l    0            screen
  270.         dc.l    0            bitmap
  271.         dc.w    320,256,320,256        min-max size
  272.         dc.w    WBENCHSCREEN        type
  273.  
  274. MyWinTitle    dc.b    'DigiCLOCK v1.51',0
  275.  
  276.         libnames            kirjastojen nimet&osoittimet
  277.  
  278.         end
  279.  
  280.