Programming question: better way to wait for the disk interface initialization

By sd_snatcher

Prophet (3645)

sd_snatcher's picture

24-07-2013, 18:16

Here's a question for the more advanced programmers here.

When programming a ROM software, the usual way to wait for the end of the boot process so all the present devices are initialized is to use the HSTKE hook and wait to be called back when the MSX finishes it boot process. This is the way used by Konami games that have diskdrive support, like King's Valley-2 and Metal Gear-2.

But then there's a catch: It seems that you'll only have DiskBIOS v1 support this way. MSX-DOS2, or IDE/SD interfaces seem to be ignored.

The question is: Is there another way for a ROM cartridge to wait for the boot process so it can also have MSX-DOS2 devices support? But it must be compatible with computers without any MSX-DOS2 BIOS present too, of course.

Login or register to post comments

By NYYRIKKI

Enlighted (6033)

NYYRIKKI's picture

24-07-2013, 21:58

This approach kind of sucks, but I've not found a better way...

	org #4000

	defb "AB"
	defw start
	defw 0,0,0,0,0,0

HOOK:	EQU #FDC2		; Character get routine HOOK.

start:

      	DI
	LD 	A,#F7
	LD 	(HOOK),A

	IN 	A,(#A8)
	RRCA			;move it to bit 0,1 of [Acc]
	RRCA
	AND	00000011B
	LD	C,A
	LD	B,0
	LD	HL,#FCC1	;see if this slot is expanded or not
	ADD	HL,BC
	LD	C,A		;save primary slot #
	LD	A,(HL)		;See if the slot is expanded or not
	AND	80H
	OR	C		;set MSB if so
	LD	C,A		;save it to [C]
	INC	HL		;Point to SLTTBL entry
	INC	HL
	INC	HL
	INC	HL
	LD	A,(HL)		;Get what is currently output
				;to expansion slot register
	AND	00001100B
	OR	C		;Finally form slot address (SlotID)

	LD	(HOOK+1),A

	LD	HL,ROUTINE
	LD 	(HOOK+2),HL
	LD	A,#C9
	LD	(HOOK+4),A
	RET
	
ROUTINE:

	LD	A,(HOOK+1)
        LD	HL,#4000
        LD	E,L
        CALL	#14
        LD	HL,#C9C9
        LD	(HOOK),HL
        LD	(HOOK+2),HL
	.
	.
	.
	RET

By sd_snatcher

Prophet (3645)

sd_snatcher's picture

25-07-2013, 18:41

What a nifty way to do it. Very interesting! Smile

But I did some tests, and unfortunately that's not a good option. If there's a bootable disk on the drive, it will boot that disk instead. If the disk contains MSX-DOS(1/2), it will load the system (that will fiddle with a lot of things) and only then the ROM will be started.

I investigated the matter by debugging the boot process a little. It seems that indeed the HSTKE hook is the right one to use. I also discovered that the problem is being caused only on MSX Turbo-R, and the IDE BIOS adds insult to injury.

1) The MSX Turbo-R built-in MSX-DOS2 was modified to force the DiskBIOS1 when the HSTKE hook is used. They probably did this as an overcautious compatibility measure. Pressing "1" on boot would have had the same effect, without eliminating the possibility to use DOS2 on ROM programs. A bad decision from ASCII (or Panasonic, maybe).

2) Additionally, the IDE BIOS has no DiskBIOS1 support. As the Turbo-R is forcing the DiskBIOS1 for ROM cartridges, the IDE partition becomes inaccessible. But if I use a LPEMMCV8 the ROM cartridge can access the SDcard even on MSX Turbo-R.

Summarizing:

- Everything works fine with a MSX2/2+ and a MSX-DOS2 cartridge. Even when using the IDE.
- The IDE BIOS lacks support for DiskBIOS1. But this problem wouldn't ever be triggered on a MSX2/2+.
- The MSX Turbo-R forces DiskBIOS1 for cartridges. This causes the IDE disk to be inaccessible.
- Turbo-R works fine with cartridges that have both DiskBIOS1 and DiskBIOS2 support, like the LPEMMCV8.

By hit9918

Prophet (2927)

hit9918's picture

26-07-2013, 00:40

How about installing it to be callable with CALL?

I wonder whether the habit of enforced autostart does fit the nature of the expansion computer?
It is no console, I can think of doing something else with the MSX.
Then the enforced cartridge removal gets uncool.

Another example is wanting to use SCC and enforced start is the problem.

By NYYRIKKI

Enlighted (6033)

NYYRIKKI's picture

26-07-2013, 01:27

sd_snatcher wrote:

What a nifty way to do it. Very interesting! Smile

As I said, this approach kind of sucks (because of the reasons you already noticed) I only tried to debug the problem on MSX tR and I noticed that at least when you are using hooks, I could not find a better way... Maybe it would be possible to trick the MSX-DOS2 & IDE to start with custom load routine, but I didn't go that far in my investigation.

By NYYRIKKI

Enlighted (6033)

NYYRIKKI's picture

26-07-2013, 02:01

hit9918 wrote:

How about installing it to be callable with CALL?

Although this fights against the whole idea of game cartridges, I kind of like the idea... Today when the auto-start is not anymore a way to prevent copying I think this could be working idea between hobbyists.

How ever I think that even better one would be a common agreement something like "hold SELECT to skip game start". This way we would not dismiss Zemmix-users and we could still prevent at least some unnecessary cartridge handling.

By hit9918

Prophet (2927)

hit9918's picture

26-07-2013, 15:03

No autostart upon SELECT key, and then the game is still CALLable, very good.

Even a bit less console and more flexible computer style would be:
Only autostart when one of the three triggers is pressed. Space key or joystick fire button.
I.e. the inverse, need to press something to make autostart.

Like, what if the console got no SELECT key but expansions Big smile
Like a jukebox with disk autoexec to present a menu to pick one of the cartridges in the expander rack Smile