Moving the sprite list, HScroll table locations

SGDK only sub forum

Moderator: Stef

Post Reply
Grind
Very interested
Posts: 69
Joined: Fri Jun 13, 2014 1:26 pm
Location: US
Contact:

Moving the sprite list, HScroll table locations

Post by Grind » Sun Sep 27, 2015 10:24 pm

A certain popular game I have based my engine on draws dialog boxes at the bottom of the screen. Since there is already the level background and foreground tiles I am using the window plane. The problem is that both the HScroll table and sprite list overlap this area in VRAM.

Image

The two vertical lines covering the text are from the HScroll table. The stuff overlapping the character's face is the sprite list. After messing around with VDP_setSpriteListAddress and VDP_setHScrollTableAddress I have gotten this to work for a while:

Code: Select all

	VDP_setPlanSize(64, 32);
	VDP_setSpriteListAddress(0xB600); // Default: 0xBC00
	VDP_setHScrollTableAddress(0xF800); // Default: 0xB800
No more overlap, except this doesn't work anymore with the latest SGDK version. I can still move the sprite list, and the scroll table, but only individually. If I set both the game doesn't start, including setting both to the default values.

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

Re: Moving the sprite list, HScroll table locations

Post by Stef » Mon Sep 28, 2015 8:11 am

It's true than default allocated window area is small, because in 95% of case you won't use it.
I don't really get what you're doing in your code, it seems you are only relocating the sprite and hscroll tables but you are relocating sprite table in the window area O_o ? In the last SGDK version (WIP version at least) i allocate by default like this :

#define WINDOW_DEFAULT 0xB000
#define HSCRL_DEFAULT 0xB800
#define SLIST_DEFAULT 0xBC00
#define APLAN_DEFAULT 0xE000
#define BPLAN_DEFAULT 0xC000

So window plan as only 0x800 bytes which is not enough depending where the window is located (bottom of screen) and if you use the H40 mode.
you can indeed move the HScroll table at 0xF800 but you should keep the sprite table at its current location or move it at 0xFC00 :)

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Moving the sprite list, HScroll table locations

Post by Sik » Mon Sep 28, 2015 4:36 pm

Stef wrote:you are relocating sprite table in the window area O_o ?
Well, as long as the top five rows of the window aren't used (extremely likely when the window is at the bottom of the screen), you can safely fit the sprite table at the beginning of the window table... (it's ten rows in H32 mode, but that's still less than half the screen's height)
Sik is pronounced as "seek", not as "sick".

Grind
Very interested
Posts: 69
Joined: Fri Jun 13, 2014 1:26 pm
Location: US
Contact:

Re: Moving the sprite list, HScroll table locations

Post by Grind » Wed Sep 30, 2015 12:17 am

Thanks for the advice guys. Turns out my problem was just me being an idiot. I forgot to disable interrupts!

Code: Select all

int main() {
	VDP_init();
	SYS_disableInts();
	VDP_setPlanSize(64, 32);
	// Sprite list overlaps the bottom of the window, so move it
	VDP_setHScrollTableAddress(0xF800); // Default: 0xB800
	VDP_setSpriteListAddress(0xFC00); // Default: 0xBC00
	SYS_enableInts();
Still gives problems if I try 0xB000 + 0xB400 but 0xF800 + 0xFC00 seem to work without any issue.

Post Reply