General questions

SGDK only sub forum

Moderator: Stef

Post Reply
vnsbr
Interested
Posts: 40
Joined: Sun Dec 17, 2017 4:13 pm

General questions

Post by vnsbr » Sat Feb 16, 2019 8:32 pm

Hello i have finally something to show https://gendev.spritesmind.net/forum/vi ... f=8&t=2982 source code is included ;)

I have some questions mainly about best practices, i thought it was a good idead to ask them here since its more related forum.
1) do the scrolling directly on DMA or setmapex
.

Background level image is 256px wide I am using
drawimageex and setverticalscroll since it is very small, can it be an issue?
2) Im drawing both hud and background using drawimageex. But i only need 64 pixels for Hud and 256 for stage background. I dont know how to set the planes to be smaller and still not wrap around
Related as above. I put hud in PLAN_A for now. But it takes only 64px wide, so im not sure if its good usage of the plan as it is now. I also need it to be in front of my sprites. Currently i do a hack and check if sprite is near to the hud edge..
3) plan_window usage. Can be useful for hud but couldnt get it to work.
I tried to set same addresses xgm player demo and then use setvscroll (...), but got garbled tiles all around the screen.
Load sprites on demand
Currently i use spr_addspr and spr_release when object gets in/leaves screen. But i made exception for bullets and load a fixed size at startup. Does sgdk has a recommended way to dealing with this kind of thing. It may be problematic since i might not know how many enemies will appear same time in screen before hand.

Thanks! Thats a lot of questions :o

Stef
Very interested
Posts: 2994
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: General questions

Post by Stef » Mon Feb 18, 2019 8:48 am

1) do the scrolling directly on DMA or setmapex
What do you mean by "do the scrolling directly on DMA ?
The good way to do it is to update only 1 row or 1 column of your tilemap, and setMapEx(..) is handy to do it (don't forget to use unpacked Map otherwise it will be damn slow).
Background level image is 256px wide I am using
drawimageex and setverticalscroll since it is very small, can it be an issue?
drawImageEx(..) both upload tiles to VRAM and set the tilemap so yeah it's quite slow, but if you do it only once (level loading) it's fine.
2) Im drawing both hud and background using drawimageex. But i only need 64 pixels for Hud and 256 for stage background. I dont know how to set the planes to be smaller and still not wrap around
You can't set the plan smaller, the window is handy when it comes to do a HUD.
But for that you need to have enough VRAM allocated for the window plan (by default SGDK only allow to have the window display on top, it doesn't allocate enough VRAM to display at left/ right or bottom).
Related as above. I put hud in PLAN_A for now. But it takes only 64px wide, so im not sure if its good usage of the plan as it is now. I also need it to be in front of my sprites. Currently i do a hack and check if sprite is near to the hud edge..
Just for your pan in high priority while keeping sprites in low priority, should be enough :)

3) plan_window usage. Can be useful for hud but couldnt get it to work.
Don't forget to setup the window using these methods :

Code: Select all

void VDP_setWindowHPos(u16 right, u16 pos);
void VDP_setWindowVPos(u16 down, u16 pos);
Currently i use spr_addspr and spr_release when object gets in/leaves screen. But i made exception for bullets and load a fixed size at startup. Does sgdk has a recommended way to dealing with this kind of thing. It may be problematic since i might not know how many enemies will appear same time in screen before hand.

Thanks! Thats a lot of questions :o
Using addSpr(..) releaseSpr(..) is a good strategy for dynamic sprites when you don't necessary how many you can have, and indeed it's better to use a fixed pool of sprites for bullet (and limit it to 30 sprites for 30 bullets max for instance) where you can use SPR_setVisible(HIDDEN) to quickly hide it (less taxing on CPU than SPR_release(..) / SPR_add(..))

vnsbr
Interested
Posts: 40
Joined: Sun Dec 17, 2017 4:13 pm

Re: General questions

Post by vnsbr » Mon Feb 18, 2019 1:53 pm

Stef wrote:
Mon Feb 18, 2019 8:48 am
1) do the scrolling directly on DMA or setmapex
What do you mean by "do the scrolling directly on DMA ?
The good way to do it is to update only 1 row or 1 column of your tilemap, and setMapEx(..) is handy to do it (don't forget to use unpacked Map otherwise it will be damn slow).
Background level image is 256px wide I am using
drawimageex and setverticalscroll since it is very small, can it be an issue?
drawImageEx(..) both upload tiles to VRAM and set the tilemap so yeah it's quite slow, but if you do it only once (level loading) it's fine.
this is what a meant by dma: https://github.com/kcowolf/GenScrollingMapDemo

yes i use drawimage on initialize then verticalscroll on update, so i guess i should be fine :D

-------------------------------------------------------------------------

can i set plan to be 256x (32 tiles) an start after plan_a like in the mockup?
mock2.png
mock2.png (2.07 KiB) Viewed 2550 times
currently i do like:

Code: Select all

 VDP_drawImageEx(PLAN_B, &level1b, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, TILE_USERINDEX), 8, 0, FALSE, TRUE);
but my plans is set to 64 tiles

Stef
Very interested
Posts: 2994
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: General questions

Post by Stef » Mon Feb 18, 2019 3:29 pm

If you use both PLAN A and plan B or that, yeah you can.
I guess that in this case plan A is fixed as it's a HUD, right ?

vnsbr
Interested
Posts: 40
Joined: Sun Dec 17, 2017 4:13 pm

Re: General questions

Post by vnsbr » Mon Feb 18, 2019 4:14 pm

Stef wrote:
Mon Feb 18, 2019 3:29 pm
If you use both PLAN A and plan B or that, yeah you can.
I guess that in this case plan A is fixed as it's a HUD, right ?
Yes!
I have tried tht but gove me weird results if both planes are 32x32. Once i get on my pc ill take screenshot:D

Stef
Very interested
Posts: 2994
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: General questions

Post by Stef » Mon Feb 18, 2019 5:23 pm

Oh no you can't use 32 tiles mode if you need to do scrolling then, both plan A and B share the same tilemap size and plan B need more than 32 tiles here as you still has the left 8 tiles even if hidden by plan A.

notaz
Very interested
Posts: 191
Joined: Mon Feb 04, 2008 11:58 pm
Location: Lithuania

Re: General questions

Post by notaz » Wed Feb 20, 2019 6:51 pm

A bit off topic: just curious, why do you keep calling the planes/layers "plan"? I believe the official (an unofficial) docs call them (in singular) "plane" or "playfield", or sometimes just "scroll A", but never "plan".

tryphon
Very interested
Posts: 306
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Re: General questions

Post by tryphon » Wed Feb 20, 2019 7:12 pm

Just guessing : because he's French and plane is "plan" in French ? :mrgreen:

vnsbr
Interested
Posts: 40
Joined: Sun Dec 17, 2017 4:13 pm

Re: General questions

Post by vnsbr » Thu Feb 21, 2019 12:35 am

I think i had the variables name mixed in my mind :P. It is plan_a plan_b. I dunno why they are called like so( and not plane_a/b) in the code ahaha maybe it is because french code :D but i am so used i forgot the original name :D

Stef
Very interested
Posts: 2994
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: General questions

Post by Stef » Thu Feb 21, 2019 8:46 am

Oh yeah, that is my mistake so, in french we call that "plan" indeed and i put that constant names in SGDK instead of "plane" :lol:

Post Reply