No graphical sub-ROM function working in MSX-DOS

ページ 1/2
| 2

By DarkSchneider

Paragon (1030)

DarkSchneider さんの画像

09-03-2023, 10:11

I am trying to use the sub-ROM graphical functions, specially the BLTVD, but for any "BLT" one I always get a "Syntax error in 0" or "Type mismatch in 0" or things like that.

My code for calling is this:
Header:

typedef struct {
	byte a;
	word hl, de, bc;
	byte f;
} CpuRegisters;

Code. The calling convention is passing parameters in stack from left to right. The "callee" means the function itself restores the stack.

#define EXPTBL 0xFCC1
#define CALSLT 0x001C

; void call_bios(address routine_address, CpuRegisters *registers) __smallc __z88dkcallee;
public _call_bios
_call_bios:
	; extract values
	pop bc ; ret
	pop iy ; IY = *registers
	pop ix ; IX = routine_address
	push bc ; ret
	call load_regs
	push iy
	ld iy, (EXPTBL - 1)
	call CALSLT
	pop iy
	call save_regs
	ret

; void call_subrom(address routine_address, CpuRegisters *registers) __smallc __z88dk_callee;
; wrapper for calsub
public _call_subrom
_call_subrom:
	; extract values
	pop bc ; ret
	pop iy ; IY = *registers
	pop ix ; IX = routine_address
	push bc ; ret
	call load_regs
	push iy ; save *registers index
	call calsub
	; copy return values
	pop iy ; restore *registers index
	call save_regs
	ret

load_regs:
	; copy values to registers
	ld a, (iy)
	ld l, (iy + 1)
	ld h, (iy + 2)
	ld e, (iy + 3)
	ld d, (iy + 4)
	ld c, (iy + 5)
	ld b, (iy + 6)
	ret

save_regs:
	; copy registers to memory
	ld (iy), a
	ld (iy + 1), l
	ld (iy + 2), h
	ld (iy + 3), e
	ld (iy + 4), d
	ld (iy + 5), c
	ld (iy + 6), b
	push af ; save F
	pop bc
	ld (iy + 7), c
	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.
;
;#define CALSLT 0x001C
#define NMI 0x0066
#define EXTROM 0x015f
;#define EXPTBL 0xfcc1
#define H_NMI 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,
         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  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

I think the parameters are located properly (many times I reverse them because the little/big Endian...).
Tested with many other BIOS and sub-ROM functions, and seems to work fine. Tested with:
- Functions without parameters, like INIPLT or TOTEXT.
- Functions with parameter in A, like CHGMOD or CHGMDP.
- Functions with parameter in HL, like NRDVRM.
- Functions reading parameters from RAM, like INITXT.
All works fine.
But any graphical one don't work, tested with:
NVBXLN, NVBXFL: does nothing.
BLTMD, BLTVD: the "Syntax error 0" message.
More interesting about getting that message because I change to SC5 (with CHGMOD) before using them, so don't know how it writes it.

ログイン/登録して投稿

By Jipe

Paragon (1625)

Jipe さんの画像

09-03-2023, 10:25

have you missing parameters
000C9H NVBXLN
Nom : NVBXLN
Adresse : 000C9H/SUBROM
Type : MSX2
Rôle : tracé d'un rectangle à l'écran
Entrée :
BC - abscisse du pixel de départ
DE - ordonnée du pixel de départ
GXPOS - abscisse du pixel d'arrivée
GYPOS - ordonnée du pixel d'arrivée
ATRBYT - couleur à utiliser
LOGOPR - opérateur logique à appliquer

0FCB3H GXPOS 2 Abscisse du curseur graphique
0FCB5H GYPOS 2 Ordonnée du curseur graphique
0F3F2H ATRBYT 1
0FAB2H LOGOPR 1 « LOGical OPeration code », mode de tracé : 0 pour IMP, 1 pour
AND, 2 pour OR, 3 pour XOR, 4 pour NOT

By DarkSchneider

Paragon (1030)

DarkSchneider さんの画像

09-03-2023, 10:36

Yes I put all RAM parameters according to this manual:
https://www.konamiman.com/msx/msx2th/th-ap.txt

Noticed that for the "box" ones mismatched one (probably because copy-paste lines), and now works. But revised the BLT ones and continues with "Type mismatch in 0".

By gdx

Enlighted (6449)

gdx さんの画像

09-03-2023, 10:37

Try this routine :

; Routine to call a Sub-ROM routine under MSX-DOS
;
; Entry: Parameters of the routine to call
;        IX = Address of the routine to call into Sub-ROM

CalSUB:
	push	af
	ld	a,(EXBRSA)
	ld	(CalSUBslt),a	; Set slot number
	push	ix
	ex	(sp),hl
	ld	a,l
	ld	(CalSUBadrs),a	; Set low byte of the routine address
	ld	a,h
	ld	(CalSUBadr+1),a	; Set high byte of the routine address
	ex	(sp),hl
	pop	ix		
	pop	af		
	rst	030h		; Inter slot call
CalSUBslt:
	db	0		; Slot number
CalSUBadrs:
	dw	0		; Address
	ret

By DarkSchneider

Paragon (1030)

DarkSchneider さんの画像

09-03-2023, 10:53

Same "type mismatch in 0". I use the official ASCII one so it should work.
Seems to be a problem of some parameter, I pass this:

	memcpy((void *)0x8000, "OPENI001.SH5", 13);
	*((word*)0xf562) = 0x8000;
	*((word*)0xf566) = 0;
	*((word*)0xf568) = 0;
	*((byte*)0xf56f) = 0;
	*((byte*)0xf570) = 0x0b; // <- could be this one?
	regs.hl = 0xf562;
	call_subrom(0x019d, &regs);

The LOGOP (f570) maybe? It says

引用:

logical operation code (same as the logical operation code of VDP)

But the VDP includes the command itself, and there is no one for disk. The 0b is the last tested, also tested with many others.

The file I use is one created manually with hex editor, starting with NX, NY (4-bytes) then NX * NY dots of data.

Also, the program freezes and the disk keeps spinning.

This is the sub-ROM function:

引用:

* BLTVD (019DH/SUB)

Function: transfers from disk to VRAM

Input: HL register <-- F562H
The following parameters should be set:

* FNPTR (F562H, 2) address of the filename
* DUMMY (F564H, 2) dummy (not required to be set)
* DX (F566H, 2) X-coordinate of the destination
* DY (F568H, 2) Y-coordinate of the destination
* NX (F56AH, 2) number of dots in the X direction
(not required to be set; this is
already in the top of data to be
transferred)
* NY (F56CH, 2) number of dots in the Y direction
(not required to be set; this is
already in the top of data to be
transferred)
* CDUMMY (F56EH, 1) dummy (not required to be set)
* ARG (F56FH, 1) selects the direction and expansion
RAM (same as VDP R#45)
* LOGOP (F570H, 1) logical operation code (same as the
logical operation code of VDP)

Output: the CY flag is set when there is an error in the parameter

Registers: all

By DarkSchneider

Paragon (1030)

DarkSchneider さんの画像

09-03-2023, 11:59

Well found the problem: seems we cannot use 8.3 file format, only subtracting one to 7.3 format works. Also the filename must include the "" (redundant).
So we have to define the filename like i.e. in C:
"\"file.sh5\""
With escaping the \" to put into the string. Also take care of file name size not reaching the 8.3 format.

Could be because the data area:

引用:

FILNAM (F866H, 11)
contents: area to store filename

So it can store up to 11 characters, including the '.' the 8.3 are 12.

Bad news also found that only works when in bitmap mode, even with LOGOP to 0 for RAW copy. So I think I'll use my own for reading RAW data.

By Grauw

Ascended (10824)

Grauw さんの画像

09-03-2023, 14:25

Should it not be

"file    sh5"

then? So, omit point and pad with spaces.

By gdx

Enlighted (6449)

gdx さんの画像

09-03-2023, 14:55

I think the Sub-ROM can manage files in the Basic environment only. It may be possible to use them by hijacking the error handling. Anyway, it seems that information is missing to use them.

PS: The routine I give works just as well as the "official" one.

By DarkSchneider

Paragon (1030)

DarkSchneider さんの画像

09-03-2023, 15:10

Grauw wrote:

Should it not be

"file    sh5"

then? So, omit point and pad with spaces.

Didn’t tried but point or space we have 11 characters length. While we put the filename between quotes and is up to 11 length it should work.
I think too it uses the BASIC “style”, and probably uses the BASIC handling, that could be the reason for that limit, as the space at data area reserved are 11 bytes.
Anyway it will only works while in bitmap mode then don’t fit in my usage Crying

By gdx

Enlighted (6449)

gdx さんの画像

09-03-2023, 15:27

I think you misjudge the problem. I tried under Basic and i get also a Syntax Error. Routine should be poorly documented.

By DarkSchneider

Paragon (1030)

DarkSchneider さんの画像

09-03-2023, 17:11

Well I made it to work, simply renaming the file to 7.3 max length, putting it surrounded by quotes, and setting ARG and LOGOP both to 0.
The filename string in C is something like
filename = “\”img1.sh5\””;
And then it works if called while in SCREEN 5 mode.

ページ 1/2
| 2