Skip to content

Commit 65d9faa

Browse files
committed
version 1.5 release
search again with F3 until end of data animated welcome screen shader
1 parent c419f5c commit 65d9faa

File tree

6 files changed

+151
-21
lines changed

6 files changed

+151
-21
lines changed

Binmap/Content/Content.mgcb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@
3737
/processorParam:TextureFormat=Color
3838
/build:Logo.png
3939

40+
#begin Shaders/Intro.fx
41+
/importer:EffectImporter
42+
/processor:EffectProcessor
43+
/processorParam:DebugMode=Auto
44+
/build:Shaders/Intro.fx
45+

Binmap/Content/Shaders/Intro.fx

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#if OPENGL
2+
#define SV_POSITION POSITION
3+
#define VS_SHADERMODEL vs_3_0
4+
#define PS_SHADERMODEL ps_3_0
5+
#else
6+
#define VS_SHADERMODEL vs_4_0_level_9_3
7+
#define PS_SHADERMODEL ps_4_0_level_9_3
8+
#endif
9+
10+
float Time;
11+
float2 Size;
12+
Texture2D SpriteTexture;
13+
14+
sampler2D SpriteTextureSampler = sampler_state
15+
{
16+
Texture = <SpriteTexture>;
17+
};
18+
19+
struct VertexShaderOutput
20+
{
21+
float4 Position : SV_POSITION;
22+
float4 Color : COLOR0;
23+
float2 TextureCoordinates : TEXCOORD0;
24+
};
25+
26+
27+
float rand(float x) { return frac(sin(x) * 4358.5453123); }
28+
float rand(float2 co) { return frac(sin(dot(co.xy, float2(12.9898, 78.233))) * 43758.5357); }
29+
30+
float invader(float2 p, float n)
31+
{
32+
p.x = abs(p.x);
33+
p.y = floor(p.y - 5.0);
34+
return step(p.x, 2.0) * step(1.0, floor((n / (exp2(floor(p.x - 3.0*p.y))) % 2.0)));
35+
}
36+
37+
float ring(float2 uv, float rnd)
38+
{
39+
float t = 0.6*(Time + 0.2*rnd);
40+
float i = floor(t / 2.0);
41+
float2 pos = 2.0*float2(rand(i*0.123), rand(i*2.371)) - 1.0;
42+
return lerp(0.2, 0.0, abs(length(uv - pos) - (t % 2.0)));
43+
}
44+
45+
float3 color = float3(0.6, 0.1, 0.3); // red
46+
47+
48+
float4 MainPS(VertexShaderOutput input) : COLOR
49+
{
50+
//float4 col = 0.0 * tex2D(SpriteTextureSampler,input.TextureCoordinates) * input.Color;
51+
52+
float2 p = input.TextureCoordinates * Size;
53+
float2 uv = p / Size - 0.5;
54+
55+
p.y += 40.0*Time;
56+
57+
float r = rand(floor(p / 8.0));
58+
float2 ip = (p % 8.0) - 4.0;
59+
60+
float a = //lerp(0.1, 0.8, length(uv)) +
61+
invader(ip, 809999.0*r) * (0.06 + 0.3*ring(uv, r) + max(0.0, 0.2*sin(10.0*r*Time)));
62+
63+
return input.Color + 0.5*float4(a, a, a, 1.0);
64+
}
65+
66+
technique SpriteDrawing
67+
{
68+
pass P0
69+
{
70+
PixelShader = compile PS_SHADERMODEL MainPS();
71+
}
72+
};

Binmap/Controls/BinList.cs

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public Action<IInput> OnChangeCallback { set { } }
6262
private Action<BinListItem> itemSelectedCallback;
6363
private BinListItem overItem = null;
6464

65+
private float currentTime = 0;
66+
private bool f3KeyWasDown = false;
67+
private byte[] lastSearchQuery;
68+
private int lastSearchResult = 0;
69+
6570
public BinList(int x, int y, int w, int h, Action<BinListItem> itemSelectedCallback, Action<string, float> statusCallback) : base(x, y, w, h, Main.BorderColor)
6671
{
6772
this.statusCallback = statusCallback;
@@ -279,7 +284,20 @@ public bool ProcessKey(Keys key)
279284
public override void Update(float time, float dTime)
280285
{
281286
base.Update(time, dTime);
282-
287+
288+
currentTime = time;
289+
290+
// continue search (do this here so it does not require control focus)
291+
if (Main.KeyboardState.IsKeyDown(Keys.F3))
292+
{
293+
f3KeyWasDown = true;
294+
}
295+
else
296+
{
297+
if (f3KeyWasDown && lastSearchQuery != null) Search(lastSearchQuery, lastSearchResult + 1);
298+
f3KeyWasDown = false;
299+
}
300+
283301
// clear selection
284302
if (MouseIsOver && Main.MouseState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
285303
{
@@ -291,12 +309,30 @@ public override void Update(float time, float dTime)
291309
public override void CustomDraw(SpriteBatch spriteBatch)
292310
{
293311
Rectangle rect = WorldTransform;
312+
Rectangle innerRect = new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2);
294313

295-
// background
296-
spriteBatch.Draw(Main.WhiteTexture, new Rectangle(rect.X + 1, rect.Y + 1, rect.Width - 2, rect.Height - 2), Main.PanelColor);
314+
if (bins.Count > 0)
315+
{
316+
// background
317+
spriteBatch.Draw(Main.WhiteTexture, innerRect, Main.PanelColor);
297318

298-
// vertical separator line for comments column
299-
if (bins.Count > 0) spriteBatch.Draw(Main.WhiteTexture, new Rectangle(rect.X + rect.Width - commentColumnWidth, rect.Y + 2, 1, rect.Height - 4), Main.BorderColor);
319+
// vertical separator line for comments column
320+
spriteBatch.Draw(Main.WhiteTexture, new Rectangle(rect.X + rect.Width - commentColumnWidth, rect.Y + 2, 1, rect.Height - 4), Main.BorderColor);
321+
}
322+
else
323+
{
324+
// special shader for background when empty
325+
spriteBatch.End();
326+
327+
Main.IntroShader.Parameters["Size"].SetValue(new Vector2(innerRect.Width, innerRect.Height));
328+
Main.IntroShader.Parameters["Time"].SetValue(currentTime);
329+
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, Main.IntroShader);
330+
spriteBatch.Draw(Main.WhiteTexture, innerRect, Main.PanelColor);
331+
spriteBatch.End();
332+
333+
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp);
334+
return;
335+
}
300336
}
301337

302338
public override void Draw(SpriteBatch spriteBatch)
@@ -370,19 +406,31 @@ public void AddScrollbarMark(int pos, Color color)
370406

371407
public int Search(byte[] query, int offset = 0)
372408
{
409+
lastSearchQuery = query;
410+
373411
int end = bins.Count - query.Length;
374412
int num = 0;
413+
string text = "";
414+
foreach (byte b in query) text += b.ToString("X2") + " ";
375415

376416
for (int i = offset; i < end; i++)
377417
{
378418
if (bins[i].Value == query[num])
379419
{
380420
num++;
381-
if (num == query.Length) return i - query.Length + 1;
421+
if (num == query.Length)
422+
{
423+
lastSearchResult = i - query.Length + 1;
424+
ScrollTo(lastSearchResult);
425+
return lastSearchResult;
426+
}
382427
}
383428
else num = 0;
384429
}
385430

431+
if (offset > 0) statusCallback("Search reached the end.", 1);
432+
else statusCallback("No match found for query '" + text + "'.", 2);
433+
386434
return -1;
387435
}
388436

@@ -415,6 +463,8 @@ public void RemoveItem(Bin item) //NOTE: never used in this application
415463
public void Clear()
416464
{
417465
bins.Clear();
466+
lastSearchQuery = null;
467+
lastSearchResult = 0;
418468
dirty = true;
419469
deselectAll();
420470
scrollbar.ClearMarks();

Binmap/Main.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class Main : Game
2222
public static SpriteFont FontL;
2323

2424
public static Texture2D Logo;
25+
public static Effect IntroShader;
2526

2627
public static Color BackgroundColor = Color.FromNonPremultiplied(45, 45, 48, 255);
2728
public static Color PanelColor = Color.FromNonPremultiplied(30, 30, 30, 255);
@@ -45,7 +46,7 @@ public static void SetFocus(IInput control)
4546
if (focusedControl != null) focusedControl.Focused = true;
4647
}
4748

48-
public static string Version = "1.4";
49+
public static string Version = "1.5";
4950

5051
Keys[] prevPressed;
5152
GraphicsDeviceManager graphics;
@@ -88,7 +89,7 @@ protected override void LoadContent()
8889
{
8990
spriteBatch = new SpriteBatch(GraphicsDevice);
9091
WhiteTexture = new Texture2D(GraphicsDevice, 10, 10, false, SurfaceFormat.Color);
91-
92+
9293
FontS = Content.Load<SpriteFont>("Fonts/Font1");
9394
FontS.LineSpacing = 12;
9495

@@ -97,6 +98,8 @@ protected override void LoadContent()
9798

9899
Logo = Content.Load<Texture2D>("Logo");
99100

101+
IntroShader = Content.Load<Effect>("Shaders/Intro");
102+
100103
DefaultFont = FontL;
101104

102105
Color[] colorData = new Color[100];

Binmap/Screens/Layouter.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Layouter : Container
3737
private bool statusFadeOut = true;
3838
private float statusTime = 0;
3939

40-
private string usageText = "LMB: select/deselect, Shift+LMB: range selection, RMB: clear selection, ENTER: line break, BACKSPACE: remove line break";
40+
private string usageText = "LMB: select/deselect, SHIFT+LMB: range select, RMB: clear selection, ENTER/BKSPC: add/remove line break, F3: search again";
4141
private string startText = "DROP FILE TO START";
4242

4343
public string DataFilename { get; private set; } = string.Empty;
@@ -425,13 +425,13 @@ public override void Draw(SpriteBatch spriteBatch)
425425
{
426426
Point center = new Point(list.Transform.X + list.Transform.Width / 2, list.Transform.Y + list.Transform.Height / 2);
427427

428-
color = Color.FromNonPremultiplied(255, 255, 255, 40);
428+
color = Color.FromNonPremultiplied(255, 255, 255, 140);
429429
spriteBatch.Draw(Main.Logo, new Rectangle(center.X - Main.Logo.Width, center.Y - Main.Logo.Height * 2 + 50, Main.Logo.Width * 2, Main.Logo.Height * 2), color);
430430

431431
Vector2 size = Main.FontL.MeasureString(startText);
432432
spriteBatch.DrawString(Main.FontL, startText,
433433
new Vector2((float)Math.Floor(center.X - size.X / 2f), (float)Math.Floor(center.Y - size.Y / 2f) + 70),
434-
Main.BorderColor);
434+
Main.TrackColor);
435435
}
436436

437437
// write button position and visibility
@@ -558,12 +558,7 @@ private void searchChanged(IInput input)
558558
private void searchCommitted(IInput input)
559559
{
560560
byte[] query = getSearchQuery();
561-
if (query != null)
562-
{
563-
int i = list.Search(query);
564-
if (i >= 0) list.ScrollTo(i);
565-
else showStatus("No match found for query '" + searchInput.Text + "'.", 2);
566-
}
561+
if (query != null) list.Search(query);
567562
}
568563

569564
private void valueChanged(IInput input)

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# ![Binmap Logo](https://cloud.githubusercontent.com/assets/1974959/25785795/2718aaf2-3389-11e7-9078-fbf5b20801bf.png) Binmap
22

3-
A tool that helps to analyse and document binary data file formats. It also allows to edit values and write back changes.
3+
A tool that helps to analyse and document binary data files/formats. It can also be used to edit values and write back changes, just like a regular hex-editor but does not allow to insert or delete bytes.
4+
All UI controls of this application are custom-made for fast rendering and style.
45

56
## Screenshots
67

78
start screen:
89

9-
![Binmap start screen](https://cloud.githubusercontent.com/assets/1974959/25785729/f80b0ab2-3387-11e7-8a06-2a2b3fe750a1.png)
10+
![Binmap start screen](https://cloud.githubusercontent.com/assets/1974959/26288049/e2834f54-3e88-11e7-9d82-d5850e95cee0.png)
1011

11-
data loaded, unformatted:
12+
data loaded, unformatted; all bytes are formatted in hex by default:
1213

1314
![Binmap unformatted data](https://cloud.githubusercontent.com/assets/1974959/25785754/6fac491e-3388-11e7-9d53-cf7eb44e84da.png)
1415

@@ -35,12 +36,15 @@ The font in use is called [Pixel Operator](http://www.dafont.com/de/pixel-operat
3536
If you are interested in a release download, here is the latest public release (might be some subversions behind): [Binmap Release](https://github.com/movAX13h/Binmap/releases/latest)
3637

3738
### Todo
38-
- continue search with F3
3939
- TextInput text range selection (mouse and keyboard), handle longer texts
4040
- Scrollbar track click
4141
- view for multiple bytes combined as int, float, double, ...
4242

4343
### Changelog
44+
- v1.5 - 2017-05-22
45+
- F3 to repeat search (scrolls to next result till end of file is reached)
46+
- welcome screen shader
47+
4448
- v1.4 - 2017-05-16
4549
- added goto address panel (scrolls list to address) with format switch (hex/dec)
4650
- added search panel with format switch (hex/dec)

0 commit comments

Comments
 (0)