Megalextoria
Retro computing and gaming, sci-fi books, tv and movies and other geeky stuff.

Home » Digital Archaeology » Computer Arcana » Apple » Apple II » How to print text from screen memory?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
How to print text from screen memory? [message #391379] Sun, 01 March 2020 17:25 Go to next message
Anonymous
Karma:
Originally posted by: Chris Tobar

Hi all,
Let me clarify a little bit. I'm writing a program on my Apple II+ that can make maps. (Yeah, I know that's kind of "reinventing the wheel" with so many mapping programs/apps for modern computers and tablets, but I thought it would be interesting to try it on a vintage computer). Anyway, I'm using text chatacters to draw streets and location markers, etc since the Apple II can't really have graphics and text on the screen at the same time. I wanted the program to be able to print maps that you've made. The only way I can think of to do this would be to somehow "dump" the screen and send it to the printer and have it print line by line. I've asked something similar about printing the screen before, but I fugured this might be easier to do since we're talking about text, not graphics.

Does anyone have any idea how I might be able to do this?

- Chris
Re: How to print text from screen memory? [message #391385 is a reply to message #391379] Sun, 01 March 2020 19:01 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: fadden

On Sunday, March 1, 2020 at 2:25:08 PM UTC-8, Chris Tobar wrote:
> the Apple II can't really have graphics and text on the screen at the same time.

If you're satisfied with 40-column text, it's easy to have both. Some games did all their graphics with custom fonts (e.g. http://crpgaddict.blogspot.com/2013/09/game-114-dragons-eye- 1981.html ).

> The only way I can think of to do this would be to somehow "dump" the screen and send it to the printer and have it print line by line.

For 40-column text it's somewhat straightforward to extract the text from the screen memory. For 80-column text it's a bit harder.

Another option would be modify your drawing function to draw everything "off screen", into an array. That gets passed to a print function that prints it one full line at a time, either to the screen or the printer.
Re: How to print text from screen memory? [message #391387 is a reply to message #391385] Sun, 01 March 2020 20:15 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Chris Tobar

I'm just using 40-column text. I'm still thinking the easiest way would be to extract the text from screen memory...although I have no idea how to do that!


On Sunday, March 1, 2020 at 4:01:49 PM UTC-8, fadden wrote:
> On Sunday, March 1, 2020 at 2:25:08 PM UTC-8, Chris Tobar wrote:
>> the Apple II can't really have graphics and text on the screen at the same time.
>
> If you're satisfied with 40-column text, it's easy to have both. Some games did all their graphics with custom fonts (e.g. http://crpgaddict.blogspot.com/2013/09/game-114-dragons-eye- 1981.html ).
>
>> The only way I can think of to do this would be to somehow "dump" the screen and send it to the printer and have it print line by line.
>
> For 40-column text it's somewhat straightforward to extract the text from the screen memory. For 80-column text it's a bit harder.
>
> Another option would be modify your drawing function to draw everything "off screen", into an array. That gets passed to a print function that prints it one full line at a time, either to the screen or the printer.
Re: How to print text from screen memory? [message #391395 is a reply to message #391387] Mon, 02 March 2020 09:37 Go to previous messageGo to next message
Michael AppleWin Debu is currently offline  Michael AppleWin Debu
Messages: 1262
Registered: March 2013
Karma: 0
Senior Member
On Sunday, March 1, 2020 at 5:15:47 PM UTC-8, Chris Tobar wrote:
> I'm just using 40-column text. I'm still thinking the easiest way would be to extract the text from screen memory...although I have no idea how to do that!

You might be interested in my Apple 2 HGR Font Tutorial
https://github.com/Michaelangel007/apple2_hgr_font_tutorial

The text screen is memory mapped in a non-linear format.
i.e. Interleaved.

The section "Copy text screen to HGR" has a description of the layout.
https://github.com/Michaelangel007/apple2_hgr_font_tutorial# copy-text-screen-to-hgr

i.e.
Row Text Address Screen Hole
0 $400 .. $427 n/a
1 $480 .. $4A7 n/a
2 $500 .. $527 n/a
3 $580 .. $5A7 n/a
4 $600 .. $627 n/a
5 $600 .. $6A7 n/a
6 $700 .. $727 n/a
7 $780 .. $7A7 n/a
- -- --
8 $428 .. $44F n/a
9 $4A8 .. $4CF n/a
10 $528 .. $54F n/a
11 $5A8 .. $5CF n/a
12 $628 .. $64F n/a
13 $6A8 .. $6CF n/a
14 $728 .. $74F n/a
15 $7A8 .. $7CF n/a
- -- --
16 $450 .. $477 $478 .. $47F
17 $4D0 .. $4F7 $4F8 .. $4FF
18 $550 .. $577 $578 .. $57F
19 $5D0 .. $5F7 $5F8 .. $5FF
20 $650 .. $677 $678 .. $67F
21 $6D0 .. $6F7 $6F8 .. $6FF
22 $750 .. $777 $778 .. $77F

Michael
Re: How to print text from screen memory? [message #391396 is a reply to message #391387] Mon, 02 March 2020 11:00 Go to previous messageGo to next message
gids.rs is currently offline  gids.rs
Messages: 1395
Registered: October 2012
Karma: 0
Senior Member
You can use this formula from applesoft where LN is Line Number

1 HOME : LIST
5 DIM LN$(23) : GOTO 20
10 L = INT (LN / 8) : X = 1024 + 40 * L + 128 * (LN - L*8) : RETURN

20 FOR LN = 0 TO 23 : FOR J = 1 TO 40 : HTAB J
30 GOSUB 10 : CH = PEEK(X+ PEEK(36))
35 LN$(LN) = LN$(LN) + CHR$ (CH)
40 NEXT : NEXT

50 HOME : FOR I = 0 TO 22 : PRINT LN$(I);: NEXT
60 PRINT LEFT$(LN$(23),39);
70 GET A$


Note Line 60 where line 23 is a special case where if you were to Print the very last character in the bottom right corner of the screen, the screen would scroll.

If printing to a printer you can change the 39 in line #60 to a 40.
Re: How to print text from screen memory? [message #391421 is a reply to message #391396] Mon, 02 March 2020 23:13 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Chris Tobar

Thanks everyone for your help!

I actually managed to dig up some code after a lot of searching online. I found this, originally from a 1984 "Compute" magazine article (Page 169):

https://archive.org/details/1984-10-compute-magazine/page/n1 68/mode/2up

100 D$=CHR$(4)
105 PRINT D$;"PR#1"
115 FOR G=0 TO 2: FOR L=1 TO 8: PRINT SPC(20): FOR P=0 TO 39
120 C=PEEK (896+G*40+L*128+P)
150 PRINT CHR$ (C);: NEXT: PRINT: NEXT: NEXT
160 PRINT D$;"PR#0"

I tested it and it works! I listed the program, and ran it, and it prints itself on the printer. It prints slow, but that's fine for my purposes. I haven't tried the code yet with my "map" program, but I'm thinking it will work ok.

- Chris


On Monday, March 2, 2020 at 8:00:21 AM UTC-8, I am Rob wrote:
> You can use this formula from applesoft where LN is Line Number
>
> 1 HOME : LIST
> 5 DIM LN$(23) : GOTO 20
> 10 L = INT (LN / 8) : X = 1024 + 40 * L + 128 * (LN - L*8) : RETURN
>
> 20 FOR LN = 0 TO 23 : FOR J = 1 TO 40 : HTAB J
> 30 GOSUB 10 : CH = PEEK(X+ PEEK(36))
> 35 LN$(LN) = LN$(LN) + CHR$ (CH)
> 40 NEXT : NEXT
>
> 50 HOME : FOR I = 0 TO 22 : PRINT LN$(I);: NEXT
> 60 PRINT LEFT$(LN$(23),39);
> 70 GET A$
>
>
> Note Line 60 where line 23 is a special case where if you were to Print the very last character in the bottom right corner of the screen, the screen would scroll.
>
> If printing to a printer you can change the 39 in line #60 to a 40.
Re: How to print text from screen memory? [message #391464 is a reply to message #391379] Wed, 04 March 2020 15:50 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Chris Tobar

Ok, I added the code as a subroutine to my map program and it works! I just learned something new!
Re: How to print text from screen memory? [message #392427 is a reply to message #391379] Wed, 25 March 2020 23:53 Go to previous message
Anonymous
Karma:
Originally posted by: tcp

Why don't you write your own font routines and plot the text in hi-res along with your graphics?


You can port this back to BASIC if you like and change the prints to pixel draws. That's where it came from.

// Based on a program from the 1970s - original data mods by Jeff Diamond.
// Input a word and this program plots it in text using a 5 x 7 font.
// Really this is just a test program- nothing fancy.

#include <stdio.h>
#include <string.h>
#include <math.h>

// Describe 5 x 7 element font.
char *font57a[ ] = { " @DJJDXHBDDD@@@@@NDN_B_G_NN@@B@HNND^N^__OQNAQPQQN^N^N_QQQQQ_[ _@D@H@P@A@BMP@BPL@@@VM@@@@@@@@@CDX@ ",
" @DJJOYTDHBUD@@@AQLQAFPHAQQ@@D@DQQJQQQPPPQDARP[QQQQQQDQQQQQAX PCN@D@P@A@DSPD@QD@@@YS@@D@@@@Q@DDDE " ,
" @DJ_TBTHPAND@@@BSDABJ^PBQQDDH_BBUQQPQPPPQDATPUYQQQQPDQQQJJBX HCU@BMVOMNDQV@BRDZVNQQVO_QQQQQ_DDDJ " ,
" @D@JNDH@PAD_@_@DUDFFRA^DNO@@P@ADWQ^PQ^^P_DAXPUUQ^Q^NDQQUDDDX DCD@@SYPSQNSYLBTDUYQYSYPDQQQJQBH@BP " ,
" @D@_EHU@PANDD@@HYDHA_AQHQADDH_BDT_QPQPPSQDATPQSQPUTADQQUJDHX BCD@@QQPQ_DMQDB\\DUQQVMPNDQJQDODDDD@ " ,
" @@@J^SR@HBUDD@@PQDPQBQQHQB@DD@D@PQQQQPPQQDQRPQQQPRRQDQJ[QDPX ACD@@SYPSPDAQDBRDUQQPAPADSJUJAHDDD@ " ,
" @D@JDCM@DDD@H@D@NN_NBNNHN\\@HB@HDOQ^N^_POQNNQ_QQNPMQNDNDQQD_ _@_D_@MVOMND^QNLQNUQNPAP^DMDJQN_CDX@ " } ;

char plstr[132];
char twoch[] = "* ";

int main(int argc, char *argv[])
{
int b,y,z,m,n;
int index = -1;
int slen;

if (argc > 1)
strcpy(plstr, argv[1]); // plot a word in 5 x 7 font using text.
else
strcpy(plstr, argv[0]); // if no param, just use name of program.

slen = strlen(plstr);

printf("\n");
for(y=1; y<8; y++)
{ index++;
for(z=0; z < slen; z++)
{ n = font57a[index][(int) (plstr[z]-32)]-64;
for (b=4; b >= 0; b--)
{ m = (n >= ((int) pow(2,b)));
twoch[0] = plstr[z];
printf("%c", twoch[1-m]);
n=n- pow(2,b)*m;
}
printf(" ");
}
printf("\n");
}
printf("\n");
}





Chris Tobar <gatewaycityca@yahoo.com> wrote:
> Hi all,
> Let me clarify a little bit. I'm writing a program on my Apple II+ that can make maps. (Yeah, I know that's kind of "reinventing the wheel" with so many mapping programs/apps for modern computers and tablets, but I thought it would be interesting to try it on a vintage computer). Anyway, I'm using text chatacters to draw streets and location markers, etc since the Apple II can't really have graphics and text on the screen at the same time. I wanted the program to be able to print maps that you've made. The only way I can think of to do this would be to somehow "dump" the screen and send it to the printer and have it print line by line. I've asked something similar about printing the screen before, but I fugured this might be easier to do since we're talking about text, not graphics.
>
> Does anyone have any idea how I might be able to do this?
>
> - Chris

--
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -=-=-=-=-=-=-=-=-=
> Thomas Pfugglyopper * Life is too short for 4 line .sigs
> thomas@zippy.sonoma.edu* -- well, if Kibo didn't say it, he should have
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -=-=-=-=-=-=-=-=-=
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Myst on the Apple II
Next Topic: Problock3 driver for Apple /// SOS
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Sep 19 03:48:03 EDT 2024

Total time taken to generate the page: 0.00291 seconds