GeorgRottensteiner / C64Studio

C64Studio is a .NET based IDE specializing in game development for the C64 in assembler and BASIC
Other
252 stars 38 forks source link

BASIC label mode with free naming #67

Open mwedmark opened 2 years ago

mwedmark commented 2 years ago

Thanks for making a great tool!

It would be great if the labelling somehow was the original/reference file, thus making it possible to select any names to any lines. This would make big files more readable and also together with my other suggestion make the whole tool more usable for big BASIC programs.

GeorgRottensteiner commented 2 years ago

I'm not sure I understand correctly. You mean saving the label version as .bas file instead of the line number version?

mwedmark commented 2 years ago

Sorry bad description. Saving with labels already seem possible. I'll rephrase it, make it possible to use any label name, just like in assembler. If there is a problem with parsing, maybe adding a ending char like colon could work.

GeorgRottensteiner commented 2 years ago

Can you please show an example where there's a problem currently, and how the resolved code should look like? I think I understand, but that would make it a lot clearer for me.

mwedmark commented 2 years ago

OK for example my current main file of the Chip8 emulator has 443 lines of code and will become much bigger if I include everything into it. It includes many GOSUB and GOTO statements of course. At one point I changed to LABEL mode but I actually went back. I didn't like the way the labels where named. It actually made keeping track of the code even harder than just a line numbers which is a pity. It would be really nice to be able to name my labels as the function they are suppose to execute.

An example (NOTE: Will be changed to ON GOTO later): 690 IFOX=0THENGOTO860:REM OXXX FAM 700 IFOX=16THENGOTO1010:REM 1XXX FAM 710 IFOX=32THENGOTO930:REM 2XXX FAM 720 IFOX=48THENGOTO1070:REM 3XXX FAM 730 IFOX=64THENGOTO1130:REM 4XXX FAM 740 IFOX=80THENGOTO1190:REM 5XXX FAM 750 IFOX=96THENGOTO1240:REM 6XXX FAM 760 IFOX=112THENGOTO1300:REM 7XXX FAM 770 IFOX=128THENGOTO1360:REM 8XXX FAM 780 IFOX=160THENGOTO1840:REM AXXX FAM 790 IFOX=176THENGOTO1890:REM BXXX FAM 800 IFOX=192THENGOTO2190:REM CXXX FAM 810 IFOX=208THENGOTO2250:REM DXXX FAM 820 IFOX=224THENGOTO2380:REM EXXX FAM 830 IFOX=240THENGOTO2570:REM FXXX FAM

This is the main construct of the opcode-interpreter. Now I use a comment to make it clearer where the GOTO lands. It would be nicer and more readable if it could look like: IFOX=0THENGOTO OXXX_FAM IFOX=16THENGOTO 1XXX_FAM IFOX=32THENGOTO 2XXX_FAM IFOX=48THENGOTO 3XXX_FAM IFOX=64THENGOTO 4XXX_FAM IFOX=80THENGOTO 5XXX_FAM IFOX=96THENGOTO 6XXX_FAM IFOX=112THENGOTO 7XXX_FAM IFOX=128THENGOTO 8XXX_FAM IFOX=160THENGOTO AXXX_FAM IFOX=176THENGOTO BXXX_FAM IFOX=192THENGOTO CXXX_FAM IFOX=208THENGOTO DXXX_FAM IFOX=224THENGOTO EXXX_FAM IFOX=240THENGOTO FXXX_FAM

And when switching between NUMBER and LABEL mode maybe the custom labels could be kept somewhere? Though this would of course be messed up if you started changing lots of stuff in NUMBER mode.. I don't have the exact solution there. If one would like to get advanced maybe a CRC32-checksum of row complete row content and keep that in a separate file for recreation when switching back and forth between NUMBER and LABEL mode. Rows that can't be found is recreated with those default labels.

GeorgRottensteiner commented 2 years ago

Thanks, that helps a lot! I think using meta data with # would be the way to go forward. Have several labels in the followup line separated by comma, for example:

META LABELS,ACTION_MENU

100 PRINT"What now?":INPUTA$

META LABELS,OPEN_DOOR,REDRAW_SCREEN,ACTION_MENU

500 GOSUB 1000:GOSUB 8000:GOTO 100

would map to

ACTION_MENU PRINT"What now?":INPUTA$ ...

GOSUB OPEN_DOOR GOSUB REDRAW_SCREEN GOTO ACTION_MENU

RhinoDevel commented 6 months ago

Would be really nice to have!