Page 1 of 1

ZX81 convert to VBA

Posted: Sat Dec 10, 2022 7:26 pm
by oldhand
How easy would it be to Convert a ZX81 game to Excel VBA Code?

Re: ZX81 convert to VBA

Posted: Sat Dec 10, 2022 8:51 pm
by XavSnap
Hi Oldhand,
To run it, or edit the code ?

Re: ZX81 convert to VBA

Posted: Sat Dec 10, 2022 9:52 pm
by oldhand
to edit the code to run as VBA. Thank you for Answering

Re: ZX81 convert to VBA

Posted: Sat Dec 10, 2022 10:01 pm
by XavSnap
Hi,
Use "P2Text.exe", "ZxTocken" or the SAVE"MYPRG.TXT" option in Vb81.
Rename it to "MyPrg.BAS".

INPUT = INPUTBOX()
PRINT = picture1.print "xxx"
DIM S$() = Dim S$() as string
PLOT = picture1.PSET()

Example;

Code: Select all

Private Sub Timer1_Timer()
Timer1.Enabled = False
Picture1.DrawMode = 4
'If (Rnd * 3) > 1 Then Univer (Rnd * 6) * IIf(Rnd * 1 > 0, 1, -1), (Rnd * 6) * IIf(Rnd * 1 > 0, 1, -1), (Rnd * 3) * IIf(Rnd * 1 > 0, 1, -1), (Rnd * 3) * IIf(Rnd * 1 > 0, 1, -1): Exit Sub

Me.AutoRedraw = False

Dim x1, y1, U, v, r, a, b, z, a2, B2
30     Dim m(255, 2)
40     For x1 = 1 To 128
50     Let m(x1, 2) = 255
60     Next x1
70     For y1 = 0 To 175 Step 5
80     For x1 = 1 To 128
90     If x1 = 65 Then GoTo 260
100    Let U = x1 - 64
110    Let v = y1 - 87
120    Let r = Sqr(U * U + v * v) / 4 + 0.01
130    Let z = (80 * Sin(r)) / r + 10
140    Let U = 0.707 * y1
150    Let a = (x1 + U)
160    Let b = (z + U + 16)
a2 = (a * 20) - 200 ' X Scale
B2 = (b * 10) + 150 ' Y Scale
180    If b <= m(a, 1) Then GoTo 220
190    Let m(a, 1) = b

Picture1.PSet (a2, B2), RGB(100, y1 + 50, x1 + 200)
220    If b >= m(a, 2) Then GoTo 260
230    Let m(a, 2) = b

Picture1.PSet (a2, B2), RGB(100, y1 + 50, x1 + 200)
260    Next x1
270    Next y1

End Sub

Have Fun.

Re: ZX81 convert to VBA

Posted: Sat Dec 10, 2022 10:28 pm
by oldhand
I can get a Listing of the ZX81 code that is not a problem, but converting it to use as VBA Excel code is the Hard part, But zx91 code has lots of Gosubs in them and Returns also you can use W as well as W$ which are treated different in ZX81 Coding.

Re: ZX81 convert to VBA

Posted: Sat Dec 10, 2022 10:55 pm
by XavSnap

Code: Select all

Private Sub RUN_Click()
1 GoSub CLS
5 Let a$ = "Hello"
10 GoSub 100
15 Let a$ = " "
20 GoSub 100
30 Let a$ = "WORLD"
40 GoSub 100
50 Let a = 3.1416
60 GoSub NxtLine
70 GoSub 300

90 GoTo 1000
100 Text1.Text = Text1.Text + a$
200 Return
300 Text1.Text = Text1.Text + a
400 Return

CLS:
Text1.Text = ""
Return

NxtLine:
Text1.Text = Text1.Text + vbCrLf
Return

1000 Rem END

End Sub