Pal map assign

From Bennu Wiki
Jump to: navigation, search


Syntax

INT pal_map_assign ( <INT fileID> , <INT graphID>, <INT paletteID> )

Description

Changes the color palette of an 8 bit (256 color) graphic, with the palette that is loaded with Pal_load(). This palette can also be loaded from MAP's, FPG's, FNT's and other image formats, provided that they are 8 bit images. Unlike Pal_set(), the change is immediately visible.


Parameters

INT fileID - The fileID of the graphic(s), i.e. 0 for the systemfile, or the id code of an FPG archive.
INT graphID - The graphic (or mapcode) to modify.
INT paletteID - The handle of the color palette loaded with Pal_load().

Returns

INT : Error.

0 - Error: could not open file; corrupt or truncated file; file doesn't contain palette information.
1 - No error: palette was loaded with success.

Example

/* Original example from bennupack: 2 Medium\fenix test\palettes\rbear8_1.prg (from bomberlink) */

IMPORT "mod_debug";
IMPORT "mod_say";
IMPORT "mod_map";
IMPORT "mod_key";
IMPORT "mod_video";
IMPORT "mod_text";

GLOBAL
   int pal_orange;  // palette 1
   int pal_green;   // palette 2
   
   int map_count;

   int fpg_id;

PROCESS main();

BEGIN

    set_fps(10,0);
    set_mode(320,200,16);

    // load the fpg archive
    fpg_id=fpg_load("rbear8.fpg");
    
    // load the two palettes
    pal_orange=pal_load("rbear8-orange.pal");
    pal_green=pal_load("rbear8-green.pal");

    write_int(0,10,10,0,&fps);
    write(0,10,20,0,"F1/F2 - change palette");

    x=160;
    y=120;

    WHILE (NOT key(_ESC))
    
        FROM graph=1 TO 3;
        
          FRAME;
           
           IF (key(_F1))
              FROM map_count=1 TO 102;
                 say("changing colors: "+map_count);
                 pal_map_assign(fpg_id,map_count,pal_green);  // apply palette 1
              END
           END
           
           IF (key(_F2))
              FROM map_count=1 TO 102;
                 say("changing colors: "+map_count);
                 pal_map_assign(fpg_id,map_count,pal_orange); // apply palette 2
              END
           END
        
           IF (key(_ESC)) 
              BREAK; 
           END
        END
    END

END

Used in example: Pal_load(), Say(), Set_fps(), Set_mode(), Write(), Write_int()


Mod_map
Globals None
Imported:
FullscreenGraphmodeM7ScalemodeScaleresolutionScaleresolutionaspectratioScaleresolutionorientation
Constants BCLEARCHARSETCP850CHARSETISO8859GANIMATIONSPEEDGANIMATIONSTEPGANIMATIONSTEPSGCENTERXGCENTERYGDEPTHGFRAMESGHEIGHTGPITCHGWIDEGWIDTHGXCENTERGYCENTERNFBFIXEDWIDTHNFBVARIABLEWIDTH
Imported:
BABLENDBALPHABHMIRRORBNOCOLORKEYBSBLENDBTRANSLUCENTBVMIRRORDOUBLEBUFFERHWSURFACEM1024X768M1280X1024M320X200M320X240M320X400M360X240M376X282M400X300M512X384M640X400M640X480M800X600MODE16BITSMODE16BPPMODE2XSCALEMODE8BITSMODE8BPPMODEDOUBLEBUFFERMODEFRAMELESSMODEFULLSCREENMODEHARDWAREMODEMODALMODEWAITVSYNCMODEWINDOW
Functions Bdfload()Centerset()Colorfind()Colorsget()Colorsset()Fade()Fadeoff()Fadeon()Fntload()Fntnew()Fntsave()Fntunload()Fpgadd()Fpgdel()Fpgexists()Fpgload()Fpgnew()Fpgsave()Fpgunload()Getpixel()Glyphget()Glyphset()Graphicinfo()Graphicset()Mapblockcopy()Mapbuffer()Mapclear()Mapclone()Mapdel()Mapexists()Mapgetpixel()Mapinfo()Mapinfoget()Mapinfoset()Mapload()Mapname()Mapnew()Mapput()Mapputpixel()Mapsave()Mapsetname()Mapunload()Mapxput()Mapxputnp()Palclone()Paldel()Palget()Palload()Palmapassign()Palmapgetid()Palmapremove()Palnew()Palrefresh()Palsave()Palset()Palunload()Paletteconvert()Paletteroll()Pcxload()Pngload()Pngsave()Pointget()Pointset()Putpixel()Rgb()Rgbget()Rgba()Rgbaget()