tic tac toe

This commit is contained in:
kraus 2018-10-05 23:52:30 +02:00
parent 168ed38832
commit 1c8ddc40d0
6 changed files with 869 additions and 208 deletions

View File

@ -32,6 +32,9 @@
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SSD1322:
480 x 128 dot matrix
16 gray scale
*/

View File

@ -30,6 +30,9 @@
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SSD1325:
128 x 80, 16 Gray Scale Dot Matrix
*/

View File

@ -8,9 +8,9 @@
:100070000C9469040C9469040C9469040C9469044C
:100080000C9469040C9469040C9469040C9469043C
:100090000C94B91C0C9469040C9469040C946904C4
:1000A0000C9469040C9469040C946904D817DB1748
:1000B000CA17CE17D417FC17FC17FC17DF17E31766
:1000C000E717ED17F117FC17F717080B00020202EC
:1000A0000C9469040C9469040C9469049D17A017BE
:1000B0008F1793179917C117C117C117A417A8173E
:1000C000AC17B217B617C117BC17080B0002020213
:1000D00001000904000001020200000524001001D3
:1000E0000524010101042402060524060001070578
:1000F000810310004009040100020A000000070506
@ -183,8 +183,8 @@
:100B6000CF93DF9300D0CDB7DEB77C01162F042FD3
:100B7000663159F028F46431C9F0653131F027C08D
:100B8000673169F06A3118F511C060E0C7010E9451
:100B9000151A602FC7010E94061A81E019C061E092
:100BA00029833A830E94151A3A812981D701189620
:100B9000DA19602FC7010E94CB1981E019C061E00A
:100BA00029833A830E94DA193A812981D70118965C
:100BB000ED91FC911997402F612FC7010F900F9075
:100BC000DF91CF911F910F91FF90EF90099480E0FA
:100BD0000F900F90DF91CF911F910F91FF90EF90A9
@ -377,11 +377,11 @@
:101780001F910F910895DF92EF92FF920F931F9395
:10179000CF93DF93D82E8A017B01E40EF51EEB0177
:1017A000CE15DF0571F0D7FE03C0FE01849101C0A4
:1017B00088810E945D1721968111F2CF8FEF9FEFF4
:1017B00088810E94411B21968111F2CF8FEF9FEF0C
:1017C00001C0C801DF91CF911F910F91FF90EF9061
:1017D000DF9008950F931F93CF93DF931F92CDB7A0
:1017E000DEB782E0898342E450E06AEC70E080E892
:1017F0000E94C30B0E941F1ADC0112960D911C91CE
:1017F0000E94C30B0E94E419DC0112960D911C910A
:1018000013970115110569F0D801ED91FC91028043
:10181000F381E02DBE016F5F7F4FC801099597FFEF
:1018200007C089810F90DF91CF911F910F9108958B
@ -479,21 +479,21 @@
:101DE000E10083FF0FC01092E90091E09093EB00B7
:101DF0001092EC0092E39093ED001092190498E099
:101E00009093F00082FF20C093E09093E9009091BE
:101E1000F200992319F09AE39093E8009091E60379
:101E2000992339F09091E60391509093E60399231A
:101E1000F200992319F09AE39093E8009091B803A7
:101E2000992339F09091B80391509093B803992376
:101E300089F190911804992339F0909118049150E8
:101E400090931804992341F184FF10C08091E2001F
:101E50008E7E81608093E2008091E1008F7E80938E
:101E6000E1008091E7038E7E806111C080FF16C083
:101E6000E1008091B9038E7E806111C080FF16C0B1
:101E70008091E2008E7E80618093E2008091E1009B
:101E80008E7E8093E1008091E7038E7E8160809357
:101E9000E70304C05D9ACDCF289AD6CF9F918F914A
:101E80008E7E8093E1008091B9038E7E8160809385
:101E9000B90304C05D9ACDCF289AD6CF9F918F9178
:101EA0000F900FBE0F901F9018951F920F920FB6B4
:101EB0000F921124CF92DF92EF92FF920F931F9314
:101EC0002F933F934F935F936F937F938F939F9342
:101ED000AF93BF93EF93FF93CF93DF93CDB7DEB76D
:101EE0006C97DEBFCDBF1092E9008091E80083FFC0
:101EF000EDC168E0CE0145960E948B1782EF80937A
:101EF000EDC168E0CE0145960E946F1B82EF809392
:101F0000E8008D8987FF05C09091E80090FFFCCF25
:101F100003C09EEF9093E800982F907609F0C6C01A
:101F20009E892F89188D91110CC0803829F48091D9
@ -511,7 +511,7 @@
:101FE000275F3F4F3C832B838D831092E900109233
:101FF000C6021092C502F092C402E092C30249E008
:1020000050E080E00E94C30B0E94EA0BE2C0F09215
:10201000C402E092C3020E941F1ADC011296ED90E6
:10201000C402E092C3020E94E419DC011296ED9022
:10202000FC901397E114F10409F4C0C0D701ED91BD
:10203000FC910480F581E02DBE016B5E7F4FC701EE
:102040000995009719F00CF0C4C0C7C0F701E084EF
@ -523,17 +523,17 @@
:1020A0001092EA008F898093190493C08B8D9C8DC8
:1020B0001092E9001092C6021092C5029093C402D9
:1020C0008093C302898D811156C08E899D89913A72
:1020D00059F4813209F081C047E050E069E071E0D5
:1020D00059F4813209F081C047E050E065E071E0D9
:1020E00080E00E94C30B75C0913209F076C0833244
:1020F00089F4888D90E0982F88272F89822BA0E083
:10210000B0E08093000190930101A0930201B0938D
:1021100003015FC0803269F48091E80082FFFCCF48
:1021200067E089E091E00E948B178BEF8093E800D5
:1021300006C0823209F04DC08F89809310018091D2
:1021200067E085E091E00E946F1B8BEF8093E800F1
:1021300006C0823209F04DC08F8980930C018091D6
:10214000C702882319F0EEEFFAE002C0E0E0F8E001
:102150008091090190910A01A0910B01B0910C01AD
:10216000803B9440A105B10509F07BC0809110012E
:1021700080FF93C076C00E941F1ADC0112960D9159
:102150008091050190910601A0910701B0910801BD
:10216000803B9440A105B10509F07BC080910C0132
:1021700080FF93C076C00E94E419DC0112960D9195
:102180001C9113970115110541F1D801ED91FC91B6
:102190000190F081E02DBE016B5E7F4FC801099573
:1021A000811117C0F80100851185ECCF113009F4B9
@ -541,7 +541,7 @@
:1021C00081F440E86CE08EE291E00E94E71D8823F4
:1021D00021F08EEF8093E80079C081E28093EB00DC
:1021E00075C0813029F440E86BE082E291E0EDCFE8
:1021F000833099F70E941F1ADC011296ED90FC9033
:1021F000833099F70E94E419DC011296ED90FC906F
:1022000013978E010F5F1F4F6801E114F10479F0FD
:10221000D701ED91FC910680F781E02DB801C7014F
:102220000995080F111DF701E084F184EECFD80164
@ -745,139 +745,139 @@
:102E8000FD4FE55BFF4F908180931403992319F068
:102E9000109315030AC082E08093150306C0802FAB
:102EA0000E94C00D082F8111D8CF0F90DF91CF91D4
:102EB0001F910F91FF90EF9008954091C50250919E
:102EC000C6022091C3023091C40242175307B4F4E2
:102ED0009091E8009570E1F39091E80092FD19C09F
:102EE0008093F1008091C5029091C60201968F7384
:102EF0009927892B19F48EEF8093E8008091C50201
:102F00009091C60201969093C6028093C50281E01B
:102F1000089580E00895615030F02091F100FC01A7
:102F200020830196F8CF289884E6809318040895AA
:102F300040911604262F30E0240F311D2132310537
:102F4000DCF4209117042430C9F4FC0180E090E007
:102F5000861758F4309116042191DC01AA50BC4F19
:102F6000A30FB11D2C930196F3CF80911604680F27
:102F70006093160480E0089581E0089582E008954A
:102F800090E0FC013197EF30F105B0F5EA5AFF4FC0
:102F90000C947623809180008F7703C0809180000D
:102FA0008F7D80938000089580918000877FF9CF86
:102FB00084B58F7702C084B58F7D84BD08958091DC
:102FC00090008F7707C0809190008F7D03C0809123
:102FD0009000877F8093900008958091C0008F7744
:102FE00003C08091C0008F7D8093C00008958091C0
:102FF000C200877F8093C20008951F93CF93DF9311
:10300000282F30E0F901EF59F74F8491F901EE5B79
:10301000F74FD491F901ED5DF74FC491CC23C9F07E
:10302000162F81110E94C017EC2FF0E0EE0FFF1F4A
:10303000EB5EF74FA591B4918FB7F894111105C0CD
:103040009C91ED2FE095E92302C0EC91ED2BEC93E0
:103050008FBFDF91CF911F910895CF93DF9390E0C1
:10306000FC01EE5BF74F2491FC01ED5DF74F84917D
:10307000882361F190E0880F991FFC01E95FF74F09
:10308000C591D491FC01EB5EF74FA591B49161110C
:1030900009C09FB7F8948881209582238883EC919A
:1030A0002E230BC0623061F49FB7F8943881822FD1
:1030B000809583238883EC912E2B2C939FBF06C091
:1030C0008FB7F894E8812E2B28838FBFDF91CF91A3
:1030D000089508958FEF9FEF08958FEF9FEF089564
:1030E0008091F50390E09195819591090895CF9392
:1030F000DF9300D0CDB7DEB7CB01642F49835A836D
:103100000E9498174981842F5A81952F0F900F9014
:10311000DF91CF910895CF93DF931F92CDB7DEB7A4
:10312000698361E0CE0101960E94981781E090E0EA
:103130000F90DF91CF910895CF92DF92EF92FF929F
:103140000F931F93CF93DF936C017A018B01C0E043
:10315000D0E0CE15DF0589F0D8016D918D01D60143
:10316000ED91FC910190F081E02DC6010995892B2C
:1031700011F47E0102C02196ECCFC701DF91CF91FF
:103180001F910F91FF90EF90DF90CF900895CF9314
:10319000DF931F92CDB7DEB76983DC01ED91FC911F
:1031A0000280F381E02D41E050E0BE016F5F7F4F70
:1031B00009950F90DF91CF91089583E08093E90006
:1031C0008091F200882319F08AE38093E800089543
:1031D000FC018485958597FD0BC09FB7F89482E02C
:1031E0008093E9008091F2009FBF90E001960895DE
:1031F0009FB7F89482E08093E9008091F2009FBF2E
:1032000090E008950E949F1C90E008950F931F93F3
:10321000CF93DF931F92CDB7DEB78C01FC0184857D
:10322000958597FF0EC0CE0101960E94751C0197EF
:1032300019F4298130E002C02FEF3FEFF801358704
:103240002487F801848595850F90DF91CF911F9198
:103250000F910895CF93DF931F92CDB7DEB7FC0196
:103260008485958597FD05C02FEF3FEF358724872F
:103270000BC0CE0101960E94751C019719F489813B
:1032800090E002C08FEF9FEF0F90DF91CF910895F4
:10329000CF92DF92EF92FF92CF93DF93EC016831F0
:1032A00009F456C038F46431C9F0673109F0A6C09A
:1032B000F9010DC0693109F48EC0603209F09EC079
:1032C0006AE497C00DB407FEFDCF8EB5415044238C
:1032D00009F492C081918EBD0000F4CFE881F9819C
:1032E000418169E40E94CC06CFB7F8948091E8034D
:1032F000811127C0E4E3F8E08491E3E5F8E09491DC
:10330000E82FF0E0EE0FFF1FE95FF74FA591B491B2
:10331000EC91E92321F461E081E10E94FD1761E075
:1033200081E10E942D188CB580618CBD8CB58064C4
:103330008CBD61E08FE00E942D1861E080E10E9469
:103340002D188091E8038F5F8093E803CFBF54C0AE
:10335000A881B9811C96EC911C97E150E33028F4C8
:10336000F0E0EA5EFD4F808101C080E01896CD90CC
:10337000DD90ED90FC901B9720E040E052E16AE781
:1033800070E0C416D506E606F70640F47695679514
:10339000579547952F5F2630A1F727E091E09227B8
:1033A0008C708065292F2695822B91708CBD9DBDD8
:1033B000E881F981408169E4CE010E94CC06A881B0
:1033C000B981EA85FB8520E030E012964C916CE2F1
:1033D000CE01099511C0A881B981EA85FB8520E05D
:1033E00030E013964C916CE20995E881F9814181B6
:1033F00069E4CE010E94CC0681E001C080E0DF914B
:10340000CF91FF90EF90DF90CF900895CF93DF930F
:103410001F92CDB7DEB76983BE016F5F7F4F0E94F9
:10342000B01C0F90DF91CF910895462FDC011896C4
:10343000ED91FC91199720E030E060E209948091D1
:10344000ED0381110DC082E08093E90384E0809355
:10345000EA031092EC031092EB0381E08093ED03FA
:1034600089EE93E008958F929F92AF92BF92CF9290
:10347000DF92EF92FF926B017C010E945D064B018F
:103480005C01C114D104E104F104F1F00E945D0675
:10349000DC01CB0188199909AA09BB09883E934030
:1034A000A105B10570F321E0C21AD108E108F108C5
:1034B00088EE880E83E0981EA11CB11CC114D104B3
:1034C000E104F10419F7DDCFFF90EF90DF90CF908A
:1034D000BF90AF909F908F9008958F929F92AF92E0
:1034E000BF92CF92DF92EF92FF920F931F93CF93F1
:1034F000DF935C016B017A0180911001882309F44C
:103500005BC080911904882309F456C08091E703B9
:1035100080FF05C08091E00082608093E000E701B9
:1035200010E00AEF83E0882E9AE3992E2097D9F1D4
:103530000E949F1C81110AC0015009F43DC061E046
:1035400070E080E090E00E94331AF0CF282F30E046
:10355000C217D3070CF48C2F4FB7F8948092E90070
:103560009091E80095FF1DC0282F30E0C21BD30BBF
:10357000F601982F915020F081918093F100FACFBD
:10358000C20ED31E112319F09092E80009C0809159
:10359000E80085FD06C09092E80011E0209709F050
:1035A00010E04FBFC3CF1111C3CF5D9884E6809365
:1035B000E6031E141F0444F081E090E0F5019383BC
:1035C000828380E090E001C0C701DF91CF911F911D
:1035D0000F91FF90EF90DF90CF90BF90AF909F90B2
:1035E0008F9008950F931F93CF93DF93EC01862F55
:1035F000642F8C3270F48A3208F076C0883289F0F9
:10360000893209F042C070E080E090E00E94331AF5
:103610006BC08D32D1F0C8F194EB980F923020F14D
:1036200034C08E01055E1F4FD0E0F80181918F01FB
:103630008F3F39F0D03110F461E001C062E00E94A8
:103640002D18DF5FD63189F74FC0433018F082E084
:1036500090E002C085E090E0880F991F880F991FC5
:1036600005970197F1F740C08F73C80FD11D411125
:1036700007C061E08B8D0E942D1860E08B8D11C01A
:1036800062E08B8D0E942D182FC0803478F18F73EB
:10369000FE01E80FF11D238D2F3F31F1803120F421
:1036A000822F0E94FD1720C030E0F901EF59F74F3B
:1036B0008491F901EE5BF74F0491F901ED5DF74F4D
:1036C0001491112379F081110E94C017E12FF0E0CD
:1036D000EE0FFF1FE750F84FA591B491EC91E02356
:1036E00081E009F480E08E8B81E001C080E0DF9111
:1036F000CF911F910F91089585ED8093BC0080912B
:102EB0001F910F91FF90EF90089540911604262FD7
:102EC00030E0240F311D21323105DCF4209117044C
:102ED0002430C9F4FC0180E090E0861758F430916A
:102EE00016042191DC01AA50BC4FA30FB11D2C93F5
:102EF0000196F3CF80911604680F6093160480E06A
:102F0000089581E0089582E0089590E0FC013197F2
:102F1000EF30F105B0F5EA5AFF4F0C94762380911B
:102F200080008F7703C0809180008F7D8093800028
:102F3000089580918000877FF9CF84B58F7702C094
:102F400084B58F7D84BD0895809190008F7707C0F0
:102F5000809190008F7D03C080919000877F809347
:102F6000900008958091C0008F7703C08091C000C9
:102F70008F7D8093C00008958091C200877F8093E9
:102F8000C20008951F93CF93DF93282F30E0F901FB
:102F9000EF59F74F8491F901EE5BF74FD491F901A6
:102FA000ED5DF74FC491CC23C9F0162F81110E941B
:102FB0008517EC2FF0E0EE0FFF1FEB5EF74FA591AA
:102FC000B4918FB7F894111105C09C91ED2FE09545
:102FD000E92302C0EC91ED2BEC938FBFDF91CF91F1
:102FE0001F910895CF93DF9390E0FC01EE5BF74FC4
:102FF0002491FC01ED5DF74F8491882361F190E00D
:10300000880F991FFC01E95FF74FC591D491FC012E
:10301000EB5EF74FA591B491611109C09FB7F89489
:103020008881209582238883EC912E230BC0623007
:1030300061F49FB7F8943881822F80958323888329
:10304000EC912E2B2C939FBF06C08FB7F894E8818C
:103050002E2B28838FBFDF91CF91089508958FEF96
:103060009FEF08958FEF9FEF08958091C70390E041
:103070009195819591090895CF93DF9300D0CDB7B5
:10308000DEB7CB01642F49835A830E945D174981C3
:10309000842F5A81952F0F900F90DF91CF91089533
:1030A000CF93DF931F92CDB7DEB7698361E0CE0186
:1030B00001960E945D1781E090E00F90DF91CF9123
:1030C0000895CF92DF92EF92FF920F931F93CF93C9
:1030D000DF936C017A018B01C0E0D0E0CE15DF05F3
:1030E00089F0D8016D918D01D601ED91FC9101908F
:1030F000F081E02DC6010995892B11F47E0102C0F3
:103100002196ECCFC701DF91CF911F910F91FF90D6
:10311000EF90DF90CF900895CF93DF931F92CDB7BC
:10312000DEB76983DC01ED91FC910280F381E02D33
:1031300041E050E0BE016F5F7F4F09950F90DF9136
:10314000CF91089583E08093E9008091F200882375
:1031500019F08AE38093E8000895FC018485958541
:1031600097FD0BC09FB7F89482E08093E9008091AF
:10317000F2009FBF90E0019608959FB7F89482E017
:103180008093E9008091F2009FBF90E008950E9433
:103190009F1C90E00895CF93DF931F92CDB7DEB7C9
:1031A000FC018485958597FD05C02FEF3FEF35879E
:1031B00024870BC0CE0101960E94751C019719F45B
:1031C000898190E002C08FEF9FEF0F90DF91CF9148
:1031D00008950F931F93CF93DF931F92CDB7DEB760
:1031E0008C01FC018485958597FF0EC0CE01019668
:1031F0000E94751C019719F4298130E002C02FEF5D
:103200003FEFF80135872487F801848595850F9075
:10321000DF91CF911F910F910895CF92DF92EF929E
:10322000FF92CF93DF93EC01683109F456C038F474
:103230006431C9F0673109F0A6C0F9010DC06931E8
:1032400009F48EC0603209F09EC06AE497C00DB4E4
:1032500007FEFDCF8EB54150442309F492C0819101
:103260008EBD0000F4CFE881F981418169E40E94BC
:10327000CC06CFB7F8948091BA03811127C0E4E35C
:10328000F8E08491E3E5F8E09491E82FF0E0EE0FA8
:10329000FF1FE95FF74FA591B491EC91E92321F469
:1032A00061E081E10E94C21761E081E10E94F217B2
:1032B0008CB580618CBD8CB580648CBD61E08FE085
:1032C0000E94F21761E080E10E94F2178091BA0338
:1032D0008F5F8093BA03CFBF54C0A881B9811C9679
:1032E000EC911C97E150E33028F4F0E0E852FE4FF7
:1032F000808101C080E01896CD90DD90ED90FC902B
:103300001B9720E040E052E16AE770E0C416D50662
:10331000E606F70640F476956795579547952F5F33
:103320002630A1F727E091E092278C708065292F45
:103330002695822B91708CBD9DBDE881F9814081DD
:1033400069E4CE010E94CC06A881B981EA85FB859B
:1033500020E030E012964C916CE2CE01099511C04C
:10336000A881B981EA85FB8520E030E013964C9175
:103370006CE20995E881F981418169E4CE010E94FE
:10338000CC0681E001C080E0DF91CF91FF90EF900B
:10339000DF90CF900895CF93DF931F92CDB7DEB724
:1033A0006983BE016F5F7F4F0E94B01C0F90DF9159
:1033B000CF910895462FDC011896ED91FC91199755
:1033C00020E030E060E209948091BF0381110DC0DC
:1033D00082E08093BB0384E08093BC031092BE0321
:1033E0001092BD0381E08093BF038BEB93E00895BF
:1033F0008F929F92AF92BF92CF92DF92EF92FF9205
:103400006B017C010E945D064B015C01C114D1047B
:10341000E104F104F1F00E945D06DC01CB018819A2
:103420009909AA09BB09883E9340A105B10570F32B
:1034300021E0C21AD108E108F10888EE880E83E085
:10344000981EA11CB11CC114D104E104F10419F7A8
:10345000DDCFFF90EF90DF90CF90BF90AF909F9027
:103460008F9008958F929F92AF92BF92CF92DF92EA
:10347000EF92FF920F931F93CF93DF935C016B0149
:103480007A0180910C01882309F45BC080911904B2
:10349000882309F456C08091B90380FF05C080914C
:1034A000E00082608093E000E70110E00AEF83E033
:1034B000882E9AE3992E2097D9F10E949F1C8111A2
:1034C0000AC0015009F43DC061E070E080E090E086
:1034D0000E94F819F0CF282F30E0C217D3070CF460
:1034E0008C2F4FB7F8948092E9009091E80095FFF7
:1034F0001DC0282F30E0C21BD30BF601982F91502E
:1035000020F081918093F100FACFC20ED31E1123D7
:1035100019F09092E80009C08091E80085FD06C08E
:103520009092E80011E0209709F010E04FBFC3CF60
:103530001111C3CF5D9884E68093B8031E141F0455
:1035400044F081E090E0F5019383828380E090E095
:1035500001C0C701DF91CF911F910F91FF90EF90B4
:10356000DF90CF90BF90AF909F908F9008950F9372
:103570001F93CF93DF93EC01862F642F8C3270F46E
:103580008A3208F076C0883289F0893209F042C068
:1035900070E080E090E00E94F8196BC08D32D1F0AD
:1035A000C8F194EB980F923020F134C08E01055E83
:1035B0001F4FD0E0F80181918F018F3F39F0D0315A
:1035C00010F461E001C062E00E94F217DF5FD631C3
:1035D00089F74FC0433018F082E090E002C085E0E8
:1035E00090E0880F991F880F991F05970197F1F7B1
:1035F00040C08F73C80FD11D411107C061E08B8D92
:103600000E94F21760E08B8D11C062E08B8D0E94EA
:10361000F2172FC0803478F18F73FE01E80FF11D8F
:10362000238D2F3F31F1803120F4822F0E94C21769
:1036300020C030E0F901EF59F74F8491F901EE5BBA
:10364000F74F0491F901ED5DF74F1491112379F0D3
:1036500081110E948517E12FF0E0EE0FFF1FE75068
:10366000F84FA591B491EC91E02381E009F480E05A
:103670008E8B81E001C080E0DF91CF911F910F918F
:1036800008954091C5025091C6022091C302309125
:10369000C40242175307B4F49091E8009570E1F327
:1036A0009091E80092FD19C08093F1008091C502CD
:1036B0009091C60201968F739927892B19F48EEF8A
:1036C0008093E8008091C5029091C6020196909384
:1036D000C6028093C50281E0089580E0089561509C
:1036E00030F02091F100FC0120830196F8CF28985A
:1036F00084E680931804089585ED8093BC00809142
:10370000BC0084FDFCCF1092170408950E947C2316
:103710001F93CF93DF93D0E5CFEF11E010933404E4
:1037200040E06D2F8EE194E00E94CC06809134043D
@ -957,10 +957,10 @@
:103BC0003F912F910F900FBE0F901F901895CF929D
:103BD000DF92EF92FF920F931F93CF93DF931F9289
:103BE000CDB7DEB7182F062FE42E862F880F8E5FF5
:103BF00099830E945D1783E00E945D17F12EC12E0C
:103BF00099830E94411B83E00E94411BF12EC12E3C
:103C00009981D92E8C2D8F19801798F4F601E7FE33
:103C100002C0849101C080810E945D17182F80E04E
:103C20000E945D178123FFEFCF1ADF0A8111EACFCF
:103C100002C0849101C080810E94411B182F80E066
:103C20000E94411B8123FFEFCF1ADF0A8111EACFE7
:103C300001C081E00F90DF91CF911F910F91FF9014
:103C4000EF90DF90CF900895789484B5826084BD22
:103C500084B5816084BD85B5826085BD85B5816090
@ -975,10 +975,10 @@
:103CE000C20081608093C20080917A0084608093DA
:103CF0007A0080917A00826080937A0080917A00C5
:103D0000816080937A0080917A00806880937A0045
:103D1000109219041092C8021092E7038091D70004
:103D1000109219041092C8021092B9038091D70032
:103D200081608093D70080EA8093D80089B5806154
:103D300089BD89B5826089BD09B400FEFDCF61E00F
:103D400070E080E090E00E94331A8091D8008F7C70
:103D400070E080E090E00E94F8198091D8008F7CAC
:103D500080618093D8008091E000807F8093E000B4
:103D60008091E1008E7E8093E1008DE08093E200FF
:103D7000559A209AEEEFFFE7859194918B3F9C4DE9
@ -991,19 +991,19 @@
:103DE000E0912204F091230420E030E040E06BE019
:103DF0008EE194E009958EE194E09093CC0280935B
:103E0000CB0280915D0481508093CA0281E080934F
:103E10008E0498E09093040180930501809313032E
:103E10008E0498E09093040180930D018093130326
:103E20000E94A90C89EE92E07C01EE0CFF1C87E059
:103E3000C82ED12C9EE9A92E94E0B92E8EE194E0F3
:103E40000E9499148091C902E091CB02F091CC02BA
:103E500081114BC08091CD02811102C082E001C06E
:103E600084E080930601909106019E5FC7AD8C2F80
:103E600084E080930E0190910E019E5FC7AD8C2F70
:103E7000E9E09E9F801911248695C81B20E040E050
:103E800065E572E087EF8C0F0E940415C25120ECAB
:103E900031E041E060E08091CB029091CC020E9441
:103EA000DF1B20EC31E041E068E78091CB0290918C
:103EB000CC020E94DF1BD0E080910601D81708F0E9
:103EC00021C2C95021E08091E303D81320E0ED2FF7
:103ED000F0E0EE0FFF1FE852FE4F6081718140E07D
:103EB000CC020E94DF1BD0E080910E01D81708F0E1
:103EC00021C2C95021E08091F303D81320E0ED2FE7
:103ED000F0E0EE0FFF1FE552FE4F6081718140E080
:103EE0008C2F0E940415DF5FE7CF61E0CF010E94B5
:103EF0000D08612C712CC62D862D8695869586958C
:103F00008601081B1109E3E0000F111FEA95E1F794
@ -1035,81 +1035,81 @@
:1040A000F71D328004C0F401E619F7093184C32DED
:1040B000CF7009F44AC0D0E0219773E0CC0FDD1F28
:1040C0007A95E1F761E08091CB029091CC020E9459
:1040D0000D0860910501809104019E0128553E4F15
:1040D0000D0860910D01809104019E0128553E4F0D
:1040E0004091CA02460F589E400D11246150489ECF
:1040F000600D11248091CB029091CC020E94DF1BB5
:1041000034FA332430F88091130383111EC060E029
:104110008091CB029091CC020E940D086091050124
:10412000809104019E012A513E4F4091CA02460FE0
:104110008091CB029091CC020E940D0860910D011C
:10412000809104019E0127513E4F4091CA02460FE3
:10413000589E400D11246150489E600D11248091BD
:10414000CB029091CC020E94DF1B9FEF691A790A83
:10415000E8E06E16710409F09CCF5A94085F1F4F77
:10416000F7EF5F1291CF61E08091CB029091CC028A
:104170000E940D0880910801982F987819F461E049
:104180000E94AB1480910701982F987819F460E091
:104170000E940D0880911001982F987819F461E041
:104180000E94AB1480910F01982F987819F460E089
:104190000E94AB147090CE0224E0271510F464E066
:1041A000762E6BE371E08091CB029091CC020E945D
:1041B000B60861E08091CB029091CC020E940D087C
:1041C00028E0522E612C39E0432E48E7242E5DE290
:1041D000352E671409F45FC0C091CE02C719C60D11
:1041E000D0E04C9EF0014D9EF00D1124ED5BFC4F94
:1041F000E081EF70D9F1E13059F0F0E0E252FE4F8A
:1042000080818093DC039DED892E93E0992E04C07C
:104210008CED882E83E0982E4C9E80014D9E100DD3
:1041F000E081EF70D9F1E13059F0F0E0EF51FE4F7E
:1042000080818093EC039DEE892E93E0992E04C06B
:104210008CEE882E83E0982E4C9E80014D9E100DD2
:10422000112403531D4FF801E958FF4F6081C40169
:104230000E941C0CF801E758FF4F80818F708401A9
:104240000D5F1F4FF401811102C0328201C0228232
:104250004C9EF0014D9EF00D1124EB5BFC4F6081F4
:10426000C8010E941C0CF801329602C0ECEDF3E08C
:10426000C8010E941C0CF801329602C0ECEEF3E08B
:1042700010828091CB029091CC02FC0166AD63521A
:10428000B382A2822CED33E0452D0E94900A639404
:10428000B382A2822CEE33E0452D0E94900A639403
:10429000F8E05F0E9ECF8091C902823021F481E068
:1042A0009091080105C0833029F481E090910701C5
:1042A0009091100105C0833029F481E090910F01B5
:1042B0009F3F09F080E00E9498158091C9028530E7
:1042C00009F580911503E091CB02F091CC0288238F
:1042D00049F0813071F487AD869521E041E062E7D5
:1042E00072E00DC087AD869521E041E067E672E09F
:1042F00006C087AD869521E041E06DE772E082500F
:104300000E9404158091E503811104C00E94881B5E
:104310008093E5038EE194E00E946014811192CDB8
:104320008091E503811104C00E94881B8093E503FE
:104330008091E503853519F481E58093E50380914B
:10434000E503843519F482E58093E5038091E50364
:104350008093E403C091C902C23009F468C0A8F494
:104300000E9404158091F503811104C00E94881B4E
:104310008093F5038EE194E00E946014811192CDA8
:104320008091F503811104C00E94881B8093F503DE
:104330008091F503853519F481E58093F50380912B
:10434000F503843519F482E58093F5038091F50334
:104350008093F403C091C902C23009F468C0A8F484
:10436000CC23E1F0C13009F0FFC00E94121680E0BA
:104370000E94CA0EC09317030E941C1660E08FEFC4
:104380000E94E61580930801B3C0C43009F4D0C080
:104380000E94E61580931001B3C0C43009F4D0C078
:1043900008F487C0C53009F4E1C0E6C0813579F47E
:1043A0008091E303482F50E04F5F5F4F209106015B
:1043A0008091F303482F50E04F5F5F4F20910E0143
:1043B00030E0421753070CF0D7C08F5F08C082353A
:1043C00049F48091E303882309F4CEC0815080939F
:1043D000E303CAC0803509F0C7C0C091E303C1112F
:1043C00049F48091F303882309F4CEC0815080938F
:1043D000F303CAC0803509F0C7C0C091F303C1110F
:1043E00005C00E94A90C109212031BC0C13031F409
:1043F0000E94A90CC093120384E07EC0C23099F4DD
:104400008091CD02823068F00E94280C0E94280C16
:104410008091CD0282508093CD02811102C0109212
:10442000E30381E069C0C33009F09EC0FACF813553
:10442000F30381E069C0C33009F09EC0FACF813543
:1044300019F46091120306C0823559F48091120379
:1044400061E0681B809108010E94E61580930801D5
:104450008BC0803509F088C0D0910801DF3F19F486
:1044400061E0681B809110010E94E61580931001C5
:104450008BC0803509F088C0D0911001DF3F19F47E
:104460001092C90281C00E94121680E00E94CA0EFA
:1044700000911E0310911F038D2F0E94E20C829564
:104480008170F8018283D0931603C09317030E94B2
:104490001C1660E08FEF0E94E6158093070183E011
:104490001C1660E08FEF0E94E61580930F0183E009
:1044A0002BC0813519F4C091120306C08235A1F4E6
:1044B00080911203C1E0C81B6C2F809107010E94FC
:1044C000E615809307018F3F09F04EC06C2F0E94C4
:1044D000E6158093070148C0833589F40E941216BF
:1044B00080911203C1E0C81B6C2F80910F010E94F4
:1044C000E61580930F018F3F09F04EC06C2F0E94BC
:1044D000E61580930F0148C0833589F40E941216B7
:1044E00080E00E94CA0E81E0809317030E941C1690
:1044F0008FEF8093070182E08093C90235C0803539
:1045000099F560910701809108010E94EA16809157
:1044F0008FEF80930F0182E08093C90235C0803531
:1045000099F560910F01809110010E94EA16809147
:104510001403882311F085E001C084E08093C90270
:104520008FEF80930801809307010E9412161CC030
:104520008FEF8093100180930F010E9412161CC020
:1045300082E00E94CA0E0E947B0C0E941C16E09131
:104540001E03F0911F03648183810E94EA1680910B
:104550001403882309F465CF85E0CECF882321F0AA
:104560001092C9020E94A90C1092E50361E070E06C
:1045700080E090E00E94331A80E090E0892B09F4FB
:104560001092C9020E94A90C1092F50361E070E05C
:1045700080E090E00E94F81980E090E0892B09F437
:104580005DCC0E9400005ACC1092E4041092E30427
:1045900088EE93E0A0E0B0E08093E5049093E60419
:1045A000A093E704B093E8042DE132E03093E204F5
@ -1123,7 +1123,7 @@
:104620008FEF8093300480933504E9E3F4E09FEF4B
:1046300086E18E0F91938E13FDCF82E297E09093E7
:104640002304809322048CEA95E0909325048093C0
:10465000240488E499E1909327048093260482EF50
:1046500024048DE099E1909327048093260487EB4E
:104660009AE1909329048093280420E030E040E010
:1046700069E08EE194E00E94220710926304109298
:1046800062048CE495E09093500480934F048DE392
@ -1136,8 +1136,8 @@
:1046F0000590F491E02D099481E090E0F8940C94F9
:104700008823DC0101C06D9341505040E0F70895CB
:04471000F894FFCF4B
:10471400FFFFFFFF080104FFFF00E10000000000AD
:10472400001815A015C019FF1815A115C819FF18F0
:10471400FFFFFFFF0800E10000000000000104FFAC
:10472400FF1815A015C019FF1815A115C819FF18F1
:1047340015AE19FF1815AF19FF1815AE15D516804B
:1047440015A8163F15D316001540158D16141520FF
:10475400160015A115C815DA1612158116CF15D92C
@ -1149,13 +1149,13 @@
:1047B40010F0FF0F11EFF1000000183C3C183C0012
:1047C400001C3E7E6E0E1F1F001C2E3E3E1C087FEA
:1047D40000557F3E3E3E3E7F00553E3E1C3E1C7FC4
:1047E400081C497F7F3E1C7F87029802A902B302FE
:1047F4004E4252514B000000001818000000000007
:104804001C2C04040E0000001C1C1C0800000000EA
:10481400001C1C1C1C000000141C081C08000000C8
:1048240000083E1C080004080C000000008B1877E8
:1048340018950B691870186D186A1800000000C7E5
:10484400186D1A0219DD18E8182A19061900000053
:1047E400081C497F7F3E1C7F04080C87029802A99D
:1047F40002B3024E4252514B000000001818000050
:104804000000001C2C04040E0000001C1C1C0800EA
:10481400000000001C1C1C1C000000141C081C08C8
:1048240000000000083E1C08000000000050183C76
:1048340018950B2E18351832182F18000000008C0C
:1048440018321AC718A218AD18CB18E918000000BE
:1048540000980B6C0B950B940B0005A8044F707417
:10486400696F6E73004C6974746C6520526F6F6B62
:1048740020436865737300426C61636B2077696ED3

View File

@ -49,7 +49,7 @@
// Please update the pin numbers according to your setup. Use U8X8_PIN_NONE if the reset pin is not connected
//U8G2_NULL u8g2(U8G2_R0); // null device, a 8x8 pixel display which does nothing
//U8G2_SSD1306_128X64_NONAME_1_4W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition)
U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition)
//U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 10, /* dc=*/ 9, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_3W_SW_SPI u8g2(U8G2_R0, /* clock=*/ 13, /* data=*/ 11, /* cs=*/ 10, /* reset=*/ 8);
//U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

View File

@ -0,0 +1,148 @@
#
# Makefile.184 for Arduino/AVR
#
# Note:
# Display list make database: make -p -f/dev/null | less
# Install path of the arduino software. Requires a '/' at the end.
ARDUINO_PATH:=/home/kraus/prg/arduino-1.8.4/
# Board (and prozessor) information: see $(ARDUINO_PATH)hardware/arduino/avr/boards.txt
# Some examples:
# BOARD DESCRIPTION
# uno Arduino Uno
# atmega328 Arduino Duemilanove or Nano w/ ATmega328
# diecimila Arduino Diecimila, Duemilanove, or Nano w/ ATmega168
# mega Arduino Mega
# mega2560 Arduino Mega2560
# mini Arduino Mini
# lilypad328 LilyPad Arduino w/ ATmega328
# leonardo Leonardo, Arduboy, Feather AVR
BOARD:=leonardo
# The unix device where we can reach the arduino board
# Uno: /dev/ttyACM0
# Duemilanove: /dev/ttyUSB0
AVRDUDE_PORT:=/dev/ttyACM0
SRC_DIRS=$(ARDUINO_PATH)hardware/arduino/avr/cores/arduino/
SRC_DIRS+=$(ARDUINO_PATH)hardware/arduino/avr/libraries/SPI/src/
SRC_DIRS+=$(ARDUINO_PATH)hardware/arduino/avr/libraries/SPI/src/utility/
SRC_DIRS+=$(ARDUINO_PATH)hardware/arduino/avr/libraries/Wire/src/
SRC_DIRS+=$(ARDUINO_PATH)hardware/arduino/avr/libraries/Wire/src/utility/
SRC_DIRS+=../../../../csrc/
SRC_DIRS+=../../../../cppsrc/
#=== suffixes ===
.SUFFIXES: .elf .hex .ino
#=== identify user files ===
INOSRC:=$(shell ls *.ino)
TARGETNAME=$(basename $(INOSRC))
#=== internal names ===
LIBNAME:=$(TARGETNAME).a
ELFNAME:=$(TARGETNAME).elf
HEXNAME:=$(TARGETNAME).hex
BINNAME:=$(TARGETNAME).bin
DISNAME:=$(TARGETNAME).dis
MAPNAME:=$(TARGETNAME).map
#=== replace standard tools ===
CC:=$(ARDUINO_PATH)hardware/tools/avr/bin/avr-gcc
CXX:=$(ARDUINO_PATH)hardware/tools/avr/bin/avr-g++
AR:=$(ARDUINO_PATH)hardware/tools/avr/bin/avr-gcc-ar
OBJCOPY:=$(ARDUINO_PATH)hardware/tools/avr/bin/avr-objcopy
OBJDUMP:=$(ARDUINO_PATH)hardware/tools/avr/bin/avr-objdump
SIZE:=$(ARDUINO_PATH)hardware/tools/avr/bin/avr-size
AVRDUDE = $(ARDUINO_PATH)hardware/tools/avr/bin/avrdude
#=== get values from boards.txt ===
BOARDS_TXT:=$(ARDUINO_PATH)hardware/arduino/avr/boards.txt
# get the MCU value from the $(BOARD).build.mcu variable. For the atmega328 board this is atmega328p
MCU:=$(shell sed -n -e "s/$(BOARD).build.mcu=\(.*\)/\1/p" $(BOARDS_TXT))
# get the F_CPU value from the $(BOARD).build.f_cpu variable. For the atmega328 board this is 16000000
F_CPU:=$(shell sed -n -e "s/$(BOARD).build.f_cpu=\(.*\)/\1/p" $(BOARDS_TXT))
# get variant subfolder
VARIANT:=$(shell sed -n -e "s/$(BOARD).build.variant=\(.*\)/\1/p" $(BOARDS_TXT))
UPLOAD_SPEED:=$(shell sed -n -e "s/$(BOARD).upload.speed=\(.*\)/\1/p" $(BOARDS_TXT))
# get the AVRDUDE_PROGRAMMER value from the $(BOARD).upload.protocol variable. For the atmega328 board this is stk500
UPLOAD_PROTOCOL:=$(shell sed -n -e "s/$(BOARD).upload.protocol=\(.*\)/\1/p" $(BOARDS_TXT))
# use stk500v1, because stk500 will default to stk500v2
#UPLOAD_PROTOCOL:=stk500v1
AVRDUDE_FLAGS = -V -F
AVRDUDE_FLAGS += -C $(ARDUINO_PATH)/hardware/tools/avr/etc/avrdude.conf
AVRDUDE_FLAGS += -p $(MCU)
AVRDUDE_FLAGS += -P $(AVRDUDE_PORT)
AVRDUDE_FLAGS += -c $(UPLOAD_PROTOCOL)
AVRDUDE_FLAGS += -b $(UPLOAD_SPEED)
AVRDUDE_FLAGS += -U flash:w:$(HEXNAME)
#=== get all include dirs ===
INC_DIRS:=. $(SRC_DIRS) $(ARDUINO_PATH)hardware/arduino/avr/variants/$(VARIANT)
INC_OPTS:=$(addprefix -I,$(INC_DIRS))
#=== get all source files ===
CSRC:=$(shell ls $(addsuffix *.c,$(SRC_DIRS)) 2>/dev/null)
CPPSRC:=$(shell ls $(addsuffix *.cpp,$(SRC_DIRS)) 2>/dev/null)
#=== get all obj files ===
COBJ:=$(CSRC:.c=.o)
CPPOBJ:=$(CPPSRC:.cpp=.o)
OBJ:=$(COBJ) $(CPPOBJ) $(TARGETNAME).o
#=== options ===
COMMON_FLAGS = -g -Os -DF_CPU=$(F_CPU) -mmcu=$(MCU)
COMMON_FLAGS +=-DARDUINO=10800 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR
COMMON_FLAGS +=-DUSB_VID=0x2341 -DUSB_PID=0x8036
COMMON_FLAGS +=-ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects
COMMON_FLAGS +=$(INC_OPTS)
CFLAGS:=$(COMMON_FLAGS) -std=gnu99 -Wstrict-prototypes -Wall -Wextra
CXXFLAGS:=$(COMMON_FLAGS) -std=gnu++11 -fpermissive -fno-exceptions -fno-threadsafe-statics
LDFLAGS:=-g -Os -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=$(MCU)
LDLIBS:=-lm
all: $(HEXNAME) $(DISNAME)
$(SIZE) $(ELFNAME)
.PHONY: debug
debug:
@echo $(MCU) $(F_CPU) $(VARIANT) $(UPLOAD_SPEED) $(UPLOAD_PROTOCOL)
@echo $(SRC_DIRS)
@echo $(CSRC)
@echo $(CPPSRC)
@echo $(INC_OPTS)
.PHONY: clean
clean:
$(RM) $(OBJ) $(HEXNAME) $(ELFNAME) $(LIBNAME) $(DISNAME) $(MAPNAME) $(BINNAME)
.PHONY: upload
upload: $(HEXNAME)
stty -F $(AVRDUDE_PORT) 1200 raw ignbrk hup && sleep 3
$(AVRDUDE) $(AVRDUDE_FLAGS)
# implicit rules
.ino.cpp:
@cp $< $@
.elf.hex:
@$(OBJCOPY) -O ihex -R .eeprom $< $@
# explicit rules
$(ELFNAME): $(LIBNAME)($(OBJ))
$(LINK.o) $(LFLAGS) $(LIBNAME) $(LDLIBS) -o $@
$(DISNAME): $(ELFNAME)
$(OBJDUMP) -D -S $< > $@

View File

@ -0,0 +1,507 @@
/*
TicTacToe.ino
Tic Tac Toe (three in a row) game
Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
Copyright (c) 2018, olikraus@gmail.com
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or other
materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <Arduino.h>
#include <U8g2lib.h>
/*=== ARDUBOY Production, Kickstarter Edition ===*/
U8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2(U8G2_R0, /* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6); // Arduboy (Production, Kickstarter Edition)
void setup(void)
{
u8g2.begin(/*Select=*/ 7, /*Right/Next=*/ A1, /*Left/Prev=*/ A2, /*Up=*/ A0, /*Down=*/ A3, /*Home/Cancel=*/ 8); // Arduboy 10 (Production)
}
#define FLOW_CHART_DELAY 1500
u8g2_uint_t flow_chart_x_offset = 68;
u8g2_uint_t flow_chart_y_offset = 0;
void draw_text_box(u8g2_uint_t x, u8g2_uint_t y, const char *s, uint8_t bold)
{
x += flow_chart_x_offset;
y += flow_chart_y_offset;
u8g2.setFont(u8g2_font_5x7_mr);
u8g2.drawFrame(x, y, 58, 10);
if ( bold )
u8g2.drawFrame(x-1, y-1, 58+2, 10+2);
u8g2.drawStr(x+2, y+7, s);
}
void draw_box_vline(u8g2_uint_t x, u8g2_uint_t y0, u8g2_uint_t y1)
{
x += flow_chart_x_offset;
x += 58/2;
y0 += flow_chart_y_offset;
y1 += flow_chart_y_offset;
u8g2.drawVLine(x, y0, y1-y0+1);
}
void draw_flow_chart(uint8_t pos)
{
flow_chart_y_offset = 0;
if ( pos > 3 )
{
flow_chart_y_offset -= (pos-3)*20;
}
draw_text_box(0, 0, "init game", pos == 1);
draw_box_vline(0, 10, 20);
draw_text_box(0, 20, "show board", pos == 2);
draw_box_vline(0, 30, 40);
draw_text_box(0, 40, "player move", pos == 3);
draw_box_vline(0, 50, 60);
draw_text_box(0, 60, "show board", pos == 4);
draw_box_vline(0, 70, 80);
draw_text_box(0, 80, "check game", pos == 5);
draw_box_vline(0, 90, 100);
draw_text_box(0, 100, "ai move", pos == 6);
draw_box_vline(0, 110, 120);
draw_text_box(0, 120, "show board", pos == 7);
draw_box_vline(0, 130, 140);
draw_text_box(0, 140, "check game", pos == 8);
draw_box_vline(0, 150, 160);
draw_text_box(0, 160, "result", pos == 9);
}
void show_flow_chart(uint8_t pos)
{
u8g2.firstPage();
do
{
yield();
draw_flow_chart(pos);
} while ( u8g2.nextPage() );
delay(FLOW_CHART_DELAY);
}
/*==============================================*/
#define GRID_X_OFFSET 2
#define GRID_Y_OFFSET 2
#define CELL_WIDTH 17
#define CELL_HEIGHT 17
#define CELL_FRAME_WIDTH 3
uint8_t cursor_position; /* 0...8 */
u8g2_uint_t cell_x, cell_y;
/* calculate the cell position, return pixel position in global variables cell_x and cell_y */
void calc_cell_position(uint8_t x, uint8_t y )
{
cell_x = x;
cell_x*=CELL_WIDTH+CELL_FRAME_WIDTH;
cell_x+= GRID_X_OFFSET;
cell_y = y;
cell_y *=CELL_HEIGHT+CELL_FRAME_WIDTH;
cell_y +=GRID_Y_OFFSET;
}
void draw_grid(void)
{
u8g2_uint_t x, y;
x = GRID_X_OFFSET+CELL_WIDTH;
u8g2.drawVLine(x+1, GRID_Y_OFFSET, CELL_HEIGHT*3+CELL_FRAME_WIDTH*2);
x += CELL_WIDTH+CELL_FRAME_WIDTH;
u8g2.drawVLine(x+1, GRID_Y_OFFSET, CELL_HEIGHT*3+CELL_FRAME_WIDTH*2);
y = GRID_Y_OFFSET+CELL_HEIGHT;
u8g2.drawHLine(GRID_X_OFFSET, y+1, CELL_WIDTH*3+CELL_FRAME_WIDTH*2);
y += CELL_HEIGHT+CELL_FRAME_WIDTH;
u8g2.drawHLine(GRID_X_OFFSET, y+1, CELL_WIDTH*3+CELL_FRAME_WIDTH*2);
}
void draw_cursor(void)
{
u8g2_uint_t x, y;
x = cursor_position % 3;
y = cursor_position / 3;
calc_cell_position(x, y );
u8g2.drawFrame(cell_x, cell_y, CELL_WIDTH, CELL_HEIGHT);
u8g2.drawFrame(cell_x+1, cell_y+1, CELL_WIDTH-2, CELL_HEIGHT-2);
}
/*==============================================*/
#define FELD_NICHT_BELEGT 0
#define FELD_MARKIERT_DURCH_SPIELER 1
#define FELD_MARKIERT_DURCH_COMPUTER 2
int spielfeld[3][3];
int gewinner = FELD_NICHT_BELEGT;
/*==============================================*/
/* vorbelegung game_initalisierung */
void game_init(void)
{
int x, y;
show_flow_chart(1);
gewinner = FELD_NICHT_BELEGT;
for( y = 0; y < 3; y = y + 1 )
{
for( x = 0; x < 3; x = x + 1 )
{
spielfeld[y][x] = FELD_NICHT_BELEGT;
}
}
}
/*==============================================*/
/* "game engine" */
void draw_board(void)
{
int x, y;
for( y = 0; y < 3; y = y + 1 )
{
for( x = 0; x < 3; x = x + 1 )
{
if ( spielfeld[y][x] == FELD_NICHT_BELEGT )
{
/* nichts anzeigen */
}
if ( spielfeld[y][x] == FELD_MARKIERT_DURCH_SPIELER )
{
calc_cell_position(x, y);
u8g2.drawLine(cell_x, cell_y, cell_x+CELL_WIDTH-1, cell_y+CELL_HEIGHT-1);
u8g2.drawLine(cell_x+CELL_WIDTH-1, cell_y, cell_x, cell_y+CELL_HEIGHT-1);
}
if ( spielfeld[y][x] == FELD_MARKIERT_DURCH_COMPUTER )
{
calc_cell_position(x, y);
u8g2.drawCircle(cell_x+CELL_WIDTH/2, cell_y+CELL_HEIGHT/2, CELL_HEIGHT/2);
}
} /* for x */
} /* for y */
}
void draw_grid_board(void)
{
draw_grid();
draw_board();
}
void show_board(uint8_t flow_chart_pos)
{
u8g2.firstPage();
do
{
yield();
draw_flow_chart(flow_chart_pos);
draw_grid_board();
draw_cursor();
} while ( u8g2.nextPage() );
delay(FLOW_CHART_DELAY);
}
/*==============================================*/
/* Benitzerschnittstelle (User Interface) */
void zug_spieler(void)
{
static uint8_t keycode = 0;
int x;
int y;
int zaehler = 0;
for(;;) /* check valid entry */
{
for(;;) /* cursor movement loop */
{
keycode = 0;
u8g2.firstPage();
do
{
draw_flow_chart(3);
draw_grid_board();
draw_cursor();
if ( keycode == 0 )
keycode = u8g2.getMenuEvent();
} while ( u8g2.nextPage() );
while ( keycode == 0 )
{
yield();
keycode = u8g2.getMenuEvent();
}
if ( keycode == U8X8_MSG_GPIO_MENU_DOWN )
{
cursor_position += 3;
if ( cursor_position > 9 )
cursor_position -= 9;
}
if ( keycode == U8X8_MSG_GPIO_MENU_NEXT )
{
if ( cursor_position % 3 == 2 )
cursor_position-=2;
else
cursor_position += 1;
}
if ( keycode == U8X8_MSG_GPIO_MENU_UP )
{
cursor_position -= 3;
if ( cursor_position > 9 )
cursor_position += 9;
}
if ( keycode == U8X8_MSG_GPIO_MENU_PREV )
{
if ( cursor_position % 3 == 0 )
cursor_position+=2;
else
cursor_position -= 1;
}
cursor_position = cursor_position % 9;
if ( keycode == U8X8_MSG_GPIO_MENU_SELECT )
break;
if ( keycode == U8X8_MSG_GPIO_MENU_HOME )
break;
}
y = cursor_position / 3;
x = cursor_position % 3;
if ( spielfeld[y][x] == FELD_NICHT_BELEGT )
{
spielfeld[y][x] = FELD_MARKIERT_DURCH_SPIELER ;
return;
}
/*
if ( zaehler > 3 )
{
printf("Du doedl, jetzt langts aber...\n");
exit(1);
}
printf("Ahh, das feld ist schon belegt, nochmal...\n");
zaehler = zaehler + 1;
*/
}
}
/*==============================================*/
/* Künstliche Computer Intelligenz (AI NPC) */
void zug_computer(void)
{
int x, y;
/* AI: saudumme AI */
for( y = 0; y < 3; y = y + 1 )
{
for( x = 0; x < 3; x = x + 1 )
{
if ( spielfeld[y][x] == FELD_NICHT_BELEGT )
{
spielfeld[y][x] = FELD_MARKIERT_DURCH_COMPUTER;
return;
}
}
}
}
/*==============================================*/
/* Spiel Zuende Prüfung */
/* gibt 1 zurück, wenn in der zeile überall markierung gesetzt ist */
int zeile_gewonnen(int y, int markierung)
{
int x;
for( x = 0; x < 3; x++ )
{
if ( spielfeld[y][x] != markierung )
return 0;
}
return 1;
}
/* gibt 1 zurück, wenn in der zeile überall markierung gesetzt ist */
int spalte_gewonnen(int x, int markierung)
{
int y;
for( y = 0; y < 3; y++ )
{
if ( spielfeld[y][x] != markierung )
return 0;
}
return 1;
}
int diagonale_gewonnen(int markierung)
{
int i;
for( i = 0; i < 3; i ++ )
{
if ( spielfeld[i][i] != markierung )
return 0;
}
return 1;
}
int inverse_diagonale_gewonnen(int markierung)
{
int i;
for( i = 0; i < 3; i ++ )
{
if ( spielfeld[2-i][i] != markierung )
return 0;
}
return 1;
}
int ist_das_spiel_zuende(uint8_t flow_chart_pos)
{
int i, x, y;
int ist_alles_voll;
show_board(flow_chart_pos);
for( i = 0; i < 3; i ++ )
{
if ( zeile_gewonnen(i, FELD_MARKIERT_DURCH_SPIELER) )
gewinner = FELD_MARKIERT_DURCH_SPIELER;
if ( zeile_gewonnen(i, FELD_MARKIERT_DURCH_COMPUTER) )
gewinner = FELD_MARKIERT_DURCH_COMPUTER;
if ( spalte_gewonnen(i, FELD_MARKIERT_DURCH_SPIELER) )
gewinner = FELD_MARKIERT_DURCH_SPIELER;
if ( spalte_gewonnen(i, FELD_MARKIERT_DURCH_COMPUTER) )
gewinner = FELD_MARKIERT_DURCH_COMPUTER;
}
if ( diagonale_gewonnen(FELD_MARKIERT_DURCH_SPIELER) )
gewinner = FELD_MARKIERT_DURCH_SPIELER;
if ( diagonale_gewonnen(FELD_MARKIERT_DURCH_COMPUTER) )
gewinner = FELD_MARKIERT_DURCH_COMPUTER;
if ( inverse_diagonale_gewonnen(FELD_MARKIERT_DURCH_SPIELER) )
gewinner = FELD_MARKIERT_DURCH_SPIELER;
if ( inverse_diagonale_gewonnen(FELD_MARKIERT_DURCH_COMPUTER) )
gewinner = FELD_MARKIERT_DURCH_COMPUTER;
if ( gewinner != FELD_NICHT_BELEGT )
return 1;
ist_alles_voll = 1;
for( y = 0; y < 3; y = y + 1 )
{
for( x = 0; x < 3; x = x + 1 )
{
if ( spielfeld[y][x] == FELD_NICHT_BELEGT )
{
ist_alles_voll = 0;
}
}
}
if ( ist_alles_voll )
return 1;
return 0;
}
/*==============================================*/
void zeige_ergebnis_an(void)
{
u8g2.setFont(u8g2_font_helvB12_tr);
if ( gewinner == FELD_MARKIERT_DURCH_SPIELER )
u8g2.userInterfaceMessage("", "payer wins...", "", " ok ");
else if ( gewinner == FELD_MARKIERT_DURCH_COMPUTER )
u8g2.userInterfaceMessage("", "computer wins..", "", " ok ");
else
u8g2.userInterfaceMessage("", "game is a draw...", "", " ok ");
}
/*==============================================*/
/* HIER IST DIE HAUPTSCHLEIFE */
void game_play_loop(void)
{
game_init();
show_board(2);
for(;;)
{
zug_spieler();
show_board(4);
if ( ist_das_spiel_zuende(5) )
{
break;
} /* if */
show_board(6);
zug_computer();
show_board(7);
if ( ist_das_spiel_zuende(8) )
{
break;
} /* if */
} /* for */
show_board(9);
zeige_ergebnis_an();
} /* main */
void loop(void)
{
game_play_loop();
}