2d problems

mrkotfw

Mid Boss
when i try to display a 2d graphic, it shows it corrupt...

Code:
/* -------------------------------------------------------------- */

FIXED scrollxa=sip_pos_x;

FIXED scrollya=sip_pos_y;

/* -------------------------------------------------------------- */

void epScrollLogo(void){

slTVOff();

slColRAMMode(CRM16_1024);

slBack1ColSet((void *)BACK_COL_ADR,0);

slCharNbg1(COL_TYPE_256,CHAR_SIZE_1x1);

slPageNbg1((void *)NBG1_CEL_ADR,0,PNB_1WORD|CN_12BIT);

slPlaneNbg1(PL_SIZE_1x1);

slMapNbg1((void *)NBG1_MAP_ADR,(void *)NBG1_MAP_ADR,(void *)NBG1_MAP_ADR,(void *)NBG1_MAP_ADR);

Cel2VRAM(cel_logo,(void *)NBG1_CEL_ADR,320*64);

Map2VRAM(map_logo,(void *)NBG1_MAP_ADR,32,32,0,256);

Pal2CRAM(pal_logo,(void *)NBG1_COL_ADR,256);

slScrPosNbg1(toFIXED(0.0),toFIXED(0.0));

slTVOn();

	while(1){

	slScrPosNbg1(toFIXED(0.0),toFIXED(0.0));

	slSynch();

	}

}

/* -------------------------------------------------------------- */

void ss_main(void){

slInitSystem(TV_320x224,NULL,1);

	while(1){

	epScrollLogo();

	slSynch();

	}

}

how would i find out the Xs ???of the image?

Code:
Map2VRAM(map_logo,(void *)NBG1_MAP_ADR,X,X,0,256);

where are the #define's of NBG0 and NBG3 ? lol
smile.gif
 

vbt

Staff member
try to add that :

Code:
#define NBG1_CEL_ADR ( VDP2_VRAM_B1 + 0x02000 )

#define NBG1_MAP_ADR ( VDP2_VRAM_B1 + 0x12000 )

#define NBG1_COL_ADR ( VDP2_COLRAM + 0x00200 )

#define BACK_COL_ADR ( VDP2_VRAM_A1 + 0x1fffe )
 

mrkotfw

Mid Boss
Yah I got that
smile.gif
but what im having problems is the info for map2vram! how do i find the width and height?

how do i get the info where the Xs are?

Map2VRAM(yama_map , (void *)RBG0_MAP_ADR , X, X , X , X);

there is no documenation on this! the functions are written in the docs but they dont explain anything on it! help vbt
smile.gif
 
I think the functions Cel2VRAM, Map2VRAM and Pal2CRAM are "for" loops included ine some .h checkout the #include files, there you should find the definition of these functions. I think it just takes every cel of the picture array and copies it in the memory.

Here's also an extract from the SGL FAQ (which I don't understand), maybe it can help you :

1. SGL Techniques

1-1 What to Check When a Scroll Screen Does Not Display Properly

SGL maintains the preserved contents of the VDP2 registers within its system

variables at 60FFCC0. Most of the contents are copied to the VDP2 registers

during V-blank processing.

Since the VDP2 registers are write-only, it is not possible to access the

values set by the user. As a result, it is difficult to debug the cause of

display problems. However, it is possible to determine the settings made to

the VDP2's registers by referring to SGL's system variable area.


Djidjo
 
These functions are sometimes defined in a file called SCL_FUNC.C. They are not part of the SGL, but they are fully explained in the sgl tutorial ("storing scroll data in VRAM" p 8-8)
 
Oh, after uploading tiles and setting up registers allways do something like this:

slScrAutoDisp(NBG0ON | NBG1ON); // change/set NGB planes at will

From my experience, changes commited to the internal SGL registers won't be updated to VDP2 unless you do this. GiriGiri will show the changes, but a real Saturn don't display anything.

As for MAP2VRAM, here's a prototype:

Map2VRAM(Uint16 *start_of_tile_data , Uint16 *start_of_map_data, Uint16 map_width, Uint16 map_height, Uint16 pallete_used, Uint16 map_offset);

map_width and map_height are in tiles, not pixels. Remember this function is only good for 256 color modes, too. Pallete_used is set up to pick one of the palletes stored in CRAM (0 is the first 256 colors, 1 is the next 256, etc). map_offset is a wee bit strange: seemingly is for you to especify an offset of the original start_of_map_data.
 

mrkotfw

Mid Boss
hey, thanks guys i fixed it.

tip: USE TOSS.EXE!!!!!!!!!!!!!!!!!!!!! NOT the MAP EDITOR!

/me is an idiot,

/me thanks reinhart too

hey, BTW i have a problem:

here is the problems:

it displays one pic 1st, but i want the user to press start then go to another 2d pic in the same nbg1
smile.gif


1. i know the controller works, as in the code is right but it doesnt seem to work for this

2. everything else is defined, nbg1 stuff, the pic DOES display but the second one doesnt and yes the other pic works too

3. if i take off the for(); on the first one, the second pic shows....

BTW, the first pic is a PRESS START pic then the second one is STARS!
smile.gif


Code:
/* main loop */

while(1){

/* -------------------------------------------------------------- */

 	/* +---------------------+

        | ifstart.cel/map/pal |

        +---------------------+ */

 	for(x=0; x<320; x++){

  for(y=0; y<224; y++){

 	/* find the cells [cell]*64 */

 	cel2vram(ifstart_cel,(void *)NBG1_CEL_ADR,228*64);

 	/* find the actual width and /8: x/8 y/8 */

 	map2vram(ifstart_map,(void *)NBG1_MAP_ADR,319/8+1,223/8+1,1,256);

 	pal2cram(ifstart_pal,(void *)NBG1_COL_ADR,256);

 	/* set it to the position */

 	slScrPosNbg1(toFIXED(0.0),toFIXED(0.0));

 	slSynch();

 	}/* for 1 */

 	}/* for 2 */

/* -------------------------------------------------------------- */

 	/* +---------------------+

        | bg.cel/map/pal   |

        +---------------------+ */

 	if((data & PER_DGT_KL)==0){

 	for(x=0; x<320; x++){

  for(y=0; y<224; y++){

 	/* find the cells [cell]*64 */

 	cel2vram(bg_cel,(void *)NBG1_CEL_ADR,145*64);

 	/* find the actual width and /8: x/8 y/8 */

 	map2vram(bg_map,(void *)NBG1_MAP_ADR,319/8+1,223/8+1,1,256);

 	pal2cram(bg_pal,(void *)NBG1_COL_ADR,256);

 	/* set it to the position */

 	slScrPosNbg1(toFIXED(0.0),toFIXED(0.0));

 	slSynch();

 	}/* for 1 */

 	}/* for 2 */

 	}/* if */

/* -------------------------------------------------------------- */

	}/* while_main */
 
In you while loop, you display the first pic and then the second one only if a button is pressed, this is not a clean code, because you're trying to display two images in the same slSynch() cycle. Use a boolean that would be false at the beginning and if L is pressed it becomes true. Then check the value of this boolean :

If it's false -> display the first image

If it's true -> display the second one.

Or better : do 2 while loops, one for each image.

while (Smpc_Peripheral[0] & PER_DGT_KL) //as long as L is not pressed

{ for... //display first image

slsynch()

}

while(1)

{ for... //display 2d image

slSynch()

}
 

mrkotfw

Mid Boss
hey...
blush.gif
i cant use more than 256 color bmps! how do i do this..... because it looks really ugly just having 256 color bmps, i heard that toss.exe doesnt support more than 256 colors
sad.gif
 
Yes, I said that like, 3 or 4 messages ago. For that you need to use bitmap functions, that look something like this:

slBitMapNbg0(COL_TYPE_32768, BM_512x256, VDP2_VRAM_A0);

(macro definitions are on page 10 of 238-R1.pdf (SGL Reference))

I belive TOSS or SSCONV can output 16-bit format. you need to copy to VDP2_VRAM with a simple for cycle:

imagine you have a bmpdata array in the format those programs give:

Code:
void *temp;

temp = (void *) VDP2_VRAM_A0;

for i = 0 to (512*256*2){

  temp[i] = bmpdata[i]

}

should copy to the VRAM safely.
 
Top