Help please with VSCode+Beeb VSC+BeebAsm

handy tools that can assist in the development of new software
Post Reply
Arx
Posts: 33
Joined: Sat Aug 20, 2022 10:12 pm
Contact:

Help please with VSCode+Beeb VSC+BeebAsm

Post by Arx »

Apologies if the following questions have already been asked or if the answers are obvious. I'm a bit of a n00b when it comes to 21st century dev tools.

I've got VS Code with Beeb VSC and BeebAsm. I'm able to make it compile a single .asm file and put it on a brand new .ssd file. I can't figure out the following, though. Please could you advise?

1. How do I make it assemble multiple .asm files and put the binaries into the same .ssd file? I'm struggling with tasks.json, the fact that VS Code only lets me pick one build target, plus I can't figure out how to make the -di option work for BeebAsm (which I'm assuming is needed?) The disc image I want to make will probably contain at least a boot file that *RUNs the game loader at &1900 and goes to mode 7, then *RUNs a file at somewhere like &900 which sets up the custom screen mode between &5800-&7FFF, then loads an image into it, then *RUNs the game itself which will occupy &1900-&57FF (and probably some space below once loading is done and it can switch off the FS).

2. In addition, I have a binary image file which I've already converted into the format needed to load straight in to screen memory. I've managed to make that work by importing that file into a disc image using BeebEm. I've added that same file to my VS Code folder but I can't figure out how to get it onto the .ssd file from there.

3. The tasks.json file generated specifies version 0.1.0 which VS Code says is deprecated. What's this about?

Please note I'm also new to VS Code, so don't assume I will understand much about any of its concepts.

Thanks in advance!
User avatar
tricky
Posts: 7694
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Help please with VSCode+Beeb VSC+BeebAsm

Post by tricky »

I've never used VSCode, as I use Visual Studio, but this might give you some ideas.
I set the project to namake which just allows you to run a command line (.bat in my case), no make involved, which I assume you can also do with VSCode.
The .bat preprocesses some of the images to binary files, sound to (what I call) .EQUB files (just text), BASIC to .bas (again just text) and then hooks the assembly stages together by passing what one outputs (text) to the next.
In the assembly, I use INCBIN (for preprocessed data), PUTBAISC (for the loader) and PUTFILE for the files SAVEed by the previous stages.
The earlier .asm files processed with beebasm just write out files and print variables to be used later.
The last .asm file just puts the other files together in the order that I want them to be on the disc for faster loading.

Code: Select all

GAME_LOAD= 10240  : GAME_EXEC= 12763  ; Tiled  
BOOT_LOAD= 0  : BOOT_EXEC= 0  ; !BOOT  
GROM_LOAD= 14391  : GROM_EXEC= 26914  ; R.Tiled  

PUTFILE "!BOOT", BOOT_LOAD, BOOT_EXEC

IF Trickysoft
	PUTBASIC "trickysoft.bas", "L.Tiled"
ELSE
	PUTBASIC "trickycade.bas", "L.Tiled"
ENDIF

PUTFILE "R.Tiled", GROM_LOAD + &30000, GROM_EXEC + &30000

PUTFILE "Tiled", GAME_LOAD + &30000, GAME_EXEC + &30000
The first three lines were PRINTed from earlier stages and trhen the rest appended to the temp file which is the last .asm to be assembled.
This file is assembled twice, one to produce the physical disc version and once to produce the version for my menu and bbcmicro.co.uk.

Code: Select all

copy /b join.asm+make_ssd.asm build.asm
if ERRORLEVEL 1 goto :EOF
!beebasm! !VERBOSE! !DEBUG! -w -vc -D Trickysoft=0 -i build.asm -do Trickycade%~1.ssd -opt 3 -title "%~1" -d -dd -labels rom_labels.txt -writes 0
if ERRORLEVEL 1 goto :EOF
!beebasm! !VERBOSE! !DEBUG! -w -vc -D Trickysoft=1 -i build.asm -do Trickysoft%~1.ssd -opt 3 -title "%~1" -d -dd -labels rom_labels.txt -writes 0
if ERRORLEVEL 1 goto :EOF
PS This is probably overkill for most projects, but does make sense for larger projects.
Arx
Posts: 33
Joined: Sat Aug 20, 2022 10:12 pm
Contact:

Re: Help please with VSCode+Beeb VSC+BeebAsm

Post by Arx »

Thanks very much, I will try this out.
tom_seddon
Posts: 889
Joined: Tue Aug 30, 2005 12:42 am
Contact:

Re: Help please with VSCode+Beeb VSC+BeebAsm

Post by tom_seddon »

For assembling multiple files with BeebAsm, here are 3 options (there may be others):

1. invoke BeebAsm once, with a driver file that essentially does a sequence of CLEAR/INCLUDE/SAVE for each output file. Invoke BeebAsm with -do to output the overall .ssd. I think this is how BeebAsm would like you to use it! For an example, see https://github.com/kieranhj/scr-beeb/blob/scr-beeb.asm

2. invoke BeebAsm multiple times, using -o or SAVE to write a PC file each time, then have a final driver file that uses PUTFILE to put together the .ssd. Disadvantage of this is that you need to know the load/exec addresses for PUTFILE, something that might or might not be a pain, but on the plus side you can be sure each file is self-contained. For an example of a project that builds this way, see https://github.com/kieranhj/stnicc-beeb ... -build.asm

3. invoke BeebAsm multiple times, using -do to write a .ssd each time. Then use ssd extract tools to pull files off each output .ssd for later use with ssd creation tools to put together a final .ssd. This might sound a bit inefficient, and it is - luckily PCs are fast - but you don't need a driver file, and you don't need to remember any load/exec addresses. For an example of this, see https://github.com/tom-seddon/vgm_playe ... r/Makefile (and this build "system" is a bit Heath Robinson! - but note how $.vgmplay makes it way out of the BeebAsm output .ssd and then into the final .ssd files it creates).

I'll back up Tricky's suggestion of just having something that builds your whole project from a single command line, be that a batch file, shell script, Makefile, Python program, or whatever you find easiest. Many editors and IDEs, seemingly including VSCode (which I do use, though not for Beeb stuff, and certainly not in a sophisticated fashion!), have good support for running a single arbitrary command line to build your project, but things often get a bit more fiddly if you try to run multiple commands in sequence.

--Tom
User avatar
tricky
Posts: 7694
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Help please with VSCode+Beeb VSC+BeebAsm

Post by tricky »

You missed running beebasm many times with the first one doing -do and the others doing -di and -do, this is fairly easy, but the order of the files is the order that you and them - doesn't matter on mmc type systems or that much at all really ;)
User avatar
kieranhj
Posts: 1103
Joined: Sat Sep 19, 2015 11:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Help please with VSCode+Beeb VSC+BeebAsm

Post by kieranhj »

tricky wrote: Sat Sep 10, 2022 8:28 am You missed running beebasm many times with the first one doing -do and the others doing -di and -do, this is fairly easy, but the order of the files is the order that you and them - doesn't matter on mmc type systems or that much at all really ;)
I didn’t even think of this as an option. #-o
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/
Arx
Posts: 33
Joined: Sat Aug 20, 2022 10:12 pm
Contact:

Re: Help please with VSCode+Beeb VSC+BeebAsm

Post by Arx »

Right, here's how I'm doing it so far, in VSCode:

I have a binary image file called LOADSCR.bin as loading screen and a makeLOADSCR.asm file that just does ORG &3000, INCBIN "LOADSCR.bin" and SAVE "LOADSCR", &3000, &7FFF

I have a MODE.asm file for setting up the custom screen mode and a separate makeMODE.asm file which includes it, a constants file called CONS.asm (i.e. labels for OSBYTE, OSWORD etc), specifies its required ORG and does a SAVE.

(In due course, I will have a bootable loader file, too, which will make use of LOADSCR and MODE.)

I have a makeMAIN.asm file which includes CONS.asm and all the various... classes?... used by the main game for where I have many other .asm source files knocking about here. Like makeMODE.asm, it controls their ORGs and does the SAVE.

I F10-ed to add makeLOADSCR.asm a build target. I edited the tasks.json file to remove the -boot Main bit of the BeebAsm command to leave it as BeebAsm.exe -v -i makeLOADSCR.asm -do makeLOADSCR.ssd

Ditto for makeMODE.asm but I edited its BeebAsm command to BeebAsm.exe -v -i makeMODE.asm -di makeLOADSCR.ssd -do makeMODE.ssd

Similar for makeMAIN.asm; BeebAsm.exe -v -i makeMAIN.asm -di makeMODE.ssd -do EVOLVE.ssd -title EVOLVE

...making sure all three tasks had ',"isBuildCommand": true' after the "args" bit.

Plus ensuring there was a test task:
{
"taskName": "Run 'EVOLVE.ssd' in Emulator",
"isTestCommand": true,
"args": [
"BeebEm.exe EVOLVE.ssd"
]
}

It works... but I really can't believe this is optimal! Is it not possible for BeebAsm to add a file to an existing disc image?
User avatar
kieranhj
Posts: 1103
Joined: Sat Sep 19, 2015 11:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Help please with VSCode+Beeb VSC+BeebAsm

Post by kieranhj »

Arx wrote: Sat Sep 10, 2022 4:03 pm I have a binary image file called LOADSCR.bin as loading screen and a makeLOADSCR.asm file that just does ORG &3000, INCBIN "LOADSCR.bin" and SAVE "LOADSCR", &3000, &7FFF

<snip>

It works... but I really can't believe this is optimal! Is it not possible for BeebAsm to add a file to an existing disc image?
You can just use:

Code: Select all

PUTFILE “LOADSCR.bin”, “LOADSCR”, &3000 
In your main asm file to add this to the disc image.
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/
Arx
Posts: 33
Joined: Sat Aug 20, 2022 10:12 pm
Contact:

Re: Help please with VSCode+Beeb VSC+BeebAsm

Post by Arx »

Ah, thank you.
User avatar
0xC0DE
Posts: 1300
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: Help please with VSCode+Beeb VSC+BeebAsm

Post by 0xC0DE »

I typically use 1 batch file to glue everything together. It pulls in data from many different sources like image converters, data compressors, python scripts, etc. My final disk image typically contains 3 files: !BOOT, LOADER and GAME, which are produced by using beebasm.exe on main.asm:

Code: Select all

  org XXXX
.start_code
  ....
  include "file1.asm"
  include "file2.asm"
  incbin "data1.bin"
  ....
.end_code

  puttext "!BOOT.txt", "!BOOT", 0, 0
  putbasic "LOADER.txt", "LOADER"
  save "GAME", start_code, end_code
All other code and data are in separate .asm or .bin files and can be included easily. You only have 1 build target: main.asm.

(in reality I call other batch files from that main batch file and I also manipulate temporary disk images into the final disk and tape images but you probably don't need that right now)
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my games and demos for Acorn Electron and BBC Micro
User avatar
fizgog
Posts: 618
Joined: Thu Jun 17, 2021 3:18 pm
Location: Nottinghamshire
Contact:

Re: Help please with VSCode+Beeb VSC+BeebAsm

Post by fizgog »

I also use VSCode and just compile from the command, see extract below from my matrix game

Code: Select all

\ ******************************************************************
\ *	Save the code
\ ******************************************************************
PRINT
PRINT "--------------------------------------------------"
PRINT "End of ZP", ~end_of_ZP
PRINT “Font Size", ~(end_of_Fontdata-font_data)
PRINT “Sprite Size", ~(end_of_Spritedata-sprite_data) 
PRINT "Bytes Used", ~(RELOC_END-START)
PRINT "--------------------------------------------------"
PRINT
SAVE "MATRIX", START, RELOC_END, RELOC_START+OFFSET, RELOAD_ADDR
puttext "BOOT", "!BOOT",&FFFF
putbasic "Matrix.bas", "LOADER"


\\ run command line with this
\\ beebasm -v -i Matrix.asm -do Matrix.ssd -opt 3
Pitfall, Gridrunner, Matrix: Gridrunner 2, LaserZone, AcornViewer, AcornPad
Arx
Posts: 33
Joined: Sat Aug 20, 2022 10:12 pm
Contact:

Re: Help please with VSCode+Beeb VSC+BeebAsm

Post by Arx »

Right, yes, finally got the hang of it!

Side note, it didn't help that VS Code converts tasks.json from version 0.1.0 to version 2.0.0 IMPERFECTLY. Pressing F7 doesn't bring up any build tasks to run because the tasks in the converted json file are not labelled as such. Go into the "group" bit and add "kind": "build" so that VS Code spots it.

Meanwhile, the task in question requires only BeebAsm.exe -v -i make.asm -do EVOLVE.ssd -title EVOLVE

tasks.json will probably not require any further modification from now on since the contents of the disc image is controlled by make.asm which so far consists of:

Code: Select all

\make by Arx
\EVOLVE make file

\Global constants
INCLUDE "CONS.asm"


\\\\\\\\\\\\\\\\
\Auxiliary files

\Bayer 4x4 stippling patterns
PUTFILE "BAYR.bin", "BAYR", &0C80

\Loading screen
PUTFILE "LOADSCR.bin", "LOADSCR", &3000

\MODE
ORG &0900
INCLUDE "MODE.asm"
SAVE "MODE", &0900, &09FF, &0900, &0900


\\\\\\\\\\\\\\\\\
\Main game binary
GUARD &5800
ORG &5400
INCLUDE "NUMB.asm"

ORG &5500
INCLUDE "MODM.asm"
INCLUDE "COLS.asm"

ORG &5600
INCLUDE "DATA.asm"

SAVE "EVOLVE", &5400, &5700, &5400, &5400
This adds two pre-canned binary files to the disc image, then assembles MODE.asm at &0900 and adds the resulting binary to the same disc image. Then it assembles four (many more still to come) .asm files into a single binary that will comprise the main game executable.

The missing link to follow shortly is the bootable loader, at which point I will basically have a hello world every time I press F9 to launch BeebEm with the disc image booting.
User avatar
Iggypop
Posts: 192
Joined: Thu Mar 05, 2020 6:34 pm
Location: The Netherlands
Contact:

Re: Help please with VSCode+Beeb VSC+BeebAsm

Post by Iggypop »

Please help..

I'm trying to setup VSCode, Beebasm, Beebem to play nice..on windows. I added Beebem and beebams to the %path% variable.. beebasm is in the same folder als beebem is in. I installed the extensions Beeb VSC and BBC BASIC Syntax Highlighting..

I follow the Quic setup included with the Beep VSC extensie. And I got stuck at 4. Create a new build taget. No way for me to select a file !! so i never get to the message BeebVSC-added new build target 'blabla.ssd'

What am i missing ???

second question: So i made these files on the beeb. say a program in assembly.. I know i can export files from an image to the windows filingsystem with the export function of beebem.. But first i spool my program and export that file..... wel... it's not wat beebasm is expecting.. #-o
Igor

Acorn Electron, BBC Master 128, Acorn Archimedes A3000
derek
Posts: 258
Joined: Thu May 07, 2015 8:31 pm
Location: Sunny Runcorn, UK
Contact:

Re: Help please with VSCode+Beeb VSC+BeebAsm

Post by derek »

Hi,

I have installed VS Code on Window 10 computer, with beebem, beebasm locations added to the PATH Environmental Variables.

I Opened the beebasm folder in the VS Code Explorer and opened the demo.6502 file.

Pressed F10 to create the task, which displayed a message to say the task had been created, the task file is located in the .vscode folder.

Press F7 to assemble the file, demo.6502, which the beebasm output is shown in the console window.

The demo.ssd file should shown in the VS Code Explorer window.

Press F9 to run the compiled file with beebem.

All seems to work nicely.

I tried the same setup on Linux, export the locations of beebem and beebasm to the PATH variable, but after creating the task with F10, pressing F7 to compile with beebasm, can not find the source file. I think it a feature of Linux not to have the current working directory in the PATH.

Is there any way to tell VS Code where the source files are?
Regards,

Derek
Post Reply

Return to “development tools”