HELP needed - issues with H.STKE hook.

Página 1/3
| 2 | 3

Por max_iwamoto

Hero (528)

imagem de max_iwamoto

19-08-2021, 17:33

Hello!

I have a small issue with H.STKE hook. I am using it to initialize DISK ROM after my ROM started and then to get control of my ROM back.

Here is the code:

	DI
	CALL	RSLREG
	RRCA
	RRCA
	AND	%00000011
	LD	B,A
	LD	HL,EXPTBL
	ADD	A,L
	LD	L,A
	LD	C,(HL)
	INC	L
	INC	L
	INC	L
	INC	L
	LD	A,(HL)
	AND	%00001100
	OR	B
	OR	C
	LD	(F0F8h),A

	LD	H,A
	LD	L,F7h		; RST 30h
	LD	(H.STKE),HL
	LD	HL,START_2
	LD	(H.STKE+2),HL
	RET

START_2:

Everything works fine, except that my ROM executed twice. The ROM starts, then I initialize H.STKE and return back from the ROM. Then my ROM starts again, executes the same code as 1st time, initializes HSTKE again, and, on 3rd time it comes to START_2 from H.STKE hook. So, the question is - why ROM starts twice and how to prevent it from happening. I checked other similar programs and they work fine (one ROM execution and then hook). It really puzzles me. Hope somebody have an idea on why this is happening.

Entrar ou registrar-se para comentar

Por zeilemaker54

Champion (311)

imagem de zeilemaker54

19-08-2021, 18:32

Are you having this issue with a real MSX or OpenMSX ?

Por MsxKun

Paragon (1030)

imagem de MsxKun

19-08-2021, 18:44

I think you could be missing this before the last RET

LD A,$C9
LD (H.STKE+4),A

At least, I always used that and don't have that problem.

Por NYYRIKKI

Enlighted (5873)

imagem de NYYRIKKI

19-08-2021, 18:44

This is what ROM mirroring causes... Usually this means that you should be using /CE1 or /CE2 instead of /CE12 signal... If you look for a software solution, please try adding this code to beginning of your cartridge init routine:

	LD A,#40
	CP H
	RET Z

Por zeilemaker54

Champion (311)

imagem de zeilemaker54

19-08-2021, 19:05

NYYRIKKI wrote:

This is what ROM mirroring causes... Usually this means that you should be using /CE1 or /CE2 instead of /CE12 signal... If you look for a software solution, please try adding this code to beginning of your cartridge init routine:

	LD A,#40
	CP H
	RET Z

That is why I asked if it is on a real MSX or in OpenMSX.
OpenMSX does ROM mirroring (which is wrong in my opinion) on homebrewed 16KB ROMs, I have raised this already with the OpenMSX in the past:
https://github.com/openMSX/openMSX/issues/1309

By the way, I am not a fan of promoting the use of the undocumented register HL of the ROM initialize routine in your code example.

Por Grauw

Ascended (10056)

imagem de Grauw

19-08-2021, 19:23

zeilemaker54 wrote:

OpenMSX does ROM mirroring (which is wrong in my opinion) on homebrewed 16KB ROMs, I have raised this already with the OpenMSX in the past: https://github.com/openMSX/openMSX/issues/1309

By the way, I am not a fan of promoting the use of the undocumented register HL of the ROM initialize routine in your code example.

I totally agree.

Por Manuel

Ascended (18131)

imagem de Manuel

19-08-2021, 19:30

If you want a certain wiring of your ROM cartridge emulated, better explicitly specify the corresponding mapper type.

Por zeilemaker54

Champion (311)

imagem de zeilemaker54

19-08-2021, 22:38

Manuel wrote:

If you want a certain wiring of your ROM cartridge emulated, better explicitly specify the corresponding mapper type.

Of course that is a solution, but as stated I do not agree to the OpenMSX default of mirroring a 16 KB ROM.
A normal cartridge with a 16KB ROM is wired to CS1 (page 1) or CS2 (page 2) and is therefore not mirrored.
Of course there are cartridges which are wired differently (not using CS1 or CS2), but they are the minority. And those need a specified mapper type. And may be those could be added to the softwaredb.xml or have their own extension xml, making OpenMSX select the correct mappertype and mirroring.

Por max_iwamoto

Hero (528)

imagem de max_iwamoto

20-08-2021, 03:27

Thank you, everybody, for fast response.

Here are the answers to the questions:

zeilemaker54 wrote:

Are you having this issue with a real MSX or OpenMSX ?

I tested on blueMSX and openMSX (17.0). Same results.

---

MsxKun wrote:

I think you could be missing this before the last RET

LD A,$C9
LD (H.STKE+4),A

At least, I always used that and don't have that problem.

I didn't use it, because the area was already populated with C9h (RET) when ROM was executed.

---

NYYRIKKI wrote:

This is what ROM mirroring causes... Usually, this means that you should be using /CE1 or /CE2 instead of /CE12 signal... If you look for a software solution, please try adding this code to the beginning of your cartridge init routine:

	LD A,#40
	CP H
	RET Z

This code helps, indeed. It runs with HL = 4004h and then with 8004h...

---

I will check on real MSX in a few days.

---

Another interesting thing is when I test Shalom that uses a similar method, it doesn't come back to the ROM twice. It uses Konai mapper, obviously. I am using ASCII 16 mapper. Could that be the case? Or maybe because ROM is unknown compare to Shalom?

---

One more question... If I start code in my ROM from 4004h, it hangs. If I use 4010h as ROM start, everything is fine...

Por max_iwamoto

Hero (528)

imagem de max_iwamoto

20-08-2021, 05:35

One more thing... When I originally read about mirrored ROM, I checked and my ROM size was 64KB. So, possibly, the emulator would see it as a mirrored ROM... I changed ROM size to 128KB and it didn't make any difference.

I also tried to force mapper type to ASCII 16 or use "guess ROM type" option and still no changes.

Por zeilemaker54

Champion (311)

imagem de zeilemaker54

20-08-2021, 07:09

max_iwamoto wrote:

One more question... If I start code in my ROM from 4004h, it hangs. If I use 4010h as ROM start, everything is fine...

That is because 4004H (STATEMENT) should contain the pointer to the CALL statement handler in ROM.
This link will explain.

Página 1/3
| 2 | 3