TA bufferes initialize

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
Twada
DC Developer
DC Developer
Posts: 42
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Wed Jan 20, 2016 4:55 am
Has thanked: 18 times
Been thanked: 53 times

TA bufferes initialize

Post by Twada »

Hello.

I'm trying to make an TA bufferes initialize by reference to the Marcus's sample.
I wouid like to use Texture freely and lerge in VRAM. So I would like to put the TA buffer at the bottom of the VRAM.
However, if the bottom address(TA_BUFFER_BOTTOM2) of the Ta buffer is 0xa5800000, the screen freezes.
but if the adress is 0xa5700000, not freezes.

Code: Select all

#define TA_BUFFER_BOTTOM1	0xa5400000
#define TA_BUFFER_BOTTOM2	0xa5800000

/* TA Buffers */
static unsigned char *vtx_buf[2];              /* Vertex CMD buffer*/
static unsigned char *obj_ptr_buf[2];        /*Object pointer buffer*/
static unsigned char *tile_buf[2];              /*Tile buffer*/
static unsigned char *screen[2];               /*screen*/

static int current;   /*video flip num*/
static int scr_w;     /*screen width*/
static int scr_h;     /*screen height*/
.........
.........
void ta_create_buffer(){
	int i;
	unsigned char *ptr = (unsigned char *)TA_BUFFER_BOTTOM1;
	int h = scr_w>>5;            /*Tile num*/
	int v = scr_h>>5;
		
	for (i = 0; i<2; i++, ptr = (unsigned char *)TA_BUFFER_BOTTOM2) {
		ptr -= scr_w * scr_h * 2;
		screen[i] = ptr;

		ptr -= ((24 + (6 * h*v)) * 4);
		tile_buf[i] = ptr;                 /*Tile Buffer*/
		
		ptr -= (512 * 1024);
		vtx_buf[i] = ptr;                  /* Vertex Buffer */
		
		ptr -= (128 * h*v * 3);            /*(128*w*h) * (opaque+transparent+punchthruの分) */
		obj_ptr_buf[i] = ptr;              /*Object Pointer Buffer*/
		
		/*set tile buffers*/
		ta_create_tile_buffer(tile_buf[i], obj_ptr_buf[i], h, v);
	}
}

The following registry is set. I do not know the cause. Help me.

Code: Select all

volatile unsigned int *regs = (volatile unsigned int *)0xa05f8000;
unsigned int vtx = ( (unsigned int)(vtx_buf[current]) )&0x007fffff;
unsigned int opb = ( (unsigned int)(obj_ptr_buf[current]) )&0x007fffff;

        regs[0x008/4] = 1;		                                 /* Reset TA */
	regs[0x008/4] = 0;
	regs[0x124/4] = opb;
	regs[0x12c/4] = 0;
	regs[0x128/4] = vtx;
	regs[0x130/4] = vtx + (512*1024);
	regs[0x13c/4] = (((scr_h>>5)-1)<<16) | ((scr_w>>5)-1);
	regs[0x164/4] = opb;
	regs[0x140/4] = 0x00130303;
	regs[0x144/4] = 0x80000000;

User avatar
bogglez
Moderator
Moderator
Posts: 578
Joined: Sun Apr 20, 2014 9:45 am
Has thanked: 0
Been thanked: 0

Re: TA bufferes initialize

Post by bogglez »

Aren't you writing past the second VRAM bank there? What happens if you lower the value to 0xa57ffffc or below? In my code I have these numbers:

Code: Select all

static volatile union ak_pointer vram_bank1     = { .as_u8 = (u8*)0xa5000000 };
static volatile union ak_pointer vram_bank2     = { .as_u8 = (u8*)0xa5400000 };
static const   union ak_pointer vram_bank1_end = { .as_u8 = (u8*)0xa53ffffc };
static const   union ak_pointer vram_bank2_end = { .as_u8 = (u8*)0xa57ffffc };
Wiki & tutorials: http://dcemulation.org/?title=Development
Wiki feedback: viewtopic.php?f=29&t=103940
My libgl playground (not for production): https://bitbucket.org/bogglez/libgl15
My lxdream fork (with small fixes): https://bitbucket.org/bogglez/lxdream
Twada
DC Developer
DC Developer
Posts: 42
Joined: Wed Jan 20, 2016 4:55 am
Has thanked: 18 times
Been thanked: 53 times

Re: TA bufferes initialize

Post by Twada »

Thank you for your comment!
I tried some low addresses. However, the Dreamcast was frozen.

I noticed that this cause is in 0xa05f808c register.

Code: Select all

unsigned int vtx = ( (unsigned int)(vtx_buf[current]) )&0x007fffff;
unsigned int *taend = (unsigned int *)(void *)(0xa5000000|regs[0x138/4]);
......
regs[0x08c/4] = 0x01000000 | ((((char *)taend)-((char *)vtx))<<1);   /*bg plane*/
When commenting out this register, it did not freeze.
I think this register is for BG Plane. I don't know why to set vertex cmd address in this register.
Post Reply