Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #320

Re: detect character at HTAB, VTAB ( a SCRN(x,y) function for text screen) ??

From aiiadict@gmail.com
Newsgroups comp.sys.apple2.programmer
Subject Re: detect character at HTAB, VTAB ( a SCRN(x,y) function for text screen) ??
Date 2012-06-30 12:06 -0700
Organization http://groups.google.com
Message-ID <1a545dae-c002-45bf-8ad2-888b66d14c3d@googlegroups.com> (permalink)
References <94a9d08e-dc6e-4269-8fb5-83437fb0f188@googlegroups.com> <m34nptjw72.fsf@yahoo.ca>

Show all headers | View raw


On Friday, June 29, 2012 8:49:21 PM UTC-7, Jerry wrote:
>  writes:
> 
> > I didn't know what search terms to type in.
> >
> > I'd like an all applesoft (I have 6502 code) program
> > that will output the ascii value of the character stored
> > in 40 column mode X,Y position.
> >
> >
> > 10 vtab 10:htab 20:print "X";
> > 20 y=10:x=20:gosub 1000:rem get char value
> > 30 print asc(g)
> >
> > X
> >
> >
> > 1000 rem use X and Y to determine ascii value, and
> > 1010 rem return in variable G
> 
> 
> You kind of had the answer in your question title:
> 
> G = SCRN( X-1, (Y-1)*2 ) + 16 * SCRN( X-1, (Y-1)*2 + 1)
> 
> HTAB and VTAB start counting at 1 whereas the LoRES stuff starts
> counting at 0, hence the "- 1" terms above.


Cool, Thanks.   I thought SCRN would work with text screen, because GR and text use the same RAM...

Then I looked into my Basic Programming Reference Manual  II Applesoft...


page 87:

SCRN imm & def

SCRN (aexpr1,aexpr2)

In low-resolution GRaphics mode, the function SCRN returns the color code of the point whose x coordinate is \aexpr1\ and whose y coordinate is \aexpr2\.

Although low-resolution GRaphics plots points at screen positions (x,y) 
where x is in the range 0 through 39 and y is in the range of 0 through 47, 
the SCRN function accepts both x and y values in the range of 0 through 47.
However, if SCRN is used with an x value (\aexpr1\) in the range of 40 through 
47, the number returned gives the color at the point whose x coordinate is 
(\aexpr\-40) and whose y coordinate is (\aexpr2\+16).  If (\aexpr2\+16) is in the range 39 to 47, in normal mixed GRaphics plus text mode, the number returned by SCRN is related to the text character at that position in the text area below the graphics portion of the screen.  If (\aexpr2\+16) is in the range of 48 to 63, SCRN returns a number unrelated to anything on the screen.

In TEXT mode, SCRN returns numbers in the range 0 through 15 whose value is the

    upper fourbits, if aexpr2 is odd; or
    lower four bits, if aexpr2 is even
of the character at character position
(aexpr+1, INT ((aexpr2+1)/2)).  So the expression
chr$(scrn(x-1,2*(y-1))+16*scrn(x-1,2*(y-1)+1))
will return the character at character position (X,Y).


Back to comp.sys.apple2.programmer | Previous | NextPrevious in thread | Find similar


Thread

detect character at HTAB, VTAB  ( a SCRN(x,y) function for text screen)  ?? aiiadict@gmail.com - 2012-06-29 16:04 -0700
  Re: detect character at HTAB, VTAB  ( a SCRN(x,y) function for text screen)  ?? Jerry <awanderin@yahoo.ca> - 2012-06-29 21:49 -0600
    Re: detect character at HTAB, VTAB  ( a SCRN(x,y) function for text screen)  ?? aiiadict@gmail.com - 2012-06-30 12:06 -0700

csiph-web