[net.micro.atari16] Screen saver/dimmer

K538915@CZHRZU1A.BITNET (06/15/86)

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

gordon@sage.cs.reading.Ac.Uk (Simon Gordon) (06/21/86)

In article <8606172339.AA28794@ucbvax.Berkeley.EDU> K538915@CZHRZU1A.BITNET.UUCP writes:
>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!
>
Ive got a rather good screen saver which i will try to send in some time.
Once the program is run it is hooked into the screendump VBL interupt.
If you type alt help the full pallette and screen data are saved to disk
in degas format. I have converters to go degas>neo neo>degas.

(unfortunately my st isnt connected to the net, so it may be a while before
i can do so)

Thsi works with allmost all games (not bratacus as it replaces the os)
(only monochrome pawn as in colour a split mode is used so they take over
the interupts.)

It apears to have no side affects - i used this to give my local dealer a
good slide demo, and when one of the assistants saw the megaroids screen he
 decided
to play it - and couldnt work out why it didnt work

ps. Im also writing a backup program that can duplicate ANY floppy disk
on the ST. Ill tell you all when its finished.

Simon@sage@reading