Jump to content

Issues with mapping video mem to 32 bit


Zapf Bandit

Recommended Posts

I am writting some 16 colour games in which I want to be able to draw colours directly to individual pixels.

 

I wrote a little function to do this and it works fine on hardware. Unfortunately with dualis it totally stuffs up and ends up garbling the drawing. Here is the function in question.

 

void setCol( uint16* bkg, int x, int y, u32 col )

{

u32* bkg32 = (u32*)bkg;

 

int tx = x/8;

int px = x%8;

 

int ty = y/8;

int py = y%8;

 

u32 row = bkg32[ 8*(32*ty + tx) + py ];

 

u32 mask = ~(0xf << (4*px));

 

col = col << (4*px);

 

bkg32[ 8*(32*ty + tx) + py ] = (row & mask) | col;

 

}

 

I am mapping the graphics to 32 bit since this represents 8 pixels and makes the calculations much more straight forward. I'm not sure if it is this or the logical operations which are causing the issues.

 

I might try a version that doesn't use the 32 bit version and see whether that fixes it.

 

Zapf Bandit

www.zapfbandit.com

Edited by Zapf Bandit
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...