Jump to content
IGNORED

peeking the cursor


ravenxau

Recommended Posts

I want to migrate some of my commodore 64 programs to the Apple II. I have most of the ideas sorted with the exeption of screen ram. It seems the Apple II screen ram starting at address 1024 is not in one contiguious block like the commodore 64.

 

I was wondering if it is possible to set the cursor position with VTAB and HTAB and then peek a location to read what character is in that position on the screen?

 

any help or insight would be helpful

Link to comment
Share on other sites

OK....I got hold of a PDF of the Apple II Reference Manual and have worked out that the screen ram is mapped into blocks with offsets of 128 instead of 40 for the 40 characters per line......

 

 

Is there a common formula that programmers use to convert x,y values into an absolute screen address??

 

 

If there is ,I can just peek the relevant positions on the screen and not worry about the VTAB:HTAB method

Link to comment
Share on other sites

If you are using assembly language, you should JSR BASCALC at $FBC1 to translate the row in A to a screen address in $28 and $29, load the column into Y, and peek the location with LDA ($28),Y. If you are using BASIC, you can peek the screen value with the formula P = SCRN(C,R*2)+16*SCRN(C,R*2+1), where C is the column (0 .. 39) and R is the row (0 .. 23).

 

Both of these methods will return the screen code at that location, which is related to the ASCII code, but not the same.

 

Mike B.

Edited by barrym95838
Link to comment
Share on other sites

If you are using assembly language, you should JSR BASCALC at $FBC1 to translate the row in A to a screen address in $28 and $29, load the column into Y, and peek the location with LDA ($28),Y. If you are using BASIC, you can peek the screen value with the formula P = SCRN(C,R*2)+16*SCRN(C,R*2+1), where C is the column (0 .. 39) and R is the row (0 .. 23).

 

Both of these methods will return the screen code at that location, which is related to the ASCII code, but not the same.

 

Mike B.

Thank you Mike B. - Works perfectly.... and I'm using BASIC

 

Interestingly, after reading the reference manual and a few web sites, I was under the impression that SCRN only works in graphics mode, not with text mode as there was no examples like this

Edited by ravenxau
Link to comment
Share on other sites

Lo-res graphics mode uses the same memory as text mode; it just treats each byte as two nibbles of color instead of a character.

Ah.....SCRN looks at nibbles, not addresses....thats why the the second part of the formula needs *16......

 

It all makes sense now...thank you both for the insight

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...