home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d5xx / d537 / pblanker.lha / PBlanker / pbl.s < prev    next >
Text File  |  1991-08-26  |  6KB  |  263 lines

  1. *****************************************
  2. *       PAULS BLANKER        *
  3. *    by Paul Hayter (C)1991    *
  4. *                *
  5. *  based on Blanker2 on Amigan 17    *
  6. *    by Joe Hitchens        *
  7. * V1.0  910406            *
  8. * V1.1  910407 default blank in 2 mins    *
  9. *    optional screen blank time    *
  10. *    auto ptr blank in 10 secs    *
  11. *    mouse parabolic accelerator    *
  12. * V1.2  910413  Uses actual timestamp    *
  13. *    info in working out whether    *
  14. *    to blank or not        *
  15. * V1.3  910418  Processes all input    *
  16. *    events in the chain
  17. *****************************************
  18.  
  19. *    USAGE:
  20. *        pbl [time]
  21. *            time = time before blanking in seconds
  22. *    eg. pbl 180    {3 minutes}
  23. * NB: Does not need to be RUN
  24. * Also there is no way of changing settings or removing the blanker
  25.  
  26.         include "PHAD:defs/exec.defs"
  27.         include "PHAD:offs/exec.i"
  28.         include "PHAD:defs/devices.defs"
  29.         include "PHAD:defs/hardware.defs"
  30.     
  31. privatestore    equ    0
  32. PTblack        equ    privatestore    0=not blank
  33. SCblack        equ    PTblack+1        0=not blank
  34. last_ptr_secs    equ    SCblack+1
  35. last_scr_secs    equ    last_ptr_secs+4
  36. ptr_secs        equ    last_scr_secs+4
  37. scr_secs        equ    ptr_secs+4
  38. first_time    equ    scr_secs+4
  39.             
  40. SIZEOF_PS        equ    first_time+2
  41.  
  42.  
  43. custom        equ    $dff000
  44.  
  45. DEFAULT_PTR_BLANK    equ    10    10 seconds
  46. DEFAULT_SCR_BLANK    equ    120    2 minutes
  47.     
  48. START    move.l    #DEFAULT_SCR_BLANK,d7
  49.     sub.w    #$2,d0
  50.     blt    START2
  51.  
  52.     moveq    #0,d7
  53.     moveq    #0,d1
  54.     move.b    (a0)+,d1
  55. loop2    cmp.b    #$20,d1
  56.     beq.s    START2
  57.     sub.b    #$30,d1
  58.     mulu    #$A,d7
  59.     add.l    d1,d7
  60.     move.b    (a0)+,d1
  61.     dbra    d0,loop2
  62.  
  63. START2    move.l    4,a6
  64.     bsr    createport34
  65.     move.l    d0,msgport
  66.     move.l    d0,a0
  67.     bsr    createio48
  68.     move.l    d0,ioreq
  69.     lea    inputname(pc),a0
  70.     move.l    d0,a1
  71.     moveq    #0,d0
  72.     moveq    #0,d1
  73.     jsr    _LVOOpenDevice(a6)    OPEN INPUT.DEVICE
  74.     
  75.     move.l    #MEMF_CLEAR,D1
  76.     move.l    #endhandler-myhandler+IS_SIZE+SIZEOF_PS,d0
  77.     jsr    _LVOAllocMem(a6)
  78.     MOVE.L    D0,A3
  79.     lea    myhandler(pc),a0
  80.     lea    endhandler(pc),a1
  81.     move.l    d0,a2
  82. loop_1    move.b    (a0)+,(a2)+    COPY HANDLER CODE
  83.     cmp.l    a0,a1
  84.     bne.s    loop_1
  85.     
  86.     lea    privatepos(a3),a0
  87.     move.l    d7,scr_secs(a0)
  88.     move.l    #DEFAULT_PTR_BLANK,ptr_secs(a0)
  89.  
  90.     move.l    a0,IS_DATA+intpos(a3)
  91.     
  92.     move.l    a3,IS_CODE+intpos(a3)
  93.     move.b    #51,IS_NODE+LN_PRI+intpos(a3)
  94. *        handlerStuff->is_Node.ln_Name = p->Name;
  95.     move.l    ioreq(pc),a4
  96.     move.w    #IND_ADDHANDLER,io_Command(a4)
  97.     lea    intpos(a3),a1
  98.     move.l    a1,io_Data(a4)
  99.  
  100.     move.l    a4,a1
  101.     jsr    _LVODoIO(a6)
  102.     move.l    a4,a1
  103.     jsr    _LVOCloseDevice(a6)
  104.  
  105.     move.l    a4,a0
  106.     bsr    deleteio
  107.     move.l    msgport(pc),a0
  108.     bsr    deleteport
  109.     moveq    #0,d0
  110.     rts
  111.     
  112.  
  113. createport34    moveq    #34,d0
  114.         sub.l    a0,a0
  115. createport    movem.l    d2/a2-a3,-(sp) in: d0 = SIZEOF; out: d0 = port
  116.         move.l    a0,a3        name*
  117.         addq.l    #4,d0        space for SIZEOF
  118.         move.l    d0,d2
  119.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  120.         jsr    _LVOAllocMem(a6)
  121.         move.l    d0,a2
  122.         tst.l    d0
  123.         beq.s    creaport1        -> no mem
  124.         move.l    d2,(a2)+        save SIZEOF
  125.         moveq    #-1,d0
  126.         jsr    _LVOAllocSignal(a6)
  127.         move.b    d0,MP_SIGBIT(a2)
  128.         bmi.s    creaporte        -> no sigbit
  129.         sub.l    a1,a1
  130.         jsr    _LVOFindTask(a6)
  131.         move.l    d0,MP_SIGTASK(a2)
  132.         move.b    #NT_MSGPORT,LN_TYPE(a2)
  133.         move.l    a3,LN_NAME(a2)
  134.         move.b    #PA_SIGNAL,MP_FLAGS(a2)
  135.         lea    MP_MSGLIST(a2),a0
  136. ;  NEWLIST A0:
  137.         move.l    a0,(a0)
  138.         addq.l    #LH_TAIL,(a0)
  139.         clr.l    LH_TAIL(a0)
  140.         move.l    a0,(LH_TAIL+LN_PRED)(a0)
  141.         ;  ;
  142.         move.l    a2,d0
  143.         bra.s    creaport1
  144. deleteport    movem.l    d2/a2-a3,-(sp)    In: port in a0
  145.         move.l    a0,d0
  146.         beq.s    creaport1        -> no port to delete
  147.         move.l    a0,a2
  148.         moveq.l    #0,d0
  149.         move.b    MP_SIGBIT(a2),d0
  150.         bmi.s    creaporte        -> no sigbit to free
  151.         jsr    _LVOFreeSignal(a6)
  152. creaporte        move.l    -(a2),d0        SIZEOF
  153.         move.l    a2,a1
  154.         jsr    _LVOFreeMem(a6)
  155.         moveq.l    #0,d0
  156. creaport1        movem.l    (sp)+,d2/a2-a3
  157.         move.l    d0,a0
  158.         rts
  159.  
  160. createio48    moveq    #48,d0
  161. createio        movem.l    d2/a2,-(sp)    in: d0=SIZEOF, a0=MsgPort; out: d0=ioreq
  162.         move.l    a0,a2        save msgport*
  163.         addq    #4,d0        space for SIZEOF
  164.         move.l    d0,d2
  165.         move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  166.         jsr    _LVOAllocMem(a6)
  167.         move.l    d0,a0
  168.         tst.l    d0
  169.         beq.s    createio_e        -> no mem
  170.         move.l    d2,(a0)+        save SIZEOF
  171.         move.l    a2,MN_REPLYPORT(a0)
  172.         move.b    #NT_MESSAGE,LN_TYPE(a0)
  173.         subq    #4,d2            subtract SIZEOF(SIZEOF)
  174.         move.w    d2,MN_LENGTH(a0)
  175.         move.l    a0,d0
  176. createio_e    movem.l    (sp)+,d2/a2
  177.         rts
  178.  
  179. deleteio        move.l    a0,d0        in: a0 = ioreq
  180.         beq.s    deleteio0        -> nothing to delete
  181.         move.l    a0,a1
  182.         move.l    -(a1),d0        get SIZEOF
  183.         jsr    _LVOFreeMem(a6)
  184. deleteio0        rts
  185.  
  186. ** my input handler, on entry A0=input event, A1=private data
  187. myhandler    
  188.     movem.l    a0/a2,-(sp)
  189.     lea    custom+dmacon,a2
  190. LOOPY    move.b    ie_Class(a0),d1
  191.     cmp.b    #IECLASS_TIMER,d1
  192.     bne.s    try_rawmouse
  193.     move.l    ie_TimeStamp(a0),d0        READ SECONDS COUNT
  194.     tst.b    first_time(a1)
  195.     bne.s    2$
  196.     move.l    d0,last_ptr_secs(a1)
  197.     move.l    d0,last_scr_secs(a1)
  198.     move.b    #1,first_time(a1)
  199. 2$
  200.     sub.l    last_scr_secs(a1),d0    d0=timeelapsed in seconds
  201.     cmp.l    scr_secs(a1),d0
  202.     blo.s    bump_ptr_stuff
  203.     move.w    #0+DMAF_RASTER+DMAF_COPPER,(a2)
  204.     clr.w    color-dmacon(a2)        SET BLACK SCREEN
  205.     clr.l    spr+sd_dataa-dmacon(a2)    MAKE SURE SPRITE GOES
  206.     move.b    #1,SCblack(a1)    set blackflag
  207. bump_ptr_stuff
  208.     move.l    ie_TimeStamp(a0),d0
  209.     sub.l    last_ptr_secs(a1),d0    d0=timeelapsed in seconds
  210.     cmp.l    ptr_secs(a1),d0
  211.     blo.s    quit_hdl
  212.     move.w    #0+$20,(a2)    turn sprites off.
  213.     clr.l    spr+sd_dataa-dmacon(a2)
  214.     move.b    #1,PTblack(a1)
  215. quit_hdl    move.l    (a0),d0    get next event
  216.     move.l    d0,a0
  217.     bne.s    LOOPY
  218.     movem.l    (sp)+,a0/a2
  219.     move.l    a0,d0
  220.     rts
  221. try_rawmouse
  222.     cmp.b    #IECLASS_RAWMOUSE,d1
  223.     bne.s    try_rawkey
  224. acc_x    move.w    ie_X(a0),d1    MOUSE ACCELERATION
  225.     muls    d1,d1
  226.     tst.w    ie_X(a0)
  227.     bpl    1$
  228.     neg.w    d1
  229. 1$
  230.     move.w    d1,ie_X(a0)
  231. acc_y    move.w    ie_Y(a0),d1
  232.     muls    d1,d1
  233.     tst.w    ie_Y(a0)
  234.     bpl    2$
  235.     neg.w    d1
  236. 2$
  237.     move.w    d1,ie_Y(a0)
  238. ptr_on    move.w    #$8000+$20,(a2)    sprite on
  239.     clr.b    PTblack(a1)
  240.     move.l    ie_TimeStamp(a0),last_ptr_secs(a1)
  241. lites_on    move.w    #$8000+DMAF_RASTER+DMAF_COPPER,(a2)    screen on
  242.     clr.b    SCblack(a1)
  243.     move.l    ie_TimeStamp(a0),last_scr_secs(a1)
  244.     bra.s    quit_hdl
  245. try_rawkey
  246.     cmp.b    #IECLASS_RAWKEY,d1
  247.     beq.s    lites_on
  248.     bra.s    quit_hdl
  249.     
  250. endhandler
  251.  
  252. **positions in code block
  253. codepos        equ    0
  254. privatepos    equ    endhandler-myhandler
  255. intpos        equ    privatepos+SIZEOF_PS
  256.     
  257. ** DATA
  258. ioreq        dc.l    0
  259. msgport        dc.l    0
  260. inputname        dc.b    'input.device',0
  261.     
  262.     END    
  263.