Original Post

I’ve been messing around a little to get a better feel for how the VB does things. I’ve searched the forum for some examples and I found a few and tried every one that I found with no luck. I’m just playing around and trying to directly draw to the frame buffers. Currently this code just draws 5 objects that resemble cubes. That’s it nothing else. It does work and shows up on the screen but I can’t get rid of the “flicker”. I’m sure I’m missing some fundamental piece of information as to how the VB handles the frame buffers but I just can’t seem to get it. I attached my code to this post. Sorry for the mess… I’m just hacking away at stuff and I’ve never programmed in C before so keep that in mind before criticizing my code to hard :). I’m just hoping one of you experts can take a quick look and point me in the right direction. The screenControl() function is where I’m trying to handle the frame buffers and I basically took this code from the hunter game source from danB. I also compared it to some examples posted on this forum and it looks to me like I’m doing the same thing as everyone else but obviously I’m not.

Thanks.

7 Replies

Yes, and I downloaded all the source code references from it which lead me to where I am now.

void drawPixel(u16 x,u16 y, u8 color){
	//Find the byte for the pixel
	color = color<<6>>6;
	xbytel = x*256; //multiply by number of pixels per column
	ybytel = y;
	yleft = ybytel & 0x0F;//grab 1st 4 bits
	if(yleft>0) yleft = yleft<<1;
	xbytel >>= 4;//divide by 16
	ybytel >>= 4;//divide by 16
	
	LFB1[(xbytel + ybytel)] |= (color << yleft);
	RFB1[(xbytel + ybytel)] = LFB1[(xbytel + ybytel)];
	
	//LFB2[(xbytel + ybytel)] = LFB1[(xbytel + ybytel)];
	//RFB2[(xbytel + ybytel)] = LFB1[(xbytel + ybytel)];
}

Why are those last two lines commented out? The XP swaps the framebuffers each frame, so if your second set of buffers are never filled with anything, the screen will rapidly alternate between your drawing and black, causing the flickering.

When I was trying out different scenarios to try and get rid of the “flicker” I had commented those out. I was getting a more sporadic flicker when those were not commented but it’s possible I was using a different technique at the time to write to the buffers. I know I still get flicker when I run it in the reality boy emulator but I’ll try it on the hardware and see if it’s any different. It made sense to me that I should definitely need to write to those but after a few hours of frustration I began to try anything and everything.

Some advice: Reality Boy is really old and has a lot of bugs in the emulation. Use Mednafen– its emulation is much more accurate. =)

I was beginning to think that may have been part of the problem after reading that everyone seemed to be testing on Mednafen. I’ll get that installed and try it out. I’ve just become used to reality boys debug mode which I’ve used for the few translation patches so I continued using it.

blitter, thanks for the advice. Mednafen definitly made a difference. Turns out I had it right at one point but reality boy lead me astray. I uncommented those two lines and I also ended up using

void screenControl(){
	VIP_REGS[XPCTRL] = VIP_REGS[XPSTTS] | XPEN;
	while(!(VIP_REGS[INTPND] & XPEND));
	VIP_REGS[XPCTRL] = VIP_REGS[XPSTTS] & XPENOFF;//Disable drawing	
}

I had a line in to clear the XPEND
VIP_REGS[INTCLR] = XPEND

that I took out since it still caused some minor ficker.

 

Write a reply

You must be logged in to reply to this topic.