I think I figured out the problem, just don't know how to fix the problem. It appears that Chankast allows for unaligned reads/writes, but of course a real dreamcast does not.
The problem is when the memory is accessed for 32 bit and 16 bit reads and writes. I took a stab at fixing it but by bitshifting and masking experience is severly lacking 
here is what I used for the 32bit write
Code:
void storeL(_u32 address, _u32 data)
{
/*_u32* ptr = translate_address_write(address);
//Write
if (ptr)
{
*ptr = htole32(data);
post_write(address);
}
*/
unsigned int word1=(data>>16)&0xffff;
unsigned int word2=data&0xffff;
address&=0xffffff;
storeW(address,word1);
storeW(address+2,word2);
}
this is how we fixed the alignment problem in neocd. But I need to change the storeW - 16 bit write and I don't know how to do that
here was my stab at it
Code:
void storeW(_u32 address, _u16 data)
{
/*_u16* ptr = translate_address_write(address);
//Write
if (ptr)
{
*ptr = htole16(data);
post_write(address);
}
*/
unsigned int word1=(data>>8)&0x00ff;
unsigned int word2=data&0xff00;
address&=0xfffffe;
storeB(address,word1);
storeB(address+1,word2);
}
and here is the 8 bit write function that appears to be working
Code:
void storeB(_u32 address, _u8 data)
{
_u8* ptr = translate_address_write(address);
//Write
if (ptr)
{
*ptr = data;
post_write(address);
}
}
and for reads here is the 32 bit
Code:
_u32 loadL(_u32 address)
{
/*_u32* ptr = translate_address_read(address);
if (ptr == NULL)
return 0;
else
return le32toh(*ptr);
*/
_u16 data;
address&=0xfffffe;
data=loadW(address)<<16;
data|=loadW(address+2);
return data;
}
need help with the 16 bit read
Code:
_u16 loadW(_u32 address)
{
//printf("address=%0x\n",address);
/*_u16* ptr = translate_address_read(address);
//printf("ptr=%0x\n",ptr);
if (ptr == NULL)
return 0;
else
return le16toh(*ptr);
*/
_u16 data;
address&=0xfffffe;
data=loadB(address)<<8;
data|=loadB(address+1);
return data;
}
and here is the 8 bit read
Code:
_u8 loadB(_u32 address)
{
_u8* ptr = translate_address_read(address);
if (ptr == NULL)
return 0;
else
return *ptr;
}
Thanks
Troy
Bookmarks