// Created by Gregg Buntin private void DrawImage() { int sizeX = Convert.ToInt32(tbX.Text); // this is the X (width) of the image int sizeY = Convert.ToInt32(tbY.Text); // this is the Y (height) of the image int halfX = sizeX / 2; int halfY = sizeY / 2; calculatedImage = new Bitmap(sizeX, sizeY); Color tempColor = new Color(); double num = Convert.ToDouble(tbDec.Text); // This is where you plug in the Decimal value for (int Y = -(halfY); Y < 1; Y++) { int Y2 = Y * Y; for (int X = -(halfX); X < 1; X++) { tempColor = Color.White; double tempR = Math.Pow((Y2 + (X * X)), num); double R = (10000000 - tempR) / 2; int intR = Convert.ToInt32(R); double roundR = Math.Truncate(R); if (roundR != intR) tempColor = Color.Black; int X1 = X + halfX; int Y1 = Y + halfY; calculatedImage.SetPixel(X1, Y1, tempColor); calculatedImage.SetPixel(sizeX - 2 - X1, Y1, tempColor); calculatedImage.SetPixel(X1, sizeY - 2 - Y1, tempColor); calculatedImage.SetPixel(sizeX - 2 - X1, sizeY - 2 - Y1, tempColor); } // for X } // for Y pbImage.Image = calculatedImage; } // method DrawImage
Showing posts with label Apple ][. Show all posts
Showing posts with label Apple ][. Show all posts
Sunday, March 26, 2017
Calculated Image
A billion years ago I found a one liner in a magazine and it made a pretty cool image. Recently I found it again and thought it would be cool to try it on a modern computer. Below is the algorithm I came up with. Just drop a Picture Box onto a form, add an X, Y and Decimal (from .2 to .9):
Wednesday, December 7, 2016
Cool AppleSoft Emulator
I've posted about this one before (7 years ago!) but I've been feeling nostalgic lately so I revisited it... The site is at http://www.calormen.com/Applesoft/ and is an AppleSoft Basic interpreter written in JavaScript. Joshua Bell did a great job with it. I've sent him several programs (4 recently) and he included them in his Samples list. He is a really great guy.
You should try the emulator out... be sure to check my programs :)
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.
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.
Saturday, February 28, 2009
Here is some old code for you...
The Apple ][ computer didn't have super fancy graphics. They had a portion of memory mapped to the graphic screen. Since I don't really feel like trying to explain it here because others have done it far better than I could read this: http://en.wikipedia.org/wiki/Apple_II_graphics Specifically the Hires Graphics section.
Now, I had a need to be able to scroll the Hires Screen left or right. Thanks to a series of articles by David Lubar in Creative Computing called The Graph Paper (October 1982 -> March 1983) and an article called Lookup Tables (March 1982) I had a very good understanding of how each byte in memory made up the picture that was displayed so I wrote the following code using the SC Macro Assembler. This version of the code did the scroll left.
The 'Lookup Table' allowed me to access each line of the hires screen directly and in order (since the screen was 'interlaced').
BTW, comments are for losers. :)
1000 .OR $6000
1010 .TF SCROLLLEFT
1020 .LIST OFF
1030 JMP HERE
1040 TABLHI .HS 2024282C3034383C
1050 .HS 2024282C3034383C
1060 .HS 2125292D3135393D
1070 .HS 2125292D3135393D
1080 .HS 22262A2E32363A3E
1090 .HS 22262A2E32363A3E
1100 .HS 23272B2F33373B3F
1110 .HS 23272B2F33373B3F
1120 .HS 2024282C3034383C
1130 .HS 2024282C3034383C
1140 .HS 2125292D3135393D
1150 .HS 2125292D3135393D
1160 .HS 22262A2E32363A3E
1170 .HS 22262A2E32363A3E
1180 .HS 23272B2F33373B3F
1190 .HS 23272B2F33373B3F
1200 .HS 2024282C3034383C
1210 .HS 2024282C3034383C
1220 .HS 2125292D3135393D
1230 .HS 2125292D3135393D
1240 .HS 22262A2E32363A3E
1250 .HS 22262A2E32363A3E
1260 .HS 23272B2F33373B3F
1270 .HS 23272B2F33373B3F
1280 TABLLO .HS 0000000000000000
1290 .HS 8080808080808080
1300 .HS 0000000000000000
1310 .HS 8080808080808080
1320 .HS 0000000000000000
1330 .HS 8080808080808080
1340 .HS 0000000000000000
1350 .HS 8080808080808080
1360 .HS 2828282828282828
1370 .HS A8A8A8A8A8A8A8A8
1380 .HS 2828282828282828
1390 .HS A8A8A8A8A8A8A8A8
1400 .HS 2828282828282828
1410 .HS A8A8A8A8A8A8A8A8
1420 .HS 2828282828282828
1430 .HS A8A8A8A8A8A8A8A8
1440 .HS 5050505050505050
1450 .HS D0D0D0D0D0D0D0D0
1460 .HS 5050505050505050
1470 .HS D0D0D0D0D0D0D0D0
1480 .HS 5050505050505050
1490 .HS D0D0D0D0D0D0D0D0
1500 .HS 5050505050505050
1510 .HS D0D0D0D0D0D0D0D0
1520 HERE STA $C050
1530 STA $C057
1540 STA $C054
1550 STA $C052
1560 LDX #$00
1570 A7 LDA TABLLO,X
1580 STA $F0
1590 LDA TABLHI,X
1600 STA $F1
1610 CLC
1620 LDY #$27
1630 A6 LDA ($F0),Y
1640 ROL
1650 BCC A1
1660 ROR
1670 BCC A2
1680 SEC
1690 ROR
1710 JMP A3
1720 A2 ROL
1730 CLC
1740 ROR
1750 SEC
1760 ROR
1770 JMPA3
1780 A1 ROR
1790 BCC A4
1800 ROL
1810 SEC
1820 ROR
1830 A4 ROR
1840 A3 STA ($F0),Y
1850 ROR
1860 DEY
1870 BMI A5
1880 ROL
1890 JMP A6
1900 A5 INX
1910 CPX #$C0
1920 BNE A7
1930 RTS
And the code to scroll right looks like this:
1000 .OR $6000
1010 .TF SCROLLRGHT
1020 .LIST OFF
1030 JMP HERE
1040 TABLHI .HS 2024282C3034383C
1050 .HS 2024282C3034383C
1060 .HS 2125292D3135393D
1070 .HS 2125292D3135393D
1080 .HS 22262A2E32363A3E
1090 .HS 22262A2E32363A3E
1100 .HS 23272B2F33373B3F
1110 .HS 23272B2F33373B3F
1120 .HS 2024282C3034383C
1130 .HS 2024282C3034383C
1140 .HS 2125292D3135393D
1150 .HS 2125292D3135393D
1160 .HS 22262A2E32363A3E
1170 .HS 22262A2E32363A3E
1180 .HS 23272B2F33373B3F
1190 .HS 23272B2F33373B3F
1200 .HS 2024282C3034383C
1210 .HS 2024282C3034383C
1220 .HS 2125292D3135393D
1230 .HS 2125292D3135393D
1240 .HS 22262A2E32363A3E
1250 .HS 22262A2E32363A3E
1260 .HS 23272B2F33373B3F
1270 .HS 23272B2F33373B3F
1280 TABLLO .HS 0000000000000000
1290 .HS 8080808080808080
1300 .HS 0000000000000000
1310 .HS 8080808080808080
1320 .HS 0000000000000000
1330 .HS 8080808080808080
1340 .HS 0000000000000000
1350 .HS 8080808080808080
1360 .HS 2828282828282828
1370 .HS A8A8A8A8A8A8A8A8
1380 .HS 2828282828282828
1390 .HS A8A8A8A8A8A8A8A8
1400 .HS 2828282828282828
1410 .HS A8A8A8A8A8A8A8A8
1420 .HS 2828282828282828
1430 .HS A8A8A8A8A8A8A8A8
1440 .HS 5050505050505050
1450 .HS D0D0D0D0D0D0D0D0
1460 .HS 5050505050505050
1470 .HS D0D0D0D0D0D0D0D0
1480 .HS 5050505050505050
1490 .HS D0D0D0D0D0D0D0D0
1500 .HS 5050505050505050
1510 .HS D0D0D0D0D0D0D0D0
1520 HERE STA $C050
1530 STA $C057
1540 STA $C054
1550 STA $C052
1560 LDX #$00
1570 A7 LDA TABLLO,X
1580 STA $F0
1590 LDA TABLHI,X
1600 STA $F1
1610 CLC
1620 LDY #$00
1630 A6 LDA ($F0),Y
1640 ROL
1650 BCC A1
1660 ROL
1670 BCC A2
1680 SEC
1690 ROR
1700 SEC
1710 BCS A3
1720 A2 SEC
1730 ROR
1740 CLC
1750 BCC A3
1760 A1 ROL
1770 BCC A4
1780 CLC
1790 ROR
1800 SEC
1810 BCS A3
1820 A4 CLC
1830 ROR
1840 CLC
1850 A3 STA ($F0),Y
1860 ROR
1870 INY
1880 CPY #$28
1890 BEQ A5
1900 ROL
1910 JMP A6
1920 A5 INX
1930 CPX #$C0
1940 BNE A7
1950 RTS
The code is very close but there are some important differences (like line 1620, 00 starts on the left of the line and #27 starts on the right of the line).
Now, you may ask, Why did I bother posting this? Because I could and I felt like sharing. I do have some old notebook pages I found with some hand written code on them that I'm going to scan in and post here at some point in the near future.
Ah, the old days...
So, long ago I was deep into Apple ][ computers. I could hand code assembly directly into the monitor (until I got my hands on SC Macro Assembler).. A time when Boot Code tracing was the best way to get into the guts of a game and when windows were things you looked out of.
My buddy and I would figure out some cool piece of code and then share it. Each of us trying to be better than the other.
Once I figure out an easy way to link to some of the stuff we wrote, I'll post links to .bin files that will run in any Apple ][ emulator. Sure, its not up to today's standards but for the time it was pretty cool (20+ years ago!).
I miss the simplicity of the code & operating systems. Today's OSes just have way too much bloat.
Ah well... everything must pass to dust eventually
My buddy and I would figure out some cool piece of code and then share it. Each of us trying to be better than the other.
Once I figure out an easy way to link to some of the stuff we wrote, I'll post links to .bin files that will run in any Apple ][ emulator. Sure, its not up to today's standards but for the time it was pretty cool (20+ years ago!).
I miss the simplicity of the code & operating systems. Today's OSes just have way too much bloat.
Ah well... everything must pass to dust eventually
Subscribe to:
Posts (Atom)