Re: USRx() and adding more parameters?

Sean Conner via Coco <coco-uNHYcr1XS/wmlAP/[email protected]>
Newsgroups gmane.comp.hardware.tandy.coco
Message-ID <[email protected]>
It was thus said that the Great Bill Gunshannon via Coco once stated:
> 
> On 11/5/2025 1:13 PM, Sean Conner via Coco wrote:
> >It was thus said that the Great Allen Huffman via Coco once stated:
> >>The BASIC ROM has the USR function:
> >>
> >>DEF USR0=&H3F00
> >>
> >>A=USR0(42)
> >>
> >>It accepts one parameter.
> >>
> >>Since it jumps from BASIC into the USR assembly, couldn’t that code just
> >>parse a “,” and more numbers, allowing it to accept whatever needed 
> >>to be
> >>passed in?
> >>
> >>A=USR0(1,2,3,4)
> >
> >   Attached is another proof-of-concept.  This implements a USRn function
> >that draws a pattern (8x8, based on early Mac background patterns) on the
> >screen in a given area, and cycles through 38 such patterns when you hit a
> >key.  It works best in PMODEs 0, 2 or 4.  The critical line is:
> >
> >	110 X=USR0(P),(65,49)-(190,142)
> >
> >The first parameter is the pattern #, then a comma, then the upper left
> >corner, then the lower right corner of the area to draw the pattern, using
> >the code BASIC uses to parse the LINE command.  Looks weird, but it works.
> 
> Wouldn't it just be easier to pass an address as that  one argument and 
> have it point to a block containing as many parameters as you want?

  Easier for who?  The implementor?  Or the user?  Here, I can type this at
the BASIC prompt and have it work:

	X=USR0(3),(20,40)-(100,120)

or even

	X=USR0(3),(X,Y)-(X+15,Y+30)

  Otherwise, the code that doesn't do the extra parsing looks like:

	110 POKE32736,20:POKE32737,40:POKE32738,100:POKE32739,120:X=USR0(32736)

or:

	101 X1=32736:Y1=X1+1:X2=X1+2:Y2=X1+3
	110 POKEX1,20:POKEY1,40:POKEX2=100:POKEY2=120:X=USR0(X1)

  Also, the amount of code I added to support this wasn't much---it was just
two additional ROM calls:

	call	$B26D	; skip past comma
	call	$938F	; parse (x,y)-(x,y)
			; results in HORBEG,VERBEG,HOREND,VEREND
			; in the direct page

  Technically, these two calls are undocumented, but at this point, I don't
think Microsoft is going to release a new version of Color BASIC or Extended
Color BASIC, making this type of thing easier to do now.

  -spc

-- 
Coco mailing list
[email protected]
https://pairlist5.pair.net/mailman/listinfo/coco
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.