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 use HGR2 (or HGR) on an Apple II
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 use HGR2 (or HGR) on an Apple II [message #387964] Tue, 22 October 2019 21:51 Go to next message
Anonymous
Karma:
Originally posted by: Arthur Oribe

I am a big fan of the TV show lost, and I was trying to make the Dharma Initiative logo.

But at certain point I couldn't add new lines of code and the final part of the logo was cuted, I tried to change to HGR2 and worked, but now I can't write below the image.

So, I need the HGR2 $4000 memory (or more) and the mixed text and graphics mode of HGR. And i pretended to do more, write a hole program based on Lost, so i need more than just the logo.

I am programing basic in Apple II+, more specific, in Applewin emulator.

I know very basic of programing so my code is a mess.

I wrote my code in here if anyone wants.

https://retrocomputing.stackexchange.com/questions/12563/how -to-use-hgr2-or-hgr-on-an-apple-ii?noredirect=1#comment39520 _12563
Re: How to use HGR2 (or HGR) on an Apple II [message #387966 is a reply to message #387964] Tue, 22 October 2019 22:24 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Matthew Power

I can't help with memory, though I see others have... I'm just wondering how did you keep track of all the HPLOTs? Did you graph it out first or something? Looks great by the way!
Re: How to use HGR2 (or HGR) on an Apple II [message #387974 is a reply to message #387966] Wed, 23 October 2019 07:53 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: Arthur Oribe

Em terça-feira, 22 de outubro de 2019 23:24:14 UTC-3, Matthew Power escreveu:
> I can't help with memory, though I see others have... I'm just wondering how did you keep track of all the HPLOTs? Did you graph it out first or something? Looks great by the way!

Thank's, i just made it in Paint, a image with 279x159, then i keep track by there.
Re: How to use HGR2 (or HGR) on an Apple II [message #387980 is a reply to message #387964] Wed, 23 October 2019 09:58 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 Tuesday, October 22, 2019 at 6:51:57 PM UTC-7, Arthur Oribe wrote:
> I am a big fan of the TV show lost, and I was trying to make the Dharma Initiative logo.

Always great to see another fan of Apple 2's and Lost!

I'm copying my answer from Stack Overflow...

Here is a picture (to scale) of how memory is being used in
units of "pages" (256 bytes) on the Apple 2.

000000001111111111111111 2222222222222222 3 ... ... 9
89ABCDEF0123456789ABCDEF 0123456789ABCDEF 0 ... ... 6
+------------------------+----------------+--------------+
|Basic:::::::::::::::::::|::: HGR | |
|Program:::::::::::::::::|::: Page 1 | |
+------------------------+----------------+--------------+
<-- Low Memory --------------------------- High Memory -->


Here is a zoomed-out view of memory (not to scale):

+----------+----------+----------+----------+----------+
|Basic/////:// HGR : HGR : Free : DOS or |
|Program///:// Page 1 : Page 2 : Memory : BASIC |
+----------+----------+----------+----------+----------+
$0800 $2000 $4000 $6000 $9600

Your Applesoft Basic programs starts at $0800 by default. It is so
HUGE that is spilling over into the memory of the HGR graphics page 1.
When run the the HGR command literally "clears" the middle of your
program and that is why it crashes at 330.

i.e.

SYNTAX ERROR AT 330

LIST 330-

You see "junk" because the bytes of the HGR graphics page are being
(re)interpreted as BASIC tokens.

It also has a bug where you leave HCOLOR uninitialized and will use the
last HCOLOR set. That is easy to fix by adding `HCOLOR=3` at the start.

You can move your program to be above HGR page 1 by telling Applesoft
where your program now resides at. You will also need to set the first
byte to be zero. By consulting the classic [Beagle Bros Peeks and Pokes Chart](http://www.lazilong.com/apple_II/bbros/chart.jpg) we see that Zero Page address
locations 103 and 103 point to the start of the Applesoft BASIC program.

? PEEK(103)
1
? PEEK(1040
8

That is, $801 is the default.

To tell Applesoft that our programs now starts at $4000 (16384 in decimal) we can execute these commands:

POKE 103,1:POKE 104,64:POKE 16384,0
RUN LOST.BAS

Voilà! Your program now runs without crashing.

If you don't want to mess around with moving your Applesoft program to be
"above" the HGR memory to $4000 or $6000 then one solution would to split
your program into multiple programs that BLOAD & BSAVE partial image updates.

i.e.

RUN MAKE.LOST.1.BAS
RUN MAKE.LOST.2.BAS
HGR
BLOAD LOST.HGR,A$2000

You can split the program into two like this:

# --- MAKE.LOST.1.BAS ---

NEW
5 REM DHARMA INITIATIVE LOGO
10 HOME
15 HGR:HCOLOR=3
20 HPLOT 108,4 TO 170,4 TO 213,47 TO 213,110 to 170,153 TO 107,153 TO 64,110 TO 64,47 TO 107,4
25 HPLOT 108,5 TO 170,5 TO 212,47 TO 212,110 to 170,152 TO 107,152 TO 65,110 TO 65,47 TO 107,5
30 HPLOT 108,6 TO 170,6 TO 211,47 TO 211,110 to 170,151 TO 107,151 TO 66,110 TO 66,47 TO 107,6
31 HPLOT 108,7 TO 170,7 TO 210,47 TO 210,110 to 170,150 TO 107,150 TO 67,110 TO 67,47 TO 107,7
35 HPLOT 108,8 TO 170,8 TO 209,47 TO 209,110 to 170,149 TO 107,149 TO 68,110 TO 68,47 TO 107,8
40 HPLOT 108,9 TO 170,9 TO 208,47 TO 208,110 to 170,148 TO 107,148 TO 69,110 TO 69,47 TO 107,9
45 HPLOT 117,17 TO 160,17 TO 160,18 TO 117,18 TO 117,19 TO 160,19 : HPLOT 159,20 TO 118,20 TO 118,21 TO 159,21 : HPLOT 120,22 TO 157,22
50 HPLOT 167,21 TO 179,33 : HPLOT 179,34 TO 166,21 : HPLOT 166,22 TO 178,34 : HPLOT 178,35 TO 166,23 : HPLOT 165,23 TO 177,35 : HPLOT 177,36 TO 165,24 : HPLOT 165,25 TO 176,36
55 HPLOT 184,38 TO 196,50 : HPLOT 196,51 TO 183,38 : HPLOT 183,39 TO 195,51 : HPLOT 194,51 TO 182,39 : HPLOT 182,40 TO 194,52 : HPLOT 193,52 TO 181,40 : HPLOT 181,41 TO 192,52
60 HPLOT 200,57 TO 200,100 TO 199,100 TO 199,57 TO 198,57 TO 198,100 TO 197,99 TO 197,58 TO 196,58 TO 196,99 : HPLOT 195,97 TO 195,60
65 HPLOT 197,107 TO 167,137 : HPLOT 166,137 TO 197,106 : HPLOT 196,106 TO 166,136 : HPLOT 166,135 TO 195,106 : HPLOT 195,105 TO 165,135 : HPLOT 165,134 TO 194,105 : HPLOT 193,105 TO 165,133
70 HPLOT 159,140 TO 141,140 TO 141,139 TO 159,139 TO 159,138 TO 141,138 TO 141,137 TO 158,137 TO 158,136 TO 141,136 : HPLOT 141,135 TO 156,135
75 HPLOT 135,140 TO 117,140 TO 117,139 TO 135,139 TO 135,138 TO 117,138 TO 118,137 TO 135,137 TO 135,136 TO 118,136 : HPLOT 120,135 TO 135,135
80 HPLOT 109,136 TO 97,124 : HPLOT 97,123 TO 110,136 : HPLOT 110,135 TO 98,123 : HPLOT 98,122 TO 110,134 : HPLOT 111,134 TO 99,122 : HPLOT 99,121 TO 111,133 : HPLOT 111,132 TO 100,121
85 HPLOT 92,119 TO 80,107 : HPLOT 80,106 TO 93,119 : HPLOT 93,118 TO 81,106 : HPLOT 82,106 TO 94,118 : HPLOT 94,117 TO 82,105 : HPLOT 83,105 TO 95,117 : HPLOT 95,116 TO 84,105
90 HPLOT 77,100 TO 77,57 TO 78,57 TO 78,100 TO 79,100 TO 79,57 : HPLOT 80,58 TO 80,99 TO 81,99 TO 81,58 : HPLOT 82,60 TO 82,97
95 HPLOT 81,50 TO 93,38 : HPLOT 94,38 TO 81,51 : HPLOT 82,51 TO 94,39 : HPLOT 95,39 TO 83,51 : HPLOT 83,52 TO 95,40 : HPLOT 96,40 TO 84,52 : HPLOT 85,52 TO 96,41
100 HPLOT 98,33 TO 110,21 : HPLOT 111,21 TO 98,34 : HPLOT 99,34 TO 111,22 : HPLOT 111,23 TO 99,35 : HPLOT 100,35 TO 112,23 : HPLOT 112,24 TO 100,36 : HPLOT 101,36 TO 112,25
105 HPLOT 121,26 TO 135,26 TO 135,27 TO 121,27 TO 122,28 TO 135,28 TO 135,29 TO 122,29 TO 123,30 TO 135,30 TO 135,31 TO 123,31
110 HPLOT 141,26 TO 156,26 TO 156,27 TO 141,27 TO 141,28 TO 155,28 TO 155,29 TO 141,29 TO 141,30 TO 154,30 TO 154,31 TO 141,31
115 HPLOT 164,30 TO 174,40 TO 174,41 TO 163,30 TO 163,31 TO 173,41 TO 173,42 TO 163,32 TO 162,32 TO 172,42 TO 172,43 TO 162,33 TO 162,34 TO 171,43
120 HPLOT 178,44 TO 187,53 TO 187,54 TO 177,44 TO 177,45 TO 186,54 TO 185,54 TO 176,45 TO 176,46 TO 185,55 TO 184,55 TO 175,46 TO 175,47 TO 183,55
125 HPLOT 191,61 TO 191,96 TO 190,96 TO 190,61 : HPLOT 189,62 TO 189,95 TO 188,95 TO 188,62 : HPLOT 187,63 TO 187,94 TO 186,94 TO 186,63
130 HPLOT 187,104 TO 163,128 : HPLOT 162,128 TO 187,103 : HPLOT 186,103 TO 162,127 : HPLOT 162,126 TO 185,103 : HPLOT 185,102 TO 161,126 : HPLOT 161,125 TO 184,102 : HPLOT 183,102 TO 161,124
135 HPLOT 156,131 TO 121,131 TO 121,130 TO 156,130 : HPLOT 155,129 TO 122,129 TO 122,128 TO 155,128 : HPLOT 154,127 TO 123,127 TO 123,126 TO 154,126
140 HPLOT 113,127 TO 103,117 : HPLOT 103,116 TO 114,127 : HPLOT 114,126 TO 104,116 : HPLOT 104,115 TO 114,125 : HPLOT 115,125 TO 105,115 : HPLOT 105,114 TO 115,124 : HPLOT 115,123 TO 106,114
145 HPLOT 99,113 TO 90,104 : HPLOT 90,103 TO 100,113 : HPLOT 100,112 TO 91,103 : HPLOT 92,103 TO 101,112 : HPLOT 101,111 TO 92,102 : HPLOT 93,102 TO 102,111 : HPLOT 102,110 TO 94,102
150 HPLOT 86,96 TO 86,82 TO 87,82 TO 87,96 : HPLOT 88,95 TO 88,82 TO 89,82 TO 89,95 : HPLOT 90,94 TO 90,82 TO 91,82 TO 91,94
155 HPLOT 86,76 TO 86,61 TO 87,61 TO 87,76 TO 88,76 TO 88,62 TO 89,62 TO 89,76 TO 90,76 TO 90,63 TO 91,63 TO 91,76
160 HPLOT 89,54 TO 113,30 : HPLOT 114,30 TO 89,55 : HPLOT 90,55 TO 114,31 : HPLOT 114,32 TO 91,55 : HPLOT 91,56 TO 115,32 : HPLOT 115,33 TO 92,56 : HPLOT 93,56 TO 115,34
165 HPLOT 125,34 TO 152,34 TO 152,35 TO 125,35 : HPLOT 126,36 TO 151,36 TO 151,37 TO 126,37 : HPLOT 127,38 TO 150,38 TO 150,39 TO 127,39
170 HPLOT 160,38 TO 168,46 : HPLOT 168,47 TO 160,39 : HPLOT 160,40 TO 167,47 : HPLOT 167,48 TO 159,40 : HPLOT 159,41 TO 166,48 : HPLOT 166,49 TO 159,42 : HPLOT 159,43 TO 165,49
175 HPLOT 172,50 TO 179,57 : HPLOT 178,57 TO 171,50 : HPLOT 171,51 TO 177,57 : HPLOT 177,58 TO 170,51 : HPLOT 170,52 TO 176,58 : HPLOT 175,58 TO 169,52 : HPLOT 169,53 TO 174,58
180 HPLOT 183,65 TO 183,76 TO 182,76 TO 182,65 : HPLOT 181,66 TO 181,76 TO 180,76 TO 180,66 : HPLOT 179,67 TO 179,76 TO 178,76 TO 178,67
185 HPLOT 183,82 TO 183,92 TO 182,92 TO 182,82 TO 181,82 TO 181,91 TO 180,91 TO 180,82 TO 179,82 TO 179,90 TO 178,90 TO 178,82
190 HPLOT 179,100 TO 160,119 : HPLOT 160,118 TO 178,100 : HPLOT 177,100 TO 160,117 : HPLOT 159,117 TO 177,99 : HPLOT 176,99 TO 159,116 : HPLOT 159,115 TO 175,99 : HPLOT 174,99 TO 159,114
195 HPLOT 152,123 TO 141,123 TO 141,122 TO 152,122 : HPLOT 151,121 TO 141,121 TO 141,120 TO 151,120 : HPLOT 150,119 TO 141,119 TO 141,118 TO 150,118
200 HPLOT 135,123 TO 125,123 TO 125,122 TO 135,122 TO 135,121 TO 126,121 TO 126,120 TO 135,120 TO 135,119 TO 127,119 TO 127,118 TO 135,118
205 HPLOT 117,119 TO 98,100 : HPLOT 99,100 TO 117,118 : HPLOT 117,117 TO 100,100 : HPLOT 100,99 TO 118,117 : HPLOT 118,116 TO 101,99 : HPLOT 102,99 TO 118,115 : HPLOT 118,114 TO 103,99
210 HPLOT 94,92 TO 94,82 TO 95,82 TO 95,92 : HPLOT 96,91 TO 96,82 TO 97,82 TO 97,91 : HPLOT 98,90 TO 98,82 TO 99,82 TO 99,90
215 HPLOT 94,76 TO 94,65 TO 95,65 TO 95,76 TO 96,76 TO 96,66 TO 97,66 TO 97,76 TO 98,76 TO 98,67 TO 99,67 TO 99,76
220 HPLOT 97,58 TO 116,39 : HPLOT 116,40 TO 98,58 : HPLOT 99,58 TO 116,41 : HPLOT 117,41 TO 99,59 : HPLOT 100,59 TO 117,42 : HPLOT 117,43 TO 101,59 : HPLOT 102,59 TO 117,44
221 PRINT CHR$(4)"BSAVE LOST.HGR,A$2000,L$1FF8"
222 END
SAVE MAKE.LOST.1.BAS

# --- MAKE.LOST.2.BAS ---

And then for Part 2

NEW
223 HGR:HCOLOR=3
224 PRINT CHR$(4)"BLOAD LOST.HGR,A$2000,L$1FF8"
225 REM DHARMA LOGO CORE
230 HPLOT 135,46 TO 143,46 : HPLOT 130,47 TO 148,47 : HPLOT 127,48 TO 151,48 : HPLOT 125,49 TO 153,49 : HPLOT 124,50 TO 155,50 : HPLOT 122,51 TO 156,51 : HPLOT 120,52 TO 158,52
235 HPLOT 119,53 TO 160,53 : HPLOT 118,54 TO 160,54 : HPLOT 117,55 TO 161,55 : HPLOT 116,56 TO 162,56 : HPLOT 115,57 TO 163,57 : HPLOT 114,58 TO 164,58 : HPLOT 114,59 TO 164,59
240 HPLOT 113,60 TO 165,60 : HPLOT 112,61 TO 166,61 : HPLOT 112,62 TO 166,62 : HPLOT 111,63 TO 167,63 : HPLOT 111,64 TO 167,64 : HPLOT 110,65 TO 168,65 : HPLOT 109,66 TO 168,66
245 HPLOT 109,67 TO 169,67 : HPLOT 109,68 TO 169,68 : HPLOT 109,69 TO 169,69 : HPLOT 108,70 TO 170,70 : HPLOT 108,71 TO 170,71 : HPLOT 108,72 TO 170,72 : HPLOT 107,73 TO 170,73
250 HPLOT 107,74 TO 112,74 : HPLOT 119,74 TO 122,74 : HPLOT 124,74 TO 127,74 : HPLOT 129,74 TO 133,74 : HPLOT 136,74 TO 140,74 : HPLOT 146,74 TO 171,74
255 HPLOT 107,75 TO 112,75 : HCOLOR = 0 : HPLOT 112,75 : HCOLOR = 3: HPLOT 121,75 : HPLOT 125,75 TO 126,75 : HPLOT 129,75 TO 132,75 : HPLOT 136,75 TO 139,75 : HPLOT 148,75 TO 149,75
256 HPLOT 159,75 TO 162,75 : HPLOT 151,75 TO 156,75 : HPLOT 165,75 TO 171,75
260 HPLOT 107,76 TO 111,76 : HPLOT 115,76 TO 117,76 : HPLOT 121,76 : HPLOT 125,76 TO 126,76 : HPLOT 129,76 TO 132,76 : HPLOT 137,76 TO 139,76 : HPLOT 142,76 TO 145,76 : HPLOT 148,76 TO 149,76 : HPLOT 152,76 TO 155,76
265 HPLOT 159,76 TO 161,76 : HPLOT 166,76 TO 171,76
270 HPLOT 107,77 TO 111,77 : HPLOT 115,77 TO 118,77 : HPLOT 121,77 : HPLOT 125,77 TO 126,77 : HPLOT 129,77 TO 131,77 : HPLOT 134,77 TO 135,77 : HPLOT 138,77 TO 139,77 : HPLOT 142,77 TO 144,77 : HPLOT 148,77 TO 149,77
275 HPLOT 153,77 TO 154,77 : HPLOT 159,77 TO 160,77 : HPLOT 163,77 TO 164,77 : HPLOT 166,77 TO 171,77
280 HPLOT 107,78 TO 111,78 : HPLOT 115,78 TO 118,78 : HPLOT 121,78 : HPLOT 129,78 TO 131,78 : HPLOT 134,78 TO 135,78 : HPLOT 138,78 TO 139,78 : HPLOT 147,78 TO 149,78 : HPLOT 159,78 TO 160,78 : HPLOT 167,78 TO 171,78
285 HPLOT 107,79 TO 111,79 : HPLOT 115,79 TO 117,79 : HPLOT 121,79 : HPLOT 129,79 TO 130,79 : HPLOT 139,79 : HPLOT 146,79 TO 149,79 : HPLOT 152,79 : HPLOT 156,79 : HPLOT 159,79 : HPLOT 167,79 TO 171,79
290 HPLOT 107,80 TO 111,80 : HPLOT 120,80 TO 121,80 : HPLOT 125,80 TO 126,80 : HPLOT 129,80 : HPLOT 139,80 : HPLOT 142,80 TO 143,80 : HPLOT 148,80 TO 149,80 : HPLOT 152,80 TO 153,80 : HPLOT 155,80 TO 156,80 : HPLOT 159,80
295 HPLOT 162,80 TO 165,80 : HPLOT 168,80 TO 171,80
300 HPLOT 107,81 TO 111,81 : HPLOT 119,81 TO 121,81 : HPLOT 125,81 TO 126,81 : HPLOT 129,81 : HPLOT 133,81 TO 136,81 : HPLOT 139,81 : HPLOT 142,81 TO 144,81 : HPLOT 149,81 : HPLOT 152,81 TO 156,81 : HPLOT 159,81
305 HPLOT 162,81 TO 165,81 : HPLOT 169,81 TO 171,81
310 HPLOT 107,82 TO 111,82 : HPLOT 117,82 TO 122,82 : HPLOT 124,82 TO 127,82 : HPLOT 129,82 : HPLOT 132,82 TO 137,82 : HPLOT 139,82 : HPLOT 142,82 TO 145,82 : HPLOT 149,82 : HPLOT 152,82 TO 156,82 : HPLOT 159,82
315 HPLOT 161,82 TO 166,82 : HPLOT 169,82 TO 171,82
320 HPLOT 107,83 TO 171,83 : HPLOT 108,84 TO 170,84 : HPLOT 108,85 TO 170,85 : HPLOT 108,86 TO 170,86 : HPLOT 108,87 TO 170,87 : HPLOT 108,88 TO 169,88 : HPLOT 109,89 TO 169,89 : HPLOT 109,90 TO 169,90
325 HPLOT 109,91 TO 169,91 : HPLOT 110,92 TO 168,92 : HPLOT 110,93 TO 168,93 : HPLOT 111,94 TO 167,94 : HPLOT 112,95 TO 166,95 : HPLOT 112,96 TO 166,96 : HPLOT 113,97 TO 165,97 : HPLOT 114,98 TO 164,98
330 HPLOT 114,99 TO 164,99 : HPLOT 115,100 TO 163,100 : HPLOT 116,101 TO 162,101 : HPLOT 117,102 TO 162,102 : HPLOT 118,103 TO 160,103 : HPLOT 119,104 TO 159,104 : HPLOT 121,105 TO 157,105
335 HPLOT 122,106 TO 156,106 : HPLOT 124,107 TO 154,107 : HPLOT 125,108 TO 153,108 : HPLOT 127,109 TO 151,109 : HPLOT 131,110 TO 148,110 : HPLOT 135,111 TO 143,111
339 PRINT CHR$(4)"BSAVE LOST.HGR,A$2000,L$1FF8"
SAVE MAKE.LOST.2.BAS

NOTE: With AppleWin you can use `Shift-Insert` to paste text into the emulator.
Re: How to use HGR2 (or HGR) on an Apple II [message #388006 is a reply to message #387980] Wed, 23 October 2019 18:34 Go to previous messageGo to next message
Anonymous
Karma:
Originally posted by: fadden

Another idea: put all the drawing commands into a text file, without line numbers, and then "EXEC LOST.TXT".

The pauses as the operating system reads from disk add to that retro feel. :-)
Re: How to use HGR2 (or HGR) on an Apple II [message #388015 is a reply to message #388006] Thu, 24 October 2019 00:30 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
> drawing commands into a text file

That's another great idea!

Slow and bloated IMHO but it does the job!

I've updated my SO answer showing how to apply Data-Orientated Design and Data-Driven Process to Applesoft BASIC whilst keeping the original constraint of drawing the logo in order. Memory usage is ~50% of the original program.
Re: How to use HGR2 (or HGR) on an Apple II [message #388058 is a reply to message #388006] Thu, 24 October 2019 21:17 Go to previous message
Anonymous
Karma:
Originally posted by: James Davis

On Wednesday, October 23, 2019 at 3:34:36 PM UTC-7, fadden wrote:
> Another idea: put all the drawing commands into a text file, without line numbers, and then "EXEC LOST.TXT".
>
> The pauses as the operating system reads from disk add to that retro feel. :-)

Wow, that's a real K.I.S.S. on the cheek!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: ADTPro Java Catalina
Next Topic: Can the IIgs output colour on its composite monitor output?
Goto Forum:
  

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

Current Time: Mon May 13 16:40:09 EDT 2024

Total time taken to generate the page: 0.71305 seconds