gameboy printer
Fork of HelloWorld by
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 00002 #include "Pokitto.h" 00003 Pokitto::Core mygame; 00004 00005 #include <stdint.h> 00006 00007 //Total colors 4 00008 const uint16_t sprite_pal[] = { 00009 59196,35953,14823,0, 00010 }; 00011 00012 const uint8_t sprite[] = 00013 { 00014 160,144, 00015 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00016 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00017 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00018 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00019 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00020 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00021 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00022 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00023 0,0,0,0,0,0,0,0,0,0,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,0,0,0,0,0,0,0,0,0,0, 00024 0,0,0,0,0,0,0,0,0,0,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,0,0,0,0,0,0,0,0,0,0, 00025 0,0,0,0,0,0,0,0,0,0,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,0,0,0,0,0,0,0,0,0,0, 00026 0,0,0,0,0,0,0,0,0,0,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,0,0,0,0,0,0,0,0,0,0, 00027 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00028 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00029 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00030 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00031 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00032 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00033 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00034 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00035 0,0,0,0,0,0,0,0,0,85,85,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,85,85,0,0,0,0,0,0,0,0,0, 00036 0,0,0,0,0,0,0,0,0,85,85,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,85,85,0,0,0,0,0,0,0,0,0, 00037 0,0,0,0,0,0,0,0,0,85,85,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,85,85,0,0,0,0,0,0,0,0,0, 00038 0,0,0,0,0,0,0,0,0,85,85,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,85,85,0,0,0,0,0,0,0,0,0, 00039 0,0,0,0,0,0,0,0,0,85,170,170,170,85,85,85,85,85,85,85,85,85,85,85,85,85,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00040 0,0,0,0,0,0,0,0,0,85,170,170,170,85,85,85,85,85,85,85,85,85,85,85,85,85,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00041 0,0,0,0,0,0,0,0,0,85,170,170,170,85,85,85,85,85,85,85,85,85,85,85,85,85,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00042 0,0,0,0,0,0,0,0,0,85,170,170,170,85,85,85,85,85,85,85,85,85,85,85,85,85,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00043 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00044 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00045 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00046 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00047 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00048 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00049 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00050 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00051 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,85,85,0,0,0,0,85,85,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00052 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,85,85,0,0,0,0,85,85,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00053 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,85,85,0,0,0,0,85,85,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00054 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,85,85,0,0,0,0,85,85,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00055 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,85,0,0,85,0,0,85,0,0,85,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00056 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,85,0,0,85,0,0,85,0,0,85,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00057 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,85,0,0,85,0,0,85,0,0,85,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00058 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,85,0,0,85,0,0,85,0,0,85,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00059 0,0,0,0,0,0,0,85,85,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,85,85,0,0,0,0,0,0,0, 00060 0,0,0,0,0,0,0,85,85,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,85,85,0,0,0,0,0,0,0, 00061 0,0,0,0,0,0,0,85,85,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,85,85,0,0,0,0,0,0,0, 00062 0,0,0,0,0,0,0,85,85,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,85,85,0,0,0,0,0,0,0, 00063 0,0,0,0,0,0,85,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,85,0,0,0,0,0,0, 00064 0,0,0,0,0,0,85,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,85,0,0,0,0,0,0, 00065 0,0,0,0,0,0,85,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,85,0,0,0,0,0,0, 00066 0,0,0,0,0,0,85,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,85,0,0,0,0,0,0, 00067 0,0,0,0,0,0,85,0,0,85,170,170,170,85,0,0,85,0,0,0,0,0,0,85,0,0,85,170,170,170,85,0,0,85,0,0,0,0,0,0, 00068 0,0,0,0,0,0,85,0,0,85,170,170,170,85,0,0,85,0,0,0,0,0,0,85,0,0,85,170,170,170,85,0,0,85,0,0,0,0,0,0, 00069 0,0,0,0,0,0,85,0,0,85,170,170,170,85,0,0,85,0,0,0,0,0,0,85,0,0,85,170,170,170,85,0,0,85,0,0,0,0,0,0, 00070 0,0,0,0,0,0,85,0,0,85,170,170,170,85,0,0,85,0,0,0,0,0,0,85,0,0,85,170,170,170,85,0,0,85,0,0,0,0,0,0, 00071 0,0,0,0,0,0,0,85,85,85,170,170,170,85,0,0,0,85,85,85,85,85,85,0,0,0,85,170,170,170,85,85,85,0,0,0,0,0,0,0, 00072 0,0,0,0,0,0,0,85,85,85,170,170,170,85,0,0,0,85,85,85,85,85,85,0,0,0,85,170,170,170,85,85,85,0,0,0,0,0,0,0, 00073 0,0,0,0,0,0,0,85,85,85,170,170,170,85,0,0,0,85,85,85,85,85,85,0,0,0,85,170,170,170,85,85,85,0,0,0,0,0,0,0, 00074 0,0,0,0,0,0,0,85,85,85,170,170,170,85,0,0,0,85,85,85,85,85,85,0,0,0,85,170,170,170,85,85,85,0,0,0,0,0,0,0, 00075 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00076 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00077 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00078 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00079 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00080 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00081 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00082 0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0,0,0,0,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00083 0,0,0,0,0,0,0,0,0,85,170,170,170,85,85,85,85,85,85,85,85,85,85,85,85,85,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00084 0,0,0,0,0,0,0,0,0,85,170,170,170,85,85,85,85,85,85,85,85,85,85,85,85,85,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00085 0,0,0,0,0,0,0,0,0,85,170,170,170,85,85,85,85,85,85,85,85,85,85,85,85,85,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00086 0,0,0,0,0,0,0,0,0,85,170,170,170,85,85,85,85,85,85,85,85,85,85,85,85,85,85,170,170,170,85,0,0,0,0,0,0,0,0,0, 00087 0,0,0,0,0,0,0,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00088 0,0,0,0,0,0,0,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00089 0,0,0,0,0,0,0,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00090 0,0,0,0,0,0,0,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00091 0,0,0,0,0,0,0,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00092 0,0,0,0,0,0,0,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00093 0,0,0,0,0,0,0,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00094 0,0,0,0,0,0,0,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00095 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,170,170,170,170,85,85,85,170,170,85,0,0,0,0,0,0,0,0,0, 00096 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,170,170,170,170,85,85,85,170,170,85,0,0,0,0,0,0,0,0,0, 00097 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,170,170,170,170,85,85,85,170,170,85,0,0,0,0,0,0,0,0,0, 00098 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,170,170,170,170,85,85,85,170,170,85,0,0,0,0,0,0,0,0,0, 00099 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,170,170,170,170,85,85,85,170,170,85,0,0,0,0,0,0,0,0,0, 00100 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,170,170,170,170,85,85,85,170,170,85,0,0,0,0,0,0,0,0,0, 00101 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,170,170,170,170,85,85,85,170,170,85,0,0,0,0,0,0,0,0,0, 00102 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,170,170,170,170,85,85,85,170,170,85,0,0,0,0,0,0,0,0,0, 00103 0,0,0,0,0,0,0,0,0,85,170,170,85,85,85,85,85,85,170,170,170,85,85,85,170,85,85,85,170,170,85,0,0,0,0,0,0,0,0,0, 00104 0,0,0,0,0,0,0,0,0,85,170,170,85,85,85,85,85,85,170,170,170,85,85,85,170,85,85,85,170,170,85,0,0,0,0,0,0,0,0,0, 00105 0,0,0,0,0,0,0,0,0,85,170,170,85,85,85,85,85,85,170,170,170,85,85,85,170,85,85,85,170,170,85,0,0,0,0,0,0,0,0,0, 00106 0,0,0,0,0,0,0,0,0,85,170,170,85,85,85,85,85,85,170,170,170,85,85,85,170,85,85,85,170,170,85,0,0,0,0,0,0,0,0,0, 00107 0,0,0,0,0,0,0,0,0,85,170,170,85,85,85,85,85,85,170,170,170,85,85,85,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00108 0,0,0,0,0,0,0,0,0,85,170,170,85,85,85,85,85,85,170,170,170,85,85,85,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00109 0,0,0,0,0,0,0,0,0,85,170,170,85,85,85,85,85,85,170,170,170,85,85,85,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00110 0,0,0,0,0,0,0,0,0,85,170,170,85,85,85,85,85,85,170,170,170,85,85,85,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00111 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,85,85,85,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00112 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,85,85,85,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00113 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,85,85,85,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00114 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,85,85,85,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00115 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00116 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00117 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00118 0,0,0,0,0,0,0,0,0,85,170,170,170,170,85,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00119 0,0,0,0,0,0,0,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00120 0,0,0,0,0,0,0,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00121 0,0,0,0,0,0,0,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00122 0,0,0,0,0,0,0,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,0,0,0,0,0,0,0, 00123 0,0,0,0,0,0,0,0,0,85,85,85,170,170,170,170,170,170,85,85,85,170,170,170,170,170,170,170,85,85,85,0,0,0,0,0,0,0,0,0, 00124 0,0,0,0,0,0,0,0,0,85,85,85,170,170,170,170,170,170,85,85,85,170,170,170,170,170,170,170,85,85,85,0,0,0,0,0,0,0,0,0, 00125 0,0,0,0,0,0,0,0,0,85,85,85,170,170,170,170,170,170,85,85,85,170,170,170,170,170,170,170,85,85,85,0,0,0,0,0,0,0,0,0, 00126 0,0,0,0,0,0,0,0,0,85,85,85,170,170,170,170,170,170,85,85,85,170,170,170,170,170,170,170,85,85,85,0,0,0,0,0,0,0,0,0, 00127 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00128 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00129 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00130 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00131 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00132 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00133 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00134 0,0,0,0,0,0,0,0,0,85,0,0,85,170,170,170,170,170,170,170,170,170,170,170,170,170,170,85,0,0,85,0,0,0,0,0,0,0,0,0, 00135 0,0,0,0,0,0,0,0,0,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,0,0,0,0,0,0,0,0,0, 00136 0,0,0,0,0,0,0,0,0,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,0,0,0,0,0,0,0,0,0, 00137 0,0,0,0,0,0,0,0,0,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,0,0,0,0,0,0,0,0,0, 00138 0,0,0,0,0,0,0,0,0,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,0,0,0,0,0,0,0,0,0, 00139 0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0, 00140 0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0, 00141 0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0, 00142 0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0, 00143 0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0, 00144 0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0, 00145 0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0, 00146 0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,0,0,85,0,0,0,0,0,0,0,0,0, 00147 0,0,0,0,0,0,0,0,0,0,85,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,85,0,0,0,0,0,0,0,0,0,0, 00148 0,0,0,0,0,0,0,0,0,0,85,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,85,0,0,0,0,0,0,0,0,0,0, 00149 0,0,0,0,0,0,0,0,0,0,85,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,85,0,0,0,0,0,0,0,0,0,0, 00150 0,0,0,0,0,0,0,0,0,0,85,85,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,85,0,0,0,0,0,0,0,0,0,0, 00151 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00152 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00153 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00154 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00155 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00156 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00157 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00158 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 00159 }; 00160 00161 00162 00163 00164 int px,py=0; 00165 00166 char respond[] = {0, 0}; //The 2 byte response we always get 00167 00168 DigitalInOut datClk(P0_11); 00169 DigitalInOut datIn(P0_17); 00170 DigitalInOut datOut(P0_13); 00171 00172 unsigned short checksum = 0; 00173 int whichChar = 0; 00174 bool isPrinter=0; 00175 00176 void sendByte(unsigned char byteToSend) { 00177 00178 checksum += byteToSend; //Always build this, even if not used 00179 for (int x = 0 ; x < 8 ; x++) { 00180 if (byteToSend & B10000000) { 00181 datOut = 1; // data high 00182 } else { 00183 datOut = 0; // data low 00184 } 00185 datClk = 0; // clock low 00186 wait_us(55); 00187 datClk = 1; // clock high 00188 byteToSend <<= 1; 00189 wait_us(55); 00190 } 00191 datOut = 0; // test... 00192 wait_us(200); 00193 } 00194 00195 00196 void getResponse() { 00197 respond[0] = 0; 00198 respond[1] = 0; 00199 00200 for (int xx = 0 ; xx < 2 ; xx++) { 00201 for (int x = 0 ; x < 8 ; x++) { 00202 respond[xx] <<= 1; //Shift to the left making room for next bit. DO this first so we don't lose the last one 00203 datClk = 0; 00204 wait_us(25); 00205 if(datIn){ 00206 respond[xx] |= 1; //Set it 00207 } 00208 wait_us(25); 00209 datClk = 1; 00210 wait_us(55); 00211 } 00212 wait_us(200); 00213 } 00214 wait_us(500); 00215 } 00216 00217 void sendChecksum() { 00218 unsigned short lineChecksum = checksum; //Grab the state of checksum so we don't change it while sending 00219 sendByte(lineChecksum & 0xFF); //Send checksum low byte 00220 sendByte(lineChecksum >> 8); //Send checksum high byte 00221 } 00222 00223 void sendHeader(){ 00224 sendByte(0x88); // magic 00225 sendByte(0x33); // magic 00226 checksum = 0; // reset checksum 00227 } 00228 00229 void initPrinter(){ 00230 sendHeader(); 00231 sendByte(0x01); // 1 = init printer 00232 sendByte(0x00); // compression, 0 = none, 1 = RLE 00233 sendByte(0x00); // data length 00234 sendByte(0x00); // data length 2nd byte 00235 sendChecksum(); 00236 getResponse(); 00237 } 00238 00239 void printLine(){ 00240 sendHeader(); 00241 sendByte(0x04); // 4 = Send some print data 00242 sendByte(0x00); // compression, 0 = none, 1 = RLE 00243 // send 0x280 which is 640, the maximum data allowed at a time 00244 sendByte(0x80); // data length 00245 sendByte(0x02); // data length 2nd byte 00246 /* 00247 for(int t=0; t<640; t++){ 00248 //sendByte(hadl[t]); // test data 00249 sendByte(sprite[t+2]); // test data 00250 } 00251 */ 00252 00253 int x1,y1,p1,p2,p3,p4,p5,p6,p7,p8,fullPixel; 00254 for(int line=0; line<2; line++){ 00255 for(int block=0; block<20; block++){ 00256 for(int row=0; row<8; row++){ 00257 fullPixel = 0; 00258 x1 = px+(block*8); 00259 y1 = py+(line*8)+row; 00260 p1 = (mygame.display.getPixel(x1, y1)&2)>>1; 00261 p2 = (mygame.display.getPixel(x1+1, y1)&2)>>1; 00262 p3 = (mygame.display.getPixel(x1+2, y1)&2)>>1; 00263 p4 = (mygame.display.getPixel(x1+3, y1)&2)>>1; 00264 p5 = (mygame.display.getPixel(x1+4, y1)&2)>>1; 00265 p6 = (mygame.display.getPixel(x1+5, y1)&2)>>1; 00266 p7 = (mygame.display.getPixel(x1+6, y1)&2)>>1; 00267 p8 = (mygame.display.getPixel(x1+7, y1)&2)>>1; 00268 // getPixel is currently broken, so were-combine the pixels in a different order. 00269 fullPixel = (p4<<7)+(p3<<6)+(p2<<5)+(p1<<4)+(p8<<3)+(p7<<2)+(p6<<1)+p5; 00270 sendByte(fullPixel); 00271 00272 p1 = mygame.display.getPixel(x1, y1)&1; 00273 p2 = mygame.display.getPixel(x1+1, y1)&1; 00274 p3 = mygame.display.getPixel(x1+2, y1)&1; 00275 p4 = mygame.display.getPixel(x1+3, y1)&1; 00276 p5 = mygame.display.getPixel(x1+4, y1)&1; 00277 p6 = mygame.display.getPixel(x1+5, y1)&1; 00278 p7 = mygame.display.getPixel(x1+6, y1)&1; 00279 p8 = mygame.display.getPixel(x1+7, y1)&1; 00280 fullPixel = (p4<<7)+(p3<<6)+(p2<<5)+(p1<<4)+(p8<<3)+(p7<<2)+(p6<<1)+p5; 00281 00282 sendByte(fullPixel); 00283 } 00284 } 00285 } 00286 00287 sendChecksum(); 00288 getResponse(); 00289 // end data statement 00290 sendHeader(); 00291 sendByte(0x04); // 00292 sendByte(0x00); // 00293 sendByte(0x00); // 00294 sendByte(0x00); // 00295 sendChecksum(); 00296 getResponse(); 00297 00298 sendByte(0x88); // Magic bytes 00299 sendByte(0x33); 00300 checksum = 0; 00301 sendByte(0x02); // Commande 2 (Print) 00302 sendByte(0x00); 00303 sendByte(0x04); // 4 bytes to send 00304 sendByte(0x00); 00305 sendByte(0x01); // 1 = print, 0 = line feed 00306 if(py/16==8){ 00307 sendByte(0x03); // Marges (nibbles avant 1, après 3) 00308 }else{ 00309 sendByte(0x00); // Marges (nibbles avant 1, après 3) 00310 } 00311 sendByte(0xE4); // Palette (11100100: Noir, Foncé, Clair, Blanc) 00312 sendByte(0x40); // Expo (7 bits) 00313 00314 sendChecksum(); 00315 getResponse(); 00316 00317 } 00318 00319 00320 int main () { 00321 mygame.begin(); 00322 00323 datClk.output(); // clock to output 00324 datOut.output(); // data out to output 00325 datIn.input(); // data In to input 00326 datIn.mode(PullUp); 00327 00328 datClk = 1; // start clock line high 00329 datOut = 0; // start data low 00330 00331 00332 //wait(5); // hang on a little 00333 00334 //printShape(1); // test! 00335 00336 mygame.display.persistence = 1; 00337 // mygame.display.clear(); 00338 // mygame.display.print("Printer Test\n"); 00339 00340 mygame.display.drawBitmap(0,0,sprite); 00341 mygame.display.load565Palette(sprite_pal); 00342 00343 00344 while (mygame.isRunning()) { 00345 if (mygame.update()) { 00346 00347 if (mygame.buttons.bBtn()){ 00348 mygame.display.drawBitmap(0,0,sprite); 00349 py=0; 00350 } 00351 00352 if (mygame.buttons.aBtn()){ 00353 initPrinter(); 00354 py=0; 00355 if(respond[0]==0x81 && respond[1]==0x00){ 00356 isPrinter=1; 00357 } 00358 00359 00360 if(isPrinter){ 00361 int t=0; 00362 while(t<9){ 00363 00364 wait_ms(300); 00365 sendByte(0x88); // magic 00366 sendByte(0x33); // magic 00367 checksum = 0; 00368 sendByte(0x0F); // 00369 sendByte(0x00); // 00370 sendByte(0x00); // 00371 sendByte(0x00); // 00372 sendChecksum(); 00373 getResponse(); 00374 00375 if(!(respond[1]&0x0B)){ 00376 printLine(); 00377 py+=16; 00378 t++; 00379 } 00380 } // t 00381 00382 00383 00384 00385 }else{ 00386 // show error log here 00387 if(respond[0] != 0x81){ 00388 mygame.display.print("Not Printer\n"); 00389 }else{ 00390 mygame.display.print("Printer Error\n"); 00391 } 00392 } 00393 00394 // wait(1); 00395 } 00396 } 00397 } 00398 00399 }
Generated on Tue Jul 19 2022 02:32:22 by 1.7.2