DOS-2 and mapper weird behaviour

By mohai

Paladin (833)

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

25-01-2019, 20:23

Hello !
I am experiencing some problems with a file loader I wrote in assembler.
The program loads several files from disk (using FCB), after setting mapper page for page 2 (address 8000h), in order to load 1 file per mapper page.
My program is working in BASIC environment (DOS not active), with enabled BIOS (it is a BLOAD file).

If I run the program from a diskette (DOS 1), it works flawlessly. Mapper page switching works fine and every file is loaded correctly.

BUT, working from hard drive using DOS-2 diskrom (exactly same program, FCBs), after opening the file, DOS2 restores mapper pages to the boot-up state (FCh=3, FD=2, FE=1, FF=0), so some files are not correctly loaded. Question

Is it a normal behavior of DOS-2?
Can it be avoided or I will need to change my loading routines in order to avoid this "bug"?

I made a simple test from BASIC: after altering mapper registers, (i.e. OUT &HFE,4) and issue a FILES command, all registers are restored.

I tried in a 128K RAM MSX and a 256K MSX and both work the same.

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

By Grauw

Ascended (8372)

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

25-01-2019, 20:58

In DOS2 environment, you can not OUT to mapper registers directly. Always use the mapper support routines. Otherwise your program can not cooperate with other software which uses the mapper, such as DOS2 itself, causing segment restore issues such as these and worst case overwriting code or data causing crashes.

Quote:

A program can request a 16k RAM segment at any time by calling the "ALL_SEG" routine. This either returns an error if there are no free segments, or the segment number of a new segment which the program can use. A program must not use any segment which it has not explicitly allocated, except for the four segments which make up the basic 64k of RAM.

Quote:

Routines are provided to explicitly page a segment in, or to find out which segment is in a particular page. There are routines in which the page (0...3) is specified by the top two bits of an address in HL ("PUT_PH" and "GET_PH"). And there are also specific routines for accessing each page ("GET_Pn" and "PUT_Pn"). These routines are very fast so a program should not suffer in performance by using them.

Here is some example code. After determining the mapper support routines base address, it copies the jump table to a static location in the program code, so that I can call it easily.

For DOS1 support you could pre-populate the jump table with very simple implementations of those functions, so that if DOS2 is not found it will use those instead. Or you can ask users to run MU.COM before executing your program, this provides mapper support routines for DOS1.

By gdx

Prophet (2976)

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

26-01-2019, 01:57

This is extended Bios that provides these mapper support routines. Extended Bios is installed by Disk-ROM 2.xx (but can be installed too by another device). Extended bios routines are also available in Basic environement when Disk-Basic 2.xx in installed.
MU.COM is avalaible Here.

By mohai

Paladin (833)

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

27-01-2019, 14:37

Thank you everybody.
It seems that what started being a simple file loader would end up in a quite complicated program. LOL!
I will study the DOS2 mapper support routines and see if they suit my routines ...

By NYYRIKKI

Enlighted (5358)

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

27-01-2019, 15:10

As a work around there is MAP2-utility, but it does not work on all computers... If you plan to release your work as DOS2 compatible, I suggest you go with already mentioned standard solutions.

By ToriHino

Champion (357)

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

27-01-2019, 19:00

mohai wrote:

Thank you everybody.
It seems that what started being a simple file loader would end up in a quite complicated program. LOL!
I will study the DOS2 mapper support routines and see if they suit my routines ...

Using the DOS2 mapper routines as indicated by Grauw is not that complicated. In fact, it even provides good support to multiple mappers as well in various (sub)slots, without worrying about where they are located.

By DarkSchneider

Paladin (860)

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

14-02-2019, 10:09

If you want to use extended memory in BASIC, I would recommend you to use NESTOR BASIC. No need to reinvent the wheel. It also includes Moonblaster re-player and more things.

By mohai

Paladin (833)

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

24-02-2019, 23:30

Thanks for the info.
I am starting to work with extended BIOS routines and getting positive results.