#include <Windows.h>
#include <iostream>
#include <easyx.h>
using namespace std;
typedef size_t iter_t;
typedef BYTE byte_t;
#define VK_ENTER VK_RETURN
#define VK_CTRL VK_CONTROL
#define H 512
#define W 724
size_t ch_bit[] = {
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b00000000000000000000000000000000,
0b01000100010000000100000000000000,
0b10101010000000000000000000000000,
0b10101110101011101010000000000000,
0b01001110100001000010111001000000,
0b10100010010010001010000000000000,
0b01001010010010100110000000000000,
0b01000100000000000000000000000000,
0b00100100010001000010000000000000,
0b01000010001000100100000000000000,
0b10100100101000000000000000000000,
0b00000100111001000000000000000000,
0b00000000000000000010010000000000,
0b00000000111000000000000000000000,
0b00000000000000000100000000000000,
0b00100010010010001000000000000000,
0b11101010101010101110000000000000,
0b01001100010001001110000000000000,
0b11100010111010001110000000000000,
0b11100010111000101110000000000000,
0b10101010111000100010000000000000,
0b11101000111000101110000000000000,
0b11101000111010101110000000000000,
0b11100010001000100010000000000000,
0b11101010111010101110000000000000,
0b11101010111000101110000000000000,
0b00000000010000000100000000000000,
0b00000000001000000010010000000000,
0b00100100100001000010000000000000,
0b00001110000011100000000000000000,
0b10000100001001001000000000000000,
0b11100010010000000100000000000000,
0b11100100101001101110000000000000,
0b01001010101011101010000000000000,
0b11101010110010101110000000000000,
0b11101000100010001110000000000000,
0b11001010101010101100000000000000,
0b11101000111010001110000000000000,
0b11101000111010001000000000000000,
0b11101000101010101110000000000000,
0b10101010111010101010000000000000,
0b11100100010001001110000000000000,
0b00100010001000101110000000000000,
0b10101010110010101010000000000000,
0b10001000100010001110000000000000,
0b10101110101010101010000000000000,
0b11101010101010101010000000000000,
0b11101010101011100000000000000000,
0b11101010111010001000000000000000,
0b11101010101010100100000000000000,
0b11101010110010101010000000000000,
0b11101000010000101110000000000000,
0b11100100010001000100000000000000,
0b10101010101010101110000000000000,
0b10101010101010100100000000000000,
0b10101010101011101010000000000000,
0b10101010010010101010000000000000,
0b10101010010001000100000000000000,
0b11100010010010001110000000000000,
0b01100100010001000110000000000000,
0b10001000010000100010000000000000,
0b01100010001000100110000000000000,
0b01001010000000000000000000000000,
0b00000000000000001111000000000000,
0b01000010000000000000000000000000,
0b00000000010010100110000000000000,
0b10001000111010101110000000000000,
0b00000000111010001110000000000000,
0b00100010111010101110000000000000,
0b00000000111010101100000000000000,
0b01100100111001000100000000000000,
0b00000000111010101110001011100000,
0b10001000111010101010000000000000,
0b01000000010001000100000000000000,
0b01000000010001000100110000000000,
0b10001000101011001010000000000000,
0b11000100010001001110000000000000,
0b00000000101011101110000000000000,
0b00000000111010101010000000000000,
0b00000000111010101110000000000000,
0b00000000111010101110100010000000,
0b00000000111010101110001000100000,
0b00000000111010001000000000000000,
0b00000000110010100110000000000000,
0b00000100111001000100000000000000,
0b00000000101010101110000000000000,
0b00000000101010100100000000000000,
0b00000000111011101010000000000000,
0b00000000101001001010000000000000,
0b00000000101010101110001011100000,
0b00000000011010101100000000000000,
0b01100100100001000110000000000000,
0b01000100010001000100000000000000,
0b11000100001001001100000000000000,
0b00001000111000100000000000000000,
0b00000000000000000000000000000000
};
struct color_t {
byte_t r;
byte_t g;
byte_t b;
}fc;
struct Image {
size_t h;
size_t w;
color_t** c;
}bg;
struct Position {
int x;
int y;
}pos;
struct logfont {
color_t fc;
color_t bc;
}lf;
bool KEYDOWN(int vk_code) {
return ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0);
}
bool KEYUP(int vk_code) {
return ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1);
}
HWND init(int h, int w) {
fc = { 255, 255, 255 };
lf.fc = { 255, 255, 255 };
lf.bc = { 0, 0, 0 };
pos = { 0, 0 };
bg.h = h;
bg.w = w;
bg.c = new color_t*[h];
for (iter_t it = 0; it < H; it++) {
bg.c[it] = new color_t[w];
}
return initgraph(w, h);
}
void close() {
closegraph();
return;
}
void bg_color(color_t c) {
for (iter_t ty = 0; ty < H; ty++) {
for (iter_t tx = 0; tx < W; tx++) {
bg.c[ty][tx].r = c.r;
bg.c[ty][tx].g = c.g;
bg.c[ty][tx].b = c.b;
}
}
}
void flush() {
for (iter_t ty = 0; ty < H; ty++) {
for (iter_t tx = 0; tx < W; tx++) {
putpixel(tx, ty, RGB(bg.c[ty][tx].r, bg.c[ty][tx].g, bg.c[ty][tx].b));
}
}
return;
}
void pixel(int x, int y) {
bg.c[y][x].r = fc.r;
bg.c[y][x].g = fc.g;
bg.c[y][x].b = fc.b;
return;
}
void putch(char ch) {
size_t bit = ch_bit[(int)ch];
int tx = 3;
int ty = 7;
for (iter_t it = 0; it < 32; it++) {
if (bit & 1) {
bg.c[ty + pos.y][tx + pos.x].r = lf.fc.r;
bg.c[ty + pos.y][tx + pos.x].g = lf.fc.g;
bg.c[ty + pos.y][tx + pos.x].b = lf.fc.b;
}
else {
bg.c[ty + pos.y][tx + pos.x].r = lf.bc.r;
bg.c[ty + pos.y][tx + pos.x].g = lf.bc.g;
bg.c[ty + pos.y][tx + pos.x].b = lf.bc.b;
}
bit >>= 1;
tx--;
if (tx == -1) {
tx = 3;
ty--;
}
}
pos.x += 4;
if (pos.x >= W) {
pos.x = 0;
pos.y += 8;
if (pos.y >= H)
pos.y = 0;
}
flush();
return;
}
void gets(char* str, size_t size) {
size_t len = 0;
while (KEYUP(VK_ENTER)) {
if (KEYDOWN(VK_BACK)) {
if (len > 0) {
len--;
pos.x -= 4;
putch((int)' ');
pos.x -= 4;
}
while (KEYDOWN(VK_BACK));
}
if (KEYDOWN(VK_SPACE)) {
str[len] = ' ';
putch(str[len]);
len++;
while (KEYDOWN(VK_SPACE));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
if (KEYDOWN(VK_OEM_3)) {
if (KEYUP(VK_SHIFT))
str[len] = '`';
else
str[len] = '~';
putch(str[len]);
len++;
while (KEYDOWN(VK_OEM_3));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
if (KEYDOWN(VK_OEM_MINUS)) {
if (KEYUP(VK_SHIFT))
str[len] = '-';
else
str[len] = '_';
putch(str[len]);
len++;
while (KEYDOWN(VK_OEM_MINUS));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
if (KEYDOWN(VK_OEM_PLUS)) {
if (KEYUP(VK_SHIFT))
str[len] = '=';
else
str[len] = '+';
putch(str[len]);
len++;
while (KEYDOWN(VK_OEM_PLUS));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
if (KEYDOWN(VK_OEM_4)) {
if (KEYUP(VK_SHIFT))
str[len] = '[';
else
str[len] = '{';
putch(str[len]);
len++;
while (KEYDOWN(VK_OEM_4));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
if (KEYDOWN(VK_OEM_6)) {
if (KEYUP(VK_SHIFT))
str[len] = ']';
else
str[len] = '}';
putch(str[len]);
len++;
while (KEYDOWN(VK_OEM_6));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
if (KEYDOWN(VK_OEM_5)) {
if (KEYUP(VK_SHIFT))
str[len] = '\\';
else
str[len] = '|';
putch(str[len]);
len++;
while (KEYDOWN(VK_OEM_5));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
if (KEYDOWN(VK_OEM_1)) {
if (KEYUP(VK_SHIFT))
str[len] = ';';
else
str[len] = ':';
putch(str[len]);
len++;
while (KEYDOWN(VK_OEM_1));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
if (KEYDOWN(VK_OEM_7)) {
if (KEYUP(VK_SHIFT))
str[len] = '\'';
else
str[len] = '\"';
putch(str[len]);
len++;
while (KEYDOWN(VK_OEM_7));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
if (KEYDOWN(VK_OEM_COMMA)) {
if (KEYUP(VK_SHIFT))
str[len] = ',';
else
str[len] = '<';
putch(str[len]);
len++;
while (KEYDOWN(VK_OEM_COMMA));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
if (KEYDOWN(VK_OEM_PERIOD)) {
if (KEYUP(VK_SHIFT))
str[len] = '.';
else
str[len] = '>';
putch(str[len]);
len++;
while (KEYDOWN(VK_OEM_PERIOD));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
if (KEYDOWN(VK_OEM_2)) {
if (KEYUP(VK_SHIFT))
str[len] = '/';
else
str[len] = '?';
putch(str[len]);
len++;
while (KEYDOWN(VK_OEM_2));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
for (iter_t it = 48; it < 58; it++) {
if (KEYDOWN(it)) {
if (KEYUP(VK_SHIFT)) {
str[len] = (char)it;
}
else {
switch (it) {
case 48: {
str[len] = ')';
break;
}
case 49: {
str[len] = '!';
break;
}
case 50: {
str[len] = '@';
break;
}
case 51: {
str[len] = '#';
break;
}
case 52: {
str[len] = '$';
break;
}
case 53: {
str[len] = '%';
break;
}
case 54: {
str[len] = '^';
break;
}
case 55: {
str[len] = '&';
break;
}
case 56: {
str[len] = '*';
break;
}
case 57: {
str[len] = '(';
break;
}
}
}
putch(str[len]);
len++;
while (KEYDOWN(it));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
}
for (iter_t it = 65; it < 91; it++) {
if (KEYDOWN(it)) {
if (KEYUP(VK_SHIFT)) {
str[len] = (char)(it + 32);
}
else {
str[len] = (char)it;
}
putch(str[len]);
len++;
while (KEYDOWN(it));
if (len == size - 1) {
while (KEYUP(VK_ENTER));
goto GETS_END;
}
}
}
}
GETS_END:
str[len] = '\0';
pos.y += 8;
if (pos.y >= H)
pos.y = 0;
pos.x = 0;
while (KEYDOWN(VK_ENTER));
return;
}
int main() {
init(H, W);
color_t c = { 0, 0, 0 };
bg_color(c);
char s[1024];
while (true)
gets(s, 1024);
close();
return 0;
}