[Coco] USRx() and adding more parameters?
Sean Conner
sean at conman.org
Wed Nov 5 13:13:57 EST 2025
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.
-spc
-------------- next part --------------
1 DATA50,120,189,179,237,16,131,0,38,16,36,54,174,88,73,88,73,88,73,195,126,208,31,1,52,16,189,178,109,189,147,143,158,189,156,195,35,8,220,195,30,16,159,189,221,195,158,191,156,197,35,8,220,197,30,16,159,191,221,197,150,182,129,4,39,4,4,190,4,196
2 DATA129,2,36,4,4,192,4,198,53,16,51,228,214,190,196,7,134,8,52,6,230,128,166,97,39,8,84,36,2,202,128,74,38,248,231,192,106,228,38,236,53,6,49,141,0,189,166,165,151,205,67,151,207,49,40,214,196,196,7,166,165,151,206,67,151,208,150,198,144,192,76
3 DATA151,209,220,195,147,189,195,0,1,221,210,158,186,150,185,214,192,61,48,139,214,190,84,84,84,58,214,190,196,7,79,211,210,16,131,0,8,46,15,150,205,154,206,151,205,67,151,207,220,210,221,214,32,13,214,190,196,7,231,226,198,8,224,224,79,221,214
4 DATA134,8,151,203,51,228,220,210,221,212,15,204,166,132,148,205,167,132,166,196,148,207,170,132,167,132,220,212,147,214,221,212,220,212,16,131,0,8,45,16,131,0,8,221,212,214,204,92,166,196,167,133,215,204,32,232,220,212,39,19,43,17,214,204,92,166
5 DATA133,148,206,167,133,166,196,148,208,170,133,167,133,214,185,58,51,65,10,209,39,6,10,203,38,170,32,162,50,104,57,0,128,192,224,240,248,252,254,127,63,31,15,7,3,1,0,0,0,0,0,0,0,0,0,34,0,136,0,34,0,136,0,34,136,34,136,34,136,34,136,85,170,85,170
6 DATA85,170,85,170,170,0,170,0,170,0,170,0,85,85,85,85,85,85,85,85,17,34,68,136,17,34,68,136,119,119,119,119,119,119,119,119,78,207,252,228,39,63,243,114,127,239,253,223,254,247,191,251,0,119,119,119,0,119,119,119,0,127,127,127,0,247,247,247,127
7 DATA255,255,255,255,255,255,255,127,191,223,255,253,251,247,255,125,187,198,187,125,254,254,254,7,139,221,184,112,232,221,142,170,95,191,191,170,245,251,251,223,175,119,119,119,119,250,253,255,128,128,158,158,158,158,128,255,255,255,255,255,255
8 DATA255,255,127,255,247,255,127,255,247,255,119,255,221,255,119,255,221,255,119,221,119,221,119,221,119,221,85,255,85,255,85,255,85,255,0,255,0,255,0,255,0,255,238,221,187,119,238,221,187,119,0,255,255,255,0,255,255,255,254,253,251,247,239,223
9 DATA191,127,85,255,127,255,119,255,127,255,0,127,127,127,127,127,127,127,247,227,221,62,127,254,253,251,119,235,221,190,119,255,85,255,191,95,255,255,251,245,255,255,252,123,183,207,243,253,254,254,127,127,190,193,247,247,235,28,239,223,171,85,0
10 DATA253,251,247,136,118,112,112,136,103,7,7,255,247,235,213,170,213,235,247
11 CLEAR200,32142:FORA=32143TO32767:READB:POKEA,B:NEXT:DEFUSR0=32143
100 PMODE4,1:SCREEN1,0:COLOR0,1:PCLS:P=0:LINE(64,48)-(191,143),PSET,B
110 X=USR0(P),(65,49)-(190,142)
120 A$=INKEY$:IFA$=""THEN120
130 P=P+1:IFP=38THENP=0
140 GOTO110
More information about the Coco
mailing list