[MSX-C] Q&A official thread

Страница 15/56
8 | 9 | 10 | 11 | 12 | 13 | 14 | | 16 | 17 | 18 | 19 | 20

By anonymous

incognito ergo sum (118)

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

11-09-2015, 17:55

Oh, I see now what you mean. The cpyv2v code is correct, and the problem is somewhere else: color 0 is ignoring the RGB settings and is being displayed as black.

Can you paste the code where you set up the palette?

By anonymous

incognito ergo sum (118)

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

11-09-2015, 17:57

AxelStone wrote:

if I try what you are making (for example cpyv2v(.........,8)) I get compilation error: 9th argument conflict,I must made explicit casting to [...]

Can you also paste the code where you declare the variable types?

cpyv2v() and related shouldn't need the cast unless you're working with different types than the ones required by this function.

In fact, I don't think I even need to cast to TINY when I do the screen() call... let me confirm.

By AxelStone

Prophet (2758)

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

11-09-2015, 18:06

Here goes the full code, it's a WIP code so it's a little dirty, sorry:

#include<stdio.h>
#include<glib.h>

#define PAGE0 0x0000
#define PAGE1 0x8000
#define SCREEN5 (TINY)5
#define SCREEN0 (TINY)0
#define BUFSIZE 128
#define COUNT 1
#define VREG23 (TINY)23
#define JIFFY (*(TINY *)0xfc9e)
#define REGISTROS 3840
#define SCREEN_SIZE 256
#define JOY_CURSOR (TINY)0

TINY stage[REGISTROS];
TINY pantalla[13][16];

NAT grbdat[16]={0x0442,0x0000,0x0400,0x0040,0x0200,0x0221,0x0231,0x0224,0x0346,0x0777,0x0436,0x0120,0x0555,0x0420,0x0250,0x0113};

loadplt() {
	TINY pal;
	iniplt();
	for(pal=0;pal<16;pal++) {
		setplt(pal,grbdat[pal]); 
	}
	rstplt();
}

loadimg() {
	FILE *fp;
	char buf[BUFSIZE];
	int i;
	int vrami=PAGE1;
	fp=fopen("tiles4.sc5","rb");
	if(fp==NULL) {
		printf("File read error!");
		return;
	}
	fread(buf,7,COUNT,fp);
	for(i=0; i<213; i++) {
		fread(buf,BUFSIZE,COUNT,fp);
		ldirvm(vrami,buf,BUFSIZE);
		vrami = vrami+BUFSIZE;
	}
	fclose(fp); 
}

loadst() {
	FILE *fp;
	int i;
	fp=fopen("stage1.dat","rb");
	fread(stage,sizeof(TINY),REGISTROS,fp);
	fclose(fp);
}

loadsc(sc)
TINY sc;
{
	TINY x,y,tl;
	NAT sx1,sy1;
	int adr;
	disscr();
	for(y=0;y<=12;y++) {
		for(x=0;x<=15;x++) {
			adr=(x+y*16)+(int)(256*(int)sc);
			pantalla[x][y]=stage[adr];
			tl=pantalla[x][y];
			if(tl==0) {
				cpyv2v(240,144,255,159,(TINY)1,(NAT)x*16,(NAT)y*16,(TINY)0,(TINY)8);
			} else {
				sx1=(NAT)((tl-1)%16)*16;
				sy1=(NAT)((tl-1)/16)*16;
				cpyv2v(sx1,sy1,sx1+15,sy1+15,(TINY)1,(NAT)x*16,(NAT)y*16,(TINY)0,(TINY)8); 
			}
		}
	}
	enascr();
}

main(){
	TINY sc,key;
	sc=2;
	screen(SCREEN5);
	loadplt();
	loadimg();
	rstplt();
	loadst();
	loadsc(sc);
	while(sc>=0 && sc<=14 && key!=1) {
		key=gtstck(JOY_CURSOR);
		if(key==3) {
			sc=sc+1;
			loadsc(sc);
		}
		if(key==7) {
			sc=sc-1;
			loadsc(sc);
		}			 
	}
	screen(SCREEN0);
}

It's a little code to test full stage, since I can go forward and backward using cursor keys. Thanks.

By anonymous

incognito ergo sum (118)

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

11-09-2015, 18:07

JaviLM wrote:

In fact, I don't think I even need to cast to TINY when I do the screen() call... let me confirm.

I was wrong. If I do screen(5) instead of screen((TINY)5) then the program doesn't change to the right screen mode, though it compiles just fine.

As expected, doing c = 5; screen(c); (where c is of type TINY) works without issues.

By anonymous

incognito ergo sum (118)

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

11-09-2015, 18:19

Could this be the problem?

AxelStone wrote:
	loadplt();
	loadimg();
	rstplt();

1) You load the palette
2) You load the image
3) You reset the palette to the colors read from the image (thus destroing what you did in 1)

Try putting loadplt() after rstplt() and see what happens (or remove rstplt()) if you're setting the colors manually.

By AxelStone

Prophet (2758)

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

11-09-2015, 18:26

@JaviLM Done, there is no rstplt() in anywhere, and nothing happens Sad . I've tried even remove initplt() and I have the same result. It's strange, perhaps there is something wrong in MiFui pictures format, but in Basic it works.

I've to go out, I'll come back in a while. If you can I can zip the code and images. Anyway thanks for your help!

By anonymous

incognito ergo sum (118)

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

11-09-2015, 18:32

Sure, send me the archive and I'll take a look.

By AxelStone

Prophet (2758)

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

11-09-2015, 19:08

Mail sent!

By hit9918

Prophet (2896)

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

12-09-2015, 10:23

It gets confusing, what was solved and what not, transparent blit topic vs palette.
Go screen 1 in BASIC. Make color 0,4,1. Then color 0,4,15. whoops, it changes with border color. It is the MSX1 thing, involved a genlock story.
vdp(9) = vdp(9) OR 32. then it is palette.

By Louthrax

Prophet (2280)

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

12-09-2015, 11:35

AxelStone wrote:

Thanks Javi, I've tried even with logical op 8, but it doesn't works. Here goes the pictures:

This is the custom palette in MiFui. As you can see, I've selected RGB=442 as transparent since it's only used in background tiles.


This is the upstatirs tile. Since it appears on background, I can use transparent color and copy it using without transparency.


Same screen in MSX-C, the upstairs are transparent, whenever logop=0 or logop=8.

What could be wrong? Thanks.

Look at custom palette color 0 and the upstairs color : looks like they are the same. MIF just does its job: it assigns the upstairs color to the closest color in the palette (color 0 here). So when you do the copy on MSX, it gets transparent if transparency is enabled.

I have a new beta-version of MIF somewhere that handles transparency in .PNG files (along with other changes), but it's not ready for release yet, and most people do not know how to handle that in Gimp or Photoshop. Waiting for that, I suggest that you use a "special" color for transparency in your custom palette (something like violet R=7 G=0 B=7). This color will only be used for transparency and should not be used for real graphics.

Страница 15/56
8 | 9 | 10 | 11 | 12 | 13 | 14 | | 16 | 17 | 18 | 19 | 20