Jump to content
Sid1968

A worse programmers questions

Recommended Posts

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 by Sid1968

Share this post


Link to post
Share on other sites

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. 

  • Like 1

Share this post


Link to post
Share on other sites
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 by Sid1968

Share this post


Link to post
Share on other sites

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:

plot.png.d9d52c6d63cc9bcb0e3db527da4f204d.png

 

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 by Asmusr
  • Like 3
  • Thanks 2

Share this post


Link to post
Share on other sites
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... 

 

image.thumb.png.a65b9cdd4d0c4907d8228872f9e782a5.png

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. 🙂

 

  • Thanks 1

Share this post


Link to post
Share on other sites
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. ;)

 

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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:

plot.png.d9d52c6d63cc9bcb0e3db527da4f204d.png

 

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 by Sid1968

Share this post


Link to post
Share on other sites
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 by Sid1968

Share this post


Link to post
Share on other sites

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.

 

SINE.JPG.d313deac116c46bf802e8a963bb90891.JPG

SINE.JPG

  • Thanks 3

Share this post


Link to post
Share on other sites
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.

 

SINE.JPG.d313deac116c46bf802e8a963bb90891.JPG

SINE.JPG

 

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 by Sid1968

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

  • Like 1

Share this post


Link to post
Share on other sites
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. 

Share this post


Link to post
Share on other sites
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 by Sid1968

Share this post


Link to post
Share on other sites
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. ;)

 

Share this post


Link to post
Share on other sites
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 by Tursi
  • Like 1

Share this post


Link to post
Share on other sites
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. ;)

Share this post


Link to post
Share on other sites
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 by Sid1968

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...