home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-386-Vol-2of3.iso
/
s
/
stblsrc.zip
/
STBLPRG.ASM
< prev
Wrap
Assembly Source File
|
1989-04-06
|
28KB
|
757 lines
*****************************************************************
* General purpose screen blanking desk accessory - PRG part *
*****************************************************************
* Language : 68000 assembler *
* Assembler : Metacomco (Version 12.0) *
* Version : 2.0.1 *
* Date created : 1989/08/24 *
* Last modified : 1993/01/22 *
*****************************************************************
* HISTORY *
*****************************************************************
* Ver * Date * Comments *
*****************************************************************
* 1.0.0 * 01/09/89 * First release *
*****************************************************************
* 1.0.1 * 01/09/89 * All A-Line variables are now saved and *
* restored to prevent crashes in applications software *
*****************************************************************
* 1.0.2 * 02/09/89 * A-Line code replaced by own plotting code *
* and stack size increased, both to prevent application crashes *
*****************************************************************
* 1.1.0 * 01/12/89 * Star table changed so that it will work on *
* ST's with a 32-bit address bus (i.e. TT machine). Stars ON/OFF*
* option added to dialogue, along with star speed selector. Full*
* version information appears on accessory menu slot *
*****************************************************************
* 1.2.0 * 03/04/90 * Improved XBRA installation, and BIOS output*
* to PRT, AUX, CON or MIDI is counted as "activity" *
*****************************************************************
* 1.2.1 * 03/04/90 * All key presses now detected by virtue of *
* and IKBD interrupt handler. Since this same routine also *
* handles mouse packets, the old mouse handler is not required, *
* and button presses are now recognised, as is joystick movement*
*****************************************************************
* 1.2.2 * 04/04/90 * Error messages now output when ST Blank *
* fails to install *
*****************************************************************
* 1.2.3 * 21/05/90 * Bug fixed in BIOS intercept that caused *
* G+PLUS to crash *
*****************************************************************
* 1.3.0 * 24/09/90 * Save / Load config option added, some code *
* reorganisation *
*****************************************************************
* 1.3.1 * 20/10/90 * BIOS TRAP handler modified to cope with the*
* longer stack frame of the '010, 020, 030 and 040 processors *
*****************************************************************
* 2.0.0 * 21/09/91 * Splitting of ST Blank into resident .PRG *
* and configuring ACC/PRG *
*****************************************************************
* 2.0.1 * 22/01/93 * Fix bug that caused .PRG part to crash if *
* .INF file not found *
*****************************************************************
INCLUDE "STBLANK.I"
*****************************************************************
* The "Permanent" code section *
*****************************************************************
start:
bra GO Call the installation code
******************** Interrupt handlers *************************
* IKBD interrupt handler
okhand equ *+8 Address of "old" IKBD handler
xblock insert XBRA block
khandler:
movem.l d0/a0,-(sp) save regs
lea KACIA,a0 Get address of keyboard ACIA
move.b (a0),d0 Get ACIA status
btst #7,d0 Interrupt request?
beq not_kb No
btst #0,d0 Receiver buffer full?
beq not_kb No
bsr activity There was keyboard activity
not_kb movem.l (sp)+,d0/a0 retrieve regs
move.l okhand,-(sp)
rts exec old routine
* New 200Hz interrupt handler
oh200 equ *+8 To hold old 200Hz vector
xblock XBRA block
hz_200:
addq.w #1,timer Increment our timer
tst.w active Is blanker active?
beq q_h200 quit if not
tst.l counter Is countdown zero?
beq q_h200 quit if is
subq.l #1,counter else decrement counter
q_h200
move.l oh200,-(sp)
rts
* BIOS TRAP vector handler
oldbios equ *+8 To hold "old" BIOS vector
xblock XBRA header
bios:
move.l a0,-(sp) Save a0
btst #13,4(sp) Called from super mode?
beq 1$ jif not
* Yes, called from SUPER
move.l sp,a0 a0=SSP+10
lea.l 10(a0),a0 (first parm is at SSP+10)
tst.w longframe 68000 processor?
beq 2$ Fine if so
lea.l 2(a0),a0 Account for extra word
bra 2$
* No, called from USER
1$ move.l USP,a0 USP points to first parameter
2$ cmp.w #Bconout,(a0) Bconout function call?
bne not_op ignore if not
cmp.w #ikbd,2(a0) IKBD device
beq not_op Skip if IKBD output
op_act bsr activity There was some activity
not_op move.l (sp)+,a0 Retreive a0
move.l oldbios,-(sp) stack old BIOS address
rts and call it.
activity:
move.l timeout,counter Reset the counter
* Quick hack:
* addq.l #1,$F8000 Show activity
* For testing!
rts
* Vertical blank interrupt handler
xblock XBRA block
blnk_vbl:
tst.w active Blanker active?
beq q_vbl jif not
tst.w flock Floppies active?
beq tst_blnk If not, check for blanking
q_vbl rts
tst_blnk
tst.l counter Is counter=0
beq wait If so, blank screen
bra q_vbl
wait:
bsr savscreen Save screen
tst.w star_disp Stars enabled?
bne 3$
bsr starsetup prepare stars
1$ tst.w star_disp Stars On flag
bne 3$ If not, no stars
bsr dostars Do one frame of stars
3$ tst.l counter Check counter
beq 1$ if zero, keep doing stars
2$ bsr restscreen restore screen
move.l timeout,counter restore countdown
bra q_vbl and continue normal processing
savscreen:
move.l #membuff,a0 Get address of memory buffer
lea.l col_pal,a1 Address of palette registers
moveq #1,d0 two 16 byte blocks to a palette
bsr cpy
colour move.w #$0FFF,col_pal+2 Colour 1=white (FFF for expanded palettes)
sav_s move.l _v_bas_ad,a1 and address of screen memory
move.w #1999,d0 2000 16 byte blocks to a screen
bsr cpy
rts
cpy move.l (a1),(a0)+ copy word
clr.l (a1)+ and clear screen at same time
move.l (a1),(a0)+
clr.l (a1)+
move.l (a1),(a0)+
clr.l (a1)+
move.l (a1),(a0)+
clr.l (a1)+
dbf d0,cpy Until done
rts
restscreen:
lea col_pal,a0 Get address of colour palette
move.l #membuff,a1 and address of buffer
moveq #1,d0 2 16 byte blocks in a palette
bsr cpy Restore palette
move.l _v_bas_ad,a0 Address of screen
move.w #1999,d0 2000 16 byte blocks to a screen
bsr cpy Restore screen
rts
starsetup:
lea sp_list(pc),a0 Initialise star pointer
move.l #s1,(a0)+
move.l #s2+8,(a0)+
move.l #s3+16,(a0)+
move.l #s4,(a0)+
move.l #s5+4,(a0)+
move.l #s6+12,(a0)+
move.l #s7,(a0)+
move.l #s8+20,(a0)+
move.l #s9+4,(a0)+
move.l #s10+24,(a0)+
move.l #s11,(a0)+
move.l #s12+4,(a0)+
move.l #s13+12,(a0)+
move.l #s14+28,(a0)+
move.l #s15,(a0)+
move.l #s16+20,(a0)+
move.l #s17+8,(a0)+
move.l #s18+4,(a0)
lea sp_list(pc),a0 Back to start of list
moveq #17,d2 18 sets of coords
set_p move.l (a0)+,a1
move.w (a1),d0
move.w 2(a1),d1
bsr point Plot first star of each
dbf d2,set_p
rts
dostars:
lea sp_list(pc),a1 Pointer to list of pointers to star coords
moveq #17,d3 18 lists
do_s move.l (a1),a0 Get star pointer
bsr do_next remove previous & draw new star
dbf d3,do_s
bsr delay
rts
do_next
move.w (a0)+,d0 Get old x coord
move.w (a0)+,d1 and y coord
tst.w d0 is d0 negative?
bmi wrap handle end of table if so
r_old move.l a0,(a1)+
bsr point Remove old point
move.w (a0),d0 Get new x coord
move.w 2(a0),d1 and y coord
bsr point plot it
rts
wrap move.l (a0),d2 Get next longword
move.l d2,a0 it's the address of the start of the table
bra r_old
delay:
clr.w timer Zero timer
wait_timer:
move.w timer,d0
cmp.w star_delay,d0
blo wait_timer
rts
point:
movem.l d0-d3/a0,-(sp) Save regs
move.l _v_bas_ad,a0 Base address of screen
move.b res,d2 Get res from hardware
and.b #3,d2 Isolate screen resolution
cmp.b #2,d2 High res
beq plot_hi No prelim. action necessary
lsr.w #1,d1 divide y coord by 2
cmp.b #1,d2 Med res?
beq plot_med That's all if so
lsr.w #1,d0 Else halve x coord too
plot_low:
mulu #160,d1 160 bytes per row
move d0,d3
lsr #1,d3
and #$FFF8,d3 Horiz offset
comb_o add d3,d1 combine horiz+vert offsets
adda d1,a0 add to screen base addr
and #$F,d0 correct pixel
neg d0
add #15,d0
bchg d0,(a0) Toggle first bit plane (only
* want to do colour one)
unstack:
movem.l (sp)+,d0-d3/a0 Restore regs
rts
plot_med:
mulu #160,d1 160 bytes per row
move d0,d3
lsr #4,d3 /16 word offset per plane
lsl #1,d3 2 planes
add d3,d3 word offset -> byte offset
bra comb_o rest is common code
plot_hi:
mulu #80,d1 80 bytes per row
move d0,d2
lsr #4,d2 /16 word offset on row
add d2,d2 -> byte offset
add d2,d1 combine v+h offsets
adda d1,a0 add to screen base address
and #$F,d0 d0 now holds correct pixel
neg d0
add #15,d0 correct bit
bchg d0,(a0)
bra unstack unstack correct regs
***********************************************************************
* "PERMANENT" DATA SECTION *
***********************************************************************
* Data in this section is retained after the PRG terminates, and should
* be used for stuff that the interrupt handlers or ST Blank ACC/PRG
* references. Anything else can go in the "disposable" data section
ourdata:
* This data area is accessed by the ST Blank accessory/program
cnop 0,4 Longword align
savestart equ * Stuff to save/load starts here
mins ds.b 1 No. of minutes
secs ds.b 1 and secs to blankout
timeout ds.l 1 Time constant for countdown, set by user
star_delay:
dc.w 29 Delay as displayed to user
active dc.w 0 <>0 if blanking enabled
filler ds.w 1 Filler for backward compatibility
star_disp:
dc.w 0 0 = Display stars
* n = Don't display stars
lselect ds.w 1 Last radio button selected
saveend equ * End of save block
counter ds.l 1 Running countdown decremented by 200Hz interrupt
timer ds.w 1 Counter incremented by 200Hz interrupt
khandl ds.l 1 Address of IKBD interrupt vector
sp_list ds.l 18 List of pointers to pointers of star coordinates
* Coordinates for stars
m equ $80000000
coords:
s1 dc.w 308,196,290,191,263,184,220,170,159,151,075,127
dc.l m,s1
s2 dc.w 308,191,298,188,285,181,263,169,225,152,165,121
dc.w 087,081,003,039
dc.l m,s2
s3 dc.w 316,194,290,172,244,132,170,069,108,008
dc.l m,s3
s4 dc.w 318,194,314,183,302,157,284,112,259,051
dc.l m,s4
s5 dc.w 320,193,322,184,328,168,337,136,348,093,363,043
dc.l m,s5
s6 dc.w 322,195,327,188,337,182,351,166,371,148,399,119
dc.w 433,083,490,021
dc.l m,s6
s7 dc.w 325,195,347,184,381,163,429,135,494,100,569,053
dc.l m,s7
s8 dc.w 326,198,336,196,350,191,371,184,406,175,463,161
dc.w 531,142,623,119
dc.l m,s8
s9 dc.w 328,200,347,201,379,204,423,209,482,216,559,224
dc.l m,s9
s10 dc.w 330,204,339,209,354,215,373,223,397,235,435,251
dc.w 492,276,576,313
dc.l m,s10
s11 dc.w 328,206,339,215,357,231,385,253,430,289,494,340
dc.l m,s11
s12 dc.w 323,207,326,213,330,221,335,229,344,244,356,265
dc.w 372,295,395,335,423,385
dc.l m,s12
s13 dc.w 319,208,317,229,314,266,309,313,305,371
dc.l m,s13
s14 dc.w 311,209,308,216,300,226,288,242,272,265,249,296
dc.w 221,331,190,373
dc.l m,s14
s15 dc.w 304,210,286,224,249,254,189,292,115,349
dc.l m,s15
s16 dc.w 300,208,290,212,275,218,254,227,225,240,179,258
dc.w 123,283,057,311,000,336
dc.l m,s16
s17 dc.w 309,202,290,203,256,209,206,219,134,232,031,250
dc.l m,s17
s18 dc.w 302,197,293,197,279,196,257,194,227,191,182,187
dc.w 113,181,025,172
dc.l m,s18
************************************************************************
* "DISPOSABLE" CODE SECTION *
************************************************************************
membuff ds.l 16
* Code in this area becomes part of the screen buffer after the PRG
* terminates
GO:
move.l 4(a7),a5 Get address of basepage
move.l a5,basepage Save it
move.l #USTK,a7 Install stack
move.l basepage,d0 Address of base page
move.l #membuff,d1 Address of end of useful code
sub.l d0,d1 d1 := d1 - d0
add.l #32032,d1 Add length of screen and palette buffer
move.l d1,useful_len Save it
clr.w active Don't dare blank during installation
bsr installation Install
bsr file_load Load parameters
pea installmsg(pc) Address of text to be printed
move.w #Cconws,-(sp) Print it
trap #dos
addq.l #6,sp Tidy stack
* All OK,so now must Terminate and Stay Resident
move.w sactive,active Set activity word
move.w #0,-(sp) No errors
move.l useful_len,-(sp) No. of bytes to protect
move.w #Ptermres,-(sp)
trap #dos
file_load:
move.w #1,-(sp) Open file for reading
pea save_name(pc)
move.w #Fopen,-(sp)
trap #dos
addq.l #8,sp
tst.w d0 Errors?
bmi l_err Handle if so
move.w d0,f_handle Make note of handle returned
pea savestart(pc) Start of buffer to load
move.l #savelen,-(sp) Length of load info
move.w f_handle,-(sp) File handle
move.w #Fread,-(sp) Fread
trap #dos
lea.l 12(sp),sp tidy stack
move.w active,sactive
clr.w active Don't dare activate yet!
tst.l d0
bmi l_err_r load error
cmp.l #savelen,d0 All information loaded?
bne l_err_r abort if not
bsr fclose
tst.w d0 Error?
bmi l_err
rts
fclose:
move.w f_handle,-(sp) Close file
move.w #Fclose,-(sp)
trap #dos
addq.l #4,sp tidy
rts
l_err:
* Error opening/closing file
move.l #lerrmsg,d0
bsr printstg Print access error message
bsr set_defaults
rts
l_err_r:
* Error reading file
bsr fclose Attempt to close file
move.l #rerrmsg,d0
bsr printstg Print string
bsr set_defaults
rts
set_defaults:
move.b #2,mins Default 2 mins
move.b #0,secs 0 seconds
move.l #24000,timeout Equivalent in 5ms units
move.w #14,star_delay
move.w #1,active Default is to be active
move.w #1,sactive
clr.w star_disp With stars on
clr.w lselect No last button
rts
**************************** Install handlers **************************
installation:
clr.w ierror No errors yet
move.w #34,-(sp) kbdvbase funct
trap #xbios
addq.l #2,sp tidy
add.l #32,d0
move.l d0,khandl store IKBD interrupt vector
pea inst_crit(pc) Install interrupt routines
move.w #38,-(sp) Supexec call
trap #xbios
addq.l #6,sp tidy
rts All done
XBRAcheck:
* Checks vector addressed by a0,for installation with address
* in a1. Attempts to handle re-installation by virtue of XBRA
* protocol.
move.l (a0),a2 Get address from vector
tst.l (a0) Zero vectors are special
beq xb_install so just get on with it
cmp.l #xb_magic,-12(a2) Something already installed with XBRA?
bne xb_install Straight XBRA installation if not
cmp.l #xb_id,-8(a2) Has XBRA installed program got our ID?
bne xb_install If not,can install in XBRA chain
move.l -4(a2),-4(a1) Use old old vector
bra xb_i2 And continue installation
xb_install:
move.l a2,-4(a1) Save old vector value in our XBRA block
xb_i2 move.l a1,(a0) Install our new handler
rts Done
inst_crit:
or.w #$700,SR Interrupts off
* We're going to search the VBL queue backwards, because
* GEM always hijacks the first VBL entry, no matter what is
* already installed.
bsr inst_cookie Install cookie
move.w _bootdev,d0 Determine boot device
add.b #"A",d0 Turn into a drive name
move.b d0,save_name Insert in info file name
inst_vbl:
move.l _vblqueue,a0 Get address of VBL list
clr.l d0
move.w nvbls,d0 and no. of VBLs
subq.w #1,d0
asl.w #2,d0 convert to offset
fspace move.l 0(a0,d0.w),d1 Get routine address
beq free if it's zero,we can use it
move.l d1,a1 copy into a1
cmp.l #xb_id,-8(a1) Already installed?
beq free If so,reinstall
subq.l #4,d0 else search next slot
bne fspace until d0=0
* No free slots,so expand VBL list
clr.l d0
move.w nvbls,d0 No of VBLs
addq.l #8,d0 Add another 8 slots
move.l d0,-(sp) Save d0
asl.l #2,d0 Multiply d0 by 4
bsr our_malloc Allocate memory
move.l d0,a0 Get address of new memory
move.l _vblqueue,a1 Address of old VBL queue
move.w nvbls,d1 No of entries
subq.w #1,d1
xfer_vbls:
move.l (a1)+,(a0)+ Copy entry
dbf d1,xfer_vbls Until done
move.w #8-1,d1 Zero extra 8 slots
zap_vbl
clr.l (a0)+
dbf d1,zap_vbl
move.l d0,_vblqueue Install new queue
move.l (sp)+,d0 Get no. of new VBL slots back
move.l d0,nvbls And install
bra inst_vbl Go back and try again
free add.l d0,a0 Calc target vector
lea blnk_vbl(pc),a1 Aiming to install this addr.
bsr XBRAcheck now
move.l khandl,a0 IKBD handler vector
lea khandler(pc),a1 Address of new handler
bsr XBRAcheck Test for XBRA & install
i_mfp moveq.l #5,d0 5th MFP interrupt
asl.l #2,d0 convert to offset
add.l #$100,d0 MFP vector start address
move.l d0,a0 is the target
lea hz_200(pc),a1 want to install this
bsr XBRAcheck install
move.l #bios_trap,a0 Target vector
lea bios(pc),a1 What we want to install
bsr XBRAcheck install
q_inst and.w #$F8FF,SR Interrupts back on
rts Done!
printstg:
move.l d0,-(sp) Address of text to be printed
move.w #Cconws,-(sp) Cconws func
trap #dos
addq.l #6,sp tidy
rts
************************* Cookie jar stuff ************************
* Must be executed in supervisor mode
inst_cookie:
move.l _p_cookies,d0 Get cookie pointer
tst.l d0 Is it zero?
beq new_cookie If so,must install cookie jar
* Otherwise, look for free cookie slot
move.l d0,a0 Address of cookie jar in A0
clr.l d0 Zero counter
srch_cookie:
move.l (a0)+,d1 Get cookie
move.l (a0)+,d2 Get value of cookie
addq.l #1,d0 Increment counter
cmp.l #ourcookie,d1 One of ours?
beq our_cookie
tst.l d1 Zero cookie?
bne srch_cookie
cmp.l d0,d2 Jar full?
beq full_jar
clr.l (a0) New end marker
addq.l #1,d2
move.l d2,4(a0)
move.l #ourcookie,-8(a0) Our cookie
move.l #ourdata,-4(a0) Address of our data
rts Done
our_cookie:
* Already found our cookie
move.l #ourdata,-4(a0) Update to point to our data area
rts Done
new_cookie:
move.l #8,d0 8 slots in new cookie jar
bsr alloc_jar Allocate memory
move.l d0,a0
move.l #'_CPU',(a0)+ CPU type
move.l #0,(a0)+ Is 68000
move.l #'_VDO',(a0)+ Video shifter
move.l #0,(a0)+ Is standard ST version
move.l #'_SND',(a0)+ Sound hardware
move.l #0,(a0)+ Is standard Yamaha chip
move.l #'_MCH',(a0)+ Machine cookie
move.l #0,(a0)+ Is standard ST
move.l #ourcookie,(a0)+ Our cookie
move.l #ourdata,(a0)+ And data pointer
clr.l (a0)+ End of cookie marker
move.l #8,(a0) Eight cookie slots in the jar
move.l d0,_p_cookies Install jar
rts Done
full_jar:
addq.w #8,d0 Add an extra 8 slots
move.w d0,d2 Save new no. of slots
movem.l d1-d2,-(sp) Save these regs
bsr alloc_jar Allocate memory
movem.l (sp)+,d1-d2 Retrieve d1 and d2
move.l d0,a1 Address of new jar
move.l _p_cookies,d0
move.l d0,a0 Address of old jar
subq.w #1,d1 Set up no. of cookies to transfer
xfer_cookies:
move.l (a0)+,(a1)+ Transfer cookie
move.l (a0)+,(a1)+
dbra d1,xfer_cookies
move.l #ourcookie,(a1)+ Install our cookie
move.l #ourdata,(a1)+ And pointer to our data
clr.l (a1)+
move.l d2,(a1)+ Total number of cookies in jar
rts Done
alloc_jar:
asl.l #3,d0 Multiply d0 by 8
our_malloc:
move.l useful_len,d1 Current useful prog length
move.l basepage,d2 Address of base page
add.l d1,d2 Calc end of useful mem
add.l d0,d1 Add on size of new cookie jar
move.l d1,useful_len And assure its future
move.l d2,d0 Address of new cookie jar
rts Done
*************************************************************************
*** "DISPOSABLE" DATA SECTION ***
*************************************************************************
* The data in this section of the program will become part of the screen
* buffer when the .PRG terminates and therefore should not contain data
* referenced by the interrupt handlers (which should be put in the
* permanent data section)
useful_len ds.l 1 No. of useful bytes to retain upon termination
basepage ds.l 1 Address of basepage
f_handle ds.w 1 File handle
ierror ds.w 1 Installation error
sactive ds.w 1 Saved "active" word
installmsg:
dc.b 13,10
dc.b 27,'p ST Blank 2.0.1 installed '
dc.b 27,'q',13,10,0
lerrmsg:
dc.b 7,13,10,'*** Error accessing STBLANK.INF ***',13,10,0
rerrmsg:
dc.b 7,13,10,'*** Error reading STBLANK.INF ***',13,10,0
save_name
dc.b 'A:\STBLANK.INF',0
DS.L 99
USTK DS.L 1 Stack of 100 long_words
scratch_mem equ * Scratch memory starts here
END