1 unit uLandUtils; |
1 unit uLandUtils; |
2 interface |
2 interface |
|
3 uses SDLh; |
3 |
4 |
4 procedure ResizeLand(width, height: LongWord); |
5 procedure ResizeLand(width, height: LongWord); |
5 procedure DisposeLand(); |
6 procedure DisposeLand(); |
6 procedure InitWorldEdges(); |
7 procedure InitWorldEdges(); |
7 |
8 |
8 function LandGet(y, x: LongInt): Word; |
9 function LandGet(y, x: LongInt): Word; |
9 procedure LandSet(y, x: LongInt; value: Word); |
10 procedure LandSet(y, x: LongInt; value: Word); |
|
11 function LandRow(row: LongInt): PWordArray; |
10 |
12 |
11 procedure FillLand(x, y: LongInt; border, value: Word); |
13 procedure FillLand(x, y: LongInt; border, value: Word); |
|
14 |
|
15 function LandPixelGet(y, x: LongInt): Longword; |
|
16 procedure LandPixelSet(y, x: LongInt; value: Longword); |
|
17 function LandPixelRow(row: LongInt): PLongwordArray; |
12 |
18 |
13 implementation |
19 implementation |
14 uses uUtils, uConsts, uVariables, uTypes; |
20 uses uUtils, uConsts, uVariables, uTypes; |
15 |
21 |
16 const LibFutureName = 'hwengine_future'; |
22 const LibFutureName = 'hwengine_future'; |
17 function create_game_field(width, height: Longword): pointer; cdecl; external LibFutureName; |
23 function create_game_field(width, height: Longword): pointer; cdecl; external LibFutureName; |
18 procedure dispose_game_field(game_field: pointer); cdecl; external LibFutureName; |
24 procedure dispose_game_field(game_field: pointer); cdecl; external LibFutureName; |
19 function land_get(game_field: pointer; x, y: LongInt): Word; cdecl; external LibFutureName; |
25 function land_get(game_field: pointer; x, y: LongInt): Word; cdecl; external LibFutureName; |
20 procedure land_set(game_field: pointer; x, y: LongInt; value: Word); cdecl; external LibFutureName; |
26 procedure land_set(game_field: pointer; x, y: LongInt; value: Word); cdecl; external LibFutureName; |
|
27 function land_row(game_field: pointer; row: LongInt): PWordArray; cdecl; external LibFutureName; |
21 procedure land_fill(game_field: pointer; x, y: LongInt; border, fill: Word); cdecl; external LibFutureName; |
28 procedure land_fill(game_field: pointer; x, y: LongInt; border, fill: Word); cdecl; external LibFutureName; |
|
29 |
|
30 function land_pixel_get(game_field: pointer; x, y: LongInt): Longword; cdecl; external LibFutureName; |
|
31 procedure land_pixel_set(game_field: pointer; x, y: LongInt; value: Longword); cdecl; external LibFutureName; |
|
32 function land_pixel_row(game_field: pointer; row: LongInt): PLongwordArray; cdecl; external LibFutureName; |
22 |
33 |
23 var gameField: pointer; |
34 var gameField: pointer; |
24 |
35 |
25 function LandGet(y, x: LongInt): Word; |
36 function LandGet(y, x: LongInt): Word; |
26 begin |
37 begin |
30 procedure LandSet(y, x: LongInt; value: Word); |
41 procedure LandSet(y, x: LongInt; value: Word); |
31 begin |
42 begin |
32 land_set(gameField, x, y, value) |
43 land_set(gameField, x, y, value) |
33 end; |
44 end; |
34 |
45 |
|
46 function LandRow(row: LongInt): PWordArray; |
|
47 begin |
|
48 LandRow:= land_row(gameField, row) |
|
49 end; |
|
50 |
35 procedure FillLand(x, y: LongInt; border, value: Word); |
51 procedure FillLand(x, y: LongInt; border, value: Word); |
36 begin |
52 begin |
37 land_fill(gameField, x, y, border, value) |
53 land_fill(gameField, x, y, border, value) |
|
54 end; |
|
55 |
|
56 function LandPixelGet(y, x: LongInt): Longword; |
|
57 begin |
|
58 LandPixelGet:= land_pixel_get(gameField, x, y) |
|
59 end; |
|
60 |
|
61 procedure LandPixelSet(y, x: LongInt; value: Longword); |
|
62 begin |
|
63 land_pixel_set(gameField, x, y, value) |
|
64 end; |
|
65 |
|
66 function LandPixelRow(row: LongInt): PLongwordArray; |
|
67 begin |
|
68 LandPixelRow:= land_pixel_row(gameField, row) |
38 end; |
69 end; |
39 |
70 |
40 procedure ResizeLand(width, height: LongWord); |
71 procedure ResizeLand(width, height: LongWord); |
41 var potW, potH: LongInt; |
72 var potW, potH: LongInt; |
42 begin |
73 begin |
47 LAND_WIDTH:= potW; |
78 LAND_WIDTH:= potW; |
48 LAND_HEIGHT:= potH; |
79 LAND_HEIGHT:= potH; |
49 LAND_WIDTH_MASK:= not(LAND_WIDTH-1); |
80 LAND_WIDTH_MASK:= not(LAND_WIDTH-1); |
50 LAND_HEIGHT_MASK:= not(LAND_HEIGHT-1); |
81 LAND_HEIGHT_MASK:= not(LAND_HEIGHT-1); |
51 cWaterLine:= LAND_HEIGHT; |
82 cWaterLine:= LAND_HEIGHT; |
52 if (cReducedQuality and rqBlurryLand) = 0 then |
|
53 SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH) |
|
54 else |
|
55 SetLength(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2); |
|
56 |
83 |
57 gameField:= create_game_field(LAND_WIDTH, LAND_HEIGHT); |
84 gameField:= create_game_field(LAND_WIDTH, LAND_HEIGHT); |
58 SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32)); |
85 SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32)); |
59 // 0.5 is already approaching on unplayable |
86 // 0.5 is already approaching on unplayable |
60 if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= cMaxZoomLevel/2; |
87 if (width div 4096 >= 2) or (height div 2048 >= 2) then cMaxZoomLevel:= cMaxZoomLevel/2; |