Jump to content
IGNORED

A worse programmers questions


Sid1968

Recommended Posts

15 hours ago, apersson850 said:

There's Matlab for things like that. Recreating parts of that on an old computer isn't within my interest.

Those who dont want to participate must NOT inform me/us. But nevertheless Thank you for that information. Its a pleasure to read your always constructive posts. ?

 

The Commodore C64 has a very good curve sketching program with a function plotter, called "Opti-Ma" from Heureka Teachware (1988). Click me for the German Manual of Opti-MA!

From page 43 to 79 in that manual you can see some plot examples.

 

You see even 8-Bit machines can do this. ;-)

Doing the function plotter on a TI-99/4A should make FUN! ?

 

Kind Regards

Sid

Edited by Sid1968
Link to comment
Share on other sites

Why this distinction between 8-bit and 16-bit machines? An 8-bit CPU can do anything a 16-bit can. It will usually take a longer time, but it can do it. Comparing with the TMS 9900 even implies that you compare processors with the same address space, since the TMS 9900 has a 16-bit address bus, something many 8-bit CPU designs also supports.

When it comes to advanced function analysis, memory had more to do with it. Looking at plotting, the video processor implies certain limits.

 

We've already seen that you can plot a function with a TI 99/4A, in several ways.

There's been no decision about which language to use. Making a general plotter, you have to make some kind of provision for getting the function in there. In BASIC, it's frequently so that the user is supposed to make one or more program lines to calculate the function. In traditional compiled languages, like Pascal, that's not equally easy. One way is to access the user defined function in a separate unit, so the user only has to compile that.

In Forth, you can define words that evaluate the function. But the plot package has to access a function that's not yet defined. And can later be redefined any number of times. I've not used Forth enough to know the best way to do that. Can you have a pointer to a word, and run it like that? As you define words, they are packed in memory, one after another. Can you redefine a word, when more other words have been defined after it? How does it fit, if the new definition is longer?

In assembly you can do whatever you like, but that's a bit awkward for a plotter.

 

An other approach is to write a general math statement parser, so you can key in your function as a text string. But already there, the main task of the plotter is no longer plotting on the screen, but parsing and evaluating that function.

Plotting on the screen is impossible in BASIC, at least on the full screen, without assembly support. It can't be done in Pascal either, not without expanding the functionality like I did with the turtlegraphics unit. But there too you need at least a little assembly support to set up the system. I've written line drawing procedures in Pascal, and they work, but are far too slow for practical use. At least the unit concept conceals the assembly part, so as a user of the library, you don't have to worry. You just include the statement uses turtlegraphics in your program.

 

I just quickly read the manual you linked to. It confirmed my suspicion that the main part of such a program isn't drawing on the screen, it's the management of the mathematical functions.

Edited by apersson850
Link to comment
Share on other sites

1 hour ago, apersson850 said:

I just quickly read the manual you linked to. It confirmed my suspicion that the main part of such a program isn't drawing on the screen, it's the management of the mathematical functions.

Thank you very much for your answer, you speak german? If you would have understood the challenge right, you could read that we only concentrate us on the plotter part. ;-)

And the reason is... that we make something together while we learn... The actual Challenge is about plotting... Wow... what a news...

 

For me it would be very interesting how Rich would solve it by using Assembler code in RXB and if Lee will find a solution in fbForth or Forth .

 

I remember Lees Post #345

On 10/16/2019 at 3:57 PM, Lee Stewart said:

Drawing the Cartesian axes and plotting curves in bitmap mode is trivial in fbForth 2.0. Labeling the axes, however, is not. The problem is that the programmer must essentially plot the letters and numbers because fonts do not work in bitmap mode as they do in most of the other display modes.

 

The problem is the reverse in graphics mode (the mode used by TI Basic and all XBs). In that mode, letters and numbers are easy, but plotting can only be done by manipulating character codes, which quickly limits fonts due to consuming characters during the plot. BTW, the “out of ink” problem in TI Logo is due to this consumption of character patterns for plotting in graphics mode.

 

That said, I will have an example plot in the near future for which I may try to use the font scheme of TI Forth’s 64-column editor.

 

...lee

 

Edited by Sid1968
Link to comment
Share on other sites

Then I have the news for you that the plotting challenge is already resolved. Just look at the posts in the thread.

But I can remind you about that you also asked for a way to input the functions to plot, and that it should be more than one function. Which is what I discussed above. If you need that explained more times, just read this post again.

 

Once you are done with that, some constructive input to how to define the functions would be more fruitful.

Link to comment
Share on other sites

17 minutes ago, apersson850 said:

Then I have the news for you that the plotting challenge is already resolved. Just look at the posts in the thread.

But I can remind you about that you also asked for a way to input the functions to plot, and that it should be more than one function. Which is what I discussed above. If you need that explained more times, just read this post again.

 

Once you are done with that, some constructive input to how to define the functions would be more fruitful.

In TI-Basic and Cortex Basic, yes. Do you really think that i didnt know that?!? But not in RXB, fbForth, xb256, Assembler, Pascal etc...

Iam very exciting if there will be some more examples.... and apersson850... believe it or not... not all people on this wonderful planet do have a negativ mindset.

I wish you a happy day!

 

Kind Regards

Sid ?

 

Edited by Sid1968
Link to comment
Share on other sites

40 minutes ago, Sid1968 said:

In TI-Basic and Cortex Basic, yes. Do you really think that i didnt know that?!? But not in RXB, fbForth, xb256, Assembler, Pascal etc...

Iam very exciting if there will be some more examples.... and apersson850... believe it or not... not all people on this wonderful planet do have a negativ mindset.

I wish you a happy day!

 

Kind Regards

Sid ?

 

Neither RXB nor XB256 have provisions for bit mapped graphics. So any plotting would have to be done the same way it is in TI Basic. To learn how to use bit mapped graphics in assembly, start at page 334 of the E/A manual. Forth and Pascal are beyond my pay grade. There are at least 3 utilities that provide bit mapped graphics in XB: Draw and Plot, Apesoft graphics, and The Missing Link, which in my not so humble opinion is the best of the 3. Have you downloaded any of these? I don't think so because if you had you would realize that the plotting part of the problem has been solved and no further research is needed. With the ability to plot pixels, it's time to move "on to the next cow" as they say on the farm, and figure out how to continue with the tricky part of your program which is getting the function into a form that can actually be evaluated without hard coding the program.

  • Like 2
Link to comment
Share on other sites

Since I'm a professional in this field, I have a realistic mindset. Those who have no idea sometimes consider that negative.

 

I was about to comment on the plotting part, but senior_falcon beat me to it.

That also Forth (all versions, but lets stay with fbForth) have the ability to switch to bitmap mode is well known, so the prerequisites are there. Pascal doesn't support bitmap, as it's delivered, but I made it possible. Perhaps somebody else too, but I've never heard about it. It doesn't matter either; it's at least possible with what I did. That there would be an interest in doing all the extra work required to implement this in assembly only - well, I don't think so. Going that way it will never be ready.

 

So, to bring this project any further, the next cow it is. What's the best way to get the function to plot into the program? The reasoning above leads us to three possible languages/operating environments to use: Extended BASIC supported by The missing link, fbForth or UCSD Pascal.

Link to comment
Share on other sites

44 minutes ago, senior_falcon said:

Neither RXB nor XB256 have provisions for bit mapped graphics. So any plotting would have to be done the same way it is in TI Basic. To learn how to use bit mapped graphics in assembly, start at page 334 of the E/A manual. Forth and Pascal are beyond my pay grade. There are at least 3 utilities that provide bit mapped graphics in XB: Draw and Plot, Apesoft graphics, and The Missing Link, which in my not so humble opinion is the best of the 3. Have you downloaded any of these? I don't think so because if you had you would realize that the plotting part of the problem has been solved and no further research is needed. With the ability to plot pixels, it's time to move "on to the next cow" as they say on the farm, and figure out how to continue with the tricky part of your program which is getting the function into a form that can actually be evaluated without hard coding the program.

Didnt Rich mentioned that RXB can implement Assembler Code for plotting? Even though Tursi did a fantastic job, its seemes for me that Cortex Basic is the only Basic Dialect that is usable... but... the only one???... Nobody tested Mechatronic Extended Basic II Plus with its "Axis" command.

 

It keeps to be exiting.... and of sure they will be a next challenge... a next "small" step... but i must not tell everything before the time has come....

But maybe the negativ "teammates" will have success and this thing is dead... we will see. ?

Edited by Sid1968
Link to comment
Share on other sites

Not that I've used RXB, but from what I've heard of it, you can use The missing link. But RXB itself doesn't provide for bitmapped graphics. There may be something else in RXB that's beneficiary for this project, but until we know what else to do, you can just as well use the normal Extended BASIC.

  • Like 1
Link to comment
Share on other sites

4 minutes ago, apersson850 said:

Not that I've used RXB, but from what I've heard of it, you can use The missing link. But RXB itself doesn't provide for bitmapped graphics. There may be something else in RXB that's beneficiary for this project, but until we know what else to do, you can just as well use the normal Extended BASIC.

If you mean with "we" yourself too i really dont know how you want to manage the next step if you didnt  managed the first...

Link to comment
Share on other sites

Well, you came up with the idea, so it's rather you who are the project manager. I'm giving suggestions to how to bring this project any further now. I don't intend to take on any project management role. As you've stated all the time, it's supposed to be a "together project".

Again, the next thing to consider is how to get the function(s) into the program.

Link to comment
Share on other sites

19 minutes ago, apersson850 said:

Well, you came up with the idea, so it's rather you who are the project manager. I'm giving suggestions to how to bring this project any further now. I don't intend to take on any project management role. As you've stated all the time, it's supposed to be a "together project".

Again, the next thing to consider is how to get the function(s) into the program.

If your "we" is really a "we together" you are welcome. But i really wouldnt be angry of you if you would try it  in Mechatronic Extended Basic II Plus... but thats your decision.

In post 400 i set a deadline until 10/27/2019. Those of our forummates who wants to face challenge 1 should stay undisturbed till then. The next challenge comes one day later.

It would be good if we always discuss the actual challenge.

Edited by Sid1968
Link to comment
Share on other sites

I don't think I have Mechatronic Extended BASIC II Plus, so that will not happen. I never went into simulating the 99/4A. If I'm going to use some obsolete computer, it will be the real thing.

And no, it's not good to discuss a project piecemeal. You have to have the full plan first, before you start implementing the parts. Otherwise you risk completing a first part in a way that's awkward for some further step.

  • Like 2
Link to comment
Share on other sites

Mehrere Leute Hier verstehen Deutsch. Einige von uns verstehen auch Spanisch, Niederländisch, Dänisch, Schwedisch, Italienisch, Französisch, Griechisch, Portugiesisch, oder Türkisch. Englisch ist unsere gemeinsame Sprache, aber manche von uns sprechen mehrere von diesen Sprachen. Ich spreche mal Englisch, Deutsch, Französisch, oder Türkisch--aber einige Leute Hier sprechen mehr. . .

  • Like 4
Link to comment
Share on other sites

Finally—Here is the fbForth 2.0 plot of sin(-5) – sin(5) using the SPLIT2 graphics mode (bitmap graphics with a 4-line text window at the top of the screen:

 

sinPlot.thumb.png.4065ff6087a3664477cfef4a1401a31a.png

 

Spoiler

\ sin(-5)..sin(5) on Cartesian axes with 0 at (127,111)
DECIMAL 0 0 0 0 FCONSTANT XSTEP
>F 70 FCONSTANT YMAX \ 70 pixels for sin(x)=1
111 CONSTANT YORG  \ y origin
\ Patterns for ASCII 43..57 for chars {+,-./0123456789)
0 VARIABLE TNUMS   HEX
   DATA[ ( tiny char pattern in left half of full char )
         0000 4040 E040 4000 ( + )
         0000 0000 0000 0000 ( , ) ( using as space )
         0000 0000 E000 0000 ( - )
         0000 0000 0000 0040 ( . )
         0020 2040 4040 8080 ( / ) 
         0040 A0A0 A0A0 A040 ( 0 ) 
         0040 C040 4040 4040 ( 1 )
         0040 A020 4080 80E0 ( 2 ) 
         00C0 2020 C020 20C0 ( 3 ) 
         0020 A0A0 A0E0 2020 ( 4 )
         00E0 80C0 2020 20C0 ( 5 ) 
         0060 8080 C0A0 A040 ( 6 ) 
         00E0 2020 4040 8080 ( 7 )
         0040 A0A0 40A0 A040 ( 8 ) 
         0040 A0A0 6020 20C0 ( 9 )
         ( tiny char pattern in right half of full char )
         0000 0404 0E04 0400 ( + )
         0000 0000 0000 0000 ( , ) ( using as space )
         0000 0000 0E00 0000 (  -)
         0000 0000 0000 0004 (  .)
         0002 0204 0404 0808 (  /)
         0004 0A0A 0A0A 0A04 (  0)
         0004 0C04 0404 0404 (  1)
         0004 0A02 0408 080E (  2)
         000C 0202 0C02 020C (  3)
         0002 0A0A 0A0E 0202 (  4)
         000E 080C 0202 020C (  5)
         0006 0808 0C0A 0A04 (  6)
         000E 0202 0404 0808 (  7)
         0004 0A0A 040A 0A04 (  8)
         0004 0A0A 0602 020C (  9)  
   ]DATA
DROP DROP      \ don't need address, cells
\ calculate address of ASCII 0 for TNL and TNR pattern tables
TNUMS 0156 - CONSTANT TNL
TNUMS 00DE - CONSTANT TNR
DECIMAL
\ working screen char pattern buffer..6 half-chars..24 bytes
0 VARIABLE SCRSEG 22 ALLOT   
\ get 8-byte PDT address of segment
: PDTADR  ( col row -- pdtadr )
   5 SLA +           \ char offset to seg start
   3 SLA PDT +  ;    \ PDT address of seg
\ get 32x24-screen segment of 3 chars (6 half-chars)
: GETSEG  ( col row -- )
   PDTADR            \ PDT address of seg
   SCRSEG 24 VMBR ;  \ get screen segment to RAM buffer
\ put 32x24-screen segment of 3 chars (6 half-chars)
: PUTSEG  ( col row -- )
   PDTADR            \ PDT address of seg
   SCRSEG            \ seg buffer address
   SWAP 24 VMBW ;    \ 64 bytes from seg buffer to PDT
\ OR 8 bytes of chr pat at adr1 with chr pat at adr2
: ORPAT  ( adr1 adr2 -- ) 
   8 0 DO                                         
      OVER OVER               \ dup current addresses
      C@ SWAP C@ OR           \ fetch and OR chrs    
      OVER C!                 \ store result in adr2 
      1+ SWAP 1+ SWAP         \ next chr addresses   
   LOOP
   DROP DROP ;                \ clean up stack
: EVEN?  ( n -- fl ) \ is n even?
   1 AND 0=  ;
\ set up 6-char label with 1-6 chr string
: LABEL  ( col row stradr -- )
   >R OVER OVER      \ save stradr.. dup col row          
   GETSEG                                            
   R> COUNT          \ get chr count and first chr address
   0 DO              \ chr loop                           
      DUP C@         \ dup current chr adr..get chr       
      3 SLA          \ calculate pattern offset `         
      I EVEN?
      IF             \ I is even
         TNL         \ use left-nybble half-char table    
      ELSE           \ I is odd
         TNR         \ use right-nybble half-char table
      THEN
      +              \ chr table address of next chr      
      I 1 SRA 3 SLA  \ offset of next chr pat in SCRSEG   
      SCRSEG +       \ address of next chr pat in SCRSEG  
      ORPAT          \ OR current half-chr to SCRSEG      
      1+             \ next chr                           
   LOOP
   DROP              \ clean up stack
   PUTSEG            \ add label to plot
;

: SINPLOT  ( -x +x -- )
   OVER - S->F >F 250 F/ ' XSTEP F! \ XSTEP=deltay/250
   S->F \ start to FP
   252 2 DO
      FDUP SIN YMAX F* FLOOR F->S \ SIN-->y pixels
      YORG SWAP -    \ y pos to stack
      I SWAP DOT     \ dotcol dotrow DOT
      XSTEP F+       \ adjust x for next go-round
   LOOP  FDROP ;     \ clean up stack
: XAXIS  ( -- )
   0 111 255 111 LINE   \ draw x axis
   256 2 DO
      I 113 I 109 LINE  \ draw next hash mark
   25 +LOOP  ;
: YAXIS  ( -- )
   127 36 127 187 LINE  \ draw y axis
   182 41 DO
      125 I 129 I LINE  \ draw next hash mark
   14 +LOOP  ;

: XLABELS
    0 14 S" -5" LABEL
    3 14 S" -4" LABEL
    6 14 S" ,-3" LABEL
    9 14 S" ,-2" LABEL
   12 14 S" ,-1" LABEL
   16 14 S" ,0" LABEL
   19 14 S" ,1" LABEL
   22 14 S" ,2" LABEL
   25 14 S" ,3" LABEL
   28 14 S" ,4" LABEL
   31 14 S" ,5" LABEL  ;
: YLABELS
   14  4 S" 1.0" LABEL
   14  6 S" 0.8" LABEL
   14  8 S" 0.6" LABEL
   14 10 S" 0.4" LABEL
   14 12 S" 0.2" LABEL
   13 15 S" ,-0.2" LABEL
   13 17 S" ,-0.4" LABEL
   13 18 S" ,-0.6" LABEL
   13 20 S" ,-0.8" LABEL
   13 22 S" ,-1.0" LABEL  ;
   

HEX 
: DOPLOT 
   0 83C4 ! DECIMAL  \ clear ISR hook for sin interference bug
   SPLIT2            \ bitmap graphics with a 4-line text window
   XAXIS YAXIS       \ display Cartesian axes
   XLABELS YLABELS   \ display tiny chr labels
   -5 5 SINPLOT  ;   \ plot sin(-5) to sin(5)

 

 

The text labels use the half-wide characters used for the 64-column editor in TI Forth (inherited by and modified for fbForth). Their display is a little clunky because they are displayed on a 64x24 character grid. This is not too bad horizontally, but the vertical direction suffers from the limited vertical character resolution. It would have been a daunting task to increase row resolution.

 

...lee

 

  • Like 2
  • Thanks 4
Link to comment
Share on other sites

So to me the interesting thing about this submission is that it has a user interface built in.  It's possible to input different plots from the command line or more realistically loaded from disk interactively. 

 

Having a programmable interpreter/compiler is handy.

 

 

 

  • Like 2
Link to comment
Share on other sites

CHALLENGE 1 - THE RESULTS:

 

Ladies and Gentlemen,
the timelimit of the first Challenge expired. Lets look at the task, the participants with their results and rate their work.

 

 

The Task:


(Posts #327)
Draw a cartesian coordinate system with the mathematic function f(x) = sin (x) while x is between -5 and 5.
Post your coding here. This time its not important how fast the program works, but how elegant you solved the challenge and show us the capabilities of your prefered language.

 

(Posts #338)
1. Draw a cartesian coordinate system.
   This task alone is a challenge, because you have to LABEL it in step 1 (integer) like in this example. Thats not easy!
   This labels should be variable, in case that we change the x-range maybe in another challenge. ;-)

 
2. After that you should write a plot program:


    For X= -5 to 5 STEP 0.1
    D = sin (X)
    PLOT D (Here you plot a single DOT)
    NEXT X


As you can see the step of drawing each DOT is 0.1.

 

 


The Participants:

 

TheBF (Forth)(Post #329)
Tursi (TI-Basic)(Post #333)(Post #366)

Asmusr (CORTEX Basic)(Post #339)(Post #379)
senior_flacon (The Miss ing Link)(Post#385)
Lee (fbForth 2.0) (Post #416)

 

 


The Ratingsystem:

 

Every participant can earn up to 5 of 5 frypans for their work.

Additionally every participant can earn a Medal of Honor as an approval for exeptional achievements (Courage, Endurance, Purposefulness).

 

 

 

 

 

        The frypan on bronze badge with fried eggs (Bratpfanne auf Bronzeplakette mit Spiegeleiern).

 

Bratpfanne mit Bronze und Spiegelei.jpg

 

 

        The frypan on silver badge with brats (Bratpfanne auf Silberplakette mit Bratwürsten).

 

Bratpfanne mit Silber und Bratwurst.jpg

      

 

 The frypan on gold badge with steaks and mushrooms (Bratpfanne auf Goldplakette mit Steaks und Pilzen).

 

Bratpfanne mit Gold und Steaks.jpg

 

 

 

 

 

 


 

The Award Ceremony:

 

I like to thank every participant very much, for the courage to face up these challenge.
As it tourned out, the plotting and labeling of a mathematical function was not an easy task.


Here are the Results

 

 

TheBF (Forth)(Post #329)

 

3v5.jpg

 

Bratpfanne mit Silber und Bratwurst.jpg

 

 


Tursi (TI-Basic)(Post #333)(Post #366)

 

5v5.jpg

 

Bratpfanne mit Gold und Steaks.jpg

 

 

 

Asmusr (CORTEX Basic)(Post #339)(Post #379)

 

5v5.jpg

 

Bratpfanne mit Gold und Steaks.jpg

 

 


senior_flacon (The Miss ing Link)(Post#385)

 

4v5.jpg

 

Bratpfanne mit Silber und Bratwurst.jpg

 

 


Lee (fbForth 2.0) (Post #416)

 

5v5.jpg

 

Bratpfanne mit Gold und Steaks.jpg

 

 

 

 

 

 

 

 

You all did a fantastic job!

Iam gratefull to all participants and all who helped in the discussions to make this possible.

A great result of teamwork.

 

Kind Regards
Sid

 

 

 

 

 

 

 

Edited by Sid1968
Link to comment
Share on other sites

CHALLENGE 2:

-----------------

 

This challenge and those who comes build up on the Challenges before.

 

1. Colors:

  

    Background: WHITE

    AXIS: Black

    Function: BLUE

 

2. Integrate a prompt for the X-Range.

 

3. Integrate a prompt for the function.

  

4. Plot the function and the X-Range of Challenge 1.

 

 

The Deadline is 11/10/2019.

 

 

This time the integration of the function prompt will be the difficultiest part.

So lets talk about the solution.

 

Cheers

Sid

 

Edited by Sid1968
Link to comment
Share on other sites

24 minutes ago, Tursi said:

You should probably explain "a prompt for the function". That is so vague it could be anything from taking in a quadratics to "use SIN? Y/N" ;)

 

   The Program should ask:  f(x)=

   Where the user can put in for example: cos(3x) + 3x^2

 

   Then it should ask for the X-Range, and then plot the function.

 

   The user should decide what function in what X-Range should be plotted.

 

Cheers

Sid

Edited by Sid1968
Link to comment
Share on other sites

 

6 hours ago, Sid1968 said:

  The Program should ask:  f(x)=

   Where the user can put in for example: cos(3x) + 3x^2

I think you're going to find that parsing a string like that in a generic fashion is beyond most people's ability. Perhaps you can provide a BASIC example for the parser, and let people build the rest?

 

  • Thanks 1
Link to comment
Share on other sites

I think you would need to parse the expression from infix notation to an internal postfix/stack based representation. And then for each pixel plotted you would need to run an evaluator function on the stack. I wouldn't attempt to do it in BASIC without recursion and proper data structures. It sounds like something Forth might be good at?

  • Thanks 1
Link to comment
Share on other sites

21 hours ago, Sid1968 said:

This time the integration of the function prompt will be the difficultiest part.

So lets talk about the solution.

 

Cheers

Sid

 

Its true, thats not an easy task!

Learning in teamwork is the target.

 

 

I guess that every term that contains an X must get parsed.

 

Example: f(x)= cos(3X)+3*x^2

 

Parsed in: cos(3x) and (3*x^2)

 

So the program should look at where a new x is used and parse that part of the function.

Dont know if thats the solution, i only guess that is it.

 

In the calculations (which are not part of this plotter) the function would get parsed in every expression with an X too.

 

Edited by Sid1968
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...