My first steps into MSX dev world ;)

Страница 1/3
| 2 | 3

By JMeric

Rookie (29)

Аватар пользователя JMeric

26-12-2020, 20:54

Hi MSX gurus Wink

Today, I've decided to code on MSX using SDCC 4.0.0
I code on w10 using programmer's notepad and MEISEI/EMULICIOUS/CATAPULT-openMSX to test my rom

I have got some troubles as usual Wink
First step I had to do is to modify a pletter 'to nvram' decompression routine and it works (I really hope Wink )
After compiling the program, I've tested it using catapult, for these MSXs :
- nms 8245 : it works
- hbf501 : get some troubles while displaying : I see the 3 parts displaying after each one (if I switch off the screen (call 0x41) before displaying picture) !
- hb75P : get some troubles : the display is buggy
- canon V20 : same as hb75p

I want this code running on all msx1 based machines and have lot of to learn

What I'm doing
- switch off the screen
- turn into screen 2 mode
- display the 'picture'
- switch on the screen

Maybe I've forgotten important things (interruption, allocate memory, ...) I don't know because I'm studying msx today
I used to code on colecovision and wanted to convert my games Wink

Maybe it's a compiling mistake (my .rom is 16ko instead of 32ko. maybe I have to fill the rom with a program I've forgotten the name to have a 32ko rom)

I'll be happy if someone could help me friends

here is the rom > romfile
TIA

Eric

ps :I can post the program, the makefile

Для того, чтобы оставить комментарий, необходимо регистрация или !login

By Briqunullus

Champion (323)

Аватар пользователя Briqunullus

26-12-2020, 21:37

Without your code, this would be hard to tell. But one thing strikes me, after starting a few machines in openMSX myself. The program seems to run fine on MSX2 machines and has trouble on MSX1 machines. Maybe some VDP initialization has gone wrong?

By JMeric

Rookie (29)

Аватар пользователя JMeric

26-12-2020, 21:50

Many thanks Briqunullus Smile
Here is the code

//#include "tools.h"
//#include "video.h"

const unsigned char EM_LOGO[] = {
0x1a,0xc8,0xae,0xb3,0x00,0xd5,0x9b,0x00,0xd0,0x6b,0x01,0xce,0x1f,0xd8,0x00,0x7d,
0xd3,0x1f,0xfb,0xf6,0x3f,0xcd,0x01,0xc8,0xd5,0xfb,0x00,0xff,0xff,0xff,0xff };  

const unsigned char EM_MENU_COLOR[] = {
0x5f,0x11,0xe3,0x00,0x41,0xfc,0x00,0x7b,0x11,0xff,0x8e,0x00,0xe4,0x00,0x5b,0x14,
0x05,0xfc,0x07,0xf1,0xd7,0xc6,0x00,0xf4,0xb8,0x00,0x14,0xc0,0x03,0x61,0x61,0x68,
0x81,0x2f,0x89,0x91,0x05,0xf9,0x3f,0x4f,0xe6,0x00,0xf7,0x3f,0x01,0x54,0xc1,0xc2,
0x21,0x23,0x31,0x3b,0x0f,0xbf,0xfb,0x3f,0xf8,0x47,0xbf,0xd7,0x0a,0x57,0x51,0xd5,
0xd1,0x37,0x7b,0x03,0x9a,0xa1,0xa3,0xb1,0x11,0x81,0xfe,0xdf,0x9e,0xa0,0x50,0xf7,
0x71,0x75,0x2f,0x51,0x51,0x47,0xd4,0x3f,0xd7,0xfc,0x00,0x88,0xe1,0x74,0x34,0x24,
0x1e,0x24,0x14,0x34,0xfd,0x37,0xf7,0x3f,0xbb,0xf0,0xe7,0xfe,0x3f,0xf7,0xed,0x07,
0x77,0xe3,0x8f,0xff,0x7d,0x07,0xc7,0xbf,0xa7,0xef,0xdf,0x1f,0x3c,0x0f,0x54,0x00,
0xfe,0x67,0xf2,0x3e,0x04,0xf3,0x00,0xfb,0x5f,0x5b,0x17,0x67,0x00,0x1f,0x9f,0x00,
0x6e,0x3f,0xd7,0x27,0x2e,0xbb,0xa5,0x07,0x0e,0xff,0x7a,0x27,0xa0,0xff,0x79,0x11,
0x00,0xff,0xff,0xff,0xff,0x80 };

const unsigned char EM_MENU_PATTERN[] = {
0x3f,0x00,0xff,0xe1,0x00,0xdc,0xc0,0xd1,0x00,0x07,0xcd,0xc1,0x70,0x00,0x07,0x9b,
0xf1,0x80,0x10,0x83,0xf1,0xf1,0x07,0x06,0xe7,0x36,0x10,0x36,0xe3,0xe3,0x07,0x6c,
0xcc,0x0c,0x13,0x0c,0xcc,0xcc,0x07,0xd8,0x08,0x00,0xce,0xce,0x07,0xc0,0x78,0x8c,
0x0e,0x78,0x78,0x38,0x1d,0x74,0x27,0x25,0x00,0x00,0x08,0x70,0x50,0x50,0x70,0x40,
0x70,0x00,0x30,0xe0,0xaa,0x00,0xea,0xee,0x81,0x0f,0xee,0xaa,0xa8,0xee,0x82,0x0e,
0x07,0x01,0xe1,0x41,0x00,0x5b,0x00,0x08,0x17,0x00,0x03,0x03,0x08,0xd8,0x00,0x3e,
0xff,0x32,0xff,0xaa,0x01,0x08,0x80,0x50,0x5d,0x15,0x95,0x15,0x15,0x1d,0x17,0x00,
0x03,0xc1,0x2c,0x02,0x1a,0xa0,0x3b,0x2a,0x2a,0x2b,0x01,0x86,0x80,0x82,0x08,0x00,
0x02,0x82,0xff,0x23,0xfe,0xc6,0xc4,0x09,0x39,0x1a,0x55,0xf3,0x01,0xa6,0x35,0x3f,
0x55,0x29,0x01,0x54,0x08,0x6e,0xa4,0x81,0x00,0xa0,0xe0,0x00,0xa1,0x14,0x03,0xa0,
0xa0,0x6c,0x4f,0x9d,0x04,0x95,0x91,0x9d,0x85,0xdd,0x18,0x1d,0xa0,0x55,0x02,0xd5,
0x00,0x04,0xdc,0x60,0x54,0x00,0x5c,0xff,0x7f,0x38,0x7f,0xff,0x00,0xaa,0x00,0xd2,
0x77,0x01,0xfa,0x7f,0x00,0x1c,0x88,0x54,0x22,0x91,0x0d,0x44,0xaa,0x11,0x03,0x0e,
0x41,0xa2,0x14,0x08,0x62,0x17,0x55,0x22,0x04,0x36,0x03,0x02,0x00,0x3c,0x06,0x06,
0x08,0x69,0x03,0x1b,0xb6,0x3e,0x80,0x3f,0x10,0x28,0x45,0x82,0x00,0xd6,0x3f,0x1d,
0x80,0x44,0x2a,0x47,0xf0,0x3f,0xfe,0x02,0x72,0x48,0xfa,0x00,0x72,0x36,0xab,0x02,
0x68,0xaa,0x01,0xfe,0xd9,0x1c,0x02,0xe0,0x00,0x1f,0x3f,0x39,0x1a,0x37,0x37,0x3f,
0x86,0x00,0x1f,0xff,0xc8,0x00,0x7f,0x21,0x0f,0x1f,0xc4,0x00,0x0f,0x12,0x05,0x01,
0x1f,0x24,0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a,0x89,0xb8,
0x0f,0xff,0xb9,0x57,0x17,0xde,0xf7,0x1f,0x4d,0x07,0x02,0xfc,0xad,0x2f,0x1f,0x06,
0x2f,0x31,0x31,0x35,0x42,0x00,0x96,0x65,0x00,0x60,0x7d,0x03,0x00,0xef,0x8d,0x20,
0x8d,0xee,0x02,0xed,0x00,0x78,0x60,0x70,0x60,0x02,0x00,0x37,0x06,0x20,0x36,0x37,
0x22,0x37,0x00,0x83,0x80,0x30,0x03,0x83,0x00,0x00,0x70,0x68,0x30,0x00,0x00,0x02,
0x3c,0x2c,0x0c,0x18,0x18,0x00,0x01,0x01,0x10,0x10,0x11,0x1d,0x0d,0x01,0x00,0x46,
0x07,0x00,0x70,0x60,0x92,0x98,0x38,0x00,0xcf,0x0c,0x9f,0xf7,0x95,0xbf,0x00,0xe8,
0xa3,0x20,0x11,0x38,0x22,0x14,0xb8,0x08,0x11,0x38,0x07,0x88,0xfd,0xf5,0xfd,0xfd,
0x47,0xd7,0x60,0x70,0x53,0x00,0x20,0xa8,0xa2,0x06,0x88,0x9d,0x1d,0x06,0x00,0x0b,
0x9f,0xd6,0x00,0x4b,0xff,0xac,0xce,0xcf,0x31,0x0b,0x76,0xc3,0xd7,0x7e,0x98,0xb0,
0xd7,0xeb,0x68,0x2f,0x73,0xff,0xc6,0xa7,0xb0,0x91,0x80,0x07,0x3c,0x18,0x80,0x00,
0x3c,0x3c,0x00,0x01,0x7d,0x19,0x45,0x5d,0x41,0xe7,0x24,0x54,0xb0,0x54,0x28,0xa0,
0x04,0x9f,0x7c,0x6d,0x11,0x45,0x6d,0x7d,0x9a,0x32,0x07,0x7d,0x00,0x07,0xa3,0x24,
0xa3,0x8d,0x44,0x80,0x40,0x9e,0x01,0xc6,0x3d,0xbf,0xbf,0xe6,0x61,0x76,0x17,0x1d,
0x78,0x1f,0x00,0x00,0xf9,0x00,0x10,0xb3,0x01,0x78,0x92,0x85,0x78,0x78,0x5d,0x7d,
0x55,0x19,0x67,0x00,0x79,0xcf,0xef,0xc5,0xb7,0x0f,0xe1,0xaf,0xa3,0xf5,0xbd,0x97,
0x76,0x07,0x7d,0x67,0x87,0x7d,0xc7,0x7d,0x57,0xce,0x84,0xc5,0xf7,0x1f,0xdf,0x17,
0x7f,0xa7,0x3f,0x97,0x4f,0xcf,0x7c,0xc3,0xb7,0x4d,0x0f,0xba,0x6f,0x38,0x5f,0xf3,
0x8f,0xf9,0xd7,0xf8,0xe7,0xc2,0x05,0xc4,0xc8,0xc1,0x6a,0x07,0x4f,0x00,0xd1,0x0f,
0x5c,0xa7,0x4f,0xc9,0xe7,0xfe,0x06,0x83,0xb9,0xfe,0x3a,0xf7,0xe6,0x5d,0x30,0x87,
0x06,0x5c,0x57,0x76,0x37,0x38,0xf1,0xdf,0xa6,0x55,0x1f,0xc6,0x4d,0x1f,0x07,0x1e,
0x3b,0x5f,0x75,0x83,0x5f,0xfc,0xc0,0xfc,0x06,0x61,0xe7,0xfc,0xd0,0x2f,0x47,0x0e,
0x1c,0x38,0xca,0x00,0x3f,0x0c,0xeb,0x0f,0x07,0xb3,0x27,0x07,0xef,0x00,0xff,0xff,
0xff,0xfc };

static void Pletter_Dec(void)
{ 
//;-----------------------------------------------------------
//; Pletter v0.5b VRAM Depacker v1.1 - 16Kb version
//; HL = RAM/ROM source ; DE = VRAM destination
//;-----------------------------------------------------------
__asm
	di

; VRAM address setup
	ld	a,e
	out	(0x99),a
	ld	a,d
	or	#0x40
	out	(0x99),a

; Initialization
	ld	a,(hl)
	inc	hl
	exx
	ld	de,#0
	push    de	////
	add	a,a
	inc	a
	rl	e
	add	a,a
	rl	e
	add	a,a
	rl	e
	rl	e
	ld	hl,#modes
	add	hl,de
	ld	e,(hl)
	//.dw 0xdd6b		//	ld	ixl,e
	inc	hl
	ld d,(hl)	////
	push de		////
	pop ix		////
	pop de		////
	
	//ld	e,(hl)
	//.dw 0xdd63		//	ld	ixh,e
	ld	e,#1
	exx
	ld	iy,#loop

; Main depack loop
literal:ld	c,#0x98
	outi
	inc	de
loop:	add	a,a
  	call	z,getbit
	jr	nc,literal

; Compressed data
	exx
	ld	h,d
	ld	l,e
getlen: add	a,a
	call	z,getbitexx
	jr	nc,lenok
lus:	add	a,a
	call	z,getbitexx
	adc	hl,hl
	ret	c
	add	a,a
	call	z,getbitexx
	jr	nc,lenok
	add	a,a
	call	z,getbitexx
	adc	hl,hl
	jp	c,Depack_out
	add	a,a
	call	z,getbitexx
	jp	c,lus
lenok:  inc	hl
	exx
	ld	c,(hl)
	inc	hl
	ld	b,#0
	bit	7,c
	jp	z,offsok
	jp	(ix)

mode7:  add	a,a
  	call	z,getbit
	rl	b
mode6:	add	a,a
  	call	z,getbit
	rl	b
mode5:  add	a,a
  	call	z,getbit
	rl	b
mode4:  add	a,a
  	call	z,getbit
	rl	b
mode3:  add	a,a
  	call	z,getbit
	rl	b
mode2:	add	a,a
  	call	z,getbit
	rl	b
	add	a,a
  	call	z,getbit
	jr	nc,offsok
	or	a
	inc	b
	res	7,c
offsok: inc	bc
	push	hl
	exx
	push	hl
	exx
	ld	l,e
	ld	h,d
	sbc	hl,bc
	pop	bc
	push	af
loop0:	ld	a,l
	out	(0x99),a
	ld	a,h
	nop                     ; VDP timing
	out	(0x99),a
	nop                     ; VDP timing
	in	a,(0x98)
	ex	af,af
	ld	a,e
	nop			; VDP timing
	out	(0x99),a
	ld	a,d
	or	#0x40
	out	(0x99),a
	ex	af,af
	nop			; VDP timing
	out	(0x98),a
	inc	de
	cpi
	jp	pe,loop0
	pop	af
	pop	hl
//	jp	iy
	jp loop

getbit: ld	a,(hl)
	inc	hl
	rla
	ret

getbitexx:
	exx
	ld	a,(hl)
	inc	hl
	exx
	rla
	ret

; Depacker exit
Depack_out:
	ei
	ret

modes:
	.dw	offsok
	.dw	mode2
	.dw	mode3
	.dw	mode4
	.dw	mode5
	.dw	mode6
	.dw	mode7
__endasm;

}	

//--------------------------------------------------------------------------------------------------------
static void Pletter_EM_LOGO(void)
{
__asm
	ld		hl,#_EM_MENU_PATTERN
	ld		de,#0x0000
	call	_Pletter_Dec
	ld		hl,#_EM_MENU_PATTERN
	ld		de,#0x0000+2048
	call	_Pletter_Dec
	ld		hl,#_EM_MENU_PATTERN
	ld		de,#0x0000+2048+2048
	call	_Pletter_Dec
	
	ld		hl,#_EM_LOGO
	ld		de,#0x01800
	call	_Pletter_Dec
	
	ld		hl,#_EM_MENU_COLOR
	ld		de,#0x2000
	call	_Pletter_Dec
	ld		hl,#_EM_MENU_COLOR
	ld		de,#0x2000+2048
	call	_Pletter_Dec
	ld		hl,#_EM_MENU_COLOR
	ld		de,#0x2000+2048+2048
	call	_Pletter_Dec
	
	
__endasm;
}

void main(void)
{
__asm
	call 0x0041				// screen off
__endasm;

__asm
	ld a,#2			
	call 0x005F				// passe en mode 2
__endasm;

	Pletter_EM_LOGO();		// charge données : pattern, datas, sprites

__asm
	call 0x0044				// screen on
__endasm;	 
    
    while(1){};
}

By AxelF

Champion (374)

Аватар пользователя AxelF

26-12-2020, 23:16

The MSX 1 VDP is a tat slower, maybe you can add a extra NOP after Reading/Writing to port 0x98.

By gdx

Enlighted (4195)

Аватар пользователя gdx

27-12-2020, 10:37

A few remarks:
- avoid using Z80 instructions undocumented on MSX.
- avoid disabling interrupts for too long without reading the status register.
- The NOP between two writes on port #99 is useless.
- Put a wait time between specifying the address and writing into the VRAM (EX AF,AF and NOP are insufficient), and a slightly shorter wait between each writing of byte into the VRAM (do not use OTIR). Do the same for readings.
- Almost all BIOS calls that access the VDP reestablish interrupts.

By aoineko

Master (129)

Аватар пользователя aoineko

27-12-2020, 11:25

There are C libraries that already support most of the basic features for creating MSX applications with SDCC. For example : Fusion-C
However, if starting from scratch is part of the fun of your experience, go for it. :)
There are a lot of people here who will be able to help you during your journey in MSX lands.

By JMeric

Rookie (29)

Аватар пользователя JMeric

27-12-2020, 12:35

Hi Gdx and Aoineko and thanks for your advices Smile

Pletter routine is not mine.

I've added 2 extra nops (where is written VDP timing) and it seems to be better on msx1 computers except for the HB75p...

Here are the new romfile and 2 videos
rom 27.12.20
Video caputured from openMSX > HB501P
Video caputured from openMSX > HB75P

@Gdx, how can I do it better ? There are my first steps ;)

have a nice day

By JMeric

Rookie (29)

Аватар пользователя JMeric

27-12-2020, 18:35

Well,

The best thing I have to do is to test on real computer

See you and thx

By JMeric

Rookie (29)

Аватар пользователя JMeric

29-12-2020, 09:27

Hi,

I've corrected/cleaned/reorganized the code and everything is running fine now. I can continue investigate to port my coleco games

By JMeric

Rookie (29)

Аватар пользователя JMeric

30-12-2020, 16:17

Hi,

here is a very little intro of the game I'm porting from Colecovision to Msx

The video

By tfh

Prophet (2795)

Аватар пользователя tfh

30-12-2020, 16:28

Nice! Smile Looking forward to the full port Smile

Страница 1/3
| 2 | 3