+Vorticon Posted February 21, 2023 Share Posted February 21, 2023 So I came across this video by 8-bit Show and Tell on Youtube and I thought it would be interesting to recreate that on the TI, so I did I could not get the pattern to work initially, until I figured out that the line length had to be Odd, not Even, for reasons that are unclear to me. That said, I'm not terribly happy with my code, and I was wondering if there is a way to optimize it somehow... 10 CALL CLEAR :: RANDOMIZE 20 CALL SCREEN(10) 30 CALL COLOR(1,7,10,2,9,10) 40 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF") 50 CALL CHAR(40,"FFFEFCF8F0E0C0800103070F1F3F7FFF") 60 B=B=0 70 FOR I=1 TO 27 :: B=B=0 80 Z=INT(RND+0.5) 90 IF Z=0 THEN CH=33 ELSE CH=40 100 IF B=-1 THEN IF Z=0 THEN CH=34 ELSE CH=41 110 IF I=27 THEN PRINT CHR$(CH)ELSE PRINT CHR$(CH); 120 NEXT I 130 GOTO 70 5 Quote Link to comment Share on other sites More sharing options...
JJB Posted February 21, 2023 Share Posted February 21, 2023 (edited) I was intrigued too and had a go with green instead of red 🙂: 100 CALL CLEAR 110 CALL SCREEN(3) 120 CALL COLOR(9,4,13) 130 CALL CHAR(96,"FFFEFCF8F0E0C080") 140 CALL CHAR(97,"0103070F1F3F7FFF") 160 CALL CHAR(98,"80C0E0F0F8FCFEFF") 165 CALL CHAR(99,"FF7F3F1F0F070301") 170 RV=INT(RND*4) 180 PRINT CHR$(96+RV); 190 GOTO 170 Definitely needs work Edited February 21, 2023 by JJB clatification Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted February 21, 2023 Share Posted February 21, 2023 Give this a go. 10 CALL CLEAR :: RANDOMIZE :: CALL SCREEN(10):: CALL COLOR(1,7,10,2,9,10) 20 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF",40,"FFFEFCF8F0E0C0800103070F1F3F7FFF") 30 FOR I=1 TO 27 :: B=B=0 :: PRINT CHR$(34+INT(RND+.5)*7+B);:: NEXT I :: PRINT :: GOTO 30 2 Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted February 21, 2023 Share Posted February 21, 2023 Also, this is from my back-library of schtuff. 5 RANDOMIZE 10 PRINT CHR$(47+INT(RND*2)*45);:: GOTO 10 Surprisingly, a little slower than its TI BASIC equivalent. Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted February 21, 2023 Share Posted February 21, 2023 15 minutes ago, OLD CS1 said: Give this a go. 10 CALL CLEAR :: RANDOMIZE :: CALL SCREEN(10):: CALL COLOR(1,7,10,2,9,10) 20 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF",40,"FFFEFCF8F0E0C0800103070F1F3F7FFF") 30 FOR I=1 TO 27 :: B=B=0 :: PRINT CHR$(34+INT(RND+.5)*7+B);:: NEXT I :: PRINT :: GOTO 30 Oh, and to reverse the effect of B, change line 30: 30 FOR I=1 TO 27 :: B=B=0 :: PRINT CHR$(33+INT(RND+.5)*7-B);:: NEXT I :: PRINT :: GOTO 30 Lastly, you can move B=B=0 to between the PRINT and NEXT statements to have it start at 0 rather than -1. 1 Quote Link to comment Share on other sites More sharing options...
JJB Posted February 21, 2023 Share Posted February 21, 2023 16 minutes ago, OLD CS1 said: Give this a go. 10 CALL CLEAR :: RANDOMIZE :: CALL SCREEN(10):: CALL COLOR(1,7,10,2,9,10) 20 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF",40,"FFFEFCF8F0E0C0800103070F1F3F7FFF") 30 FOR I=1 TO 27 :: B=B=0 :: PRINT CHR$(34+INT(RND+.5)*7+B);:: NEXT I :: PRINT :: GOTO 30 Yes that looks great. Shame the TI doesn't have several shades of gray Quote Link to comment Share on other sites More sharing options...
JJB Posted February 21, 2023 Share Posted February 21, 2023 Cool that we both had the same idea of replacing the C64 inversion capability with a char definition. Quote Link to comment Share on other sites More sharing options...
oddemann Posted February 21, 2023 Share Posted February 21, 2023 Will compiling it make it faster? Quote Link to comment Share on other sites More sharing options...
Retrospect Posted February 21, 2023 Share Posted February 21, 2023 6 minutes ago, oddemann said: Will compiling it make it faster? Yes. Many times faster. And if there's no decimal points in the numbers, it will compile quite well. Quote Link to comment Share on other sites More sharing options...
Retrospect Posted February 21, 2023 Share Posted February 21, 2023 40 minutes ago, JJB said: PRINT CHR$(34+INT(RND+.5)*7+B) @oddemann for example, this particular line won't go down too well with the compiler, it would have to be amended somehow. Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted February 22, 2023 Share Posted February 22, 2023 1 hour ago, Retrospect said: @oddemann for example, this particular line won't go down too well with the compiler, it would have to be amended somehow. I had used RND*2 before, but I am not certain how RND returns. @senior_falcon has some details on the best way to use RND when compiled. 2 Quote Link to comment Share on other sites More sharing options...
Retrospect Posted February 22, 2023 Share Posted February 22, 2023 Just now, OLD CS1 said: I had used RND*2 before, but I am not certain how RND returns. @senior_falcon has some details on the best way to use RND when compiled. I must say those patterns are very pretty and would make a good "transition" effect between levels on an arcade game. Not that I want to derail the thread or anything but still, they're nice. 3 Quote Link to comment Share on other sites More sharing options...
+TheBF Posted February 22, 2023 Share Posted February 22, 2023 2 hours ago, OLD CS1 said: Also, this is from my back-library of schtuff. 5 RANDOMIZE 10 PRINT CHR$(47+INT(RND*2)*45);:: GOTO 10 Surprisingly, a little slower than its TI BASIC equivalent. XB random number generator sucks from what Rich has seen. Could be that. 3 Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted February 22, 2023 Author Share Posted February 22, 2023 13 hours ago, JJB said: Cool that we both had the same idea of replacing the C64 inversion capability with a char definition. Yeah that was the fastest way to simulate inversion. One could write a routine to do that, but it would have been way too slow. Quote Link to comment Share on other sites More sharing options...
+Vorticon Posted February 22, 2023 Author Share Posted February 22, 2023 14 hours ago, OLD CS1 said: Give this a go. 10 CALL CLEAR :: RANDOMIZE :: CALL SCREEN(10):: CALL COLOR(1,7,10,2,9,10) 20 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF",40,"FFFEFCF8F0E0C0800103070F1F3F7FFF") 30 FOR I=1 TO 27 :: B=B=0 :: PRINT CHR$(34+INT(RND+.5)*7+B);:: NEXT I :: PRINT :: GOTO 30 That's what I'm talking about! Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted February 22, 2023 Share Posted February 22, 2023 (edited) B=B=0 I don't understand the purpose of this? It sets B=0 and I see no place where B is ever changed PRINT CHR$(34+INT(RND+.5)*7+B) RND+.5 will be a value from .5 to 1.4999..... so INT(RND+.5) will be 0 or 1 with an equal chance of either one. so INT(RND+.5)*7 will be either 0 or 7 You could replace that with PRINT CHR$(34+INT(RND*2)*7); and since B=0 I left it out. And with those changes I think this could be compiled. Edited February 22, 2023 by senior_falcon Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted February 22, 2023 Share Posted February 22, 2023 27 minutes ago, senior_falcon said: B=B=0 I don't understand the purpose of this? It sets B=0 and I see no place where B is ever changed That is not what happens. B is set to -1 (TRUE) if B=0 going into the expression or 0 (FALSE), otherwise. The first '=' is an assignment operator and the second '=' is a relational operator. The expression is treated the same as though it were stated B=(B=0) ...lee Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted February 22, 2023 Share Posted February 22, 2023 27 minutes ago, Lee Stewart said: That is not what happens. B is set to -1 (TRUE) if B=0 going into the expression or 0 (FALSE), otherwise. The first '=' is an assignment operator and the second '=' is a relational operator. The expression is treated the same as though it were stated B=(B=0) ...lee You are right! I thought that is what would happen and tested this in the immediate mode: B=B=0 PRINT B and it prints 0 It must be that B was set to some value other than zero, because if you enter B=0 B=B=0 PRINT B then -1 is printed. And of course, the program 10 B=B=0::PRINT B will print -1 as you say. Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted February 22, 2023 Share Posted February 22, 2023 7 minutes ago, senior_falcon said: You are right! I thought that is what would happen and tested this in the immediate mode: B=B=0 PRINT B and it prints 0 It must be that B was set to some value other than zero, because if you enter B=0 B=B=0 PRINT B then -1 is printed. And of course, the program 10 B=B=0::PRINT B will print -1 as you say. Yeah, in Walid’s program, B will alternate between 0 and -1 as the loop containing it executes. ...lee Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted February 22, 2023 Share Posted February 22, 2023 You may need the parentheses for this to work compiled. Quote Link to comment Share on other sites More sharing options...
RXB Posted February 22, 2023 Share Posted February 22, 2023 52 minutes ago, Lee Stewart said: Yeah, in Walid’s program, B will alternate between 0 and -1 as the loop containing it executes. ...lee I changed the program to see what was going on in B and it was just -1 0 over and over and over? 10 CALL CLEAR :: RANDOMIZE :: CALL SCREEN(10):: CALL COLOR(1,7,10,2,9,10) 20 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF",40,"FFFEFCF8F0E0C0800103070F1F3F7FFF") 30 FOR I=1 TO 27 :: B=B=0 :: S$=S$&STR$(B):: PRINT CHR$(34+INT(RND+.5)*7+B);:: NEXT I :: PRINT :: GOTO 30 Yea I know it crashes with string full but just FCTN 4 and type PRINT S$ to see result. Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted February 22, 2023 Share Posted February 22, 2023 20 hours ago, Vorticon said: I could not get the pattern to work initially, until I figured out that the line length had to be Odd, not Even, for reasons that are unclear to me. 30 FOR I=1 TO 27 :: B=B=0 :: S$=S$&STR$(B):: PRINT CHR$(34+INT(RND+.5)*7+B);:: NEXT I :: PRINT :: GOTO 30 i'm guessing the B=(B=0) is getting out of sync when the line is even. I bet if you added B=(B=0) after NEXT I it would work properly with an even line length. (and improperly with an odd line length) 1 Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted February 22, 2023 Share Posted February 22, 2023 1 hour ago, RXB said: I changed the program to see what was going on in B and it was just -1 0 over and over and over? The value of B represents the orientation of the piece to the drawn. Quote Link to comment Share on other sites More sharing options...
+OLD CS1 Posted February 22, 2023 Share Posted February 22, 2023 55 minutes ago, senior_falcon said: i'm guessing the B=(B=0) is getting out of sync when the line is even. I bet if you added B=(B=0) after NEXT I it would work properly with an even line length. (and improperly with an odd line length) The line length is controlled by I, hence 27 characters and thus odd. Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted February 22, 2023 Share Posted February 22, 2023 Yes, and if you made it 28 and added the one extra B=(B=0) it would probably work. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.