Tuesday, March 10, 2009

One more Applesoft Program

I wrote this as two programs so long ago, I don't remember how they work :)

I thought for sure that I lost these, but stumbled across them today so I wanted to post them here for posterity.  I espcially like version 2.

If I get really ambitious I might try to write version 2 into assembly... not sure I remember assembly quite that well yet (I can read it well enough, but can I still write it???)

 1   TEXT : HOME
 2   ?  "Lo Res Graphics Fun by Gregg"
 5   ? "Which Version 1 or 2 (3 to quit): ";: GET K$
 6   IF K$ = "2" THEN 10
 7   IF K$ = "1" THEN 510
 8   IF K$ = "3" THEN HOME : ? "Bye!" : END
 9   GOTO 1
 10  TEXT : HOME : GR :T = 0:X = 1:Y = 38:C1 = 1:Z = 0:C2 = 2:XX = 0:YY = 0
 12 X1 = 19:Y1 = 20:C3 = 4
 13 X2 = 19:Y2 = 20:C4 = 6
 15  VTAB 22: PRINT "HIT ESC TO EXIT"
 20  COLOR= C1: HLIN X,Y AT X: HLIN X,Y AT Y: VLIN X,Y AT X: VLIN X,Y AT Y
 30 X = X + 1:Y = Y - 1:T = T + 1: IF T = 9 THEN XX = 1:YY = 38:Z = 1
 40  IF X = 20 THEN X = 1:Y = 38:C1 = C1 + 2: IF C1 > 15 THEN C1 = 1
 50  IF Z <  > 1 THEN 80
 60  COLOR= C2: HLIN XX,YY AT XX: HLIN XX,YY AT YY: VLIN XX,YY AT YY: VLIN XX,YY AT XX
 70 XX = XX + 1:YY = YY - 1: IF XX = 20 THEN XX = 1:YY = 38:C2 = C2 + 2: IF C2 > 14 THEN C2 = 2
 80  COLOR= C3: HLIN X1,Y1 AT X1: HLIN X1,Y1 AT Y1: VLIN X1,Y1 AT X1: VLIN X1,Y1 AT Y1
 90 X1 = X1 - 1:Y1 = Y1 + 1:
 100  IF X1 = 0 THEN X1 = 19:Y1 = 20:C3 = C3 + 2: IF C3 > 15 THEN C3 = 1
 105  IF Z <  > 1 THEN 20
 110  COLOR= C4: HLIN Y2,X2 AT X2: HLIN Y2,X2 AT Y2: VLIN Y2,X2 AT X2: VLIN Y2,X2 AT Y2
 120 X2 = X2 - 1:Y2 = Y2 + 1
 130  IF X2 = 0 THEN X2 = 19:Y2 = 20:C4 = C4 + 2: IF C4 > 15 THEN C4 = 1
 200 K =  PEEK ( - 16384): IF K <  > 155 THEN 20
 210  POKE  - 16368,0: TEXT : HOME : GOTO 1

 510  TEXT : HOME : GR :T = 0:X = 1:Y = 38:C1 = 1:Z = 0:C2 = 2:XX = 0:YY = 0
 520  COLOR= C1: HLIN X,Y AT X: HLIN X,Y AT Y: VLIN X,Y AT X: VLIN X,Y AT Y
 530 X = X + 1:Y = Y - 1:T = T + 1: IF T = 9 THEN XX = 1:YY = 38:Z = 1
 540  IF X = 39 THEN X = 1:Y = 38:C1 = C1 + 2: IF C1 > 15 THEN C1 = 1
 550  IF Z <  > 1 THEN 520
 560  COLOR= C2: HLIN XX,YY AT XX: HLIN XX,YY AT YY: VLIN XX,YY AT YY: VLIN XX,YY AT XX
 570 XX = XX + 1:YY = YY - 1: IF XX = 39 THEN XX = 1:YY = 38:C2 = C2 + 2: IF C2 > 14 THEN C2 = 2
 580  VTAB 22: PRINT "HIT 'ESC' TO EXIT":K =  PEEK ( - 16384): IF K <  > 155 THEN 520
 590  POKE  - 16368,0: TEXT : HOME : GOTO 1

Assembly is Fun!

It has been a LONG time since I seriously wrote any 6502 Assembly code, but I used to do it all the time.  I would write it out on paper first then type it in once I had it where I thought I wanted it.  Paper made it alot easier to see everything all at once (due to the tiny screens in the old days).  I think I still have a page or two of hand written code.  If I find it I'll scan and post it just for fun.

So, I was playing with this site: http://www.6502asm.com/

And decided to take an old Apple ][ Assembly program I wrote EONS ago and adapt it to work on that site.  Got it to work pretty well and even submitted it for their examples page.  I do have a Game Of Life I wrote once that I want to try and adapt, but not today :)

If you write anything cool, let me know.

Wednesday, March 4, 2009

Yawn

Tired, so tired. Not sleeping much (and haven't been for about a year). Most of it is because of work... oh well. Maybe someday it will get better (or I'll win the lottery... yah right).

So awhile ago I found this site: http://www.calormen.com/Applesoft/

Its fun to sometimes play with.

Go ahead and put this code in there:

10 TEXT : HOME : INPUT "NUMBER OF POINTS:";A: HCOLOR= 3
20 HGR : POKE -16302,0
30 FOR T1 = 0 TO (2 * 3.14) - .001 STEP ((2 * 3.14) / A)
40 FOR T2 = T1 + (2 * 3.14) / A TO (2 * 3.14) - .001 STEP (2 * 3.14) / A
50 HPLOT ( COS (T1) * 95 + 127),( SIN (T1) * 95 + 95) TO ( COS (T2) * 95 + 127),( SIN (T2) * 95 + 95)
60 NEXT
70 NEXT
80 GET A$
90 GOTO 10

or This one

10 TEXT
20 HOME
30 INPUT "Enter a number from 1 to 8:";N
40 IF N > 0 AND N < 8 THEN F = 128
50 E = 0
60 K = 4 ^ N
70 FOR X = 1 TO N
80 U = F
90 F = - E / 2
100 E = U / 2
110 NEXT
120 HGR
130 HCOLOR= 3
140 X = 80
150 Y = 70
160 HPLOT X,Y
170 FOR M = 1 TO K
180 Z = M
190 X = X + F
200 Y = Y + E
210 HPLOT TO X,Y
220 FOR A = 0 TO 1
230 Z = Z / 2
240 Q = INT (Z)
250 A = Z - Q
260 NEXT
270 A = (Q / 2 = INT (Q / 2)) * 2 - 1
280 U = F
290 F = A * E
300 E = - A * U
310 NEXT
320 GOTO 10

I sent several of my programs to the guy that wrote it so hopefully he includes them in his 'sample' list. Especially the last one I sent him... its pretty cool.
Copyright Realm Laboratories, LLC