home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD1.bin / new / util / boot / newalerthook / newalerthook.asm < prev    next >
Assembly Source File  |  1994-12-12  |  14KB  |  730 lines

  1. ; Enhanced Alert Hook
  2. ; (c) 1994 MJSoft System Software, Martin Mares
  3.  
  4. ; Set the YELLOW switch to change color of all alerts to yellow (nice if one
  5. ; has a black/white monitor).
  6.  
  7. ; Don't touch the EXEC switch. It's used if you want to incorporate NewAlertHook
  8. ; into soft-kicked Kickstart, which is very hard to do.
  9.  
  10. _LVOTimedDisplayAlert    EQU    -822
  11.  
  12.     ifnd    EXEC
  13. SYSI    equ    1
  14.     include    "ssmac.h"
  15.     elseif
  16.     include    "sys.i"
  17.     endc
  18.  
  19. ;    opt    x+
  20.     opt    nochkimm
  21.  
  22.     ifnd    EXEC
  23.  
  24.     moveq    #-1,d0
  25.     rts
  26.  
  27. Resident    dc.w    RTC_MATCHWORD
  28.     dc.l    Resident
  29.     dc.l    EndSkip
  30.     dc.b    RTF_COLDSTART
  31.     dc.b    40            ; Version
  32.     dc.b    0            ; Type
  33.     dc.b    7            ; Priority
  34.     dc.l    HookName
  35.     dc.l    HookIDStr
  36.     dc.l    Init
  37.  
  38. ; Alert Hook Initialization
  39.  
  40. Init    mpush    d1-d7/a0-a6
  41.     move.l    4.w,a6
  42.  
  43.     move.l    a6,a1
  44.     lea    (_LVOAlert).w,a0
  45.     lea    AlertFunc(pc),a2
  46.     move.l    a2,d0
  47.     call    SetFunction
  48.     bra.s    DispAlert2
  49.  
  50.     endc
  51.  
  52. ; Auxilliary routine
  53.  
  54. CopyAlertLine    move.b    (a0)+,(a3)+
  55.     move.b    (a0)+,(a3)+
  56.     move.b    #16,(a3)+
  57. 1$    move.b    (a0)+,(a3)+
  58.     bne.s    1$
  59.     st    (a3)+
  60.     rts
  61.  
  62.     ifd    EXEC
  63. AlertHookInit    clr.l    0.w
  64.     endc
  65.  
  66. DispAlert    mpush    d1-d7/a0-a6
  67.     move.l    4.w,a6
  68. DispAlert2    movem.l    LastAlert(a6),d2-d3
  69.     moveq    #-1,d0
  70.     cmp.l    d0,d2
  71.     beq    DispNoAlert
  72.     lea    -300(sp),sp
  73.     move.l    sp,a3
  74.     pea    TTask(pc)
  75.     move.l    d2,d0
  76.     swap    d0
  77.     lea    NotEnoughMem(pc),a0
  78.     cmp.b    #1,d0
  79.     beq.s    AlertHead
  80.     lea    SoftFailure(pc),a0
  81.     tst.w    d0
  82.     ble.s    AlertHead
  83.     lea    RecoverError(pc),a0
  84. AlertHead    bsr.s    CopyAlertLine
  85.     lea    PressLMB(pc),a0
  86.     bsr.s    CopyAlertLine
  87.  
  88.     sub.l    a5,a5
  89.     btst    #0,d3
  90.     bne.s    NoTaskNameS
  91.     move.l    d3,a1
  92.     bsr.s    CheckMem
  93.     beq.s    NoTaskNameS
  94.     move.b    LN_TYPE(a1),d0
  95.     subq.b    #NT_TASK,d0
  96.     beq.s    NoProcess
  97.     cmp.b    #NT_PROCESS-NT_TASK,d0
  98.     bne.s    NoTaskName
  99.     move.l    pr_CLI(a1),d0
  100.     beq.s    NoProcess
  101.     lsl.l    #2,d0
  102.     move.l    d0,a1
  103.     bsr.s    CheckMem
  104.     beq.s    NoProcess
  105.     move.l    cli_CommandName(a1),a1
  106.     add.l    a1,a1
  107.     add.l    a1,a1
  108.     addq.l    #1,a1
  109.     addq.l    #4,sp
  110.     pea    TCommand(pc)
  111.     bra.s    IsProcess
  112.  
  113. NoProcess    move.l    d3,a1
  114.     move.l    LN_NAME(a1),a1
  115. IsProcess    move.l    a1,a4
  116.     bsr.s    CheckMem
  117.     beq.s    NoTaskName
  118.     lea    260(sp),a2
  119.     lea    297(sp),a0
  120.     move.l    a2,a1
  121.     move.b    #'(',(a1)+
  122.     tst.b    (a4)
  123.     beq.s    NoTaskName
  124. CopyTName    cmp.l    a0,a1
  125.     beq.s    CopyTNEnd
  126.     move.b    (a4)+,d0
  127.     move.b    d0,(a1)+
  128.     beq.s    CopyTNEnd
  129.     lsl.b    #1,d0
  130.     cmp.b    #64,d0
  131.     bcc.s    CopyTName
  132. NoTaskNameS    bra.s    NoTaskName
  133.  
  134. CheckMem    push    a1
  135.     call    TypeOfMem
  136.     pop    a1
  137.     tst.l    d0
  138.     bne.s    1$
  139. 2$    move.l    LN_NAME(a6),d0
  140.     clr.w    d0
  141.     sub.l    a1,d0
  142.     cmp.l    #-$80000,d0
  143.     bcc.s    1$
  144.     moveq    #0,d0
  145. 1$    rts
  146.  
  147. CopyTNEnd    move.b    #')',-1(a1)
  148.     sf    (a1)
  149. CopyTNEnd1    move.l    a2,a5
  150.  
  151. NoTaskName    pop    d0
  152.     push    a5
  153.     push    d3
  154.     push    d0
  155.     push    d2
  156.     move.l    sp,a1
  157.     lea    NumberFormat(pc),a0
  158.     lea    PFPutC(pc),a2
  159.     addq.l    #2,a3
  160.     call    RawDoFmt
  161.     bsr.s    Center
  162.     lea    16(sp),sp
  163.  
  164.     addq.l    #2,a3
  165.     move.l    a3,a4
  166.     move.b    #32,(a4)+
  167.  
  168.     ifd    YELLOW
  169.     bclr    #31,d2
  170.     move.l    d2,d0
  171.     elseif
  172.     move.l    d2,d0
  173.     bclr    #31,d0
  174.     endc
  175.  
  176.     swap    d0
  177.     tst.w    d0
  178.     beq.s    FindExcept
  179.     lsr.w    #8,d0
  180.     lea    SubSysTab(pc),a2
  181.     bsr    TabulateUpper
  182. GoColon    move.b    #':',(a4)+
  183.     move.b    #' ',(a4)+
  184.  
  185.     tst.w    d2
  186.     bgt.s    FindSpecific
  187.     move.l    d2,d0
  188.     swap    d0
  189.     bclr    #15,d0
  190.     ext.w    d0
  191.     lea    GeneralErrs(pc),a2
  192.     bsr    TabulateUpper
  193.     move.w    d2,d0
  194.     beq.s    ShowAlert
  195.     bclr    #15,d0
  196.     move.b    #' ',(a4)+
  197.     move.b    #'(',(a4)+
  198.     lea    SubSysTab(pc),a2
  199.     bsr    Tabulate
  200.     move.b    #')',(a4)+
  201.     bra.s    ShowAlert
  202.  
  203. FindExcept    lea    TExcept(pc),a2
  204.     moveq    #8,d0
  205. 1$    move.b    (a2)+,(a4)+
  206.     dbf    d0,1$
  207.     moveq    #-2,d4
  208.     bra.s    GoColon
  209.  
  210. Center    move.l    a3,a0
  211. 1$    tst.b    (a0)+
  212.     bne.s    1$
  213.     move.l    a3,d0
  214.     sub.l    a0,d0
  215.     lsl.w    #2,d0
  216.     add.w    #328,d0
  217.     move.b    d0,-(a3)
  218.     lsr.w    #8,d0
  219.     move.b    d0,-(a3)
  220.     move.l    a0,a3
  221.     st    (a3)+
  222.     rts
  223.  
  224. FindSpecific    lea    Specific(pc),a2
  225.     add.w    0(a2,d4.w),a2
  226.     move.w    d2,d0
  227.     bsr.s    TabulateUpper
  228.  
  229. ShowAlert    sf    (a4)
  230.     bsr.s    Center
  231.  
  232.     ifnd    EXEC
  233.  
  234.     lea    intuiname(pc),a1
  235.     call    OldOpenLibrary
  236.  
  237.     elseif
  238.  
  239.     moveq    #3,d0
  240.     bsr    TaggedOpenLibrary
  241.  
  242.     endc
  243.  
  244.     move.l    #AT_DeadEnd+AG_OpenLib+AO_Intuition,d7
  245.     tst.l    d0
  246.     beq    AlertFunc
  247.     move.l    LastAlert+12(a6),a1
  248.     move.l    d0,a6
  249.  
  250.     sf    -(a3)
  251.     move.l    sp,a0
  252.     move.l    d2,d0
  253.     moveq    #61,d1
  254.  
  255.     ifnd    EXEC
  256.     cmp.w    #39,LIB_VERSION(a6)
  257.     bcs.s    NotTimed
  258.     call    TimedDisplayAlert
  259.     bra.s    AlertDone
  260. NotTimed    call    DisplayAlert
  261.  
  262.     elseif
  263.     call    TimedDisplayAlert
  264.     endc
  265.  
  266. AlertDone    push    d0
  267.     move.l    a6,a1
  268.     call    exec,CloseLibrary
  269.  
  270.     clr.l    0.w
  271.     moveq    #-1,d1
  272.     move.l    d1,LastAlert(a6)
  273.     pop    d0
  274.     lea    300(sp),sp
  275. DispNoAlert    movem.l    (sp)+,d1-d7/a0-a6
  276. Ret1    rts
  277.  
  278. TabulateUpper    bsr.s    Tabulate
  279.     bclr    #5,(a0)
  280.     rts
  281.  
  282. StrXpy0    move.b    (a2)+,(a4)+
  283.     bpl.s    StrXpy1
  284.     move.b    -(a4),d0
  285. StrXpyX    mpush    d5/a2
  286.     lea    Strings(pc),a2
  287. 1$    move.b    (a2)+,d5
  288.     add.l    d5,a2
  289.     addq.b    #1,d0
  290.     bne.s    1$
  291.     move.b    (a2)+,d5
  292.     bsr.s    StrXpy1
  293.     mpop    d5/a2
  294. StrXpy1    dbf    d5,StrXpy0
  295.     rts
  296.  
  297. Tabulate    moveq    #-2,d4
  298.     moveq    #0,d5
  299.     move.l    a4,a0
  300. 1$    addq.w    #2,d4
  301.     move.b    (a2)+,d5
  302.     bpl.s    3$
  303.     addq.w    #1,d1
  304.     neg.b    d5
  305.     bra.s    2$
  306. 3$    moveq    #0,d1
  307.     move.b    (a2)+,d1
  308.     bmi.s    StrXpy1
  309.     bne.s    2$
  310.     move.b    (a2)+,d1
  311.     lsl.w    #8,d1
  312.     move.b    (a2)+,d1
  313. 2$    cmp.w    d1,d0
  314.     beq.s    StrXpy1
  315.     add.w    d5,a2
  316.     bra.s    1$
  317.  
  318. PFPutC    move.b    d0,(a3)+
  319.     rts
  320.  
  321. ; Replacement of exec/Alert()
  322.  
  323.     ifnd    EXEC
  324.  
  325. AlertFunc
  326.     ifnd    DEBUG
  327.     move.w    #INTF_INTEN,$dff000+intena
  328.     endc
  329.  
  330.     movem.l    d0-d1/a0-a1/a5-a6,-(sp)
  331.     move.l    #'HELP',d0
  332.     sub.l    a0,a0
  333.  
  334.     ifnd    DEBUG
  335.     cmp.l    (a0),d0
  336.     beq.s    BlinkAlert
  337.     move.l    d0,(a0)
  338.     endc
  339.  
  340.     lea    $100.w,a1
  341.     move.l    d7,(a1)+
  342.     move.l    a5,(a1)
  343.     move.l    4.w,d0
  344.     btst    #0,d0
  345.     bne.s    BlinkAlert
  346.     move.l    d0,a6
  347.     add.l    ChkBase(a6),d0
  348.     addq.l    #1,d0
  349.     bne.s    BlinkAlert
  350.     move.l    ThisTask(a6),a5
  351.     move.l    a5,(a1)
  352.     move.l    #$F376C7C9,d0
  353.     push    d0
  354.     cmp.l    (sp)+,d0
  355.     bne.s    BlinkAlertSP
  356.     tst.l    d7
  357.     bmi.s    BlinkAlert
  358.     lea    LastAlert(a6),a0
  359.     move.l    d7,(a0)+
  360.     move.l    a5,(a0)
  361.     bsr    DispAlert
  362.     tst.l    IDNestCnt(a6)
  363.     bge.s    YetDisabled
  364.     move.w    #INTF_SETCLR+INTF_INTEN,$dff000+intena
  365. YetDisabled    moveq    #1,d0
  366.     moveq    #5,d1
  367.     ifnd    DEBUG
  368. WaitDiskDMA    tst.w    $dff000+dskbytr
  369.     dbf    d0,WaitDiskDMA
  370.     dbf    d1,WaitDiskDMA
  371.     endc
  372.     movem.l    (sp)+,d0-d1/a0-a1/a5-a6
  373.     rts
  374.  
  375. BlinkAlertSP    lea    $400.w,sp
  376.     clr.l    -(sp)
  377.     clr.l    -(sp)
  378. BlinkAlert    movem.l    d0-d1/a0-a1/a5-a6,-(sp)
  379.     sub.l    a0,a0
  380.     tst.l    $C.w    ; Obey SinSoft's rules of VBR remapping
  381.     bne.s    1$
  382.     move.l    8.w,a0
  383. 1$    lea    MyStart(pc),a1
  384.     move.l    a1,$20(a0)
  385. MyStart    move.w    #$2700,sr
  386.  
  387.     moveq    #5,d1    ; Start blinking (6 times)
  388. ;;    lea    $dff000,a0
  389. ;;    move.w    #$174,serper(a0)
  390. Blink1    moveq    #-1,d0
  391. 1$    bset    #1,$bfe001
  392.     dbf    d0,1$
  393. 2$    bclr    #1,$bfe001
  394.     dbf    d0,2$
  395. ;;    move.w    serdatr(a0),d0
  396. ;;    move.w    #INTF_RBF,intreq(a0)
  397. ;;    and.b    #$7F,d0
  398. ;;    addq.b    #1,d0
  399. ;;    dbmi    d1,Blink1
  400.     dbra    d1,Blink1
  401.  
  402. ;;    movem.l    (sp)+,d0-d1/a0-a1/a5-a6
  403. ;; Debugging not supported ... Reboot always
  404.  
  405. RestartSystem    lea    $1000000,a0    ; Supervisor mode expected
  406.     sub.l    -$14(a0),a0
  407.     move.l    4(a0),a0
  408.     jmp    -2(a0)
  409.  
  410.     endc
  411.  
  412.     dc.w    Spec_cpu-Specific
  413. Specific    dc.w    Spec_exec-Specific
  414.     dc.w    Spec_graphics-Specific
  415.     dc.w    Spec_layers-Specific
  416.     dc.w    Spec_intuition-Specific
  417.     dc.w    Spec_math-Specific
  418.     dc.w    Spec_dos-Specific
  419.     dc.w    Spec_ram-Specific
  420.     dc.w    Spec_icon-Specific
  421.     dc.w    Spec_expansion-Specific
  422.     dc.w    Spec_diskfont-Specific
  423.     dc.w    Spec_utility-Specific
  424.     dc.w    Spec_keymap-Specific
  425.     dc.w    Spec_audio-Specific
  426.     dc.w    Spec_console-Specific
  427.     dc.w    Spec_gameport-Specific
  428.     dc.w    Spec_keyboard-Specific
  429.     dc.w    Spec_trackdisk-Specific
  430.     dc.w    Spec_timer-Specific
  431.     dc.w    Spec_cia-Specific
  432.     dc.w    Spec_disk-Specific
  433.     dc.w    Spec_misc-Specific
  434.     dc.w    Spec_bootstrap-Specific
  435.     dc.w    Spec_workbench-Specific
  436.     dc.w    Spec_diskcopy-Specific
  437.     dc.w    Spec_gadtools-Specific
  438.     dc.w    Spec_utility-Specific
  439.     dc.w    Spec_unknown-Specific
  440.  
  441. STRCNT    set    $FF
  442. str    macro
  443. K\1    equ    STRCNT
  444. STRCNT    set    STRCNT-1
  445.     dc.b    \@a-*-1,\2
  446. \@a
  447.     endm
  448.  
  449. Strings    dc.b    0
  450.     str    Library,<'library'>
  451.     str    Device,<'device'>
  452.     str    Resource,<'resource'>
  453.     str    Lib,<'.',KLibrary>
  454.     str    Dev,<'.',KDevice>
  455.     str    Res,<'.',KResource>
  456.     str    Unable,<'Unable to '>
  457.     str    Open,<'open '>
  458.     str    Close,<'Close'>
  459.     str    Failed,<' failed'>
  460.     str    Unkn0,<'unknown'>
  461.     str    Unkn,<KUnkn0,KErr>
  462.     str    Err,<' ',KErr2>
  463.     str    Err2,<'error'>
  464.     str    Mem,<' ',KMemS>
  465.     str    MemS,<KMem0,' '>
  466.     str    Mem0,<'memory'>
  467.     str    Free,<'free'>
  468.     str    Bad,<'Bad '>
  469.     str    FFP,<'FFP '>
  470.     str    MMU,<'MMU '>
  471.     str    Instr,<' instruction'>
  472.     str    Disk,<'disk'>
  473.     str    NoMF,<'No',KMem,'for '>
  474.     str    Viol,<' violation'>
  475.     str    Erflow,<'erflow'>
  476.     str    Illegal,<'illegal'>
  477.     str    Interr,<'interrupt'>
  478.     str    Attempt,<'attempt'>
  479.     str    Util,<'utility'>
  480.     str    To,<'to'>
  481.     str    Frame,<' frame'>
  482.     str    Scr,<'screen'>
  483.     str    Intui,<'intuition'>
  484.     str    Messg,<'message'>
  485.     str    Init,<'init'>
  486.     str    Line,<'line '>
  487.     str    DivZ,<'division by zero'>
  488.     str    Timer,<'timer'>
  489.     str    Already,<' already '>
  490.     str    MemList,<KMem,'list'>
  491.     str    Item,<'item'>
  492.     str    Type,<'