[MSX-C] Q&A official thread

Page 17/57
10 | 11 | 12 | 13 | 14 | 15 | 16 | | 18 | 19 | 20 | 21 | 22

By AxelStone

Prophet (3064)

AxelStone's picture

13-09-2015, 10:03

The assembly code calls an extern function:

...
loadsc:
	push	af
	push	bc
	push	bc
	push	bc
	ld	hl,7
	add	hl,sp
	ld	(hl),a
	call	disscr
	xor	a
	ld	hl,0
	add	hl,sp
	ld	(hl),a
@10:
	cp	13
	jp	nc,@5
	ld	e,0
	push	af
@9:
	ld	a,e
	cp	16
	jp	nc,@6
	ld	hl,9
	add	hl,sp
	ld	a,(hl)
	ld	b,a
	ld	c,0
	ld	hl,2
	add	hl,sp
	ld	a,(hl)
	push	af
	add	a,a
	add	a,a
	add	a,a
	add	a,a
	add	a,e
	ld	l,a
	ld	h,0
	add	hl,bc
	ld	bc,stage@
	add	hl,bc
	ld	a,(hl)
	pop	bc
	ld	c,b
	ld	b,0
	ld	l,e
	ld	h,0
	add	hl,hl
	add	hl,hl
	add	hl,hl
	add	hl,hl
	add	hl,bc
	push	bc
	ld	bc,pantal
	add	hl,bc
	ld	(hl),a
	pop	bc
	ld	b,0
	ld	l,e
	ld	h,0
	add	hl,hl
	add	hl,hl
	add	hl,hl
	add	hl,hl
	add	hl,bc
	push	hl
	ld	hl,4
	add	hl,sp
	ld	(hl),c
	pop	hl
	ld	bc,pantal
	add	hl,bc
	push	de
	ld	a,(hl)
	ld	hl,4
	add	hl,sp
	ld	c,(hl)
	or	a
	jp	nz,@7
	ld	hl,4
	add	hl,sp
	ld	(hl),c
	ld	c,8
	push	bc
	ld	c,0
	push	bc
	ld	hl,8
	add	hl,sp
	ld	c,(hl)
	ld	l,c
	ld	h,0
	add	hl,hl
	add	hl,hl
	add	hl,hl
	add	hl,hl
	push	hl
	ld	l,e
	ld	h,0
	add	hl,hl
	add	hl,hl
	add	hl,hl
	add	hl,hl
	push	hl
	ld	c,1
	push	bc
	ld	bc,159
	push	bc
	ld	bc,255
	ld	de,144
	ld	hl,240
	call	cpyv2v <-- Calling cpyv2v
	pop	bc
	pop	bc
	pop	bc
	pop	bc
	pop	bc
	pop	bc
	jp	@8
@7:
	push	af
	dec	a
	and	15
	ld	l,a
	ld	h,0
	add	hl,hl
	add	hl,hl
	add	hl,hl
	add	hl,hl
	pop	af
	dec	a
	rrca
	rrca
	rrca
	rrca
	and	15
	push	de
	call	?saut7
	pop	de
	ld	l,a
	ld	h,0
	add	hl,hl
	add	hl,hl
	add	hl,hl
	add	hl,hl
	push	hl
	ld	hl,6
	add	hl,sp
	ld	(hl),c
	pop	hl
	ld	c,8
	push	bc
	ld	c,0
	push	bc
	push	de
	call	?sauhl
	defw	13+2
	pop	de
	ld	hl,8
	add	hl,sp
	ld	c,(hl)
	ld	l,c
	ld	h,0
	add	hl,hl
	add	hl,hl
	add	hl,hl
	add	hl,hl
	push	hl
	ld	l,e
	ld	h,0
	add	hl,hl
	add	hl,hl
	add	hl,hl
	add	hl,hl
	push	hl
	ld	c,1
	push	bc
	ld	hl,17
	add	hl,sp
	ld	e,(hl)
	inc	hl
	ld	d,(hl)
	ld	hl,15
	add	hl,de
	push	hl
	push	de
	call	?lauhl
	defw	19+2
	pop	de
	push	hl
	ld	bc,15
	add	hl,bc
	ld	c,l
	ld	b,h
	pop	hl
	call	cpyv2v
	pop	bc
	pop	bc
	pop	bc
	pop	bc
	pop	bc
	pop	bc
@8:
	pop	de
	inc	e
	jp	@9
@6:
	pop	af
	inc	a
	ld	hl,0
	add	hl,sp
	ld	(hl),a
	jp	@10
@5:
	call	enascr
	pop	bc
	pop	bc
	pop	bc
	pop	bc
	ret
...
...
	extrn 	ldirvm
	extrn 	cpyv2v
...

I don't see any trace of LMMM function in ASM code.

By DarkSchneider

Paladin (942)

DarkSchneider's picture

13-09-2015, 10:10

The ASM code of cpyv2v. To see how it puts the parameters like logop.

By AxelStone

Prophet (3064)

AxelStone's picture

13-09-2015, 10:29

There is no trace of cpyv2v in .MAC, .SYM or .REL, it's declared as extern so I suposse ir must be located in some external file, I'll find in libs.

P.D.: nothing too, GLIB.SYM is a binary file and GLIB.TCO only contains this:

Xcpyv2v	C	F	E
P90	N
P91	N
P92	N
P93	N
P94	C
P95	N
P96	N
P97	C
P98	C
{
}

I have no idea of the meaning of this. Where could be defined the source code of cpyv2v?

By anonymous

incognito ergo sum (116)

anonymous's picture

13-09-2015, 10:50

AxelStone wrote:

There is no trace of cpyv2v in .MAC, .SYM or .REL, it's declared as extern so I suposse ir must be located in some external file, I'll find in libs.

P.D.: nothing too, GLIB.SYM is a binary file and GLIB.TCO only contains this:
[...]

The TCO file is used to tell FPC what kind of parameters are accepted by the function. It's not intended to be read by us humans. :-)

AxelStone wrote:

I have no idea of the meaning of this. Where could be defined the source code of cpyv2v?

cpyv2v() is part of MSX-C Library. The source code is in GLIB.MAC:

Why do you need to look at the code? What problems are you having with it?

By AxelStone

Prophet (3064)

AxelStone's picture

13-09-2015, 11:18

As @DarkSchneider mentioned, I'm not sure that logop 8 is working in it's way. This is, if I use logop=8 the upstairs shouldn't take the color of whatever was drawn under them as we can see in your animated GIF. Or is this the correct behaivour?

By the way, very interesting this point of the function:

;
;	see if we can use high speed move
;
	ld	b,a			; set byte boundary flag in b
	pop	hl			; restore logical operation code in h
	pop	de			; restore source x start
	ld	a,h			; logical operation specified?
	and	a
	jr	nz,vv_logical		; yes, move logically
	ld	a,(SCRMOD)
	cp	8			; screen 8?
	jr	z,vv_hs 		; yes, always use high speed
	cp	6			; screen 6?
	jr	z,vv_check_4		; yes, check lower 2 bits
	ld	a,b			; on byte boundary?
	rrca
	jr	nc,vv_hs		; yes, use high speed move
	jr	vv_logical		; no, use logical move

It checks if can use high speed move Shocked!

By anonymous

incognito ergo sum (116)

anonymous's picture

13-09-2015, 11:24

AxelStone wrote:

As @DarkSchneider mentioned, I'm not sure that logop 8 is working in it's way. This is, if I use logop=8 the upstairs shouldn't take the color of whatever was drawn under them as we can see in your animated GIF. Or is this the correct behaivour?

According to the MSX2 Technical Handbook it IS the correct behaviour:

TIMP always ignores color 0 when copying, regardless of the contents of VDP register 8. The meaning of register 8 is not related to this:

Bit 5 = 0 means that color #0 will always be transparent (equal to the border color)
Bit 5 = 1 means that color #0 will use the value entered in the palette registers (will have its own color)

By AxelStone

Prophet (3064)

AxelStone's picture

13-09-2015, 11:36

@JaviLM Then doubt solved, once more thanks for the info Wink . Let's go for another question.

Question: How to read VDP status register? We have the following table:

   Table 4.2  Status register list

-----------------------------------------------------------------------------
|      | Corres- |							    |
| S#n  | ponding |			  Function			    |
|      | VDP(n)  |							    |
|------+---------+----------------------------------------------------------|
| S#0  | VDP(8)  | interrupt information				    |
| S#1  | VDP(-1) | interrupt information				    |
| S#2  | VDP(-2) | DP command control information/etc.			    |
| S#3  | VDP(-3) | coordinate detected (LOW)				    |
| S#4  | VDP(-4) | coordinate detected (HIGH)				    |
| S#5  | VDP(-5) | coordinate detected (LOW)				    |
| S#6  | VDP(-6) | coordinate detected (HIGH)				    |
| S#7  | VDP(-7) | data obtained by VDP command 			    |
| S#8  | VDP(-8) | X-coordinate obtained by search command (LOW)	    |
| S#9  | VDP(-9) | X-coordinate obtained by search command (HIGH)	    |
-----------------------------------------------------------------------------

And we have the following BIOS function:

RDVDP (013EH)		*1
  Function:	reads VDP status register
  Input:	none
  Output:	A for the value which was read
  Registers:	A

A simple way to read it is:

#define RDVDP 0x013E
main() {
  REGS *reg;
  calbio(RDVDP,reg);
}

However in REGS structure A register is a TINY value (8 bit) and status register has 10 bits. How it's supposed to read for example bit S#2? In Basic I did the following:

IF (VDP(-2)AND1)<>0)...

In order to check if current frame has finished to draw (VDP flag), but I don't know how to read 10bit register into 8 bit value Question

By anonymous

incognito ergo sum (116)

anonymous's picture

13-09-2015, 12:08

AxelStone wrote:

Question: How to read VDP status register? We have the following table:
[...]
However in REGS structure A register is a TINY value (8 bit) and status register has 10 bits.

No, the VDP status registers are 8 bits each.

Also, you can just use the rdvsts() function of MSX-C Library to read the VDP status registers.

TINY    rdvsts(sreg)
TINY    sreg;

It takes an 8-bit value (the status register number) and returns an 8-bit value (the value in the register).

By AxelStone

Prophet (3064)

AxelStone's picture

13-09-2015, 14:19

Your solution is much better. By the way, the doc of MSX technical handbook is a little confusing, sinc we have S#0 to S#9 it seems 10 bit. What bits are discarded when we get the TINY result?

By anonymous

incognito ergo sum (116)

anonymous's picture

13-09-2015, 14:28

AxelStone wrote:

Your solution is much better. By the way, the doc of MSX technical handbook is a little confusing, sinc we have S#0 to S#9 it seems 10 bit. What bits are discarded when we get the TINY result?

It may be a bit confusing, but it's written very clearly (at least in the Japanese version):

The V9938 has 10 status registers, each of them read-only and 8 bits long.

Where are you getting this info about the registers being 10-bit?

Page 17/57
10 | 11 | 12 | 13 | 14 | 15 | 16 | | 18 | 19 | 20 | 21 | 22