Jump to content

TheBF

+AtariAge Subscriber
  • Content Count

    3,166
  • Joined

  • Last visited

Everything posted by TheBF

  1. Latest additions to CAMEL99 Forth on GitHub: Just in case anybody cares... https://github.com/bfox9900/CAMEL99 To /DEMO added: PONG.FTH simple PONG game QUICKSORT.FTH recursive quicksort integer demo. (about 2..3X faster than COMBSORT) DUTCHFLAG7.FTH on screen combsort demo with multiple inputs To /LIB added: 80COL.FTH for F18A hardware or emulators that support it ASM9900.FTH TMS9900 RPN assembler that loads above the dictionary ATTYPE.FTH 10X faster type to screen location with error checking BOOLEAN.FTH to create BIT arrays. Slower but space efficient. DATABYTE.FTH changed to be more like TI-Assembler syntax DEFER99.FTH Forth 2012 deferred words and support words FASTCASE.FTH creates VECTOR tables easily. (Like "ON GOSUB" for BASIC programmers) MARKER.FTH ANS Forth MARKER word. UDOTR.FTH print un-signed right justified numbers VALUES.FTH create ANS Forth VALUE type TINYHEAP.FTH fixes to ANS Forth ALLOCATE implementation in TI Low-mem
  2. We shouldn't leave out both guys who use Pascal. Pascal The compiler won't let you shoot yourself in the foot. The gun is mounted such that it cannot point towards your feet, but you can swivel it round and shoot yourself in the head instead.
  3. Went down the rabbit hole playing with this combsort and the Dutch Flag Problem. https://en.wikipedia.org/wiki/Dutch_national_flag_problem (no, there is no problem with the Dutch flag) This is not an optimal way to solve it, but it makes an interesting way to view how the sort works. The sort is using the screen memory as an array of data and sorting in place. There are 4 different scenarios. (I apologize that the screen fillers are not all perfect.) I did a version with sprites pointing to where the sort is comparing, but it was too fast and not very helpful.
  4. And then I found this photo... Thanks for all your help in this forum Lee. Brian
  5. Cool! It's much handier than using a stop-watch.
  6. Looking at it again I saw another bug for ANS Forth only. : ELAPSE ( -- <forth words> ) 1 PARSE TICKER OFF EVALUATE .ELAPSED ; I had used BL PARSE, which of course parsed a space delimited word in the input. 1 PARSE will never find a delimiter and so will take in an entire line of text. You help me find bugs without even looking at them. You're a wizard. B
  7. Well done. Yes it does make a difference. I ran this code on FB-Forth and CAMEL99 and they go out of sync pretty quickly. : TEST ( start end -- ) SWAP DO CR I U. SPACE I 5 6 */ U. SPACE I 83 100 */ U. LOOP ; Thanks. I will fix it in the original post. B
  8. I will have to play with the 1/2 value to see what happens. I remember in the Byte Magazine article where I found this sort, they showed a graph where these two guys experimented with gap size s and found this magic 1.3 value. There was a switch as you say when the GAP got below a certain size that they claimed was better but my tests didn't give me an speedup because testing for the condition took more time. So your name needs to go up there in Wikipedia as one of the independent discoverers of this algorithm.
  9. Adding Elapsed Time Timer When you are trying to find out if one way to code something is faster than another method this little tool is soooo handy. The code uses the fact that the TI-99 is running a countdown timer for the screen timeout at address >83D6. Each tick of this timer is .008333 seconds so it will run for about 9 minutes. That is the maximum time we can measure with this method. The first time I saw this word ELAPSE was in FPC Forth by Tom Zimmer. I have moved it to other Forth systems since then. The video shows ELAPSE in action. \ ELAPSE.FTH elapsed time measurment words \ Thanks to Tom Zimmer for the good ideas in FPC circa 1990 \ Ported to HsForth 08MAR91 Brian Fox Canada \ Ported to CAMEL99 Nov 29 2017 \ Good for 9 minutes maximum duration \ *** YOU CANNOT CALL KSCAN WHILE TIMING *** HEX 83D6 CONSTANT TICKER \ screen timeout counter increments by 2 /16mS DECIMAL : ## ( n -- ) 0 <# # # #> TYPE ; : .MINS ( h S M -- ) BASE @ >R DECIMAL ## [CHAR] : EMIT ## [CHAR] . EMIT ## R> BASE ! ; \ 1 TICK = .008333 mS : REALTIME ( -- n ) TICKER @ 5 6 */ ; \ changed to 5/6 ratio from input by Lee Stewart. Better now : >TIME ( n -- .hh secs mins ) \ convert n to time 6000 /MOD ( -- rem mins) >R \ push minutes 100 /MOD ( -- ms secs) \ calculate seconds & hundredths R> ; \ pop minutes : .ELAPSED ( -- ) CR ." Elapsed time =" REALTIME >TIME .MINS ; : ELAPSE ( -- <forth words> ) 1 PARSE \ BF edit to allow timing a line of code TICKER OFF EVALUATE .ELAPSED ; ELAPSEDEMO.mp4
  10. Do you still have any code lying around? It sounds then like you made the comb sort independently with a 1/2 GAP which works but may be just slightly sub-optimal compared to 1/1.3 Pretty cool work by you.
  11. I think you found a similar mechanism independently, but with a different GAP ratio. There is another sort called Shell-Metzner or Shellsort that is described here: https://en.wikipedia.org/wiki/Shellsort I think you might have done that. The Combsort is a strange variation that changes the GAP by this magic ratio and it just works well. https://en.wikipedia.org/wiki/Comb_sort I didn't realize until I read the Wikipedia on Shellsort that it is "fair game" to use different GAPs, even using a list of GAPs. All that to say I think you discovered Shellsort. B
  12. Did you discover the 1.3 gap ratio independently?
  13. My wife's family is from Brabant, a couple small villages. The part of Canada that I live in had thousands of people come here after the war. The land is flat😄
  14. Hi Fred, I just realized that you might be in Belgium. My apologies if I got it wrong. BF
  15. *New and Improved* 80 Columns to Camel99 Forth It didn't sit well with me that I could not change screen modes freely. After I played around I found out that if I reset to TEXT mode, I could jump to a 80cols or GRAPHICS mode with no problem. It takes just a few milli-seconds longer but you can jump from 80cols to GRAPHICS and back. Classic99 does not seem to be able to record the 80COLS screens so you will have to load this code yourself for proof that it works. Here is the new code: -EDIT- Added count bytes to the data strings which saves a few bytes in the definitions \ 80 column mode for F18A video card (tested on Classic99) \ Register DATA taken from Turbo Forth by Mark Wills ( default colors changed to green on black screen) HEX CREATE 40COL 08 C, 00 C, F0 C, 00 C, 0E C, 01 C, 06 C, 02 C, 20 C, CREATE 80COL 15 C, 04 C, 70 C, 03 C, E8 C, 01 C, 06 C, 00 C, 20 C, 88 C, 00 C, 00 C, 00 C, 94 C, 10 C, 00 C, : VREGS ( addr n -- ) 0 DO DUP I + [email protected] I VWTR LOOP DROP ; DECIMAL \ we have to over-write the old versions to handle 80cols : TEXT ( -- ) 40COL COUNT VREGS TEXT ; : COLD ( -- ) TEXT COLD ; : TINT ( fg bg -- ) SWAP 4 LSHIFT + 7 VWTR ; : 80COLS ( -- ) TEXT 80COL COUNT VREGS 80 C/L! PAGE 80 VMODE ! ; : GRAPHICS ( -- ) TEXT GRAPHICS ;
  16. Adding 80 Columns to Camel99 Forth Finally got around to adding this functionality for the F18A. Thanks to Willsy for the register data. You can only toggle between 40 column and 80 column after this code is loaded. GRAPHICS will just give you a warning. Added the simple word TINT so you can change text and screen color. (uses machine values for colors to keep it simply) \ 80 column mode for F18A video card (tested on Classic99) \ Register DATA taken from Turbo Forth by Mark Wills ( default colors changed to green on black screen) HEX CREATE 40COL 00 C, F0 C, 00 C, 0E C, 01 C, 06 C, 02 C, 20 C, CREATE 80COL 04 C, 70 C, 03 C, E8 C, 01 C, 06 C, 00 C, 20 C, 88 C, 00 C, 00 C, 00 C, 94 C, 10 C, 00 C, : VREGS ( addr n -- ) 0 DO DUP I + [email protected] I VWTR LOOP DROP ; DECIMAL : 80COLS ( -- ) 80COL 15 VREGS 80 C/L! PAGE 80 VMODE ! ; \ we have to over-write the old versions to handle 80cols : TEXT ( -- ) 40COL 8 VREGS TEXT ; : COLD ( -- ) TEXT COLD ; : TINT ( fg bg -- ) SWAP 4 LSHIFT + 7 VWTR ; : GRAPHICS ( -- ) -1 ABORT" Needs restart" ;
  17. Hey JediMatt, I finally got around to seeing if I could compile HYPE and it requires the WORD-LIST wordset from Forth 94. I have not finished implementing that yet so no go. But it is a pretty small and effective OOP implementation for sure. Much smarter minds than mind created that one. Thanks again.
  18. Ja zeker. Groeten aan Nederland. :-)
  19. Thanks Lee. This is wonderful to have. Yes I noticed that your code talks to the chip and uses some of the same code as Turbo Forth too. I am swimming upstream here maybe but it's fun to try and craft these things in Forth to see what can be done. Thanks again for the listing. Will post what I find. B
  20. Yup. I am sure it works. I just can't understand why, when I do the equivalent things with Forth that I see in Assembler in the book, it doesn't play the list. I even made some little routines in the kernel to start and stop interrupts like in the assembler code. I will have to study Lee's code more closely. It's funny cuz I made the TMS9919 direct sound driver very quickly. :-) I notice that the assembler code is in a loop. Perhaps I am only running the first string of bytes?
  21. Forgot to mention that the way it should work is you pass the sound table to ISRPLAY as an argument. PACMAN ISRPLAY <enter>
×
×
  • Create New...