help with SDCC and msx dos target

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

By PingPong

Prophet (3410)

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

20-08-2019, 16:34

Big thanks. I will try soon to rebuild my set of library functions then adapt to. Fusion msx and contribute to a decent alternative of c programming on msx

By zPasi

Champion (409)

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

20-08-2019, 18:26

ericb59 wrote:

the coming 1.2 Version have enhanced and optimised VDP functions.

And for a good reason! Smile

For example, PutSprite is like this:

    DisableInterupt();
    VpokeFirst( Peekw( ATRBAS ) + (unsigned int)(sprite_no << 2) );
    VpokeNext( y );
    VpokeNext( x );
    VpokeNext( pattern_no );
    VpokeNext( ec_color );
    EnableInterupt();

Not bad, but when compiled, it looks like this (I'm only listing the first VpokeNext part):

;planeto1.c:159: VpokeNext( y );
	ld	d, 7 (ix)
	ld	e,#0x98
	push	de
	call	_OutPort
	pop	af
;planeto1.c:160: VpokeNext( x );
  ...

And that OutPort is:

	ld		hl, #2
	add		hl, sp
	ld		c, (hl)			;;	port
	inc		hl
	ld		a, (hl)			;;	parameter
	out		(c), a
	ret

WHAT? All that instead of simple ld a,7 (ix) out (0x98),a ?

Then, using the VDP commands is not optimal either. I noticed that after doing its job, fLMMM starts waiting for VDPready. So it doesn't return before the command finishes. I can understand why it's done this way, it's kinda foolproof way, but still.

Of course SDCC itself does suboptimal things but that is another subject. Though, I believe Fusion C is already usable and getting better with every release. Maybe I could help a little with those emprovements?

By hit9918

Prophet (2861)

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

21-08-2019, 15:07

the best is to have a function that does OUT multiple bytes. using the OTIR instruction.

By zPasi

Champion (409)

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

21-08-2019, 17:27

hit9918 wrote:

the best is to have a function that does OUT multiple bytes. using the OTIR instruction.

Yes. Even better if you update multiple sprite params in a ram buffer and then use OTIR.

I have a C demo where I do this:

typedef struct {
	u_char y;
	u_char x;
	u_char shape, color;
} hwsprite_t;
hwsprite_t hwsprites[];

// after setting that buffer up, I do this:
  my_vwrite_direct(hwsprites, spr_attributes(), 128);

(my_vwrite_direct() is like Fusion C CopyRamToVram() but faster.)

I could adapt that (and a few other things) for Fusion C.

By ericb59

Paladin (852)

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

22-08-2019, 10:43

@zPasi . VDPready calls at the end of all MSX2 VDP Commands were removed in the 1.2 version.

@zPasi . "I could adapt that (and a few other things) for Fusion C." It would be great if you can send me some routines for Fusion-C. Please contact me directly by email, it's more efficient than reading topics here.

@ all
About the put sprite, and other functions. You are free to send me better alternative source code. I'm not an ASM Programmer, that's why I build a C Library in fact.
You have to know how is huge the project to build a complete library. Not just some basic functions for expert programmers, but a real, and understandable library for all kind of MSX programmers.
Thus please, do not complain, and participe in the project. Send me better code routines, not just pointing faulty functions, or non optimised code in a forum.
OK, it's my 2cents in the jukebox... forgive me if i'm excessive.

By zPasi

Champion (409)

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

23-08-2019, 17:42

ericb59 wrote:

@zPasi . VDPready calls at the end of all MSX2 VDP Commands were removed in the 1.2 version.

Very good!

Quote:

You have to know how is huge the project to build a complete library. Not just some basic functions for expert programmers, but a real, and understandable library for all kind of MSX programmers.

Yes, of course. It's a huge task, and I appreciate your work. Really!

There is so much functionality, like the file system, mapper, i/o, graphics... it's only logical to make *some* working versions of those "putsprites" and all at first, time for optimizations comes a little later.

I'm glad if I can help with the project. I'll send you mail.

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