ravenxau Posted November 10, 2016 Share Posted November 10, 2016 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 Quote Link to comment Share on other sites More sharing options...
ravenxau Posted November 11, 2016 Author Share Posted November 11, 2016 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 Quote Link to comment Share on other sites More sharing options...
barrym95838 Posted November 11, 2016 Share Posted November 11, 2016 (edited) 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 November 11, 2016 by barrym95838 Quote Link to comment Share on other sites More sharing options...
ravenxau Posted November 11, 2016 Author Share Posted November 11, 2016 (edited) 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 November 11, 2016 by ravenxau Quote Link to comment Share on other sites More sharing options...
The Usotsuki Posted November 11, 2016 Share Posted November 11, 2016 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. Quote Link to comment Share on other sites More sharing options...
ravenxau Posted November 11, 2016 Author Share Posted November 11, 2016 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 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.