Best way to init SP (ROM)?

Page 2/3
1 | | 3

By SjaaQ

Master (215)

SjaaQ's picture

24-07-2020, 12:26

What system? I don't use the BIOS. Also, if MSX computers do not use IM2 how come it works? The NOP Mod Player v2 switches between IM2 and IM1 (IM2 while playing and IM1 while loading). I guess you mean IM0.

By NYYRIKKI

Enlighted (5837)

NYYRIKKI's picture

24-07-2020, 12:31

SjaaQ wrote:

In DotAttack, I use IM2 and do a LD SP,#FFFE. No byte to waste!

Exactly a byte wasted, LOL. To fix this, you need to use LD SP,#FFFF instead. Smile

Quote:

Also, if MSX computer do not use IM2 how come it works?

It works only, if you take all possibilities (random values) in to consideration. It works also with less hassle if your databus is pulled up, but not all MSX computers do that. The fact that MSX computers don't support that in any way does not mean that programmers don't (ab)use it. Smile

By SjaaQ

Master (215)

SjaaQ's picture

24-07-2020, 12:44

NYYRIKKI wrote:
SjaaQ wrote:

In DotAttack, I use IM2 and do a LD SP,#FFFE. No byte to waste!

Exactly a byte wasted, LOL. To fix this, you need to use LD SP,#FFFF instead. Smile

What about the memory mapper at FFFF? I cannot use that byte for SP.

Quote:
Quote:

Also, if MSX computer do not use IM2 how come it works?

It works only, if you take all possibilities (random values) in to consideration. It works also with less hassle if your databus is pulled up, but not all MSX computers do that. The fact that MSX computers don't support that in any way does not mean that programmers don't (ab)use it. Smile

I have a 256 byte table to deal with the databus problem (ok 256 bytes wasted). It contains something like #C1 for every byte so the pointer to the address will always be #C1C1. I have a Toshiba HX20 that does not have a pullup so I came across that problem (and OpenMSX does not emulate that yet).

By gdx

Enlighted (4629)

gdx's picture

24-07-2020, 12:59

Z80 has the IM2 mode but it is not used by the MSX standard, same for undocumented opcodes. Other examples: V9938 can have 192kB, handle a mouse and light pen but these functions are not in the MSX standard. Obviously, we can use them in some cases but it is not standard and it may not work in more or less cases.

By Guillian

Prophet (3447)

Guillian's picture

24-07-2020, 12:53

SjaaQ wrote:
NYYRIKKI wrote:
SjaaQ wrote:

In DotAttack, I use IM2 and do a LD SP,#FFFE. No byte to waste!

Exactly a byte wasted, LOL. To fix this, you need to use LD SP,#FFFF instead. Smile

What about the memory mapper at FFFF? I cannot use that byte for SP.

NYYRIKKI is right. The addresses used after pushing to the stack will be #FFFE-#FFFD

By NYYRIKKI

Enlighted (5837)

NYYRIKKI's picture

24-07-2020, 13:04

SjaaQ wrote:
NYYRIKKI wrote:
SjaaQ wrote:

In DotAttack, I use IM2 and do a LD SP,#FFFE. No byte to waste!

Exactly a byte wasted, LOL. To fix this, you need to use LD SP,#FFFF instead. Smile

What about the memory mapper at FFFF? I cannot use that byte for SP.

Logically ie. PUSH HL is
DEC SP
LD (SP),H
DEC SP
LD (SP),L

The address is decrement before write, so subslot handling is not affected.

Quote:

I have a 256 byte table to deal with the databus problem (ok 256 bytes wasted). It contains something like #C1 for every byte so the pointer to the address will always be #C1C1.

Off by one again. Smile You need to have 257 byte table in order to handle all possibilities since the address is 16bit.

By zeilemaker54

Champion (309)

zeilemaker54's picture

24-07-2020, 16:35

FFFE is in a reserved area. Not allowed according the MSX standard

By SjaaQ

Master (215)

SjaaQ's picture

24-07-2020, 16:38

zeilemaker54 wrote:

FFFE is in a reserved area. Not allowed according the MSX standard

Too bad peanutbutter.

	ld hl,#fe00
	ld de,#fe01
	ld bc,#100
	ld (hl),#fd	;address will be #fdfd
	ldir

By gdx

Enlighted (4629)

gdx's picture

24-07-2020, 16:48

Playsoniq cartridge use FFFEh to expand the memory mapper size.

By SjaaQ

Master (215)

SjaaQ's picture

24-07-2020, 16:55

gdx wrote:

Playsoniq cartridge use FFFEh to expand the memory mapper size.

Looks like somebody else does not keep it to the standard.

Meh as long as it works.

Page 2/3
1 | | 3