I want to learn MSX-C, where do I start?

Page 8/12
1 | 2 | 3 | 4 | 5 | 6 | 7 | | 9 | 10 | 11 | 12

By ARTRAG

Enlighted (6515)

ARTRAG's picture

24-08-2015, 14:02

I'd rather say objective-oriented

By hit9918

Prophet (2904)

hit9918's picture

24-08-2015, 20:54

Ok, now I appeared as hacker with otir. And will argue point by point how I am tidy and high level Big smile

Look at this very high level code Smile

struct OBJECT { char Y; char X; char P; char C;.... my other things, dx,dy, .... };


struct OBJECT objects[128];
struct OBJECT* spritelist[64]; int spritelistlength = 0;

void dumpSpriteAttributeTable() {
	int i;
	setSpriteAttributeTableVRAMAddress();
	for (i = 0; i < spritelistlength; i++) {
		otir(VDPport, 4, spritelist[i]);
	}
}

And the otir copies directly from the object to vram without a copy in RAM.

And the spritelist has spritesort abilities that the ordinary app can only dream about because it is too directly wired, not high level enough Big smile
Why did I make the spritelist 64 sprites? Because you never know what the sprite engine can do, this is very high level Big smile
The sprite engine does wildly shuffle in the sprite list, but your objects are not touched, because that thing is so bloody abstract and high level Big smile

I use this highly abstract object oriented coding in my highspeed asm game Big smile

Quote:

One thing that stuck out to me about the otir function is that suddenly you have to be worried about accessing the VRAM too fast in certain screen modes or VDP versions

question: what if I call screen(8) on MSX1? I use "a bios call, no coding registers, oh so high level", but the app will do nothing but garbage. the otir() is no worse!
on MSX1 you must use the screen(2). and the otir29().
and no, things are not dependant on screen mode.

the MSX has a vram file streaming device Big smile
question: what happens if you call fread() without opening the file? it crashes!
otir() has the same characteristics as the very high level fread(), you better first open the right file Big smile

otir(VDPport, amount bytes, array) also can be used on the 9990.
similar to fread() asking to pass the right file descriptor, otir() asks to pass the right VDPport descriptor - again otir() is no worse! but same as the high level function Big smile

otir(), the most abstract universal streaming device function ever Big smile
spritelist, the most abstract high level universal speed sprite datastructure ever Big smile

By Grauw

Ascended (10010)

Grauw's picture

24-08-2015, 20:57

hit9918 wrote:

Ok, now I appeared as hacker with otir. And will argue point by point how I am tidy and high level Big smile

Smile

By hit9918

Prophet (2904)

hit9918's picture

24-08-2015, 21:37

The thing is. The programmers who want BASIC in C. That is what created the tension.
There is a way to code C without the nasty operators "*" and "&" popping up.
Memory acess wise with arrays one can really code it much like BASIC.
So when I cross that red line, I am practicaly using an unknown language and the reaction is meeeeh.

Silimar situation on the library side.
You got to admit, the comparison of otir() and fread() was a surprise.
the keywords "high level" just dont cut it.
what actualy is wanted is a SAFE LANGUAGE.
And sometimes one can get the C typechecking relatively far.
When making a library for the MSX, one should hunt for avoiding the nasty operators (not in implementation, but in usage).

By hit9918

Prophet (2904)

hit9918's picture

24-08-2015, 21:51

Oh and another thing I wasn't aware of: That funny function name otir, it comes from the z80 instruction otir!
I was talking like it is clear what it does, but that assumption can't be made in a C thread.
But, the LDIRVM too has its name from a z80 instruction, LDIR.

By hit9918

Prophet (2904)

hit9918's picture

24-08-2015, 22:32

@DarkSchneider, I added some thoughts to your code.
grouping things in loops and then in a copy of 4 bytes at once. then the struct yxpc needs to be in vram order.

struct {y, x, p, c...} sprite_data; // an entry for SAT
sprite_data sprites[32]; //our 32 sprites = to the full SAT

put_sprite(TINY index, sprite_data *data)
{
sprites[i].x = data->x;
--- //copy all the other data
}

toRAMSAT(sprite_data *data) {
	for (i = 0; i <32; i++) {		//a loop instead one function call per sprite
		sprites[i].x = data->x;
		...
	}
}

toRAMSATfast(sprite_data *data) {
	for (i = 0; i <32; i++) {
		memcpy(sprites[i], &(data[i]->y), 4);	//a memcpy to copy 4 variables at once
	}

}

tovramdirect() {
	setSATvramaddress();
	for (i = 0; i <32; i++) {
		otir(VDPport, 4, &(data[i]->y));	//copy to vram directly
	}
}

In the demo I posted there is otir() for sdcc.

By anonymous

incognito ergo sum (116)

anonymous's picture

25-08-2015, 01:59

hit9918 wrote:

Look at this very high level code Smile

struct OBJECT { char Y; char X; char P; char C;.... my other things, dx,dy, .... };

struct OBJECT objects[128];
struct OBJECT* spritelist[64]; int spritelistlength = 0;

void dumpSpriteAttributeTable() {
	int i;
	setSpriteAttributeTableVRAMAddress();
	for (i = 0; i < spritelistlength; i++) {
		otir(VDPport, 4, spritelist[i]);
	}
}

And the otir copies directly from the object to vram without a copy in RAM.

You still have a copy in RAM. Where do you think these structs are stored?

Anyway, this code won't work in MSX-C, and the things you're talking about don't have much to do with the topic we were talking about. Please stop hijacking the thread.

By anonymous

incognito ergo sum (116)

anonymous's picture

25-08-2015, 02:05

hit9918 wrote:

Oh and another thing I wasn't aware of: That funny function name otir, it comes from the z80 instruction otir!

/facepalm

hit9918 wrote:

But, the LDIRVM too has its name from a z80 instruction, LDIR.

No. This name comes from the LDIRVM BIOS call, which (oh, coincidence) does the same thing as ldirvm().

By ericb59

Paragon (1046)

ericb59's picture

25-08-2015, 13:18

I'm flooded !Oo

By DarkSchneider

Paladin (941)

DarkSchneider's picture

26-08-2015, 13:34

What about the IX register to call EXTROM?

OK, I found it, using calsub().

Page 8/12
1 | 2 | 3 | 4 | 5 | 6 | 7 | | 9 | 10 | 11 | 12