Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile Cartridge ROM configuration #33

Closed
ghost opened this issue May 29, 2020 · 3 comments
Closed

Compile Cartridge ROM configuration #33

ghost opened this issue May 29, 2020 · 3 comments

Comments

@ghost
Copy link

ghost commented May 29, 2020

I am working on compiling a program and seeing if it is possible to make a program run from a 16k cartridge instead of RAM. I have started a CFG file. I am not sure if I am not missing anything.

FEATURES {
STARTADDRESS: default = $8000;
}
SYMBOLS {
EXEHDR: type = import;
STARTADDRESS: type = export, value = %S;
}
MEMORY {
ZP: file = "", define = yes, start = $0094, size = $0040;
ROM: file = "", define = yes, start = $8000, size = $2000, type = ro, fill = yes, fillval = $ff;
RAM: file = "", define = yes, start = $0400, size = STARTADDRESS - ROM, define = yes;
CARTSTART: file = %O, start = $BFEA, size = $0002;
CARTLEFT: file = %O, start = $BFFC, size = $0001;
CARTBOOT: file = %O, start = $BFFD, size = $0001; fill = yes, fillval = $59;
CARTENTRY: file = %O, start = $BFFE, size = $0002;
VECTORS: start = $BFFA, size = 6, type= ro, file = %O;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp, optional = yes;
EXEHDR: load = HEADER, type = ro, optional = yes;
MAINHDR: load = MAINHDR, type = ro, optional = yes;
JUMPTAB: load = MAIN, type = ro, define = yes, align = $100;
RUNTIME: load = MAIN, type = rw, define = yes;
CODE: load = MAIN, type = rw, define = yes;
DATA: load = RAM, type = rw optional = yes, define = yes;
BSS: load = RAM, type = bss, optional = yes, define = yes;
HEAP: load = RAM, type = bss, optional = yes
IHEADER: load = IHEADER, type = ro;
INTERP: load = INTERP, type = rw;
AUTOSTRT: load = TRAILER, type = ro, optional = yes;
CARTSTART: load = CARTSTART, type = ro;
CARTLEFT: load = CARTLEFT, type = ro;
CARTBOOT: load = CARTBOOT, type = ro;
CARTENTRY: load = CARTENTRY, type = ro;
}

@dmsc dmsc closed this as completed in b8d7ff6 May 30, 2020
@dmsc
Copy link
Owner

dmsc commented May 30, 2020

Hi!

I am working on compiling a program and seeing if it is possible to make a program run from a 16k cartridge instead of RAM. I have started a CFG file. I am not sure if I am not missing anything.

This needs a little extra work.

Normally, Fastbasic uses self-modifying-code in a few places to make the code faster, so the code can't be placed in ROM. But there is a compilation option to use alternative code that disables this, so you need to recompile the interpreter.

As I had not tested that option in a while, I just reviewed all the interpreter and found three places which still tried to write to the code, so I just fixed that.

This means:

  • You need the last (unreleased) version from github.
  • You need to compile the code using:
  make ASMFLAGS="--asm-define NO_SMCODE"
  • You need to alter the linker file.

Here there is another little issue: Fastbasic uses code in zeropage and initialized DATA.

This means you need to provide two special sections:

  • A section to place the "INTERP" segment in ROM, and at runtime copy it to RAM.
  • A section to place the "RT_DATA" segment in TOM, and again at runtime copy it to RAM.

I added a "fastbiasc-cart.cfg" file with those sections, and the support code to build the cartridge image in commit b8d7ff6 , now the full instructions to compile for a cartridge image (on Linux or other Unix) are:

  git clone https://github.com/dmsc/fastbasic/
  cd fastbasic
  make ASMFLAGS="--asm-define NO_SMCODE"
  build/compiler/fb myProgram.bas -C:build/compiler/fastbasic-cart.cfg

Have Fun!

@ghost
Copy link
Author

ghost commented Jun 3, 2020

I also have a ML routine called deflate which decompresses data blocks from Cartridge ROM into RAM. I could just use a portion of cartridge ROM for fonts, data tables, and some ML routines.

@dmsc
Copy link
Owner

dmsc commented Jun 4, 2020

Hi!

I also have a ML routine called deflate which decompresses data blocks from Cartridge ROM into RAM. I could just use a portion of cartridge ROM for fonts, data tables, and some ML routines.

Did you try using the new CART support?

Also I recently added a copy of the CC65 tools to the repo, so you don't need CC65 to use the compiler.

Have Fun!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant