home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 25
/
CD_ASCQ_25_1095.iso
/
dos
/
tools
/
auror21a
/
scrsaver.aml
< prev
next >
Wrap
Text File
|
1995-08-31
|
4KB
|
167 lines
/* ------------------------------------------------------------------ */
/* Macro: SCRSAVER.AML */
/* Written by: nuText Systems */
/* */
/* Description: This macro is runs a simple screen saver, and */
/* demonstrates how to write directly to the physical */
/* screen. */
/* */
/* Usage: Select this macro from the Macro List (on the Macro */
/* menu), or run it from the macro picklist <shift f12> */
/* ------------------------------------------------------------------ */
include bootpath "define.aml"
var attr
var count
var interval
var minutes
var obj
// draw the screen saver
function drawsaver
// change to 50-line mode
oldrows = getvidrows
videomode 80 50
// create a dummy window that covers the whole screen,
// to prevent this demo from overwriting the existing screen
createwindow
setcolor 5 (color black on black)
display
// get the current mouse button state and position
buttonstate = button? 7fh
mousex = getmousex
mousey = getmousey
// get the screen dimensions
cols = getvidcols
rows = getvidrows
// hide the mouse
hidemouse
// make video functions use the actual physical screen,
// instead of the current window
gotoscreen
// string to write
str = "░░░"
// intial x,y position on the screen
x = (rand mod cols) + 1
y = (rand mod rows) + 1
// do until an external event occurs
while not event? do
// get next random x,y position
x = x + ((rand mod 3) - 1)
y = y + ((rand mod 3) - 1)
// correct x,y if not within screen boundry
if x > cols then
x = cols
elseif x < 1 then
x = 1
end
if y > rows then
y = rows
elseif y < 1 then
y = 1
end
// write the string
writestr str attr x y
// change the string and color periodically
count = count + 1
if count > interval then
count = 0
interval = 700
// random color
attr = rand mod 256
// random string
str = case rand mod 2
when 0 "░░░"
when 1 "▒▒▒"
end
end
end
// absorb any keys entered
while keyhit? do
getkey
end
// restore the screen
showmouse
destroywindow
videomode 80 oldrows
end
// screen saver timer management
function saver (f)
// remove timers
if f == -1 then
destroytimer "saver"
destroytimer "saver2"
// check for time expired
elseif f then
if _ecount <> geteventcount then
_ecount = geteventcount
settimer "saver2" minutes * 60000 obj
elseif not (timer? "saver2") then
// call screen saver function
drawsaver
_ecount = -1
end
// start the check timer
else
setrepeat "saver" 1000 obj "saver" 1
_ecount = -1
end
end
// check for a previous install
obj = lookup "saverobj" "prf"
if obj then
installed = TRUE
else
obj = getcurrobj
setxobj "saverobj" obj "prf"
end
// screen saver dialog box
dialog "Screen Saver" 46 6 "c"
field "Delay in minutes: >" 11 2 6 10
button "O&k" 3 5 8
button "&Test" 14 5 8
whenenter "drawsaver"
button "&Remove" 25 5 8
button "Cancel" 36 5 8
case (getdialog ref minutes)
// install screen saver
when "Ok"
if minutes then
saver
if not installed then
stayresident
end
msgbox "Screen Saver Installed, delay is " + minutes + " minutes."
end
// remove screen saver
when "Remove"
if installed then
saver -1
destroyobject obj
unsetx "saverobj" "prf"
msgbox "Screen Saver Removed."
end
end