[NOTEVIL]

- Convert our goode olde ReactOS Easter Egg "notevil" app to unicode.
- Remove .rbuild file.
- Code formatting.

svn path=/trunk/; revision=62550
This commit is contained in:
Hermès Bélusca-Maïto 2014-03-23 02:24:33 +00:00
parent eab1b449bb
commit b67dc560e6
4 changed files with 209 additions and 250 deletions

View file

@ -1,5 +1,5 @@
add_executable(notevil notevil.c notevil.rc)
set_module_type(notevil win32cui)
set_module_type(notevil win32cui UNICODE)
add_importlibs(notevil user32 msvcrt kernel32)
add_cd_file(TARGET notevil DESTINATION reactos/system32 FOR all)

View file

@ -24,243 +24,207 @@
* 19990411 EA
* 19990515 EA
*/
//#define UNICODE
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <tchar.h>
#include "resource.h"
LPCTSTR app_name = _TEXT("notevil");
// #define DISPLAY_COORD
HANDLE myself;
HANDLE ScreenBuffer;
LPCWSTR app_name = L"notevil";
HANDLE myself;
HANDLE ScreenBuffer;
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo;
HANDLE WaitableTimer;
HANDLE WaitableTimer;
void
WriteStringAt(
LPTSTR lpString,
COORD xy,
WORD wColor
)
VOID
WriteStringAt(LPWSTR lpString,
COORD xy,
WORD wColor)
{
DWORD cWritten = 0;
WORD wLen = lstrlen(lpString);
DWORD cWritten = 0;
WORD wLen;
if (0 == wLen)
return;
// don't bother writing text when erasing
if( wColor )
WriteConsoleOutputCharacter( ScreenBuffer,
lpString,
wLen,
xy,
& cWritten
);
FillConsoleOutputAttribute(
ScreenBuffer,
wColor,
wLen,
xy,
& cWritten
);
if (!lpString || *lpString == 0) return;
wLen = wcslen(lpString);
/* Don't bother writing text when erasing */
if (wColor)
{
WriteConsoleOutputCharacterW(ScreenBuffer,
lpString,
wLen,
xy,
&cWritten);
}
FillConsoleOutputAttribute(ScreenBuffer,
wColor,
wLen,
xy,
&cWritten);
}
#ifdef DISPLAY_COORD
void
VOID
WriteCoord(COORD c)
{
COORD xy = {0,0};
TCHAR buf [40];
COORD xy = {0,0};
WCHAR buf[40];
wsprintf(
buf,
_TEXT("x=%02d y=%02d"),
c.X,
c.Y
);
WriteStringAt(
buf,
xy,
(BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE)
);
wsprintf(buf, L"x=%02d y=%02d", c.X, c.Y);
WriteStringAt(buf, xy,
BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE);
}
#endif /* def DISPLAY_COORD */
INT
GetNextString(
LPTSTR Buffer,
INT BufferSize,
DWORD *Index
)
VOID
GetNextString(LPWSTR Buffer,
INT BufferSize,
PDWORD Index)
{
if (RES_LAST_INDEX == *Index)
{
*Index = RES_FIRST_INDEX;
}
else
{
++*Index;
}
LoadString(
myself,
*Index,
Buffer,
BufferSize
);
return 0;
if (RES_LAST_INDEX == *Index)
*Index = RES_FIRST_INDEX;
else
++*Index;
LoadStringW(myself, *Index, Buffer, BufferSize);
}
VOID
DisplayTitle(VOID)
{
LPTSTR szTitle = _TEXT("ReactOS Coders Console Parade");
COORD xy;
LPWSTR szTitle = L"ReactOS Coders Console Parade";
COORD xy;
xy.X = (ScreenBufferInfo.dwSize.X - lstrlen(szTitle)) / 2;
xy.Y = ScreenBufferInfo.dwSize.Y / 2;
xy.X = (ScreenBufferInfo.dwSize.X - wcslen(szTitle)) / 2;
xy.Y = ScreenBufferInfo.dwSize.Y / 2;
WriteStringAt(
szTitle,
xy,
(FOREGROUND_GREEN | FOREGROUND_INTENSITY)
);
WriteStringAt(szTitle, xy,
FOREGROUND_GREEN | FOREGROUND_INTENSITY);
}
#define RES_DELAY_CHANGE 12
#define RES_BUFFER_SIZE 1024
void
MainLoop(void)
VOID
MainLoop(VOID)
{
TCHAR NameString [RES_BUFFER_SIZE];
DWORD NameIndex = 1;
INT NameLength = 0;
COORD xy;
INT n = RES_DELAY_CHANGE;
INT dir_y = 1;
INT dir_x = 1;
WORD wColor = 1;
WCHAR NameString[RES_BUFFER_SIZE];
DWORD NameIndex = 0;
INT NameLength = 0;
COORD xy;
INT n = RES_DELAY_CHANGE;
INT dir_y = 1;
INT dir_x = 1;
WORD wColor = 1;
xy.X = ScreenBufferInfo.dwSize.X / 2;
xy.Y = ScreenBufferInfo.dwSize.Y / 2;
xy.X = ScreenBufferInfo.dwSize.X / 2;
xy.Y = ScreenBufferInfo.dwSize.Y / 2;
for ( ; 1; ++n )
{
if (n == RES_DELAY_CHANGE)
{
n = GetNextString(
NameString,
RES_BUFFER_SIZE,
& NameIndex
);
NameLength = lstrlen(NameString);
wColor++;
if ((wColor & 0x000F) == 0)
wColor = 1;
}
if (xy.X == 0)
{
if (dir_x == -1)
dir_x = 1;
}
else if (xy.X >= ScreenBufferInfo.dwSize.X - NameLength - 1)
{
if (dir_x == 1)
dir_x = -1;
}
xy.X += dir_x;
for ( ; 1; ++n )
{
if (n == RES_DELAY_CHANGE)
{
n = 0;
GetNextString(NameString,
RES_BUFFER_SIZE,
&NameIndex);
NameLength = wcslen(NameString);
wColor++;
if ((wColor & 0x000F) == 0)
wColor = 1;
}
if (xy.X == 0)
{
if (dir_x == -1)
dir_x = 1;
}
else if (xy.X >= ScreenBufferInfo.dwSize.X - NameLength - 1)
{
if (dir_x == 1)
dir_x = -1;
}
xy.X += dir_x;
if (xy.Y == 0)
{
if (dir_y == -1)
dir_y = 1;
}
else if (xy.Y >= ScreenBufferInfo.dwSize.Y - 1)
{
if (dir_y == 1)
dir_y = -1;
}
xy.Y += dir_y;
if (xy.Y == 0)
{
if (dir_y == -1)
dir_y = 1;
}
else if (xy.Y >= ScreenBufferInfo.dwSize.Y - 1)
{
if (dir_y == 1)
dir_y = -1;
}
xy.Y += dir_y;
#ifdef DISPLAY_COORD
WriteCoord(xy);
WriteCoord(xy);
#endif /* def DISPLAY_COORD */
DisplayTitle();
WriteStringAt(
NameString,
xy,
wColor
);
WaitForSingleObject( WaitableTimer, INFINITE );
WriteStringAt(
NameString,
xy,
0
);
}
DisplayTitle();
WriteStringAt(NameString, xy, wColor);
WaitForSingleObject(WaitableTimer, INFINITE);
WriteStringAt(NameString, xy, 0);
}
}
int
main(
int argc,
char *argv []
)
int wmain(int argc, WCHAR* argv[])
{
LARGE_INTEGER lint;
DWORD Written;
COORD Coord = { 0, 0 };
LARGE_INTEGER lint;
DWORD Written;
COORD Coord = { 0, 0 };
myself = GetModuleHandle(NULL);
myself = GetModuleHandle(NULL);
GetConsoleScreenBufferInfo (GetStdHandle(STD_OUTPUT_HANDLE),
&ScreenBufferInfo);
ScreenBufferInfo.dwSize.X = ScreenBufferInfo.srWindow.Right - ScreenBufferInfo.srWindow.Left + 1;
ScreenBufferInfo.dwSize.Y = ScreenBufferInfo.srWindow.Bottom - ScreenBufferInfo.srWindow.Top + 1;
ScreenBuffer = CreateConsoleScreenBuffer(
GENERIC_WRITE,
0,
NULL,
CONSOLE_TEXTMODE_BUFFER,
NULL
);
if (INVALID_HANDLE_VALUE == ScreenBuffer)
{
_ftprintf(
stderr,
_TEXT("%s: could not create a new screen buffer\n"),
app_name
);
return EXIT_FAILURE;
}
// Fill buffer with black background
FillConsoleOutputAttribute( ScreenBuffer,
0,
ScreenBufferInfo.dwSize.X * ScreenBufferInfo.dwSize.Y,
Coord,
&Written );
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),
&ScreenBufferInfo);
ScreenBufferInfo.dwSize.X = ScreenBufferInfo.srWindow.Right - ScreenBufferInfo.srWindow.Left + 1;
ScreenBufferInfo.dwSize.Y = ScreenBufferInfo.srWindow.Bottom - ScreenBufferInfo.srWindow.Top + 1;
ScreenBuffer = CreateConsoleScreenBuffer(GENERIC_WRITE,
0,
NULL,
CONSOLE_TEXTMODE_BUFFER,
NULL);
if (ScreenBuffer == INVALID_HANDLE_VALUE)
{
wprintf(L"%s: could not create a new screen buffer\n", app_name);
return EXIT_FAILURE;
}
WaitableTimer = CreateWaitableTimer( NULL, FALSE, NULL );
if( WaitableTimer == INVALID_HANDLE_VALUE )
{
printf( "CreateWaitabletimer() failed\n" );
return 1;
}
lint.QuadPart = -2000000;
if( SetWaitableTimer( WaitableTimer, &lint, 200, NULL, NULL, FALSE ) == FALSE )
{
printf( "SetWaitableTimer() failed: 0x%lx\n", GetLastError() );
return 2;
}
SetConsoleActiveScreenBuffer(ScreenBuffer);
MainLoop();
CloseHandle(ScreenBuffer);
return EXIT_SUCCESS;
/* Fill buffer with black background */
FillConsoleOutputAttribute(ScreenBuffer,
0,
ScreenBufferInfo.dwSize.X * ScreenBufferInfo.dwSize.Y,
Coord,
&Written);
WaitableTimer = CreateWaitableTimer(NULL, FALSE, NULL);
if (WaitableTimer == INVALID_HANDLE_VALUE)
{
wprintf(L"CreateWaitabletimer() failed\n");
return 1;
}
lint.QuadPart = -2000000;
if (!SetWaitableTimer(WaitableTimer, &lint, 200, NULL, NULL, FALSE))
{
wprintf(L"SetWaitableTimer() failed: 0x%lx\n", GetLastError());
return 2;
}
SetConsoleActiveScreenBuffer(ScreenBuffer);
MainLoop();
CloseHandle(ScreenBuffer);
return EXIT_SUCCESS;
}
/* EOF */

View file

@ -1,5 +0,0 @@
<module name="notevil" type="win32cui" installbase="system32" installname="notevil.exe">
<include base="notevil">.</include>
<library>user32</library>
<file>notevil.c</file>
<file>notevil.rc</file>

View file

@ -1,7 +1,7 @@
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Coders Console Parade\0"
#define REACTOS_STR_INTERNAL_NAME "notevil\0"
#define REACTOS_STR_ORIGINAL_FILENAME "notevil.exe\0"
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Coders Console Parade"
#define REACTOS_STR_INTERNAL_NAME "notevil"
#define REACTOS_STR_ORIGINAL_FILENAME "notevil.exe"
#include <reactos/version.rc>
/*
@ -20,69 +20,69 @@
STRINGTABLE MOVEABLE
BEGIN
1, "Boudewijn Dekker (Ariadne)"
2, "Robert Bergkvist (FragDance Galore)"
3, "Arindam Das"
4, "Boudewijn Dekker"
5, "Jason Eager"
6, "Jason Filby"
7, "Rex Jolliff"
8, "Eric Kohl"
9, "Hans Kremer"
10, "Frederik Leemans"
11, "Jean Michault"
12, "Jim Noeth"
13, "Brian Palmer"
14, "Matt Pyne"
15, "Jason Weiler"
1, "Boudewijn Dekker (Ariadne)"
2, "Robert Bergkvist (FragDance Galore)"
3, "Arindam Das"
4, "Boudewijn Dekker"
5, "Jason Eager"
6, "Jason Filby"
7, "Rex Jolliff"
8, "Eric Kohl"
9, "Hans Kremer"
10, "Frederik Leemans"
11, "Jean Michault"
12, "Jim Noeth"
13, "Brian Palmer"
14, "Matt Pyne"
15, "Jason Weiler"
END
STRINGTABLE MOVEABLE
BEGIN
16, "David Welch"
17, "Emanuele Aliberti"
18, "Phillip Susi"
19, "Paolo Pantaleo"
20, "Hernan Ochoa"
21, "Casper Hornstrup"
22, "Steven Edwards"
23, "KJK::Hyperion"
24, "Robert Dickenson"
25, "Eugene Ingerman"
26, "Guido de Jong"
27, "Jurgen van Gael"
28, "Marty Dill"
29, "Ge van Geldorp"
30, "Richard Campbell"
16, "David Welch"
17, "Emanuele Aliberti"
18, "Phillip Susi"
19, "Paolo Pantaleo"
20, "Hernan Ochoa"
21, "Casper Hornstrup"
22, "Steven Edwards"
23, "KJK::Hyperion"
24, "Robert Dickenson"
25, "Eugene Ingerman"
26, "Guido de Jong"
27, "Jurgen van Gael"
28, "Marty Dill"
29, "Ge van Geldorp"
30, "Richard Campbell"
END
STRINGTABLE MOVEABLE
BEGIN
31, "Gunnar Andre' Dalsnes"
32, "Aleksey Bragin"
33, "Royce Mitchell III"
34, "Mark Tempel"
35, "Art Yerkes"
36, "Martin Fuchs"
37, "Vizzini"
38, "Filip Navara"
39, "Andrew Greenwood"
40, "Thomas Weidenmueller"
41, "Jonathan Wilson"
42, "Alex Ionescu"
43, "Jim Tabor"
44, "Magnus Olsen"
45, "Herve Poussineau"
31, "Gunnar Andre' Dalsnes"
32, "Aleksey Bragin"
33, "Royce Mitchell III"
34, "Mark Tempel"
35, "Art Yerkes"
36, "Martin Fuchs"
37, "Vizzini"
38, "Filip Navara"
39, "Andrew Greenwood"
40, "Thomas Weidenmueller"
41, "Jonathan Wilson"
42, "Alex Ionescu"
43, "Jim Tabor"
44, "Magnus Olsen"
45, "Herve Poussineau"
END
STRINGTABLE MOVEABLE
BEGIN
46, "Christoph von Wittich"
47, "Brandon Turner"
48, "Ged Murphy"
49, "Klemens R. Friedl"
50, "Maarten Bosma"
51, "Saveliy Tretiakov"
46, "Christoph von Wittich"
47, "Brandon Turner"
48, "Ged Murphy"
49, "Klemens R. Friedl"
50, "Maarten Bosma"
51, "Saveliy Tretiakov"
END
/* EOF */