# HG changeset patch # User koda # Date 1278113478 -7200 # Node ID b50215a8a43de96e2be3c09cc74ae88650ac68cd # Parent ed00aa2b339e8846e54f0e2cca0c138d67179a0f land arrays are allocated dynamically, so DOWNSCALE and LOWRES macros are now removed and replaced by run time flags rqBlurryLand and rqLowRes diff -r ed00aa2b339e -r b50215a8a43d hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Sat Jul 03 00:11:23 2010 +0200 +++ b/hedgewars/hwengine.pas Sat Jul 03 01:31:18 2010 +0200 @@ -373,7 +373,7 @@ //uLandGraphics does not need initialization //uLandObjects does not need initialization //uLandTemplates does not need initialization - //uLandTexture does not need initialization + uLandTexture.initModule; //uLocale does not need initialization uRandom.initModule; //uSHA is initialized internally @@ -402,7 +402,7 @@ uRandom.freeModule; //stub //uLocale does not need to be freed //uLandTemplates does not need to be freed - //uLandTexture does not need to be freed + uLandTexture.freeModule; //uLandObjects does not need to be freed //uLandGraphics does not need to be freed uKeys.freeModule; //stub @@ -495,7 +495,7 @@ isMusicEnabled:= ParamStr(17) = '1'; if (ParamStr(18) = '1') then //HACK - cReducedQuality:= $FFFFFFFF + cReducedQuality:= $FFFFFFFF xor rqLowRes else val(ParamStr(18), cReducedQuality); end; @@ -576,7 +576,7 @@ cShowFPS:= ParamStr(13) = '1'; val(ParamStr(14), cTimerInterval); if (ParamStr(15) = '1') then //HACK - cReducedQuality:= $FFFFFFFF + cReducedQuality:= $FFFFFFFF xor rqLowRes else val(ParamStr(15), cReducedQuality); end diff -r ed00aa2b339e -r b50215a8a43d hedgewars/options.inc --- a/hedgewars/options.inc Sat Jul 03 00:11:23 2010 +0200 +++ b/hedgewars/options.inc Sat Jul 03 01:31:18 2010 +0200 @@ -33,8 +33,6 @@ {$DEFINE SDL_IMAGE_NEWER} {$DEFINE HWLIBRARY} {$DEFINE GLunit:=gles11} - {$DEFINE DOWNSCALE} -// {$DEFINE LOWRES} {$ENDIF} {$IFNDEF DARWIN} diff -r ed00aa2b339e -r b50215a8a43d hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Sat Jul 03 00:11:23 2010 +0200 +++ b/hedgewars/uConsts.pas Sat Jul 03 01:31:18 2010 +0200 @@ -183,7 +183,6 @@ TScreenFade = (sfNone, sfInit, sfToBlack, sfFromBlack, sfToWhite, sfFromWhite); const sfMax = 1000; -const // message constants errmsgCreateSurface = 'Error creating SDL surface'; errmsgTransparentSet = 'Error setting transparent color'; @@ -241,25 +240,6 @@ tpHigh = 0.75; tpHighest = 1.00; - {* REFERENCE - 4096 -> $FFFFF000 - 2048 -> $FFFFF800 - 1024 -> $FFFFFC00 - 512 -> $FFFFFE00 *} - -{$IFDEF LOWRES} - // default for iphone pre 3gs - LAND_WIDTH = 2048; - LAND_HEIGHT = 1024; - LAND_WIDTH_MASK = $FFFFF800; - LAND_HEIGHT_MASK = $FFFFFC00; -{$ELSE} - LAND_WIDTH = 4096; - LAND_HEIGHT = 2048; - LAND_WIDTH_MASK = $FFFFF000; - LAND_HEIGHT_MASK = $FFFFF800; -{$ENDIF} - // To allow these to layer, going to treat them as masks. The bottom byte is reserved for objects // TODO - set lfBasic for all solid land, ensure all uses of the flags can handle multiple flag bits lfBasic = $8000; // white @@ -468,6 +448,10 @@ var PathPrefix: shortstring = './'; Pathz: array[TPathType] of shortstring; CountTexz: array[1..Pred(AMMO_INFINITE)] of PTexture; + LAND_WIDTH :longint; + LAND_HEIGHT :longint; + LAND_WIDTH_MASK :longWord; + LAND_HEIGHT_MASK :longWord; const cTagsMasks : array[0..15] of byte = (7, 0, 0, 0, 15, 6, 4, 5, 0, 0, 0, 0, 0, 14, 12, 13); @@ -2186,12 +2170,30 @@ procedure freeModule; implementation +uses uMisc; procedure initModule; - begin Pathz:= cPathz; - + {* REFERENCE + 4096 -> $FFFFF000 + 2048 -> $FFFFF800 + 1024 -> $FFFFFC00 + 512 -> $FFFFFE00 *} + if (cReducedQuality and rqLowRes) <> 0 then + begin + LAND_WIDTH:= 2048; + LAND_HEIGHT:= 1024; + LAND_WIDTH_MASK:= $FFFFF800; + LAND_HEIGHT_MASK:= $FFFFFC00; + end + else + begin + LAND_WIDTH:= 4096; + LAND_HEIGHT:= 2048; + LAND_WIDTH_MASK:= $FFFFF000; + LAND_HEIGHT_MASK:= $FFFFF800 + end; end; procedure freeModule; diff -r ed00aa2b339e -r b50215a8a43d hedgewars/uLand.pas --- a/hedgewars/uLand.pas Sat Jul 03 00:11:23 2010 +0200 +++ b/hedgewars/uLand.pas Sat Jul 03 01:31:18 2010 +0200 @@ -23,15 +23,10 @@ uses SDLh, uLandTemplates, uFloat, uConsts, GLunit; type -{$IFDEF DOWNSCALE} - TLandArray = packed array[0 .. LAND_HEIGHT div 2 - 1, 0 .. LAND_WIDTH div 2 - 1] of LongWord; -{$ELSE} - TLandArray = packed array[0 .. LAND_HEIGHT - 1, 0 .. LAND_WIDTH - 1] of LongWord; -{$ENDIF} - - TCollisionArray = packed array[0 .. LAND_HEIGHT - 1, 0 .. LAND_WIDTH - 1] of Word; + TLandArray = packed array of array of LongWord; + TCollisionArray = packed array of array of Word; TPreview = packed array[0..127, 0..31] of byte; - TDirtyTag = packed array[0 .. LAND_HEIGHT div 32 - 1, 0 .. LAND_WIDTH div 32 - 1] of byte; + TDirtyTag = packed array of array of byte; var Land: TCollisionArray; LandPixels: TLandArray; @@ -607,27 +602,19 @@ function SelectTemplate: LongInt; begin -case cTemplateFilter of - 0: begin - SelectTemplate:= getrandom(Succ(High(EdgeTemplates))); - end; - 1: begin - SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))]; - end; - 2: begin - SelectTemplate:= MediumTemplates[getrandom(Succ(High(MediumTemplates)))]; - end; - 3: begin - SelectTemplate:= LargeTemplates[getrandom(Succ(High(LargeTemplates)))]; - end; - 4: begin - SelectTemplate:= CavernTemplates[getrandom(Succ(High(CavernTemplates)))]; - end; - 5: begin - SelectTemplate:= WackyTemplates[getrandom(Succ(High(WackyTemplates)))]; - end; -end; -WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter)); + if (cReducedQuality and rqLowRes) <> 0 then + SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))] + else + case cTemplateFilter of + 0: SelectTemplate:= getrandom(Succ(High(EdgeTemplates))); + 1: SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))]; + 2: SelectTemplate:= MediumTemplates[getrandom(Succ(High(MediumTemplates)))]; + 3: SelectTemplate:= LargeTemplates[getrandom(Succ(High(LargeTemplates)))]; + 4: SelectTemplate:= CavernTemplates[getrandom(Succ(High(CavernTemplates)))]; + 5: SelectTemplate:= WackyTemplates[getrandom(Succ(High(WackyTemplates)))]; + end; + + WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter)); end; procedure LandSurface2LandPixels(Surface: PSDL_Surface); @@ -1344,12 +1331,21 @@ begin LandBackSurface:= nil; digest:= ''; - FillChar(LandPixels, sizeof(TLandArray), 0); + + if (cReducedQuality and rqBlurryLand) = 0 then + SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH) + else + SetLength(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2); + + SetLength(Land, LAND_HEIGHT, LAND_WIDTH); + SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32)); end; procedure freeModule; begin - + Land:= nil; + LandPixels:= nil; + LandDirty:= nil; end; end. diff -r ed00aa2b339e -r b50215a8a43d hedgewars/uLandTexture.pas --- a/hedgewars/uLandTexture.pas Sat Jul 03 00:11:23 2010 +0200 +++ b/hedgewars/uLandTexture.pas Sat Jul 03 01:31:18 2010 +0200 @@ -22,6 +22,8 @@ interface uses SDLh; +procedure initModule; +procedure freeModule; procedure UpdateLandTexture(X, Width, Y, Height: LongInt); procedure DrawLand(dX, dY: LongInt); procedure FreeLand; @@ -31,23 +33,15 @@ const TEXSIZE = 256; -{$IFDEF DOWNSCALE} - LANDTEXARW = (LAND_WIDTH div TEXSIZE) div 2; - LANDTEXARH = (LAND_HEIGHT div TEXSIZE) div 2; -{$ELSE} - LANDTEXARW = LAND_WIDTH div TEXSIZE; - LANDTEXARH = LAND_HEIGHT div TEXSIZE; -{$ENDIF} -var - LandTextures: array[0..LANDTEXARW - 1, 0..LANDTEXARH - 1] of - record +type TLandRecord = record shouldUpdate: boolean; tex: PTexture; end; - +var LandTextures: array of array of TLandRecord; tmpPixels: array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord; - +LANDTEXARW: LongWord; + LANDTEXARH: LongWord; function Pixels(x, y: Longword): Pointer; var ty: Longword; begin @@ -135,10 +129,29 @@ FreeTexture(tex); tex:= nil; end; - if LandBackSurface <> nil then SDL_FreeSurface(LandBackSurface); LandBackSurface:= nil; end; +procedure initModule; +begin + if (cReducedQuality and rqBlurryLand) = 0 then + begin + LANDTEXARW:= LAND_WIDTH div TEXSIZE; + LANDTEXARH:= LAND_HEIGHT div TEXSIZE; + end + else + begin + LANDTEXARW:= (LAND_WIDTH div TEXSIZE) div 2; + LANDTEXARH:= (LAND_HEIGHT div TEXSIZE) div 2; + end; + + SetLength(LandTextures, LANDTEXARW, LANDTEXARH); +end; + +procedure freeModule; +begin + LandTextures:= nil; +end; end.