Can it be safe using all 32k at MTX500 ?

About the BASIC system (not including PROGRAMMING)
Post Reply
User avatar
Crazyboss
Site Admin
Posts: 274
Joined: 09 Aug 2012 21:45
Location: Sweden
Contact:

Can it be safe using all 32k at MTX500 ?

Post by Crazyboss »

Hi.

Is there a way to "disable" the system variables. Or maybe I should say it another way, can I use all the memory from 8000-FFFF at a MTX500, when basic have been booted?

I know basic use some of the top memory, and also disk systems like sdx use Memory as low as D800->

But when my code start and I am not returning to basic again should it be safe to use the memory range 8000-FFFF

I am asking cause I have a game that might be ported to MTX, its 32kb (or close), I think about load the first part of the code into vram, and load the second part into main ram and then decompress from vram, that way I will use almost the whole range 8000-FFFF, when my code is executed, it will never return to basic, so all system variables etc. are have been overwritten.

But is it safe ?
//CLAUS - Webmaster at www.mtxworld.dk
Bill B
Posts: 593
Joined: 26 Jan 2014 16:31

Re: Can it be safe using all 32k at MTX500 ?

Post by Bill B »

Claus,

It is certainly possible to use all 32K of RAM, but their are a couple of restrictions:
  • You will either have to disable interrupts, or install your own handlers for all of them.
  • Many of the ROM routines make use of some of the system variables, so not only can you not return to Basic (although a jump to 0 would work), you will be unable to use many of the ROM routines. You would have to examine the ROM listing for each routine to be sure.
Martin A
Posts: 799
Joined: 09 Nov 2013 21:03

Re: Can it be safe using all 32k at MTX500 ?

Post by Martin A »

What you're suggesting is pretty much what the FDX boot rom does to get a MTX512 to run CPM. Once it's finished the rom isn't even in the memory map any more.

However in order to do that it has to install it's own screen/keyboard handlers. The rom also turns off the interrupts and CTC for safety.

As Bill says, take care of the details and it's doable.
User avatar
Crazyboss
Site Admin
Posts: 274
Joined: 09 Aug 2012 21:45
Location: Sweden
Contact:

Re: Can it be safe using all 32k at MTX500 ?

Post by Crazyboss »

Thanks.

I am not needing any MTX ROM Routines anyway.

So what I think is to:

1. Load 16kb code into vram.
2. Load 16kb code into 8000-c000
3. execute code which do:
disable interrupts
reset CTC (Turn off)
copy the code from vram to c001-FFFF
execute the original code.

This should be safe, I stole the way to reset/turn of the ctc from Astropac, its done this way:

CLCTC: ;clear interupt channels only memotech

ld b,$02
ld a,3
LPCTC:
out ($08),a
out ($09),a
out ($0A),a
out ($0B),a
djnz LPCTC

Maybe it safe also write $E2 to vdp register 1 before clearing the CTC?
//CLAUS - Webmaster at www.mtxworld.dk
User avatar
thewiz
Posts: 137
Joined: 12 Aug 2012 16:08

Re: Can it be safe using all 32k at MTX500 ?

Post by thewiz »

Copying 16Kb to vram and back again sounds a bit excessive, plus will look ugly.

Why not load a small loader, no more then 256 bytes say, use that to turn off ctc etc and get that to load in the rest, e.g. 8100 to ffff?

You will probably have to copy the ROM tape loader code too and change any sysvar locations.

Thinking about that, this method will not with with emulators so they will need another way of doing it.

Could you get some free space by compressing the code? In fact presumably some of that code will be graphics. If that was loaded directly into vram, would it reduce the code to a manageable level?

Don't forget to leave space for the stack :)
THIS is what Memotech is doing now.
User avatar
Crazyboss
Site Admin
Posts: 274
Joined: 09 Aug 2012 21:45
Location: Sweden
Contact:

Re: Can it be safe using all 32k at MTX500 ?

Post by Crazyboss »

That is an idea too.

I could set the vdp bit to blank screen, so no one will notice :)

Unless I write my own loader, I do think the system variables might change durring the loading?

Yes for sure need space for the stack and around 1k of working space for the game.

That is a later issue :) Maybe first make the game run as a .RUN after that is time to space hunt :)

Anyway I do not have a MTX500 so cant really test, ofcause can always poke it back to a MTX500 ;)
//CLAUS - Webmaster at www.mtxworld.dk
Martin A
Posts: 799
Joined: 09 Nov 2013 21:03

Re: Can it be safe using all 32k at MTX500 ?

Post by Martin A »

There's a full listing of the MTX Rom source included in with the CFX source code. It shouldn't be too hard to steal/look at the tape loading code

http://primrosebank.net/computers/mtx/p ... htm#source

Open with Wordpad (Notepad wont recognise the Unix style end of line markers.)

The tape code runs from, ".toggle" up to ".printx".

The block read/write entry point #0AAE is the label ".inout"
Last edited by Martin A on 27 Oct 2015 20:00, edited 1 time in total.
User avatar
thewiz
Posts: 137
Joined: 12 Aug 2012 16:08

Re: Can it be safe using all 32k at MTX500 ?

Post by thewiz »

Another thing is you can set the machine stack to $f000 within the sysvars of the basic loader. That is, the first thing you load can have its sysvars such that the machine stack is at $f000.

VARNAM $f000
VALBOT $f001
CALCBOT $f001
CALCST $f001

Possibly even high as sysvars starts at $f8f2. You could try moving the machine stack to $f800 if feeling brave.
THIS is what Memotech is doing now.
Post Reply