how can we load files from floppies in assembly?

Pagina 1/3
| 2 | 3

Door nitrofurano

Champion (301)

afbeelding van nitrofurano

18-05-2016, 11:17

i have a question now - imagine that we would create a floppy game on Pasmo (my goal is doing this on Boriel’s ZX-Basic Compiler later, but Pasmo would be just perfectly fine for now), and the main executable binary would be loaded only via autoexec.bas (no msxdos1 or msxdos2 at all), and this compiled code would access files on the floppy, whatever it is a msx 1, 2, 2+, turbo-r or whatever - how files are loaded via assembly routines, that would be have just like a bload from basic? or should we (a quite ludicrous situation, imho) always return to basic for loading “bloadable” files from floppies every time is needed? if it is related to bios routines, how are they accessed? and if they are i/o routines, how they would look like? thanks! Smile

Aangemeld of registreer om reacties te plaatsen

Van NYYRIKKI

Enlighted (5943)

afbeelding van NYYRIKKI

18-05-2016, 11:43

Actually the routines work exactly like in DOS. You just need to replace BDOS entrypoint from 5 to #F37D

Van Daemos

Paragon (2009)

afbeelding van Daemos

18-05-2016, 12:15

Wasn't it so that if you do not use any DOS or basic to load from the floppy you need to find out in which slot your diskrom is and get your diskrom in the right page first?

Van zPasi

Champion (499)

afbeelding van zPasi

18-05-2016, 22:41

Daemos wrote:

Wasn't it so that if you do not use any DOS or basic to load from the floppy you need to find out in which slot your diskrom is and get your diskrom in the right page first?

No. Just use call 0F37DH (the Disk Basic hook) instead of call 5. Like NYYRIKKI wrote.

Lot of technical info on http://www.konamiman.com/msx/msx2th/th-3.txt

Van DarkSchneider

Paladin (944)

afbeelding van DarkSchneider

19-05-2016, 09:44

I think the BIOS has functions for disk management. And use it to ensure compatibility. Never use directly the disk controller because each manufacturer can have its own.

Quote:

PHYDIO (0144H)
Function: Physical input/output for disk devices
Input: A for the drive number (0 = A:, 1 = B:,...)
B for the number of sector to be read from or written to
C for the media ID
DE for the first sector number to be read rom or written to
HL for the startinga address of the RAM buffer to be
read from or written to specified sectors
CY set for sector writing; reset for sector reading
Output: CY set if failed
B for the number of sectors actually read or written
A for the error code (only if CY set):
0 = Write protected
2 = Not ready
4 = Data error
6 = Seek error
8 = Record not found
10 = Write error
12 = Bad parameter
14 = Out of memory
16 = Other error
Registers: all

Quote:

ISFLIO (014AH) *1
Function: tests whether the device is active
Input: none
Output: A = 0 -> active
A <>0 -> inactive
Registers: AF

Van NYYRIKKI

Enlighted (5943)

afbeelding van NYYRIKKI

19-05-2016, 11:06

I can't recommend using PHYDIO for handling files in any case. It will be nightmare even if you don't plan to support any mass storage devices.

Van DarkSchneider

Paladin (944)

afbeelding van DarkSchneider

19-05-2016, 13:08

Yep, unless you have a table of "files" and data filled manually to use (positions and sizes oO ). Any case if available is much better to use system functions, as they have that purpose.

Van nitrofurano

Champion (301)

afbeelding van nitrofurano

19-05-2016, 14:37

btw, i was looking for something “simple”, just like a register pair pointing to a filename somewhere in the memory, and perhaps some other registers pointing to where would be loaded and size, and then call the routine needed for loading the file - would be that possible? is that routine available on the bios somewhere? or should we need to create it somehow?

Van NYYRIKKI

Enlighted (5943)

afbeelding van NYYRIKKI

19-05-2016, 14:57

You have to create FCB that contains the filename. The OPEN function will fill in the size information, but after open you have to set manually the read block size (eg 1-byte). The load address can be set with SET DTA (#1A) command... After loading what you want to load, please CLOSE the file. All of this is actually explained quite a well in MSX-DOS2 manuals. See here: https://www.msx.org/wiki/MSX-DOS

Usage of Disk BASIC 2.0 with FIB is a bit more easy as you can usually just point to ASCIIZ string, but it limits the compatibility to machines with DOS2 ROM.

Van nitrofurano

Champion (301)

afbeelding van nitrofurano

19-05-2016, 21:28

the information there seems incomplete or confusing, at least for me - and i'm really interested on using it on all machines, not restricting it to dos2 machines

Van DarkSchneider

Paladin (944)

afbeelding van DarkSchneider

20-05-2016, 08:07

I think DOS has the same functions, at least for floppy, and DOS doesn't requires anything special, it works on any MSX with 64KB, without any extra cartridge.

Pagina 1/3
| 2 | 3