This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
85 lines (73 loc) · 2.52 KB
/
main.cpp
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
#include <Windows.h>
#include <tchar.h>
#include "ILBM.h"
#include <stdio.h>
#include "czGraphics.h"
void _tmain(int argc, _TCHAR* argv[])
{
printf("ILBMViewer by Gargaj / Conspiracy\n");
printf("\n");
printf("Based on the documentation of Jerry Morrison (Electronic Arts)\n");
printf(" http://home.comcast.net/~erniew/lwsdk/docs/filefmts/ilbm.html\n");
printf("\"Blend-shift\" algorithm originally devised by Joseph Huckaby\n");
printf(" http://www.effectgames.com/demos/canvascycle/\n");
printf("\n");
printf("Keys:\n");
printf(" 1-5: Cycling speed (25%%, 50%%, 100%%, 150%%, 200%% respectively)\n");
printf(" F/D: Zoom on/off (keeps aspect ratio, only uses integer multiples)\n");
printf(" R/E: Blend-shift on/off\n");
printf(" Alt-Enter: Switch to/from fullscreen\n");
if (argc < 2)
{
printf("\n");
printf("Usage: ILBMViewer.exe <filename>\n");
printf("\n");
return;
}
CILBMViewer ilbm;
if (!ilbm.Load( argv[1] ))
return;
// int w = ilbm.GetWidth();
// int h = ilbm.GetHeight();
int w = 1280;
int h = 720;
czGraphics graph( w, h, false );
graph.Init( GetModuleHandle(NULL) );
unsigned int * vscr = new unsigned int[ w * h ];
unsigned int * pic = new unsigned int[ ilbm.GetWidth() * ilbm.GetHeight() ];
bool bZoom = true;
while (!graph.quit)
{
ZeroMemory(vscr,w * h * sizeof(unsigned int));
graph.Messages();
if (graph.active)
{
if (GetAsyncKeyState('F') & 0x8000) bZoom = true;
if (GetAsyncKeyState('D') & 0x8000) bZoom = false;
if (GetAsyncKeyState('R') & 0x8000) ilbm.bBlendShift = true;
if (GetAsyncKeyState('E') & 0x8000) ilbm.bBlendShift = false;
if (GetAsyncKeyState('1') & 0x8000) ilbm.nFPS = 15;
if (GetAsyncKeyState('2') & 0x8000) ilbm.nFPS = 30;
if (GetAsyncKeyState('3') & 0x8000) ilbm.nFPS = 60;
if (GetAsyncKeyState('4') & 0x8000) ilbm.nFPS = 90;
if (GetAsyncKeyState('5') & 0x8000) ilbm.nFPS = 120;
}
ilbm.UpdatePalette( GetTickCount() );
ilbm.RenderTo32bit( pic );
int zoomX = w / ilbm.GetWidth();
int zoomY = h / ilbm.GetHeight();
int ratio = bZoom ? min(zoomX,zoomY) : 1;
int cx = (w - (ilbm.GetWidth() * ratio)) / 2;
int cy = (h - (ilbm.GetHeight() * ratio)) / 2;
for (int y = 0; y < ilbm.GetHeight() * ratio; y++)
{
for (int x = 0; x < ilbm.GetWidth() * ratio; x++)
{
vscr[ cx + x + (cy + y) * w ] = pic[ (x / ratio) + (y / ratio) * ilbm.GetWidth() ];
}
}
graph.Update( vscr );
}
delete[] pic;
delete[] vscr;
}