Sprite Engine Help

SGDK only sub forum

Moderator: Stef

MrTamk1s
Very interested
Posts: 75
Joined: Sun Jan 04, 2015 10:27 pm
Location: Pennsylvania
Contact:

Re: Sprite Engine Help

Post by MrTamk1s » Wed Feb 03, 2016 2:02 am

Hate to bump, but still trying to debug the issues.
Next important graphics-related issues to fix are some sprites disappearing... Not sure why, but when I enable the powerups options variables (Opts[2]=PTRUE in main.h) and the game attempts to display the saved and active powerups for each player on the HUD, all of the sprites in game become invisible. In Gen's VDP VRAM debugger, the VRAM still holds the sprites, but they are not appearing. What in my code is causing this (I suspect pointer issues or badly timed interrupts at play)? Relevant code in game.c, functions InitGame() and HUD().
Looked at the VDP Sprites List in KMod 0.7.3, and, when the powerups are enabled (Opts[2]==PTRUE), the VDP Sprites List is corrupting, though I don't know why. See the pics below for what the sprite list should look like when powerups are disabled. There should only be 3 sprites on the screen when the powerups are disabled. When powerups are enabled, the Sprite List is corrupting with garbage values up to sprite #18, which doesn't make sense, since the game should only have 6 sprites in use (Red Paddle, Blue Paddle, Puck, 3 powerup icons), and since I have hard-coded the game to have an array of 15 sprite game objects. Possibly either a buffer overflow or a stack overflow.

Does anyone see any major coding issues for the code at Github from the previous post to cause these issues? This bug seems to have been introduced when I added puck-paddle collision, and I am certain the issues are under IF blocks that check where (Opts[2]==PTRUE).
Attachments
Pwrups_On.png
Powerups On (Opts[2]==PTRUE)
Pwrups_On.png (106.11 KiB) Viewed 1576 times
Pwrups_Off.png
Powerups Off (Opts[2]==_FALSE)
Pwrups_Off.png (90.48 KiB) Viewed 1576 times
SGDK homebrew dev and Unity3D Indie dev.
Sega does what Nintendont!

dub
Very interested
Posts: 101
Joined: Thu Mar 19, 2015 1:26 pm

Re: Sprite Engine Help

Post by dub » Wed Feb 03, 2016 8:24 am

For your power-ups, maybe it's an init link problems.
I can't have time to compile and test because you use a specific batch.

I think, when you use the sgdk sprite-engine, you can't allow empty slot between sprites. And we see the mess in your link satb.

Code: Select all

#define SOff_paddle 0   //Always 0 
232 #define SOff_pucks 2    //Always stars at 2 
233 #define SOff_objects 5  //SOff_pucks+Max_Pucks 
234 #define SOff_power 13   //SOff_objects+Max_Objs 
235 #define SOff_spower 14  //Soff_Power+1 
236 #define SOff_Total 15   //1-based total of sprites (for SPR_Update value) 
So you have sprite 0,1 -> player ,2,3,4,5,6 -> puck, 13,14,15 ->powerups (empty space between 6 and 13)
Try sprite 0,1,2,3,4,5,6,7,8,9

Code: Select all

234 #define SOff_power 7 //SOff_objects+Max_Objs 
235 #define SOff_spower 8 //Soff_Power+1 
236 #define SOff_Total 9 //1-based total of sprites (for SPR_Update value)
But I'm not sure of your sprite number for pucks. Also test with uncomments "//Create Objs" function before to see if all sprites appear.

MrTamk1s
Very interested
Posts: 75
Joined: Sun Jan 04, 2015 10:27 pm
Location: Pennsylvania
Contact:

Re: Sprite Engine Help

Post by MrTamk1s » Wed Feb 03, 2016 11:07 pm

dub wrote:For your power-ups, maybe it's an init link problems.
I can't have time to compile and test because you use a specific batch.

I think, when you use the sgdk sprite-engine, you can't allow empty slot between sprites. And we see the mess in your link satb.

Code: Select all

#define SOff_paddle 0   //Always 0 
232 #define SOff_pucks 2    //Always stars at 2 
233 #define SOff_objects 5  //SOff_pucks+Max_Pucks 
234 #define SOff_power 13   //SOff_objects+Max_Objs 
235 #define SOff_spower 14  //Soff_Power+1 
236 #define SOff_Total 15   //1-based total of sprites (for SPR_Update value) 
So you have sprite 0,1 -> player ,2,3,4,5,6 -> puck, 13,14,15 ->powerups (empty space between 6 and 13)

Try sprite 0,1,2,3,4,5,6,7,8,9

Code: Select all

234 #define SOff_power 7 //SOff_objects+Max_Objs 
235 #define SOff_spower 8 //Soff_Power+1 
236 #define SOff_Total 9 //1-based total of sprites (for SPR_Update value)
But I'm not sure of your sprite number for pucks. Also test with uncomments "//Create Objs" function before to see if all sprites appear.
[/quote]

The space between 2 & 5 will hold 3 pucks (2,3,4, for the multipuck powerup), and the empty space between 6 & 13 is where objects in the game will be (from powerups, such as bumpers, wall pieces, etc). The indices in the GameSprite sprite array are hard coded for each of the particular objects, so the #defines are offsets.

I will try initializing the empty slots with test graphics to see if it will stop the VDP corruption, and if that doesn't work, try splitting the GameSprites variable into a smaller, more logical sprite arrays.
SGDK homebrew dev and Unity3D Indie dev.
Sega does what Nintendont!

dub
Very interested
Posts: 101
Joined: Thu Mar 19, 2015 1:26 pm

Re: Sprite Engine Help

Post by dub » Thu Feb 04, 2016 8:09 am

The space between 2 & 5 will hold 3 pucks (2,3,4, for the multipuck powerup), and the empty space between 6 & 13 is where objects in the game will be (from powerups, such as bumpers, wall pieces, etc). The indices in the GameSprite sprite array are hard coded for each of the particular objects, so the #defines are offsets.
This is why I told you to uncomment your objects sprite code to see if It works :mrgreen:

Post Reply