CALL handler on page 3

By NYYRIKKI

Enlighted (5385)

NYYRIKKI's picture

16-08-2018, 13:16

I've tried to repeat to my self over and over again "Assuming things is dangerous. When you start assuming you may get the facts wrong. Long lasting assumptions that are not proven wrong tend to change in to facts inside human head."

Yet once again I found that I've had such assumption in my head:

I've known for a long time that although the actual program can be on any memory area, the ROM-header must be located in page 1 or 2 in order for cartridge to boot... and this is correct... but for some weird reason I've also assumed that this same rule applies to all of the things in the 16-byte header including call command handler... and this seems to be false.

It seems that this is 100% valid CALL-command handler:


        OUTPUT "X.BIN"
        
        ; USAGE:
        ; BLOAD"X.BIN",R
        ; CALL X == CLS

        DB #FE
        DW BEGIN,END,START

        ORG     #C004
BEGIN:
        DW CALLHAND
START:
        LD A,(#F344)
	AND A
	JP M,.SKIP
	AND 3
.SKIP
	AND 15
	LD E,A
	RLCA
	RLCA
	RLCA
	RLCA
	OR E
	AND 60
	LD D,0
	LD E,A
	LD HL,#FCCC
	ADD HL,DE
	SET 5,(HL)
	RET

CALLHAND:

        PUSH HL
        LD HL,#FD89
        LD A,(HL)
        CP "X"
        JR NZ,.NOTFORME
        INC HL
        LD A,(HL)
        AND A
        JR NZ,.NOTFORME
        CALL #C3 ;CLS
        POP HL
        AND A
        RET
        
.NOTFORME
	POP	HL
        SCF
	RET
END:

My main questions are:

- Was I the only one around with this assumption?
- Are there even some real life BASIC extensions that use this possibility?

Login or register to post comments

By sd_snatcher

Prophet (3068)

sd_snatcher's picture

16-08-2018, 16:41

AFAIK, this only works for call handlers in *RAM*, thus only those that self-installed themselves on SLTATR *after* the boot. This method is not different than capturing hooks for any other type of extension.

It shouldn't be possible to build a real ROM cartridge the normal way, with CALL handlers in the frame-3 on its header, so when booting, the system would find its ROM-headers and fill the SLTATR entry itself. Have you tried this possibility?

By NYYRIKKI

Enlighted (5385)

NYYRIKKI's picture

16-08-2018, 17:52

sd_snatcher wrote:

AFAIK, this only works for call handlers in *RAM*

Interesting question... I'm not sure that RAM is requirement, but this might be very hard to implement on ROM -> Needs more investigation.

Quote:

only those that self-installed themselves on SLTATR *after* the boot.

When the activation is done is not critical, but indeed this method requires external code to be activated.

Quote:

This method is not different than capturing hooks for any other type of extension.

Yes it is... Normally MSX hooks are always active and require you to implement a jump code. These require activation and pointer instead of direct code.

Quote:

It shouldn't be possible to build a real ROM cartridge the normal way, with CALL handlers in the frame-3 on its header, so when booting, the system would find its ROM-headers and fill the SLTATR entry itself. Have you tried this possibility?

No, I have not tried this, but I've read trough the boot process in the past. From that I can say that I agree with your reasoning: This should not be possible.

By sd_snatcher

Prophet (3068)

sd_snatcher's picture

16-08-2018, 19:22

NYYRIKKI wrote:
Quote:

This method is not different than capturing hooks for any other type of extension.

Yes it is... Normally MSX hooks are always active and require you to implement a jump code. These require activation and pointer instead of direct code.

I mean from the point of view of the algorithm, not the minor technical details of how the jumps are implemented.

1) Hooks: the user-software has to capture the entry points itself

2) Normal SLTATR use: the system itself searches for the ROM headers on boot and fill the necessary entries for CALL and DEVICE extensions. No similar search is performed for the hooks.

By NYYRIKKI

Enlighted (5385)

NYYRIKKI's picture

16-08-2018, 20:41

sd_snatcher wrote:

I mean from the point of view of the algorithm, not the minor technical details of how the jumps are implemented.

Hmm... If we want to split hairs, there is also difference on return... Hooks don't expect any return values, while CALL handling expects value in CF flag... These are anyway too little difference to get real conversation going on. Smile

By Manel46

Champion (431)

Manel46's picture

16-08-2018, 20:47

There are also roms with the header on page 0, such as "CRAZY TRAIN".
There are some more, I remember.
In fact, this is a 16 kbs rom, which works on page 0.