BeebASM -> JsBeeb - Development Environment

bbc micro/electron/atom/risc os coding queries and routines
Post Reply
User avatar
anthonylime
Posts: 14
Joined: Mon Sep 04, 2023 6:55 pm
Contact:

BeebASM -> JsBeeb - Development Environment

Post by anthonylime »

Hi,

I've recently decided to return to BBC Micro programming after about 34 years :)
My ambition is to write a platform game using 6502 assembler running on a BBC Model B
My theory is that where I failed in my teenage years I can succeed because I've got more experience but critically tools etc are just alot better.

I wanted advice on setting up my development environment. My ideal wishlist is that I can work on my Mac laptop, code using a modern IDE, run the code quickly and beyond that have access to automated testing, debugging etc.

My first focus is on making the code -> build -> run fast. My toolchain is:-
VSCode
BeebAsm
Horizon emulator.

Its ok but a bit clunkier than I would like. I have to run a command line to compile, then switch to horizon and select the SSD file to re-open.

I want to switch to use JsBeeb because the potential for debugging, profiling etc is great. I'm finding my self using it alot, its such a great piece of work! However its still very manual with my having to open a browser, run some BBC Basic lines in the emulator and set up debug breakpoints etc in the javascript console.

My specific question is:-
Has anyone automated via a shell script or similar the code to compile the SSD image and then open it automatically in JSBeeb (presumably in a browser). At the moment I have to type "*RUN Code" in the JSBeeb emulator which I want to remove.

Going beyond that I am really interested in how I could include automatically run some javascript in the console window to set up breakpoints / asserts etc and edit that code in VSCode (and keep it source control) - has anyone done that already?
tnash
Posts: 163
Joined: Mon May 02, 2022 9:56 am
Contact:

Re: BeebASM -> JsBeeb - Development Environment

Post by tnash »

There's a plugin that works fine for me in vscode https://marketplace.visualstudio.com/it ... m.beeb-vsc
User avatar
anthonylime
Posts: 14
Joined: Mon Sep 04, 2023 6:55 pm
Contact:

Re: BeebASM -> JsBeeb - Development Environment

Post by anthonylime »

Thanks

I also found some more info on the JSBeeb Wiki
https://github.com/mattgodbolt/jsbeeb/w ... pment-with

And created a bash script thats working ok.

Code: Select all

#!/bin/sh
# compile
./beebasm -i game-wip.6502 -do game-wip.ssd -boot Code -v > outputasm.6502
# copy the disk image to the jsbeeb folder
cp ./game-wip.ssd ../jsbeeb/discs/

# Open jsbeeb in Chrome (or refresh) 
./scripts/open-browser-url.sh "http://localhost:8080/?disc1=game-wip.ssd&autoboot&about&keyLayout=natural"
# open-browser-url.sh Taken from https://gist.github.com/davidwieler/c25f0878d63029f07c6d94a168f95066

#Still to work out how to inject breakpoints into the Chrome Developer tools window...
#processor.debugInstruction.add(function(pc) { return pc == 0x1E1B);
VectorEyes
Posts: 573
Joined: Fri Apr 13, 2018 2:48 pm
Contact:

Re: BeebASM -> JsBeeb - Development Environment

Post by VectorEyes »

I code using BeebAsm and VSCode on MacOS. I have it set up so there’s one shortcut for “build” and one for “test in emulator”. I use B2 for debugging at the moment but there have been times in the past where I used a local install of JSBeeb. It’s all do-able. Happy to share more details if there are specific steps you’re having difficulty with.
AngusH
Posts: 7
Joined: Thu Apr 02, 2020 2:31 pm
Contact:

Re: BeebASM -> JsBeeb - Development Environment

Post by AngusH »

I too am Mac-based.

After 35 years, I've got an idea for something so am slowly trying to get back up to speed in 6502 & the modern dev environment.

As far as writing code is concerned, I'm happy with a chain of Sublime Text, BeebAsm invoke from command-line, & emulating in B2. I've got an interesting and encouraging scrolling demo working.

What's the best solution for generating sprite-based graphics? I have some .png files that I'd like to convert to Mode 5 format. Anyone know of script to do this? An alternative might be to find an existing beeb editor that could run in an emulator & [somehow] extract/export the data that way. Am I clutching at straws here?

All suggestions welcome if it means I can avoid the a) graph-paper route, and manual byte calculation or b) investing in a windows machine !!
julie_m
Posts: 596
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BeebASM -> JsBeeb - Development Environment

Post by julie_m »

Mac OS is a Unix-like environment, so you already have Perl and Python available -- and therefore, you can code up anything you like, almost as easily as on a Beeb. You just need some code that can load an image into memory and examine the individual pixels of it. Then you can create yourself a corresponding stream of bytes exactly matching the way the Beeb stores its pixels, dump that to a file and INCLUDE it in a BeebASM disc image.

This thread is about MODE 2; but you should be able to adapt the general principle.

Note, if you find something neat on GitHub that mentions Linux but is deathly silent on Apple: Almost anything that builds and runs on Linux should also work fine on MacOS -- just watch out for filenames, because Mac OS has had the capitalisation-sensitivity for which Unix was (in)?famous beaten out of it.
AngusH
Posts: 7
Joined: Thu Apr 02, 2020 2:31 pm
Contact:

Re: BeebASM -> JsBeeb - Development Environment

Post by AngusH »

Thanks Julie_m - having done a lot of searching this morning, I seemed to have reached the conclusion that coding something up might be the simplest approach after all. Thanks for the link to the mode 2 work, that's a great starting point. I'll see what I can come up with :D
julie_m
Posts: 596
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BeebASM -> JsBeeb - Development Environment

Post by julie_m »

I'll even tell you for free how four MODE 5 pixels (and MODE 1 works the same way) are packed into a byte of memory:

Code: Select all

128 = leftmost pixel colour bit 2
64  = second pixel colour bit 2
32  = third pixel colour bit 2
16  = rightmost colour bit pixel 2
8   = leftmost pixel colour bit 1
4   = second pixel colour bit 1
2   = third pixel colour bit 1
1   = rightmost pixel colour bit 1
AngusH
Posts: 7
Joined: Thu Apr 02, 2020 2:31 pm
Contact:

Re: BeebASM -> JsBeeb - Development Environment

Post by AngusH »

Ha ha - I knew that already!

Image Magic installed - will try and find some time this evening to put it all together.
dr_d_gee
Posts: 30
Joined: Thu Feb 01, 2024 6:53 pm
Contact:

Re: BeebASM -> JsBeeb - Development Environment

Post by dr_d_gee »

julie_m wrote: Mon Apr 29, 2024 11:43 am Mac OS is a Unix-like environment, so you already have Perl and Python available -- and therefore, you can code up anything you like, almost as easily as on a Beeb. You just need some code that can load an image into memory and examine the individual pixels of it. Then you can create yourself a corresponding stream of bytes exactly matching the way the Beeb stores its pixels, dump that to a file and INCLUDE it in a BeebASM disc image.
This is no longer true — Perl, Python and Ruby were removed from MacOS a while back. I know because the removal stopped another program from working — and as it had been hard-coded to use the version of Python in /System/LibraryFrameworks, installing Python separately didn't work.

You can install Python separately, but the same is true of other OSs as well.
dr_d_gee
Posts: 30
Joined: Thu Feb 01, 2024 6:53 pm
Contact:

Re: BeebASM -> JsBeeb - Development Environment

Post by dr_d_gee »

julie_m wrote: Mon Apr 29, 2024 11:43 am Mac OS is a Unix-like environment, so you already have Perl and Python available -- and therefore, you can code up anything you like, almost as easily as on a Beeb. You just need some code that can load an image into memory and examine the individual pixels of it. Then you can create yourself a corresponding stream of bytes exactly matching the way the Beeb stores its pixels, dump that to a file and INCLUDE it in a BeebASM disc image.
This is no longer true — Perl, Python and Ruby were removed from MacOS a while back. I know because the removal stopped another program from working — and as it had been hard-coded to use the version of Python in /System/LibraryFrameworks, installing Python separately didn't work.

You can install Python separately, but the same is true of other OSs as well.
AngusH
Posts: 7
Joined: Thu Apr 02, 2020 2:31 pm
Contact:

Re: BeebASM -> JsBeeb - Development Environment

Post by AngusH »

Luckily my dev laptop is running an older version of Mac OS. However, it's not a complete installation of Perl on there, shipped by Apple. So am trying to reinstall / upgrade that too.

It's been 20 years since I last did Perl too .... starting to feel old!
julie_m
Posts: 596
Joined: Wed Jul 24, 2019 9:53 pm
Location: Derby, UK
Contact:

Re: BeebASM -> JsBeeb - Development Environment

Post by julie_m »

dr_d_gee wrote: Tue Apr 30, 2024 3:24 pmThis is no longer true — Perl, Python and Ruby were removed from MacOS a while back.
Ah -- I must have missed that! But then, MacPorts -- other package management tools are available -- was one of the first things I installed.
Post Reply

Return to “programming”