Getting C64Studio to work with C128 BASIC and Assembly

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.

Starting with a template

Sample Project 14 – BASIC and Assembly has most of the settings you need to get going. The keys to this setup

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:

C64Studio setting the Compile Target properties on a BASIC file.
Check “Dependant” and “Symbols”

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.

Post Build step on the BASIC file to add the Assembly file.
$(MediaManager) -d64 "$(BuildTargetFilename)" -import asmloop.prg -renameto "ASMLOOP.PRG"

Right-click your main BASIC source file and make it the Active Element

Active element should be bold after right-clicking and selecting “Set as 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”)

;startup address
  * = $0c00
;create BASIC startup
ASMSTART
  ldx #$00
  ldy #$00
  lda #$00
  sta $a0
  sta $a1
  sta $a2
  sta LOBYTE
  sta LOBYTE
  lda #$60
.loop
  inx
  bne .nocarry
  iny
  bne .nocarry
  inc HIBYTE
.nocarry
  cmp $a2
  bcs .loop
  stx LOBYTE
  sty MIDBYTE
  rts
HIBYTE
  !byte $00
MIDBYTE
  !byte $00
LOBYTE
  !byte $00

In the BASIC file these symbols can be used within curly braces:

BASIC code referencing Assembly labels/symbols
.

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).

URI::InvalidURIError : The scheme mysql2 does not accept the registry part

How you can end up with the URI::InvalidURIError

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:passwordwith.and#and$init@mymacbook.local: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?))

Solution

The above error message ends before the first problematic character (#). These need to be URL encoded (%23 for '#'). mysql2://my-user-name:passwordwith.Eand%23and$init@mymacbook.local: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:

irb(main):013:0> URI::RFC2396_Parser.new.parse('mysql2://my-user-name:passwordwith%2Eand#a
nd$init@mymacbook.local:3306/db')
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?))
irb(main):014:0> URI::RFC2396_Parser.new.parse('mysql2://my-user-name:passwordwith%2Eand%2
3and$init@mymacbook.local:3306/db')
=> #<URI::Generic mysql2://my-user-name:passwordwith%2Eand%23and$init@mymacbook.local:3306/db>