Sid1968 Posted October 17, 2019 Author Share Posted October 17, 2019 (edited) For those readers of this thread that are the opinion that the claim to share the programlisting in this thread could be called arrogant, i give this short explanation: The actual challenge has its origin in the discussion on how to solve a "plot" command. The discussion went well, but got a little too theroretical. So this challenge were born. We see now that some dialects/languages have some problems with the labeling. Sharing the programlistings in THIS thread has the reason, that interested readers must not look at other places. So the reason for sharing the programlisting in this thread is the clarity! Its easier for all, the paricipans and the interested readers, if they can find the programlistings here. Since i thought this would be clear for all participants of this challenge i didnt mentioned it before. So lets get this challenge going in a positiv matter. Iam still very exited of Lees and Richs listings... and maybe the experienced senior_falcon will share his listing with us too. Kind Regards Sid ? Edited October 17, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted October 17, 2019 Share Posted October 17, 2019 Have you downloaded The Missing Link and looked at the demo program? That would give you a good idea of what can be accomplished. This challenge would take one or two lines using TML. You have expressed an interest in the TI99/4a. Your challenge would be a perfect opportunity to get your hands on the keyboard and actually learn by doing. There are lots of people here who could help guide you when you go astray. 1 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted October 17, 2019 Author Share Posted October 17, 2019 (edited) 29 minutes ago, senior_falcon said: Have you downloaded The Missing Link and looked at the demo program? That would give you a good idea of what can be accomplished. This challenge would take one or two lines using TML. You have expressed an interest in the TI99/4a. Your challenge would be a perfect opportunity to get your hands on the keyboard and actually learn by doing. There are lots of people here who could help guide you when you go astray. I know that. But this challenge is not mainly for learning for me (like the other challenges too) than for seeing the strength and weekness of each dialect/language. The target is certainly not to show somebody up, but to look at where an improvement is needed and to make the readers of this thread hungry to reproduce the listings on its own TI-99/4A. You should know me good enough, that you know my targets are ALWAYS positiv. Please post your listing here, everyone would benefit of it. After this challenge i will give other challenges that build on this challenge... in the end we will have a nice functionplotter. So far as i know the VIC-20 has NO functionplotter.... so we would be a little "superior" over the VIC-20. But in each and everycase we, the people of this community together, have learned something more. Isnt that a good target? Cheers Sid Edited October 17, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
Asmusr Posted October 17, 2019 Share Posted October 17, 2019 (edited) I can't let Tursi and TI BASIC win this one. So here's a Cortex BASIC version with labels. Takes about 5 seconds to draw where the TI BASIC version takes about 10 minutes. 10 COLOUR 1,14 20 GRAPH 30 DIM $F(10,3) 40 $F(0,0)="111101101101111" 50 $F(1,0)="010110010010010" 60 $F(2,0)="111001111100111" 70 $F(3,0)="111001111001111" 80 $F(4,0)="101101111001001" 90 $F(5,0)="111100111001111" 100 $F(6,0)="111100111101111" 110 $F(7,0)="111001001001001" 120 $F(8,0)="111101111101111" 130 $F(9,0)="111101111001111" 140 SW=256 : SH=192 150 GW=10 : GH=SH/SW*GW 160 SX=0.9*SW/GW : SY=SH/GH 170 OX=SW/2 : OY=SH/2 180 REM DRAW X-AXIS 190 PLOT 0,OY TO SW-1,OY 200 FOR X=INT(-GW/2) TO INT(GW/2) STEP 1 210 XS=OX+X*SX 220 PLOT XS,OY-2 TO XS,OY+2 230 XS=XS-1 240 YS=OY+4 250 N=X 260 IF N<>0 THEN GOSUB 1000 270 NEXT X 280 REM DRAW Y-AXIS 300 PLOT OX,0 TO OX,SH-1 310 FOR Y=INT(-GH/2) TO INT(GH/2) STEP 1 320 YS=OY-Y*SY 330 PLOT OX-2,YS TO OX+2,YS 340 XS=OX+4 350 YS=YS-2 360 N=Y 370 IF N<>0 THEN GOSUB 1000 380 NEXT Y 390 REM DRAW GRAPH 400 FOR X=-5 TO 5 STEP 0.1 410 PLOT OX+X*SX,OY-SIN(X)*SY 420 NEXT X 430 WAIT 1000 440 TEXT 450 STOP 1000 REM PLOT NUMBER N AT POS XS,YS 1010 IF N<0 THEN PLOT XS,YS+2 TO XS+2,YS+2 : XS=XS+4 1020 DIM $CH(3) 1030 $CH(0)=$F(ABS(N),0) 1040 FOR R=0 TO 4 1050 FOR C=0 TO 2 1060 I=R*3+C+1 1070 IF ASC($CH(0;I))=49 THEN PLOT XS+C,YS+R 1080 NEXT C 1090 NEXT R 1100 RETURN Output: I have to say, string handling in Cortex BASIC is weird. Took me hours to figure out how to make a simple array. Edit: Notice that the labels on the y-axis are not flipped like in the TI BASIC version. Edited October 17, 2019 by Asmusr 4 2 Quote Link to comment Share on other sites More sharing options...
+TheBF Posted October 17, 2019 Share Posted October 17, 2019 11 hours ago, Tursi said: I don't think "improve" is the right word, you changed the rules after I posted it. There you go. However, until you actually sit and run it yourself, don't ask for more. I've documented this one a little further, but most of the comments are NOT in the code. I'm not sure there's enough RAM left for them... might be. Anyway... This is such a clever method. While it could be literally translated from BASIC to Forth with CAMEL99's re-entrant *string library, there is also an opportunity to use this method but make use of the machine in ways that native BASIC doesn't have. (*I made the first version in 1987 to give TI-Forth BASIC string functions) Perhaps Tursi can weigh in if I understand things correctly. Make dot plotting characters use the chars above 127. This would mean we don't need the CC$() array. We can just use the pattern descriptor table for that purpose Then we could redefine existing 1,2,3,4,5, "-" chars as tiny numbers and print to the screen directly And of course, with some effort, we could swap out the string functions for bit operations on the PDT data which would go faster. It is still a considerable effort (for me) to re-write it but I will come back here in future. ? 1 Quote Link to comment Share on other sites More sharing options...
Tursi Posted October 17, 2019 Share Posted October 17, 2019 1 hour ago, TheBF said: Make dot plotting characters use the chars above 127. This would mean we don't need the CC$() array. We can just use the pattern descriptor table for that purpose Yeah, the main reason for the CC$ array is that TI BASIC can not access the pattern definitions (ie: no CALL CHARPAT), so I needed some way to know the current pattern in order to add a single pixel to it. I was always jealous of bitmapped mode on the Apple 2 back in the day, and having only TI BASIC, I did stuff like this to see if it could be done. When the Missing Link was released, I was all over that too. 3 1 Quote Link to comment Share on other sites More sharing options...
apersson850 Posted October 18, 2019 Share Posted October 18, 2019 Is there a specific point in making the label digits smaller than normal? Do you think they occupy too much screen real estate? There have been function plotters for the TI, in different languages, for more than 35 years now. Many years ago, I did one in TI Extended BASIC, which had the same resolution as multicolor mode. By defining a number of characters, with two by two "blocks", not more characters were needed than that I could define all of them. If I needed the two top blocks on in a specific position on the screen, I printed that character on that location. If then a new curve (the program could plot multiple functions in the same screen) needed the two blocks at the bottom of that position on, I replaced the character with two top blocks for one with two top and two bottom blocks. This allowed plotting any combinations of curve across the whole screen, but with the resolution limited to four by four pixel blocks. It wasn't until I implemented bitmap mode in Pascal, a few years later, that I could plot multiple functions, with lines in different colors, and add text labels, with the resolution of one pixel. Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted October 18, 2019 Author Share Posted October 18, 2019 (edited) 14 hours ago, Asmusr said: I can't let Tursi and TI BASIC win this one. So here's a Cortex BASIC version with labels. Takes about 5 seconds to draw where the TI BASIC version takes about 10 minutes. 10 COLOUR 1,14 20 GRAPH 30 DIM $F(10,3) 40 $F(0,0)="111101101101111" 50 $F(1,0)="010110010010010" 60 $F(2,0)="111001111100111" 70 $F(3,0)="111001111001111" 80 $F(4,0)="101101111001001" 90 $F(5,0)="111100111001111" 100 $F(6,0)="111100111101111" 110 $F(7,0)="111001001001001" 120 $F(8,0)="111101111101111" 130 $F(9,0)="111101111001111" 140 SW=256 : SH=192 150 GW=10 : GH=SH/SW*GW 160 SX=0.9*SW/GW : SY=SH/GH 170 OX=SW/2 : OY=SH/2 180 REM DRAW X-AXIS 190 PLOT 0,OY TO SW-1,OY 200 FOR X=INT(-GW/2) TO INT(GW/2) STEP 1 210 XS=OX+X*SX 220 PLOT XS,OY-2 TO XS,OY+2 230 XS=XS-1 240 YS=OY+4 250 N=X 260 IF N<>0 THEN GOSUB 1000 270 NEXT X 280 REM DRAW Y-AXIS 300 PLOT OX,0 TO OX,SH-1 310 FOR Y=INT(-GH/2) TO INT(GH/2) STEP 1 320 YS=OY-Y*SY 330 PLOT OX-2,YS TO OX+2,YS 340 XS=OX+4 350 YS=YS-2 360 N=Y 370 IF N<>0 THEN GOSUB 1000 380 NEXT Y 390 REM DRAW GRAPH 400 FOR X=-5 TO 5 STEP 0.1 410 PLOT OX+X*SX,OY-SIN(X)*SY 420 NEXT X 430 WAIT 1000 440 TEXT 450 STOP 1000 REM PLOT NUMBER N AT POS XS,YS 1010 IF N<0 THEN PLOT XS,YS+2 TO XS+2,YS+2 : XS=XS+4 1020 DIM $CH(3) 1030 $CH(0)=$F(ABS(N),0) 1040 FOR R=0 TO 4 1050 FOR C=0 TO 2 1060 I=R*3+C+1 1070 IF ASC($CH(0;I))=49 THEN PLOT XS+C,YS+R 1080 NEXT C 1090 NEXT R 1100 RETURN Output: I have to say, string handling in Cortex BASIC is weird. Took me hours to figure out how to make a simple array. Edit: Notice that the labels on the y-axis are not flipped like in the TI BASIC version. Thats perfect! Thank you. Tursi likes the missions impossible... He showed us, what most of us, not suspected in TI-Basic. A great work. Since the main task was not the speed but the elegance Tursi set a new standard for elegance. ? Asmusr you made a fantastic job in Cortex Basic, even though your task was simpler because Cortex Basic offers the plott command. I say Thank you to all participans of this challenge... and maybe Tursi or another Assemberpro will show us how to solve this in Assembler. Maybe there the plotting would run a little faster... Edited October 18, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted October 18, 2019 Author Share Posted October 18, 2019 (edited) 12 hours ago, Tursi said: Yeah, the main reason for the CC$ array is that TI BASIC can not access the pattern definitions (ie: no CALL CHARPAT), so I needed some way to know the current pattern in order to add a single pixel to it. I was always jealous of bitmapped mode on the Apple 2 back in the day, and having only TI BASIC, I did stuff like this to see if it could be done. When the Missing Link was released, I was all over that too. Isnt your method in your TI-Basicprogram the same that is used for scrolling Text/Objects in Demos? Edited October 18, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted October 18, 2019 Share Posted October 18, 2019 10 CALL LINK("LINE",96,1,96,240):: CALL LINK("LINE",1,120,192,120):: FOR C=-5 TO 5 STEP .04 :: CALL LINK("PIXEL",96-SIN(C)*30,120+C*25):: NEXT C 20 GOTO 20 I will leave it to someone else to put in the tick marks and numbers. 3 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted October 18, 2019 Author Share Posted October 18, 2019 (edited) 1 hour ago, senior_falcon said: 10 CALL LINK("LINE",96,1,96,240):: CALL LINK("LINE",1,120,192,120):: FOR C=-5 TO 5 STEP .04 :: CALL LINK("PIXEL",96-SIN(C)*30,120+C*25):: NEXT C 20 GOTO 20 I will leave it to someone else to put in the tick marks and numbers. Thank you senior_falcon. Thats a good start with an impressing short program. ? Is the labeling a problem in xb256, too? So far as i know fbForth has problems too. But maybe Lee found a solution in the meanwhile. Kind Regards Sid Edited October 18, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted October 18, 2019 Author Share Posted October 18, 2019 5 hours ago, apersson850 said: Is there a specific point in making the label digits smaller than normal? Do you think they occupy too much screen real estate? There have been function plotters for the TI, in different languages, for more than 35 years now. Many years ago, I did one in TI Extended BASIC, which had the same resolution as multicolor mode. By defining a number of characters, with two by two "blocks", not more characters were needed than that I could define all of them. If I needed the two top blocks on in a specific position on the screen, I printed that character on that location. If then a new curve (the program could plot multiple functions in the same screen) needed the two blocks at the bottom of that position on, I replaced the character with two top blocks for one with two top and two bottom blocks. This allowed plotting any combinations of curve across the whole screen, but with the resolution limited to four by four pixel blocks. It wasn't until I implemented bitmap mode in Pascal, a few years later, that I could plot multiple functions, with lines in different colors, and add text labels, with the resolution of one pixel. Is it possible for you to face the challenge in Pascal? Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted October 18, 2019 Share Posted October 18, 2019 19 minutes ago, Sid1968 said: Is the labeling a problem in xb256, too? The program was done using The Missing Link, not XB256. Labeling is not a problem in TML. If you download TML and run TMLDEMO you would see that text can be displayed anywhere on the screen with pixel accuracy. 1 Quote Link to comment Share on other sites More sharing options...
Asmusr Posted October 18, 2019 Share Posted October 18, 2019 On 10/17/2019 at 2:15 PM, Sid1968 said: After this challenge i will give other challenges that build on this challenge... I think it would be fun to have more programming challenges, but perhaps you should start a new thread, since most of us (judging from the many frustrated answers) thought this thread was about you seeking advice on how to program the TI-99/4A. For me to participate in a more challenges, the rules for each challenge should be stated unambiguously in advance, including a deadline for when to submit your solution. We don't necessarily need to have a winner, but it should be clear what we're trying to accomplish. All in a positive and friendly spirit, of course. Well, that's my opinion. Kill this thread and start another one with a clear purpose. Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted October 18, 2019 Author Share Posted October 18, 2019 (edited) 1 hour ago, Asmusr said: I think it would be fun to have more programming challenges, but perhaps you should start a new thread, since most of us (judging from the many frustrated answers) thought this thread was about you seeking advice on how to program the TI-99/4A. For me to participate in a more challenges, the rules for each challenge should be stated unambiguously in advance, including a deadline for when to submit your solution. We don't necessarily need to have a winner, but it should be clear what we're trying to accomplish. All in a positive and friendly spirit, of course. Well, that's my opinion. Kill this thread and start another one with a clear purpose. The title of this thread is "A worse programmers questions". Do you know the saying "The more i know, the more i know that i know nothing"? This thread is like a river on which we let us drive. It developes its own dynamic. Thats good. From each question, comes new ones. If you read the thread the first testprograms were the result of some questions... after that we settled down.. and the thread developed itself to the question how to plot something. Actually we run a challenge and see again, that not every dialect/language can solve a problem that easy while others (TI-Basic) made it. The challenges are one part of the questions. I try to ask in a matter that everyone can profit of it. Another advantage of the challenges is that they bring a little more life in it. So we have a change between dry ask and answer parts and more exiting challenge parts. I think this idea of the threat is not bad. And i think that the programers and developers of the languages do profit from the information exchange too. But certainly we can make another "Challenge only" thread too. How do you people think about that idea? Cheers Sid Edited October 18, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
Tursi Posted October 18, 2019 Share Posted October 18, 2019 10 hours ago, apersson850 said: Is there a specific point in making the label digits smaller than normal? Do you think they occupy too much screen real estate? No, I had to type the font bitmaps in by hand. The smaller they are, the less I had to type. Quote Link to comment Share on other sites More sharing options...
Tursi Posted October 18, 2019 Share Posted October 18, 2019 (edited) 10 hours ago, Sid1968 said: maybe Tursi or another Assemberpro will show us how to solve this in Assembler. Maybe there the plotting would run a little faster... No interest, done it before. Go search the threads on different ways to plot the 3d hat shape, or draw Alfred E Neuman, etc etc... Edited October 18, 2019 by Tursi 1 Quote Link to comment Share on other sites More sharing options...
Tursi Posted October 18, 2019 Share Posted October 18, 2019 10 hours ago, Sid1968 said: Isnt your method in your TI-Basicprogram the same that is used for scrolling Text/Objects in Demos? I don't think you read the source code. Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted October 18, 2019 Author Share Posted October 18, 2019 (edited) 42 minutes ago, Tursi said: I don't think you read the source code. You changed charakters into dots, right? As far as i know changing charakters into others was used in demos. Edited October 18, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
apersson850 Posted October 19, 2019 Share Posted October 19, 2019 17 hours ago, Sid1968 said: Is it possible for you to face the challenge in Pascal? Yes, but I don't intend to. You can find a summary of everything I did to implement bitmap graphics in Pascal at the whtech server. Look for programming/pascal/turtlegraphics. Here's the interface part of the turtlegraphics unit, as far as I brought it. You can go to and from bitmap mode, you can move the turtle, and while doing that, you can set the pen mode so that the turtle just moves invisibly, or draws a line behind it. You can also write characters and strings, as well as create a hardcopy of the screen for Epson-compatible dot matrix printers. unit turtlegraphics; (* Test of turtle graphic routines *) (* A-DATA 870408 *) interface type screen_color = (transparent,black,green2,green3,blue1,blue3,red1,cyan,red2, red3,yellow1,yellow3,green1,magenta,gray,white); screen_mode = (invisible,substitute,overwrite,underwrite,complement, none,draw,erase,reverse); procedure grafmode; procedure initturtle; procedure textmode; procedure viewport(left,right,bottom,top:integer); procedure pen_color(newcolor :screen_color); procedure pen_mode(newmode :screen_mode); procedure move(distance :integer); procedure moveto(x,y :integer); procedure turn(newangle :integer); procedure turnto(newangle :integer); function turtle_x :integer; function turtle_y :integer; function turtle_ang :integer; procedure w_char(ch :char); procedure w_string(line :string); procedure hardcopy; implementation Quote Link to comment Share on other sites More sharing options...
apersson850 Posted October 19, 2019 Share Posted October 19, 2019 There's much more information to get by looking at the referred data at whtech, rather than posting one single example here. Serveral samples of plotting data too. Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted October 19, 2019 Author Share Posted October 19, 2019 Thank you for that advices. Look Buddies... lets have a little fun together... As i wrote above at the end of these PLOT-Challenge we wanna have a beautiful functionplotter that we made together. For this it would be great if those people that have fun to participate, play with. We make one step after the other to reach the goal. For this its important to make the first step...this first challenge. This is the reason why I ask if someone could face the challange in one language. In this way we can see additionaly how the challenge is solved in the different languages... ? After the goal is reached, we will see how this thread developes and if there are new questions. ? Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted October 19, 2019 Share Posted October 19, 2019 Please define a "beautiful function plotter" Quote Link to comment Share on other sites More sharing options...
HOME AUTOMATION Posted October 19, 2019 Share Posted October 19, 2019 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted October 19, 2019 Author Share Posted October 19, 2019 (edited) 1 hour ago, senior_falcon said: Please define a "beautiful function plotter" Maybe i didt found the right english words. The german words are "Kurvendiskussion" and "Funktionsplotter". In a "Kurvendiskussion=?curve sketching?" mathematical functions are discussed. Example: The discussion of the function f(x)=sin(x)+3x means that the program calculates among others the zeniths (Scheitelpunkte) and the zeropoints (Nullpunkte). It can calculate the Ableitung (?derivatives?). The Funktionsplotter (?function plotter?) is a part of a Kurvendiskussionsprogramm (curve sketching program). We concentrate only on that. At the end our function plotter program should ask for the functions (we want to be able to draw more then one), and the x-range and should output the values of the zeropoints (where the function hits the x-axis) and the zeniths. It should label the function with its name. We will do this at best if we write the functionname under the plot and give the name and the function the same color. But lets do this step by step. Click me for curve sketching example Click me for function plotter example Because i was spoken to set a fixed deadline to present a result i beg all interested participans to submit the programlisting and screenshot of the first challenge in this thread until: 10/27/2019. Is this deadline to long/short? Give me a feedback. Cheers Sid Edited October 19, 2019 by Sid1968 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.