Arkos Tracker 2 and MSX Basic compiler

Страница 1/2
| 2

By Amaury Carvalho

Rookie (23)

Аватар пользователя Amaury Carvalho

21-06-2021, 23:00

Hello there!

I'm proud to announce that MSXBAS2ROM (the open source cross platform MSX Basic compiler) has officially now Arkos Tracker 2 support and can play songs on "AKM" file format!

So, if you dont know Z80 assembly very well or its searching for an easy way to test your songs on a MSX machine, you can use MSXBAS2ROM to create a ROM program file from your Arkos project and do it!

Download the test package below to see some examples and get the how-to documentation:

Test package

Or, click into link below for more information about MSXBAS2ROM compiler:

MSXBAS2ROM project

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By Amaury Carvalho

Rookie (23)

Аватар пользователя Amaury Carvalho

22-06-2021, 16:57

Creating your songs on Arkos Tracker 2

  • You need to write the songs on your AKS project to play on 50hz speed, focusing to use with the Arkos Minimalist Player;
  • Consult here for more information about this player limitations.

Exporting songs to use with MSXBAS2ROM

  • Open your AKS project and use "File -> Export -> Export as minimalist (AKM)" option to create the AKM file;
  • Mark the "Export as -> binary file (z80)" option and inform "0100" on "Enconde to adress..." field;
  • Only one AKM can be used with each MSX Basic compiled program, so all the subsongs to use with your project needs to be onto the same exported file.

Writing a MSX Basic program to test your song

  • Create a text file and insert your MSX Basic code into it;
  • To play AKM files in your program you need to use some special new commands. Below you can see a simple MSX Basic example (program.bas):
        FILE "music.akm"
        10 CMD PLYLOAD 0
        20 CMD PLYPLAY
        30 PRINT "Playing the first song on AKM file..."
        40 GOTO 40
  • The "music.akm" needs to be on the same folder of your MSX Basic program text file.

Compiling your MSX Basic program

  • MSXBAS2ROM is a command line tool, so you need to open a terminal to use it (on Windows: "Start -> Run -> CMD" to open a MS-DOS terminal);
  • To compile your MSX Basic text file, use the command below on terminal:
       msxbas2rom -c program.bas
  • Use the command below to get the "CMD PLY..." commands list reference:
       msxbas2rom --doc

Testing it on emulators and real machines

  • MSXBAS2ROM will compile your MSX Basic program to a 48kb ROM file when you attach an AKM file into it;
  • This ROM can be loaded directly as cartridge into emulators like OpenMSX and WebMSX, or loaded into real machines with SofaRUN or ODO (ExecROM cannot load 48kb linear ROMs).

By Pencioner

Scribe (1468)

Аватар пользователя Pencioner

22-06-2021, 18:24

Very interesting project, kudos for it!

By PingPong

Prophet (3756)

Аватар пользователя PingPong

25-06-2021, 09:59

this is a very interesting project, we also hava XBasic but its main limitation are the size of the compiler and the need of basic interpreter.

From my understanding those constraints are not on this project.
So finally may be we have a true good basic compiler, able to generate independent binary code.

By Amaury Carvalho

Rookie (23)

Аватар пользователя Amaury Carvalho

28-06-2021, 01:43

Thanks, Pencioner, for your feedback! Thanks PingPong for your feedback too.

The main difference of MSXBAS2ROM compilation process from XBasic its that the latter compiles your program at runtime on your MSX, requiring both the compiler and your Basic code loaded in RAM, allocating a lot of memory resource and processor time during it. The former, instead, compiles your program on your PC (Windows or Linux), saving on your ROM file only the binary code required to run your program on MSX.

MSXBAS2ROM can build 32kb (for simple programs), 48kb (for programs with Arkos integration) and 128kb (Konami SCC MegaROM format) compiled ROMs.

You can know a little more about MSXBAS2ROM compilation process here, and watch an Arkos integration test at here (note: brazilian portuguese videos).

By Manuel

Ascended (18092)

Аватар пользователя Manuel

28-06-2021, 23:44

Can you tell a bit more about your compiler? What programs does it support? Which instructions? Which not?
Can we compile existing BASIC programs with it?
How does it compare with existing BASIC compilers (that were running on the MSX itself), like MCBC?

By Kai Magazine

Paragon (1411)

Аватар пользователя Kai Magazine

29-06-2021, 14:34

if you type this:
msxbas2rom.exe --doc

you get this:

Functions supported:
INT, FIX, RND, SIN, COS, TAN, ATN, EXP,
LOG, SQR, VAL, TIME, SGN, ABS, ASC, INKEY,
LEN, CSNG, CDBL, CINT, CHR$, INKEY$, INPUT$,
SPACE$, SPC, TAB, STRING$, STR$, LEFT$, RIGHT$, MID$,
INSTR, OCT$, HEX$, BIN$, PEEK, VPEEK, INP, POS, LPOS,
CSRLIN, STRIG, STICK, PDL, PAD, BASE, VARPTR,
PLAY, VDP, POINT, COLLISION, FRE, HEAP, TILE,
RESOURCE, USR, PSG, MSX, NTSC, TURBO, MAKER

TIME and MID$ assignments
VDP assignment

Data types, operators and operations supported:

Integer, Float, String, Fixed Bidimensional Arrays
Math expressions and basic operators (+-*/^)
OR, AND, XOR, EQV, IMP, NOT, MOD, SHL, SHR
&h0000, &o0000, &b00000000

Limitations and differences:

- Minimum hardware requirements for compiled programs:
* MSX1 machine (with ROM BIOS and ROM BASIC);
* 16kb of RAM for running as Cartridge without resources;
* 32kb of RAM for running as Cartridge with resources;
* 64kb of RAM for running with ExecROM (for 32kb ROMs) or ODO
(for 48kb ROMs) via disk driver or Caslink3/CASDuino/MSX2CAS
via cassete;
* 64kb Memory Mapper and/or MegaRAM for running with SofaRun;
* MegaROM compiled mode needs a Memory Mapper and/or MegaRAM with
at least the same size as the final ROM for running it in memory
with ExecROM (note: not required for running as Konami SCC
Cartridge in emulators);
- Partial file support (OPEN "GRP:", PRINT #...);
- No dynamic arrays (REDIM);
- No variant data type (only string, integer and single);
- All variables has an unique data type (dont change in runtime);
- Variables are not initialized at startup (do it yourself);
- Default data type is single (use DEFINT A-Z to modify it to integer);
- CIRCLE tracing and aspect parameters not supported;
- SCREEN cassette speed, printertype and displaymode parameters not
supported;
- STOP works like END;
- CMD WRTSCR/CMD WRTCHR activate the tiled mode in screen 2, forcing text
mode coords;
- LOCATE/PRINT works in graphical mode (screen 2+) without use of
OPEN 'GRP:'. When in screen 2 tiled mode, it works similar as text
mode coords (faster output);
- PUT TILE , (x,y) - for tiled mode used with screens 0-2;
- COPY works only with graphical parameters (no files support) just
like: COPY (x0,y0)-(x1,y1) TO (x2,y2);
COPY ... TO / COPY TO ... is accepted
instead of COPY ... (try HEAP() as );
When in screen 2 tiled mode, it works with text mode coords;
- IDATA (integer data) and IREAD (integer read) works similar as DATA/READ
but use less ROM memory and its faster;
- BLOAD works only to load screen files. You need to inform a file
name as literal (no via variables) because it will be loaded into ROM
(it will activate MegaROM mode). Ex: BLOAD "file.sc5", S;
- RANDOMIZE is the same as RND(-TIME);
- FRE() return free RAM size only (doesnt accept parameters);
- HEAP() return first free RAM address;
- TILE(x,y) return character from position (screens mode 0-2);
- MSX() return current machine version (0: MSX1, 1: MSX2,
2: MSX2+, 3: MSXturboR);
- NTSC() return true to a NTSC (or PAL-M) machine and false to a PAL one;
- TURBO() return true to cpu turbo mode (R800 or 5.37mhz) or false
to standard mode (Z80/3.57mhz). Use with CMD TURBO...
- VDP() without parameters return VDP version (0: TMS9918A, 1: V9938,
2: V9958, x: VDP ID);
- MAKER() return the manufacturer ID [1:ASCII/Microsoft, 2:Canon, 3:Casio,
4:Fujitsu, 5:General, 6:Hitachi, 7:Kyocera, 8:Matsushita (Panasonic),
9:Mitsubishi, 10:NEC, 11:Nippon Gakki (Yamaha), 12:JVC, 13Tonguehilips,
14Tongueioneer, 15:Sanyo, 16:Sharp, 17:SONY, 18:Spectravideo, 19:Toshiba,
20:Mitsumi, 21:Telematica, 22:Gradiente, 23:Sharp Brazil,
24:GoldStar(LG), 25Big smileaewoo, 26:Samsung,
212:1chipMSX/Zemmix Neo(KdL firmware)];
Works only in some MSX2 machines;
- RESOURCE(number) return resource start address (use with COPY);
- COLLISION() return if a sprite collided with another sprite;
- INKEY() is a alternative to INKEY$, but returning an integer instead;
- Spaces on your line code, REMs and blank lines not affect compiled code
size, but if your include it on your program it can help the compilation
process (not need for strip spaces from your code anymore);
- Resources total size are limited to 16kb (for FILE directive), and
when compiled generates 48kb ROMs thats can run as cartridge or in RAM
with SofaRUN or ODO loaders (ExecROM do not support this ROM size);
- Arkos Tracker 2 player use the minimalist binary file (AKM and AKX),
with songs composed to play at 50hz, exported at 0100 address, and must
be included as the first resource in the list (AKM as 1st and AKX as 2nd);
- PT3 player support is now deprecated, dont use it. Also, it cannot be
used in concurrence with Arkos Tracker 2 player too.

Statements not supported:

AUTO, BLOAD, BSAVE, CALL, CLOAD,
CONT, CSAVE, DEF FN, DELETE, EOF, ERASE,
ERL, ERR, ERROR, FILES, FN, FPOS, FIELD,
GET, GET DATE, GET TIME, IPL, LIST, LLIST,
LOAD, LOC, LSET, LPRINT, MERGE, RSET,
MOTOR, NEW, PUT, PUT KANJI, RENUM, RUN, SAVE,
SET ADJUST, SET BEEP, SET DATE, SET PASSWORD,
SET PROMPT, SET SCREEN, SET TIME,
SET TITLE, SET VIDEO, TROFF, TRON,
RESUME, ON ERROR GOTO,
CLEAR

RESOURCES DIRECTIVES

TEXT
FILE
INCLUDE

EXTENDED COMMANDS

Play a text resource with Basic (xbasic compatible, channel C disabled
to use with SOUND command)
CMD PLAY [, ]

Mute the PSG (for PLAY use)
CMD MUTE

Draw a text resource with Basic (xbasic compatible)
CMD DRAW

Exec a binary uncompressed resource as a assembly code
CMD RUNASM

Exec a text resource as a plain text basic code (must start with ':')
CMD RUNBAS

Write a compressed resource (pletter) to VRAM address
CMD WRTVRAM ,

Write a compressed .ALF resource (pletter) to VRAM font pattern table
CMD WRTFNT

Write a compressed resource (pletter) to VRAM tile pattern table
CMD WRTCHR

Write a compressed resource (pletter) to VRAM tile color table
CMD WRTCLR

Write a compressed resource (pletter) to VRAM screen table
CMD WRTSCR

Write a compressed resource (pletter) to VRAM sprite pattern table
CMD WRTSPRPAT

Write a compressed resource (pletter) to VRAM sprite color table
CMD WRTSPRCLR

Write a compressed resource (pletter) to VRAM sprite attribute table
CMD WRTSPRATR

Write RAM to VRAM address
CMD RAMTOVRAM , ,

Write VRAM to RAM address
CMD VRAMTORAM , ,

Write RAM to RAM address
CMD RAMTORAM , ,

Inhibits the screen display
CMD DISSCR

Display the screen
CMD ENASCR

Turn off keyboard clicks (for xbasic use)
CMD KEYCLKOFF

Clear keyboard buffer and reset joysticks ports
CMD CLRKEY

Fill screen 2 with spaces to use with SETFNT/PRINT
CMD CLRSCR

Load internal FONTs to VRAM font pattern table (screen mode >= 1)
CMD SETFNT [, ]
0 = BIOS default font
1 = Compile Zanac Style
2 = Konami Gradius Style 1
3 = Konami Gradius Style 2

Update tiled font color with current fore/background COLOR
CMD UPDFNTCLR

Set clipping on and off (screen modes 5 through 8,
and same as '#C of xbasic)
CMD CLIP <0=off | 1=on>

Activate cpu turbo mode (R800 or 5.37mhz)
CMD TURBO <0=off | 1=on>

EXTENDED FUNCTIONS

Get resource data address
= USR0()

Get resource data size
= USR1()

Multifunction alternatives
PLAY() function alternative (xbasic compatible)
<0=false> = USR2(0)

INKEY$ function alternative (integer, for speed)
= USR2(1)

INPUT$(1) function alternative (integer, for speed)
= USR2(2)

AKM/PT3 PLAYER STATUS (bit 7 = end of song reached, bit 0 = loop status)
= USR2(3)

Read PSG register
n = PSG( )

Sprite Collision Detection
<-1=no collision|collided sprite number> = COLLISION( <-1=any sprite |
collider sprite number | &hCCSS> )
<-1=no collision|collided sprite number> = USR3( <-1=any sprite |
collider sprite number | &hCCSS> )
Examples
Beep if any sprite collided with each other:
SN# = COLLISION(-1)
IF SN# >= 0 THEN BEEP
Beep if any sprite collided with sprite 2:
SN# = COLLISION(2)
IF SN# >= 0 THEN BEEP
Beep if sprite 4 collided with sprite 5:
SN# = COLLISION(5)
IF SN# = 4 THEN BEEP
Beep if sprite 5 collided with sprite 4 (direct test):
SN# = COLLISION( &h0405 )
IF SN# >= 0 THEN BEEP
Beep if sprite 0 collided with sprite 1 (direct test):
SN# = COLLISION( &h0100 )
IF SN# >= 0 THEN BEEP
Notes
Sprites with same X and Y position are considered the same object, thus
there's no collision in this case.

ARKOS TRACKER 2 PLAYER SUPPORT

Load an AKM (songs) and AKX (effects) uncompressed files resources in memory
setting up the first song to play
CMD PLYLOAD [, ]

Initialize a song from the previous AKM resource loaded
CMD PLYSONG []

Play/continue a song in memory
CMD PLYPLAY

Mute/pause a song in memory
CMD PLYMUTE

Play a sound effect from the previous AKX resource loaded
CMD PLYSOUND [, [, ] ]

Set the song loop status
CMD PLYLOOP <0=off | 1=on>

Restart a song in memory
CMD PLYREPLAY

PT3 PLAYER SUPPORT (DEPRECATED)

Load a PT3 compressed resource (pletter) in memory
CMD PT3LOAD

Play/continue a PT3 in memory
CMD PT3PLAY

Mute/pause a PT3 in memory
CMD PT3MUTE

Set PT3 loop status
CMD PT3LOOP <0=off | 1=on>

Restart a PT3 in memory
CMD PT3REPLAY

FOOTNOTES

= Resource Sequence Number (start with zero)

By jltursan

Prophet (2537)

Аватар пользователя jltursan

30-06-2021, 08:56

That's impressive, does it really has support for such exhaustive list of commands and features?, wow Shocked!

MSX-BASIC lovers will be extremely happy with your tool!

By Manuel

Ascended (18092)

Аватар пользователя Manuel

30-06-2021, 10:46

Quote:

Can we compile existing BASIC programs with it?
How does it compare with existing BASIC compilers (that were running on the MSX itself), like MCBC?

Did someone try to port some existing programs and compare them with interpreted BASIC and perhaps other compilers like MSX-BASIC-kun or MCBC?

By Grauw

Ascended (10022)

Аватар пользователя Grauw

30-06-2021, 13:24

It’s the first time I heard of it, really cool stuff! I remember back in the days extensively trying out different basic compilers like BASIC-kun, MCBC, BASCOM, but only BASIC-kun stuck with me, until I learned assembly programming.

By Amaury Carvalho

Rookie (23)

Аватар пользователя Amaury Carvalho

30-06-2021, 23:15

Hi, Manuel!

I've writing this compiler for about a little more than 1 year, and although it already have a good support to a lot of MSX Basic instructions, some of them works a little bit different from the interpreter original version. Also, it have some limitations too (--doc option will show some of them, like Kai Magazine noted).

In addition, my lexer identify some Basic code in different way.

For example, the code below will result in syntax error on MSX interpreter ("port = 1" will be read like "p or t = 1"), but will be compiled correctly by MSXBAS2ROM:

10 port = 1
20 print port

On the flip side, the code below will run correctly on MSX interpreter but will result in syntax error on my compiler (you'll need to put spaces between instructions to be correctly recognized by my compiler):

10 p = 1 : t = 0
20 ifportthenprint"ok"

And about other compilers, my main goal with MSXBAS2ROM are:

  1. have a tool thats can compile any size of Basic program and generate any size of ROM file (think really big games);
  2. have a compiler that its free and can be ported to any future platform (think natural evolution of technology);
  3. have a tool that its easy to install and use, and can be integrated with any IDE (think new generations, *kids*, learning and using it).

Also, although now I can write programs directly in assembly, I really love to write code in Basic like I did when I was a kid. So, I use it to write my own games too.

Here you can watch a test I did some time ago compiling some of the examples of the 1973 book 101 Basic Computer Games.

Страница 1/2
| 2