HomeForumsWhat's newResources 
 
 
need help
vbt - Feb 22, 2004
   vbt Feb 22, 2004 
Thanks to the answers about the tile modes I tried to write a simple program using this mode and it worked perfectly . Now I'm trying to use this mode in SMS plus but I encounter some problems, the tiles are incorrectly displayed. Here is what I did : Code:
  
map = (Uint8 *)SCL_VDP2_VRAM_B0; // map location cache = (Uint8 *)SCL_VDP2_VRAM_B1; // tile location (SMS plus converts SMS tiles and put them in cache) ... // NBG0 init SCL_InitConfigTb(&scfg); scfg.dispenbl = ON; scfg.charsize = SCL_CHAR_SIZE_2X2; scfg.pnamesize = SCL_PN1WORD; scfg.flip = SCL_PN_10BIT; scfg.platesize = SCL_PL_SIZE_1X1; scfg.coltype = SCL_COL_TYPE_256; scfg.datatype = SCL_CELL; scfg.patnamecontrl = 0x000c;// VRAM B1 for(i=0;i<4;i++) scfg.plate_addr[i] = SCL_VDP2_VRAM_B0;

The modifed bg display function :

Code:
  
void render_bg_sms(int line) { int locked = 0; int v_line = (line + vdp.reg[9]) % 224; int v_row = (v_line & 7) << 3; int hscroll = ((vdp.reg[0] & 0x40) && (line < 0x10)) ? 0 : (0x100 - vdp.reg[8]); int column = 0; word attr; word *nt = (word *)&vdp.vram[vdp.ntab + ((v_line >> 3) << 6)]; int nt_scroll = (hscroll >> 3); int shift = (hscroll & 7); dword atex_mask; dword *cache_ptr; dword *linebuf_ptr = (dword *)&linebuf[0 - shift]; /* Draw a line of the background */ if(line%32==0) // VBT : get map only every 32 lines for(; column < 32; column ++) { /* Stop vertical scrolling for leftmost eight columns */ if((vdp.reg[0] & 0x80) && (!locked) && (column >= 24)) { locked = 1; v_row = (line & 7) << 3; nt = (word *)&vdp.vram[((vdp.reg[2] << 10) & 0x3800) + ((line >> 3) << 6)]; } /* Get name table attribute word */ attr = nt[(column + nt_scroll) & 0x1F]; #ifndef LSB_FIRST attr = (((attr & 0xFF) << 8) | ((attr & 0xFF00) >> 8)); #endif // VBT : fill the tile of 32x32 map[line+column] = ((attr & 0x7FF) << 6) | (v_row); } }

I think there is something wrong in the display fonction and maybe in the init of the NBG0. Maybe it's because of the tile cache of SMS plus ? Anybody has got an idea ?

   vreuzon Feb 24, 2004 
What do you mean by "incorrectly displayed" ?

   ExCyber Feb 24, 2004 
Yeah, it's hard to figure out what's wrong without at least a description of what it looks like... but from a quick proofread I can see:

Code:
  
if(line%32==0) // VBT : get map only every 32 lines for(; column < 32; column ++)

This will mess up raster effects at the very least, since you're not updating scroll/blanking state on each line. For most games this shouldn't be a big deal though...

Code:
  
/* Stop vertical scrolling for leftmost eight columns */ if((vdp.reg[0] & 0x80) && (!locked) && (column >= 24))

Just a nitpick, but that's the rightmost eight columns (I think it's the comment that's wrong rather than the code )

   vbt Feb 24, 2004 
Here is a pic of my current problem :



Don't pay attention on the correct sprite, I've modified SMS plus to use 2 plans (NBG0 : BG in tile mode, NBG1 : sprites in Bitmap mode). Also I've change map assignment and it seems to be a little better : map[line+column] = attr;

to display a simple tile of 32x24 I used this but I didn't manage to reproduce the same way of working :

Code:
  
for(i=0;i<24;i++) { memcpy(map_addr, &map_wb[i*32],32); map_addre+= 64; }

   vbt Feb 25, 2004 
I found the solution the charsize was wrong and also my loop

The worlking loop looks like this :

(maybe somthing can be improved ?)

Code:
  
if(line==0) map=(Uint8 *)SCL_VDP2_VRAM_B0; // VBT : line moved out of this function if(line%8==0) { for(; column < 32; column ++) { /* Get name table attribute word */ attr = nt[(column + nt_scroll) & 0x1F]; map[column] = (((attr & 0xFF) << 9) | ((attr & 0xFF00) >> 7)); } map+=64; }

   slinga Feb 25, 2004 
The masses want a screenshot

   vbt Feb 26, 2004 
Here is the pic the background is displayed perfectly, I still have to move the sprite part to tile mode too but already on Girigiri the result seems to be interesting

PS : there is no more zoom but it's just a detail


   M3d10n Feb 27, 2004 
Holy cow! Looking very good. Are you using the Saturn's own tile layers to show the SMS tiles? Such concept fascinates me. It's like emulating an N64 using Glide or something.

Wasn't Stardust trying to do the same?

   slinga Feb 27, 2004 
Yeah VBT awesome screenshot :cheers

   vbt Feb 28, 2004 
again a problem

I moved the sprite layer to tile mode, the sprites are displayed (with a bad color but it doesn't matter) but when a tile is displayed I don't manage to clear a tile no more usefull, can someonr help me ? Also I'd like to know what is the use of the lookup table ? I never use it in fact.

Code:
  
if (line%8==0) map2[xp>>3]=n<<1; // VBT : set the tile to display for(x = start; x < end; x ++) { /* Source pixel from cache */ byte sp = cache_ptr[x]; /* Only draw opaque sprite pixels */ if(sp) { /* Background pixel from line buffer */ byte bg = linebuf_ptr[x]; /* Look up result */ // linebuf_ptr[x] = lut[(bg << 8) | (sp)]; /* Set sprite collision flag */ if(bg & 0x40) vdp.status |= 0x20; }

   vbt Feb 29, 2004 
I managed to corect the palette problems by using two palettes but I have a real pb with the two layers

Case 1 :

cache = (Uint8 *)SCL_VDP2_VRAM_A1;

cache2 = (Uint8 *)SCL_VDP2_VRAM_B1;

map = (Uint8 *)SCL_VDP2_VRAM_A0;

map2 = (Uint8 *)SCL_VDP2_VRAM_B0;

with config.patnamecontrl = 0x000c;// VRAM B1 づオフセット for the two layers. In that case, the two layers diplays the same thing whereas the maps are differents !!!

Case 2 :

cache = (Uint8 *)SCL_VDP2_VRAM_A1;

cache2 = (Uint8 *)SCL_VDP2_VRAM_B1;

map = (Uint8 *)SCL_VDP2_VRAM_B0;

map2 = (Uint8 *)SCL_VDP2_VRAM_A0;

with config.patnamecontrl = 0x000c;// VRAM B1 づオフセット for the two layers. In that case, the first and second layer displays something correctly but some frame later, the sprite layer start to display unwanted tiles (even if I remove all update of the map)

So I'd like to know what is the right way to set layer and also what seems to be correct in the two cases. Finally, I'd like to know how to set config.patnamecontrl I searched in the VDP doc and didn't find something that tell me 0x0c=VRAM_B1 0xXX=VRAM_A1

   ExCyber Mar 1, 2004 
The VDP docs are pretty much 100% low-level stuff, for registers they define the individual bitfields/flags rather than values that you would write to the entire register. You might want to check the SGL Reference Manual.

   vbt Mar 2, 2004 
I returned to the case two and forced the first tile to 0x00 and now the display is almost correct. I still have some glitches between transition screens.

PS : I found some good info about the VDP2 in the souce of MESS there

http://cvs.mess.org:6502/cgi-bin/viewcvs.c....view...

It's easy to find the same information in the SEGA doc but it's more readable .


   vbt Mar 20, 2004 
I finally managed to display real Saturn sprites and tile but I have a lot of glitches and I have lost the transparency color.

For those who have a commcard you can test this binary :

SMS Plus with tile and sprites...

Dega PC : 100 %

SMS Plus Saturn: 48 %

Master Gear Saturn :31 %

Previous SMS Plus Saturn: 25 %

   vbt Apr 4, 2004 
Eh Eh, I have made small improvements :

- There are less glitches.Two sprites seem to be mandatory : one to define the system clipping, the second one to define the local coordinates

- Sprite positions are correct on emus and on Saturn

- supports now 8x8 and 8x16 sprites

This is a small sample with a game that uses 8x16 sprites



Binary for a PAR...