#11 Article 3482 Posted at 1989/08/29 15:08:06 by ISAM (MAP1129) [MSX.ML1]

Subject: Re:*5 TP用ML1手続きいります? /3475 ... /3467 /3465

MSX2は・・・


#define	HMMC	0xf0
#define	YMMM	0xe0
#define	HMMM	0xd0
#define	HMMV	0xc0
#define	LMMC	0xb0
#define	LMCM	0xa0
#define	LMMM	0x90
#define	LMMV	0x80
#define	LINE	0x70
#define	SRCH	0x60
#define	PSET	0x50
#define	POINT	0x40
#define	STOP	0x00

#define	IMP		0x00
#define	AND		0x01
#define	OR		0x02
#define	EOR		0x03
#define	NOT		0x04
#define	TIMP	0x08
#define	TAND	0x09
#define	TOR		0x0a
#define	TEOR	0x0b
#define	TNOT	0x0c

struct	vdp {
	unsigned int	sx,sy,dx,dy,nx,ny;
	char	clr,arg,cmr;
	};

というような、ヘッダファイルを作っておいて

vdpstart:
	call	wait_vdp
	ld	a,(WRVDP)
	ld	c,a
	inc	c
	out	(c),d
	ld	a,80h+17
	out	(c),a		;set R#17
	inc	c
	inc	c
	ret

vdp32@::
	push	hl
	ld	d,32
	di
	call	vdpstart
	pop	hl
	ld	b,15
	otir
	ei
	ret

wait_vdp:
	ld	bc,(RDVDP)
	inc	c
	ld	b,2
	ld	e,08fh
wait_loop:
	out	(c),b
	out	(c),e
	in	a,(c)
	and	1
	jp	nz,wait_loop
	out	(c),a
	out	(c),e
	in	a,(c)
	ret

のようなサブルーチンを使い

	struct vdp reg;
	reg.sx=x;reg.sy=y;
	reg.dx=x1;reg.dy=y1;
	reg.nx=reg.ny=16;
	reg.arg=reg.clr=0;
	reg.cmr=LMMM|TIMP;
	vdp32(&reg);

というように、やればCでもたいていのことができます。
リアルタイムゲームも可能です(ただし、メインとVRAMのデータのやり取りはこういった関数では無理)。
 スプライトなんかは、

	struct	splite {
		char	y,x,patnum,color;
	};

といった構造体を使うと、よろしいようです。
当然アセンブラでは、

	dseg
sx:	ds	2
sy:	ds	2
dx:	ds	2
dy:	ds	2
nx:	ds	2
ny:	ds	2
clr:	ds	1
arg:	ds	1
cmr:	ds	1
	cseg

	ld	hl,sx
	call	vdp32@

とやってやればいいのです。
 このへんが、究極のZ80マシンと呼ばれる所以でもあるわけですね(僕が勝手にそう呼んでいるだけだけど)。

	アミガにゃ負けるけどね				ISAM