C64Studio for building more complex projects for Commodore build targets
C64Studio is a .NET based IDE which has some nice macros and dependency linking to connect your BASIC and Assembly files together automatically. Using it with Commodore 128 BASIC and linking the Assembly in add a few extra challenges.
The compile target for the BASIC program needs to have the Assembly file checked as “Dependant” and “Symbols” and that D64 should be the output:
Set up a “Post Build” step on the BASIC file to add the Assembly target to the D64 image $(MediaManager) -d64 "$(BuildTargetFilename)" -import asmloop.prg -renameto "ASMLOOP.PRG". The .asm extension of the file should be changed to .prg for the post build command.
Right-click your main BASIC source file and make it the Active Element
Linking source itself
C64Studio will expose label references in dependencies in BASIC, so for the following Assembly, ASMSTART, HIBYTE, MIDBYTE, LOBYTE are all available (I haven’t tried .loop or .nocarry, but they are intended to be “local labels”)
In the BASIC file these symbols can be used within curly braces:
Make sure to use curly braces and select the proper BASIC for your target Commodore. Since I’m targeting Commodore 128, I’ve selected BASIC V7.0. Basic keywords are compiled to two-byte codes, dependent on the version, so if you select the wrong one, some keywords may be treated as variables or use the wrong keyword code and you’ll get bizarre errors. (I initially got “Compile Errors” on my BASIC with no error message and then “Type Mismatch” on my “compiled” BASIC file.)
Compile and Run
You should be able to click “Compile and Run” now if you’ve set up your emulator in the IDE to point at an installed emulator (VICE GTK has been working for me).
This error is pretty easy to end up with if you have database URL with embedded username and password, although it’s also possible if you’re using basic auth over https.
Example problem URL
Suppose you have a URL such as mysql2://my-user-name:firstname.lastname@example.org:3306/db. The passwordwith.and#and$init will cause an error message:
URI::InvalidURIError (the scheme mysql2 does not accept registry part: my-user-name:passwordwith.and (or bad hostname?))
The above error message ends before the first problematic character (#). These need to be URL encoded (%23 for '#'). mysql2://my-user-name:passwordwith.Eandemail@example.com:3306/db should pass.
Using Ruby to Quickly validate the URLs
The URI::RFC2396_Parser in ruby can provide a quicker way to validate vs. trying to boot an application dependent on the URL:
Traceback (most recent call last):
8: from /Users/tpowell/.rbenv/versions/2.7.2/bin/irb:23:in `<main>'
7: from /Users/tpowell/.rbenv/versions/2.7.2/bin/irb:23:in `load'
6: from /Users/tpowell/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
5: from (irb):12
4: from (irb):13:in `rescue in irb_binding'
3: from /Users/tpowell/.rbenv/versions/2.7.2/lib/ruby/2.7.0/uri/rfc2396_parser.rb:219:in `parse'
2: from /Users/tpowell/.rbenv/versions/2.7.2/lib/ruby/2.7.0/uri/rfc2396_parser.rb:219:in `new'
1: from /Users/tpowell/.rbenv/versions/2.7.2/lib/ruby/2.7.0/uri/generic.rb:208:in `initialize'
URI::InvalidURIError (the scheme mysql2 does not accept registry part: my-user-name:passwordwith%2Eand (or bad hostname?))
=> #<URI::Generic mysql2://my-user-name:passwordwith%2Eandfirstname.lastname@example.org:3306/db>