home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / tbsource.lha / TBSource / Reset / Reset.S
Text File  |  1993-12-21  |  3KB  |  196 lines

  1. *************************************************
  2. *                        *
  3. *         (C)opyright 1992        *
  4. *                        *
  5. *        by  Tomi Blinnikka        *
  6. *                        *
  7. *    Don´t try to understand the code    *
  8. *                        *
  9. * Version 0.01    04/07/1992            *
  10. *                        *
  11. * BUGS:    None.                    *
  12. *                        *
  13. * Version 0.02    11/07/1992            *
  14. *                        *
  15. * Added delay. Added informing TTYs. Added    *
  16. * -q(uiet) option                *
  17. *                        *
  18. * BUGS:    -q didn't work...            *
  19. *                        *
  20. * Version 0.03    26/07/1992            *
  21. *                        *
  22. * Version 0.04    28/07/1992            *
  23. *                        *
  24. * Added CTRL_C check.                *
  25. *                        *
  26. * Version 0.05    28/12/1992            *
  27. *                        *
  28. * Added quick option.                *
  29. *                        *
  30. * Version 1.00    30/12/1992            *
  31. *                        *
  32. * CBM guidelines in parser.             *
  33. *                        *
  34. *************************************************
  35.  
  36.     INCLUDE    "JMPLibs.i"
  37.     INCLUDE    "exec/types.i"
  38.     INCLUDE    "libraries/dos.i"
  39.  
  40.     INCLUDE    "XREF:2.0.xref"
  41.     INCLUDE    "XREF:exec.xref"
  42.     INCLUDE    "XREF:dos.xref"
  43.  
  44.         section    Reset,CODE
  45.  
  46.         move.l    a0,a4
  47.         clr.b    -1(a0,d0.l)
  48.         openlib    Dos,NoDos
  49.  
  50.         lea.l    CLTemplate1,a0
  51.         move.l    a0,d1
  52.         lea.l    CLArray1,a0
  53.         move.l    a0,d2
  54.         clr.l    d3
  55.         lib    Dos,ReadArgs
  56.         move.l    d0,RDArgs1
  57.         beq    NoRDArgs
  58.  
  59.         tst.l    DevPointer
  60.         beq    Start1
  61.  
  62.         clr.l    d4
  63.  
  64. WriteLoop:    move.l    DevPointer,a0
  65.         move.l    d4,d3
  66.         mulu.w    #4,d3
  67.         add.l    d3,a0
  68.  
  69.         move.l    (a0),a0
  70.  
  71.         cmp.l    #$00,a0        ;if pointer is NULL
  72.         beq    Start1        ;we don't have a string
  73.  
  74.         move.l    a0,d1
  75.         move.l    #MODE_NEWFILE,d2
  76.         lib    Dos,Open
  77.         tst.l    d0
  78.         beq    Start1
  79.  
  80.         move.l    d0,d5
  81.         lea.l    ResetText1,a0
  82.         move.l    a0,d2
  83.         bsr    GetLength        ;loads d3 with length
  84.         lib    Dos,Write
  85.  
  86.         move.l    d5,d1
  87.         lib    Dos,Close
  88.  
  89.         add.l    #1,d4
  90.         bra    WriteLoop
  91.  
  92. Start1:        tst.l    Immediate
  93.         beq    Wait
  94.  
  95.         lea.l    ResetText2,a0
  96.         bsr    Printer
  97.         bra    SkipWait
  98.  
  99. Wait:        lea.l    ResetText1,a0
  100.         bsr    Printer
  101.  
  102.         move.l    #5*50,d1
  103.         lib    Dos,Delay
  104.  
  105. SkipWait:    clr.l    d0
  106.         bset.l    #SIGBREAKB_CTRL_C,d1    ;check for CTRL_C
  107.         lib    Dos,CheckSignal
  108.         btst.l    #SIGBREAKB_CTRL_C,d0
  109.         beq    DoReset
  110.  
  111.         lea.l    BreakText1,a0
  112.         bsr    Printer
  113.         bra    ShutDown
  114.  
  115. DoReset:    lib    Exec,ColdReboot
  116.         
  117. ShutDown:    move.l    RDArgs1,d1
  118.         beq    ShutDown1000
  119.         lib    Dos,FreeArgs
  120.  
  121. ShutDown1000:    closlib    Dos
  122.         move.l    #RETURN_OK,d0
  123.         rts
  124.  
  125. NoDos:        move.l    #RETURN_FAIL,d0
  126.         rts
  127.  
  128. NoRDArgs:    lib    Dos,IoErr
  129.         move.l    d0,d1
  130.         clr.l    d2
  131.         lib    Dos,PrintFault
  132.         bra    ShutDown
  133.  
  134. Printer:    tst.l    Quiet
  135.         bne    Printer1
  136.         printa    a0
  137. Printer1:    rts
  138.  
  139. ;Get length of text in given address
  140. ;
  141. ;Input a0 = Address of null terminated text string
  142. ;
  143. ;Result d3 = Length
  144.  
  145. GetLength:    push    a0
  146.         clr.l    d3
  147.         cmp.l    #$00,a0        ;fixes enforcer hit
  148.         beq    GetLength_OUT
  149. GetLength2:    add.l    #1,d3
  150.         tst.b    (a0)+
  151.         bne    GetLength2
  152.         sub.l    #1,d3        ;don't include NULL
  153. GetLength_OUT:    pull    a0
  154.         rts
  155.  
  156. ;Structures and reservations
  157.  
  158. VersionString:    dc.b    "$VER: Reset 1.00 (30.12.92) (C)opyright Tomi Blinnikka",0
  159. CLTemplate1:    dc.b    "Q=QUIET/S,I=IMMEDIATE/S,DEVS=DEVICES/M",0
  160.  
  161. ResetText1:    dc.b    7,13,10,"WARNING! System shutdown begins in 5 seconds!",13,10
  162.         dc.b    "Please logon again in a few minutes.",13,10,0
  163. ResetText2:    dc.b    7,13,10,"WARNING! System shutdown!",13,10
  164.         dc.b    "Please logon again in a few minutes.",13,10,0
  165. BreakText1:    dc.b    "***Break: Reset",13,10,0
  166.         ds.l    0
  167.  
  168. ;library stuff
  169.  
  170.         libnames
  171.  
  172. ;Options
  173.  
  174. RDArgs1:    dc.l    0
  175.  
  176. CLArray1:
  177. Quiet:        dc.l    0        ;0=Print texts, 1=Be quiet
  178. Immediate:    dc.l    0        ;0=Wait N secs, 1=Do not wait
  179. DevPointer:    dc.l    0        ;Pointer to devices string
  180.  
  181. ;buffers
  182.  
  183. Buf1:        dcb.b    10,0
  184. Buf2:        dcb.b    10,0
  185. Buf3:        dcb.b    10,0
  186. Buf4:        dcb.b    10,0
  187. Buf5:        dcb.b    10,0
  188. Buf6:        dcb.b    10,0
  189. Buf7:        dcb.b    10,0
  190. Buf8:        dcb.b    10,0
  191. Buf9:        dcb.b    10,0
  192. Buf10:        dcb.b    10,0
  193. Buf11:        dcb.b    10,0
  194.  
  195.         END
  196.