Sprite Jitterbug Issues

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
User avatar
ggvicviper
Posts: 16
Joined: Sat Oct 24, 2015 8:54 pm

Re: Sprite Jitterbug Issues

Post by ggvicviper »

D3thAdd3r wrote:I compiled it and it's strange about those tiles going black. Could you confirm that commenting out the print function here:

Code: Select all

	//Shooting
	if(controller[num] & BTN_A) {
		playerShotTime[num]++;
		if(playerShotTime[num] == 8) {
			playerShotTime[num] = 0;
		}
		
		if(playerShotTime[num] == 0) {
			shotInitNext(num, playerPos[num], playerX[num], playerY[num]);
			playerScore[num] += 100;
			if(num == 0) {
				//PrintLong(7, 1, playerScore[num]);
			} else {
				PrintLong(29, 1, playerScore[num]);
			}
		}
	} else {
		playerShotTime[num] = 255;
	}
fixes the black box issue on your end also?
Confirmed. I took out the button A press, the tiles remain, and no sprite jitters (also because the shots aren't being initailized due to this).
User avatar
ggvicviper
Posts: 16
Joined: Sat Oct 24, 2015 8:54 pm

Re: Sprite Jitterbug Issues

Post by ggvicviper »

D3thAdd3r wrote:Also I do not understand what you are meaning by sprite jitter. I attached what I compiled, does it exhibit the jitter you are talking about? If it does, could you explain a bit more what you mean? To me it looks good and the enemy movement is what I would expect from the code.
The jitter I'm experiencing is that maybe he sprite will be behind a half a frame and jumps back into place back and forth. It's happening on the shot sprites. It happens when you hold the fire button.
User avatar
D3thAdd3r
Posts: 3222
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: Sprite Jitterbug Issues

Post by D3thAdd3r »

I eliminated this line just to test:

Code: Select all

//	Print(1, 27, copyrightString);
then made changed the kernel flags:

Code: Select all

 -DSCREEN_TILES_V=27 -DFIRST_RENDER_LINE=28
as well as commenting out both PrintLong() for the player scores. After that it should be 1 tile shorter and centered vertically and not have that corruption you had previously. It was just to eliminate the possibility something weird was happening because you were out of free cycles in a frame. Maybe sprites only getting half blit before being shown or something. Also what version of the emulator are you using?

I didn't check it out, but you might save some cycles by turning this:

Code: Select all

//main()..
//...
		i = MAX_SHOT_PLAYER;
		while(i--) {
			shotUpdate(i);
		}
into this:

Code: Select all

shotUpdate();

//....in shot.c
[code]
void shotUpdate() {

	i = MAX_SHOT_PLAYER;
	while(i--) {

		if(!(shotFlags[i] & FLAG_ACTIVE)) {
			continue;//return;
		}
//......
and likewise for the enemyUpdate(). I don't know if GCC would optimize away those function calls in those cases. If not that would be a big cycle gain maybe.
Attachments
hypergrid-invaders.hex
more free cycles
(56.06 KiB) Downloaded 331 times
User avatar
ggvicviper
Posts: 16
Joined: Sat Oct 24, 2015 8:54 pm

Re: Sprite Jitterbug Issues

Post by ggvicviper »

D3thAdd3r wrote:I eliminated this line just to test:

Code: Select all

//	Print(1, 27, copyrightString);
then made changed the kernel flags:

Code: Select all

 -DSCREEN_TILES_V=27 -DFIRST_RENDER_LINE=28
as well as commenting out both PrintLong() for the player scores. After that it should be 1 tile shorter and centered vertically and not have that corruption you had previously. It was just to eliminate the possibility something weird was happening because you were out of free cycles in a frame. Maybe sprites only getting half blit before being shown or something. Also what version of the emulator are you using?

I didn't check it out, but you might save some cycles by turning this:

Code: Select all

//main()..
//...
		i = MAX_SHOT_PLAYER;
		while(i--) {
			shotUpdate(i);
		}
into this:

Code: Select all

shotUpdate();

//....in shot.c
[code]
void shotUpdate() {

	i = MAX_SHOT_PLAYER;
	while(i--) {

		if(!(shotFlags[i] & FLAG_ACTIVE)) {
			continue;//return;
		}
//......
and likewise for the enemyUpdate(). I don't know if GCC would optimize away those function calls in those cases. If not that would be a big cycle gain maybe.
I'll give all of those a try, thanks. Not sure if I could already be running out of cycles, but I guess we'll see. However, im not using an emulator. I'm running everything off the Uzebox JAMMA and running on arcade hardware
User avatar
ggvicviper
Posts: 16
Joined: Sat Oct 24, 2015 8:54 pm

Re: Sprite Jitterbug Issues

Post by ggvicviper »

So, I have a bit of good news. I solved half the problem, which was the sprite jittering. Something must have been wrong with the order of which text was being written (and how often), so I moved it outside with a "old score vs new score" setup that notifies when to update the score. Sprite jittering gone.

The other issue remains - two of the BG tiles disappear when a score number is drawn. Any VRAM_TILES flags that have been suggested haven't been working particularly. I've attached the latest hex. Also, you can see my repo in git got updated with my latest code. I've also attached my latest hex. Button 1 now simply fires, but button 2 increases the score for the player.
Attachments
hypergrid-invaders.hex
10/25 build for Hypergrid Invaders
(56.01 KiB) Downloaded 330 times
Post Reply