🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.atari16
Article #891

Screen saver/dimmer

#891
From: K538915
Date: Sun, 15 Jun 1986 13:41
453 lines
11339 bytes
2 screen savers: the first one cycles thru the palette registers
                 (you could make this one even fancier, but i've
                  only got a monochrome set),
                 the second one turns the internal gereration of the
                 horizontal and vertical sync pulses off. This results
                 in a nice black screen, but it also means you lose
                 the hblank and vblank interrupts.
                 ----->>>any routine in the vblank queue stops
                 ----->>>disk changes will not be noticed
                 ----->>>drives will not be deselected
                 so dont flame me if you scramble your disk!!
                 If anybody finds a way of using a timer interrupt
                 to get around this: tell me!

 Use following batch file to assemble and link the programs:

 as68 -p -l %1.s
 link68 [u] %1.68k=%1
 rm %1.o
 relmod %1.68k %1.prg
 rm %1.68k
 wait

 ------->>>>>>> read the code and if you don't like it, change it!!!!


                             Simon
-----------------Cut here-----------------------------------------
******************************************************************
*
*               Screen Saver (c) V0.0 by S.Poole 1986
*
*               Use this at your own risk!!!!!!!
*
*
******************************************************************

gemdos      equ $1

keep        equ $31

xbios       equ $e

super       equ 38

nvbls       equ $454

vblqueue    equ $456

palbase     equ $FF8240

synmode     equ $FF820A

keyvec      equ $118

hires       equ 2

midres      equ 1

lores       equ 0

modereg     equ $FF8260


* for the monochrome monitor a value of 70 is one second
* for color monitors 60 or 50
*
* a value of 21000 waits 5 minutes before turning the screen off
waittime    equ 21000

changetime  equ 70

bpgsize     equ $100

textlen     equ $C

datalen     equ $14

bsslen      equ $1C

       .text

* put routine in VBL-queue and catch keyboard-midi interrupt

init:

*         calculate size of program and save it

          movea.l    $0004(A7),A0
          move.l     #bpgsize,D6
          add.l      textlen(A0),D6
          add.l      datalen(A0),D6
          add.l      bsslen(A0),D6
          move.l     d6,len

*         print starting message

          move.l     #msg1,a0
          bsr        prstr

*         execute the putvbl routine in supervisor mode

          move.l     #putvbl,-(sp)
          move       #super,-(sp)
          trap       #xbios

*         if result of putvbl negative (=no slot found) terminate

          bmi        abort

*         otherwise  terminate and stay resident

          clr.w      -(A7)
          move.l     D6,-(A7)
          move.w     #keep,-(A7)
abort:    trap       #gemdos

****************************************************************

*         find an empty slot and install screen saver

putvbl:   move       nvbls,d0
            lsl        #2,d0
          move.l     vblqueue,a0
          clr        d1
loop1:    tst.l      (a0,d1)
          beq        free
          addq       #4,d1
          cmp        d0,d1
          bne        loop1
          move.l     -1,d0
          tst.l      d0
          rts

*         there was a free slot: so put address of screen saver in it

free:     move.l     #start,(a0,d1)

*         get keyboard and midi interrupt vector and save it

          move.l     keyvec,saveint

*         put our interrupt vektor in its place

          move.l     #newint,keyvec
          rts

*         a small routine to print strings

prstr:    move.l     a0,-(sp)
          move.w     #9,-(sp)
          trap       #gemdos
          addq.l     #6,sp
          rts

***************************************************************
***************************************************************


* our interrupt handler
*
*   don't forget: this routine is not allowed to use any
*   registers
*
*         reset the counter

newint:   move.w     #waittime,count

          cmpi.w     #1,flag
          bne        toold

*         stop cycling the palettes

          move.w     #0,cflag

*         jump to the old interrupt routine

toold:    move.l     saveint,-(a7)
          rts

*****************************************************************
*****************************************************************

* screen saver


start:

*         its zero so don't do anything

empty:    cmpi.w     #0,count
          beq        finish

*         if cflag has been cleared, restore everything

          cmpi.w     #1,cflag
          beq        dec
restore:  move.w     #15,d0
          move.l     #palbase,a0
          move.l     #palsave,a1
reloop:   move.w     (a1)+,(a0)+
          dbra       d0,reloop
          move.w     #0,flag
          move.w     #1,cflag
          bra        finish


*         decrement count, if zero turn screen off and set flag


dec:      subq       #1,count
          cmpi.w     #0,count
          bne        finish

*         if screen already turned off, reset count and cycle colors

flagon:   cmpi.w     #1,flag
          bne        turnoff



cycle:    move.w     #changetime,count

*         its got a monochrome monitor

          btst       #1,modereg
          beq        mid
          bchg       #0,palbase
          bra        finish

*         its got a color monitor

mid:      move.l     #palbase,a0
          btst       #0,modereg
          beq        lo
          move.w     6(a0),d1
          move.w     #2,d0
          adda.l     #4,a0
midcycle: move.w     (a0)+,(a0)
          suba.l     #4,a0
          dbra       d0,midcycle
          move.w     d1,palbase
          bra        finish

lo:       move.w     30(a0),d1
          move.w     #14,d0
          adda.l     #28,a0
locycle:  move.w     (a0)+,(a0)
          suba.l     #4,a0
          dbra       d0,locycle
          move.w     d1,palbase
          bra        finish

*         save palette registers
*
*
turnoff:  move.w     #15,d0
          move.l     #palbase,a0
          move.l     #palsave,a1
storepal: move.w     (a0)+,(a1)+
          dbra       d0,storepal

          move.w     #1,flag
          bra        flagon

finish:
          rts

       .data
flag:     dc.w        0
cflag:    dc.w        1
count:    dc.w     waittime
saveint:  dc.l        0
palsave:  dc.w        0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
len:      dc.l        0
msg1:     dc.b     'Screen Saver (c) S.Poole 1986',0
       .end
------------------Cut here----------------------------------------
******************************************************************
*
*               Screen Saver V0.0sync (c) by S.Poole 1986
*
*               Use this at your own risk!!!!!!!
*
*               Important: this version stops the VBL-interrupt,
*                          it turns the internal HSync and VSync
*                          signals off.
*
******************************************************************

gemdos      equ $1

keep        equ $31

xbios       equ $e

super       equ 38

nvbls       equ $454

vblqueue    equ $456

synmode     equ $FF820A

keyvec      equ $118

* for the monochrome monitor a value of 70 is one second
* for color monitors 60 or 50
*
* a value of 21000 waits 5 minutes before turning the screen off
waittime    equ 21000

bpgsize     equ $100

textlen     equ $C

datalen     equ $14

bsslen      equ $1C

       .text

* put routine in VBL-queue and catch keyboard-midi interrupt

init:

*         calculate size of program and save it

          movea.l    $0004(A7),A0
          move.l     #bpgsize,D6
          add.l      textlen(A0),D6
          add.l      datalen(A0),D6
          add.l      bsslen(A0),D6
          move.l     d6,len

*         print starting message

          move.l     #msg1,a0
          bsr        prstr

*         execute the putvbl routine in supervisor mode

          move.l     #putvbl,-(sp)
          move       #super,-(sp)
          trap       #xbios

*         if result of putvbl negative (=no slot found) terminate

          bmi        abort

*         otherwise  terminate and stay resident

          clr.w      -(A7)
          move.l     D6,-(A7)
          move.w     #keep,-(A7)
abort:    trap       #gemdos

****************************************************************

*         find an empty slot and install screen saver

putvbl:   move       nvbls,d0
            lsl        #2,d0
          move.l     vblqueue,a0
          clr        d1
loop1:    tst.l      (a0,d1)
          beq        free
          addq       #4,d1
          cmp        d0,d1
          bne        loop1
          move.l     -1,d0
          tst.l      d0
          rts

*         there was a free slot: so put address of screen saver in it

free:     move.l     #start,(a0,d1)

*         get keyboard and midi interrupt vector and save it

          move.l     keyvec,saveint

*         put our interrupt vektor in its place

          move.l     #newint,keyvec
          rts

*         a small routine to print strings

prstr:    move.l     a0,-(sp)
          move.w     #9,-(sp)
          trap       #gemdos
          addq.l     #6,sp
          rts

***************************************************************
***************************************************************


* our interrupt handler
*
*   don't forget: this routine is not allowed to use any
*   registers
*
*         reset the counter

newint:   move.w     #waittime,count

*         if screen turned off: turn it back on

          cmpi.w     #1,flag
          bne        toold
          bchg       #0,synmode
          move.w     #0,flag

*         jump to the old interrupt routine

toold:    move.l     saveint,-(a7)
          rts

*****************************************************************
*****************************************************************

* screen saver


start:

*         its zero so don't do anything

empty:    cmpi.w     #0,count
          beq        finish

*
*         decrement count if zero turn screen off and set flag

          subq       #1,count
          cmpi.w     #0,count
          bne        finish


          bchg       #0,synmode
          move.w     #1,flag

finish:   rts

       .data
flag:     dc.w        0
count:    dc.w     waittime
saveint:  dc.l        0
len:      dc.l        0
msg1:     dc.b     'Screen Saver (c) S.Poole 1986',0
       .end
Technical Details
Message-ID: <8606172339.AA28794@ucbvax.Berkeley.EDU>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!ucbvax!CZHRZU1A.BITNET!K538915

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!ucbvax!CZHRZU1A.BITNET!K538915
From: K538915@CZHRZU1A.BITNET
Newsgroups: net.micro.atari16
Subject: Screen saver/dimmer
Message-ID: <8606172339.AA28794@ucbvax.Berkeley.EDU>
Date: Sun, 15-Jun-86 09:41:30 EDT
Article-I.D.: ucbvax.8606172339.AA28794
Posted: Sun Jun 15 09:41:30 1986
Date-Received: Thu, 19-Jun-86 07:45:46 EDT
Sender: daemon@ucbvax.BERKELEY.EDU
Organization: The ARPA Internet
Lines: 453