https://wiki.bennugd.org/index.php?title=Pal_refresh&feed=atom&action=historyPal refresh - Revision history2024-03-29T14:46:23ZRevision history for this page on the wikiMediaWiki 1.36.2https://wiki.bennugd.org/index.php?title=Pal_refresh&diff=9779&oldid=prev82.74.128.190: Created page with 'Category:functions Category:palettes Category:mod_map == Syntax == '''INT''' pal_refresh ( [<'''INT''' paletteID>] ) == Description == Refreshes the color palette …'2012-03-17T13:58:19Z<p>Created page with '<a href="/index.php?title=Category:Functions" class="mw-redirect" title="Category:Functions">Category:functions</a> <a href="/index.php?title=Category:Palettes" class="mw-redirect" title="Category:Palettes">Category:palettes</a> <a href="/index.php?title=Category:Mod_map" class="mw-redirect" title="Category:Mod map">Category:mod_map</a> == Syntax == '''INT''' pal_refresh ( [<'''INT''' paletteID>] ) == Description == Refreshes the color palette …'</p>
<p><b>New page</b></p><div>[[Category:functions]]<br />
[[Category:palettes]]<br />
[[Category:mod_map]]<br />
<br />
== Syntax ==<br />
'''INT''' pal_refresh ( [<'''INT''' paletteID>] )<br />
<br />
== Description ==<br />
<br />
Refreshes the color palette after a call of [[Pal_set]](), to the make color change visible.<br />
<br />
<br />
== Parameters ==<br />
{| <br />
|'''INT''' paletteID || - The handle of the color palette loaded with [[Pal_load]](), and used by [[Pal_get]] and [[Pal_set]](). The parameter is optional. <br />
|}<br />
<br />
<br />
== Returns ==<br />
'''INT''' : Status.<br />
{|<br />
| 1 || - The status.<br />
|}<br />
<br />
== Example ==<br />
<pre><br />
<br />
/* original bennupack example FROM: \2 Medium\fenix test\palettes\rbear8-2.prg (from bomberlink) */<br />
<br />
/* this program demonstrates the use of the functions: pal_load(), pal_clone(), pal_get(), */<br />
/* pal_map_assign(), pal_set() and pal_refresh(). */<br />
<br />
<br />
IMPORT "mod_debug";<br />
IMPORT "mod_say";<br />
IMPORT "mod_map";<br />
IMPORT "mod_key";<br />
IMPORT "mod_video";<br />
IMPORT "mod_text";<br />
<br />
<br />
GLOBAL<br />
<br />
// palette identifiers<br />
int pal_orange;<br />
int pal_green;<br />
int pal_normal;<br />
<br />
int status1;<br />
int status2;<br />
<br />
// identifier of the fpg archive<br />
int fpg_id;<br />
<br />
// arrays for the data of the two color palettes.<br />
byte pal_orange_data[255]; <br />
byte pal_green_data[255]; <br />
<br />
int map_count;<br />
<br />
PROCESS main();<br />
<br />
BEGIN<br />
<br />
set_fps(10,0);<br />
set_mode(320,200,16); // we use a 16 bit color mode<br />
<br />
// load two color palettes and duplicate one<br />
pal_green=pal_load("rbear8-green.pal");<br />
pal_orange=pal_load("rbear8-orange.pal");<br />
<br />
// pal_clone (int pal_id);<br />
pal_normal=pal_clone(pal_orange); // duplicate palette, i.e. make a copy of it.<br />
<br />
// load the fpg file<br />
fpg_id=fpg_load("rbear8.fpg");<br />
<br />
write_int(0,10,10,0,&fps);<br />
write(0,10,20,0,"F1/F2 - change palette");<br />
<br />
x = 160;<br />
y = 120;<br />
<br />
// pal_get (int pal_id, int start_color, int num_colors, pointer pal_data);<br />
pal_get(pal_green,7,7,&pal_green_data); // get colors 7 - 13 and store them in the array<br />
pal_get(pal_orange,7,7,&pal_orange_data); <br />
<br />
FROM map_count=1 TO 102; // there are 102 frames in the animation<br />
<br />
// pal_map_assign (int fileid, int graph, int pal_id);<br />
pal_map_assign(fpg_id,map_count,pal_normal); // assign the "normal (original source)" color <br />
// palette that we duplicated earlier.<br />
END<br />
<br />
WHILE (NOT key(_ESC))<br />
<br />
FROM graph=1 TO 13;<br />
<br />
FRAME;<br />
<br />
IF (key(_F1))<br />
say("switched to green palette");<br />
<br />
// pal_set (int pal_id, int start_color, int num_colors, pointer pal_data);<br />
status1=pal_set(pal_normal,7,7,&pal_green_data); // change colors 7 - 13 in the "normal" <br />
// palette, by using the values from the<br />
// "green" color palette.<br />
<br />
say("pal_set_status: "+status1); <br />
<br />
// pal_refresh (int pal_id);<br />
status2=pal_refresh(pal_normal); // apply the modified color palette to the graphics.<br />
// this function is required to make the change visible. <br />
<br />
say("pal_refresh_status: "+status2); <br />
<br />
// conclusion: the difference between pal_map_assign() and pal_set() is that pal_map_assign()<br />
// works immediately, and that pal_set() requires the palette to be refreshed to make the <br />
// change visible. <br />
END<br />
<br />
IF (key(_F2))<br />
say("switched to orange palette");<br />
pal_set(pal_normal,7,7,&pal_orange_data); // colors 7 - 13<br />
pal_refresh(pal_normal);<br />
END<br />
<br />
IF (key(_ESC)) <br />
BREAK; <br />
END<br />
END<br />
END<br />
<br />
END<br />
</pre><br />
<br />
Used in example: [[Pal_load]](), [[pal_get]](), [[Pal_set]](), [[Pal_map_assign]](), [[Pal_clone]](), [[Say]](), [[Set_fps]](), [[Set_mode]](), [[Write]](), [[Write_int]]()<br />
<br />
<br />
{{Moduledocbox<br />
| module = Mod_map<br />
}}</div>82.74.128.190