vbt
Staff member
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 :
The modifed bg display function :
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 ?
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 ?