Implementing support for new devices for BASIC

Par DamnedAngel

Master (184)

Portrait de DamnedAngel

21-03-2020, 02:53

Hi,

As some of you already know, I am developing a set of templates for MSX Projects (BIN and DOS are already out, and ROM is WIP).
The ROM template will support the CALL and DEVICE extensions for BASIC. CALL extensions is already implemented, and DEVICE extension is halfway through.
I need now to implement a test program to both test the DEVICE extension implementation and to serve as a sample application. But I cannot find what exacly the implementation of the OPEN command should look like. The device is recognized, the extension handler routine is called, but I don't know exactly what variables to set so that BASIC knows that the file is open.
In short, the open command "works", in the sense that the empty handler is called, BUT the following print #1 does not work, because since open is empty, BASIC still doesn't have file #1 open.
Do you guys have either some reference (MSX TOP SECRET and THE RED BOOK didn't help), an example of implementation or at least any clue in the matter?

best regards,

!login ou Inscrivez-vous pour poster

Par zeilemaker54

Champion (265)

Portrait de zeilemaker54

21-03-2020, 10:31

You could look at the way the MSX2 MEM device (at 36D5H) is implemented:
https://sourceforge.net/p/msxsyssrc/git/ci/master/tree/base200/subrom.mac
Or the MSX serial COM device (at 41FCH):
https://sourceforge.net/p/msxsyssrc/git/ci/master/tree/serial100/serial.mac
These are all sequential devices.

Par NYYRIKKI

Enlighted (5505)

Portrait de NYYRIKKI

21-03-2020, 11:27

Here is some more info about COM-device routines input and output parameters:
http://www.msxarchive.nl/pub/msx/mirrors/msx2.com/sources/23...

Par zeilemaker54

Champion (265)

Portrait de zeilemaker54

21-03-2020, 12:10

NYYRIKKI wrote:

Here is some more info about COM-device routines input and output parameters:
http://www.msxarchive.nl/pub/msx/mirrors/msx2.com/sources/232bcal.txt

MSX serial extended bios calls are not 1:1 the same thing as BASIC device handlers. For example, the MSX serial extended bios call for the OPEN function is at 426AH and the BASIC device handler for the OPEN function is at 425EH
https://sourceforge.net/p/msxsyssrc/git/ci/master/tree/serial100/serial.mac

Par zeilemaker54

Champion (265)

Portrait de zeilemaker54

22-03-2020, 10:22

May be this helps:
Functions

A = 0FFH (INQUIRE)
Input:
PROCNM (0FD89H) = device name
Output:
Cx set, device not recognized
Cx reset, device recognized
A = DeviceID (0-3, extension can support max. of 4 devices)

OPEN (A = 0)
input:
DEVICE (0FD99H) deviceID
HL = pointer to io channel control block
E = mode (1 = sequential input, 2 = sequential output, 4 = random mode)

CLOSE (A = 2)
input:
DEVICE (0FD99H) deviceID
HL = pointer to io channel control block

RANDOM ACCESS (A = 4)
input:
DEVICE (0FD99H) deviceID
HL = pointer to io channel control block
D = (80H PUT, 000H GET)

SEQUENTIAL OUTPUT (A = 6)
input:
DEVICE (0FD99H) deviceID
HL = pointer to io channel control block
C = character

SEQUENTIAL INPUT (A = 8)
input:
DEVICE (0FD99H) deviceID
HL = pointer to io channel control block
output:
A = character

LOC function (A = 10)
input:
DEVICE (0FD99H) deviceID
HL = pointer to io channel control block
output:
DAC = result

LOF function (A = 12)
input:
DEVICE (0FD99H) deviceID
HL = pointer to io channel control block
output:
DAC = result

EOF function (A = 14)
input:
DEVICE (0FD99H) deviceID
HL = pointer to io channel control block
output:
DAC = result

FPOS function (A = 16)
input:
DEVICE (0FD99H) deviceID
HL = pointer to io channel control block
output:
DAC = result

BACKUP character (A = 18)
input:
DEVICE (0FD99H) deviceID
HL = pointer to io channel control block
C = backup character

Par DamnedAngel

Master (184)

Portrait de DamnedAngel

29-03-2020, 21:14

zeilemaker54 and NYYRIKKI,

Thanks for the insights.

zeilemaker54, this io channel control lock is probably what I was looking for.

Where did you take the above information from?

Do you have any references for the format of this control block? Would that be the same thing as the MSX Basic's FCB?

Par zeilemaker54

Champion (265)

Portrait de zeilemaker54

08-05-2020, 10:45

DamnedAngel wrote:

zeilemaker54 and NYYRIKKI,

Thanks for the insights.

zeilemaker54, this io channel control lock is probably what I was looking for.

Where did you take the above information from?

Do you have any references for the format of this control block? Would that be the same thing as the MSX Basic's FCB?

This information is poorly documented in the offical msx documentation, so most is deducted by disassembling the MSX system roms (see my project https://sourceforge.net/projects/msxsyssrc/).
The structure of the i/o channel is not very well documented either, but the MSX technical data book give some clues (how it is being used in the case of a diskfile):
+0 FL.MOD Open Mode
+1 FL.FCB Pointer to diskfile FCB
+3 FL.LSA Backup character
+4 FL.DSK Device number
+5 FL.SLB ?
+6 FL.BPS Position in FL.BUF
+7 FL.FLG Flags
+8 FL.OPS Psuedo head position
+9 FL.BUF 256 byte buffer