Page 2 of 3
Re: WINDOWS MYSTIFY CLONE....ALMOST WORKING
Posted: Tue May 09, 2023 6:06 pm
by ahenry3068
This is driving me to drink.....lol....
I want the code to be able to handle any number of boxes. any number of corners 2 or greater. I have
a certain subset working but it has yet to turn out General Purpose.... !!!!!
Anything over 3 boxes and 4 to 6 corners is going to be sluggish for this system but I still want the code
logic to be correct...
Re: WINDOWS MYSTIFY CLONE....ALMOST WORKING
Posted: Tue May 09, 2023 6:39 pm
by DragWx
Don't worry too much about optimizing the code; even if you go out of your way to do all of the usual CBM BASIC optimizations, you'll only get a small boost at the cost of making the code unreadable:
(I was having a bit of fun with the code after I posted my initial fixes, and this was one of the things I tried
)
Code: Select all
10 SCREEN 128
20 RECT 0,0,319,239,16
30 NB = 2: REM NUMBER OF SHAPES ON SCREEN
35 NC = 4: REM NUMBER OF CORNERS FOR THE SHAPES
40 BD = 8: REM DEPTH TO DRAW BEFORE STARTING ERASURE
45 YL = 238
50 XL = 318
110 P1 = 1 : REM CURRENT BOX
120 P2 = 1 : REM PREVIOUS BUFFER POSITION
130 P3 = 2 : REM CURRENT BUFFER POSITION
140 P4 = 0 : REM CURRENT COLOR
150 X1 = 0: X2 = 0: X3 = 0
160 Y1 = 0: Y2 = 0: Y3 = 0
170 DIM BX(NB,BD, NC) : REM CORNER X COORDINATES
180 DIM BY(NB,BD, NC) : REM CORNER Y COORDINATES
190 DIM XI(NB, NC) : REM X INCREMENT
200 DIM YI(NB, NC) : REM Y INCREMENT
210 DIM BC(NB) : REM COLOR OF THE BOX
300 GOSUB 6000
400 FOR P1=1 TO NB
410 X2=BX(P1,P3,NC):Y2=BY(P1,P3,NC)
420 FOR C=1 TO NC
430 X1=X2:X2=BX(P1,P3,C):Y1=Y2:Y2=BY(P1,P3,C)
440 LINE X1,Y1,X2,Y2,16
450 X3=BX(P1,P2,C)+XI(P1,C):Y3=BY(P1,P2,C)+YI(P1,C)
460 IF X3>XL THEN XI(P1,C)=-INT((RND(1)*5)+1):X3=XL
470 IF X3<0 THEN XI(P1,C)=INT(RND(1)*5)+1:X3=0
480 IF Y3>YL THEN YI(P1,C)=-INT((RND(1)*5)+1):Y3=YL
490 IF Y3<0 THEN YI(P1,C)=INT(RND(1)*5)+1:Y3=0
500 BX(P1,P3,C)=X3:BY(P1,P3,C)=Y3
510 NEXT
520 X2=X3:Y2=Y3:P4=BC(P1)
530 FOR C=1 TO NC
540 X1=X2:X2=BX(P1,P3,C):Y1=Y2:Y2=BY(P1,P3,C)
550 LINE X1,Y1,X2,Y2,P4
560 NEXT:NEXT
570 P2=P3:P3=P3+1:IF P3>BD THEN P3=1
580 GOTO 400
5999 REM SETUP VARIABLES
6000 X = INT(RND(-TI))
6005 FOR B = 1 TO NB
6010 BC(B) = INT(RND(1)*255)+1
6020 IF BC(B)=0 OR BC(B)=16 THEN GOTO 6010
6040 FOR C = 1 TO NC
6050 XI(B,C) = INT(RND(1)*5)+1
6060 IF (INT(RND(1)*20)+1) > 10 THEN XI(B,C)= -XI(B,C)
6070 YI(B,C) = INT(RND(1)*5)+1
6080 IF (INT(RND(1)*20)+1) > 10 THEN YI(B,C)= -XI(B,C)
6090 BX(B,1,C) = INT(RND(1)*319) + 1
6100 BY(B,1,C) = INT(RND(1)*239) + 1
6110 NEXT C
6120 NEXT B
6130 RETURN
...so I don't think it's worthwhile.
Re: WINDOWS MYSTIFY CLONE....ALMOST WORKING
Posted: Tue May 09, 2023 6:54 pm
by ahenry3068
Works well.... It actually runs faster than I thought it might....
One of the reasons this is driving me crazy is I did exactly this algorithm in the 90's only in Borland Pascal.
Re: WINDOWS MYSTIFY CLONE....ALMOST WORKING
Posted: Tue May 09, 2023 6:56 pm
by ahenry3068
I think it might run quite smoothly in C or Prog8
Re: WINDOWS MYSTIFY CLONE....ALMOST WORKING
Posted: Tue May 09, 2023 7:04 pm
by ahenry3068
I guess there was I reason I left QuickBasic for Pascal.....lol.
I think the entire development community went askew when they Chose C & C++ ............lol
Re: WINDOWS MYSTIFY CLONE....ALMOST WORKING
Posted: Tue May 09, 2023 7:19 pm
by ahenry3068
If Borland ever did a Turbo Pascal for C64 and I got hold of the source code.... I would take lead on porting to CX16... I don't think I could devote my twilight years to writing it from Scratch....... lol
Re: WINDOWS MYSTIFY CLONE....ALMOST WORKING
Posted: Tue May 09, 2023 7:36 pm
by ahenry3068
TO DRAGWX.
Drop me your name in a PM.... I appreciate your interest in the Code.
If I use this code anywhere else I want to at least give you a name drop..
I have no plans for anything commercial.... lol
Re: WINDOWS MYSTIFY CLONE....ALMOST WORKING
Posted: Tue May 09, 2023 8:57 pm
by DragWx
No need, and don't worry about it; use the code however you'd like.
Re: WINDOWS MYSTIFY CLONE....ALMOST WORKING
Posted: Tue May 09, 2023 10:08 pm
by TomXP411
ahenry3068 wrote: ↑Tue May 09, 2023 7:04 pm
I guess there was I reason I left QuickBasic for Pascal.....lol.
I think the entire development community went askew when they Chose C & C++ ............lol
Huh. I can't stand Pascal. I did my one semester of Pascal in college, then deleted the compiler and never looked back.
Looked at objectively, C and its derived languages (C++, C#, Java) are the only high level programming languages we really need. Everything done in other languages can be done in C++, with the right libraries, of course.
Re: WINDOWS MYSTIFY CLONE....ALMOST WORKING
Posted: Tue May 09, 2023 10:19 pm
by ahenry3068
I'm quite aware that I'm the weirdo here... Pascal
always struck me as the correct compromise
between the low level capabilities of C and the readability
of BASIC or COBOL The Borland Dialects of the language
have every bit of the capabilities of C or C++
My last major project I used the Free Pascal Compiler
and implemented almost a complete backend for
Web Server Programs (Common Gateway Interface)
The last parts of that project are still on the web though
kind of defunct. PSP and PowUtils (Pascal Server Pages)