English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 07 August 2018, 21:47   #1
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,539
Visual Studio Code Blitz Basic extension

Visual Studio Code is a light weight, open source IDE for Windows, Mac and Linux. I've started work on a custom extension for Blitz Basic. There's not a lot to it so far - basically just some code highlighting, I'd really like to work out how to add some intellisense or error checking to it.

I'm not that familiar with either textmate or regex so I don't claim it's well made by any means, and I'll accept pull requests if someone wants to improve on it.



Instructions:
  1. Download or clone from https://github.com/earok/VSCBlitzBasic to
    "%USERPROFILE%\.vscode\extensions\VSCBlitzBasic" on Windows, "$HOME/.vscode/extensions/VSCBlitzBasic" on Mac/Linux
  2. (Re)open visual studio
  3. If it's in the right place, any .bb or .bb2 files should be highlighted per the screenshot, and it'll say Blitz Basic in the corner.
  4. Make sure any files you create with it have "LF" line endings (again, in the corner, it's easy to switch between them)
  5. This goes without saying, but you still need an Amiga environment to compile it. My standard setup is to load WinUAE, trigger a script that makes a copy of my code (that I can save on top of to keep the Blitz Basic settings, without tokenisation messing up the original) and opens it in Blitz Basic.
earok is offline  
Old 08 August 2018, 00:52   #2
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,539


I've started on Intellisense, in a somewhat hacky way - using the "snippets" functionality. With this we can autofill with the required and optional parameters, as well as display text from the manual (albeit with broken linewraps).

While you can't just hover over a command to see all the details, you can see all the details of any command just by starting to type it in - or at least, once I've implemented every single command, thus far only the commands in the "Program Flow" section of the manual are there.

When it's done, this should be pretty useful - I can hardly ever remember the syntax for InitCopList! - but it's probably going to take me a month or more to go through it.


Edit: Done a few more check-ins, there's now 80 commands represented in autofill. In a couple of places, I've attempted to have useful autofill. Eg, if you want to target CD32 pads, type in "gameb", press tab and you'll get:

Code:
CD32_Buttons = GameB(Port)
CD32_Play = CD32_Buttons & 1 = 1
CD32_Reverse = CD32_Buttons & 2 = 2
CD32_Forward = CD32_Buttons & 4 = 4
CD32_Green = CD32_Buttons & 8 = 8
CD32_Yellow = CD32_Buttons & 16 = 16
CD32_Red = CD32_Buttons & 32 = 32
CD32_Blue = CD32_Buttons & 64 = 64
So you don't need to refer back to the manual to check which bitflags belong to which buttons.

Last edited by earok; 08 August 2018 at 11:33.
earok is offline  
Old 08 August 2018, 15:38   #3
MickGyver
Registered User
 
MickGyver's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 643
Very nice earok! I have to try this out!
MickGyver is offline  
Old 09 August 2018, 06:19   #4
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,539
Quote:
Originally Posted by MickGyver View Post
Very nice earok! I have to try this out!
Thanks mate!


Progress goes on with the Intellisense stuff. Reference sections 1-4 are done (20% of the total commands - eg 100 out of about 500!).

HUGE thanks to Darren Chapman for whipping up a text parser to convert the commands in the manual to snippets - it'll make it much faster for bringing the rest of the text across. It should hopefully be all done in a day or two rather than a month!
earok is offline  
Old 09 August 2018, 10:31   #5
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
Great stuff

Is it possible to make use of MickGyver's work with notepad++ to integrate a compilation option via winuae/arexx?
E-Penguin is offline  
Old 09 August 2018, 12:05   #6
MickGyver
Registered User
 
MickGyver's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 643
Quote:
Originally Posted by E-Penguin View Post
Great stuff

Is it possible to make use of MickGyver's work with notepad++ to integrate a compilation option via winuae/arexx?
I guess that should be possible, VS Code is very capable. I recently improved my workflow so I just have a 'run.bat' file in every project folder, then in Notepad++ I press CTRL+F5 to directly execute run.bat in the folder of the source file being edited. The batch file takes a copy of the source file and at the same time converts line breaks from CRLF to LF.

Just let me know if I can help with this. The tools and instructions are available in this thread.
MickGyver is offline  
Old 09 August 2018, 12:12   #7
MickGyver
Registered User
 
MickGyver's Avatar
 
Join Date: Oct 2008
Location: Finland
Posts: 643
Also, it would be very nice to be able to use the code outline view in VS Code:

https://code.visualstudio.com/update...#_outline-view

Did you look into this already @earok? Not trying to stress you or anything.

I made a function list for my Notepad++ extension (RegEx) but I'm not sure how it's done in VS Code.
MickGyver is offline  
Old 09 August 2018, 12:37   #8
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,539
Quote:
Originally Posted by MickGyver View Post
Also, it would be very nice to be able to use the code outline view in VS Code:

https://code.visualstudio.com/update...#_outline-view

Did you look into this already @earok? Not trying to stress you or anything.

I made a function list for my Notepad++ extension (RegEx) but I'm not sure how it's done in VS Code.
Eeep.

I'm not quite at that level yet! I could maybe look at that in future. What I was hoping to solve next is code formatting (so you can press SHIFT+ALT+F and have all of the scopes properly tab indented)

There's two main components to what I've done so far. The first is just syntax highlighting, using Visual Studio Codes' standard colors and definitions. For example, this is in the .tmLanguage file

Code:
{
	"name": "keyword.control.operator.blitzbasic",
	"match" : "(?i)\\b(not|bitset|bitclr|bitchg|bittst|lsl|asl|lsr|asr|and|or)\\b"
},
Which simply finds and highlights those operators.

The second part is the "snippets" functionality, which is meant to be used for simple code shortcuts but in practice I find it useful as an intellisense alternative. For example:

Code:
"ReadFile": {
	"prefix": "ReadFile",
	"body": [
		"if ReadFile(File#,Filename$)",
		"\t;Do your file handling here.",
		"\tCloseFile File#",
		"else",
		"\t;The file was not successfully opened. Do your error handling here.",
		"endif"
	],
	"description": "ReadFile opens an already existing file specified by Filename$ for sequential reading. If the specified file was successfully opened, ReadFile will return true (-1), otherwise ReadFile will return false (0). Once a file is open using ReadFile, FileInput may be used to read information from it."
},
  • The root name is simply a unique identifier.
  • If you start typing in the prefix, you'll see this as an option in a list.
  • If you press tab with this option highlighted, the body will be filled out (for readfile I thought it might be useful to have a sensible default template, for example, but for almost all of the other commands it simply fills out the command with placeholder parameters).
  • Finally, description shows if you start typing it in and select it from the list. Just a quick manual reference.

The project is open source and I'm happy to accept pull requests, such as WinUAE/ARREX integration if possible OR, I should be able to add others to have full write access to the repo if required?
earok is offline  
Old 09 August 2018, 12:58   #9
AChristian
Registered User
 
Join Date: Aug 2018
Location: england
Posts: 24
when editing on a modern pc does the blitz code get compiled on the pc and turned into an amiga binary file, or does the blitz code get inserted into the amiga compiler?
AChristian is offline  
Old 09 August 2018, 13:05   #10
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,539
Quote:
Originally Posted by AChristian View Post
when editing on a modern pc does the blitz code get compiled on the pc and turned into an amiga binary file, or does the blitz code get inserted into the amiga compiler?
There's currently no way to compile Blitz Basic from a purely PC environment - solutions such as this require WinUAE running the original Blitz Basic compiler to compile the code.
earok is offline  
Old 09 August 2018, 17:00   #11
AChristian
Registered User
 
Join Date: Aug 2018
Location: england
Posts: 24
Quote:
Originally Posted by earok View Post
There's currently no way to compile Blitz Basic from a purely PC environment - solutions such as this require WinUAE running the original Blitz Basic compiler to compile the code.
thanks
AChristian is offline  
Old 09 August 2018, 22:38   #12
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
I wonder whether one could use something like AWS to remotely start a virtual machine running winuae, compile the software and save it back to the local computer. I'll investigate...
E-Penguin is offline  
Old 10 August 2018, 11:46   #13
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,539
I'm done on the project for now - I've finished transferring nearly 550 commands to the intellisense snippets (there's likely to be a few missing commands here and there, and I KNOW that there's AREXX, BREXX and Serial Port commands missing - anyone's welcome to add anything that I've missed).

Next month I'll look at adding intellisense for either library commands or 68K instructions.

Definitely very interested to see if anyone comes up with some form of WinUAE integration
earok is offline  
Old 10 August 2018, 11:59   #14
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
Quote:
Originally Posted by E-Penguin View Post
I wonder whether one could use something like AWS to remotely start a virtual machine running winuae, compile the software and save it back to the local computer. I'll investigate...
I did many years ago some kind of headless WinUAE mode that boots to remote shell (via telnet I think) with current directory as boot drive. Perhaps it would be useful in this situation? (it most likely isn't working anymore or was not fully implemented)
Toni Wilen is offline  
Old 11 August 2018, 11:26   #15
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,539
I have a partial solution for building through Visual Studio Code! It's not perfect (yet) but I've found it fairly useful.

On the Visual Studio end -
  1. Create a .vscode folder in your Blitz project directory (subfolder of your root)
  2. Create a tasks.json file inside that with something along the lines of the following:
    Code:
    {
        // See https://go.microsoft.com/fwlink/?LinkId=733558
        // for the documentation about the tasks.json format
        "version": "2.0.0",
        "tasks": [
            {
                "label": "build",
                "type": "shell",
                "command": "./build.bat",
                "group": {
                    "kind": "build",
                    "isDefault": true
                }
            }
        ]
    }
  3. Now you need a build.bat file that opens a WinUAE configuration. In the batch, CD to the WinUAE directory and run
    Code:
    WinUAE.exe -config=MyConfig.UAE -G
  4. Press Ctrl+Shift + B (or Tasks->Run Build Task) to run it

On the WinUAE end, I have a configuration like so:
- DH0 points to a folder that has the Blitz Install, and has a Startup-Sequence that tells it to go to DH1 and run "execute make"
- DH1 has the blitz project itself, and make is a script that makes a copy of the source (so that we don't tokenise the original source), and opens that copy in Blitz.

To be clear - the DH0 folder is shared between all of my Blitz projects, DH1 is different for each project.

There are at least two issues that prevent this from being a fully complete build process:

1. Blitz still requires manual mouse intervention to compile (MickGyver, you solved this through AREXX or the like..?)
2. WinUAE still needs to be manually closed afterwards (Toni, I take it there's no way to tell WinUAE to quit from inside the emulated Amiga environment..?)
earok is offline  
Old 11 August 2018, 11:38   #16
Daedalus
Registered User
 
Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,334
Quote:
Originally Posted by earok View Post
1. Blitz still requires manual mouse intervention to compile (MickGyver, you solved this through AREXX or the like..?)
Early versions of the Blitz editor don't have an ARexx port. However, Blitz itself has a "BRexx" library that basically fakes Intuition inputs, so it should be possible to write a simple program to do whatever you need.
Daedalus is offline  
Old 11 August 2018, 12:06   #17
E-Penguin
Banana
 
E-Penguin's Avatar
 
Join Date: Jul 2016
Location: Darmstadt
Posts: 1,213
You mean, use blitz to automate blitz? That's brilliantly recursive
E-Penguin is offline  
Old 12 August 2018, 01:37   #18
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 4,332
Just use ARexx. It's super-easy. http://eab.abime.net/showthread.php?t=77610
idrougge is offline  
Old 12 August 2018, 03:07   #19
earok
Registered User
 
Join Date: Dec 2013
Location: Auckland
Posts: 3,539
Hey, that's pretty cool. So, I've got my execute script to include

Code:
run blitz2:blitz2
SYS:REXXC/waitForPort TED_REXX1
SYS:REXXC/rx "address TED_REXX1; SHOWSCREEN"
SYS:REXXC/rx "address TED_REXX1; ACTIVATE"
SYS:REXXC/rx "address TED_REXX1; LOADNEW 'build.bb'"
SYS:REXXC/rx "address TED_REXX1; COMPILE 'build.bb'"
Which runs the game! So I can test the game with the CTRL+SHIFT+B shortcut combination with visual studio code. (To be clear, "Blitz2" here is superted, not ted)

However, some odd quirks - when I quit the game, I still have the "Okee Dokee" and "!PANIC!" windows open, and I can't seem to dismiss them?
earok is offline  
Old 12 August 2018, 12:06   #20
carrion
Registered User
 
carrion's Avatar
 
Join Date: Dec 2016
Location: Warsaw area
Posts: 152
@earok
thanks for your work. I will use it with VSCode on my Mac It even kinda works now but I still have one issue. After the SuperTED start I can't get rid of the welcome splash window with OKEE DOKEE buton and thus the TED can't load the file. Is there a way to get rid of this window automatically so the file loads?

I also don't quite understand how to deal with ascii files and the .xtra config files so I don't have to change number of SHAPES for example in the compiler config.
carrion is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Amiga Assembly extension for Visual Studio Code prb28 Coders. Asm / Hardware 342 15 December 2023 21:22
Blitz Basic 2 source code Retro1234 Coders. Blitz Basic 8 25 May 2016 05:07
very basic C/ASM/Visual Studio hand holding Sephnroth Coders. C/C++ 2 08 March 2016 20:15
Somebody teach me to code in Blitz Basic, please!!! Toni Galvez Coders. Blitz Basic 18 21 May 2015 00:03
3D code and/or internet code for Blitz Basic 2.1 EdzUp Retrogaming General Discussion 0 10 February 2002 11:40

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 03:27.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.11897 seconds with 15 queries