summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 23c3f9e)
raw | patch | inline | side by side (parent: 23c3f9e)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Tue, 5 Feb 2019 23:42:09 +0000 (02:42 +0300) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Sun, 10 Feb 2019 10:05:11 +0000 (13:05 +0300) |
src/lib/allegro4/allegro.pas | patch | blob | history | |
src/nogl/noGLALSW.inc | patch | blob | history | |
src/wrappers/sdl2/sdl2allegro.inc | patch | blob | history |
index 0560035d927097633e50020754300fea258a49ca..d2483528bd2abc3372b576d0127ba2a350c787c1 100644 (file)
windowed: cint;
end;
+ PRGB = ^RGB;
RGB = record
r, g, b, filler: cuchar;
end;
key_shifts: cint; LibraryLibAllegroVar;
color_map: PCOLOR_MAP_T; LibraryLibAllegroVar;
gfx_driver: PGFX_DRIVER_T; LibraryLibAllegroVar;
+ palette_color: array [0..255] of cint; LibraryLibAllegroVar;
function get_desktop_resolution (width, height: Pcint): cint; LibraryLibAllegroImp;
function get_gfx_mode_list (card: cint): PGFX_MODE_LIST; LibraryLibAllegroImp;
procedure vsync; LibraryLibAllegroImp;
function desktop_color_depth: cint; LibraryLibAllegroImp;
+ procedure select_palette (const p: PALETTE); LibraryLibAllegroImp;
+ procedure unselect_palette; LibraryLibAllegroImp;
+ procedure set_color (index: cint; const p: PRGB); LibraryLibAllegroImp;
+
(* MACRO *)
function install_allegro (system_id: cint; errno_ptr: Pcint; atexit_ptr: AtExitFunction): cint; inline;
function allegro_init: cint; inline;
diff --git a/src/nogl/noGLALSW.inc b/src/nogl/noGLALSW.inc
index e06b9c3f2b3d6af2221424b7157dc03c59dc0da1..d18ff9923e81023e8acfaf1eb9277b2a86e08349 100644 (file)
--- a/src/nogl/noGLALSW.inc
+++ b/src/nogl/noGLALSW.inc
matrixMode: GLenum;
blendMode: Integer;
- globalTransTable: COLOR_MAP_T;
- redTransTable: COLOR_MAP_T;
- greenTransTable: COLOR_MAP_T;
- blueTransTable: COLOR_MAP_T;
- darkTransTable: COLOR_MAP_T;
- lightTransTable: COLOR_MAP_T;
+ vram_usage, xram_usage: Integer;
function AddTexture: Integer;
var i: Integer;
tex[ctex].bmp := create_bitmap(width, height);
assert(tex[ctex].bmp <> nil);
+ vram_usage += width * height;
if pixels = nil then exit;
p := pixels;
if format = GL_RGBA then
begin
+ xram_usage += width * height * 4;
if sdl2allegro_bpp <= 8 then
trans := 0
else
end
else
begin
+ xram_usage += width * height * 3;
for j := 0 to height - 1 do
for i := 0 to width - 1 do
begin
p := pixels;
if format = GL_RGBA then
begin
+ xram_usage += width * height * 4;
if sdl2allegro_bpp <= 8 then
trans := 0
else
end
else
begin
+ xram_usage += width * height * 4;
for j := 0 to height - 1 do
for i := 0 to width - 1 do
begin
procedure nogl_Init;
begin
cmds.mode := GL_INVALID_ENUM;
- create_trans_table(@globalTransTable, default_palette, 255, 255, 255, nil);
- create_trans_table(@redTransTable, default_palette, 0, 255, 255, nil);
- create_trans_table(@greenTransTable, default_palette, 255, 0, 255, nil);
- create_trans_table(@blueTransTable, default_palette, 255, 255, 0, nil);
- create_trans_table(@darkTransTable, default_palette, 191, 191, 191, nil);
- create_trans_table(@lightTransTable, default_palette, 64, 64, 64, nil);
- color_map := @globalTransTable;
end;
procedure nogl_Quit;
begin
+ e_LogWritefln('vram=%s xram=%s', [vram_usage, xram_usage]);
end;
initialization
index 8cbe419a16d73813a96203b35997f09ea2cf4b9d..a5de6da8d5ad15f3f407d13b8c4aca4570fdb319 100644 (file)
var
sdl2allegro_screen: PBITMAP;
sdl2allegro_bpp: Integer;
+ globalTransTable: COLOR_MAP_T;
+ redTransTable: COLOR_MAP_T;
+ greenTransTable: COLOR_MAP_T;
+ blueTransTable: COLOR_MAP_T;
+ darkTransTable: COLOR_MAP_T;
+ lightTransTable: COLOR_MAP_T;
+
/// FUNCTIONS ///
{$IFDEF GO32V2}
go32,
{$ENDIF}
- e_Log, g_options, SysUtils, Math, ctypes;
+ e_Log, g_options, SysUtils, Math, Classes, ctypes;
const
maxKeyBuffer = 64;
useVsync: Boolean;
ticks: UInt32;
quit: Boolean;
+ custompal: PALETTE;
s2lc: array [0..KEY_MAX] of char = (
#00, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
SDL_SCANCODE_UNKNOWN (* KEY_MAX *)
);
+ procedure LoadCustomPalette (const name: String);
+ var f: TFileStream; i: Integer;
+ begin
+ try
+ f := TFileStream.Create(name, fmOpenRead);
+ e_LogWriteLn('Load custom palette ' + name);
+ for i := 0 to 255 do
+ begin
+ custompal[i].r := f.ReadByte();
+ custompal[i].g := f.ReadByte();
+ custompal[i].b := f.ReadByte();
+ custompal[i].filler := $FF;
+ end;
+ f.Destroy
+ except
+ e_LogWriteLn('Fallback to default palette');
+ custompal := default_palette;
+(*
+ for i := 0 to 255 do
+ begin
+ custompal[i].r := i div 4;
+ custompal[i].g := i div 4;
+ custompal[i].b := i div 4;
+ custompal[i].filler := $FF;
+ end;
+*)
+ end
+ end;
+
+ procedure UpdatePalette;
+ begin
+ set_palette(custompal);
+ select_palette(custompal);
+ create_trans_table(@globalTransTable, custompal, 255, 255, 255, nil);
+ create_trans_table(@redTransTable, custompal, 0, 255, 255, nil);
+ create_trans_table(@greenTransTable, custompal, 255, 0, 255, nil);
+ create_trans_table(@blueTransTable, custompal, 255, 255, 0, nil);
+ create_trans_table(@darkTransTable, custompal, 191, 191, 191, nil);
+ create_trans_table(@lightTransTable, custompal, 64, 64, 64, nil);
+ color_map := @globalTransTable;
+ end;
+
function IsEmptyKeyboard: Boolean;
begin
result := keybeg = keyend
window.w := w;
window.h := h;
window.mode := mode;
+ UpdatePalette;
result := window
end
end;
if sdl2allegro_screen = nil then
sdl2allegro_screen := create_bitmap(window.w, window.h);
ASSERT(sdl2allegro_screen <> nil);
- set_palette(desktop_palette);
+ UpdatePalette;
window.mode := mode;
result := 0
end
if sdl2allegro_screen = nil then
sdl2allegro_screen := create_bitmap(w, h);
ASSERT(sdl2allegro_screen <> nil);
- set_palette(desktop_palette);
+ UpdatePalette;
window.w := w;
window.h := h
end
deskw := 640;
deskh := 480
end;
+ LoadCustomPalette('PLAYPAL.LMP');
result := 0
end
end;