Jump to content
IGNORED

Modern tool chain for 8bit development


Recommended Posts

Awesome, thanks!

And if I may ask for one more thing: Would it be possible to add a configuration where the most recently edited file would be built/run with DEBUG options? In that case, I could just put a number of .asm files that I'm working on in one folder, and whichever is edited/saved most recently will be run with Altirra?

Link to comment
Share on other sites

A new version (1.9.0) of the VSCode extension has been published.

The biggest change is the more customizable build process.

There are now various options available to those who want to use them.

1. The default is still the creation of the atasm-build.json file. This will build the specified file with all the command line options applied.

2. You can turn off the forced config file creation and use various other options.

The sequence of finding the file to assemble is now:

- Look at the Default Asm File to Assemble setting.  If set then this is the file that will be assembled.

- If that is not set then the current editor tab is checked if its an assembler file.  If it is then that is assembled. You can turn that off with the 'Assemble Current Asm File' option

- If you don't have a default and the current editor is not an assembler file or that option it turned off then the alphabetical first assembler file or the last modified one are assembled.

  The order is set by the Find First File By option.

 

Lots of options are available.

 

I would use a build config file so that I can include search paths and parameters but I would edit the JSON file and clear the input setting.

In this case we combine both worlds.  Use the build parameters but use the search rules to find the file to assemble.

My favorite here is to assemble the current editor file

 

 

  • Like 2
Link to comment
Share on other sites

Ok, some interesting findings about wine and pathnames in command line arguments: Wine requires backslashes instead of slashes, even on Unix-like systems such as Linux and MacOS. So it was probably not Altirra's problem that I had to do all this scripting on the previous page in order to change to the output directory and then call Altirra just with the filename.xex only, it seems to be a wine thing. Because if I call Altirra with a filename including the full path, but have the slashes converted to (simple, single) backslashes, it works perfectly fine also with any kind of filename with a preceding full path.

 

@RetroCoder: Since the default output is the "out" directory underneath the code directory (which is great and should stay that way), the question is whether you could detect what kind of system your extension runs on, and if it is a non-Windows system, replace all instances of a forward slash (as a path delimiter) with a backslash (as it would be on Windows)? So that "out/WozMon.asm" becomes "out\Wozmon.asm"?

If so, then my whole workaround with the altirra.sh script above would no longer be necessary and everything could be just configured via your extension's settings, which would be much more transparent.

 

If not, I'd have to find a way how to replace all slashes inside the $@ array of command line arguments. That is unfortunately not as easy as in Perl, for example, but would probably be somehow doable. But as I said, if you could do this already on the level of the extension, it would be much easier for everyone...

  • Like 1
Link to comment
Share on other sites

Posted (edited)

I managed to find a solution using the shell, so my altirra.sh now looks like this:

#!/bin/bash
filename="${3//\//\\}"
set -- "${@:1:2}" "$filename" "${@:4}"
WINEDEBUG=-all /opt/homebrew/bin/wine64 ~/Downloads/Altirra-4.01/Altirra64.exe $@

So there's no need for you to make any further changes, because I was wrong in assuming that not every Altirra option could be configured via the extension – all the options are in fact coming from the extension (such as /pal). The only thing where my script would have to be adjusted is if the filename is not on third position, currently for me it's

/pal /run "out/WozMon.xex" /singleinstance
I don't know if this can change or if it would be easier to always put the /run "..." at the very beginning, then the filename would always be on position 2.
This would be the only benefit to do the slash-conversion on the level of the extension as this uncertainty would then be overcome, preventing that Altirra gets confused because my script suddenly changes a worng parameter. But if it's clear that no matter what, the filename will always be on position 3 (as it is in my example), then there is also no issue at all.
Edited by freetz
  • Like 2
Link to comment
Share on other sites

21 hours ago, freetz said:

I don't know if this can change or if it would be easier to always put the /run "..." at the very beginning, then the filename would always be on position 2.

I'm sure that can be arranged.

 

I've also updated Atasm to V1.25 on GitHub.

 

The new version has better Mac/65 compatibility. Now offers some better trig functions and finally has commands to set the INITAT and RUNAT locations.

Here is a sample:
 

    .BANK
    *=  $8000
INIT:
    LDA #0
    STA 710
    RTS
 
    .INIT INIT
 
    .BANK
    *=  $8000
CYCLE:
    LDA 20
    STA 709
    JMP CYCLE
 
    .RUN CYCLE
  • Like 3
Link to comment
Share on other sites

V1.9.1 of the VSCode extension has been published.  It always puts the /run xex first and and second.

Also Atasm has been bumped to V1.25 and windows and linux binaries have been included.  Got no way to build mac binaries at the moment.

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Posted (edited)

Cool, thanks a lot!

So just for the record, this is how altirra.sh will now have to look like (cleaned it up a bit by having the paths right at the beginning):

#!/bin/bash
WINE_EXEC=/opt/homebrew/bin/wine64
ALTIRRA_EXEC=~/Downloads/Altirra-4.01/Altirra64.exe
filename="${2//\//\\}"
set -- "$1" "$filename" "${@:3}"
WINEDEBUG=-all $WINE_EXEC $ALTIRRA_EXEC $@

Feel free to add this to your repo, if this might help Mac and Linux users.

 

Thanks again for being so responsive, @RetroCoder, programming for the Atari has become even more fun with your extension :)!

P.S.: Let me know if you need me to build any mac binaries, happy to help if possible.

P.P.S.: If Atasm and the other compilers are also hosted on GitHub, there is a way to use GitHub workflows to regularly pull the most recent versions into your repository and then have them compiled as binaries, provided the compiler exists under Ubuntu, I think, as this is the OS that the workflows run under...

Edited by freetz
  • Like 1
Link to comment
Share on other sites

3 hours ago, RetroCoder said:

V1.9.1 of the VSCode extension has been published.

Very cool!

 

Itching to try it ... but guests in town, now the Miami F1 GP ... diving tomorrow, so it's looking like Tuesday before I can update and get to work.

Link to comment
Share on other sites

Too much celebration last night means no diving today, so I got to play with this properly.

 

Now have it working beautifully with MADS and Altirra, on macOS, so many thanks to both @RetroCoder for the VSC extension and @freetz for the inspiration for some clever script workarounds for Wine64 Windows-handling of paths.

 

...

 

One interesting thing I noticed is that when scripts are involved, you cannot use the ~ prefix as an alias for your home directory.  The default macOS shell for /bin/sh (Bash 3.2, I think) won't resolve it correctly.  So you need to use the full path and replace ~ with the path to your home folder. I don't know if it is VSC using /bin/sh, or the extension making that call explicitly (I may go look at the source), but I don't see it happening in other tools/languages under VSC.  It may be that I use ZSH for everything, now, anyway, that has hidden this in the past.

 

...

 

Anyway, thanks again, this is awesome!

Link to comment
Share on other sites

I don't know what you mean with the shells you mention: The default shell in MacOS is zsh. sh and bash are two quite different shells, and no matter what the default shell might be, if you hashbang the shell of your choice at the beginning of the script, that one will be taken no matter what. I'm still used to bash, so that's what you can find in my altirra.sh, and using the tilde to refer to the home directory works fine here on MacOS Sonoma. In the standard terminal of VSC I can also open a terminal which will give me zsh, and doing ls ~ there will give me the contents of my home directory. So what exactly isn't working for you, and where?

Link to comment
Share on other sites

So ...

 

Yes, the default macOS shell is ZSH, and VSC's terminal is running as ZSH.

 

The issue is NOT in the script that is being launched - as you say, the shebang runs the script under the specified shell, it's in how it is being launched.

 

Maybe it's a VSC configuration issue - though it's not a setting I've ever had cause to change.

 

But when hitting the "Assemble + Debug" button in the Atasm Altirra Bridge extension, if the "Atasm-altirra-bridge > Emulator > Altirra Path" is set to, say, "~/Emulation/Altirra/Altirra64_VSC.sh", then VSC fails to launch that script as it is using /bin/sh (which resolves to Bash 3.2) to try and run the "Altirra64_VSC.sh"

 

And you (or, well, I) get:

 

WARNING: Your chosen Altirra emulator path '~/Emulation/Altirra/Altirra64_VSC.sh' cannot be found.Please set the path in the settings...


Launching emulator...
"~/Emulation/Altirra/Altirra64_VSC.sh"
/run "out/Minimal.xex" /ntsc  /debug /debugcmd:.loadsym /singleinstance
/bin/sh: ~/Emulation/Altirra/Altirra64_VSC.sh: No such file or directory
Exit code: 127

 

Replace the home-folder alias '~' with '/Users/name' (etc.) and it's fine.

 

 

Link to comment
Share on other sites

8 minutes ago, Torq said:

Replace the home-folder alias '~' with '/Users/name' (etc.) and it's fine.

Have to tried $HOME instead of ~?
(Not knowing if this variable is actually set in MacOS - being a Linux/Windows user.) ;)

  • Like 1
Link to comment
Share on other sites

29 minutes ago, DjayBee said:

Have to tried $HOME instead of ~?
(Not knowing if this variable is actually set in MacOS - being a Linux/Windows user.) ;)

Yep!

 

You can use $HOME instead of ~.

 

Looking at the code to the extension its using NodeJS "child_process"' spawn() function to launch the emulator, which is picking up the default Bash shell (3.2 on macOS 14.4.1), which doesn't support ~.

 

No biggie, just mentioned it because it threw an error with ~.

 

Upgrading the OS version of Bash to 5.2 may fix it (depending on how you do it); I just don't have any other reason to fiddle with that ... so never did.

  • Like 1
Link to comment
Share on other sites

On my system, it spawns /bin/sh - which is not the same as bash. It clearly says that:

/bin/sh: ~/altirra.sh: No such file or directory

You are right that /bin/sh does not support ~ to refer to the home directory. /bin/bash would do it that way I think from when it was invented, that's why I was wondering. I'm also surprised why spawn() would use a non-default shell (on MacOS that would be zsh) and instead uses /bin/sh. Maybe because that is available on every system, no matter how old? In any case, good to know about this caveat!

  • Like 1
Link to comment
Share on other sites

I delved a bit deeper ... on my system /bin/sh is using the link (alias) at /private/var/select/sh to resolve what shell to actually run - which on my system points to /bin/bash (the old, outdated 3.2.57 version).  Changing that causes other issues (will see why).

 

But, at least as far as this extension goes, it doesn't matter at this point.

Link to comment
Share on other sites

Thank you for pointing out all these issues with shell scripts.  I see from the node documentation that the childprocess.spawn command launches /bin/sh on Unix systems.

 

I'll investigate what other options are available

  • Like 1
Link to comment
Share on other sites

Posted (edited)

ok. wanted to setup the extension. most of the time last years i used VScode just to manage my sources and edit but not for compiling etc. which I did in console window or via batch files. 

 

now I configured the extension so far I run into following issues (might be that I dont get the VSCode basics ;)) but maybe someone can point me to the direction.

 

so I am on Win11 btw.

 

Altirra is setup in the config file. I opened a folder (does it not work on file basis because normally i have several files open from different source folders). ok. Extension seems show up in the bottom when I create a new file it works for that by pressing "compile and run" and altirra opens with the file in the debugger. ok...

 

now I open another old source... and no way... it always assembles theapp.asm (which was my test file)...

 

what I am doing wrong here?


image.thumb.png.c4244a88a03bdb4876a238a2a0a9488b.png

 

Edited by Heaven/TQA
Link to comment
Share on other sites

Posted (edited)
9 minutes ago, freetz said:

Because that's what you define under "input" in the config. Read about the new settings possibilities so you can do it without the config.

Will have a look but I did not edit any Json file just the inputs on the config extension page. 

when I click on the config icon below the file window it opens that json file i showed above with the "theapp.asm" and this is shown when entering the config via extension marketplace?

 

{
    "terminal.explorerKind": "external",
    "z80-macroasm.files.include": "**/*.{a80,inc,s}",
    "workbench.startupEditor": "none",
    "launch": {
        "configurations": [
 
        ]
    },
    "atomKeymap.promptV3Features": true,
    "window.zoomLevel": 2,
    "editor.multiCursorModifier": "alt",
    "atasm-altirra-bridge.application.configuration.latestVersion": "1.9.1",
    "atasm-altirra-bridge.assembler.madsPath": "C:\\coding\\Mad-Assembler-2.1.5\\mads.exe",
    "atasm-altirra-bridge.assembler.whichAssembler": "Mads",
    "atasm-altirra-bridge.emulator.altirra.path": "C:\\Emulation\\Altirra64.exe",
    "atasm-altirra-bridge.emulator.altirra.singleInstance": true,
    "atasm-altirra-bridge.application.configuration.findFirstFileBy": "Last Modified"
Edited by Heaven/TQA
Link to comment
Share on other sites

Posted (edited)
33 minutes ago, freetz said:

atasm-build.json, as you yourself posted the screenshot! 

Ok. Don't get it what to do now 🤣want to use them.

 

1. The default is still the creation of the atasm-build.json file. This will build the specified file with all the command line options applied.

 

2. You can turn off the forced config file creation and use various other options.

 

The sequence of finding the file to assemble is now:

 

- Look at the Default Asm File to Assemble setting. If set then this is the file that will be assembled.

 

- If that is not set then the current editor tab is checked if its an assembler file. If it is then that is assembled. You can turn that off with the 'Assemble Current Asm File' option

 

- If you don't have a default and the current editor is not an assembler file or that option it turned off then the alphabetical first assembler file or the last modified one are assembled.

 

  The order is set by the Find First File By option.

Edited by Heaven/TQA
Link to comment
Share on other sites

There is a very easy way to configure the atasm-altirra-bridge to handle two basic scenarios:

1. Working on a project -> need a fully setup "build configuration" file.

2. Working on adhoc files (in a folder) -> need a more flexible "build configuration" file.

 

The basic idea of the extension is that you have to work in some kind of reference folder. Hence you need to open a folder to have the extension work for you.

In the first scenario you have a project in some folder.

Call it c:\projects\mygame.

Open that folder and click the gear at the bottom of the screen to create the 'atasm-build.json' file.

image.png.6f9a6e00db33ac2886d311d4e87652bf.png

This will generate the default "atasm-build.json" file.

The default file where the assembly start is "theapp.asm", change that in line 5: "input": ".....",

With this setup you can configure which folders to use for file includes, command line parameters you want to pass to atasm, etc.

Good for a project where the settings do not change and you always have the same starting point.

 

In the 2nd case you have multiple files that you just want to quickly edit and test out individually.

- You could edit the "input" field in the "atasm-build.json" file before each assembly.

But there is a better option.

Just clear the input data field: image.png.2f8b3e33f83e4a51dc9fc7a234c667d9.png

And make sure that you have the following atasm settings configured (press Ctrl+s and type atasm into the "Search settings" bar)

Turn ON the creation of the 'atasm-build.json' file. (making sure you clear the "input" setting)

image.thumb.png.7d0c15d7eaed3383454fe5834d2f9113.png

 

Turn ON Assemble Current Asm File, and leave the "Default Asm File To Assemble" blank

image.png.def0889547c758b4e222d7ea22313f4b.png

 

With these configurations set you can press F5 to assemble and run the currently open assembler file.  Makes switching between different test files very easy.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...