This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathL2WorldMapBigBlock.cs
118 lines (101 loc) · 3.08 KB
/
L2WorldMapBigBlock.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Text;
namespace LEdit
{
//This is both idiotic and pathetic...
public class L2WorldMapBigBlock
{
#region STATIC
public const long Offset = 0xD0000;
public const int Count = 0xF2E;
static L2WorldMapBigBlock[] WMBB = new L2WorldMapBigBlock[Count];
public static L2WorldMapBigBlock Get(int n)
{
if (n >= 0 && n < Count)
return WMBB[n];
else
return null;
}
public static void InitROM(BinaryReader br)
{
br.BaseStream.Seek(Offset, SeekOrigin.Begin);
for (int i = 0; i < Count; i++)
WMBB[i] = new L2WorldMapBigBlock(br);
}
#endregion
Bitmap bmp;
bool drawn;
ushort[,] blocks = new ushort[2, 2];
public L2WorldMapBigBlock(BinaryReader br)
{
drawn = false;
FromStream(br);
}
~L2WorldMapBigBlock()
{
if (bmp != null) bmp.Dispose();
}
public void FromStream(BinaryReader br)
{
if (br != null)
{
for (int y = 0; y < 2; y++)
{
for (int x = 0; x < 2; x++)
blocks[x, y] = br.ReadUInt16();
}
}
}
public void PreDraw(SNESTileset8 set, SNESPalette[] pals)
{
if (!drawn)
{
bmp = new Bitmap(32, 32, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(bmp);
for (int y = 0; y < 2; y++)
{
for (int x = 0; x < 2; x++)
{
L2WorldMapBlock.Get(blocks[x, y]).Draw(
g,
set,
pals,
x << 4,
y << 4,
1);
}
drawn = true;
}
}
}
public void Draw(Graphics dst, SNESTileset8 set, SNESPalette[] pals, int dx, int dy)
{ Draw(dst, set, pals, dx, dy, 1); }
public void Draw(Graphics dst, SNESTileset8 set, SNESPalette[] pals, int dx, int dy, int zoom)
{
if (zoom < 1) zoom = 1;
PreDraw(set, pals);
if (zoom == 1 && drawn)
dst.DrawImage(bmp, dx, dy);
else
{
for (int y = 0; y < 2; y++)
{
for (int x = 0; x < 2; x++)
{
L2WorldMapBlock.Get(blocks[x, y]).Draw(
dst,
set,
pals,
dx + x * (zoom << 4),
dy + y * (zoom << 4),
zoom);
}
}
}
}
}
}