Metropoli BBS
VIEWER: rain.s MODE: TEXT (ASCII)
	TITLE	Rain  v1.0

ASSEMBLE

**** Unsupported entry point
PopASavPtr	EQU	#3251C

**** EQUates
wait		EQU	150
nlines		EQU	64
RPL

::
  CK1NoBlame			( make sure there is an object to pop )
  TURNMENUOFF			( turn off the menu bar )
CODE
	GOSBVL	=PopASavPtr	pop object
	AD1EX
	C=DAT1	A
	LA(5)	=DOGROB		grob check
	?A=C	A
	GOYES	typeOK
	LA(5)	=argtypeerr	"Bad Argument Type"
	GOTO	ErrOut
typeOK
	D1=D1+	10		point past prolog and length
	C=DAT1	A
	LA(5)	=nlines		height check
	?A=C	A
	GOYES	heightOK
	LA(5)	=argvalerr	"Bad Argument Value"
	GOTO	ErrOut	
heightOK
	D1=D1+	5
	C=DAT1	A
	LA(5)	131		width check
	?A=C	A
	GOYES	widthOK
	LA(5)	=argvalerr	"Bad Argument Value"

** and fall into Error exit....
ErrOut	GOSBVL	=GETPTR		we need to restore D1
	GOVLNG	=Errjmp		Error exit here for convienience

widthOK	D1=D1+	5		point to first nib of GROB data
	GOSBVL	=D0->Row1
	CD0EX
	RSTK=C			save HARDBUFF address
	CD0EX

	AD1EX
	LC(5)	34*63		NOTE : 63 is (=nlines)-1
	A=A+C	A
	AD1EX
	LC(2)	(=nlines)-1
	D=C	B

**
** OK, everything is initialized... start the outer loop
** 

Main							<------------------- \
	C=D	B		get outer loop counter			     |
	B=C	B		initialise inner loop counter		     |
*									     |
	C=RSTK			\					     |
	RSTK=C			 > Reset the Write Addr to top of HARDBUFF   |
	D0=C			/					     |
*									     |
****** Start of inner loop ******					     |
Inner								<------ \    |
	C=DAT1	W		first 16 nibs				|    |
	DAT0=C	W							|    |
	D1=D1+	16							|    |
	D0=D0+	16							|    |
	C=DAT1	W		next 16 nibs				|    |
	DAT0=C	W							|    |
	D1=D1+	16							|    |
	D0=D0+	16							|    |
	C=DAT1	B		last 2 nibs				|    |
	DAT0=C	B							|    |
*	D1=D1+	2		don't do this 'cos we back up 32 nibs	|    |
	D0=D0+	2							|    |
*									|    |
	AD1EX			\					|    |
	LC(5)	32		 \ Reset the				|    |
	A=A-C	A		 / read address				|    |
	AD1EX			/					|    |
*									|    |
	LA(5)	=wait		\					|    |
dec	A=A-1	A		 > wait a bit... we are too fast!	|    |
	GONC	dec		/					|    |
*									|    |
	B=B-1	B		check inner loop counter		|    |
	GONC	Inner				------------------------'    |
*									     |
** Finished one line, so back up Read Address and do next line		     |
	AD1EX			\					     |
	LC(5)	34		 \ back up the read address		     |
	A=A-C	A		 / another line ready for inner loop	     |
	AD1EX			/					     |
*									     |
	D=D-1	B		check outer loop counter		     |
	GONC	Main						-------------'

	C=RSTK			Make sure we don't leave @ HARDBUFF in RSTK

	GOVLNG	=GETPTRLOOP	all finished, so restore registers & exit
ENDCODE
;
[ RETURN TO DIRECTORY ]