Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdint.h>
- const uint16_t width = 80;
- const uint16_t height = 30;
- SMALL_RECT testscreenrect={0, 0, width-1, height-1};
- HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- CHAR_INFO screen[width*height];
- typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX {
- ULONG cbSize;
- COORD dwSize;
- COORD dwCursorPosition;
- WORD wAttributes;
- SMALL_RECT srWindow;
- COORD dwMaximumWindowSize;
- WORD wPopupAttributes;
- BOOL bFullscreenSupported;
- COLORREF ColorTable[16];
- } CONSOLE_SCREEN_BUFFER_INFOEX, *PCONSOLE_SCREEN_BUFFER_INFOEX;
- extern "C" BOOL WINAPI GetConsoleScreenBufferInfoEx(
- HANDLE hConsoleOutput,
- PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx
- );
- extern "C" BOOL WINAPI SetConsoleScreenBufferInfoEx(
- HANDLE hConsoleOutput,
- PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx
- );
- void initscreen(){
- SetConsoleOutputCP(437);
- CONSOLE_CURSOR_INFO temp2={100, 0};
- SetConsoleCursorInfo(hConsole, &temp2);
- CONSOLE_SCREEN_BUFFER_INFO temp;
- GetConsoleScreenBufferInfo(hConsole, &temp);
- SetConsoleScreenBufferSize(hConsole, {width, temp.dwSize.Y});
- SetConsoleScreenBufferSize(hConsole, {temp.dwSize.X, height});
- SetConsoleScreenBufferSize(hConsole, {width, height});
- SetConsoleWindowInfo(hConsole, 1, &testscreenrect);
- SetConsoleScreenBufferSize(hConsole, {width, height});
- CONSOLE_SCREEN_BUFFER_INFOEX colorinfo;
- colorinfo.cbSize = sizeof(CONSOLE_SCREEN_BUFFER_INFOEX);
- HMODULE KERNEL32 = LoadLibrary("KERNEL32.dll");
- if (KERNEL32 != NULL){
- auto GetConsoleScreenBufferInfoExfunction = reinterpret_cast<decltype(GetConsoleScreenBufferInfoEx)*>(GetProcAddress(KERNEL32, "GetConsoleScreenBufferInfoEx"));
- if (GetConsoleScreenBufferInfoExfunction != NULL){
- GetConsoleScreenBufferInfoExfunction(hConsole, &colorinfo);
- }
- }
- colorinfo.dwSize = {width, height};
- colorinfo.srWindow.Left = 0;
- colorinfo.srWindow.Top = 0;
- colorinfo.srWindow.Right = width;
- colorinfo.srWindow.Bottom = height;
- for(int i=0; i<16; i++){
- colorinfo.ColorTable[i] = (i&1)*0xAA0000+(i&2)/2*0x00AA00+(i&4)/4*0x0000AA+(i&8)/8*0x555555;
- }
- if (KERNEL32 != NULL){
- auto SetConsoleScreenBufferInfoExfunction = reinterpret_cast<decltype(SetConsoleScreenBufferInfoEx)*>(GetProcAddress(KERNEL32, "SetConsoleScreenBufferInfoEx"));
- if (SetConsoleScreenBufferInfoExfunction != NULL){
- SetConsoleScreenBufferInfoExfunction(hConsole, &colorinfo);
- }
- }
- }
- int main(){
- initscreen();
- const char* colortable = "\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- \x00\x00\x00\x00\x10\x10\x10\x10\x20\x20\x20\x20\x30\x30\x30\x30\x40\x40\x40\x40\x50\x50\x50\x50\x60\x60\x60\x60\x70\x70\x70\x70\x80\x80\x80\x80\x90\x90\x90\x90\xa0\xa0\xa0\xa0\xb0\xb0\xb0\xb0\xc0\xc0\xc0\xc0\xd0\xd0\xd0\xd0\xe0\xe0\xe0\xe0\xf0\xf0\xf0\xf0pppppppppppppppp\
- \x00\x00\x00\x00\x01\x01\x01\x01\x02\x02\x02\x02\x03\x03\x03\x03\x04\x04\x04\x04\x05\x05\x05\x05\x06\x06\x06\x06\x07\x07\x07\x07\x08\x08\x08\x08\x09\x09\x09\x09\x0a\x0a\x0a\x0a\x0b\x0b\x0b\x0b\x0c\x0c\x0c\x0c\x0d\x0d\x0d\x0d\x0e\x0e\x0e\x0e\x0f\x0f\x0f\x0fpppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- \x00\x00\x01\x01\x02\x02\x03\x03\x04\x04\x05\x05\x06\x06\x07\x07\x08\x08\x09\x09\x0a\x0a\x0b\x0b\x0c\x0c\x0d\x0d\x0e\x0e\x0f\x0f\x10\x10\x11\x11\x12\x12\x13\x13\x14\x14\x15\x15\x16\x16\x17\x17\x18\x18\x19\x19\x1a\x1a\x1b\x1b\x1c\x1c\x1d\x1d\x1e\x1e\x1f\x1fpppppppppppppppp\
- !!\"\"##$$%%&&''(())**++,,--..//00112233445566778899::;;<<==>>??pppppppppppppppp\
- @@AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZ[[\\\\]]^^__pppppppppppppppp\
- ``aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~\x7f\x7fpppppppppppppppp\
- ÇÇüüééââääààååççêêëëèèïïîîììÄÄÅÅÉÉææÆÆôôööòòûûùùÿÿÖÖÜÜ¢¢££¥¥₧₧ƒƒpppppppppppppppp\
- ááííóóúúññÑѪªºº¿¿⌐⌐¬¬½½¼¼¡¡««»»░░▒▒▓▓││┤┤╡╡╢╢╖╖╕╕╣╣║║╗╗╝╝╜╜╛╛┐┐pppppppppppppppp\
- └└┴┴┬┬├├──┼┼╞╞╟╟╚╚╔╔╩╩╦╦╠╠══╬╬╧╧╨╨╤╤╥╥╙╙╘╘╒╒╓╓╫╫╪╪┘┘┌┌██▄▄▌▌▐▐▀▀pppppppppppppppp\
- ααßßΓΓππΣΣσσµµττΦΦΘΘΩΩδδ∞∞φφεε∩∩≡≡±±≥≥≤≤⌠⌠⌡⌡÷÷≈≈°°∙∙··√√ⁿⁿ²²■■ pppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\
- pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp";
- const char* texttable = "\
- The quick brown fox jumps over the lazy dog. \
- \
- All CP437 characters: \
- \x0\x1\x2\x3\x4\x5\x6\x7\x8\x9\xa\xb\xc\xd\xe\xf\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>? \
- @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f \
- ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐ \
- └┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ \
- \
- ┌────────────┬─┐ ╓────────────╥─╖ ╒════════════╤═╕ ╔════════════╦═╗ \
- │Single table│ │ ║Mixed1 table║ ║ │Mixed2 table│ │ ║Double table║ ║ ⌠ \
- ├────────────┼─┤ ╟────────────╫─╢ ╞════════════╪═╡ ╠════════════╬═╣ │ \
- └────────────┴─┘ ╙────────────╨─╜ ╘════════════╧═╛ ╚════════════╩═╝ ⌡ \
- \
- 16 colors: \
- \
- ████████████████████████████████████████████████████████████████ \
- \
- xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy \
- xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy \
- xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy \
- xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy \
- xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy \
- xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy \
- xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy \
- xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy \
- \
- \
- \
- \
- \
- ";
- for(int i=0; i<width*height; i++){
- screen[i].Attributes = (uint8_t)colortable[i];
- screen[i].Char.AsciiChar = (uint8_t)texttable[i];
- }
- WriteConsoleOutput(hConsole, screen, {width, height}, {0, 0}, &testscreenrect);
- while(true);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement