{"action":"created","issue":{"url":"https://api.github.com/repos/HaxeFoundation/code-cookbook/issues/55","repository_url":"https://api.github.com/repos/HaxeFoundation/code-cookbook","labels_url":"https://api.github.com/repos/HaxeFoundation/code-cookbook/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/HaxeFoundation/code-cookbook/issues/55/comments","events_url":"https://api.github.com/repos/HaxeFoundation/code-cookbook/issues/55/events","html_url":"https://github.com/HaxeFoundation/code-cookbook/issues/55","id":178712372,"number":55,"title":"VGA text renderer","user":{"login":"Simn","id":634365,"avatar_url":"https://avatars.githubusercontent.com/u/634365?v=3","gravatar_id":"","url":"https://api.github.com/users/Simn","html_url":"https://github.com/Simn","followers_url":"https://api.github.com/users/Simn/followers","following_url":"https://api.github.com/users/Simn/following{/other_user}","gists_url":"https://api.github.com/users/Simn/gists{/gist_id}","starred_url":"https://api.github.com/users/Simn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Simn/subscriptions","organizations_url":"https://api.github.com/users/Simn/orgs","repos_url":"https://api.github.com/users/Simn/repos","events_url":"https://api.github.com/users/Simn/events{/privacy}","received_events_url":"https://api.github.com/users/Simn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-09-22T20:28:54Z","updated_at":"2016-10-11T15:11:05Z","closed_at":null,"body":"anniz on #haxe posted a fun little example of a vga text renderer:\r\n\r\n```haxe\r\nclass Main {\r\n\tstatic var Font = [\r\n\t\t0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\r\n\t\t0x7E,0x81,0xA5,0x81,0xBD,0x99,0x81,0x7E,\r\n\t\t0x7E,0xFF,0x00,0xFF,0xC3,0xE7,0xFF,0x7E,\r\n\t\t0x6C,0xFE,0xFE,0xFE,0x7C,0x38,0x10,0x00,\r\n\t\t0x10,0x38,0x7C,0xFE,0x7C,0x38,0x10,0x00,\r\n\t\t0x38,0x7C,0x38,0xFE,0xFE,0x92,0x10,0x7C,\r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66,0xFF,0x66,0x24,0x00,0x00,\r\n\t\t0x00,0x18,0x3C,0x7E,0xFF,0xFF,0x00,0x00,\r\n\t\t0x00,0xFF,0xFF,0x7E,0x3C,0x18,0x00,0x00,\r\n\t\t0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\r\n\t\t0x18,0x3C,0x3C,0x18,0x18,0x00,0x18,0x00,\r\n\t\t0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00,\r\n\t\t0x6C,0x6C,0xFE,0x6C,0xFE,0x6C,0x6C,0x00,\r\n\t\t0x18,0x7E,0xC0,0x7C,0x06,0xFC,0x18,0x00,\r\n\t\t0x00,0xC6,0xCC,0x18,0x30,0x66,0xC6,0x00,\r\n\t\t0x38,0x6C,0x38,0x76,0xDC,0xCC,0x76,0x00,\r\n\t\t0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00,\r\n\t\t0x18,0x30,0x60,0x60,0x60,0x30,0x18,0x00,\r\n\t\t0x60,0x30,0x18,0x18,0x18,0x30,0x60,0x00,\r\n\t\t0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00,\r\n\t\t0x00,0x18,0x18,0x7E,0x18,0x18,0x00,0x00,\r\n\t\t0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30,\r\n\t\t0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00,\r\n\t\t0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,\r\n\t\t0x06,0x0C,0x18,0x30,0x60,0xC0,0x80,0x00,\r\n\t\t0x7C,0xCE,0xDE,0xF6,0xE6,0xC6,0x7C,0x00,\r\n\t\t0x30,0x70,0x30,0x30,0x30,0x30,0xFC,0x00,\r\n\t\t0x78,0xCC,0x0C,0x38,0x60,0xCC,0xFC,0x00,\r\n\t\t0x78,0xCC,0x0C,0x38,0x0C,0xCC,0x78,0x00,\r\n\t\t0x1C,0x3C,0x6C,0xCC,0xFE,0x0C,0x1E,0x00,\r\n\t\t0xFC,0xC0,0xF8,0x0C,0x0C,0xCC,0x78,0x00,\r\n\t\t0x38,0x60,0xC0,0xF8,0xCC,0xCC,0x78,0x00,\r\n\t\t0xFC,0xCC,0x0C,0x18,0x30,0x30,0x30,0x00,\r\n\t\t0x78,0xCC,0xCC,0x78,0xCC,0xCC,0x78,0x00,\r\n\t\t0x78,0xCC,0xCC,0x7C,0x0C,0x18,0x70,0x00,\r\n\t\t0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00,\r\n\t\t0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x30,\r\n\t\t0x18,0x30,0x60,0xC0,0x60,0x30,0x18,0x00,\r\n\t\t0x00,0x00,0x7E,0x00,0x7E,0x00,0x00,0x00,\r\n\t\t0x60,0x30,0x18,0x0C,0x18,0x30,0x60,0x00,\r\n\t\t0x3C,0x66,0x0C,0x18,0x18,0x00,0x18,0x00,\r\n\t\t0x7C,0xC6,0xDE,0xDE,0xDC,0xC0,0x7C,0x00,\r\n\t\t0x30,0x78,0xCC,0xCC,0xFC,0xCC,0xCC,0x00,\r\n\t\t0xFC,0x66,0x66,0x7C,0x66,0x66,0xFC,0x00,\r\n\t\t0x3C,0x66,0xC0,0xC0,0xC0,0x66,0x3C,0x00,\r\n\t\t0xF8,0x6C,0x66,0x66,0x66,0x6C,0xF8,0x00,\r\n\t\t0xFE,0x62,0x68,0x78,0x68,0x62,0xFE,0x00,\r\n\t\t0xFE,0x62,0x68,0x78,0x68,0x60,0xF0,0x00,\r\n\t\t0x3C,0x66,0xC0,0xC0,0xCE,0x66,0x3A,0x00,\r\n\t\t0xCC,0xCC,0xCC,0xFC,0xCC,0xCC,0xCC,0x00,\r\n\t\t0x78,0x30,0x30,0x30,0x30,0x30,0x78,0x00,\r\n\t\t0x1E,0x0C,0x0C,0x0C,0xCC,0xCC,0x78,0x00,\r\n\t\t0xE6,0x66,0x6C,0x78,0x6C,0x66,0xE6,0x00,\r\n\t\t0xF0,0x60,0x60,0x60,0x62,0x66,0xFE,0x00,\r\n\t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0x7C,0xCC,0xCC,0x76,0x00,\r\n\t\t0x00,0x00,0x78,0xCC,0xFC,0xC0,0x78,0x00,\r\n\t\t0x38,0x6C,0x64,0xF0,0x60,0x60,0xF0,0x00,\r\n\t\t0x00,0x00,0x76,0xCC,0xCC,0x7C,0x0C,0xF8,\r\n\t\t0xE0,0x60,0x6C,0x76,0x66,0x66,0xE6,0x00,\r\n\t\t0x30,0x00,0x70,0x30,0x30,0x30,0x78,0x00,\r\n\t\t0x0C,0x00,0x1C,0x0C,0x0C,0xCC,0xCC,0x78,\r\n\t\t0xE0,0x60,0x66,0x6C,0x78,0x6C,0xE6,0x00,\r\n\t\t0x70,0x30,0x30,0x30,0x30,0x30,0x78,0x00,\r\n\t\t0x00,0x00,0xCC,0xFE,0xFE,0xD6,0xD6,0x00,\r\n\t\t0x00,0x00,0xB8,0xCC,0xCC,0xCC,0xCC,0x00,\r\n\t\t0x00,0x00,0x78,0xCC,0xCC,0xCC,0x78,0x00,\r\n\t\t0x00,0x00,0xDC,0x66,0x66,0x7C,0x60,0xF0,\r\n\t\t0x00,0x00,0x76,0xCC,0xCC,0x7C,0x0C,0x1E,\r\n\t\t0x00,0x00,0xDC,0x76,0x62,0x60,0xF0,0x00,\r\n\t\t0x00,0x00,0x7C,0xC0,0x70,0x1C,0xF8,0x00,\r\n\t\t0x10,0x30,0xFC,0x30,0x30,0x34,0x18,0x00,\r\n\t\t0x00,0x00,0xCC,0xCC,0xCC,0xCC,0x76,0x00,\r\n\t\t0x00,0x00,0xCC,0xCC,0xCC,0x78,0x30,0x00,\r\n\t\t0x00,0x00,0xC6,0xC6,0xD6,0xFE,0x6C,0x00,\r\n\t\t0x00,0x00,0xC6,0x6C,0x38,0x6C,0xC6,0x00,\r\n\t\t0x00,0x00,0xCC,0xCC,0xCC,0x7C,0x0C,0xF8,\r\n\t\t0x00,0x00,0xFC,0x98,0x30,0x64,0xFC,0x00,\r\n\t\t0x1C,0x30,0x30,0xE0,0x30,0x30,0x1C,0x00,\r\n\t\t0x18,0x18,0x18,0x00,0x18,0x18,0x18,0x00,\r\n\t\t0xE0,0x30,0x30,0x1C,0x30,0x30,0xE0,0x00,\r\n\t\t0x76,0xDC,0x00,0x00,0x00,0x00,0x00,0x00,\r\n\t\t0x00,0x10,0x38,0x6C,0xC6,0xC6,0xFE,0x00\r\n\t];\r\n\r\n\tpublic static function PcRenderLetter(charCode:Int, colorOn:Int, colorOff:Int, baseRow:Int, baseCol:Int, targetBMD:flash.display.BitmapData) {\r\n\t\tvar baseIndex = charCode << 3;\r\n\t\tfor (curRow in 0...8) {\r\n\t\t\tvar rowBits = Font[baseIndex + curRow];\r\n\t\t\tfor (curCol in 0...8) {\r\n\t\t\t\ttargetBMD.setPixel32(baseCol+curCol, baseRow+curRow, (((rowBits << curCol) & 0x80) == 0x80)? colorOn : colorOff);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tpublic static function main() {\r\n\t\tvar bmd = new flash.display.BitmapData(320, 200, false, 0);\r\n\t\tvar bm = new flash.display.Bitmap(bmd);\r\n\r\n\t\tvar msgLines = [\r\n\t\t\t\"256KB OK\",\r\n\t\t\t\"\",\r\n\t\t\t\"\",\r\n\t\t\t\"The current date is: Thu 04/20/1989\",\r\n\t\t\t\"Enter new date: (mm-dd-yy)\",\r\n\t\t\t\"\",\r\n\t\t\t\"The current time is: 03:14:15.9\",\r\n\t\t\t\"Enter new time:\",\r\n\t\t\t\"\",\r\n\t\t\t\"\",\r\n\t\t\t\"MS-DOS 2.04\",\r\n\t\t\t\"\",\r\n\t\t\t\"A:\\\\>\"\r\n\t\t];\r\n\r\n\t\tfor (j in 0...msgLines.length) {\r\n\t\t\tvar msgStr = msgLines[j];\r\n\t\t\tfor (i in 0...msgStr.length) {\r\n\t\t\t\tvar c = msgStr.charCodeAt(i);\r\n\t\t\t\tPcRenderLetter(c, 0xa0a0a0, 0, (j>>1) + (j<<3), (i>>1) + (i<<3), bmd);\r\n\t\t\t}\r\n\t\t}\r\n\t\tflash.Lib.current.addChild(bm);\r\n\t}\r\n}\r\n```\r\n\r\nMaybe we could port it to canvas?"},"comment":{"url":"https://api.github.com/repos/HaxeFoundation/code-cookbook/issues/comments/252946353","html_url":"https://github.com/HaxeFoundation/code-cookbook/issues/55#issuecomment-252946353","issue_url":"https://api.github.com/repos/HaxeFoundation/code-cookbook/issues/55","id":252946353,"user":{"login":"fullofcaffeine","id":81248,"avatar_url":"https://avatars.githubusercontent.com/u/81248?v=3","gravatar_id":"","url":"https://api.github.com/users/fullofcaffeine","html_url":"https://github.com/fullofcaffeine","followers_url":"https://api.github.com/users/fullofcaffeine/followers","following_url":"https://api.github.com/users/fullofcaffeine/following{/other_user}","gists_url":"https://api.github.com/users/fullofcaffeine/gists{/gist_id}","starred_url":"https://api.github.com/users/fullofcaffeine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fullofcaffeine/subscriptions","organizations_url":"https://api.github.com/users/fullofcaffeine/orgs","repos_url":"https://api.github.com/users/fullofcaffeine/repos","events_url":"https://api.github.com/users/fullofcaffeine/events{/privacy}","received_events_url":"https://api.github.com/users/fullofcaffeine/received_events","type":"User","site_admin":false},"created_at":"2016-10-11T15:11:05Z","updated_at":"2016-10-11T15:11:05Z","body":"@dstrekelj Once again, thank you very much for the comprehensive explanation! "}}
{"actor":{"display_login":"fullofcaffeine"}}