calling the msx2 subrom from msxdos

Página 1/2
| 2

Por ARTRAG

Enlighted (6923)

Imagen del ARTRAG

21-11-2010, 21:21

I was trying to call the COLOR RESTORE subroutine from msxdos

I have adapted to my purpose this code from tni-map

RSTPLT  EQU    0x0145		; Restores palette from VRAM


		global _restore

_restore:
		push	ix
		push	iy
		ld	ix,RSTPLT
		call CALSUB
		pop		iy
		pop		ix
		ret

; CALSUB
;
; In: IX = address of routine in MSX2 SUBROM
;     AF, HL, DE, BC = parameters for the routine
;
; Out: AF, HL, DE, BC = depending on the routine
;
; Changes: IX, IY, AF', BC', DE', HL'
;
; Call MSX2 subrom from MSXDOS. Should work with all versions of MSXDOS.
;
; Notice: NMI hook will be changed. This should pose no problem as NMI is
; not supported on the MSX at all.
;
CALSLT  EQU    0x001C
NMI     EQU    0x0066
EXTROM  EQU    0x015f
EXPTBL  EQU    0xfcc1
H_NMI   EQU    0xfdd6

		
CALSUB:  
		 exx
         ex     af,af'       ; store all registers
         ld     hl,EXTROM
         push   hl
         ld     hl,0xC300
         push   hl           ; push NOP ; JP EXTROM
         push   ix
         ld     hl,0x21DD
         push   hl           ; push LD IX,<entry>
         ld     hl,0x3333
         push   hl           ; push INC SP; INC SP
         ld     hl,0
         add    hl,sp        ; HL = offset of routine
         ld     a,0xC3
         ld     (H_NMI),a
         ld     (H_NMI+1),hl ; JP <routine> in NMI hook
         ex     af,af'
         exx                 ; restore all registers
         ld     ix,NMI
         ld     iy,(EXPTBL-1)
         call   CALSLT       ; call NMI-hook via NMI entry in ROMBIOS
                             ; NMI-hook will call SUBROM
         exx
         ex     af,af'       ; store all returned registers
         ld     hl,10
         add    hl,sp
         ld     sp,hl        ; remove routine from stack
         ex     af,af'
         exx                 ; restore all returned registers
         ret

But sadly it seems that CALSUB has no effect.
I changed CALLSLT to CALSLT assuming it was a type in the source
as CALLSLT was undefined. Nevertheless it coninues to hang...

Any idea or workaround?
I just need to restore palette from a screen 5 image.

Login sesión o register para postear comentarios

Por Leo

Paragon (1236)

Imagen del Leo

21-11-2010, 21:58

i think you are correct fir the typo if i look : http://msxbanzai.tni.nl/dev/faq.html

it seems you forgot ld iy,(EXPTBL-1) before first call

i look in :
http://map.grauw.nl/sources/callbios.php

look for the very first lines for invoking the subroutine

Por RetroTechie

Paragon (1563)

Imagen del RetroTechie

21-11-2010, 23:06

Interslot-call to main ROM to call subROM, and (ab)using NMI entry point... hmm ugly! Smile2 Why not call MSX2 subROM directly?

From MSX2 Technical Handbook: EXBRSA (EXtended Bios Rom Slot Address?) = FAF8h = SUB-ROM slot address. I suppose you should be able to work it out from there.

Por ARTRAG

Enlighted (6923)

Imagen del ARTRAG

22-11-2010, 00:09

i think you are correct fir the typo if i look : http://msxbanzai.tni.nl/dev/faq.html

it seems you forgot ld iy,(EXPTBL-1) before first call

i look in :
http://map.grauw.nl/sources/callbios.php

look for the very first lines for invoking the subroutine

the code comes from there and the IY seems exactily set as there

Por ARTRAG

Enlighted (6923)

Imagen del ARTRAG

22-11-2010, 00:15

from tni map site

You can’t call the SUBROM from MSX-DOS as you would normally, the reason for this is that both EXTROM and CALSLT use the IX register to pass parameters. Calling directly to the SUBROM doesn’t work either, because using an interslot call to call the SUBROM is not allowed per the MSX2 standard. The reason for this, according to Alex Wulms in MCM 48, is that some DiskROMs couldn’t handle the the SUBROM being in page 0.

Por ARTRAG

Enlighted (6923)

Imagen del ARTRAG

22-11-2010, 08:48

solved! My fault

Por Leo

Paragon (1236)

Imagen del Leo

22-11-2010, 10:00

what is the solution then , just curious ?

Por RetroTechie

Paragon (1563)

Imagen del RetroTechie

22-11-2010, 11:55

using an interslot call to call the SUBROM is not allowed per the MSX2 standard. The reason for this, according to Alex Wulms in MCM 48, is that some DiskROMs couldn’t handle the the SUBROM being in page 0.
"Citation needed" - what official reference doc sez so, and where?

When calling subROM via CALSLT (from a .com program), @what time is a diskROM paged in? Only possibility I can think of, is a diskROM that sets an interrupt hook, interrupt occurs during interslot-call while subROM routine is executing, and diskROM interrupt-code does something stupid. Which is unlikely to say the least: CALSLT disables interrupts (and BIOS routines that access the VDP probably too), so time window would be if subROM routine re-enables interrupts, but before returning from the interslot-call. And diskROM interrupt-code is usually short & just updates counters or maybe checks an FDC register.

Apart from standard or whether it could cause problems: what would CALSLT called from a .com program do, that interslot-call from BIOS to subROM would not do? Question

Por ARTRAG

Enlighted (6923)

Imagen del ARTRAG

22-11-2010, 20:49

what is the solution then , just curious ?

The problem in the end was that color restore routine expects the active page be set in the BIOS ram area
The CALSUB code, once fixed the typo, works fine.

Por ARTRAG

Enlighted (6923)

Imagen del ARTRAG

22-11-2010, 20:50

using an interslot call to call the SUBROM is not allowed per the MSX2 standard. The reason for this, according to Alex Wulms in MCM 48, is that some DiskROMs couldn’t handle the the SUBROM being in page 0.
"Citation needed" - what official reference doc sez so, and where?

When calling subROM via CALSLT (from a .com program), @what time is a diskROM paged in? Only possibility I can think of, is a diskROM that sets an interrupt hook, interrupt occurs during interslot-call while subROM routine is executing, and diskROM interrupt-code does something stupid. Which is unlikely to say the least: CALSLT disables interrupts (and BIOS routines that access the VDP probably too), so time window would be if subROM routine re-enables interrupts, but before returning from the interslot-call. And diskROM interrupt-code is usually short & just updates counters or maybe checks an FDC register.

Apart from standard or whether it could cause problems: what would CALSLT called from a .com program do, that interslot-call from BIOS to subROM would not do? Question

As I told the citation is from tni map website:
http://map.grauw.nl/sources/callbios.php

Por RetroTechie

Paragon (1563)

Imagen del RetroTechie

22-11-2010, 22:19

While I have no doubt about Alex Wulms' knowledge, he is not an official reference. Neither am I or anyone else on this forum. That's why I asked about official doc on this topic.

The other question also still stands: what makes interslot-call from BIOS to subROM different from 'direct' interslot-call? Question In both cases you would have RAM in page 1, the subROM in page 0 during execution of the subROM routine, interrupts disabled @start of that routine, and (possibly) re-enabled when that routine is done. If a diskROM can cause trouble with subROM in page 0, it would also apply when called via the BIOS, since the subROM has to be in page 0 sometime if any of its code is to be called. Therefore it only seems logical to cut the main BIOS ROM out of the call procedure.

Página 1/2
| 2