Message Board


Message Board > Fenix / Bennu / Gemix / DIV > Using pointers to change mode7 playfield

December 23, 2006, 09:28
Atari
old guy
18 posts

I've been reading up on pointers and at first, I couldn't get my head around them. While pondering them, I think I somewhat get it now. So here's my question...

I'm writing a game using Fenix for Dreamcast (0.84b), and due to it's overhead, I've had to optimize quite a bit to keep the frame rate up to a decent rate. One of the unfortunate realities of this is that I cannot call mode7 more than once, or it'll drop the frame rate by 3-5 frames each time you call it. stop_mode7 doesn't work in this case either. My question is, can I use a pointer to "stuff" a different graph number into the running mode7 playfield to change it without having to stop_mode7 and call it again? If I understand pointers correctly, you can assign a variable to point to the memory location where the mode7 background graphs are stored. It seems like it would make sense that you could change the value in that location using this variable. But I wouldn't know how to go about it. Is this possible, and if so, could someone help by providing a small example? I'll credit you in my game once it's finished :)

Thanks for any and all help offered.
____________
#
December 23, 2006, 11:53
Sandman
F3n!x0r
1194 posts

I don't think you can adjust it on the fly using pointers, but perhaps you can use map_put() on the graphID used for Mode7, although I doubt this will work. In fact, I doubt you can adjust it on the fly at all.
____________
BennuWiki
Yes, my avatar has grey borders in IE (so get a decent browser)
ROOFLEZ ROOFLEZ
#
December 23, 2006, 15:04
PEader
お前はもう死んでいる
1486 posts

The mode7 process would need to use a pointer for you to pass it a pointer. In Div there was a function to refresh the mode7 and scroll windows does Fenix not have something similar? Then you could do what Sandman suggested.
____________
I see 57,005 people.
#
December 24, 2006, 02:11
Atari
old guy
18 posts

I looked around for any DIV info about refreshing the mode7 window but couldn't find any. Anyone have any idea how this is done?

I tried to use map_put, but there's really no way to get rid of the underlying playfield once you overlay the new one. I only want to change and refresh the playfield once every 5-8 levels or so, but stopping the current mode7 window and starting a new one just drops the frame rate every time. I may end up having to stick with only one playfield for the entire game if i can't figure out a solution *sigh* :(
____________
#
December 26, 2006, 19:57
Quiest
now with more happynes
142 posts

Do you create a new map everytime you use start_mode7? If so, did you try to unload that map after the stop_mode7?
____________
Roundhousekick to the face, baby!
#
December 26, 2006, 23:30
Atari
old guy
18 posts

Quoting Quiest:
Do you create a new map everytime you use start_mode7? If so, did you try to unload that map after the stop_mode7?


What I did was put the graph number of the map into a struct, then stop_mode7(), change the level number, which is the array element, then call mode7 again, so the line is start_mode7(0,0,lvl_params[level].pfbg,lvl_params[level].pfbg,0,64);

I haven't tried to unload the current map. I'll look that one up, as I've never used unload_map before. Thanks for the suggestion.
____________
#
December 28, 2006, 04:59
Atari
old guy
18 posts

Ok... I'm confused about how load_map and unload_map works. load_map requires a filename, but unload_map requires a library number and graph number? This doesn't make sense to me at all. I tried to load a png file using load_map (the only parameter required is a filename) and use a variable (pf=load_map("foo.png")) for my background, but it didn't work at all. Unloading a map while an FPG is loaded is no problem.

So my question is, what is the proper syntax for load_map?
____________
#
December 28, 2006, 11:42
yonni
None
420 posts
If you want to load direct from a PNG file then you want to use load_png(string file), not load_map(string file). Fenix perameters seem to assume that you have loaded all of your graphics using an FPG file, and therefore have a library number (set by variable=load_fpg() or variable=fpg_new()) and a graph number (the number of the graph within the FPG). If you want to use a png file loaded using load_png() then you simply pass the library number as 0 and the graph number (set by variable=load_png()). For example:

Code:
global
   fpg;
   png;
   map;
begin
   fpg = load_fpg("fpg.fpg");
   unload_map(fpg,*number of graphic within fpg*);
   unload_fpg(fpg);
   png = load_png("pnggraphic.png");
   unload_map(0,png);
   map = load_map("mapgraphic.map");
   unload_map(0,map);
end;


Using 0 as the library number also works for things like scroll windows, for example:

Code:
start_scroll(0,0,load_png("images\background.png"),0,0,0);


works just as well as:

Code:
start_scroll(0,load_fpg("images\scroll.fpg"),1,0,0,0);


the only difference being that the former requires no fpg file, just the original png.
____________
#
December 28, 2006, 16:20
Atari
old guy
18 posts

Makes more sense now. Thanks for the explanation.

I think what I'll try to do is load all of the m7 playfields with load_png (3 or 4 of them), unloading them as I need new ones. And hopefully, this will cure my slowdown problems.
____________
#
January 11, 2007, 03:46
Atari
old guy
18 posts

Nope. No good. I converted some pngs to map files, loaded a couple of them, stopped mode7, unloaded one as the levels ended, loaded a new one, called mode7 again, and continue to lose 2-5 fps everytime I call mode7. Turns out that DC Fenix is the culprit.

*sigh* oh well... maybe I'll just figure out a way to change the color of the playfield without having to call mode7 everytime. I looked into map_put_pixel, but that would be a royal pain in the ass it seems, as I'd have to put all of the color values and x/y coords into a struct, and for-end the entire thing.

Or maybe I'm just stuck with one playfield...
____________
#

Message Board > Fenix / Bennu / Gemix / DIV > Using pointers to change mode7 playfield

Quick reply


You must log in or register to post.
Copyright © 2005 Booleansoup.com
Questions? Comments? Bug reports? Contact us!