Skip to content

Commit

Permalink
import from clipboard added
Browse files Browse the repository at this point in the history
  • Loading branch information
RetroNick2020 committed Feb 24, 2023
1 parent 8758a73 commit 4e9da52
Show file tree
Hide file tree
Showing 12 changed files with 334 additions and 104 deletions.
2 changes: 1 addition & 1 deletion mapeditor.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ object MapEdit: TMapEdit
Height = 682
Top = 159
Width = 1130
Caption = 'Map Edititor'
Caption = 'Map Editor'
ClientHeight = 662
ClientWidth = 1130
Menu = MainMenu1
Expand Down
2 changes: 1 addition & 1 deletion rmabout.pas
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,lclintf;

Const
ProgramName ='Raster Master v1.4 R75';
ProgramName ='Raster Master v1.4 R77';
ProgramLicense = 'Released under MIT License';

type
Expand Down
2 changes: 1 addition & 1 deletion rmcolorvga.lfm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object RMVgaColorDialog: TRMVgaColorDialog
AnchorSideRight.Side = asrBottom
Left = 13
Height = 120
Top = -3
Top = 8
Width = 474
ButtonHeight = 60
ButtonWidth = 60
Expand Down
61 changes: 57 additions & 4 deletions rmcore.pas
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ function CanLoadPaletteFile(PaletteMode : integer) : boolean;
function isAmigaPaletteMode(pm : integer) : boolean;
function ColIndexToHoverInfo(colIndex : integer; pm : integer) : string;

procedure LoadPaletteBuf(var PalBuf : TRMPaletteBuf; PaletteMode : integer);
Procedure MakeRGBToEGACompatible(r,g,b : integer;var er,eg,eb : integer);

implementation

Expand Down Expand Up @@ -712,7 +714,6 @@ function RGBToEGAIndex(r,g,b : integer) : integer;
var
i : integer;
begin
(*
for i:=0 to 63 do
begin
if (EGADefault64[i].r = r) AND(EGADefault64[i].g = g) AND (EGADefault64[i].b = b) then
Expand All @@ -721,9 +722,32 @@ function RGBToEGAIndex(r,g,b : integer) : integer;
exit;
end;
end;
RGBToEGAIndex:=RGBToEGAIndex2(r,g,b); // not precise but we come up with a number
*)
RGBToEGAIndex:=RGBTOEGA(r,g,b);
RGBToEGAIndex:=RGBToEGA(EightToTwoBit(r),EightToTwoBit(g),EightToTwoBit(b));
//RGBToEGAIndex:=RGBToEGAIndex2(r,g,b); // not precise but we come up with a number

// RGBToEGAIndex:=RGBTOEGA(r,g,b);
end;

Procedure MakeRGBToEGACompatible(r,g,b : integer;var er,eg,eb : integer);
var
i : integer;
begin
for i:=0 to 63 do
begin
if (EGADefault64[i].r = r) AND(EGADefault64[i].g = g) AND (EGADefault64[i].b = b) then
begin
er:=r;
eg:=g;
eb:=b;
exit;
end;
end;
er:=EightToTwoBit(r);
er:=TwoToEightBit(er);
eg:=EightToTwoBit(g);
eg:=TwoToEightBit(eg);
eb:=EightToTwoBit(b);
eb:=TwoToEightBit(eb);
end;

function RGBToEGAIndex2(r,g,b : integer) : integer;
Expand Down Expand Up @@ -757,6 +781,35 @@ procedure GetDefaultRGBVGA(index : integer;var cr : TRMColorREc);
cr:=VGADefault256[index];
end;


procedure LoadPaletteBuf(var PalBuf : TRMPaletteBuf; PaletteMode : integer);
begin
if PaletteMode = PaletteModeMono then
begin
Move(MonoDefault,PalBuf,sizeof(MonoDefault));
end
else if PaletteMode = PaletteModeCGA0 then
begin
Move(CGADefault0,PalBuf,sizeof(CGADefault0));
end
else if PaletteMode = PaletteModeCGA1 then
begin
Move(CGADefault1,PalBuf,sizeof(CGADefault1));
end
else if isAmigaPaletteMode(PaletteMode) then
begin
Move(AmigaDefault32,PalBuf,sizeof(AmigaDefault32));
end
else if PaletteMode = PaletteModeEGA then
begin
Move(EGADefault16,PalBuf,sizeof(EGADefault16));
end
else
begin
Move(VGADefault256,PalBuf,sizeof(VGADefault256));
end;
end;

Constructor TRMPalette.create;
begin
ColorCount:=0;
Expand Down
12 changes: 11 additions & 1 deletion rmmain.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,8 @@ procedure TRMMainForm.UpdatePaletteMenu;
PaletteEGA.Checked:=false;
PaletteVGA.Checked:=false;
PaletteVGA256.Checked:=false;
PaletteXGA.Checked:=false;
PaletteXGA256.Checked:=false;
PaletteAmiga.Checked:=false;
PaletteAmiga2.Checked:=false;
PaletteAmiga4.Checked:=false;
Expand All @@ -1483,6 +1485,14 @@ procedure TRMMainForm.UpdatePaletteMenu;
begin
PaletteVGA.Checked:=true;
end
else if pm = PaletteModeXGA256 then
begin
PaletteXGA256.Checked:=true;
end
else if pm = PaletteModeXGA then
begin
PaletteXGA.Checked:=true;
end
else if pm = PaletteModeEGA then
begin
PaletteEGA.Checked:=true;
Expand Down Expand Up @@ -2087,7 +2097,7 @@ procedure TRMMainForm.OpenFileClick(Sender: TObject);
end
else if (ext = '.LBM') or (ext = '.BBM') or (ext = '.ILBM') or (ext = '.IFF') then
begin
if ReadILBM(OpenDialog1.FileName,x,y,x2,y2,lp) <> 0 then
if ReadILBM(OpenDialog1.FileName,x,y,x2,y2,lp,pm) <> 0 then
begin
ShowMessage('Error Opening IFF/ILBM file!');
exit;
Expand Down
9 changes: 3 additions & 6 deletions rwbmp.pas
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ function GetMaxColor : integer;
RMCoreBase.PutPixel(x+i-1,y+j-1,Uline[i-1]);
end;
end;

end
else if myBmp.Bits=4 then
begin
Expand Down Expand Up @@ -331,18 +330,16 @@ function GetMaxColor : integer;


If (lp=1) and (CanLoadPaletteFile(pm)) and (myColNum > 0) then //we do not load palette for mono and cga or if we are select/clip open mode pal=0
begin
begin
if pm=PaletteModeEGA then //if we are in ega palette mode we need to be able to remap rgb color ega64 palette
begin //if not we skip setting that color
for i:=0 to myColNum-1 do
begin
cr.r:=bmpPal[i].red;
cr.g:=bmpPal[i].green;
cr.b:=bmpPal[i].blue;
if RGBToEGAIndex(cr.r,cr.g,cr.b) > -1 then //if this returns an index to EGA color we can accept it
begin
RMCoreBase.Palette.SetColor(i,cr);
end;
MakeRGBToEGACompatible(cr.r,cr.g,cr.b,cr.r,cr.g,cr.b);
RMCoreBase.Palette.SetColor(i,cr);
end;
end
else if isAmigaPaletteMode(pm) then
Expand Down
58 changes: 51 additions & 7 deletions rwgif.pas
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,57 @@ function RGif(x,y,x2,y2,Lp,Pm : integer;filename : string) : integer;
error:=LoadGif(filename);
if (error = 0) and (Lp = 1) and (pm <>PaletteModeMono ) and (pm<>PaletteModeCGA0) and (pm<>PaletteModeCGA1) and (pm<> PaletteModeEGA) then
begin
For i:=0 to myNumCols-1 do
begin
cr.r:=GifPalette[i*3];
cr.g:=GifPalette[i*3+1];
cr.b:=GifPalette[i*3+2];
RMCoreBase.Palette.SetColor(i,cr);
end;
// For i:=0 to myNumCols-1 do
// begin
// cr.r:=GifPalette[i*3];
// cr.g:=GifPalette[i*3+1];
// cr.b:=GifPalette[i*3+2];
// RMCoreBase.Palette.SetColor(i,cr);
// end;

if pm=PaletteModeEGA then //if we are in ega palette mode we need to be able to remap rgb color ega64 palette
begin //if not we skip setting that color
for i:=0 to myNumCols-1 do
begin
cr.r:=GifPalette[i*3];
cr.g:=GifPalette[i*3+1];
cr.b:=GifPalette[i*3+2];
MakeRGBToEGACompatible(cr.r,cr.g,cr.b,cr.r,cr.g,cr.b);
RMCoreBase.Palette.SetColor(i,cr);
end;
end
else if isAmigaPaletteMode(pm) then
begin
for i:=0 to myNumCols-1 do
begin
cr.r:=FourToEightBit(EightToFourBit(GifPalette[i*3]));
cr.g:=FourToEightBit(EightToFourBit(GifPalette[i*3+1]));
cr.b:=FourToEightBit(EightToFourBit(GifPalette[i*3+2]));
RMCoreBase.Palette.SetColor(i,cr);
end;
end
else if (pm=PaletteModeVGA) or (pm=PaletteModeVGA256) then
begin
for i:=0 to myNumCols-1 do
begin
cr.r:=SixToEightBit(EightToSixBit(GifPalette[i*3])); //we bitshift because if palette was saved when PaletteModeXga or PaletteModeXga256
cr.g:=SixToEightBit(EightToSixBit(GifPalette[i*3+1])); //we will have invalid values
cr.b:=SixToEightBit(EightToSixBit(GifPalette[i*3+2]));
RMCoreBase.Palette.SetColor(i,cr);
// SetColor(i,cr);
end;
end
else if (pm=PaletteModeXGA) or (pm=PaletteModeXGA256) then
begin
for i:=0 to myNumCols-1 do
begin
cr.r:=GifPalette[i*3];
cr.g:=GifPalette[i*3+1];
cr.b:=GifPalette[i*3+2];
RMCoreBase.Palette.SetColor(i,cr);
// SetColor(i,cr);
end;
end;
end;
RGif:=error;
end;
Expand Down
51 changes: 41 additions & 10 deletions rwilbm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@


function WriteILBM(filename : string; x,y,x2,y2 : word;cmp :byte) : word;
function ReadILBM(filename : string; x,y,x2,y2,lp : integer) : word;
function ReadILBM(filename : string; x,y,x2,y2,lp,pm : integer) : word;

Implementation

Expand Down Expand Up @@ -310,7 +310,7 @@ function ReadILBM(filename : string; x,y,x2,y2,lp : integer) : word;
end; //next i
end;

Procedure ProcessCMAP(var F: File;cmapsize : longword; lp : integer);
Procedure ProcessCMAP(var F: File;cmapsize : longword; lp,pm : integer);
var
numColors,i : integer;
cmap : ColorMapRec;
Expand All @@ -322,10 +322,41 @@ function ReadILBM(filename : string; x,y,x2,y2,lp : integer) : word;
BlockRead(F,cmap,sizeof(cmap));
if lp = 1 then
begin
cr.r:=cmap.red;
cr.g:=cmap.green;
cr.b:=cmap.blue;
SetColor(i,cr);
// cr.r:=cmap.red;
// cr.g:=cmap.green;
// cr.b:=cmap.blue;
// SetColor(i,cr);
if pm=PaletteModeEGA then //if we are in ega palette mode we need to be able to remap rgb color ega64 palette
begin //if not we skip setting that color
cr.r:=cmap.red;
cr.g:=cmap.green;
cr.b:=cmap.blue;
MakeRGBToEGACompatible(cr.r,cr.g,cr.b,cr.r,cr.g,cr.b);
RMCoreBase.Palette.SetColor(i,cr);
end
else if isAmigaPaletteMode(pm) then
begin
cr.r:=FourToEightBit(EightToFourBit(cmap.red));
cr.g:=FourToEightBit(EightToFourBit(cmap.green));
cr.b:=FourToEightBit(EightToFourBit(cmap.blue));
RMCoreBase.Palette.SetColor(i,cr);
end
else if (pm=PaletteModeVGA) or (pm=PaletteModeVGA256) then
begin
cr.r:=SixToEightBit(EightToSixBit(cmap.red)); //we bitshift because if palette was saved when PaletteModeXga or PaletteModeXga256
cr.g:=SixToEightBit(EightToSixBit(cmap.green)); //we will have invalid values
cr.b:=SixToEightBit(EightToSixBit(cmap.blue));
RMCoreBase.Palette.SetColor(i,cr);
// SetColor(i,cr);
end
else if (pm=PaletteModeXGA) or (pm=PaletteModeXGA256) then
begin
cr.r:=cmap.red;
cr.g:=cmap.green;
cr.b:=cmap.blue;
RMCoreBase.Palette.SetColor(i,cr);
// SetColor(i,cr);
end;
end;
// SetRGBPalette(i,cmap.red ,cmap.green ,cmap.blue ); //todo
end;
Expand All @@ -347,7 +378,7 @@ function ReadILBM(filename : string; x,y,x2,y2,lp : integer) : word;
chunkname[chunknamelength]:=chr(newbyte);
end;

Procedure Process(var F : File;x,y,x2,y2,lp : integer);
Procedure Process(var F : File;x,y,x2,y2,lp,pm : integer);
var
chunkname : chunknamerec;
chunknamelength : integer;
Expand Down Expand Up @@ -392,7 +423,7 @@ function ReadILBM(filename : string; x,y,x2,y2,lp : integer) : word;
begin
BlockRead(F,cmapsize,sizeof(cmapsize));
cmapsize:=LongToLE(cmapsize);
ProcessCMAP(F,cmapsize,lp);
ProcessCMAP(F,cmapsize,lp,pm);
end
else if (chunkname ='BODY') And FoundBMap then
begin
Expand Down Expand Up @@ -728,15 +759,15 @@ function WriteILBM(filename : string; x,y,x2,y2 : word;cmp :byte) : word;
end;


function ReadILBM(filename : string; x,y,x2,y2,lp : integer) : word;
function ReadILBM(filename : string; x,y,x2,y2,lp,pm : integer) : word;
var
f : file;
begin
SetCoreActive;
Assign(F,filename);
{$I-}
Reset(F,1);
Process(F,x,y,x2,y2,lp);
Process(F,x,y,x2,y2,lp,pm);
Close(f);
{$I+}
ReadILBM:=IORESULT;
Expand Down
6 changes: 2 additions & 4 deletions rwpcx.pas
Original file line number Diff line number Diff line change
Expand Up @@ -664,10 +664,8 @@ function GetMaxColor : integer;
cr.r:=PcxPal[i,0];
cr.g:=PcxPal[i,1];
cr.b:=PcxPal[i,2];
if RGBToEGAIndex(cr.r,cr.g,cr.b) > -1 then //if this returns an index to EGA color we can accept it
begin
RMCoreBase.Palette.SetColor(i,cr);
end;
MakeRGBToEGACompatible(cr.r,cr.g,cr.b,cr.r,cr.g,cr.b);
RMCoreBase.Palette.SetColor(i,cr);
end;
end
else if isAmigaPaletteMode(pm) then
Expand Down
Loading

0 comments on commit 4e9da52

Please sign in to comment.