Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : NEXT STEP- To start converting all the archive of programs.
Page 1 of 2 | |||||
Author | Message | ||||
mclout999 Guru Joined: 05/07/2020 Location: United StatesPosts: 430 |
Hi, Just got my baby!!! Now I would like to start converting all the old programs For CMM1 and other variants. I got that zip file compilations of code. Can we start this as a discussion on how to do that and maybe wind up with a guide to conversion possibly for inclusion of a section in the manual. I have tried a few apps but think I will have to learn alot about the difference between the versions. When I use the "option legacy on" it does not seem to help much. Is this a useful project? I think it would be good for new users to have a section or tutorial on how to do the translation and maybe along the way, point out how to use the features in the CMM2 to make the programs better. I'm just spitballing here. I may learn a lot by trying to do this. |
||||
capsikin Guru Joined: 30/06/2020 Location: AustraliaPosts: 341 |
Yes I like that idea. Another thing you can do if you don't use option legacy on, is map maximite, to get the colours set like the original colour maximite. For picking a mode, you might want mode 1,2 or 3, so the pixels align properly in an LCD, or you could use mode 4 which matches the size of the older CMM. I think it would be useful to start with shorter or easier programs to work out what needs to change, before working out the bigger ones. |
||||
mclout999 Guru Joined: 05/07/2020 Location: United StatesPosts: 430 |
Sounds good. I will have to read through some of the manuals from the older MMBasics because I am getting loads of crashes and the MMTrek game hangs my CMM2 so have to turn it off to get it back!! Hopefully this thread will gain some traction and we all collectivly find the best guidlines for translations and optimizations. |
||||
capsikin Guru Joined: 30/06/2020 Location: AustraliaPosts: 341 |
Once we get a few example I was thinking of putting them on fruitoftheshed. |
||||
mclout999 Guru Joined: 05/07/2020 Location: United StatesPosts: 430 |
Yes, we should have them add a subfolder called CMM2 Translations. Then we can just all start dumping them in there but make sure in each one you leave comments showing original Syntax and indicate what you did to fix it. Then we have a self-teaching resource for everyone. I am open to suggestions on a consistent format for these change comments, but we should have one. |
||||
capsikin Guru Joined: 30/06/2020 Location: AustraliaPosts: 341 |
I didn't mean the whole programs (though that might be good too) but examples of individual changes needed to convert programs. |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5921 |
Start with something simple. I had to make two changes to this program. I could have used OPTION LEGACY but prefer to make the changes. Pixel(X,Y) = COUNT Mod 8 This sets the pixel to a colour number 0 to 7 The 'new' method is: Pixel X,Y, col(COUNT Mod 8) It sets the colour which is stored in an array col() This array is filled with the (more or less) standard GW Basic colours. 'GW Basic colours DIM col(15) ' GWBasic colours col(0) = RGB( 0, 0, 0) ' black col(1) = RGB( 0, 0, 170) ' blue col(2) = RGB( 0, 170, 0) ' green col(3) = RGB( 0, 153, 153) ' cyan col(4) = RGB( 170, 0, 0) ' red col(5) = RGB( 153, 0, 153) ' magenta col(6) = RGB( 153, 102, 0) ' brown col(7) = RGB( 170, 170, 170)' dull white col(8) = RGB( 85, 85, 85) ' grey col(9) = RGB( 102, 102, 255)' light blue col(10) = RGB(102, 255, 102)' light green col(11) = RGB(102, 255, 255)' light cyan col(12) = RGB(255, 102, 102)' light red col(13) = RGB(255, 102, 255)' light magenta col(14) = RGB(255, 255, 102)' yellow col(15) = RGB(255, 255, 255)' bright white I have that code saved as an INC file to save copy and pasting it in each time. 'JULIA.BAS - Draws Julia set fractal images 'by loki Mode 3 Cls 'GW Basic colours DIM col(15) ' GWBasic colours col(0) = RGB( 0, 0, 0) ' black col(1) = RGB( 0, 0, 170) ' blue col(2) = RGB( 0, 170, 0) ' green col(3) = RGB( 0, 153, 153) ' cyan col(4) = RGB( 170, 0, 0) ' red col(5) = RGB( 153, 0, 153) ' magenta col(6) = RGB( 153, 102, 0) ' brown col(7) = RGB( 170, 170, 170)' dull white col(8) = RGB( 85, 85, 85) ' grey col(9) = RGB( 102, 102, 255)' light blue col(10) = RGB(102, 255, 102)' light green col(11) = RGB(102, 255, 255)' light cyan col(12) = RGB(255, 102, 102)' light red col(13) = RGB(255, 102, 255)' light magenta col(14) = RGB(255, 255, 102)' yellow col(15) = RGB(255, 255, 255)' bright white 'Specify initial values RealOffset = -1.30 ImaginOffset = -1.22 '------------------------------------------------* 'Set the Julia set constant [eg C = -1.2 + 0.8i] CRealVal = -0.78 CImagVal = -0.20 '------------------------------------------------* MAXIT=80 'max iterations PixelWidth = MM.HRes PixelHeight = MM.VRes GAP = PixelHeight / PixelWidth SIZE = 2.50 XDelta = SIZE / PixelWidth YDelta = (SIZE * GAP) / PixelHeight 'Loop processing - visit every pixel For X = 0 To (PixelWidth - 1) CX = X * Xdelta + RealOffset For Y = 0 To (PixelHeight - 1) CY = Y * YDelta + ImaginOffset Zr = CX Zi = CY COUNT = 0 'Begin Iteration loop Do While (( COUNT <= MAXIT ) And (( Zr * Zr + Zi * Zi ) < 4 )) new_Zr = Zr * Zr - Zi * Zi + CRealVal new_Zi = 2 * Zr * Zi + CImagVal Zr = new_Zr Zi = new_Zi COUNT = COUNT + 1 Loop 'Pixel(X,Y) = COUNT Mod 8 ' CMM1 method Pixel X,Y, col(COUNT Mod 8) Next Y Next X Do a$ = Inkey$ Loop While a$ = "" No other changes were required in this case. Jim VK7JH MMedit  MMBasic Help |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8601 |
The biggest issue with many of these old programs is the re-use of variables with different types. e.g. A and A$ Modern versions of MMBasic (V5 onwards) don't allow this so that is the first thing to fix. |
||||
mclout999 Guru Joined: 05/07/2020 Location: United StatesPosts: 430 |
Modern versions of MMBasic (V5 onwards) don't allow this so that is the first thing to fix. That makes sense as I keep getting errors saying variable already used or somthing like that. This is the kind if insight I wanted this thread to bring out. This could be in the first section on translating programs. |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8601 |
Page 43 of the user manual |
||||
capsikin Guru Joined: 30/06/2020 Location: AustraliaPosts: 341 |
I've started the page at http://fruitoftheshed.com/Colour%20MaxiMite%202%20(CMM2).Converting-older-MMBASIC-programs.ashx Others are welcome to add to it. I haven't really put up example code yet, beyond syntax. We can link examples on separate pages and/or make them file uploads (though I haven't tried the file uploads myself yet), if they don't fit on the single wiki page. |
||||
mclout999 Guru Joined: 05/07/2020 Location: United StatesPosts: 430 |
Page 43 of the user manual I have read the thing a few times but it just does not go into am much detail as I need and show more example code. I still think this thread will be a very practical exercise in the best ways to do the porting as the manual is very terse with few examples that this thread can provide. I just reread it and it points out the issues but I am going to need some fleshing out of how to deal with these differences a have some practical examples. |
||||
Atomizer_Zero Senior Member Joined: 04/07/2020 Location: United KingdomPosts: 134 |
This is a great idea. I think overall, we could do with a resource of example code on doing various things. like, for example, I had an issue where I was doing this DIM INTEGER VALUE = 0 DIM ANARRAY(63,3) AS INTEGER FOR VALUE = 0 TO 63 VALUEINPUT(VALUE) NEXT VALUE FUNCTION VALUEINPUT(VALUE) LOCAL INTEGER INDEX = (VALUE/4) AND &HFFFF LOCAL INTEGER TEMPVALUE SELECT CASE (VALUE MOD 4) CASE 0: TEMPVALUE = ANARRAY(INDEX,0) CASE 1: TEMPVALUE = ANARRAY(INDEX,1) CASE 2: TEMPVALUE = ANARRAY(INDEX,2) CASE 3: TEMPVALUE = ANARRAY(INDEX,3) END SELECT VALUEINPUT = TEMPVALUE END FUNCTION the problem with this code is that, when it got to INDEX = 63, it was erroring out with "Error Index out of Dimension" The reason for this is because it was treating INDEX as a float. the fix (pun unintended.. you'll see why).. is to use use "FIX(VALUE / MOD) AND &HFFFF". The function worked as intended then. I'm sure there's probably other ways of achieving the same thing, but this is what I did. Edited 2020-07-31 01:25 by Atomizer_Zero |
||||
lizby Guru Joined: 17/05/2016 Location: United StatesPosts: 3027 |
The reason for this is because it was treating INDEX as a float. the fix (pun unintended.. you'll see why).. is to use use "FIX(VALUE / MOD) AND &HFFFF". The function worked as intended then. I'm sure there's probably other ways of achieving the same thing, but this is what I did. as per another recent thread: FUNCTION VALUEINPUT(VALUE as integer) as integer PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8601 |
Also if you want integer division use \ not / (VALUE/4) gives a float as all divides convert to float as per the manual page bottom page 22 |
||||
Atomizer_Zero Senior Member Joined: 04/07/2020 Location: United KingdomPosts: 134 |
Learning everyday. Half the fun of this is finding this stuff out. Thanks for your assistance lizby and matherp. Is using a \ faster than fix() ? I would assume yes. |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8601 |
Probably slightly Personally, my approach is to start all programs with OPTION EXPLICIT and then either OPTION DEFAULT INTEGER or OPTION DEFAULT NONE. Unless you are doing math there is no advantage and lots of disadvantages to using floats especially when bit twiddling |
||||
Atomizer_Zero Senior Member Joined: 04/07/2020 Location: United KingdomPosts: 134 |
Thing about that is, I am using both those options. It was still treating the division as a float. EDIT: Correction , I wasn't using OPTION EXPLICIT afterall. I thought I was... hmm. That's a mistake on my end. Edited 2020-07-31 02:08 by Atomizer_Zero |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8601 |
yes, that is the way Geoff designed it - just use the integer divide "\" to avoid the problem |
||||
capsikin Guru Joined: 30/06/2020 Location: AustraliaPosts: 341 |
Modern versions of MMBasic (V5 onwards) don't allow this so that is the first thing to fix. That makes sense as I keep getting errors saying variable already used or somthing like that. This is the kind if insight I wanted this thread to bring out. This could be in the first section on translating programs. This is what I've put so far on the wiki: Different variable names by type Many old programs re-use variables with different types. e.g. A and A$. Modern versions of MMBasic (V5 onwards) don't allow this so that is the first thing to fix. e.g they could be A and AStr$ instead. Old: DIM A DIM A$ A=1.6 A$="Hello" PRINT A$ New: DIM A DIM AStr$ A=1.6 AStr$="Hello" PRINT AStr$ Edited 2020-07-31 11:06 by capsikin |
||||
Page 1 of 2 |
Print this page |