From ed6b23b0b3143a5ddfe9b21d97d7bb50a56959c8 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 3 Jun 2022 10:58:36 -0700 Subject: [PATCH 01/91] Improve directions on how to find dimensions, which are kinda important for images. --- scripts/User/ReadMe.md | 5 ++++- scripts/User/decode.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index f207bfe8f1d..15fd6b715d3 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -16,7 +16,10 @@ HOW TO USE ## Decode a .mb into .xbm: decode.py input_image output_image [width] [height] -Dimensions are not stored in .bm so you need to specify. +Dimensions are not stored in .bm so you need to specify +If you have the meta.txt available for the animation set the dimensions will be in here. +It may also be part of the directory name for the animation files as well. + If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. ## diff --git a/scripts/User/decode.py b/scripts/User/decode.py index dd557f0256b..21c4a353d5d 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -27,9 +27,9 @@ def padded_hex(i, l): parser.add_argument('outfile', metavar='o', help='File to write to') parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", - help='Width of the image') + help='Width of the image. Find from meta.txt or directory name') parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", - help='Height of the image') + help='Height of the image. Find from meta.txt or directory name') args = vars(parser.parse_args()) From f0310aa35650bcfdc51fa47d6cf929cbfe1fc04e Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 3 Jun 2022 11:08:50 -0700 Subject: [PATCH 02/91] encode will print out image dimensions --- scripts/User/ReadMe.md | 1 + scripts/User/encode.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 17553bcda12..7cf94ace204 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -26,6 +26,7 @@ If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE ## Encode an .xbm file into .xb encode.py input_image output_image +You will also get the image dimensions for use in meta.txt That's it. diff --git a/scripts/User/encode.py b/scripts/User/encode.py index 43d04063c31..d3b7a21e7cd 100644 --- a/scripts/User/encode.py +++ b/scripts/User/encode.py @@ -21,8 +21,11 @@ output = subprocess.check_output(["cat", args["infile"]]) f = io.StringIO(output.decode().strip()) +print("Image Dimensions:") width = int(f.readline().strip().split(" ")[2]) height = int(f.readline().strip().split(" ")[2]) +print("Height:", height) +print("Width: ", width) data = f.read().strip().replace("\n", "").replace(" ", "").split("=")[1][:-1] data_str = data[1:-1].replace(",", " ").replace("0x", "") From 11f41668b9708723cd90307245123fc6b9344b70 Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 3 Jun 2022 11:10:23 -0700 Subject: [PATCH 03/91] Update ReadMe.md --- scripts/User/ReadMe.md | 60 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 7cf94ace204..444a94435cc 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -1,33 +1,33 @@ -##################################### -encode.py -decode.py - -A set of python3 scripts for processing the Flipper image files. - -##################################### -PREREQUISITES - - -You'll need heatshrink installed - a small embedded/RTOS compression and decompression library -You can get that here https://github.com/atomicobject/heatshrink - -##################################### -HOW TO USE - -## -Decode a .mb into .xbm: -decode.py input_image output_image [width] [height] -Dimensions are not stored in .bm so you need to specify -If you have the meta.txt available for the animation set the dimensions will be in here. -It may also be part of the directory name for the animation files as well. - -If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. - -## -Encode an .xbm file into .xb -encode.py input_image output_image -You will also get the image dimensions for use in meta.txt -That's it. +##################################### +encode.py +decode.py + +A set of python3 scripts for processing the Flipper image files. + +##################################### +PREREQUISITES + + +You'll need heatshrink installed - a small embedded/RTOS compression and decompression library +You can get that here https://github.com/atomicobject/heatshrink + +##################################### +HOW TO USE + +## +Decode a .mb into .xbm: +decode.py input_image output_image [width] [height] +Dimensions are not stored in .bm so you need to specify +If you have the meta.txt available for the animation set the dimensions will be in here. +It may also be part of the directory name for the animation files as well. + +If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. + +## +Encode an .xbm file into .xb +encode.py input_image output_image +You will also get the image dimensions for use in meta.txt +That's it. From d2b01ddc5a4c4ac6788193fffdd109f035d92fe6 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 3 Jun 2022 11:20:49 -0700 Subject: [PATCH 04/91] QOL --- scripts/User/decode.py | 2 +- scripts/User/encode.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/User/decode.py b/scripts/User/decode.py index 21c4a353d5d..f3b83a12e99 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -49,7 +49,7 @@ def padded_hex(i, l): unpad=fileStream[4:] else: if(fileStream[0:1] == bytes([0x00])): - unpad=fileStream[2:] + unpad=fileStream[3:] diff --git a/scripts/User/encode.py b/scripts/User/encode.py index d3b7a21e7cd..c1fcc4b0f8b 100644 --- a/scripts/User/encode.py +++ b/scripts/User/encode.py @@ -23,9 +23,10 @@ f = io.StringIO(output.decode().strip()) print("Image Dimensions:") width = int(f.readline().strip().split(" ")[2]) +print("W: ", width) height = int(f.readline().strip().split(" ")[2]) -print("Height:", height) -print("Width: ", width) +print("H: ", height) + data = f.read().strip().replace("\n", "").replace(" ", "").split("=")[1][:-1] data_str = data[1:-1].replace(",", " ").replace("0x", "") From 5456f5cc5a72a7a7214b8f2fdaf75345950236b4 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 00:53:24 -0700 Subject: [PATCH 05/91] New: decoder for heatshrunk char array icons. You'll likely need to trim some bytes off the start. the format here is a bit different than elsewhere. --- scripts/User/decode.py | 2 ++ scripts/User/encode.py | 2 ++ scripts/User/icondecode.py | 66 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 scripts/User/icondecode.py diff --git a/scripts/User/decode.py b/scripts/User/decode.py index f3b83a12e99..01b405c0d95 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -70,3 +70,5 @@ def padded_hex(i, l): data=width_out+height_out+bytes_out w.write(data) +r.close() +w.close() \ No newline at end of file diff --git a/scripts/User/encode.py b/scripts/User/encode.py index c1fcc4b0f8b..d2d533ea3f7 100644 --- a/scripts/User/encode.py +++ b/scripts/User/encode.py @@ -45,3 +45,5 @@ else: data = b"\x00" + data_bin w.write(data) +r.close() +w.close() diff --git a/scripts/User/icondecode.py b/scripts/User/icondecode.py new file mode 100644 index 00000000000..ffc00eafdfd --- /dev/null +++ b/scripts/User/icondecode.py @@ -0,0 +1,66 @@ +import logging +import argparse +import subprocess +import io +import os +import sys + +def padded_hex(i, l): + given_int = i + given_len = l + + hex_result = hex(given_int)[2:] # remove '0x' from beginning of str + num_hex_chars = len(hex_result) + extra_zeros = '0' * (given_len - num_hex_chars) # may not get used.. + + return ('0x' + hex_result if num_hex_chars == given_len else + '?' * given_len if num_hex_chars > given_len else + '0x' + extra_zeros + hex_result if num_hex_chars < given_len else + None) + + +parser = argparse.ArgumentParser(description='Turn icon char arrays back into .xbm') + +parser.add_argument('infile', metavar='i', + help='Input file') +parser.add_argument('outfile', metavar='o', + help='File to write to') +parser.add_argument('Trim', metavar='T', type=int, nargs="?", default="0", + help='Number of bytes off the start/header to trim. Multiples of 2 required.') +parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", + help='Width of the image. Find from meta.txt or directory name') +parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", + help='Height of the image. Find from meta.txt or directory name') + +args = vars(parser.parse_args()) + +r = open(args["infile"],"r") +w = open(args["outfile"],"w") +imageWidth=args["Width"] +imageHeight=args["Height"] +trimStart=args["Trim"] + +output = subprocess.check_output(["cat", args["infile"]]) #yes this is terrible. +f = io.StringIO(output.decode().strip()) + +data = f.read().strip() +data_str = data[1:-1].replace(",", "").replace("0x", "") +data_bin = bytearray.fromhex(data_str[trimStart:]) + +data_decoded_str = subprocess.check_output( + ["heatshrink", "-d","-w8","-l4"], input=data_bin +) + +b=list(data_decoded_str) + +c=', '.join(padded_hex(my_int,2) for my_int in b) + +width_out = "#define icon_width "+ str(imageWidth) + "\n" +height_out = "#define icon_height "+ str(imageHeight) + "\n" +bytes_out = "static unsigned char icon_bits[] = {"+ str(c) + "};" + +data=width_out+height_out+bytes_out + +w.write(data) +r.close() +w.close() \ No newline at end of file From a172bef26539d503a79735761ffcc2bb783c7a19 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 01:08:57 -0700 Subject: [PATCH 06/91] help info --- scripts/User/ReadMe.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 444a94435cc..5be0e099622 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -1,7 +1,8 @@ ##################################### encode.py decode.py - +icondecode.py + A set of python3 scripts for processing the Flipper image files. ##################################### @@ -15,6 +16,8 @@ You can get that here https://github.com/atomicobject/heatshrink HOW TO USE ## +# decode. + Decode a .mb into .xbm: decode.py input_image output_image [width] [height] Dimensions are not stored in .bm so you need to specify @@ -24,10 +27,19 @@ It may also be part of the directory name for the animation files as well. If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. ## +# encode Encode an .xbm file into .xb encode.py input_image output_image You will also get the image dimensions for use in meta.txt That's it. +## +# icondecode +Decompress an icon asset (as found in assets_icons.c and elsewhere) +icondecodepy input_image output_image [trim] [width] [height] +The icons in this file have a different header format. This will need to be trimmed. +A value of 8 for trim appears to be correct. +As with regular decoding, the width and height are not listed - but can be found in code/const/variable/etc names. + From 831b5b05a630d13543eff9e38e6ccc0a2ea0ac85 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 01:11:48 -0700 Subject: [PATCH 07/91] re-arrange params --- scripts/User/icondecode.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/User/icondecode.py b/scripts/User/icondecode.py index ffc00eafdfd..85d2de1c7d2 100644 --- a/scripts/User/icondecode.py +++ b/scripts/User/icondecode.py @@ -25,13 +25,12 @@ def padded_hex(i, l): help='Input file') parser.add_argument('outfile', metavar='o', help='File to write to') -parser.add_argument('Trim', metavar='T', type=int, nargs="?", default="0", - help='Number of bytes off the start/header to trim. Multiples of 2 required.') parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", help='Width of the image. Find from meta.txt or directory name') parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", help='Height of the image. Find from meta.txt or directory name') - +parser.add_argument('Trim', metavar='T', type=int, nargs="?", default="8", + help='Number of bytes off the start/header to trim. Multiples of 2 required.') args = vars(parser.parse_args()) r = open(args["infile"],"r") @@ -62,5 +61,4 @@ def padded_hex(i, l): data=width_out+height_out+bytes_out w.write(data) -r.close() -w.close() \ No newline at end of file +w.close() From a09acc5a4566566a9b3e888a635888005cc546a8 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 01:18:01 -0700 Subject: [PATCH 08/91] QOL --- scripts/User/ReadMe.md | 6 ++++++ scripts/User/icondecode.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 5be0e099622..ff6f284f044 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -40,6 +40,12 @@ icondecodepy input_image output_image [trim] [width] [height] The icons in this file have a different header format. This will need to be trimmed. A value of 8 for trim appears to be correct. As with regular decoding, the width and height are not listed - but can be found in code/const/variable/etc names. +copy just the char array. The script does not care if the curly braces or semicolon are in place. +i.e. the following are all acceptable and equivalent. +{0x00,0x08,0x1C,0x3E,0x7F,}; +{0x00,0x08,0x1C,0x3E,0x7F,} +0x00,0x08,0x1C,0x3E,0x7F + diff --git a/scripts/User/icondecode.py b/scripts/User/icondecode.py index 85d2de1c7d2..241831510f2 100644 --- a/scripts/User/icondecode.py +++ b/scripts/User/icondecode.py @@ -42,8 +42,8 @@ def padded_hex(i, l): output = subprocess.check_output(["cat", args["infile"]]) #yes this is terrible. f = io.StringIO(output.decode().strip()) -data = f.read().strip() -data_str = data[1:-1].replace(",", "").replace("0x", "") +data = f.read().strip().replace(";","").replace("{","").replace("}","") +data_str = data.replace(",", "").replace("0x", "") data_bin = bytearray.fromhex(data_str[trimStart:]) data_decoded_str = subprocess.check_output( From 6bdf24d06c5ab51f1188639c1448bde53ba1ef7e Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 4 Jun 2022 01:34:45 -0700 Subject: [PATCH 09/91] Update ReadMe.md --- scripts/User/ReadMe.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index ff6f284f044..d4d2d60beac 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -41,10 +41,10 @@ The icons in this file have a different header format. This will need to be trim A value of 8 for trim appears to be correct. As with regular decoding, the width and height are not listed - but can be found in code/const/variable/etc names. copy just the char array. The script does not care if the curly braces or semicolon are in place. -i.e. the following are all acceptable and equivalent. -{0x00,0x08,0x1C,0x3E,0x7F,}; -{0x00,0x08,0x1C,0x3E,0x7F,} -0x00,0x08,0x1C,0x3E,0x7F +i.e. the following are all acceptable and equivalent. +{0x00,0x08,0x1C,0x3E,0x7F,}; +{0x00,0x08,0x1C,0x3E,0x7F,} +0x00,0x08,0x1C,0x3E,0x7F From d3eb86de2777d8596c267bcc54c79276f290794b Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 02:55:07 -0700 Subject: [PATCH 10/91] icon encoder added --- scripts/User/iconencode.py | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 scripts/User/iconencode.py diff --git a/scripts/User/iconencode.py b/scripts/User/iconencode.py new file mode 100644 index 00000000000..fd35502b6f2 --- /dev/null +++ b/scripts/User/iconencode.py @@ -0,0 +1,61 @@ +import logging +import argparse +import subprocess +import io +import os +import sys + +def padded_hex(i, l): + given_int = i + given_len = l + + hex_result = hex(given_int)[2:] # remove '0x' from beginning of str + num_hex_chars = len(hex_result) + extra_zeros = '0' * (given_len - num_hex_chars) # may not get used.. + + return ('0x' + hex_result if num_hex_chars == given_len else + '?' * given_len if num_hex_chars > given_len else + '0x' + extra_zeros + hex_result if num_hex_chars < given_len else + None) + + +parser = argparse.ArgumentParser(description='Turn icon char arrays back into .xbm') + +parser.add_argument('infile', metavar='i', + help='Input file') +parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", + help='Width of the image. Find from meta.txt or directory name') +parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", + help='Height of the image. Find from meta.txt or directory name') +args = vars(parser.parse_args()) + +r = open(args["infile"],"r") +infile=args["infile"].split(".")[0] + +imageWidth=args["Width"] +imageHeight=args["Height"] +dims=str(imageWidth)+"x"+str(imageHeight) + +output = subprocess.check_output(["cat", args["infile"]]) #yes this is terrible. +f = io.StringIO(output.decode().strip()) + +data = f.read().strip().replace(";","").replace("{","").replace("}","") +data_str = data.replace(",", "").replace("0x", "") +data_bin = bytearray.fromhex(data_str) + +data_encoded_str = subprocess.check_output( + ["heatshrink", "-e","-w8","-l4"], input=data_bin +) + +b=list(data_encoded_str) + +c=','.join(padded_hex(my_int,2) for my_int in b) + +# a bit ugly. +char_out = "const uint8_t _I_"+infile+"_"+dims+"_0[] = {"+ str(c) + ",};" +char_out2 = "const uint8_t* const _I_" +infile+"{_I_"+infile+"};" +#data=bytes_out +print(char_out) +print(char_out2) +#w.write(data) +#w.close() From b7af240d3f1edd0bbb0d45cdbda8857db0c93089 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 03:08:46 -0700 Subject: [PATCH 11/91] s --- scripts/User/ReadMe.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index d4d2d60beac..db0a43323eb 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -1,7 +1,8 @@ ##################################### encode.py decode.py -icondecode.py +iconencode.py +icondecode.py A set of python3 scripts for processing the Flipper image files. @@ -33,6 +34,11 @@ encode.py input_image output_image You will also get the image dimensions for use in meta.txt That's it. +## +# iconencode +Compress an icon asset from an XBM to a compressed char array ready to paste +Will assume dimensions of 128x64 + ## # icondecode Decompress an icon asset (as found in assets_icons.c and elsewhere) From 40cc775edc6467455402566fd8dc1c5d1749aac1 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 03:09:16 -0700 Subject: [PATCH 12/91] cleanup --- scripts/User/iconencode.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/User/iconencode.py b/scripts/User/iconencode.py index fd35502b6f2..409327c2058 100644 --- a/scripts/User/iconencode.py +++ b/scripts/User/iconencode.py @@ -52,8 +52,12 @@ def padded_hex(i, l): c=','.join(padded_hex(my_int,2) for my_int in b) # a bit ugly. -char_out = "const uint8_t _I_"+infile+"_"+dims+"_0[] = {"+ str(c) + ",};" -char_out2 = "const uint8_t* const _I_" +infile+"{_I_"+infile+"};" + +framename="_I_"+infile+"_"+dims + + +char_out = "const uint8_t "+framename+"_0[] = {"+ str(c) + ",};" +char_out2 = "const uint8_t "+framename+"[] = {"+framename+"_0};" #data=bytes_out print(char_out) print(char_out2) From cb27c8c6067117a4c9cafa9c601bedcea3a5f740 Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 4 Jun 2022 03:11:39 -0700 Subject: [PATCH 13/91] Update ReadMe.md --- scripts/User/ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index db0a43323eb..c8b3acab4af 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -5,7 +5,7 @@ iconencode.py icondecode.py A set of python3 scripts for processing the Flipper image files. - +These work as-is but I am rolling in improvements. ##################################### PREREQUISITES From ea0bca17b01cb52cf2f6d6095b23835f38973010 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sun, 5 Jun 2022 11:32:48 -0700 Subject: [PATCH 14/91] Update ReadMe.md --- scripts/User/ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index c8b3acab4af..5ed42cff705 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -5,7 +5,7 @@ iconencode.py icondecode.py A set of python3 scripts for processing the Flipper image files. -These work as-is but I am rolling in improvements. +These work as-is but I am rolling in improvements. ##################################### PREREQUISITES From cc717906cf1fdeca87354aa0226f724c84a9f60a Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sun, 5 Jun 2022 11:45:40 -0700 Subject: [PATCH 15/91] Update ReadMe.md --- scripts/User/ReadMe.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 5ed42cff705..84711196111 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -36,8 +36,9 @@ That's it. ## # iconencode -Compress an icon asset from an XBM to a compressed char array ready to paste -Will assume dimensions of 128x64 +Compress an icon asset from an XBM to a compressed char array ready to paste +Will assume dimensions of 128x64 +There is a small header on these I haven't determined the format of, so this won't work as is yet. ## # icondecode From 78f8f27ef380216b7e54483cda1a946bbd0e80fb Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Mon, 6 Jun 2022 13:47:57 -0700 Subject: [PATCH 16/91] I can't count --- scripts/User/decode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/User/decode.py b/scripts/User/decode.py index 01b405c0d95..f6779d967f3 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -49,7 +49,7 @@ def padded_hex(i, l): unpad=fileStream[4:] else: if(fileStream[0:1] == bytes([0x00])): - unpad=fileStream[3:] + unpad=fileStream[2:] From 5adddb8cfdaa3be86f39407ebfcceb0fa43ce0a3 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Wed, 8 Jun 2022 22:21:49 -0700 Subject: [PATCH 17/91] box tutorial --- applications/applications.c | 9 +++ applications/applications.mk | 7 ++ applications/box_mover/box_mover.c | 106 +++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 applications/box_mover/box_mover.c diff --git a/applications/applications.c b/applications/applications.c index 31416b5a56f..99f6ac725a4 100644 --- a/applications/applications.c +++ b/applications/applications.c @@ -50,6 +50,7 @@ extern int32_t music_player_app(void* p); extern int32_t snake_game_app(void* p); extern int32_t tetris_game_app(void *p); extern int32_t clock_app(void *p); +extern int32_t box_mover_app(void* p); // extern int32_t floopper_bloopper(void* p); // extern int32_t raycast_game_app(void* p); extern int32_t spectrum_analyzer_app(void* p); @@ -346,6 +347,14 @@ const FlipperApplication FLIPPER_GAMES[] = { .flags = FlipperApplicationFlagDefault}, #endif +#ifdef APP_BOX_MOVER + {.app = box_mover_app, + .name = "Box Mover", + .stack_size = 1024, + .icon = &A_Plugins_14, + .flags =FlipperApplicationFlagDefault}, +#endif + #ifdef APP_ZOMBIEZ {.app = zombiez_app, .name = "Zombiez", diff --git a/applications/applications.mk b/applications/applications.mk index a122c859ca3..789bc2abf48 100644 --- a/applications/applications.mk +++ b/applications/applications.mk @@ -48,6 +48,7 @@ APP_UPDATER = 1 APP_MUSIC_PLAYER = 1 APP_SNAKE_GAME = 1 APP_TETRIS_GAME = 1 +APP_BOX_MOVER = 1 # APP_RAYCAST_GAME = 1 APP_CLOCK = 1 APP_SPECTRUM_ANALYZER = 1 @@ -275,6 +276,12 @@ CFLAGS += -DAPP_SNAKE_GAME SRV_GUI = 1 endif +APP_BOX_MOVER ?= 0 +ifeq ($(APP_BOX_MOVER),1) +CFLAGS += -DAPP_BOX_MOVER +SRV_GUI = 1 +endif + APP_SPECTRUM_ANALYZER ?= 0 ifeq ($(APP_SPECTRUM_ANALYZER), 1) CFLAGS += -DAPP_SPECTRUM_ANALYZER diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c new file mode 100644 index 00000000000..0739cd1ffc5 --- /dev/null +++ b/applications/box_mover/box_mover.c @@ -0,0 +1,106 @@ +#include +#include +#include + +typedef struct { + int x; + int y; +} BoxMoverModel; + +typedef struct { + BoxMoverModel* model; + osMutexId_t* model_mutex; + + osMessageQueueId_t event_queue; + + ViewPort* view_port; + Gui* gui; +} BoxMover; + +BoxMover* box_mover_alloc(){ + BoxMover* instance = malloc(sizeof(BoxMover)); + instance->model = malloc(sizeof(BoxMoverModel)); + instance->model->x = 10; + instance->model->y = 10; + + instance->view_port = view_port_alloc(); + view_port_draw_callback_set(instance->view_port, draw_callback, instance); + + view_port_input_callback_set(instance->view_port, input_callback, instance); + instance->model_mutex = osMutexNew(NULL); + + instance->gui = furi_record_open("gui"); + gui_add_view_port(instance->view_port, GuiLayerFullscreen); + + instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); + + return instance; +} + +void box_mover_free(BoxMover* instance){ + view_port_enabled_set(instance->view_port,false); + gui_remove_view_port(instance->gui, view_port); + furi_record_close("gui"); + osMessageQueueDelete(instance->event_queue); + osMutexDelete(instance->model_mutex); + view_port_free(instance->view_port); + free(instance->model); + free(instance); +} + +int32_t box_mover_app(void* p){ + UNUSED(p); + BoxMover* box_mover = box_mver_alloc(); + + box_mover_free(box_mover) + + for(bool processing = true; processing;){ + osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); + furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); + if(status==osOK){ + if(event.type==InputTypePress){ + switch(event.key){ + case InputKeyUp: + box_mover->model->y-=2; + break; + case InputKeyDown: + box_mover->model->y+=2; + break; + case InputKeyLeft: + box_mover->model->x-=2; + break; + case InputKeyRight: + box_mover->model->x+=2; + break; + case InputKeyOk: + case InputKeyBack: + processing = false; + break; + } + } + } + osMutexRElease(box_mover->model_mutex); + view_port_update(box_mover->view_port); + } + + + box_mover_free(box_mover) + return 0; +} + +void draw_callback(Canvas* cancas, void* ctx){ + BoxMover *box_mover = ctx; + furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); + + canvas_draw_box(canvas, box_mover->x,box_mover->y, 4, 4); + + osReleaseMutex(box_mover->model_mutex); +} + +void input_callback(InputEvent* input, osMessageQueueId_t event_queue){ + BoxMover* box_mover = ctx; + osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); + +} + + From 0c6fcbbafb350a1cedea6bccc981f4d1b01eeef7 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Thu, 9 Jun 2022 00:59:20 -0700 Subject: [PATCH 18/91] Box Mover but added stuff --- applications/box_mover/box_mover.c | 104 +++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 27 deletions(-) diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c index 0739cd1ffc5..fc3366d5951 100644 --- a/applications/box_mover/box_mover.c +++ b/applications/box_mover/box_mover.c @@ -1,10 +1,15 @@ #include #include +#include #include +#include +#include typedef struct { int x; int y; + int sizex; + int sizey; } BoxMoverModel; typedef struct { @@ -17,43 +22,66 @@ typedef struct { Gui* gui; } BoxMover; + + +void draw_callback(Canvas* canvas, void* ctx){ + BoxMover* box_mover = ctx; + furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); + + canvas_draw_box(canvas, box_mover->model->x,box_mover->model->y, box_mover->model->sizex, box_mover->model->sizey); + + osMutexRelease(box_mover->model_mutex); +} + +void input_callback(InputEvent* input, void* ctx){ + BoxMover* box_mover = ctx; + osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); + +} + BoxMover* box_mover_alloc(){ BoxMover* instance = malloc(sizeof(BoxMover)); instance->model = malloc(sizeof(BoxMoverModel)); instance->model->x = 10; instance->model->y = 10; + instance->model->sizex = 4; + instance->model->sizey = 4; +instance->model_mutex = osMutexNew(NULL); + instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); instance->view_port = view_port_alloc(); view_port_draw_callback_set(instance->view_port, draw_callback, instance); view_port_input_callback_set(instance->view_port, input_callback, instance); - instance->model_mutex = osMutexNew(NULL); + instance->gui = furi_record_open("gui"); - gui_add_view_port(instance->view_port, GuiLayerFullscreen); + gui_add_view_port(instance->gui, instance->view_port, GuiLayerFullscreen); + - instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); return instance; } void box_mover_free(BoxMover* instance){ view_port_enabled_set(instance->view_port,false); - gui_remove_view_port(instance->gui, view_port); + gui_remove_view_port(instance->gui, instance->view_port); furi_record_close("gui"); + view_port_free(instance->view_port); osMessageQueueDelete(instance->event_queue); osMutexDelete(instance->model_mutex); - view_port_free(instance->view_port); + free(instance->model); free(instance); } + int32_t box_mover_app(void* p){ UNUSED(p); - BoxMover* box_mover = box_mver_alloc(); + BoxMover* box_mover = box_mover_alloc(); - box_mover_free(box_mover) + InputEvent event; for(bool processing = true; processing;){ osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); @@ -61,46 +89,68 @@ int32_t box_mover_app(void* p){ if(event.type==InputTypePress){ switch(event.key){ case InputKeyUp: - box_mover->model->y-=2; + if (box_mover->model->y >= 1) + box_mover->model->y-=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } break; case InputKeyDown: - box_mover->model->y+=2; - break; + if (box_mover->model->y <= (64-(box_mover->model->sizey+1))) + box_mover->model->y+=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } + break; case InputKeyLeft: - box_mover->model->x-=2; + if (box_mover->model->x >= 1) + box_mover->model->x-=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } break; case InputKeyRight: - box_mover->model->x+=2; + if (box_mover->model->x <= (128-(box_mover->model->sizex+1))) + box_mover->model->x+=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } break; case InputKeyOk: + if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ + box_mover->model->sizex+=1; + box_mover->model->sizey+=1; + } + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } + + break; case InputKeyBack: processing = false; break; } } } - osMutexRElease(box_mover->model_mutex); + osMutexRelease(box_mover->model_mutex); view_port_update(box_mover->view_port); } - box_mover_free(box_mover) + box_mover_free(box_mover); return 0; } -void draw_callback(Canvas* cancas, void* ctx){ - BoxMover *box_mover = ctx; - furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); - canvas_draw_box(canvas, box_mover->x,box_mover->y, 4, 4); - - osReleaseMutex(box_mover->model_mutex); -} - -void input_callback(InputEvent* input, osMessageQueueId_t event_queue){ - BoxMover* box_mover = ctx; - osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); - -} From 63f9b7e0a7dc054ab5dac2aac854b5933af3bb9b Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Thu, 9 Jun 2022 01:37:03 -0700 Subject: [PATCH 19/91] Improved bounds checks --- applications/box_mover/box_mover.c | 48 ++++++++++++++++-------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c index fc3366d5951..f70ba0f5571 100644 --- a/applications/box_mover/box_mover.c +++ b/applications/box_mover/box_mover.c @@ -22,7 +22,11 @@ typedef struct { Gui* gui; } BoxMover; - +void shake(void){ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } void draw_callback(Canvas* canvas, void* ctx){ BoxMover* box_mover = ctx; @@ -92,48 +96,47 @@ int32_t box_mover_app(void* p){ if (box_mover->model->y >= 1) box_mover->model->y-=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyDown: - if (box_mover->model->y <= (64-(box_mover->model->sizey+1))) + if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))) // So we're trying to see if it's even or odd, to determine how much to offset the bounds check by, since we're doing this based of the square origin+its size. idk. box_mover->model->y+=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyLeft: if (box_mover->model->x >= 1) box_mover->model->x-=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyRight: - if (box_mover->model->x <= (128-(box_mover->model->sizex+1))) + if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))) box_mover->model->x+=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyOk: if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ - box_mover->model->sizex+=1; - box_mover->model->sizey+=1; + if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ + if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ + box_mover->model->sizex+=1; + box_mover->model->sizey+=1; + //TODO - also check the box will not grow past boundary. + } + else + shake(); + } + else + shake(); } - else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); - } + else + shake(); + break; case InputKeyBack: @@ -147,6 +150,7 @@ int32_t box_mover_app(void* p){ } + box_mover_free(box_mover); return 0; } From 3a6430da1233034a495f247fcfa0d2565583da4d Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Thu, 9 Jun 2022 10:14:33 -0700 Subject: [PATCH 20/91] Video Poker game --- applications/VideoPoker/poker.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 applications/VideoPoker/poker.c diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c new file mode 100644 index 00000000000..8888349d372 --- /dev/null +++ b/applications/VideoPoker/poker.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include +#include +#include + +// deck array +// hand array +// scoring system + +// card faces +// splash screen/music +// win/lose music + +// bet amount +// bet multi From c6b91e9e0985362388d35d1a10afd7801a657047 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 10 Jun 2022 00:42:23 -0700 Subject: [PATCH 21/91] Box Mover Splash Screen! --- applications/VideoPoker/poker.c | 1 + applications/box_mover/box_mover.c | 149 +++++++++++++++++++---------- 2 files changed, 98 insertions(+), 52 deletions(-) diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c index 8888349d372..47fc9aff3c6 100644 --- a/applications/VideoPoker/poker.c +++ b/applications/VideoPoker/poker.c @@ -4,6 +4,7 @@ #include #include #include +#include "furi_hal_random.h" // deck array // hand array diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c index f70ba0f5571..eee577d77f1 100644 --- a/applications/box_mover/box_mover.c +++ b/applications/box_mover/box_mover.c @@ -4,12 +4,32 @@ #include #include #include +#include +#include "assets_icons.h" +#include + + +/* 0x01,0x00,0xa4,0x01 +typedef struct { + uint8_t is_compressed; + uint8_t reserved; + uint16_t compressed_buff_size; +} FuriHalCompressHeader; +*/ + +const uint8_t _I_BoxMover_128x64_0[] = {0x01,0x00,0xa4,0x01,0x00,0x78,0x03,0xc0,0x1e,0x00,0xab,0x00,0x3f,0xbf,0x90,0x30,0x29,0xfc,0x23,0xfe,0x0c,0x1e,0x0c,0x12,0x99,0xf8,0x78,0x3d,0x27,0xff,0x8c,0x78,0x3d,0x3c,0x10,0x3b,0xf0,0x3d,0x2f,0xe0,0xf1,0xe3,0x83,0xcf,0xf0,0x0a,0x18,0x08,0x3c,0xef,0x13,0xc8,0xf7,0x1c,0x10,0x71,0xf0,0x88,0xc1,0xc1,0xed,0xef,0x07,0x97,0x00,0x18,0x33,0xe9,0xf0,0x3e,0xbf,0x10,0x10,0x88,0x8c,0x84,0x1e,0xbf,0xe0,0x39,0x06,0xc4,0x7c,0x3f,0x01,0x81,0x13,0xc4,0x1e,0x98,0x03,0x60,0x84,0x46,0xf8,0x43,0x13,0xf9,0x03,0xd0,0x38,0x21,0x12,0x87,0x8c,0x08,0xfe,0x20,0xf4,0xbe,0x04,0x49,0x02,0x20,0x11,0x17,0xbc,0x78,0x22,0x41,0xd1,0xc0,0x10,0x04,0x9e,0xd7,0xe1,0x71,0x0f,0x47,0xc0,0x0f,0x5f,0x70,0x3c,0x7c,0xde,0x38,0x1a,0x04,0xaf,0x90,0x63,0xfb,0xe1,0xbf,0xe2,0xe2,0x10,0x88,0x3d,0x7c,0xe0,0xf1,0x83,0x0f,0x84,0xde,0x24,0xe1,0x07,0xaa,0xfc,0xa0,0xdf,0xce,0x08,0xb8,0x44,0x22,0x0f,0x4c,0xf3,0x7c,0xa0,0xdc,0xcf,0xb8,0x50,0x67,0xe0,0xf3,0x77,0xac,0x1a,0x18,0xfd,0x12,0x81,0x03,0xca,0x7e,0x0f,0x1c,0x18,0x3c,0xff,0x8f,0xf3,0x07,0x94,0x7f,0xc1,0x83,0x07,0xa7,0x62,0x0e,0xee,0x20,0x78,0x80,0x18,0x1e,0x31,0x8c,0xfa,0x44,0x41,0xf9,0xfc,0x17,0x08,0x3f,0x2c,0x00,0x63,0x07,0xf8,0x3f,0xff,0xdf,0xf0,0x02,0x43,0xc1,0xff,0x06,0x8e,0x03,0xfb,0xf0,0x0f,0xef,0x04,0x7c,0x1e,0x90,0xe8,0x74,0x7d,0xbc,0x3c,0x08,0x08,0x3c,0x70,0x10,0xf0,0x7b,0x43,0xe3,0x80,0xf2,0x87,0x1a,0x06,0x18,0x0f,0x68,0x3c,0x60,0x1e,0xb0,0x00,0x7a,0xc1,0xb8,0xe0,0xf1,0xfc,0x4c,0x41,0xf3,0x04,0xe3,0xce,0x3c,0x40,0xff,0x07,0xd6,0x3a,0x28,0x0f,0x31,0xfc,0x83,0xd3,0x81,0x81,0x37,0x88,0x3d,0xe2,0x00,0xf3,0x3f,0x90,0x3f,0x07,0xf4,0x0f,0x32,0x7d,0x83,0xc6,0xf1,0xf2,0x07,0xf8,0x3e,0xe3,0x20,0xf1,0xf8,0x03,0xf2,0x0e,0x0f,0x1c,0x00,0x3c,0x61,0xc0,0xf5,0x83,0x83,0xc6,0x1f,0x7c,0x07,0x9d,0xf0,0x1e,0x9e,0x08,0x18,0x3c,0x63,0xf7,0xe0,0x79,0xfc,0x20,0x20,0xf3,0xfc,0x40,0x3f,0xdf,0xf0,0x02,0x43,0xf8,0x10,0xf0,0x79,0xcf,0xc1,0xf1,0x00,0x9f,0x03,0xcb,0x81,0x07,0x07,0xcb,0x4c,0x41,0xe2,0x2e,0x10,0x7c,0x86,0xc4,0x1e,0x22,0x31,0x07,0xcc,0x02,0x3f,0x60,0x21,0x90,0x02,0xbf,0x16,0x03,0x19,0x00,0x2b,0xc1,0x63,0x41,0x90,0x02,0xc6,0x86,0x00,0xbf,0xe4,0x0c,0x1f,0xab,0xf3,0x00,0x78,0x03,0xc0,0x1f,0x00,}; +const uint8_t* _I_BoxMover_128x64[] = {_I_BoxMover_128x64_0}; +const Icon I_BoxMover_128x64 = {.width=128,.height=64,.frame_count=1,.frame_rate=0,.frames=_I_BoxMover_128x64}; +int moves; //Count moves. Text testing. +//const uint8_t _I_Splash_128x64_0[] = { +int splash; //Have we seen the title typedef struct { int x; int y; int sizex; int sizey; + } BoxMoverModel; typedef struct { @@ -29,18 +49,30 @@ void shake(void){ } void draw_callback(Canvas* canvas, void* ctx){ + BoxMover* box_mover = ctx; furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); - + if(splash==0) + { + //canvas_draw_icon(canvas, 22, 20, &I_UsbTree_48x22); //testing :) + canvas_draw_icon(canvas, 0, 0, &I_BoxMover_128x64); + osMutexRelease(box_mover->model_mutex); // lol + } + else{ + canvas_clear(canvas); canvas_draw_box(canvas, box_mover->model->x,box_mover->model->y, box_mover->model->sizex, box_mover->model->sizey); - + char buffer[13]; + snprintf(buffer, sizeof(buffer), "Moves: %u", moves); + canvas_set_color(canvas, ColorBlack); + canvas_set_font(canvas, FontPrimary); + canvas_draw_str_aligned(canvas, 5, 5, AlignLeft, AlignTop, buffer); osMutexRelease(box_mover->model_mutex); + } } void input_callback(InputEvent* input, void* ctx){ BoxMover* box_mover = ctx; osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); - } BoxMover* box_mover_alloc(){ @@ -50,6 +82,8 @@ BoxMover* box_mover_alloc(){ instance->model->y = 10; instance->model->sizex = 4; instance->model->sizey = 4; + moves=0; + splash=0; instance->model_mutex = osMutexNew(NULL); instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); @@ -90,60 +124,71 @@ int32_t box_mover_app(void* p){ osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); if(status==osOK){ - if(event.type==InputTypePress){ - switch(event.key){ - case InputKeyUp: - if (box_mover->model->y >= 1) - box_mover->model->y-=2; - else{ - shake(); - } - break; - case InputKeyDown: - if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))) // So we're trying to see if it's even or odd, to determine how much to offset the bounds check by, since we're doing this based of the square origin+its size. idk. - box_mover->model->y+=2; - else{ - shake(); - } - break; - case InputKeyLeft: - if (box_mover->model->x >= 1) - box_mover->model->x-=2; - else{ - shake(); - } - break; - case InputKeyRight: - if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))) - box_mover->model->x+=2; - else{ - shake(); - } - break; - case InputKeyOk: - if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ - if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ - if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ - box_mover->model->sizex+=1; - box_mover->model->sizey+=1; - //TODO - also check the box will not grow past boundary. + if(event.type==InputTypePress){ + if(splash==0){splash=1;} + switch(event.key){ + case InputKeyUp: + if (box_mover->model->y >= 1){ + box_mover->model->y-=2; + moves++; + } + else{ + shake(); + } + break; + case InputKeyDown: + if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ // So we're trying to see if it's even or odd, to determine how much to offset the bounds check by, since we're doing this based of the square origin+its size. idk. + box_mover->model->y+=2; + moves++; + } + else{ + shake(); + } + break; + case InputKeyLeft: + if (box_mover->model->x >= 1){ + box_mover->model->x-=2; + moves++; + } + else{ + shake(); + } + break; + case InputKeyRight: + if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ + box_mover->model->x+=2; + moves++; + } + else{ + shake(); + } + break; + case InputKeyOk: + if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ + if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ + if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ + box_mover->model->sizex+=1; + box_mover->model->sizey+=1; + //TODO - also check the box will not grow past boundary. + } + else + shake(); } else + shake(); + } + else shake(); - } - else - shake(); - } - else - shake(); - + + + break; + case InputKeyBack: + processing = false; + break; - break; - case InputKeyBack: - processing = false; - break; + } } - } + } osMutexRelease(box_mover->model_mutex); view_port_update(box_mover->view_port); From 50b591d827bdb3ea399d3626b4b22b66518a77fe Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 10 Jun 2022 01:02:10 -0700 Subject: [PATCH 22/91] Update README.md --- README.md | 63 ++++++------------------------------------------------- 1 file changed, 6 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index 5e13c42847c..a303301a469 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,8 @@ -# [Flipper Zero Firmware](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/ReadMe.md) <= READ THIS READ ME -- ****This software is for experimental purposes only and is not meant for any illegal activity/purposes. We do not condone illegal activity and strongly encourage keeping transmissions to legal/valid uses allowed by law.** -- FLASH STOCK FIRST BEFORE UPDATING TO CUSTOM FIRMWARE -- BUILD WITH COMPACT FLAG SINCE IT IS TOO LARGE -- CH0NG, CH33CH and N00BY rename your flipper. +########## +Do not use this. +Go for an upstream project. +This is a personal sandbox/learning/testing build. -# Clone the Repository +Anything I think is worthwhile will become PR -You should clone with -```shell -$ git clone --recursive https://github.com/RogueMaster/flipperzero-firmware-wPlugins.git -$ docker-compose up -d -$ docker-compose exec dev make DEBUG=0 COMPACT=1 -``` - -Latest Updates: -- Latest DEV changes -- RF Remix updates -- Updates to assets for NFC and SubGHz - -**Special Instructions:** -- Download these files into the subghz/assets folder on your SD card. Edit the two `_map` files to contain your specific subghz (.SUB) files. -- - Note 1: If you don't have a subghz/assets folder, you should ensure you have made at least one clean flash with stock firmware and your SD card installed in order to ensure the database structure is built, otherwise it will not exist for alternative forks. -- - Note 2: /any is a special keyword signifying either /int (internal storage) or /ext (external storage). -- - Note 3: the changes you are making to the `_map` files is to point to the location of the specific assets of the touchtunes folder as well as the universal RF map apps which you will have to develop or compile seperately and are not a part of this repo. -- - Note 4: /any is effectively root, so the folder structure should start "/any/subghz/assets" and not what is based on the repo below do not blindly copy the repo it will not work. -- - [assets/resources/subghz/assets/universal_rf_map](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/subghz/assets/universal_rf_map) -- - [assets/resources/subghz/assets/touchtunes_map](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/subghz/assets/touchtunes_map) -- - [assets/resources/subghz/assets/setting_user](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/subghz/assets/setting_user) -- Download this file into the nfc/assets folder on your SD card. -- - [assets/resources/nfc/assets/mf_classic_dict.nfc](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/nfc/assets/mf_classic_dict.nfc) -- Add a folder to SD card named `wav_player` (for 8bit 2ch unsigned wav files) -- Add a folder to SD card named `music_player` (FMF and RTTTL/TXT files) - -Special shout out to these libraries for giving us more fun: -- https://github.com/Gioman101/FlipperAmiibo -- https://github.com/jimilinuxguy/flipperzero-touchtunes -- https://github.com/Lucaslhm/AmiiboFlipperConverter -- https://github.com/MuddledBox/FlipperZeroCases -- https://github.com/MuddledBox/FlipperZeroSub-GHz -- https://github.com/neverfa11ing/FlipperMusicRTTTL -- https://github.com/UberGuidoZ/Flipper -- https://github.com/UberGuidoZ/Flipper-IRDB - -Plugins: -- [Clock/Stopwatch (By CompaqDisc, Stopwatch & Sound Alert By RogueMaster)](https://gist.github.com/CompaqDisc/4e329c501bd03c1e801849b81f48ea61) -- [Dice Roller Including SEX/WAR/8BALL/WEED DICE (By RogueMaster)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/applications/dice/dice.c) -- [Flappy Bird (By DroomOne)](https://github.com/DroomOne/flipperzero-firmware/tree/dev/applications/flappy_bird) -- [HID Analyzer (By Ownasaurus)](https://github.com/Ownasaurus/flipperzero-firmware/tree/hid-analyzer/applications/hid_analyzer) -- [Menu Changes and Icons (By Redlink)](https://github.com/redlink2/flipperzero-firmware/tree/menuChanges) -- [Mouse Jiggler (By Jacob-Tate)](https://github.com/Jacob-Tate/flipperzero-firmware/blob/dev/applications/mouse_jiggler/mouse_jiggler.c) -- [RF Remix (By ESurge)(Original By jimilinuxguy)](https://github.com/ESurge/flipperzero-firmware-unirfremix) -- [Spectrum Analyzer (By jolcese)](https://github.com/jolcese/flipperzero-firmware/tree/spectrum/applications/spectrum_analyzer) -- [Tetris (By jeffplang)](https://github.com/jeffplang/flipperzero-firmware/tree/tetris_game/applications/tetris_game) -- [Touch Tunes Remote (By jimilinuxguy)](https://github.com/jimilinuxguy/flipperzero-universal-rf-remote/tree/028d615c83f059bb2c905530ddb3d4efbd3cbcae/applications/jukebox) -- [WAV Player (By Zlo)](https://github.com/flipperdevices/flipperzero-firmware/tree/zlo/wav-player) With Fix From Atmanos -- [Zombiez (By Dooskington)](https://github.com/Dooskington/flipperzero-zombiez) - -Thank you, [MuddleBox](https://github.com/MuddledBox/flipperzero-firmware), [Eng1n33r](https://github.com/Eng1n33r/flipperzero-firmware) & of course, most of all [Flipper Devices](https://github.com/flipperdevices/flipperzero-firmware)! +This will likley break or components will exist in a messy state. From e9ae9306d456e2097de187ca7e4826851f5046f5 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 10 Jun 2022 01:03:09 -0700 Subject: [PATCH 23/91] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a303301a469..0e15396b518 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -########## -Do not use this. +## +**Do not use this.** Go for an upstream project. This is a personal sandbox/learning/testing build. - +## Anything I think is worthwhile will become PR This will likley break or components will exist in a messy state. From 815d687929c549704cbf2c85f0070e5aaaaafea2 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 10 Jun 2022 01:04:56 -0700 Subject: [PATCH 24/91] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e15396b518..ec0eaf3e905 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,6 @@ Go for an upstream project. This is a personal sandbox/learning/testing build. ## -Anything I think is worthwhile will become PR +Anything I think is worthwhile will become PR once polished up. This will likley break or components will exist in a messy state. From 69bf5d0b705ec7cbcc5244d2f487b97c521eb9b4 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Mon, 13 Jun 2022 02:11:29 -0700 Subject: [PATCH 25/91] INITIAL Video Poker - it works! It's messy! --- applications/VideoPoker/poker.c | 976 +++++++++++++++++++++++++++++++- applications/applications.c | 15 +- applications/applications.mk | 9 +- scripts/User/iconencode.py | 5 +- 4 files changed, 991 insertions(+), 14 deletions(-) diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c index 47fc9aff3c6..61da1f22d1e 100644 --- a/applications/VideoPoker/poker.c +++ b/applications/VideoPoker/poker.c @@ -4,15 +4,973 @@ #include #include #include -#include "furi_hal_random.h" +#include +#include "assets_icons.h" +#include -// deck array -// hand array -// scoring system +/* KNOWN BUGS +This has been converted from a standalone PC console app to flipper +All of the original input/output handing code has been ripped out +Original code also used TONS of defines and everything was a global. +I have not completed cleaning up and moving globals to members. -// card faces -// splash screen/music -// win/lose music +It's not super well written but I think it at least meets a minimum expectation of quality +A lot of it could be cleaned up or optimized. +As is, it does what it wanted and doesn't seem to have major issues, so that's pretty good. +Game logic is handled during input and this is a bit of a mess of nested ifs. +Sometimes duplicate cards will show up. there is a function to test this. I should use it better. -// bet amount -// bet multi +*/ + +#define TAG "Video Poker" + +void Poker_Shaker(void) { + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); +} + +typedef struct { + int index; /* cards value, minus 1 */ + char* sym; /* text appearance */ + int suit; /* card's suit (see just below) */ + int gone; /* true if it's been dealt */ + int held; /* for hand */ +} card; + +typedef struct { + osMutexId_t* model_mutex; + osMessageQueueId_t event_queue; + ViewPort* view_port; + Gui* gui; + card hand[5]; + card shand[5]; + int held[5]; + int score; + int pot; + int GameState; + int selected; +} PokerPlayer; +/* GameState +0=Splash/help, OK button (later on up/down for rules or settings) +1=cards down, betting enabled, left/right to change bet, OK to confirm +2=first hand, holding enabled, left/right to pick card, OK to hold/unhold card, down to confirm +3=second hand, only confirm to claim rewards +4=game over/won +*/ + +card deck[52] = { + /* index, card name, suit, gone */ + /* Clubs:0 Diamonds:1 Hearts: 2 Spades: 3 */ + {1, "2", 0, 0}, {2, "3", 0, 0}, {3, "4", 0, 0}, {4, "5", 0, 0}, {5, "6", 0, 0}, + {6, "7", 0, 0}, {7, "8", 0, 0}, {8, "9", 0, 0}, {9, "10", 0, 0}, {10, "J", 0, 0}, + {11, "Q", 0, 0}, {12, "K", 0, 0}, {13, "A", 0, 0}, + + {1, "2", 1, 0}, {2, "3", 1, 0}, {3, "4", 1, 0}, {4, "5", 1, 0}, {5, "6", 1, 0}, + {6, "7", 1, 0}, {7, "8", 1, 0}, {8, "9", 1, 0}, {9, "10", 1, 0}, {10, "J", 1, 0}, + {11, "Q", 1, 0}, {12, "K", 1, 0}, {13, "A", 1, 0}, + + {1, "2", 2, 0}, {2, "3", 2, 0}, {3, "4", 2, 0}, {4, "5", 2, 0}, {5, "6", 2, 0}, + {6, "7", 2, 0}, {7, "8", 2, 0}, {8, "9", 2, 0}, {9, "10", 2, 0}, {10, "J", 2, 0}, + {11, "Q", 2, 0}, {12, "K", 2, 0}, {13, "A", 2, 0}, + + {1, "2", 3, 0}, {2, "3", 3, 0}, {3, "4", 3, 0}, {4, "5", 3, 0}, {5, "6", 3, 0}, + {6, "7", 3, 0}, {7, "8", 3, 0}, {8, "9", 3, 0}, {9, "10", 3, 0}, {10, "J", 3, 0}, + {11, "Q", 3, 0}, {12, "K", 3, 0}, {13, "A", 3, 0}, +}; +/* +Calculated Header: 0x01,0x00,0xa4,0x01 +0x01 = Compressed +0x00 = Reserved Section +0xa4,0x01 = 0x1a4, or, 420 - the size of the compressed array, minus this header. +Rest of the data is char array output from heatshrink of the original XBM char array. + +from furi_hal_compress.c +typedef struct { + uint8_t is_compressed; + uint8_t reserved; + uint16_t compressed_buff_size; +} FuriHalCompressHeader; +*/ + +const uint8_t _I_Splash_128x64_0[] = {0x01,0x00,0x8a,0x02,0x00,0x78,0x02,0x60,0xe0,0x54,0xc0,0x03,0x9f,0xc0,0x0f,0x5a,0x04,0x04,0x1e,0xdf,0x08,0x78,0x0c,0x60,0xc0,0x21,0x90,0x40,0xa3,0x00,0xf5,0xfe,0x61,0xc1,0xe9,0x1e,0x8e,0x59,0xf0,0x02,0x24,0x9f,0x70,0xc0,0x63,0x03,0x01,0x0c,0x0b,0xc1,0x80,0xbc,0x83,0xd3,0x3f,0x63,0x98,0x03,0xcf,0x88,0x02,0x1c,0x31,0x5d,0x38,0xf6,0x19,0xc0,0xa0,0xfc,0x93,0x13,0x12,0xf0,0x38,0x76,0x08,0xc7,0x00,0x1e,0x5e,0x8b,0xcc,0x32,0x86,0x0f,0x4f,0x0c,0x80,0x06,0x20,0x72,0xe4,0x5e,0x33,0xd4,0x73,0xf2,0x5d,0xe2,0x10,0xef,0xe6,0x02,0x0f,0x07,0x84,0x4c,0x33,0xd2,0x70,0x79,0xd8,0x2e,0x11,0x88,0x3d,0xff,0xc1,0xc7,0x83,0xc4,0x20,0x10,0xc9,0x18,0x3d,0x27,0x18,0x8c,0x3c,0xde,0xe1,0xe6,0x87,0x7e,0x0c,0x62,0x12,0x10,0x01,0xce,0x31,0x9c,0x39,0x9c,0x62,0x67,0x0f,0x83,0x7f,0x27,0xe0,0xf5,0x8c,0x71,0xbc,0x31,0x8c,0xc4,0xe2,0x1e,0x62,0x1e,0x02,0xe0,0x80,0x05,0x1c,0xe1,0xdc,0x23,0x97,0xc8,0xe4,0x5c,0x12,0x50,0x40,0x7a,0x43,0x38,0x77,0x88,0xf4,0x36,0x3d,0x1f,0x04,0x94,0x20,0x1e,0x98,0xce,0x0d,0xbe,0x37,0x0d,0xcd,0xbd,0x0c,0x7e,0xbe,0xce,0x07,0x1f,0xf3,0xfc,0xf8,0xb2,0x8d,0x30,0x20,0x53,0xbe,0x60,0x06,0x03,0x78,0xf0,0x06,0x4c,0x1e,0x34,0x10,0x29,0x5e,0x05,0x0f,0x00,0xa0,0x40,0x24,0x20,0x52,0x76,0x88,0x01,0xc1,0xe3,0x11,0x05,0xc3,0xe9,0x20,0x10,0x97,0x01,0xcf,0xc1,0xf2,0x81,0x3f,0xe7,0xfc,0x66,0xf4,0x02,0xf1,0xc0,0x3f,0xdf,0xf0,0x30,0xc6,0x1e,0xe5,0xff,0x81,0xf0,0x3f,0xe5,0xb2,0x80,0x7f,0xc1,0xe5,0x1c,0x03,0x0f,0xe3,0xff,0x1f,0xf8,0x02,0x48,0x00,0x31,0xfe,0x0b,0xa4,0x61,0xcc,0x62,0xfc,0x4f,0xe3,0x0f,0x31,0x41,0x0e,0x02,0x07,0x01,0x07,0x8a,0xb4,0xa3,0x84,0x71,0x8f,0xff,0x20,0x77,0x00,0x78,0x95,0x46,0x06,0x13,0x10,0x78,0xef,0x3f,0x5f,0xfc,0xff,0xea,0x07,0xf0,0x37,0x90,0x3c,0x78,0x00,0xf2,0xae,0x7f,0x77,0xf7,0xaf,0xec,0x0f,0x88,0x41,0x1b,0x06,0x02,0x03,0xc0,0x02,0x8c,0x08,0x5c,0x37,0xff,0xa9,0x3c,0x7b,0xcc,0x52,0xe0,0x70,0x7c,0x31,0x89,0xe4,0xff,0xfb,0xff,0xdf,0x8c,0x46,0x03,0x1f,0x34,0x17,0x83,0xe1,0x71,0x8f,0x6f,0xe7,0xe0,0xc1,0x8f,0xfd,0x20,0x18,0x65,0x59,0x47,0xaf,0x9b,0x8b,0x9e,0x6f,0xe7,0x1f,0x16,0x0c,0x3e,0x3d,0x00,0xe4,0x43,0xd1,0xe5,0x3f,0xe6,0x6e,0xfb,0x39,0x88,0x67,0xea,0xff,0xc5,0x22,0x8f,0xc0,0xf0,0x41,0x71,0xe7,0x76,0xf9,0x98,0x48,0x64,0x17,0x59,0x38,0x05,0x8f,0xc0,0xd0,0x5f,0xe8,0x0f,0x1a,0xdb,0xe6,0xb1,0xd1,0xa0,0x50,0x85,0x59,0x7e,0x16,0x05,0x06,0x80,0x71,0xbf,0xf7,0x19,0x85,0x99,0x74,0x6d,0x31,0x02,0x10,0x88,0x7c,0xdd,0xdb,0x84,0x62,0x7c,0x0f,0x38,0xe5,0xf0,0x1e,0x97,0xce,0x67,0xbc,0xb6,0x40,0xa3,0x98,0x00,0xc5,0x76,0x53,0x8c,0x67,0x1e,0x07,0x0e,0x63,0x0a,0xe4,0x9c,0x62,0x0f,0x11,0x41,0x95,0x88,0x1e,0x41,0xd1,0x8c,0x49,0x80,0xe6,0x00,0x50,0xb8,0xa3,0x07,0xf1,0x7f,0x06,0xb8,0x00,0x61,0xce,0xb2,0x9c,0x53,0x01,0xf3,0xf0,0x55,0x97,0xd0,0x3f,0x40,0x03,0xfd,0x33,0xc8,0x01,0x71,0x92,0x78,0x80,0x2f,0x80,0x6f,0x20,0x03,0xff,0x23,0xe7,0x02,0x02,0x18,0x01,0xa3,0x91,0x00,0x18,0xc3,0x20,0x91,0xc0,0x7c,0x7f,0x83,0x42,0xaa,0x1f,0xe0,0xbe,0x60,0x46,0xa2,0x81,0xe2,0x24,0x21,0xf9,0x54,0x14,0x18,0x9e,0x3f,0xe4,0x29,0x00,0x12,0x0e,0xb0,0x28,0x50,0x3c,0x60,0x50,0x85,0xf4,0x7f,0xb8,0x3f,0xf3,0xf8,0x83,0xe0,0x00,0x38,0x6e,0x0c,0xc3,0xf2,0x2f,0x94,0x09,0x07,0xc7,0xf7,0x3f,0xfe,0x0d,0xc4,0x00,0xfc,0x4c,0x05,0x86,0x15,0x23,0x92,0x03,0xe7,0xf9,0x80,0x0f,0x97,0x52,0x0c,0x2f,0xb1,0xf8,0xe3,0x01,0xf3,0x82,0x27,0x8d,0xe6,0x41,0x1c,0x17,0xcf,0xfc,0x3e,0x64,0xf8,}; +const uint8_t* _I_Splash_128x64[] = {_I_Splash_128x64_0}; +const Icon I_Splash_128x64 = + {.width = 128, .height = 64, .frame_count = 1, .frame_rate = 0, .frames = _I_Splash_128x64}; + +const uint8_t _I_BadEnd_128x64_0[] = { + 0x01, 0x00, 0xDF, 0x01, 0x00, 0x2c, 0x12, 0x01, 0x02, 0x80, 0x40, 0x70, 0x10, 0x0a, 0x04, 0x02, + 0x41, 0x3e, 0xcf, 0x63, 0xfb, 0xfe, 0xc8, 0x18, 0x3e, 0x6f, 0xdb, 0xfc, 0xf8, 0x3c, 0x60, 0xe0, + 0xf9, 0xb3, 0x6c, 0xf3, 0x3c, 0x1b, 0x6c, 0x18, 0x5f, 0x40, 0xf1, 0xe7, 0xdb, 0xc1, 0xf4, 0x2f, + 0x10, 0x78, 0xdb, 0xbc, 0xdf, 0xf0, 0x04, 0x59, 0x81, 0xe3, 0xc1, 0xb6, 0x41, 0x83, 0xd1, 0x00, + 0xbf, 0x6c, 0xc9, 0xe6, 0x0f, 0x91, 0xf8, 0x9b, 0xcc, 0x1f, 0x20, 0x06, 0x07, 0xf8, 0x3e, 0x0b, + 0x32, 0x00, 0x50, 0x88, 0xc4, 0x20, 0x10, 0x85, 0xfd, 0x03, 0xfc, 0x1f, 0xe0, 0xff, 0x07, 0xf9, + 0x7f, 0xc3, 0xdc, 0x89, 0x10, 0x7d, 0x00, 0x04, 0x1f, 0xe0, 0xfd, 0xfc, 0x40, 0xc1, 0xfb, 0x07, + 0x8e, 0x2f, 0xf3, 0x9f, 0x00, 0xb0, 0x7f, 0x97, 0xf6, 0x0a, 0x11, 0x10, 0xa3, 0xec, 0x10, 0x21, + 0x32, 0x07, 0xd0, 0x18, 0x40, 0xa2, 0x0f, 0xb0, 0x20, 0x81, 0xc4, 0x1f, 0xeb, 0xfa, 0xbf, 0x84, + 0x86, 0x01, 0xc8, 0x5f, 0xd0, 0x0c, 0x81, 0xe2, 0x05, 0x10, 0x7e, 0xdc, 0xc1, 0xf5, 0x01, 0xe0, + 0x41, 0xf2, 0x17, 0xf0, 0x7d, 0xaf, 0x0a, 0x7e, 0x0f, 0xbf, 0x84, 0x7f, 0x21, 0x1f, 0x2b, 0x8e, + 0x3c, 0xbe, 0xd3, 0xf0, 0x78, 0xc4, 0xfa, 0x0b, 0xf2, 0x00, 0x08, 0x81, 0xa1, 0xf3, 0x08, 0x9f, + 0xc0, 0x1e, 0x57, 0x00, 0x7b, 0x60, 0x60, 0x3e, 0x08, 0x4f, 0x80, 0x1e, 0x59, 0x05, 0xc1, 0x03, + 0xce, 0xc3, 0x00, 0x2f, 0x88, 0x3c, 0xe2, 0x10, 0x20, 0x78, 0xbd, 0xc6, 0xff, 0x7c, 0x8c, 0x0e, + 0x48, 0x1e, 0x90, 0x48, 0x47, 0xe2, 0x06, 0x1b, 0x1e, 0x3c, 0x1c, 0x1e, 0x80, 0x01, 0x93, 0xad, + 0x06, 0x1e, 0x0a, 0x28, 0x04, 0x18, 0x1e, 0x81, 0xe1, 0x90, 0x20, 0x46, 0x49, 0xa9, 0x91, 0x3e, + 0x46, 0xf8, 0x0f, 0xac, 0x48, 0x3c, 0xb0, 0x82, 0x52, 0x07, 0xa1, 0x08, 0x43, 0xe5, 0x72, 0x93, + 0x41, 0x7e, 0x01, 0x01, 0x07, 0xc7, 0x8a, 0x97, 0xa9, 0x39, 0x88, 0xa0, 0x7f, 0x00, 0xf2, 0x08, + 0x0c, 0x03, 0x25, 0x54, 0x88, 0xe9, 0x66, 0x11, 0xc2, 0x99, 0x9e, 0x07, 0xff, 0x13, 0x90, 0x7f, + 0xb2, 0x60, 0xf2, 0xaa, 0x79, 0x1b, 0xe5, 0x01, 0xfe, 0x1f, 0xca, 0x41, 0x08, 0xb0, 0xd4, 0xe2, + 0x33, 0x9c, 0x9f, 0x13, 0xff, 0x07, 0xc0, 0x0c, 0x04, 0x1e, 0x54, 0x08, 0x40, 0x64, 0x80, 0x03, + 0x84, 0xff, 0xc0, 0x68, 0x10, 0x0f, 0x80, 0x3d, 0x13, 0xc2, 0x00, 0x28, 0x25, 0xfa, 0x00, 0x0f, + 0x76, 0x60, 0x83, 0xcc, 0x04, 0x20, 0xc1, 0x07, 0xaf, 0xc8, 0x52, 0x52, 0x00, 0x7a, 0x2f, 0xcc, + 0x16, 0x31, 0x30, 0x49, 0x48, 0x17, 0xe5, 0x20, 0xc0, 0x23, 0xce, 0x81, 0x80, 0x88, 0xe6, 0x24, + 0x7c, 0x69, 0xc0, 0xd0, 0xa2, 0x1c, 0x00, 0x79, 0x85, 0x07, 0xe3, 0xa4, 0xb0, 0x4a, 0x64, 0xa0, + 0xf3, 0x57, 0x9d, 0x82, 0x01, 0x80, 0x84, 0x54, 0xb2, 0x19, 0x48, 0x91, 0x90, 0xa2, 0x1f, 0x00, + 0x79, 0x0f, 0x87, 0x80, 0x0f, 0x44, 0x21, 0x03, 0xd0, 0x3e, 0x26, 0x01, 0xa6, 0x44, 0x2c, 0x79, + 0xc0, 0x79, 0xb3, 0xc4, 0xbe, 0x5e, 0x01, 0x08, 0x80, 0x09, 0x56, 0x20, 0x01, 0x98, 0x03, 0xc4, + 0xfe, 0x51, 0x0b, 0xf8, 0x3c, 0xf8, 0x00, 0x32, 0x9c, 0x7f, 0x01, 0xe8, 0x1f, 0x40, 0x21, 0xd7, + 0x81, 0xfb, 0x80, 0xcf, 0x8f, 0x44, 0x1e, 0x7c, 0x88, 0x38, 0x28, 0x70, 0xe4, 0x92, 0xff, 0xc7, + 0xef, 0x1f, 0x80, +}; +const uint8_t* _I_BadEnd_128x64[] = {_I_BadEnd_128x64_0}; +const Icon I_BadEnd_128x64 = + {.width = 128, .height = 64, .frame_count = 1, .frame_rate = 0, .frames = _I_BadEnd_128x64}; + +const uint8_t _I_Hand_12x10_0[] = { + 0x01, 0x00, 0x11, 0x00, 0x8c, 0x40, 0x25, 0x00, 0x16, 0xb4, 0x40, + 0x35, 0x10, 0x1d, 0x5c, 0x1b, 0x5b, 0x0a, 0x84, 0xc2, 0x80, +}; +const uint8_t* _I_Hand_12x10[] = {_I_Hand_12x10_0}; +const Icon I_Hand_12x10 = + {.width = 12, .height = 10, .frame_count = 1, .frame_rate = 0, .frames = _I_Hand_12x10}; + +const uint8_t _I_CardBack_22x35_0[] = { + 0x01, 0x00, 0x23, 0x00, 0xfe, 0x7f, 0xe1, 0xf0, 0x28, 0x04, 0x43, 0xe3, 0xff, + 0x91, 0xea, 0x75, 0x52, 0x6a, 0xad, 0x56, 0x5b, 0xad, 0xd5, 0x4a, 0x80, 0xbe, + 0x05, 0xf0, 0x2f, 0x81, 0x7c, 0x0b, 0x45, 0x32, 0x2c, 0x91, 0x7c, 0x8c, 0xa4, +}; +const uint8_t* _I_CardBack_22x35[] = {_I_CardBack_22x35_0}; +const Icon I_CardBack_22x35 = + {.width = 22, .height = 35, .frame_count = 1, .frame_rate = 0, .frames = _I_CardBack_22x35}; + +//uncompressed but lol +const uint8_t _I_club_7x8_0[] = {0x00, 0x08, 0x1c, 0x1c, 0x6b, 0x7f, 0x36, 0x08, 0x1c}; +const uint8_t* _I_club_7x8[] = {_I_club_7x8_0}; +const Icon I_club_7x8 = + {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_club_7x8}; + +//uncompressed but lol +const uint8_t _I_diamond_7x8_0[] = {0x00, 0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08}; +const uint8_t* _I_diamond_7x8[] = {_I_diamond_7x8_0}; +const Icon I_diamond_7x8 = + {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_diamond_7x8}; + +//uncompressed +const uint8_t _I_hearts_7x8_0[] = {0x00, 0x00, 0x36, 0x7f, 0x7f, 0x7f, 0x3e, 0x1c, 0x08}; +const uint8_t* _I_hearts_7x8[] = {_I_hearts_7x8_0}; +const Icon I_hearts_7x8 = + {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_hearts_7x8}; + +//uncompressed +const uint8_t _I_spade_7x8_0[] = {0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x7f, 0x36, 0x08, 0x1c}; +const uint8_t* _I_spade_7x8[] = {_I_spade_7x8_0}; +const Icon I_spade_7x8 = + {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_spade_7x8}; + +const uint8_t _I_King_7x8_0[] = { + 0x01, 0x00, 0x1a, 0x00, 0xc1, 0xc0, 0xf8, 0x70, 0x1f, 0x1c, 0x02, 0xe7, 0x00, 0x9d, 0xc0, + 0x23, 0xf0, 0x08, 0x78, 0x0c, 0x80, 0xe2, 0x0b, 0x10, 0x78, 0x84, 0xc4, 0x2e, 0x20, 0x01, +}; +const uint8_t* _I_King_7x8[] = {_I_King_7x8_0}; +const Icon I_King_7x8 = + {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_King_7x8}; + +const uint8_t _I_Queen_7x8_0[] = { + 0x01, 0x00, 0x13, 0x00, 0xfe, 0x40, 0x3f, 0xd0, 0x1c, 0x3c, 0x0c, 0x01, + 0x76, 0x38, 0x1f, 0x8e, 0x07, 0xc7, 0x81, 0x85, 0x47, 0xf9, 0x01, +}; +const uint8_t* _I_Queen_7x8[] = {_I_Queen_7x8_0}; +const Icon I_Queen_7x8 = + {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Queen_7x8}; + +const uint8_t _I_Jack_7x8_0[] = { + 0x01, + 0x00, + 0x0D, + 0x00, + 0x80, + 0x40, + 0xc0, + 0x3a, + 0x00, + 0x5c, + 0x3c, + 0x0f, + 0xfd, + 0x01, + 0xfe, + 0x40, + 0x00, +}; +const uint8_t* _I_Jack_7x8[] = {_I_Jack_7x8_0}; +const Icon I_Jack_7x8 = + {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Jack_7x8}; + +const uint8_t _I_Ace_7x8_0[] = { + 0x01, 0x00, 0x13, 0x00, 0x98, 0x40, 0x2f, 0x00, 0x12, 0xe6, 0x00, 0x4b, + 0x0d, 0x01, 0x00, 0x8c, 0x0e, 0x07, 0xff, 0x00, 0x90, 0x01, 0xc0, +}; +const uint8_t* _I_Ace_7x8[] = {_I_Ace_7x8_0}; +const Icon I_Ace_7x8 = + {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Ace_7x8}; + +const uint8_t _I_Ten_7x8_0[] = { + 0x01, 0x00, 0x29, 0x00, 0x86, 0x7f, 0x00, 0x43, 0xfe, 0x80, 0xc3, 0xf0, 0xf0, 0x38, 0x7e, + 0x0e, 0x07, 0x0c, 0xe1, 0x80, 0x87, 0xc6, 0x02, 0x1b, 0x98, 0x08, 0x67, 0x60, 0x21, 0x8f, + 0x80, 0x86, 0x1e, 0x02, 0x18, 0x38, 0x08, 0x43, 0x43, 0x7f, 0x10, 0x0d, 0xfc, 0x4c, 0x20, +}; +const uint8_t* _I_Ten_7x8[] = {_I_Ten_7x8_0}; +const Icon I_Ten_7x8 = + {.width = 18, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Ten_7x8}; + +// King 26 0xc1,0xc0,0xf8,0x70,0x1f,0x1c,0x02,0xe7,0x00,0x9d,0xc0,0x23,0xf0,0x08,0x78,0x0c,0x80,0xe2,0x0b,0x10,0x78,0x84,0xc4,0x2e,0x20,0x01, +// Queen 19 0xfe,0x40,0x3f,0xd0,0x1c,0x3c,0x0c,0x01,0x76,0x38,0x1f,0x8e,0x07,0xc7,0x81,0x85,0x47,0xf9,0x01, +// Jack 13 0x80,0x40,0xc0,0x3a,0x00,0x5c,0x3c,0x0f,0xfd,0x01,0xfe,0x40,0x00, +// Ace 19 0x98,0x40,0x2f,0x00,0x12,0xe6,0x00,0x4b,0x0d,0x01,0x00,0x8c,0x0e,0x07,0xff,0x00,0x90,0x01,0xc0, +// 10 41 0x86,0x7f,0x00,0x43,0xfe,0x80,0xc3,0xf0,0xf0,0x38,0x7e,0x0e,0x07,0x0c,0xe1,0x80,0x87,0xc6,0x02,0x1b,0x98,0x08,0x67,0x60,0x21,0x8f,0x80,0x86,0x1e,0x02,0x18,0x38,0x08,0x43,0x43,0x7f,0x10,0x0d,0xfc,0x4c,0x20, + +const char* StateName[10] = { + "Intro", // should never see this + "Select Bet", // cards are face down + "Choose Cards", // cards are revealed, player can choose which to hold + "Good Luck!" // cards are replaced, payouts here. +}; + +//const uint8_t _I_Splash_128x64_0[] = { +int Poker_Title; //Have we seen the title + +const char* suitname[4] = {"C", "D", "H", "S"}; + +int score_low = 1000; +int score_high = 1000; + +int minbet = 10; +int bet = 10; + +int betmultiplier = 1; + +#define AllAmerican 0 +#define TensOrBetter 1 +#define BonusPoker 2 +#define DoubleBonus 3 +#define DoubleBonusBonus 4 +#define JacksOrBetter 5 /* default */ +#define JacksOrBetter95 6 +#define JacksOrBetter86 7 +#define JacksOrBetter85 8 +#define JacksOrBetter75 9 +#define JacksOrBetter65 10 +/* If you add another game, increment NUMGAMES: */ +#define NUMGAMES 11 + +/* + The game in play. Default is Jacks or Better, + which is coded into initialization of static data +*/ + +int game = JacksOrBetter; + +const char* gamenames[NUMGAMES] = { + "All American", + "Tens or Better", + "Bonus Poker", + "Double Bonus", + "Double Bonus Bonus", + "Jacks or Better", + "9/5 Jacks or Better", + "8/6 Jacks or Better", + "8/5 Jacks or Better", + "7/5 Jacks or Better", + "6/5 Jacks or Better"}; + +/* Sanity check: check that there are no duplicate cards in hand */ + +void playcard(PokerPlayer* app) { + int i, c, crd; + + int hold[5]; + hold[5] = 2; + // int digit; + c = 1; + c++; + c = hold[5]; /* FIX for unused-but-set-variable */ + /* initialize deck */ + for(i = 0; i < 52; i++) deck[i].gone = 0; + + /* initialize hold[] */ + for(i = 0; i < 5; i++) hold[i] = 1; + + /* app->score -= bet; */ + + for(i = 0; i < 5; i++) { + /* find a card not already dealt */ + do crd = random() % 52; + while(deck[crd].gone); + hold[i] = 1; + deck[crd].gone = 1; + if(!app->held[i]) { + app->hand[i] = deck[crd]; + } + } +} + +int check_for_dupes(PokerPlayer* app) { + int i, j; + + for(i = 0; i < 5; i++) { + for(j = i + 1; j < 5; j++) { + if(app->hand[i].index == app->hand[j].index && app->hand[i].suit == app->hand[j].suit) + return 0; + } + } + + return 1; +} + +/* Functions that recognize winning hands */ + +/* + Flush: + returns 1 if the sorted hand is a flush +*/ + +int flush(PokerPlayer* app) { + if(app->shand[0].suit == app->shand[1].suit && app->shand[1].suit == app->shand[2].suit && + app->shand[2].suit == app->shand[3].suit && app->shand[3].suit == app->shand[4].suit) + return 1; + + return 0; +} + +/* + Straight: + returns 1 if the sorted hand is a straight +*/ + +int straight(PokerPlayer* app) { + if(app->shand[1].index == app->shand[0].index + 1 && + app->shand[2].index == app->shand[1].index + 1 && + app->shand[3].index == app->shand[2].index + 1 && + app->shand[4].index == app->shand[3].index + 1) + return 1; + + /* Ace low straight: Ace, 2, 3, 4, 5 */ + + if(app->shand[4].index == 13 && app->shand[0].index == 1 && app->shand[1].index == 2 && + app->shand[2].index == 3 && app->shand[3].index == 4) + return 1; + + return 0; +} + +/* + Four of a kind: + the middle 3 all match, and the first or last matches those +*/ + +int four(PokerPlayer* app) { + if((app->shand[1].index == app->shand[2].index && + app->shand[2].index == app->shand[3].index) && + (app->shand[0].index == app->shand[2].index || app->shand[4].index == app->shand[2].index)) + return 1; + + return 0; +} + +/* + Full house: + 3 of a kind and a pair +*/ + +int full(PokerPlayer* app) { + if(app->shand[0].index == app->shand[1].index && + (app->shand[2].index == app->shand[3].index && app->shand[3].index == app->shand[4].index)) + return 1; + + if(app->shand[3].index == app->shand[4].index && + (app->shand[0].index == app->shand[1].index && app->shand[1].index == app->shand[2].index)) + return 1; + + return 0; +} + +/* + Three of a kind: + it can appear 3 ways +*/ + +int three(PokerPlayer* app) { + if(app->shand[0].index == app->shand[1].index && app->shand[1].index == app->shand[2].index) + return 1; + + if(app->shand[1].index == app->shand[2].index && app->shand[2].index == app->shand[3].index) + return 1; + + if(app->shand[2].index == app->shand[3].index && app->shand[3].index == app->shand[4].index) + return 1; + + return 0; +} + +/* + Two pair: + it can appear in 3 ways +*/ + +int twopair(PokerPlayer* app) { + if(((app->shand[0].index == app->shand[1].index) && + (app->shand[2].index == app->shand[3].index)) || + ((app->shand[0].index == app->shand[1].index) && + (app->shand[3].index == app->shand[4].index)) || + ((app->shand[1].index == app->shand[2].index) && + (app->shand[3].index == app->shand[4].index))) + return 1; + + return 0; +} + +/* + Two of a kind (pair), jacks or better + or if the game is Tens or Better, 10s or better. +*/ + +int two(PokerPlayer* app) { + int min = 10; + + if(game == TensOrBetter) min = 9; + + if(app->shand[0].index == app->shand[1].index && app->shand[1].index >= min) return 1; + if(app->shand[1].index == app->shand[2].index && app->shand[2].index >= min) return 1; + if(app->shand[2].index == app->shand[3].index && app->shand[3].index >= min) return 1; + if(app->shand[3].index == app->shand[4].index && app->shand[4].index >= min) return 1; + + return 0; +} + +int paytable[10] = { + 800, /* royal flush: 800 */ + 50, /* straight flush: 50 */ + 25, /* 4 of a kind: 25 */ + 9, /* full house: 9 */ + 6, /* flush: 6 */ + 4, /* straight: 4 */ + 3, /* 3 of a kind: 3 */ + 2, /* two pair: 2 */ + 1, /* jacks or better: 1 */ + 0 /* nothing */ +}; + +const char* handname[10] = { + "Royal Flush", + "Straight Flush", + "Four of a Kind", + "Full House", + "Flush", + "Straight", + "Three of a Kind", + "Two Pair", + "Pair", + "Nothing", +}; + +int recognize(PokerPlayer* app) { + int i, j, f = 0; + int min = 100; + card tmp[5]; + int st = 0, fl = 0; + + /* Sort hand into sorted hand (app->shand) */ + + /* make copy of hand */ + for(i = 0; i < 5; i++) tmp[i] = app->hand[i]; + + for(i = 0; i < 5; i++) { + /* put lowest card in hand into next place in app->shand */ + + for(j = 0; j < 5; j++) + if(tmp[j].index <= min) { + min = tmp[j].index; + f = j; + } + + app->shand[i] = tmp[f]; + tmp[f].index = 100; /* larger than any card */ + min = 100; + } + + /* royal and straight flushes, strait, and flush */ + + fl = flush(app); + st = straight(app); + + if(st && fl && app->shand[0].index == 9) return 0; + if(st && fl) return 1; + if(four(app)) return 2; + if(full(app)) return 3; + if(fl) return 4; + if(st) return 5; + if(three(app)) return 6; + if(twopair(app)) return 7; + if(two(app)) return 8; + + /* Nothing */ + + return 9; +} + +void poker_draw_callback(Canvas* canvas, void* ctx) { + PokerPlayer* poker_player = ctx; + furi_check(osMutexAcquire(poker_player->model_mutex, osWaitForever) == osOK); + canvas_clear(canvas); + char buffer[25]; + canvas_set_color(canvas, ColorBlack); + canvas_set_font(canvas, FontSecondary); + + /* Magic Begins */ + + /* Status Info */ + if(poker_player->GameState != 0 && poker_player->GameState != 4) { + snprintf(buffer, sizeof(buffer), "%d", poker_player->score); + canvas_draw_str_aligned(canvas, 127, 0, AlignRight, AlignTop, buffer); + } + + /* Draw the Cards */ + if(poker_player->GameState == 1) { + snprintf(buffer, sizeof(buffer), "Bet:%d", bet); + canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); + snprintf(buffer, sizeof(buffer), "<*> Place Bet"); + canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); + canvas_draw_icon(canvas, 5, 18, &I_CardBack_22x35); + + canvas_draw_icon(canvas, 29, 18, &I_CardBack_22x35); + + canvas_draw_icon(canvas, 53, 18, &I_CardBack_22x35); + + canvas_draw_icon(canvas, 77, 18, &I_CardBack_22x35); + + canvas_draw_icon(canvas, 101, 18, &I_CardBack_22x35); + + } + + else if(poker_player->GameState == 2 || poker_player->GameState == 3) { + snprintf(buffer, sizeof(buffer), "Pot:%d", bet); + canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); + snprintf(buffer, sizeof(buffer), "<*> Select Hold"); + canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); + + /* snprintf( + buffer, + sizeof(buffer), + "%s:%ix", + handname[recognize(poker_player)], + paytable[recognize(poker_player)]); + canvas_draw_str_aligned(canvas, 5, 5, AlignLeft, AlignTop, buffer); */ + + poker_player->held[0] ? canvas_draw_rbox(canvas, 5, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 5, 18, 22, 35, 3); + + poker_player->held[1] ? canvas_draw_rbox(canvas, 29, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 29, 18, 22, 35, 3); + + poker_player->held[2] ? canvas_draw_rbox(canvas, 53, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 53, 18, 22, 35, 3); + + poker_player->held[3] ? canvas_draw_rbox(canvas, 77, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 77, 18, 22, 35, 3); + + poker_player->held[4] ? canvas_draw_rbox(canvas, 101, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 101, 18, 22, 35, 3); + + //shameful + poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[0].suit == 0) // club + canvas_draw_icon(canvas, 18, 43, &I_club_7x8); + + if(poker_player->hand[0].suit == 1) // diamond + canvas_draw_icon(canvas, 18, 43, &I_diamond_7x8); + + if(poker_player->hand[0].suit == 2) // heart + canvas_draw_icon(canvas, 18, 43, &I_hearts_7x8); + + if(poker_player->hand[0].suit == 3) // spade + canvas_draw_icon(canvas, 18, 43, &I_spade_7x8); + + //canvas_draw_str_aligned(canvas, 25, 49, AlignRight, AlignBottom, buffer); + + poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[1].suit == 0) // club + canvas_draw_icon(canvas, 42, 43, &I_club_7x8); + + if(poker_player->hand[1].suit == 1) // diamond + canvas_draw_icon(canvas, 42, 43, &I_diamond_7x8); + + if(poker_player->hand[1].suit == 2) // heart + canvas_draw_icon(canvas, 42, 43, &I_hearts_7x8); + + if(poker_player->hand[1].suit == 3) // spade + canvas_draw_icon(canvas, 42, 43, &I_spade_7x8); + + //canvas_draw_str_aligned(canvas, 49, 49, AlignRight, AlignBottom, buffer); + + poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[2].suit == 0) // club + canvas_draw_icon(canvas, 66, 43, &I_club_7x8); + + if(poker_player->hand[2].suit == 1) // diamond + canvas_draw_icon(canvas, 66, 43, &I_diamond_7x8); + + if(poker_player->hand[2].suit == 2) // heart + canvas_draw_icon(canvas, 66, 43, &I_hearts_7x8); + + if(poker_player->hand[2].suit == 3) // spade + canvas_draw_icon(canvas, 66, 43, &I_spade_7x8); + + // canvas_draw_str_aligned(canvas, 73, 49, AlignRight, AlignBottom, buffer); + + poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[3].suit == 0) // club + canvas_draw_icon(canvas, 90, 43, &I_club_7x8); + + if(poker_player->hand[3].suit == 1) // diamond + canvas_draw_icon(canvas, 90, 43, &I_diamond_7x8); + + if(poker_player->hand[3].suit == 2) // heart + canvas_draw_icon(canvas, 90, 43, &I_hearts_7x8); + + if(poker_player->hand[3].suit == 3) // spade + canvas_draw_icon(canvas, 90, 43, &I_spade_7x8); + + // canvas_draw_str_aligned(canvas, 97, 49, AlignRight, AlignBottom, buffer); + + poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[4].suit == 0) // club + canvas_draw_icon(canvas, 113, 43, &I_club_7x8); + + if(poker_player->hand[4].suit == 1) // diamond + canvas_draw_icon(canvas, 113, 43, &I_diamond_7x8); + + if(poker_player->hand[4].suit == 2) // heart + canvas_draw_icon(canvas, 113, 43, &I_hearts_7x8); + + if(poker_player->hand[4].suit == 3) // spade + canvas_draw_icon(canvas, 113, 43, &I_spade_7x8); + + //canvas_draw_str_align-ed(canvas, 120, 50, AlignRight, AlignBottom, buffer); + + canvas_set_font(canvas, FontBigNumbers); + if(poker_player->hand[0].index >= 1 && poker_player->hand[0].index <= 8) { + poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[0].sym); + canvas_draw_str_aligned(canvas, 7, 22, AlignLeft, AlignTop, buffer); + } else { + poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[0].index == 9) // Ten + canvas_draw_icon(canvas, 7, 22, &I_Ten_7x8); + + if(poker_player->hand[0].index == 10) // Jack + canvas_draw_icon(canvas, 7, 22, &I_Jack_7x8); + + if(poker_player->hand[0].index == 11) // Queen + canvas_draw_icon(canvas, 7, 22, &I_Queen_7x8); + + if(poker_player->hand[0].index == 12) // King + canvas_draw_icon(canvas, 7, 22, &I_King_7x8); + + if(poker_player->hand[0].index == 13) // ace + canvas_draw_icon(canvas, 7, 22, &I_Ace_7x8); + } + if(poker_player->hand[1].index >= 0 && poker_player->hand[1].index <= 8) { + poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[1].sym); + canvas_draw_str_aligned(canvas, 31, 22, AlignLeft, AlignTop, buffer); + } else { + /* bitmap time */ + poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[1].index == 9) // Ten + canvas_draw_icon(canvas, 31, 22, &I_Ten_7x8); + + if(poker_player->hand[1].index == 10) // Jack + canvas_draw_icon(canvas, 31, 22, &I_Jack_7x8); + + if(poker_player->hand[1].index == 11) // Queen + canvas_draw_icon(canvas, 31, 22, &I_Queen_7x8); + + if(poker_player->hand[1].index == 12) // King + canvas_draw_icon(canvas, 31, 22, &I_King_7x8); + + if(poker_player->hand[1].index == 13) // ace + canvas_draw_icon(canvas, 31, 22, &I_Ace_7x8); + } + if(poker_player->hand[2].index >= 0 && poker_player->hand[2].index <= 8) { + poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[2].sym); + canvas_draw_str_aligned(canvas, 55, 22, AlignLeft, AlignTop, buffer); + } else { + /* bitmap time */ + poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[2].index == 9) // Ten + canvas_draw_icon(canvas, 55, 22, &I_Ten_7x8); + + if(poker_player->hand[2].index == 10) // Jack + canvas_draw_icon(canvas, 55, 22, &I_Jack_7x8); + + if(poker_player->hand[2].index == 11) // Queen + canvas_draw_icon(canvas, 55, 22, &I_Queen_7x8); + + if(poker_player->hand[2].index == 12) // King + canvas_draw_icon(canvas, 55, 22, &I_King_7x8); + + if(poker_player->hand[2].index == 13) // ace + canvas_draw_icon(canvas, 55, 22, &I_Ace_7x8); + } + if(poker_player->hand[3].index >= 0 && poker_player->hand[3].index <= 8) { + poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[3].sym); + canvas_draw_str_aligned(canvas, 79, 22, AlignLeft, AlignTop, buffer); + } else { + /* bitmap time */ + poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[3].index == 9) // Ten + canvas_draw_icon(canvas, 79, 22, &I_Ten_7x8); + + if(poker_player->hand[3].index == 10) // Jack + canvas_draw_icon(canvas, 79, 22, &I_Jack_7x8); + + if(poker_player->hand[3].index == 11) // Queen + canvas_draw_icon(canvas, 79, 22, &I_Queen_7x8); + + if(poker_player->hand[3].index == 12) // King + canvas_draw_icon(canvas, 79, 22, &I_King_7x8); + + if(poker_player->hand[3].index == 13) // ace + canvas_draw_icon(canvas, 79, 22, &I_Ace_7x8); + } + if(poker_player->hand[4].index >= 0 && poker_player->hand[4].index <= 8) { + poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[4].sym); + canvas_draw_str_aligned(canvas, 103, 22, AlignLeft, AlignTop, buffer); + } else { + /* bitmap time */ + poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[4].index == 9) // Ten + canvas_draw_icon(canvas, 103, 22, &I_Ten_7x8); + + if(poker_player->hand[4].index == 10) // Jack + canvas_draw_icon(canvas, 103, 22, &I_Jack_7x8); + + if(poker_player->hand[4].index == 11) // Queen + canvas_draw_icon(canvas, 103, 22, &I_Queen_7x8); + + if(poker_player->hand[4].index == 12) // King + canvas_draw_icon(canvas, 103, 22, &I_King_7x8); + + if(poker_player->hand[4].index == 13) // ace + canvas_draw_icon(canvas, 103, 22, &I_Ace_7x8); + } + + /* Draw the Select hand */ + if(poker_player->GameState == 2) { + canvas_set_color(canvas, ColorBlack); + if(poker_player->selected == 0) { + canvas_draw_icon(canvas, 11, 54, &I_Hand_12x10); + } + + if(poker_player->selected == 1) { + canvas_draw_icon(canvas, 35, 54, &I_Hand_12x10); + } + + if(poker_player->selected == 2) { + canvas_draw_icon(canvas, 58, 54, &I_Hand_12x10); + } + + if(poker_player->selected == 3) { + canvas_draw_icon(canvas, 83, 54, &I_Hand_12x10); + } + + if(poker_player->selected == 4) { + canvas_draw_icon(canvas, 109, 54, &I_Hand_12x10); + } + } + } // GameState 2 or 3 + + canvas_set_color(canvas, ColorBlack); + canvas_set_font(canvas, FontSecondary); + if(poker_player->GameState == 3) { + snprintf( + buffer, + sizeof(buffer), + "%s:%ix", + handname[recognize(poker_player)], + paytable[recognize(poker_player)]); + canvas_draw_str_aligned(canvas, 63, 63, AlignCenter, AlignBottom, buffer); + } + if(poker_player->GameState == 0) { + canvas_draw_icon(canvas, 0, 0, &I_Splash_128x64); + } + if(poker_player->GameState == 4) { + canvas_draw_icon(canvas, 0, 0, &I_BadEnd_128x64); + } + + osMutexRelease(poker_player->model_mutex); +} + +void poker_input_callback(InputEvent* input, void* ctx) { + PokerPlayer* poker_player = ctx; + osMessageQueuePut(poker_player->event_queue, input, 0, osWaitForever); +} + +PokerPlayer* poker_player_alloc() { + PokerPlayer* poker_player = malloc(sizeof(PokerPlayer)); + + poker_player->score = 1000; + poker_player->model_mutex = osMutexNew(NULL); + poker_player->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); + poker_player->view_port = view_port_alloc(); + poker_player->selected = 0; + poker_player->GameState = 0; + playcard( + poker_player); /* Get things rolling before the player gets into the game. This will preload the hand. */ + view_port_draw_callback_set(poker_player->view_port, poker_draw_callback, poker_player); + + view_port_input_callback_set(poker_player->view_port, poker_input_callback, poker_player); + + poker_player->gui = furi_record_open("gui"); + gui_add_view_port(poker_player->gui, poker_player->view_port, GuiLayerFullscreen); + + return poker_player; +} + +void poker_player_free(PokerPlayer* poker_player) { + view_port_enabled_set(poker_player->view_port, false); + gui_remove_view_port(poker_player->gui, poker_player->view_port); + furi_record_close("gui"); + view_port_free(poker_player->view_port); + osMessageQueueDelete(poker_player->event_queue); + osMutexDelete(poker_player->model_mutex); + + free(poker_player); +} + +int32_t video_poker_app(void* p) { + UNUSED(p); + PokerPlayer* poker_player = poker_player_alloc(); + + InputEvent event; + for(bool processing = true; processing;) { + osStatus_t status = osMessageQueueGet(poker_player->event_queue, &event, NULL, 100); + furi_check(osMutexAcquire(poker_player->model_mutex, osWaitForever) == osOK); + if(status == osOK) { + if(event.type == InputTypePress) { + switch(event.key) { + case InputKeyUp: + Poker_Shaker(); + break; + case InputKeyDown: + if(poker_player->GameState == 2) { + playcard(poker_player); + if(check_for_dupes(poker_player) == 0) { + playcard(poker_player); + } + + poker_player->GameState = 3; + } + break; + case InputKeyLeft: + if(poker_player->GameState == 1) { + if(bet > minbet + 10) { + bet -= 10; + } + } else if(poker_player->selected > 0 && poker_player->GameState == 2) { + poker_player->selected--; + } // Move hand left/right + else if(poker_player->selected == 0 && poker_player->GameState == 2) { + poker_player->selected = 4; //wraparound + } + break; + case InputKeyRight: + if(poker_player->GameState == 1) { + if(bet < poker_player->score + 10) { + bet += 10; + } + } + if(poker_player->selected < 4 && poker_player->GameState == 2) { + poker_player->selected++; + } // Move hand left/right + else if(poker_player->selected == 4 && poker_player->GameState == 2) { + poker_player->selected = 0; //wraparound + } + break; + case InputKeyOk: + if(poker_player->GameState == 0) { + poker_player->GameState = 1; + } else if(poker_player->GameState == 1) { + poker_player->score -= bet; + poker_player->GameState = 2; + } else if(poker_player->GameState == 2) { + poker_player->held[poker_player->selected] = + !poker_player + ->held[poker_player->selected]; //cursed and bad pls replace + } else if(poker_player->GameState == 3) { + if(recognize(poker_player) != 9) { + poker_player->score += bet * paytable[recognize(poker_player)]; + } + poker_player->GameState = 1; + if(bet > poker_player->score) { + bet = poker_player->score; + } + poker_player->held[0] = 0; + poker_player->held[1] = 0; + poker_player->held[2] = 0; + poker_player->held[3] = 0; + poker_player->held[4] = 0; + if(poker_player->score <= 0) { + poker_player->GameState = 4; + } + playcard(poker_player); // shuffle shuffle + } else if(poker_player->GameState == 4) { + Poker_Shaker(); + processing = false; + } + break; + case InputKeyBack: + processing = false; + break; + } + } + } + osMutexRelease(poker_player->model_mutex); + view_port_update(poker_player->view_port); + } + + poker_player_free(poker_player); + return 0; +} diff --git a/applications/applications.c b/applications/applications.c index 93d0879b00d..dc8bc5589be 100644 --- a/applications/applications.c +++ b/applications/applications.c @@ -50,7 +50,8 @@ extern int32_t music_player_app(void* p); extern int32_t snake_game_app(void* p); extern int32_t tetris_game_app(void *p); extern int32_t clock_app(void *p); -extern int32_t box_mover_app(void* p); +//extern int32_t box_mover_app(void* p); +extern int32_t video_poker_app(void* p); // extern int32_t floopper_bloopper(void* p); // extern int32_t raycast_game_app(void* p); extern int32_t spectrum_analyzer_app(void* p); @@ -349,8 +350,16 @@ const FlipperApplication FLIPPER_GAMES[] = { #endif #ifdef APP_BOX_MOVER - {.app = box_mover_app, - .name = "Box Mover", + {.app = video_poker_app, + .name = "Video Poker", + .stack_size = 1024, + .icon = &A_Plugins_14, + .flags =FlipperApplicationFlagDefault}, +#endif + +#ifdef APP_VIDEO_POKER + {.app = video_poker_app, + .name = "Video Poker", .stack_size = 1024, .icon = &A_Plugins_14, .flags =FlipperApplicationFlagDefault}, diff --git a/applications/applications.mk b/applications/applications.mk index 6b8dcdd51ef..56620739053 100644 --- a/applications/applications.mk +++ b/applications/applications.mk @@ -48,7 +48,8 @@ APP_UPDATER = 1 APP_MUSIC_PLAYER = 1 APP_SNAKE_GAME = 1 APP_TETRIS_GAME = 1 -APP_BOX_MOVER = 1 +//APP_BOX_MOVER = 1 +APP_VIDEO_POKER = 1 # APP_RAYCAST_GAME = 1 APP_CLOCK = 1 APP_SPECTRUM_ANALYZER = 1 @@ -289,6 +290,12 @@ CFLAGS += -DAPP_BOX_MOVER SRV_GUI = 1 endif +APP_VIDEO_POKER ?= 0 +ifeq ($(APP_VIDEO_POKER),1) +CFLAGS += -DAPP_VIDEO_POKER +SRV_GUI = 1 +endif + APP_SPECTRUM_ANALYZER ?= 0 ifeq ($(APP_SPECTRUM_ANALYZER), 1) CFLAGS += -DAPP_SPECTRUM_ANALYZER diff --git a/scripts/User/iconencode.py b/scripts/User/iconencode.py index 409327c2058..67ba05d1baf 100644 --- a/scripts/User/iconencode.py +++ b/scripts/User/iconencode.py @@ -54,7 +54,10 @@ def padded_hex(i, l): # a bit ugly. framename="_I_"+infile+"_"+dims - +print(len(b)) +#d=len(b) +# if b > 255 split 0x1234 into 0x34,0x12 +#d=hex(len(b)) char_out = "const uint8_t "+framename+"_0[] = {"+ str(c) + ",};" char_out2 = "const uint8_t "+framename+"[] = {"+framename+"_0};" From e82d5cb8e92da107828deefdd89780c22cf98abc Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Mon, 13 Jun 2022 11:10:05 -0700 Subject: [PATCH 26/91] Still a bit messy. But it seems to be good now. --- applications/VideoPoker/poker.c | 117 ++++++++++++++++++++++---------- 1 file changed, 82 insertions(+), 35 deletions(-) diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c index 61da1f22d1e..1b625250068 100644 --- a/applications/VideoPoker/poker.c +++ b/applications/VideoPoker/poker.c @@ -19,7 +19,7 @@ A lot of it could be cleaned up or optimized. As is, it does what it wanted and doesn't seem to have major issues, so that's pretty good. Game logic is handled during input and this is a bit of a mess of nested ifs. Sometimes duplicate cards will show up. there is a function to test this. I should use it better. - +After losing, bet is set to 10 eve */ #define TAG "Video Poker" @@ -45,19 +45,16 @@ typedef struct { Gui* gui; card hand[5]; card shand[5]; + card deck[52]; int held[5]; int score; int pot; int GameState; int selected; + int bet; + int minbet; } PokerPlayer; -/* GameState -0=Splash/help, OK button (later on up/down for rules or settings) -1=cards down, betting enabled, left/right to change bet, OK to confirm -2=first hand, holding enabled, left/right to pick card, OK to hold/unhold card, down to confirm -3=second hand, only confirm to claim rewards -4=game over/won -*/ + card deck[52] = { /* index, card name, suit, gone */ @@ -78,13 +75,27 @@ card deck[52] = { {6, "7", 3, 0}, {7, "8", 3, 0}, {8, "9", 3, 0}, {9, "10", 3, 0}, {10, "J", 3, 0}, {11, "Q", 3, 0}, {12, "K", 3, 0}, {13, "A", 3, 0}, }; +/* +int score_low = 1000; + int score_high = 1000; + int minbet = 10; + int betmultiplier = 1; + */ +/* GameState +0=Splash/help, OK button (later on up/down for rules or settings) +1=cards down, betting enabled, left/right to change bet, OK to confirm +2=first hand, holding enabled, left/right to pick card, OK to hold/unhold card, down to confirm +3=second hand, only confirm to claim rewards +4=game over/won +*/ + /* -Calculated Header: 0x01,0x00,0xa4,0x01 +Image Format 0x01 = Compressed 0x00 = Reserved Section 0xa4,0x01 = 0x1a4, or, 420 - the size of the compressed array, minus this header. Rest of the data is char array output from heatshrink of the original XBM char array. - +Calculated Header: 0x01,0x00,0xa4,0x01 from furi_hal_compress.c typedef struct { uint8_t is_compressed; @@ -93,7 +104,49 @@ typedef struct { } FuriHalCompressHeader; */ -const uint8_t _I_Splash_128x64_0[] = {0x01,0x00,0x8a,0x02,0x00,0x78,0x02,0x60,0xe0,0x54,0xc0,0x03,0x9f,0xc0,0x0f,0x5a,0x04,0x04,0x1e,0xdf,0x08,0x78,0x0c,0x60,0xc0,0x21,0x90,0x40,0xa3,0x00,0xf5,0xfe,0x61,0xc1,0xe9,0x1e,0x8e,0x59,0xf0,0x02,0x24,0x9f,0x70,0xc0,0x63,0x03,0x01,0x0c,0x0b,0xc1,0x80,0xbc,0x83,0xd3,0x3f,0x63,0x98,0x03,0xcf,0x88,0x02,0x1c,0x31,0x5d,0x38,0xf6,0x19,0xc0,0xa0,0xfc,0x93,0x13,0x12,0xf0,0x38,0x76,0x08,0xc7,0x00,0x1e,0x5e,0x8b,0xcc,0x32,0x86,0x0f,0x4f,0x0c,0x80,0x06,0x20,0x72,0xe4,0x5e,0x33,0xd4,0x73,0xf2,0x5d,0xe2,0x10,0xef,0xe6,0x02,0x0f,0x07,0x84,0x4c,0x33,0xd2,0x70,0x79,0xd8,0x2e,0x11,0x88,0x3d,0xff,0xc1,0xc7,0x83,0xc4,0x20,0x10,0xc9,0x18,0x3d,0x27,0x18,0x8c,0x3c,0xde,0xe1,0xe6,0x87,0x7e,0x0c,0x62,0x12,0x10,0x01,0xce,0x31,0x9c,0x39,0x9c,0x62,0x67,0x0f,0x83,0x7f,0x27,0xe0,0xf5,0x8c,0x71,0xbc,0x31,0x8c,0xc4,0xe2,0x1e,0x62,0x1e,0x02,0xe0,0x80,0x05,0x1c,0xe1,0xdc,0x23,0x97,0xc8,0xe4,0x5c,0x12,0x50,0x40,0x7a,0x43,0x38,0x77,0x88,0xf4,0x36,0x3d,0x1f,0x04,0x94,0x20,0x1e,0x98,0xce,0x0d,0xbe,0x37,0x0d,0xcd,0xbd,0x0c,0x7e,0xbe,0xce,0x07,0x1f,0xf3,0xfc,0xf8,0xb2,0x8d,0x30,0x20,0x53,0xbe,0x60,0x06,0x03,0x78,0xf0,0x06,0x4c,0x1e,0x34,0x10,0x29,0x5e,0x05,0x0f,0x00,0xa0,0x40,0x24,0x20,0x52,0x76,0x88,0x01,0xc1,0xe3,0x11,0x05,0xc3,0xe9,0x20,0x10,0x97,0x01,0xcf,0xc1,0xf2,0x81,0x3f,0xe7,0xfc,0x66,0xf4,0x02,0xf1,0xc0,0x3f,0xdf,0xf0,0x30,0xc6,0x1e,0xe5,0xff,0x81,0xf0,0x3f,0xe5,0xb2,0x80,0x7f,0xc1,0xe5,0x1c,0x03,0x0f,0xe3,0xff,0x1f,0xf8,0x02,0x48,0x00,0x31,0xfe,0x0b,0xa4,0x61,0xcc,0x62,0xfc,0x4f,0xe3,0x0f,0x31,0x41,0x0e,0x02,0x07,0x01,0x07,0x8a,0xb4,0xa3,0x84,0x71,0x8f,0xff,0x20,0x77,0x00,0x78,0x95,0x46,0x06,0x13,0x10,0x78,0xef,0x3f,0x5f,0xfc,0xff,0xea,0x07,0xf0,0x37,0x90,0x3c,0x78,0x00,0xf2,0xae,0x7f,0x77,0xf7,0xaf,0xec,0x0f,0x88,0x41,0x1b,0x06,0x02,0x03,0xc0,0x02,0x8c,0x08,0x5c,0x37,0xff,0xa9,0x3c,0x7b,0xcc,0x52,0xe0,0x70,0x7c,0x31,0x89,0xe4,0xff,0xfb,0xff,0xdf,0x8c,0x46,0x03,0x1f,0x34,0x17,0x83,0xe1,0x71,0x8f,0x6f,0xe7,0xe0,0xc1,0x8f,0xfd,0x20,0x18,0x65,0x59,0x47,0xaf,0x9b,0x8b,0x9e,0x6f,0xe7,0x1f,0x16,0x0c,0x3e,0x3d,0x00,0xe4,0x43,0xd1,0xe5,0x3f,0xe6,0x6e,0xfb,0x39,0x88,0x67,0xea,0xff,0xc5,0x22,0x8f,0xc0,0xf0,0x41,0x71,0xe7,0x76,0xf9,0x98,0x48,0x64,0x17,0x59,0x38,0x05,0x8f,0xc0,0xd0,0x5f,0xe8,0x0f,0x1a,0xdb,0xe6,0xb1,0xd1,0xa0,0x50,0x85,0x59,0x7e,0x16,0x05,0x06,0x80,0x71,0xbf,0xf7,0x19,0x85,0x99,0x74,0x6d,0x31,0x02,0x10,0x88,0x7c,0xdd,0xdb,0x84,0x62,0x7c,0x0f,0x38,0xe5,0xf0,0x1e,0x97,0xce,0x67,0xbc,0xb6,0x40,0xa3,0x98,0x00,0xc5,0x76,0x53,0x8c,0x67,0x1e,0x07,0x0e,0x63,0x0a,0xe4,0x9c,0x62,0x0f,0x11,0x41,0x95,0x88,0x1e,0x41,0xd1,0x8c,0x49,0x80,0xe6,0x00,0x50,0xb8,0xa3,0x07,0xf1,0x7f,0x06,0xb8,0x00,0x61,0xce,0xb2,0x9c,0x53,0x01,0xf3,0xf0,0x55,0x97,0xd0,0x3f,0x40,0x03,0xfd,0x33,0xc8,0x01,0x71,0x92,0x78,0x80,0x2f,0x80,0x6f,0x20,0x03,0xff,0x23,0xe7,0x02,0x02,0x18,0x01,0xa3,0x91,0x00,0x18,0xc3,0x20,0x91,0xc0,0x7c,0x7f,0x83,0x42,0xaa,0x1f,0xe0,0xbe,0x60,0x46,0xa2,0x81,0xe2,0x24,0x21,0xf9,0x54,0x14,0x18,0x9e,0x3f,0xe4,0x29,0x00,0x12,0x0e,0xb0,0x28,0x50,0x3c,0x60,0x50,0x85,0xf4,0x7f,0xb8,0x3f,0xf3,0xf8,0x83,0xe0,0x00,0x38,0x6e,0x0c,0xc3,0xf2,0x2f,0x94,0x09,0x07,0xc7,0xf7,0x3f,0xfe,0x0d,0xc4,0x00,0xfc,0x4c,0x05,0x86,0x15,0x23,0x92,0x03,0xe7,0xf9,0x80,0x0f,0x97,0x52,0x0c,0x2f,0xb1,0xf8,0xe3,0x01,0xf3,0x82,0x27,0x8d,0xe6,0x41,0x1c,0x17,0xcf,0xfc,0x3e,0x64,0xf8,}; +const uint8_t _I_Splash_128x64_0[] = { + 0x01, 0x00, 0x8a, 0x02, 0x00, 0x78, 0x02, 0x60, 0xe0, 0x54, 0xc0, 0x03, 0x9f, 0xc0, 0x0f, 0x5a, + 0x04, 0x04, 0x1e, 0xdf, 0x08, 0x78, 0x0c, 0x60, 0xc0, 0x21, 0x90, 0x40, 0xa3, 0x00, 0xf5, 0xfe, + 0x61, 0xc1, 0xe9, 0x1e, 0x8e, 0x59, 0xf0, 0x02, 0x24, 0x9f, 0x70, 0xc0, 0x63, 0x03, 0x01, 0x0c, + 0x0b, 0xc1, 0x80, 0xbc, 0x83, 0xd3, 0x3f, 0x63, 0x98, 0x03, 0xcf, 0x88, 0x02, 0x1c, 0x31, 0x5d, + 0x38, 0xf6, 0x19, 0xc0, 0xa0, 0xfc, 0x93, 0x13, 0x12, 0xf0, 0x38, 0x76, 0x08, 0xc7, 0x00, 0x1e, + 0x5e, 0x8b, 0xcc, 0x32, 0x86, 0x0f, 0x4f, 0x0c, 0x80, 0x06, 0x20, 0x72, 0xe4, 0x5e, 0x33, 0xd4, + 0x73, 0xf2, 0x5d, 0xe2, 0x10, 0xef, 0xe6, 0x02, 0x0f, 0x07, 0x84, 0x4c, 0x33, 0xd2, 0x70, 0x79, + 0xd8, 0x2e, 0x11, 0x88, 0x3d, 0xff, 0xc1, 0xc7, 0x83, 0xc4, 0x20, 0x10, 0xc9, 0x18, 0x3d, 0x27, + 0x18, 0x8c, 0x3c, 0xde, 0xe1, 0xe6, 0x87, 0x7e, 0x0c, 0x62, 0x12, 0x10, 0x01, 0xce, 0x31, 0x9c, + 0x39, 0x9c, 0x62, 0x67, 0x0f, 0x83, 0x7f, 0x27, 0xe0, 0xf5, 0x8c, 0x71, 0xbc, 0x31, 0x8c, 0xc4, + 0xe2, 0x1e, 0x62, 0x1e, 0x02, 0xe0, 0x80, 0x05, 0x1c, 0xe1, 0xdc, 0x23, 0x97, 0xc8, 0xe4, 0x5c, + 0x12, 0x50, 0x40, 0x7a, 0x43, 0x38, 0x77, 0x88, 0xf4, 0x36, 0x3d, 0x1f, 0x04, 0x94, 0x20, 0x1e, + 0x98, 0xce, 0x0d, 0xbe, 0x37, 0x0d, 0xcd, 0xbd, 0x0c, 0x7e, 0xbe, 0xce, 0x07, 0x1f, 0xf3, 0xfc, + 0xf8, 0xb2, 0x8d, 0x30, 0x20, 0x53, 0xbe, 0x60, 0x06, 0x03, 0x78, 0xf0, 0x06, 0x4c, 0x1e, 0x34, + 0x10, 0x29, 0x5e, 0x05, 0x0f, 0x00, 0xa0, 0x40, 0x24, 0x20, 0x52, 0x76, 0x88, 0x01, 0xc1, 0xe3, + 0x11, 0x05, 0xc3, 0xe9, 0x20, 0x10, 0x97, 0x01, 0xcf, 0xc1, 0xf2, 0x81, 0x3f, 0xe7, 0xfc, 0x66, + 0xf4, 0x02, 0xf1, 0xc0, 0x3f, 0xdf, 0xf0, 0x30, 0xc6, 0x1e, 0xe5, 0xff, 0x81, 0xf0, 0x3f, 0xe5, + 0xb2, 0x80, 0x7f, 0xc1, 0xe5, 0x1c, 0x03, 0x0f, 0xe3, 0xff, 0x1f, 0xf8, 0x02, 0x48, 0x00, 0x31, + 0xfe, 0x0b, 0xa4, 0x61, 0xcc, 0x62, 0xfc, 0x4f, 0xe3, 0x0f, 0x31, 0x41, 0x0e, 0x02, 0x07, 0x01, + 0x07, 0x8a, 0xb4, 0xa3, 0x84, 0x71, 0x8f, 0xff, 0x20, 0x77, 0x00, 0x78, 0x95, 0x46, 0x06, 0x13, + 0x10, 0x78, 0xef, 0x3f, 0x5f, 0xfc, 0xff, 0xea, 0x07, 0xf0, 0x37, 0x90, 0x3c, 0x78, 0x00, 0xf2, + 0xae, 0x7f, 0x77, 0xf7, 0xaf, 0xec, 0x0f, 0x88, 0x41, 0x1b, 0x06, 0x02, 0x03, 0xc0, 0x02, 0x8c, + 0x08, 0x5c, 0x37, 0xff, 0xa9, 0x3c, 0x7b, 0xcc, 0x52, 0xe0, 0x70, 0x7c, 0x31, 0x89, 0xe4, 0xff, + 0xfb, 0xff, 0xdf, 0x8c, 0x46, 0x03, 0x1f, 0x34, 0x17, 0x83, 0xe1, 0x71, 0x8f, 0x6f, 0xe7, 0xe0, + 0xc1, 0x8f, 0xfd, 0x20, 0x18, 0x65, 0x59, 0x47, 0xaf, 0x9b, 0x8b, 0x9e, 0x6f, 0xe7, 0x1f, 0x16, + 0x0c, 0x3e, 0x3d, 0x00, 0xe4, 0x43, 0xd1, 0xe5, 0x3f, 0xe6, 0x6e, 0xfb, 0x39, 0x88, 0x67, 0xea, + 0xff, 0xc5, 0x22, 0x8f, 0xc0, 0xf0, 0x41, 0x71, 0xe7, 0x76, 0xf9, 0x98, 0x48, 0x64, 0x17, 0x59, + 0x38, 0x05, 0x8f, 0xc0, 0xd0, 0x5f, 0xe8, 0x0f, 0x1a, 0xdb, 0xe6, 0xb1, 0xd1, 0xa0, 0x50, 0x85, + 0x59, 0x7e, 0x16, 0x05, 0x06, 0x80, 0x71, 0xbf, 0xf7, 0x19, 0x85, 0x99, 0x74, 0x6d, 0x31, 0x02, + 0x10, 0x88, 0x7c, 0xdd, 0xdb, 0x84, 0x62, 0x7c, 0x0f, 0x38, 0xe5, 0xf0, 0x1e, 0x97, 0xce, 0x67, + 0xbc, 0xb6, 0x40, 0xa3, 0x98, 0x00, 0xc5, 0x76, 0x53, 0x8c, 0x67, 0x1e, 0x07, 0x0e, 0x63, 0x0a, + 0xe4, 0x9c, 0x62, 0x0f, 0x11, 0x41, 0x95, 0x88, 0x1e, 0x41, 0xd1, 0x8c, 0x49, 0x80, 0xe6, 0x00, + 0x50, 0xb8, 0xa3, 0x07, 0xf1, 0x7f, 0x06, 0xb8, 0x00, 0x61, 0xce, 0xb2, 0x9c, 0x53, 0x01, 0xf3, + 0xf0, 0x55, 0x97, 0xd0, 0x3f, 0x40, 0x03, 0xfd, 0x33, 0xc8, 0x01, 0x71, 0x92, 0x78, 0x80, 0x2f, + 0x80, 0x6f, 0x20, 0x03, 0xff, 0x23, 0xe7, 0x02, 0x02, 0x18, 0x01, 0xa3, 0x91, 0x00, 0x18, 0xc3, + 0x20, 0x91, 0xc0, 0x7c, 0x7f, 0x83, 0x42, 0xaa, 0x1f, 0xe0, 0xbe, 0x60, 0x46, 0xa2, 0x81, 0xe2, + 0x24, 0x21, 0xf9, 0x54, 0x14, 0x18, 0x9e, 0x3f, 0xe4, 0x29, 0x00, 0x12, 0x0e, 0xb0, 0x28, 0x50, + 0x3c, 0x60, 0x50, 0x85, 0xf4, 0x7f, 0xb8, 0x3f, 0xf3, 0xf8, 0x83, 0xe0, 0x00, 0x38, 0x6e, 0x0c, + 0xc3, 0xf2, 0x2f, 0x94, 0x09, 0x07, 0xc7, 0xf7, 0x3f, 0xfe, 0x0d, 0xc4, 0x00, 0xfc, 0x4c, 0x05, + 0x86, 0x15, 0x23, 0x92, 0x03, 0xe7, 0xf9, 0x80, 0x0f, 0x97, 0x52, 0x0c, 0x2f, 0xb1, 0xf8, 0xe3, + 0x01, 0xf3, 0x82, 0x27, 0x8d, 0xe6, 0x41, 0x1c, 0x17, 0xcf, 0xfc, 0x3e, 0x64, 0xf8, +}; const uint8_t* _I_Splash_128x64[] = {_I_Splash_128x64_0}; const Icon I_Splash_128x64 = {.width = 128, .height = 64, .frame_count = 1, .frame_rate = 0, .frames = _I_Splash_128x64}; @@ -176,6 +229,8 @@ const uint8_t* _I_spade_7x8[] = {_I_spade_7x8_0}; const Icon I_spade_7x8 = {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_spade_7x8}; +// They only included Numeric Profont22 glyphs and I don't want to fuck up the font embeds right now sooo.. + const uint8_t _I_King_7x8_0[] = { 0x01, 0x00, 0x1a, 0x00, 0xc1, 0xc0, 0xf8, 0x70, 0x1f, 0x1c, 0x02, 0xe7, 0x00, 0x9d, 0xc0, 0x23, 0xf0, 0x08, 0x78, 0x0c, 0x80, 0xe2, 0x0b, 0x10, 0x78, 0x84, 0xc4, 0x2e, 0x20, 0x01, @@ -232,13 +287,8 @@ const uint8_t* _I_Ten_7x8[] = {_I_Ten_7x8_0}; const Icon I_Ten_7x8 = {.width = 18, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Ten_7x8}; -// King 26 0xc1,0xc0,0xf8,0x70,0x1f,0x1c,0x02,0xe7,0x00,0x9d,0xc0,0x23,0xf0,0x08,0x78,0x0c,0x80,0xe2,0x0b,0x10,0x78,0x84,0xc4,0x2e,0x20,0x01, -// Queen 19 0xfe,0x40,0x3f,0xd0,0x1c,0x3c,0x0c,0x01,0x76,0x38,0x1f,0x8e,0x07,0xc7,0x81,0x85,0x47,0xf9,0x01, -// Jack 13 0x80,0x40,0xc0,0x3a,0x00,0x5c,0x3c,0x0f,0xfd,0x01,0xfe,0x40,0x00, -// Ace 19 0x98,0x40,0x2f,0x00,0x12,0xe6,0x00,0x4b,0x0d,0x01,0x00,0x8c,0x0e,0x07,0xff,0x00,0x90,0x01,0xc0, -// 10 41 0x86,0x7f,0x00,0x43,0xfe,0x80,0xc3,0xf0,0xf0,0x38,0x7e,0x0e,0x07,0x0c,0xe1,0x80,0x87,0xc6,0x02,0x1b,0x98,0x08,0x67,0x60,0x21,0x8f,0x80,0x86,0x1e,0x02,0x18,0x38,0x08,0x43,0x43,0x7f,0x10,0x0d,0xfc,0x4c,0x20, - const char* StateName[10] = { + /* use this for the status line and put in better wording */ "Intro", // should never see this "Select Bet", // cards are face down "Choose Cards", // cards are revealed, player can choose which to hold @@ -250,14 +300,6 @@ int Poker_Title; //Have we seen the title const char* suitname[4] = {"C", "D", "H", "S"}; -int score_low = 1000; -int score_high = 1000; - -int minbet = 10; -int bet = 10; - -int betmultiplier = 1; - #define AllAmerican 0 #define TensOrBetter 1 #define BonusPoker 2 @@ -545,7 +587,7 @@ void poker_draw_callback(Canvas* canvas, void* ctx) { /* Draw the Cards */ if(poker_player->GameState == 1) { - snprintf(buffer, sizeof(buffer), "Bet:%d", bet); + snprintf(buffer, sizeof(buffer), "Bet:%d", poker_player->bet); canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); snprintf(buffer, sizeof(buffer), "<*> Place Bet"); canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); @@ -562,7 +604,7 @@ void poker_draw_callback(Canvas* canvas, void* ctx) { } else if(poker_player->GameState == 2 || poker_player->GameState == 3) { - snprintf(buffer, sizeof(buffer), "Pot:%d", bet); + snprintf(buffer, sizeof(buffer), "Pot:%d", poker_player->bet); canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); snprintf(buffer, sizeof(buffer), "<*> Select Hold"); canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); @@ -857,6 +899,9 @@ PokerPlayer* poker_player_alloc() { poker_player->view_port = view_port_alloc(); poker_player->selected = 0; poker_player->GameState = 0; + poker_player->bet = 10; + poker_player->minbet = 10; + playcard( poker_player); /* Get things rolling before the player gets into the game. This will preload the hand. */ view_port_draw_callback_set(poker_player->view_port, poker_draw_callback, poker_player); @@ -906,8 +951,8 @@ int32_t video_poker_app(void* p) { break; case InputKeyLeft: if(poker_player->GameState == 1) { - if(bet > minbet + 10) { - bet -= 10; + if(poker_player->bet >= poker_player->minbet + 10) { + poker_player->bet -= 10; } } else if(poker_player->selected > 0 && poker_player->GameState == 2) { poker_player->selected--; @@ -918,8 +963,8 @@ int32_t video_poker_app(void* p) { break; case InputKeyRight: if(poker_player->GameState == 1) { - if(bet < poker_player->score + 10) { - bet += 10; + if(poker_player->bet < poker_player->score + 10) { + poker_player->bet += 10; } } if(poker_player->selected < 4 && poker_player->GameState == 2) { @@ -933,7 +978,7 @@ int32_t video_poker_app(void* p) { if(poker_player->GameState == 0) { poker_player->GameState = 1; } else if(poker_player->GameState == 1) { - poker_player->score -= bet; + poker_player->score -= poker_player->bet; poker_player->GameState = 2; } else if(poker_player->GameState == 2) { poker_player->held[poker_player->selected] = @@ -941,11 +986,12 @@ int32_t video_poker_app(void* p) { ->held[poker_player->selected]; //cursed and bad pls replace } else if(poker_player->GameState == 3) { if(recognize(poker_player) != 9) { - poker_player->score += bet * paytable[recognize(poker_player)]; + poker_player->score += + poker_player->bet * paytable[recognize(poker_player)]; } poker_player->GameState = 1; - if(bet > poker_player->score) { - bet = poker_player->score; + if(poker_player->bet > poker_player->score) { + poker_player->bet = poker_player->score; } poker_player->held[0] = 0; poker_player->held[1] = 0; @@ -974,3 +1020,4 @@ int32_t video_poker_app(void* p) { poker_player_free(poker_player); return 0; } + From 1e9c301294ab9c77621f6c88b169891b911953c5 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Mon, 13 Jun 2022 11:10:29 -0700 Subject: [PATCH 27/91] Still a bit messy. But it seems to be good now. --- applications/box_mover/box_mover.c | 205 ----------------------------- 1 file changed, 205 deletions(-) delete mode 100644 applications/box_mover/box_mover.c diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c deleted file mode 100644 index eee577d77f1..00000000000 --- a/applications/box_mover/box_mover.c +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include "assets_icons.h" -#include - - -/* 0x01,0x00,0xa4,0x01 -typedef struct { - uint8_t is_compressed; - uint8_t reserved; - uint16_t compressed_buff_size; -} FuriHalCompressHeader; -*/ - -const uint8_t _I_BoxMover_128x64_0[] = {0x01,0x00,0xa4,0x01,0x00,0x78,0x03,0xc0,0x1e,0x00,0xab,0x00,0x3f,0xbf,0x90,0x30,0x29,0xfc,0x23,0xfe,0x0c,0x1e,0x0c,0x12,0x99,0xf8,0x78,0x3d,0x27,0xff,0x8c,0x78,0x3d,0x3c,0x10,0x3b,0xf0,0x3d,0x2f,0xe0,0xf1,0xe3,0x83,0xcf,0xf0,0x0a,0x18,0x08,0x3c,0xef,0x13,0xc8,0xf7,0x1c,0x10,0x71,0xf0,0x88,0xc1,0xc1,0xed,0xef,0x07,0x97,0x00,0x18,0x33,0xe9,0xf0,0x3e,0xbf,0x10,0x10,0x88,0x8c,0x84,0x1e,0xbf,0xe0,0x39,0x06,0xc4,0x7c,0x3f,0x01,0x81,0x13,0xc4,0x1e,0x98,0x03,0x60,0x84,0x46,0xf8,0x43,0x13,0xf9,0x03,0xd0,0x38,0x21,0x12,0x87,0x8c,0x08,0xfe,0x20,0xf4,0xbe,0x04,0x49,0x02,0x20,0x11,0x17,0xbc,0x78,0x22,0x41,0xd1,0xc0,0x10,0x04,0x9e,0xd7,0xe1,0x71,0x0f,0x47,0xc0,0x0f,0x5f,0x70,0x3c,0x7c,0xde,0x38,0x1a,0x04,0xaf,0x90,0x63,0xfb,0xe1,0xbf,0xe2,0xe2,0x10,0x88,0x3d,0x7c,0xe0,0xf1,0x83,0x0f,0x84,0xde,0x24,0xe1,0x07,0xaa,0xfc,0xa0,0xdf,0xce,0x08,0xb8,0x44,0x22,0x0f,0x4c,0xf3,0x7c,0xa0,0xdc,0xcf,0xb8,0x50,0x67,0xe0,0xf3,0x77,0xac,0x1a,0x18,0xfd,0x12,0x81,0x03,0xca,0x7e,0x0f,0x1c,0x18,0x3c,0xff,0x8f,0xf3,0x07,0x94,0x7f,0xc1,0x83,0x07,0xa7,0x62,0x0e,0xee,0x20,0x78,0x80,0x18,0x1e,0x31,0x8c,0xfa,0x44,0x41,0xf9,0xfc,0x17,0x08,0x3f,0x2c,0x00,0x63,0x07,0xf8,0x3f,0xff,0xdf,0xf0,0x02,0x43,0xc1,0xff,0x06,0x8e,0x03,0xfb,0xf0,0x0f,0xef,0x04,0x7c,0x1e,0x90,0xe8,0x74,0x7d,0xbc,0x3c,0x08,0x08,0x3c,0x70,0x10,0xf0,0x7b,0x43,0xe3,0x80,0xf2,0x87,0x1a,0x06,0x18,0x0f,0x68,0x3c,0x60,0x1e,0xb0,0x00,0x7a,0xc1,0xb8,0xe0,0xf1,0xfc,0x4c,0x41,0xf3,0x04,0xe3,0xce,0x3c,0x40,0xff,0x07,0xd6,0x3a,0x28,0x0f,0x31,0xfc,0x83,0xd3,0x81,0x81,0x37,0x88,0x3d,0xe2,0x00,0xf3,0x3f,0x90,0x3f,0x07,0xf4,0x0f,0x32,0x7d,0x83,0xc6,0xf1,0xf2,0x07,0xf8,0x3e,0xe3,0x20,0xf1,0xf8,0x03,0xf2,0x0e,0x0f,0x1c,0x00,0x3c,0x61,0xc0,0xf5,0x83,0x83,0xc6,0x1f,0x7c,0x07,0x9d,0xf0,0x1e,0x9e,0x08,0x18,0x3c,0x63,0xf7,0xe0,0x79,0xfc,0x20,0x20,0xf3,0xfc,0x40,0x3f,0xdf,0xf0,0x02,0x43,0xf8,0x10,0xf0,0x79,0xcf,0xc1,0xf1,0x00,0x9f,0x03,0xcb,0x81,0x07,0x07,0xcb,0x4c,0x41,0xe2,0x2e,0x10,0x7c,0x86,0xc4,0x1e,0x22,0x31,0x07,0xcc,0x02,0x3f,0x60,0x21,0x90,0x02,0xbf,0x16,0x03,0x19,0x00,0x2b,0xc1,0x63,0x41,0x90,0x02,0xc6,0x86,0x00,0xbf,0xe4,0x0c,0x1f,0xab,0xf3,0x00,0x78,0x03,0xc0,0x1f,0x00,}; -const uint8_t* _I_BoxMover_128x64[] = {_I_BoxMover_128x64_0}; -const Icon I_BoxMover_128x64 = {.width=128,.height=64,.frame_count=1,.frame_rate=0,.frames=_I_BoxMover_128x64}; -int moves; //Count moves. Text testing. -//const uint8_t _I_Splash_128x64_0[] = { -int splash; //Have we seen the title - -typedef struct { - int x; - int y; - int sizex; - int sizey; - -} BoxMoverModel; - -typedef struct { - BoxMoverModel* model; - osMutexId_t* model_mutex; - - osMessageQueueId_t event_queue; - - ViewPort* view_port; - Gui* gui; -} BoxMover; - -void shake(void){ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); - } - -void draw_callback(Canvas* canvas, void* ctx){ - - BoxMover* box_mover = ctx; - furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); - if(splash==0) - { - //canvas_draw_icon(canvas, 22, 20, &I_UsbTree_48x22); //testing :) - canvas_draw_icon(canvas, 0, 0, &I_BoxMover_128x64); - osMutexRelease(box_mover->model_mutex); // lol - } - else{ - canvas_clear(canvas); - canvas_draw_box(canvas, box_mover->model->x,box_mover->model->y, box_mover->model->sizex, box_mover->model->sizey); - char buffer[13]; - snprintf(buffer, sizeof(buffer), "Moves: %u", moves); - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 5, 5, AlignLeft, AlignTop, buffer); - osMutexRelease(box_mover->model_mutex); - } -} - -void input_callback(InputEvent* input, void* ctx){ - BoxMover* box_mover = ctx; - osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); -} - -BoxMover* box_mover_alloc(){ - BoxMover* instance = malloc(sizeof(BoxMover)); - instance->model = malloc(sizeof(BoxMoverModel)); - instance->model->x = 10; - instance->model->y = 10; - instance->model->sizex = 4; - instance->model->sizey = 4; - moves=0; - splash=0; - -instance->model_mutex = osMutexNew(NULL); - instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); - instance->view_port = view_port_alloc(); - view_port_draw_callback_set(instance->view_port, draw_callback, instance); - - view_port_input_callback_set(instance->view_port, input_callback, instance); - - - instance->gui = furi_record_open("gui"); - gui_add_view_port(instance->gui, instance->view_port, GuiLayerFullscreen); - - - - return instance; -} - -void box_mover_free(BoxMover* instance){ - view_port_enabled_set(instance->view_port,false); - gui_remove_view_port(instance->gui, instance->view_port); - furi_record_close("gui"); - view_port_free(instance->view_port); - osMessageQueueDelete(instance->event_queue); - osMutexDelete(instance->model_mutex); - - free(instance->model); - free(instance); -} - - -int32_t box_mover_app(void* p){ - UNUSED(p); - BoxMover* box_mover = box_mover_alloc(); - - - InputEvent event; - for(bool processing = true; processing;){ - osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); - furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); - if(status==osOK){ - if(event.type==InputTypePress){ - if(splash==0){splash=1;} - switch(event.key){ - case InputKeyUp: - if (box_mover->model->y >= 1){ - box_mover->model->y-=2; - moves++; - } - else{ - shake(); - } - break; - case InputKeyDown: - if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ // So we're trying to see if it's even or odd, to determine how much to offset the bounds check by, since we're doing this based of the square origin+its size. idk. - box_mover->model->y+=2; - moves++; - } - else{ - shake(); - } - break; - case InputKeyLeft: - if (box_mover->model->x >= 1){ - box_mover->model->x-=2; - moves++; - } - else{ - shake(); - } - break; - case InputKeyRight: - if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ - box_mover->model->x+=2; - moves++; - } - else{ - shake(); - } - break; - case InputKeyOk: - if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ - if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ - if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ - box_mover->model->sizex+=1; - box_mover->model->sizey+=1; - //TODO - also check the box will not grow past boundary. - } - else - shake(); - } - else - shake(); - } - else - shake(); - - - break; - case InputKeyBack: - processing = false; - break; - - } - } - - } - osMutexRelease(box_mover->model_mutex); - view_port_update(box_mover->view_port); - } - - - - box_mover_free(box_mover); - return 0; -} - - - - From fe3b4b323f6d6778debdc5a62e36cbb7e03203aa Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 3 Jun 2022 10:58:36 -0700 Subject: [PATCH 28/91] Improve directions on how to find dimensions, which are kinda important for images. --- scripts/User/ReadMe.md | 31 +++++++++++++++++++++++++++++++ scripts/User/decode.py | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 9139b00fef2..fb70138adfc 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -1,3 +1,4 @@ +<<<<<<< HEAD encode.py decode.py A set of python3 scripts for processing the Flipper image files. @@ -18,6 +19,36 @@ If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE Encode an .xbm file into .xb encode.py input_image output_image That's it. +======= +##################################### +encode.py +decode.py + +A set of python3 scripts for processing the Flipper image files. + +##################################### +PREREQUISITES + +You'll need heatshrink installed - a small embedded/RTOS compression and decompression library +You can get that here https://github.com/atomicobject/heatshrink + +##################################### +HOW TO USE + +## +Decode a .mb into .xbm: +decode.py input_image output_image [width] [height] +Dimensions are not stored in .bm so you need to specify +If you have the meta.txt available for the animation set the dimensions will be in here. +It may also be part of the directory name for the animation files as well. + +If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. + +## +Encode an .xbm file into .xb +encode.py input_image output_image +That's it. +>>>>>>> ed6b23b0 (Improve directions on how to find dimensions, which are kinda important for images.) diff --git a/scripts/User/decode.py b/scripts/User/decode.py index dd557f0256b..21c4a353d5d 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -27,9 +27,9 @@ def padded_hex(i, l): parser.add_argument('outfile', metavar='o', help='File to write to') parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", - help='Width of the image') + help='Width of the image. Find from meta.txt or directory name') parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", - help='Height of the image') + help='Height of the image. Find from meta.txt or directory name') args = vars(parser.parse_args()) From 61d0bbf04c8792b0dd193746aff126310973410d Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 3 Jun 2022 11:08:50 -0700 Subject: [PATCH 29/91] encode will print out image dimensions --- scripts/User/ReadMe.md | 1 + scripts/User/encode.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index fb70138adfc..27f3ac6f2ce 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -47,6 +47,7 @@ If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE ## Encode an .xbm file into .xb encode.py input_image output_image +You will also get the image dimensions for use in meta.txt That's it. >>>>>>> ed6b23b0 (Improve directions on how to find dimensions, which are kinda important for images.) diff --git a/scripts/User/encode.py b/scripts/User/encode.py index 43d04063c31..d3b7a21e7cd 100644 --- a/scripts/User/encode.py +++ b/scripts/User/encode.py @@ -21,8 +21,11 @@ output = subprocess.check_output(["cat", args["infile"]]) f = io.StringIO(output.decode().strip()) +print("Image Dimensions:") width = int(f.readline().strip().split(" ")[2]) height = int(f.readline().strip().split(" ")[2]) +print("Height:", height) +print("Width: ", width) data = f.read().strip().replace("\n", "").replace(" ", "").split("=")[1][:-1] data_str = data[1:-1].replace(",", " ").replace("0x", "") From 59f5a0d650dd517802f23f4da94b070b258d92f8 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 3 Jun 2022 11:20:49 -0700 Subject: [PATCH 30/91] QOL --- scripts/User/decode.py | 2 +- scripts/User/encode.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/User/decode.py b/scripts/User/decode.py index 21c4a353d5d..f3b83a12e99 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -49,7 +49,7 @@ def padded_hex(i, l): unpad=fileStream[4:] else: if(fileStream[0:1] == bytes([0x00])): - unpad=fileStream[2:] + unpad=fileStream[3:] diff --git a/scripts/User/encode.py b/scripts/User/encode.py index d3b7a21e7cd..c1fcc4b0f8b 100644 --- a/scripts/User/encode.py +++ b/scripts/User/encode.py @@ -23,9 +23,10 @@ f = io.StringIO(output.decode().strip()) print("Image Dimensions:") width = int(f.readline().strip().split(" ")[2]) +print("W: ", width) height = int(f.readline().strip().split(" ")[2]) -print("Height:", height) -print("Width: ", width) +print("H: ", height) + data = f.read().strip().replace("\n", "").replace(" ", "").split("=")[1][:-1] data_str = data[1:-1].replace(",", " ").replace("0x", "") From 907596bb7d0e679bf403a24f61db6b4885002bcd Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 3 Jun 2022 11:10:23 -0700 Subject: [PATCH 31/91] Update ReadMe.md --- scripts/User/ReadMe.md | 57 ++++++++++++------------------------------ 1 file changed, 16 insertions(+), 41 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 27f3ac6f2ce..28abdc5cfda 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -1,55 +1,30 @@ -<<<<<<< HEAD +##################################### encode.py decode.py -A set of python3 scripts for processing the Flipper image files. +A set of python3 scripts for processing the Flipper image files. +##################################### PREREQUISITES + + You'll need heatshrink installed - a small embedded/RTOS compression and decompression library You can get that here https://github.com/atomicobject/heatshrink - +##################################### HOW TO USE + +## Decode a .mb into .xbm: -decode.py input_image output_image [width] [height] -Dimensions are not stored in .bm so you need to specify. -If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. +decode.py input_image output_image [width] [height] +Dimensions are not stored in .bm so you need to specify +If you have the meta.txt available for the animation set the dimensions will be in here. +It may also be part of the directory name for the animation files as well. +If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. +## Encode an .xbm file into .xb encode.py input_image output_image -That's it. -======= -##################################### -encode.py -decode.py - -A set of python3 scripts for processing the Flipper image files. - -##################################### -PREREQUISITES - -You'll need heatshrink installed - a small embedded/RTOS compression and decompression library -You can get that here https://github.com/atomicobject/heatshrink - -##################################### -HOW TO USE - -## -Decode a .mb into .xbm: -decode.py input_image output_image [width] [height] -Dimensions are not stored in .bm so you need to specify -If you have the meta.txt available for the animation set the dimensions will be in here. -It may also be part of the directory name for the animation files as well. - -If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. - -## -Encode an .xbm file into .xb -encode.py input_image output_image -You will also get the image dimensions for use in meta.txt -That's it. ->>>>>>> ed6b23b0 (Improve directions on how to find dimensions, which are kinda important for images.) - - - +You will also get the image dimensions for use in meta.txt +That's it. From 4bb7f1306721722159042f381595e457ff0abbb8 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 00:53:24 -0700 Subject: [PATCH 32/91] New: decoder for heatshrunk char array icons. You'll likely need to trim some bytes off the start. the format here is a bit different than elsewhere. --- scripts/User/decode.py | 2 ++ scripts/User/encode.py | 2 ++ scripts/User/icondecode.py | 66 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 scripts/User/icondecode.py diff --git a/scripts/User/decode.py b/scripts/User/decode.py index f3b83a12e99..01b405c0d95 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -70,3 +70,5 @@ def padded_hex(i, l): data=width_out+height_out+bytes_out w.write(data) +r.close() +w.close() \ No newline at end of file diff --git a/scripts/User/encode.py b/scripts/User/encode.py index c1fcc4b0f8b..d2d533ea3f7 100644 --- a/scripts/User/encode.py +++ b/scripts/User/encode.py @@ -45,3 +45,5 @@ else: data = b"\x00" + data_bin w.write(data) +r.close() +w.close() diff --git a/scripts/User/icondecode.py b/scripts/User/icondecode.py new file mode 100644 index 00000000000..ffc00eafdfd --- /dev/null +++ b/scripts/User/icondecode.py @@ -0,0 +1,66 @@ +import logging +import argparse +import subprocess +import io +import os +import sys + +def padded_hex(i, l): + given_int = i + given_len = l + + hex_result = hex(given_int)[2:] # remove '0x' from beginning of str + num_hex_chars = len(hex_result) + extra_zeros = '0' * (given_len - num_hex_chars) # may not get used.. + + return ('0x' + hex_result if num_hex_chars == given_len else + '?' * given_len if num_hex_chars > given_len else + '0x' + extra_zeros + hex_result if num_hex_chars < given_len else + None) + + +parser = argparse.ArgumentParser(description='Turn icon char arrays back into .xbm') + +parser.add_argument('infile', metavar='i', + help='Input file') +parser.add_argument('outfile', metavar='o', + help='File to write to') +parser.add_argument('Trim', metavar='T', type=int, nargs="?", default="0", + help='Number of bytes off the start/header to trim. Multiples of 2 required.') +parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", + help='Width of the image. Find from meta.txt or directory name') +parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", + help='Height of the image. Find from meta.txt or directory name') + +args = vars(parser.parse_args()) + +r = open(args["infile"],"r") +w = open(args["outfile"],"w") +imageWidth=args["Width"] +imageHeight=args["Height"] +trimStart=args["Trim"] + +output = subprocess.check_output(["cat", args["infile"]]) #yes this is terrible. +f = io.StringIO(output.decode().strip()) + +data = f.read().strip() +data_str = data[1:-1].replace(",", "").replace("0x", "") +data_bin = bytearray.fromhex(data_str[trimStart:]) + +data_decoded_str = subprocess.check_output( + ["heatshrink", "-d","-w8","-l4"], input=data_bin +) + +b=list(data_decoded_str) + +c=', '.join(padded_hex(my_int,2) for my_int in b) + +width_out = "#define icon_width "+ str(imageWidth) + "\n" +height_out = "#define icon_height "+ str(imageHeight) + "\n" +bytes_out = "static unsigned char icon_bits[] = {"+ str(c) + "};" + +data=width_out+height_out+bytes_out + +w.write(data) +r.close() +w.close() \ No newline at end of file From a987a289e8adf801bb373fbf1b73de0d4e9ea103 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 01:08:57 -0700 Subject: [PATCH 33/91] help info --- scripts/User/ReadMe.md | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 scripts/User/ReadMe.md diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md deleted file mode 100644 index 28abdc5cfda..00000000000 --- a/scripts/User/ReadMe.md +++ /dev/null @@ -1,30 +0,0 @@ -##################################### -encode.py -decode.py - -A set of python3 scripts for processing the Flipper image files. - -##################################### -PREREQUISITES - - -You'll need heatshrink installed - a small embedded/RTOS compression and decompression library -You can get that here https://github.com/atomicobject/heatshrink - -##################################### -HOW TO USE - -## -Decode a .mb into .xbm: -decode.py input_image output_image [width] [height] -Dimensions are not stored in .bm so you need to specify -If you have the meta.txt available for the animation set the dimensions will be in here. -It may also be part of the directory name for the animation files as well. - -If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. - -## -Encode an .xbm file into .xb -encode.py input_image output_image -You will also get the image dimensions for use in meta.txt -That's it. From d1e6c3f88dc3b15a832b6fab58a88ce168ea8d93 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 01:11:48 -0700 Subject: [PATCH 34/91] re-arrange params --- scripts/User/icondecode.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/User/icondecode.py b/scripts/User/icondecode.py index ffc00eafdfd..85d2de1c7d2 100644 --- a/scripts/User/icondecode.py +++ b/scripts/User/icondecode.py @@ -25,13 +25,12 @@ def padded_hex(i, l): help='Input file') parser.add_argument('outfile', metavar='o', help='File to write to') -parser.add_argument('Trim', metavar='T', type=int, nargs="?", default="0", - help='Number of bytes off the start/header to trim. Multiples of 2 required.') parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", help='Width of the image. Find from meta.txt or directory name') parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", help='Height of the image. Find from meta.txt or directory name') - +parser.add_argument('Trim', metavar='T', type=int, nargs="?", default="8", + help='Number of bytes off the start/header to trim. Multiples of 2 required.') args = vars(parser.parse_args()) r = open(args["infile"],"r") @@ -62,5 +61,4 @@ def padded_hex(i, l): data=width_out+height_out+bytes_out w.write(data) -r.close() -w.close() \ No newline at end of file +w.close() From 54946d0e2ef0abf0d1d6a6fda6767fa5fdd5b567 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 01:18:01 -0700 Subject: [PATCH 35/91] QOL --- scripts/User/icondecode.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/User/icondecode.py b/scripts/User/icondecode.py index 85d2de1c7d2..241831510f2 100644 --- a/scripts/User/icondecode.py +++ b/scripts/User/icondecode.py @@ -42,8 +42,8 @@ def padded_hex(i, l): output = subprocess.check_output(["cat", args["infile"]]) #yes this is terrible. f = io.StringIO(output.decode().strip()) -data = f.read().strip() -data_str = data[1:-1].replace(",", "").replace("0x", "") +data = f.read().strip().replace(";","").replace("{","").replace("}","") +data_str = data.replace(",", "").replace("0x", "") data_bin = bytearray.fromhex(data_str[trimStart:]) data_decoded_str = subprocess.check_output( From 14fd8b851985c332a46371edba05d609e0e16f72 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 02:55:07 -0700 Subject: [PATCH 36/91] icon encoder added --- scripts/User/iconencode.py | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 scripts/User/iconencode.py diff --git a/scripts/User/iconencode.py b/scripts/User/iconencode.py new file mode 100644 index 00000000000..fd35502b6f2 --- /dev/null +++ b/scripts/User/iconencode.py @@ -0,0 +1,61 @@ +import logging +import argparse +import subprocess +import io +import os +import sys + +def padded_hex(i, l): + given_int = i + given_len = l + + hex_result = hex(given_int)[2:] # remove '0x' from beginning of str + num_hex_chars = len(hex_result) + extra_zeros = '0' * (given_len - num_hex_chars) # may not get used.. + + return ('0x' + hex_result if num_hex_chars == given_len else + '?' * given_len if num_hex_chars > given_len else + '0x' + extra_zeros + hex_result if num_hex_chars < given_len else + None) + + +parser = argparse.ArgumentParser(description='Turn icon char arrays back into .xbm') + +parser.add_argument('infile', metavar='i', + help='Input file') +parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", + help='Width of the image. Find from meta.txt or directory name') +parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", + help='Height of the image. Find from meta.txt or directory name') +args = vars(parser.parse_args()) + +r = open(args["infile"],"r") +infile=args["infile"].split(".")[0] + +imageWidth=args["Width"] +imageHeight=args["Height"] +dims=str(imageWidth)+"x"+str(imageHeight) + +output = subprocess.check_output(["cat", args["infile"]]) #yes this is terrible. +f = io.StringIO(output.decode().strip()) + +data = f.read().strip().replace(";","").replace("{","").replace("}","") +data_str = data.replace(",", "").replace("0x", "") +data_bin = bytearray.fromhex(data_str) + +data_encoded_str = subprocess.check_output( + ["heatshrink", "-e","-w8","-l4"], input=data_bin +) + +b=list(data_encoded_str) + +c=','.join(padded_hex(my_int,2) for my_int in b) + +# a bit ugly. +char_out = "const uint8_t _I_"+infile+"_"+dims+"_0[] = {"+ str(c) + ",};" +char_out2 = "const uint8_t* const _I_" +infile+"{_I_"+infile+"};" +#data=bytes_out +print(char_out) +print(char_out2) +#w.write(data) +#w.close() From ca21fcb8fcdd612bd72f8da2259f517a276cdddc Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 03:09:16 -0700 Subject: [PATCH 37/91] cleanup --- scripts/User/iconencode.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/User/iconencode.py b/scripts/User/iconencode.py index fd35502b6f2..409327c2058 100644 --- a/scripts/User/iconencode.py +++ b/scripts/User/iconencode.py @@ -52,8 +52,12 @@ def padded_hex(i, l): c=','.join(padded_hex(my_int,2) for my_int in b) # a bit ugly. -char_out = "const uint8_t _I_"+infile+"_"+dims+"_0[] = {"+ str(c) + ",};" -char_out2 = "const uint8_t* const _I_" +infile+"{_I_"+infile+"};" + +framename="_I_"+infile+"_"+dims + + +char_out = "const uint8_t "+framename+"_0[] = {"+ str(c) + ",};" +char_out2 = "const uint8_t "+framename+"[] = {"+framename+"_0};" #data=bytes_out print(char_out) print(char_out2) From 5cb506867c59d3368e3c0d9426a74825cd8befb1 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Mon, 6 Jun 2022 13:47:57 -0700 Subject: [PATCH 38/91] I can't count --- scripts/User/decode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/User/decode.py b/scripts/User/decode.py index 01b405c0d95..f6779d967f3 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -49,7 +49,7 @@ def padded_hex(i, l): unpad=fileStream[4:] else: if(fileStream[0:1] == bytes([0x00])): - unpad=fileStream[3:] + unpad=fileStream[2:] From 9158eb6393579c32d48a5e21056976c164d0105e Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Wed, 8 Jun 2022 22:21:49 -0700 Subject: [PATCH 39/91] box tutorial --- applications/applications.c | 16 +++++ applications/applications.mk | 7 ++ applications/box_mover/box_mover.c | 106 +++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 applications/box_mover/box_mover.c diff --git a/applications/applications.c b/applications/applications.c index d3090297f1a..ce218f2b907 100644 --- a/applications/applications.c +++ b/applications/applications.c @@ -50,6 +50,7 @@ extern int32_t music_player_app(void* p); extern int32_t snake_game_app(void* p); extern int32_t tetris_game_app(void *p); extern int32_t clock_app(void *p); +extern int32_t box_mover_app(void* p); // extern int32_t floopper_bloopper(void* p); extern int32_t raycast_game_app(void* p); extern int32_t spectrum_analyzer_app(void* p); @@ -357,6 +358,21 @@ const FlipperApplication FLIPPER_GAMES[] = { .flags = FlipperApplicationFlagDefault}, #endif +#ifdef APP_BOX_MOVER + {.app = box_mover_app, + .name = "Box Mover", + .stack_size = 1024, + .icon = &A_Plugins_14, + .flags =FlipperApplicationFlagDefault}, +#endif + +#ifdef APP_ZOMBIEZ + {.app = zombiez_app, + .name = "Zombiez", + .stack_size = 2048, + .icon = &A_Plugins_14, + .flags = FlipperApplicationFlagDefault}, +#endif }; diff --git a/applications/applications.mk b/applications/applications.mk index 8614bd72ad7..95d124e9f3d 100644 --- a/applications/applications.mk +++ b/applications/applications.mk @@ -49,6 +49,7 @@ APP_MUSIC_PLAYER = 1 APP_SNAKE_GAME = 1 APP_TETRIS_GAME = 1 APP_RAYCAST_GAME = 1 +# APP_RAYCAST_GAME = 1 APP_CLOCK = 1 APP_SPECTRUM_ANALYZER = 1 APP_FLAPPY_GAME = 1 @@ -277,6 +278,12 @@ CFLAGS += -DAPP_SNAKE_GAME SRV_GUI = 1 endif +APP_BOX_MOVER ?= 0 +ifeq ($(APP_BOX_MOVER),1) +CFLAGS += -DAPP_BOX_MOVER +SRV_GUI = 1 +endif + APP_SPECTRUM_ANALYZER ?= 0 ifeq ($(APP_SPECTRUM_ANALYZER), 1) CFLAGS += -DAPP_SPECTRUM_ANALYZER diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c new file mode 100644 index 00000000000..0739cd1ffc5 --- /dev/null +++ b/applications/box_mover/box_mover.c @@ -0,0 +1,106 @@ +#include +#include +#include + +typedef struct { + int x; + int y; +} BoxMoverModel; + +typedef struct { + BoxMoverModel* model; + osMutexId_t* model_mutex; + + osMessageQueueId_t event_queue; + + ViewPort* view_port; + Gui* gui; +} BoxMover; + +BoxMover* box_mover_alloc(){ + BoxMover* instance = malloc(sizeof(BoxMover)); + instance->model = malloc(sizeof(BoxMoverModel)); + instance->model->x = 10; + instance->model->y = 10; + + instance->view_port = view_port_alloc(); + view_port_draw_callback_set(instance->view_port, draw_callback, instance); + + view_port_input_callback_set(instance->view_port, input_callback, instance); + instance->model_mutex = osMutexNew(NULL); + + instance->gui = furi_record_open("gui"); + gui_add_view_port(instance->view_port, GuiLayerFullscreen); + + instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); + + return instance; +} + +void box_mover_free(BoxMover* instance){ + view_port_enabled_set(instance->view_port,false); + gui_remove_view_port(instance->gui, view_port); + furi_record_close("gui"); + osMessageQueueDelete(instance->event_queue); + osMutexDelete(instance->model_mutex); + view_port_free(instance->view_port); + free(instance->model); + free(instance); +} + +int32_t box_mover_app(void* p){ + UNUSED(p); + BoxMover* box_mover = box_mver_alloc(); + + box_mover_free(box_mover) + + for(bool processing = true; processing;){ + osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); + furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); + if(status==osOK){ + if(event.type==InputTypePress){ + switch(event.key){ + case InputKeyUp: + box_mover->model->y-=2; + break; + case InputKeyDown: + box_mover->model->y+=2; + break; + case InputKeyLeft: + box_mover->model->x-=2; + break; + case InputKeyRight: + box_mover->model->x+=2; + break; + case InputKeyOk: + case InputKeyBack: + processing = false; + break; + } + } + } + osMutexRElease(box_mover->model_mutex); + view_port_update(box_mover->view_port); + } + + + box_mover_free(box_mover) + return 0; +} + +void draw_callback(Canvas* cancas, void* ctx){ + BoxMover *box_mover = ctx; + furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); + + canvas_draw_box(canvas, box_mover->x,box_mover->y, 4, 4); + + osReleaseMutex(box_mover->model_mutex); +} + +void input_callback(InputEvent* input, osMessageQueueId_t event_queue){ + BoxMover* box_mover = ctx; + osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); + +} + + From cdeaf0e076e58b4148fed1836b869ec7aa164c2f Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Thu, 9 Jun 2022 00:59:20 -0700 Subject: [PATCH 40/91] Box Mover but added stuff --- applications/box_mover/box_mover.c | 104 +++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 27 deletions(-) diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c index 0739cd1ffc5..fc3366d5951 100644 --- a/applications/box_mover/box_mover.c +++ b/applications/box_mover/box_mover.c @@ -1,10 +1,15 @@ #include #include +#include #include +#include +#include typedef struct { int x; int y; + int sizex; + int sizey; } BoxMoverModel; typedef struct { @@ -17,43 +22,66 @@ typedef struct { Gui* gui; } BoxMover; + + +void draw_callback(Canvas* canvas, void* ctx){ + BoxMover* box_mover = ctx; + furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); + + canvas_draw_box(canvas, box_mover->model->x,box_mover->model->y, box_mover->model->sizex, box_mover->model->sizey); + + osMutexRelease(box_mover->model_mutex); +} + +void input_callback(InputEvent* input, void* ctx){ + BoxMover* box_mover = ctx; + osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); + +} + BoxMover* box_mover_alloc(){ BoxMover* instance = malloc(sizeof(BoxMover)); instance->model = malloc(sizeof(BoxMoverModel)); instance->model->x = 10; instance->model->y = 10; + instance->model->sizex = 4; + instance->model->sizey = 4; +instance->model_mutex = osMutexNew(NULL); + instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); instance->view_port = view_port_alloc(); view_port_draw_callback_set(instance->view_port, draw_callback, instance); view_port_input_callback_set(instance->view_port, input_callback, instance); - instance->model_mutex = osMutexNew(NULL); + instance->gui = furi_record_open("gui"); - gui_add_view_port(instance->view_port, GuiLayerFullscreen); + gui_add_view_port(instance->gui, instance->view_port, GuiLayerFullscreen); + - instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); return instance; } void box_mover_free(BoxMover* instance){ view_port_enabled_set(instance->view_port,false); - gui_remove_view_port(instance->gui, view_port); + gui_remove_view_port(instance->gui, instance->view_port); furi_record_close("gui"); + view_port_free(instance->view_port); osMessageQueueDelete(instance->event_queue); osMutexDelete(instance->model_mutex); - view_port_free(instance->view_port); + free(instance->model); free(instance); } + int32_t box_mover_app(void* p){ UNUSED(p); - BoxMover* box_mover = box_mver_alloc(); + BoxMover* box_mover = box_mover_alloc(); - box_mover_free(box_mover) + InputEvent event; for(bool processing = true; processing;){ osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); @@ -61,46 +89,68 @@ int32_t box_mover_app(void* p){ if(event.type==InputTypePress){ switch(event.key){ case InputKeyUp: - box_mover->model->y-=2; + if (box_mover->model->y >= 1) + box_mover->model->y-=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } break; case InputKeyDown: - box_mover->model->y+=2; - break; + if (box_mover->model->y <= (64-(box_mover->model->sizey+1))) + box_mover->model->y+=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } + break; case InputKeyLeft: - box_mover->model->x-=2; + if (box_mover->model->x >= 1) + box_mover->model->x-=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } break; case InputKeyRight: - box_mover->model->x+=2; + if (box_mover->model->x <= (128-(box_mover->model->sizex+1))) + box_mover->model->x+=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } break; case InputKeyOk: + if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ + box_mover->model->sizex+=1; + box_mover->model->sizey+=1; + } + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } + + break; case InputKeyBack: processing = false; break; } } } - osMutexRElease(box_mover->model_mutex); + osMutexRelease(box_mover->model_mutex); view_port_update(box_mover->view_port); } - box_mover_free(box_mover) + box_mover_free(box_mover); return 0; } -void draw_callback(Canvas* cancas, void* ctx){ - BoxMover *box_mover = ctx; - furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); - canvas_draw_box(canvas, box_mover->x,box_mover->y, 4, 4); - - osReleaseMutex(box_mover->model_mutex); -} - -void input_callback(InputEvent* input, osMessageQueueId_t event_queue){ - BoxMover* box_mover = ctx; - osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); - -} From c852a51a74ed0c5b214319a2e9878562e2b443b7 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Thu, 9 Jun 2022 01:37:03 -0700 Subject: [PATCH 41/91] Improved bounds checks --- applications/box_mover/box_mover.c | 48 ++++++++++++++++-------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c index fc3366d5951..f70ba0f5571 100644 --- a/applications/box_mover/box_mover.c +++ b/applications/box_mover/box_mover.c @@ -22,7 +22,11 @@ typedef struct { Gui* gui; } BoxMover; - +void shake(void){ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } void draw_callback(Canvas* canvas, void* ctx){ BoxMover* box_mover = ctx; @@ -92,48 +96,47 @@ int32_t box_mover_app(void* p){ if (box_mover->model->y >= 1) box_mover->model->y-=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyDown: - if (box_mover->model->y <= (64-(box_mover->model->sizey+1))) + if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))) // So we're trying to see if it's even or odd, to determine how much to offset the bounds check by, since we're doing this based of the square origin+its size. idk. box_mover->model->y+=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyLeft: if (box_mover->model->x >= 1) box_mover->model->x-=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyRight: - if (box_mover->model->x <= (128-(box_mover->model->sizex+1))) + if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))) box_mover->model->x+=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyOk: if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ - box_mover->model->sizex+=1; - box_mover->model->sizey+=1; + if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ + if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ + box_mover->model->sizex+=1; + box_mover->model->sizey+=1; + //TODO - also check the box will not grow past boundary. + } + else + shake(); + } + else + shake(); } - else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); - } + else + shake(); + break; case InputKeyBack: @@ -147,6 +150,7 @@ int32_t box_mover_app(void* p){ } + box_mover_free(box_mover); return 0; } From 3f4484b48d8f64aadb2f576f6f443256bb9de612 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Thu, 9 Jun 2022 10:14:33 -0700 Subject: [PATCH 42/91] Video Poker game --- applications/VideoPoker/poker.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 applications/VideoPoker/poker.c diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c new file mode 100644 index 00000000000..8888349d372 --- /dev/null +++ b/applications/VideoPoker/poker.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include +#include +#include + +// deck array +// hand array +// scoring system + +// card faces +// splash screen/music +// win/lose music + +// bet amount +// bet multi From 8876a68226df95196e5a942e12c37c824f818bbb Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 10 Jun 2022 00:42:23 -0700 Subject: [PATCH 43/91] Box Mover Splash Screen! --- applications/VideoPoker/poker.c | 1 + applications/box_mover/box_mover.c | 149 +++++++++++++++++++---------- 2 files changed, 98 insertions(+), 52 deletions(-) diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c index 8888349d372..47fc9aff3c6 100644 --- a/applications/VideoPoker/poker.c +++ b/applications/VideoPoker/poker.c @@ -4,6 +4,7 @@ #include #include #include +#include "furi_hal_random.h" // deck array // hand array diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c index f70ba0f5571..eee577d77f1 100644 --- a/applications/box_mover/box_mover.c +++ b/applications/box_mover/box_mover.c @@ -4,12 +4,32 @@ #include #include #include +#include +#include "assets_icons.h" +#include + + +/* 0x01,0x00,0xa4,0x01 +typedef struct { + uint8_t is_compressed; + uint8_t reserved; + uint16_t compressed_buff_size; +} FuriHalCompressHeader; +*/ + +const uint8_t _I_BoxMover_128x64_0[] = {0x01,0x00,0xa4,0x01,0x00,0x78,0x03,0xc0,0x1e,0x00,0xab,0x00,0x3f,0xbf,0x90,0x30,0x29,0xfc,0x23,0xfe,0x0c,0x1e,0x0c,0x12,0x99,0xf8,0x78,0x3d,0x27,0xff,0x8c,0x78,0x3d,0x3c,0x10,0x3b,0xf0,0x3d,0x2f,0xe0,0xf1,0xe3,0x83,0xcf,0xf0,0x0a,0x18,0x08,0x3c,0xef,0x13,0xc8,0xf7,0x1c,0x10,0x71,0xf0,0x88,0xc1,0xc1,0xed,0xef,0x07,0x97,0x00,0x18,0x33,0xe9,0xf0,0x3e,0xbf,0x10,0x10,0x88,0x8c,0x84,0x1e,0xbf,0xe0,0x39,0x06,0xc4,0x7c,0x3f,0x01,0x81,0x13,0xc4,0x1e,0x98,0x03,0x60,0x84,0x46,0xf8,0x43,0x13,0xf9,0x03,0xd0,0x38,0x21,0x12,0x87,0x8c,0x08,0xfe,0x20,0xf4,0xbe,0x04,0x49,0x02,0x20,0x11,0x17,0xbc,0x78,0x22,0x41,0xd1,0xc0,0x10,0x04,0x9e,0xd7,0xe1,0x71,0x0f,0x47,0xc0,0x0f,0x5f,0x70,0x3c,0x7c,0xde,0x38,0x1a,0x04,0xaf,0x90,0x63,0xfb,0xe1,0xbf,0xe2,0xe2,0x10,0x88,0x3d,0x7c,0xe0,0xf1,0x83,0x0f,0x84,0xde,0x24,0xe1,0x07,0xaa,0xfc,0xa0,0xdf,0xce,0x08,0xb8,0x44,0x22,0x0f,0x4c,0xf3,0x7c,0xa0,0xdc,0xcf,0xb8,0x50,0x67,0xe0,0xf3,0x77,0xac,0x1a,0x18,0xfd,0x12,0x81,0x03,0xca,0x7e,0x0f,0x1c,0x18,0x3c,0xff,0x8f,0xf3,0x07,0x94,0x7f,0xc1,0x83,0x07,0xa7,0x62,0x0e,0xee,0x20,0x78,0x80,0x18,0x1e,0x31,0x8c,0xfa,0x44,0x41,0xf9,0xfc,0x17,0x08,0x3f,0x2c,0x00,0x63,0x07,0xf8,0x3f,0xff,0xdf,0xf0,0x02,0x43,0xc1,0xff,0x06,0x8e,0x03,0xfb,0xf0,0x0f,0xef,0x04,0x7c,0x1e,0x90,0xe8,0x74,0x7d,0xbc,0x3c,0x08,0x08,0x3c,0x70,0x10,0xf0,0x7b,0x43,0xe3,0x80,0xf2,0x87,0x1a,0x06,0x18,0x0f,0x68,0x3c,0x60,0x1e,0xb0,0x00,0x7a,0xc1,0xb8,0xe0,0xf1,0xfc,0x4c,0x41,0xf3,0x04,0xe3,0xce,0x3c,0x40,0xff,0x07,0xd6,0x3a,0x28,0x0f,0x31,0xfc,0x83,0xd3,0x81,0x81,0x37,0x88,0x3d,0xe2,0x00,0xf3,0x3f,0x90,0x3f,0x07,0xf4,0x0f,0x32,0x7d,0x83,0xc6,0xf1,0xf2,0x07,0xf8,0x3e,0xe3,0x20,0xf1,0xf8,0x03,0xf2,0x0e,0x0f,0x1c,0x00,0x3c,0x61,0xc0,0xf5,0x83,0x83,0xc6,0x1f,0x7c,0x07,0x9d,0xf0,0x1e,0x9e,0x08,0x18,0x3c,0x63,0xf7,0xe0,0x79,0xfc,0x20,0x20,0xf3,0xfc,0x40,0x3f,0xdf,0xf0,0x02,0x43,0xf8,0x10,0xf0,0x79,0xcf,0xc1,0xf1,0x00,0x9f,0x03,0xcb,0x81,0x07,0x07,0xcb,0x4c,0x41,0xe2,0x2e,0x10,0x7c,0x86,0xc4,0x1e,0x22,0x31,0x07,0xcc,0x02,0x3f,0x60,0x21,0x90,0x02,0xbf,0x16,0x03,0x19,0x00,0x2b,0xc1,0x63,0x41,0x90,0x02,0xc6,0x86,0x00,0xbf,0xe4,0x0c,0x1f,0xab,0xf3,0x00,0x78,0x03,0xc0,0x1f,0x00,}; +const uint8_t* _I_BoxMover_128x64[] = {_I_BoxMover_128x64_0}; +const Icon I_BoxMover_128x64 = {.width=128,.height=64,.frame_count=1,.frame_rate=0,.frames=_I_BoxMover_128x64}; +int moves; //Count moves. Text testing. +//const uint8_t _I_Splash_128x64_0[] = { +int splash; //Have we seen the title typedef struct { int x; int y; int sizex; int sizey; + } BoxMoverModel; typedef struct { @@ -29,18 +49,30 @@ void shake(void){ } void draw_callback(Canvas* canvas, void* ctx){ + BoxMover* box_mover = ctx; furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); - + if(splash==0) + { + //canvas_draw_icon(canvas, 22, 20, &I_UsbTree_48x22); //testing :) + canvas_draw_icon(canvas, 0, 0, &I_BoxMover_128x64); + osMutexRelease(box_mover->model_mutex); // lol + } + else{ + canvas_clear(canvas); canvas_draw_box(canvas, box_mover->model->x,box_mover->model->y, box_mover->model->sizex, box_mover->model->sizey); - + char buffer[13]; + snprintf(buffer, sizeof(buffer), "Moves: %u", moves); + canvas_set_color(canvas, ColorBlack); + canvas_set_font(canvas, FontPrimary); + canvas_draw_str_aligned(canvas, 5, 5, AlignLeft, AlignTop, buffer); osMutexRelease(box_mover->model_mutex); + } } void input_callback(InputEvent* input, void* ctx){ BoxMover* box_mover = ctx; osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); - } BoxMover* box_mover_alloc(){ @@ -50,6 +82,8 @@ BoxMover* box_mover_alloc(){ instance->model->y = 10; instance->model->sizex = 4; instance->model->sizey = 4; + moves=0; + splash=0; instance->model_mutex = osMutexNew(NULL); instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); @@ -90,60 +124,71 @@ int32_t box_mover_app(void* p){ osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); if(status==osOK){ - if(event.type==InputTypePress){ - switch(event.key){ - case InputKeyUp: - if (box_mover->model->y >= 1) - box_mover->model->y-=2; - else{ - shake(); - } - break; - case InputKeyDown: - if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))) // So we're trying to see if it's even or odd, to determine how much to offset the bounds check by, since we're doing this based of the square origin+its size. idk. - box_mover->model->y+=2; - else{ - shake(); - } - break; - case InputKeyLeft: - if (box_mover->model->x >= 1) - box_mover->model->x-=2; - else{ - shake(); - } - break; - case InputKeyRight: - if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))) - box_mover->model->x+=2; - else{ - shake(); - } - break; - case InputKeyOk: - if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ - if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ - if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ - box_mover->model->sizex+=1; - box_mover->model->sizey+=1; - //TODO - also check the box will not grow past boundary. + if(event.type==InputTypePress){ + if(splash==0){splash=1;} + switch(event.key){ + case InputKeyUp: + if (box_mover->model->y >= 1){ + box_mover->model->y-=2; + moves++; + } + else{ + shake(); + } + break; + case InputKeyDown: + if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ // So we're trying to see if it's even or odd, to determine how much to offset the bounds check by, since we're doing this based of the square origin+its size. idk. + box_mover->model->y+=2; + moves++; + } + else{ + shake(); + } + break; + case InputKeyLeft: + if (box_mover->model->x >= 1){ + box_mover->model->x-=2; + moves++; + } + else{ + shake(); + } + break; + case InputKeyRight: + if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ + box_mover->model->x+=2; + moves++; + } + else{ + shake(); + } + break; + case InputKeyOk: + if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ + if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ + if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ + box_mover->model->sizex+=1; + box_mover->model->sizey+=1; + //TODO - also check the box will not grow past boundary. + } + else + shake(); } else + shake(); + } + else shake(); - } - else - shake(); - } - else - shake(); - + + + break; + case InputKeyBack: + processing = false; + break; - break; - case InputKeyBack: - processing = false; - break; + } } - } + } osMutexRelease(box_mover->model_mutex); view_port_update(box_mover->view_port); From 42ac2fe6f7a1f70c4f83402bb680b4ceedf01c32 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Mon, 13 Jun 2022 02:11:29 -0700 Subject: [PATCH 44/91] INITIAL Video Poker - it works! It's messy! --- applications/VideoPoker/poker.c | 976 ++++++++++++++++++++++++++++- applications/applications.c | 15 +- applications/applications.mk | 7 + applications/box_mover/box_mover.c | 205 ------ scripts/User/iconencode.py | 5 +- 5 files changed, 990 insertions(+), 218 deletions(-) delete mode 100644 applications/box_mover/box_mover.c diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c index 47fc9aff3c6..61da1f22d1e 100644 --- a/applications/VideoPoker/poker.c +++ b/applications/VideoPoker/poker.c @@ -4,15 +4,973 @@ #include #include #include -#include "furi_hal_random.h" +#include +#include "assets_icons.h" +#include -// deck array -// hand array -// scoring system +/* KNOWN BUGS +This has been converted from a standalone PC console app to flipper +All of the original input/output handing code has been ripped out +Original code also used TONS of defines and everything was a global. +I have not completed cleaning up and moving globals to members. -// card faces -// splash screen/music -// win/lose music +It's not super well written but I think it at least meets a minimum expectation of quality +A lot of it could be cleaned up or optimized. +As is, it does what it wanted and doesn't seem to have major issues, so that's pretty good. +Game logic is handled during input and this is a bit of a mess of nested ifs. +Sometimes duplicate cards will show up. there is a function to test this. I should use it better. -// bet amount -// bet multi +*/ + +#define TAG "Video Poker" + +void Poker_Shaker(void) { + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); +} + +typedef struct { + int index; /* cards value, minus 1 */ + char* sym; /* text appearance */ + int suit; /* card's suit (see just below) */ + int gone; /* true if it's been dealt */ + int held; /* for hand */ +} card; + +typedef struct { + osMutexId_t* model_mutex; + osMessageQueueId_t event_queue; + ViewPort* view_port; + Gui* gui; + card hand[5]; + card shand[5]; + int held[5]; + int score; + int pot; + int GameState; + int selected; +} PokerPlayer; +/* GameState +0=Splash/help, OK button (later on up/down for rules or settings) +1=cards down, betting enabled, left/right to change bet, OK to confirm +2=first hand, holding enabled, left/right to pick card, OK to hold/unhold card, down to confirm +3=second hand, only confirm to claim rewards +4=game over/won +*/ + +card deck[52] = { + /* index, card name, suit, gone */ + /* Clubs:0 Diamonds:1 Hearts: 2 Spades: 3 */ + {1, "2", 0, 0}, {2, "3", 0, 0}, {3, "4", 0, 0}, {4, "5", 0, 0}, {5, "6", 0, 0}, + {6, "7", 0, 0}, {7, "8", 0, 0}, {8, "9", 0, 0}, {9, "10", 0, 0}, {10, "J", 0, 0}, + {11, "Q", 0, 0}, {12, "K", 0, 0}, {13, "A", 0, 0}, + + {1, "2", 1, 0}, {2, "3", 1, 0}, {3, "4", 1, 0}, {4, "5", 1, 0}, {5, "6", 1, 0}, + {6, "7", 1, 0}, {7, "8", 1, 0}, {8, "9", 1, 0}, {9, "10", 1, 0}, {10, "J", 1, 0}, + {11, "Q", 1, 0}, {12, "K", 1, 0}, {13, "A", 1, 0}, + + {1, "2", 2, 0}, {2, "3", 2, 0}, {3, "4", 2, 0}, {4, "5", 2, 0}, {5, "6", 2, 0}, + {6, "7", 2, 0}, {7, "8", 2, 0}, {8, "9", 2, 0}, {9, "10", 2, 0}, {10, "J", 2, 0}, + {11, "Q", 2, 0}, {12, "K", 2, 0}, {13, "A", 2, 0}, + + {1, "2", 3, 0}, {2, "3", 3, 0}, {3, "4", 3, 0}, {4, "5", 3, 0}, {5, "6", 3, 0}, + {6, "7", 3, 0}, {7, "8", 3, 0}, {8, "9", 3, 0}, {9, "10", 3, 0}, {10, "J", 3, 0}, + {11, "Q", 3, 0}, {12, "K", 3, 0}, {13, "A", 3, 0}, +}; +/* +Calculated Header: 0x01,0x00,0xa4,0x01 +0x01 = Compressed +0x00 = Reserved Section +0xa4,0x01 = 0x1a4, or, 420 - the size of the compressed array, minus this header. +Rest of the data is char array output from heatshrink of the original XBM char array. + +from furi_hal_compress.c +typedef struct { + uint8_t is_compressed; + uint8_t reserved; + uint16_t compressed_buff_size; +} FuriHalCompressHeader; +*/ + +const uint8_t _I_Splash_128x64_0[] = {0x01,0x00,0x8a,0x02,0x00,0x78,0x02,0x60,0xe0,0x54,0xc0,0x03,0x9f,0xc0,0x0f,0x5a,0x04,0x04,0x1e,0xdf,0x08,0x78,0x0c,0x60,0xc0,0x21,0x90,0x40,0xa3,0x00,0xf5,0xfe,0x61,0xc1,0xe9,0x1e,0x8e,0x59,0xf0,0x02,0x24,0x9f,0x70,0xc0,0x63,0x03,0x01,0x0c,0x0b,0xc1,0x80,0xbc,0x83,0xd3,0x3f,0x63,0x98,0x03,0xcf,0x88,0x02,0x1c,0x31,0x5d,0x38,0xf6,0x19,0xc0,0xa0,0xfc,0x93,0x13,0x12,0xf0,0x38,0x76,0x08,0xc7,0x00,0x1e,0x5e,0x8b,0xcc,0x32,0x86,0x0f,0x4f,0x0c,0x80,0x06,0x20,0x72,0xe4,0x5e,0x33,0xd4,0x73,0xf2,0x5d,0xe2,0x10,0xef,0xe6,0x02,0x0f,0x07,0x84,0x4c,0x33,0xd2,0x70,0x79,0xd8,0x2e,0x11,0x88,0x3d,0xff,0xc1,0xc7,0x83,0xc4,0x20,0x10,0xc9,0x18,0x3d,0x27,0x18,0x8c,0x3c,0xde,0xe1,0xe6,0x87,0x7e,0x0c,0x62,0x12,0x10,0x01,0xce,0x31,0x9c,0x39,0x9c,0x62,0x67,0x0f,0x83,0x7f,0x27,0xe0,0xf5,0x8c,0x71,0xbc,0x31,0x8c,0xc4,0xe2,0x1e,0x62,0x1e,0x02,0xe0,0x80,0x05,0x1c,0xe1,0xdc,0x23,0x97,0xc8,0xe4,0x5c,0x12,0x50,0x40,0x7a,0x43,0x38,0x77,0x88,0xf4,0x36,0x3d,0x1f,0x04,0x94,0x20,0x1e,0x98,0xce,0x0d,0xbe,0x37,0x0d,0xcd,0xbd,0x0c,0x7e,0xbe,0xce,0x07,0x1f,0xf3,0xfc,0xf8,0xb2,0x8d,0x30,0x20,0x53,0xbe,0x60,0x06,0x03,0x78,0xf0,0x06,0x4c,0x1e,0x34,0x10,0x29,0x5e,0x05,0x0f,0x00,0xa0,0x40,0x24,0x20,0x52,0x76,0x88,0x01,0xc1,0xe3,0x11,0x05,0xc3,0xe9,0x20,0x10,0x97,0x01,0xcf,0xc1,0xf2,0x81,0x3f,0xe7,0xfc,0x66,0xf4,0x02,0xf1,0xc0,0x3f,0xdf,0xf0,0x30,0xc6,0x1e,0xe5,0xff,0x81,0xf0,0x3f,0xe5,0xb2,0x80,0x7f,0xc1,0xe5,0x1c,0x03,0x0f,0xe3,0xff,0x1f,0xf8,0x02,0x48,0x00,0x31,0xfe,0x0b,0xa4,0x61,0xcc,0x62,0xfc,0x4f,0xe3,0x0f,0x31,0x41,0x0e,0x02,0x07,0x01,0x07,0x8a,0xb4,0xa3,0x84,0x71,0x8f,0xff,0x20,0x77,0x00,0x78,0x95,0x46,0x06,0x13,0x10,0x78,0xef,0x3f,0x5f,0xfc,0xff,0xea,0x07,0xf0,0x37,0x90,0x3c,0x78,0x00,0xf2,0xae,0x7f,0x77,0xf7,0xaf,0xec,0x0f,0x88,0x41,0x1b,0x06,0x02,0x03,0xc0,0x02,0x8c,0x08,0x5c,0x37,0xff,0xa9,0x3c,0x7b,0xcc,0x52,0xe0,0x70,0x7c,0x31,0x89,0xe4,0xff,0xfb,0xff,0xdf,0x8c,0x46,0x03,0x1f,0x34,0x17,0x83,0xe1,0x71,0x8f,0x6f,0xe7,0xe0,0xc1,0x8f,0xfd,0x20,0x18,0x65,0x59,0x47,0xaf,0x9b,0x8b,0x9e,0x6f,0xe7,0x1f,0x16,0x0c,0x3e,0x3d,0x00,0xe4,0x43,0xd1,0xe5,0x3f,0xe6,0x6e,0xfb,0x39,0x88,0x67,0xea,0xff,0xc5,0x22,0x8f,0xc0,0xf0,0x41,0x71,0xe7,0x76,0xf9,0x98,0x48,0x64,0x17,0x59,0x38,0x05,0x8f,0xc0,0xd0,0x5f,0xe8,0x0f,0x1a,0xdb,0xe6,0xb1,0xd1,0xa0,0x50,0x85,0x59,0x7e,0x16,0x05,0x06,0x80,0x71,0xbf,0xf7,0x19,0x85,0x99,0x74,0x6d,0x31,0x02,0x10,0x88,0x7c,0xdd,0xdb,0x84,0x62,0x7c,0x0f,0x38,0xe5,0xf0,0x1e,0x97,0xce,0x67,0xbc,0xb6,0x40,0xa3,0x98,0x00,0xc5,0x76,0x53,0x8c,0x67,0x1e,0x07,0x0e,0x63,0x0a,0xe4,0x9c,0x62,0x0f,0x11,0x41,0x95,0x88,0x1e,0x41,0xd1,0x8c,0x49,0x80,0xe6,0x00,0x50,0xb8,0xa3,0x07,0xf1,0x7f,0x06,0xb8,0x00,0x61,0xce,0xb2,0x9c,0x53,0x01,0xf3,0xf0,0x55,0x97,0xd0,0x3f,0x40,0x03,0xfd,0x33,0xc8,0x01,0x71,0x92,0x78,0x80,0x2f,0x80,0x6f,0x20,0x03,0xff,0x23,0xe7,0x02,0x02,0x18,0x01,0xa3,0x91,0x00,0x18,0xc3,0x20,0x91,0xc0,0x7c,0x7f,0x83,0x42,0xaa,0x1f,0xe0,0xbe,0x60,0x46,0xa2,0x81,0xe2,0x24,0x21,0xf9,0x54,0x14,0x18,0x9e,0x3f,0xe4,0x29,0x00,0x12,0x0e,0xb0,0x28,0x50,0x3c,0x60,0x50,0x85,0xf4,0x7f,0xb8,0x3f,0xf3,0xf8,0x83,0xe0,0x00,0x38,0x6e,0x0c,0xc3,0xf2,0x2f,0x94,0x09,0x07,0xc7,0xf7,0x3f,0xfe,0x0d,0xc4,0x00,0xfc,0x4c,0x05,0x86,0x15,0x23,0x92,0x03,0xe7,0xf9,0x80,0x0f,0x97,0x52,0x0c,0x2f,0xb1,0xf8,0xe3,0x01,0xf3,0x82,0x27,0x8d,0xe6,0x41,0x1c,0x17,0xcf,0xfc,0x3e,0x64,0xf8,}; +const uint8_t* _I_Splash_128x64[] = {_I_Splash_128x64_0}; +const Icon I_Splash_128x64 = + {.width = 128, .height = 64, .frame_count = 1, .frame_rate = 0, .frames = _I_Splash_128x64}; + +const uint8_t _I_BadEnd_128x64_0[] = { + 0x01, 0x00, 0xDF, 0x01, 0x00, 0x2c, 0x12, 0x01, 0x02, 0x80, 0x40, 0x70, 0x10, 0x0a, 0x04, 0x02, + 0x41, 0x3e, 0xcf, 0x63, 0xfb, 0xfe, 0xc8, 0x18, 0x3e, 0x6f, 0xdb, 0xfc, 0xf8, 0x3c, 0x60, 0xe0, + 0xf9, 0xb3, 0x6c, 0xf3, 0x3c, 0x1b, 0x6c, 0x18, 0x5f, 0x40, 0xf1, 0xe7, 0xdb, 0xc1, 0xf4, 0x2f, + 0x10, 0x78, 0xdb, 0xbc, 0xdf, 0xf0, 0x04, 0x59, 0x81, 0xe3, 0xc1, 0xb6, 0x41, 0x83, 0xd1, 0x00, + 0xbf, 0x6c, 0xc9, 0xe6, 0x0f, 0x91, 0xf8, 0x9b, 0xcc, 0x1f, 0x20, 0x06, 0x07, 0xf8, 0x3e, 0x0b, + 0x32, 0x00, 0x50, 0x88, 0xc4, 0x20, 0x10, 0x85, 0xfd, 0x03, 0xfc, 0x1f, 0xe0, 0xff, 0x07, 0xf9, + 0x7f, 0xc3, 0xdc, 0x89, 0x10, 0x7d, 0x00, 0x04, 0x1f, 0xe0, 0xfd, 0xfc, 0x40, 0xc1, 0xfb, 0x07, + 0x8e, 0x2f, 0xf3, 0x9f, 0x00, 0xb0, 0x7f, 0x97, 0xf6, 0x0a, 0x11, 0x10, 0xa3, 0xec, 0x10, 0x21, + 0x32, 0x07, 0xd0, 0x18, 0x40, 0xa2, 0x0f, 0xb0, 0x20, 0x81, 0xc4, 0x1f, 0xeb, 0xfa, 0xbf, 0x84, + 0x86, 0x01, 0xc8, 0x5f, 0xd0, 0x0c, 0x81, 0xe2, 0x05, 0x10, 0x7e, 0xdc, 0xc1, 0xf5, 0x01, 0xe0, + 0x41, 0xf2, 0x17, 0xf0, 0x7d, 0xaf, 0x0a, 0x7e, 0x0f, 0xbf, 0x84, 0x7f, 0x21, 0x1f, 0x2b, 0x8e, + 0x3c, 0xbe, 0xd3, 0xf0, 0x78, 0xc4, 0xfa, 0x0b, 0xf2, 0x00, 0x08, 0x81, 0xa1, 0xf3, 0x08, 0x9f, + 0xc0, 0x1e, 0x57, 0x00, 0x7b, 0x60, 0x60, 0x3e, 0x08, 0x4f, 0x80, 0x1e, 0x59, 0x05, 0xc1, 0x03, + 0xce, 0xc3, 0x00, 0x2f, 0x88, 0x3c, 0xe2, 0x10, 0x20, 0x78, 0xbd, 0xc6, 0xff, 0x7c, 0x8c, 0x0e, + 0x48, 0x1e, 0x90, 0x48, 0x47, 0xe2, 0x06, 0x1b, 0x1e, 0x3c, 0x1c, 0x1e, 0x80, 0x01, 0x93, 0xad, + 0x06, 0x1e, 0x0a, 0x28, 0x04, 0x18, 0x1e, 0x81, 0xe1, 0x90, 0x20, 0x46, 0x49, 0xa9, 0x91, 0x3e, + 0x46, 0xf8, 0x0f, 0xac, 0x48, 0x3c, 0xb0, 0x82, 0x52, 0x07, 0xa1, 0x08, 0x43, 0xe5, 0x72, 0x93, + 0x41, 0x7e, 0x01, 0x01, 0x07, 0xc7, 0x8a, 0x97, 0xa9, 0x39, 0x88, 0xa0, 0x7f, 0x00, 0xf2, 0x08, + 0x0c, 0x03, 0x25, 0x54, 0x88, 0xe9, 0x66, 0x11, 0xc2, 0x99, 0x9e, 0x07, 0xff, 0x13, 0x90, 0x7f, + 0xb2, 0x60, 0xf2, 0xaa, 0x79, 0x1b, 0xe5, 0x01, 0xfe, 0x1f, 0xca, 0x41, 0x08, 0xb0, 0xd4, 0xe2, + 0x33, 0x9c, 0x9f, 0x13, 0xff, 0x07, 0xc0, 0x0c, 0x04, 0x1e, 0x54, 0x08, 0x40, 0x64, 0x80, 0x03, + 0x84, 0xff, 0xc0, 0x68, 0x10, 0x0f, 0x80, 0x3d, 0x13, 0xc2, 0x00, 0x28, 0x25, 0xfa, 0x00, 0x0f, + 0x76, 0x60, 0x83, 0xcc, 0x04, 0x20, 0xc1, 0x07, 0xaf, 0xc8, 0x52, 0x52, 0x00, 0x7a, 0x2f, 0xcc, + 0x16, 0x31, 0x30, 0x49, 0x48, 0x17, 0xe5, 0x20, 0xc0, 0x23, 0xce, 0x81, 0x80, 0x88, 0xe6, 0x24, + 0x7c, 0x69, 0xc0, 0xd0, 0xa2, 0x1c, 0x00, 0x79, 0x85, 0x07, 0xe3, 0xa4, 0xb0, 0x4a, 0x64, 0xa0, + 0xf3, 0x57, 0x9d, 0x82, 0x01, 0x80, 0x84, 0x54, 0xb2, 0x19, 0x48, 0x91, 0x90, 0xa2, 0x1f, 0x00, + 0x79, 0x0f, 0x87, 0x80, 0x0f, 0x44, 0x21, 0x03, 0xd0, 0x3e, 0x26, 0x01, 0xa6, 0x44, 0x2c, 0x79, + 0xc0, 0x79, 0xb3, 0xc4, 0xbe, 0x5e, 0x01, 0x08, 0x80, 0x09, 0x56, 0x20, 0x01, 0x98, 0x03, 0xc4, + 0xfe, 0x51, 0x0b, 0xf8, 0x3c, 0xf8, 0x00, 0x32, 0x9c, 0x7f, 0x01, 0xe8, 0x1f, 0x40, 0x21, 0xd7, + 0x81, 0xfb, 0x80, 0xcf, 0x8f, 0x44, 0x1e, 0x7c, 0x88, 0x38, 0x28, 0x70, 0xe4, 0x92, 0xff, 0xc7, + 0xef, 0x1f, 0x80, +}; +const uint8_t* _I_BadEnd_128x64[] = {_I_BadEnd_128x64_0}; +const Icon I_BadEnd_128x64 = + {.width = 128, .height = 64, .frame_count = 1, .frame_rate = 0, .frames = _I_BadEnd_128x64}; + +const uint8_t _I_Hand_12x10_0[] = { + 0x01, 0x00, 0x11, 0x00, 0x8c, 0x40, 0x25, 0x00, 0x16, 0xb4, 0x40, + 0x35, 0x10, 0x1d, 0x5c, 0x1b, 0x5b, 0x0a, 0x84, 0xc2, 0x80, +}; +const uint8_t* _I_Hand_12x10[] = {_I_Hand_12x10_0}; +const Icon I_Hand_12x10 = + {.width = 12, .height = 10, .frame_count = 1, .frame_rate = 0, .frames = _I_Hand_12x10}; + +const uint8_t _I_CardBack_22x35_0[] = { + 0x01, 0x00, 0x23, 0x00, 0xfe, 0x7f, 0xe1, 0xf0, 0x28, 0x04, 0x43, 0xe3, 0xff, + 0x91, 0xea, 0x75, 0x52, 0x6a, 0xad, 0x56, 0x5b, 0xad, 0xd5, 0x4a, 0x80, 0xbe, + 0x05, 0xf0, 0x2f, 0x81, 0x7c, 0x0b, 0x45, 0x32, 0x2c, 0x91, 0x7c, 0x8c, 0xa4, +}; +const uint8_t* _I_CardBack_22x35[] = {_I_CardBack_22x35_0}; +const Icon I_CardBack_22x35 = + {.width = 22, .height = 35, .frame_count = 1, .frame_rate = 0, .frames = _I_CardBack_22x35}; + +//uncompressed but lol +const uint8_t _I_club_7x8_0[] = {0x00, 0x08, 0x1c, 0x1c, 0x6b, 0x7f, 0x36, 0x08, 0x1c}; +const uint8_t* _I_club_7x8[] = {_I_club_7x8_0}; +const Icon I_club_7x8 = + {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_club_7x8}; + +//uncompressed but lol +const uint8_t _I_diamond_7x8_0[] = {0x00, 0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08}; +const uint8_t* _I_diamond_7x8[] = {_I_diamond_7x8_0}; +const Icon I_diamond_7x8 = + {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_diamond_7x8}; + +//uncompressed +const uint8_t _I_hearts_7x8_0[] = {0x00, 0x00, 0x36, 0x7f, 0x7f, 0x7f, 0x3e, 0x1c, 0x08}; +const uint8_t* _I_hearts_7x8[] = {_I_hearts_7x8_0}; +const Icon I_hearts_7x8 = + {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_hearts_7x8}; + +//uncompressed +const uint8_t _I_spade_7x8_0[] = {0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x7f, 0x36, 0x08, 0x1c}; +const uint8_t* _I_spade_7x8[] = {_I_spade_7x8_0}; +const Icon I_spade_7x8 = + {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_spade_7x8}; + +const uint8_t _I_King_7x8_0[] = { + 0x01, 0x00, 0x1a, 0x00, 0xc1, 0xc0, 0xf8, 0x70, 0x1f, 0x1c, 0x02, 0xe7, 0x00, 0x9d, 0xc0, + 0x23, 0xf0, 0x08, 0x78, 0x0c, 0x80, 0xe2, 0x0b, 0x10, 0x78, 0x84, 0xc4, 0x2e, 0x20, 0x01, +}; +const uint8_t* _I_King_7x8[] = {_I_King_7x8_0}; +const Icon I_King_7x8 = + {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_King_7x8}; + +const uint8_t _I_Queen_7x8_0[] = { + 0x01, 0x00, 0x13, 0x00, 0xfe, 0x40, 0x3f, 0xd0, 0x1c, 0x3c, 0x0c, 0x01, + 0x76, 0x38, 0x1f, 0x8e, 0x07, 0xc7, 0x81, 0x85, 0x47, 0xf9, 0x01, +}; +const uint8_t* _I_Queen_7x8[] = {_I_Queen_7x8_0}; +const Icon I_Queen_7x8 = + {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Queen_7x8}; + +const uint8_t _I_Jack_7x8_0[] = { + 0x01, + 0x00, + 0x0D, + 0x00, + 0x80, + 0x40, + 0xc0, + 0x3a, + 0x00, + 0x5c, + 0x3c, + 0x0f, + 0xfd, + 0x01, + 0xfe, + 0x40, + 0x00, +}; +const uint8_t* _I_Jack_7x8[] = {_I_Jack_7x8_0}; +const Icon I_Jack_7x8 = + {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Jack_7x8}; + +const uint8_t _I_Ace_7x8_0[] = { + 0x01, 0x00, 0x13, 0x00, 0x98, 0x40, 0x2f, 0x00, 0x12, 0xe6, 0x00, 0x4b, + 0x0d, 0x01, 0x00, 0x8c, 0x0e, 0x07, 0xff, 0x00, 0x90, 0x01, 0xc0, +}; +const uint8_t* _I_Ace_7x8[] = {_I_Ace_7x8_0}; +const Icon I_Ace_7x8 = + {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Ace_7x8}; + +const uint8_t _I_Ten_7x8_0[] = { + 0x01, 0x00, 0x29, 0x00, 0x86, 0x7f, 0x00, 0x43, 0xfe, 0x80, 0xc3, 0xf0, 0xf0, 0x38, 0x7e, + 0x0e, 0x07, 0x0c, 0xe1, 0x80, 0x87, 0xc6, 0x02, 0x1b, 0x98, 0x08, 0x67, 0x60, 0x21, 0x8f, + 0x80, 0x86, 0x1e, 0x02, 0x18, 0x38, 0x08, 0x43, 0x43, 0x7f, 0x10, 0x0d, 0xfc, 0x4c, 0x20, +}; +const uint8_t* _I_Ten_7x8[] = {_I_Ten_7x8_0}; +const Icon I_Ten_7x8 = + {.width = 18, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Ten_7x8}; + +// King 26 0xc1,0xc0,0xf8,0x70,0x1f,0x1c,0x02,0xe7,0x00,0x9d,0xc0,0x23,0xf0,0x08,0x78,0x0c,0x80,0xe2,0x0b,0x10,0x78,0x84,0xc4,0x2e,0x20,0x01, +// Queen 19 0xfe,0x40,0x3f,0xd0,0x1c,0x3c,0x0c,0x01,0x76,0x38,0x1f,0x8e,0x07,0xc7,0x81,0x85,0x47,0xf9,0x01, +// Jack 13 0x80,0x40,0xc0,0x3a,0x00,0x5c,0x3c,0x0f,0xfd,0x01,0xfe,0x40,0x00, +// Ace 19 0x98,0x40,0x2f,0x00,0x12,0xe6,0x00,0x4b,0x0d,0x01,0x00,0x8c,0x0e,0x07,0xff,0x00,0x90,0x01,0xc0, +// 10 41 0x86,0x7f,0x00,0x43,0xfe,0x80,0xc3,0xf0,0xf0,0x38,0x7e,0x0e,0x07,0x0c,0xe1,0x80,0x87,0xc6,0x02,0x1b,0x98,0x08,0x67,0x60,0x21,0x8f,0x80,0x86,0x1e,0x02,0x18,0x38,0x08,0x43,0x43,0x7f,0x10,0x0d,0xfc,0x4c,0x20, + +const char* StateName[10] = { + "Intro", // should never see this + "Select Bet", // cards are face down + "Choose Cards", // cards are revealed, player can choose which to hold + "Good Luck!" // cards are replaced, payouts here. +}; + +//const uint8_t _I_Splash_128x64_0[] = { +int Poker_Title; //Have we seen the title + +const char* suitname[4] = {"C", "D", "H", "S"}; + +int score_low = 1000; +int score_high = 1000; + +int minbet = 10; +int bet = 10; + +int betmultiplier = 1; + +#define AllAmerican 0 +#define TensOrBetter 1 +#define BonusPoker 2 +#define DoubleBonus 3 +#define DoubleBonusBonus 4 +#define JacksOrBetter 5 /* default */ +#define JacksOrBetter95 6 +#define JacksOrBetter86 7 +#define JacksOrBetter85 8 +#define JacksOrBetter75 9 +#define JacksOrBetter65 10 +/* If you add another game, increment NUMGAMES: */ +#define NUMGAMES 11 + +/* + The game in play. Default is Jacks or Better, + which is coded into initialization of static data +*/ + +int game = JacksOrBetter; + +const char* gamenames[NUMGAMES] = { + "All American", + "Tens or Better", + "Bonus Poker", + "Double Bonus", + "Double Bonus Bonus", + "Jacks or Better", + "9/5 Jacks or Better", + "8/6 Jacks or Better", + "8/5 Jacks or Better", + "7/5 Jacks or Better", + "6/5 Jacks or Better"}; + +/* Sanity check: check that there are no duplicate cards in hand */ + +void playcard(PokerPlayer* app) { + int i, c, crd; + + int hold[5]; + hold[5] = 2; + // int digit; + c = 1; + c++; + c = hold[5]; /* FIX for unused-but-set-variable */ + /* initialize deck */ + for(i = 0; i < 52; i++) deck[i].gone = 0; + + /* initialize hold[] */ + for(i = 0; i < 5; i++) hold[i] = 1; + + /* app->score -= bet; */ + + for(i = 0; i < 5; i++) { + /* find a card not already dealt */ + do crd = random() % 52; + while(deck[crd].gone); + hold[i] = 1; + deck[crd].gone = 1; + if(!app->held[i]) { + app->hand[i] = deck[crd]; + } + } +} + +int check_for_dupes(PokerPlayer* app) { + int i, j; + + for(i = 0; i < 5; i++) { + for(j = i + 1; j < 5; j++) { + if(app->hand[i].index == app->hand[j].index && app->hand[i].suit == app->hand[j].suit) + return 0; + } + } + + return 1; +} + +/* Functions that recognize winning hands */ + +/* + Flush: + returns 1 if the sorted hand is a flush +*/ + +int flush(PokerPlayer* app) { + if(app->shand[0].suit == app->shand[1].suit && app->shand[1].suit == app->shand[2].suit && + app->shand[2].suit == app->shand[3].suit && app->shand[3].suit == app->shand[4].suit) + return 1; + + return 0; +} + +/* + Straight: + returns 1 if the sorted hand is a straight +*/ + +int straight(PokerPlayer* app) { + if(app->shand[1].index == app->shand[0].index + 1 && + app->shand[2].index == app->shand[1].index + 1 && + app->shand[3].index == app->shand[2].index + 1 && + app->shand[4].index == app->shand[3].index + 1) + return 1; + + /* Ace low straight: Ace, 2, 3, 4, 5 */ + + if(app->shand[4].index == 13 && app->shand[0].index == 1 && app->shand[1].index == 2 && + app->shand[2].index == 3 && app->shand[3].index == 4) + return 1; + + return 0; +} + +/* + Four of a kind: + the middle 3 all match, and the first or last matches those +*/ + +int four(PokerPlayer* app) { + if((app->shand[1].index == app->shand[2].index && + app->shand[2].index == app->shand[3].index) && + (app->shand[0].index == app->shand[2].index || app->shand[4].index == app->shand[2].index)) + return 1; + + return 0; +} + +/* + Full house: + 3 of a kind and a pair +*/ + +int full(PokerPlayer* app) { + if(app->shand[0].index == app->shand[1].index && + (app->shand[2].index == app->shand[3].index && app->shand[3].index == app->shand[4].index)) + return 1; + + if(app->shand[3].index == app->shand[4].index && + (app->shand[0].index == app->shand[1].index && app->shand[1].index == app->shand[2].index)) + return 1; + + return 0; +} + +/* + Three of a kind: + it can appear 3 ways +*/ + +int three(PokerPlayer* app) { + if(app->shand[0].index == app->shand[1].index && app->shand[1].index == app->shand[2].index) + return 1; + + if(app->shand[1].index == app->shand[2].index && app->shand[2].index == app->shand[3].index) + return 1; + + if(app->shand[2].index == app->shand[3].index && app->shand[3].index == app->shand[4].index) + return 1; + + return 0; +} + +/* + Two pair: + it can appear in 3 ways +*/ + +int twopair(PokerPlayer* app) { + if(((app->shand[0].index == app->shand[1].index) && + (app->shand[2].index == app->shand[3].index)) || + ((app->shand[0].index == app->shand[1].index) && + (app->shand[3].index == app->shand[4].index)) || + ((app->shand[1].index == app->shand[2].index) && + (app->shand[3].index == app->shand[4].index))) + return 1; + + return 0; +} + +/* + Two of a kind (pair), jacks or better + or if the game is Tens or Better, 10s or better. +*/ + +int two(PokerPlayer* app) { + int min = 10; + + if(game == TensOrBetter) min = 9; + + if(app->shand[0].index == app->shand[1].index && app->shand[1].index >= min) return 1; + if(app->shand[1].index == app->shand[2].index && app->shand[2].index >= min) return 1; + if(app->shand[2].index == app->shand[3].index && app->shand[3].index >= min) return 1; + if(app->shand[3].index == app->shand[4].index && app->shand[4].index >= min) return 1; + + return 0; +} + +int paytable[10] = { + 800, /* royal flush: 800 */ + 50, /* straight flush: 50 */ + 25, /* 4 of a kind: 25 */ + 9, /* full house: 9 */ + 6, /* flush: 6 */ + 4, /* straight: 4 */ + 3, /* 3 of a kind: 3 */ + 2, /* two pair: 2 */ + 1, /* jacks or better: 1 */ + 0 /* nothing */ +}; + +const char* handname[10] = { + "Royal Flush", + "Straight Flush", + "Four of a Kind", + "Full House", + "Flush", + "Straight", + "Three of a Kind", + "Two Pair", + "Pair", + "Nothing", +}; + +int recognize(PokerPlayer* app) { + int i, j, f = 0; + int min = 100; + card tmp[5]; + int st = 0, fl = 0; + + /* Sort hand into sorted hand (app->shand) */ + + /* make copy of hand */ + for(i = 0; i < 5; i++) tmp[i] = app->hand[i]; + + for(i = 0; i < 5; i++) { + /* put lowest card in hand into next place in app->shand */ + + for(j = 0; j < 5; j++) + if(tmp[j].index <= min) { + min = tmp[j].index; + f = j; + } + + app->shand[i] = tmp[f]; + tmp[f].index = 100; /* larger than any card */ + min = 100; + } + + /* royal and straight flushes, strait, and flush */ + + fl = flush(app); + st = straight(app); + + if(st && fl && app->shand[0].index == 9) return 0; + if(st && fl) return 1; + if(four(app)) return 2; + if(full(app)) return 3; + if(fl) return 4; + if(st) return 5; + if(three(app)) return 6; + if(twopair(app)) return 7; + if(two(app)) return 8; + + /* Nothing */ + + return 9; +} + +void poker_draw_callback(Canvas* canvas, void* ctx) { + PokerPlayer* poker_player = ctx; + furi_check(osMutexAcquire(poker_player->model_mutex, osWaitForever) == osOK); + canvas_clear(canvas); + char buffer[25]; + canvas_set_color(canvas, ColorBlack); + canvas_set_font(canvas, FontSecondary); + + /* Magic Begins */ + + /* Status Info */ + if(poker_player->GameState != 0 && poker_player->GameState != 4) { + snprintf(buffer, sizeof(buffer), "%d", poker_player->score); + canvas_draw_str_aligned(canvas, 127, 0, AlignRight, AlignTop, buffer); + } + + /* Draw the Cards */ + if(poker_player->GameState == 1) { + snprintf(buffer, sizeof(buffer), "Bet:%d", bet); + canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); + snprintf(buffer, sizeof(buffer), "<*> Place Bet"); + canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); + canvas_draw_icon(canvas, 5, 18, &I_CardBack_22x35); + + canvas_draw_icon(canvas, 29, 18, &I_CardBack_22x35); + + canvas_draw_icon(canvas, 53, 18, &I_CardBack_22x35); + + canvas_draw_icon(canvas, 77, 18, &I_CardBack_22x35); + + canvas_draw_icon(canvas, 101, 18, &I_CardBack_22x35); + + } + + else if(poker_player->GameState == 2 || poker_player->GameState == 3) { + snprintf(buffer, sizeof(buffer), "Pot:%d", bet); + canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); + snprintf(buffer, sizeof(buffer), "<*> Select Hold"); + canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); + + /* snprintf( + buffer, + sizeof(buffer), + "%s:%ix", + handname[recognize(poker_player)], + paytable[recognize(poker_player)]); + canvas_draw_str_aligned(canvas, 5, 5, AlignLeft, AlignTop, buffer); */ + + poker_player->held[0] ? canvas_draw_rbox(canvas, 5, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 5, 18, 22, 35, 3); + + poker_player->held[1] ? canvas_draw_rbox(canvas, 29, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 29, 18, 22, 35, 3); + + poker_player->held[2] ? canvas_draw_rbox(canvas, 53, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 53, 18, 22, 35, 3); + + poker_player->held[3] ? canvas_draw_rbox(canvas, 77, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 77, 18, 22, 35, 3); + + poker_player->held[4] ? canvas_draw_rbox(canvas, 101, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 101, 18, 22, 35, 3); + + //shameful + poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[0].suit == 0) // club + canvas_draw_icon(canvas, 18, 43, &I_club_7x8); + + if(poker_player->hand[0].suit == 1) // diamond + canvas_draw_icon(canvas, 18, 43, &I_diamond_7x8); + + if(poker_player->hand[0].suit == 2) // heart + canvas_draw_icon(canvas, 18, 43, &I_hearts_7x8); + + if(poker_player->hand[0].suit == 3) // spade + canvas_draw_icon(canvas, 18, 43, &I_spade_7x8); + + //canvas_draw_str_aligned(canvas, 25, 49, AlignRight, AlignBottom, buffer); + + poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[1].suit == 0) // club + canvas_draw_icon(canvas, 42, 43, &I_club_7x8); + + if(poker_player->hand[1].suit == 1) // diamond + canvas_draw_icon(canvas, 42, 43, &I_diamond_7x8); + + if(poker_player->hand[1].suit == 2) // heart + canvas_draw_icon(canvas, 42, 43, &I_hearts_7x8); + + if(poker_player->hand[1].suit == 3) // spade + canvas_draw_icon(canvas, 42, 43, &I_spade_7x8); + + //canvas_draw_str_aligned(canvas, 49, 49, AlignRight, AlignBottom, buffer); + + poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[2].suit == 0) // club + canvas_draw_icon(canvas, 66, 43, &I_club_7x8); + + if(poker_player->hand[2].suit == 1) // diamond + canvas_draw_icon(canvas, 66, 43, &I_diamond_7x8); + + if(poker_player->hand[2].suit == 2) // heart + canvas_draw_icon(canvas, 66, 43, &I_hearts_7x8); + + if(poker_player->hand[2].suit == 3) // spade + canvas_draw_icon(canvas, 66, 43, &I_spade_7x8); + + // canvas_draw_str_aligned(canvas, 73, 49, AlignRight, AlignBottom, buffer); + + poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[3].suit == 0) // club + canvas_draw_icon(canvas, 90, 43, &I_club_7x8); + + if(poker_player->hand[3].suit == 1) // diamond + canvas_draw_icon(canvas, 90, 43, &I_diamond_7x8); + + if(poker_player->hand[3].suit == 2) // heart + canvas_draw_icon(canvas, 90, 43, &I_hearts_7x8); + + if(poker_player->hand[3].suit == 3) // spade + canvas_draw_icon(canvas, 90, 43, &I_spade_7x8); + + // canvas_draw_str_aligned(canvas, 97, 49, AlignRight, AlignBottom, buffer); + + poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[4].suit == 0) // club + canvas_draw_icon(canvas, 113, 43, &I_club_7x8); + + if(poker_player->hand[4].suit == 1) // diamond + canvas_draw_icon(canvas, 113, 43, &I_diamond_7x8); + + if(poker_player->hand[4].suit == 2) // heart + canvas_draw_icon(canvas, 113, 43, &I_hearts_7x8); + + if(poker_player->hand[4].suit == 3) // spade + canvas_draw_icon(canvas, 113, 43, &I_spade_7x8); + + //canvas_draw_str_align-ed(canvas, 120, 50, AlignRight, AlignBottom, buffer); + + canvas_set_font(canvas, FontBigNumbers); + if(poker_player->hand[0].index >= 1 && poker_player->hand[0].index <= 8) { + poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[0].sym); + canvas_draw_str_aligned(canvas, 7, 22, AlignLeft, AlignTop, buffer); + } else { + poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[0].index == 9) // Ten + canvas_draw_icon(canvas, 7, 22, &I_Ten_7x8); + + if(poker_player->hand[0].index == 10) // Jack + canvas_draw_icon(canvas, 7, 22, &I_Jack_7x8); + + if(poker_player->hand[0].index == 11) // Queen + canvas_draw_icon(canvas, 7, 22, &I_Queen_7x8); + + if(poker_player->hand[0].index == 12) // King + canvas_draw_icon(canvas, 7, 22, &I_King_7x8); + + if(poker_player->hand[0].index == 13) // ace + canvas_draw_icon(canvas, 7, 22, &I_Ace_7x8); + } + if(poker_player->hand[1].index >= 0 && poker_player->hand[1].index <= 8) { + poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[1].sym); + canvas_draw_str_aligned(canvas, 31, 22, AlignLeft, AlignTop, buffer); + } else { + /* bitmap time */ + poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[1].index == 9) // Ten + canvas_draw_icon(canvas, 31, 22, &I_Ten_7x8); + + if(poker_player->hand[1].index == 10) // Jack + canvas_draw_icon(canvas, 31, 22, &I_Jack_7x8); + + if(poker_player->hand[1].index == 11) // Queen + canvas_draw_icon(canvas, 31, 22, &I_Queen_7x8); + + if(poker_player->hand[1].index == 12) // King + canvas_draw_icon(canvas, 31, 22, &I_King_7x8); + + if(poker_player->hand[1].index == 13) // ace + canvas_draw_icon(canvas, 31, 22, &I_Ace_7x8); + } + if(poker_player->hand[2].index >= 0 && poker_player->hand[2].index <= 8) { + poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[2].sym); + canvas_draw_str_aligned(canvas, 55, 22, AlignLeft, AlignTop, buffer); + } else { + /* bitmap time */ + poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[2].index == 9) // Ten + canvas_draw_icon(canvas, 55, 22, &I_Ten_7x8); + + if(poker_player->hand[2].index == 10) // Jack + canvas_draw_icon(canvas, 55, 22, &I_Jack_7x8); + + if(poker_player->hand[2].index == 11) // Queen + canvas_draw_icon(canvas, 55, 22, &I_Queen_7x8); + + if(poker_player->hand[2].index == 12) // King + canvas_draw_icon(canvas, 55, 22, &I_King_7x8); + + if(poker_player->hand[2].index == 13) // ace + canvas_draw_icon(canvas, 55, 22, &I_Ace_7x8); + } + if(poker_player->hand[3].index >= 0 && poker_player->hand[3].index <= 8) { + poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[3].sym); + canvas_draw_str_aligned(canvas, 79, 22, AlignLeft, AlignTop, buffer); + } else { + /* bitmap time */ + poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[3].index == 9) // Ten + canvas_draw_icon(canvas, 79, 22, &I_Ten_7x8); + + if(poker_player->hand[3].index == 10) // Jack + canvas_draw_icon(canvas, 79, 22, &I_Jack_7x8); + + if(poker_player->hand[3].index == 11) // Queen + canvas_draw_icon(canvas, 79, 22, &I_Queen_7x8); + + if(poker_player->hand[3].index == 12) // King + canvas_draw_icon(canvas, 79, 22, &I_King_7x8); + + if(poker_player->hand[3].index == 13) // ace + canvas_draw_icon(canvas, 79, 22, &I_Ace_7x8); + } + if(poker_player->hand[4].index >= 0 && poker_player->hand[4].index <= 8) { + poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[4].sym); + canvas_draw_str_aligned(canvas, 103, 22, AlignLeft, AlignTop, buffer); + } else { + /* bitmap time */ + poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[4].index == 9) // Ten + canvas_draw_icon(canvas, 103, 22, &I_Ten_7x8); + + if(poker_player->hand[4].index == 10) // Jack + canvas_draw_icon(canvas, 103, 22, &I_Jack_7x8); + + if(poker_player->hand[4].index == 11) // Queen + canvas_draw_icon(canvas, 103, 22, &I_Queen_7x8); + + if(poker_player->hand[4].index == 12) // King + canvas_draw_icon(canvas, 103, 22, &I_King_7x8); + + if(poker_player->hand[4].index == 13) // ace + canvas_draw_icon(canvas, 103, 22, &I_Ace_7x8); + } + + /* Draw the Select hand */ + if(poker_player->GameState == 2) { + canvas_set_color(canvas, ColorBlack); + if(poker_player->selected == 0) { + canvas_draw_icon(canvas, 11, 54, &I_Hand_12x10); + } + + if(poker_player->selected == 1) { + canvas_draw_icon(canvas, 35, 54, &I_Hand_12x10); + } + + if(poker_player->selected == 2) { + canvas_draw_icon(canvas, 58, 54, &I_Hand_12x10); + } + + if(poker_player->selected == 3) { + canvas_draw_icon(canvas, 83, 54, &I_Hand_12x10); + } + + if(poker_player->selected == 4) { + canvas_draw_icon(canvas, 109, 54, &I_Hand_12x10); + } + } + } // GameState 2 or 3 + + canvas_set_color(canvas, ColorBlack); + canvas_set_font(canvas, FontSecondary); + if(poker_player->GameState == 3) { + snprintf( + buffer, + sizeof(buffer), + "%s:%ix", + handname[recognize(poker_player)], + paytable[recognize(poker_player)]); + canvas_draw_str_aligned(canvas, 63, 63, AlignCenter, AlignBottom, buffer); + } + if(poker_player->GameState == 0) { + canvas_draw_icon(canvas, 0, 0, &I_Splash_128x64); + } + if(poker_player->GameState == 4) { + canvas_draw_icon(canvas, 0, 0, &I_BadEnd_128x64); + } + + osMutexRelease(poker_player->model_mutex); +} + +void poker_input_callback(InputEvent* input, void* ctx) { + PokerPlayer* poker_player = ctx; + osMessageQueuePut(poker_player->event_queue, input, 0, osWaitForever); +} + +PokerPlayer* poker_player_alloc() { + PokerPlayer* poker_player = malloc(sizeof(PokerPlayer)); + + poker_player->score = 1000; + poker_player->model_mutex = osMutexNew(NULL); + poker_player->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); + poker_player->view_port = view_port_alloc(); + poker_player->selected = 0; + poker_player->GameState = 0; + playcard( + poker_player); /* Get things rolling before the player gets into the game. This will preload the hand. */ + view_port_draw_callback_set(poker_player->view_port, poker_draw_callback, poker_player); + + view_port_input_callback_set(poker_player->view_port, poker_input_callback, poker_player); + + poker_player->gui = furi_record_open("gui"); + gui_add_view_port(poker_player->gui, poker_player->view_port, GuiLayerFullscreen); + + return poker_player; +} + +void poker_player_free(PokerPlayer* poker_player) { + view_port_enabled_set(poker_player->view_port, false); + gui_remove_view_port(poker_player->gui, poker_player->view_port); + furi_record_close("gui"); + view_port_free(poker_player->view_port); + osMessageQueueDelete(poker_player->event_queue); + osMutexDelete(poker_player->model_mutex); + + free(poker_player); +} + +int32_t video_poker_app(void* p) { + UNUSED(p); + PokerPlayer* poker_player = poker_player_alloc(); + + InputEvent event; + for(bool processing = true; processing;) { + osStatus_t status = osMessageQueueGet(poker_player->event_queue, &event, NULL, 100); + furi_check(osMutexAcquire(poker_player->model_mutex, osWaitForever) == osOK); + if(status == osOK) { + if(event.type == InputTypePress) { + switch(event.key) { + case InputKeyUp: + Poker_Shaker(); + break; + case InputKeyDown: + if(poker_player->GameState == 2) { + playcard(poker_player); + if(check_for_dupes(poker_player) == 0) { + playcard(poker_player); + } + + poker_player->GameState = 3; + } + break; + case InputKeyLeft: + if(poker_player->GameState == 1) { + if(bet > minbet + 10) { + bet -= 10; + } + } else if(poker_player->selected > 0 && poker_player->GameState == 2) { + poker_player->selected--; + } // Move hand left/right + else if(poker_player->selected == 0 && poker_player->GameState == 2) { + poker_player->selected = 4; //wraparound + } + break; + case InputKeyRight: + if(poker_player->GameState == 1) { + if(bet < poker_player->score + 10) { + bet += 10; + } + } + if(poker_player->selected < 4 && poker_player->GameState == 2) { + poker_player->selected++; + } // Move hand left/right + else if(poker_player->selected == 4 && poker_player->GameState == 2) { + poker_player->selected = 0; //wraparound + } + break; + case InputKeyOk: + if(poker_player->GameState == 0) { + poker_player->GameState = 1; + } else if(poker_player->GameState == 1) { + poker_player->score -= bet; + poker_player->GameState = 2; + } else if(poker_player->GameState == 2) { + poker_player->held[poker_player->selected] = + !poker_player + ->held[poker_player->selected]; //cursed and bad pls replace + } else if(poker_player->GameState == 3) { + if(recognize(poker_player) != 9) { + poker_player->score += bet * paytable[recognize(poker_player)]; + } + poker_player->GameState = 1; + if(bet > poker_player->score) { + bet = poker_player->score; + } + poker_player->held[0] = 0; + poker_player->held[1] = 0; + poker_player->held[2] = 0; + poker_player->held[3] = 0; + poker_player->held[4] = 0; + if(poker_player->score <= 0) { + poker_player->GameState = 4; + } + playcard(poker_player); // shuffle shuffle + } else if(poker_player->GameState == 4) { + Poker_Shaker(); + processing = false; + } + break; + case InputKeyBack: + processing = false; + break; + } + } + } + osMutexRelease(poker_player->model_mutex); + view_port_update(poker_player->view_port); + } + + poker_player_free(poker_player); + return 0; +} diff --git a/applications/applications.c b/applications/applications.c index ce218f2b907..4ab7633deef 100644 --- a/applications/applications.c +++ b/applications/applications.c @@ -50,7 +50,8 @@ extern int32_t music_player_app(void* p); extern int32_t snake_game_app(void* p); extern int32_t tetris_game_app(void *p); extern int32_t clock_app(void *p); -extern int32_t box_mover_app(void* p); +//extern int32_t box_mover_app(void* p); +extern int32_t video_poker_app(void* p); // extern int32_t floopper_bloopper(void* p); extern int32_t raycast_game_app(void* p); extern int32_t spectrum_analyzer_app(void* p); @@ -359,8 +360,16 @@ const FlipperApplication FLIPPER_GAMES[] = { #endif #ifdef APP_BOX_MOVER - {.app = box_mover_app, - .name = "Box Mover", + {.app = video_poker_app, + .name = "Video Poker", + .stack_size = 1024, + .icon = &A_Plugins_14, + .flags =FlipperApplicationFlagDefault}, +#endif + +#ifdef APP_VIDEO_POKER + {.app = video_poker_app, + .name = "Video Poker", .stack_size = 1024, .icon = &A_Plugins_14, .flags =FlipperApplicationFlagDefault}, diff --git a/applications/applications.mk b/applications/applications.mk index 95d124e9f3d..73d89208be8 100644 --- a/applications/applications.mk +++ b/applications/applications.mk @@ -49,6 +49,7 @@ APP_MUSIC_PLAYER = 1 APP_SNAKE_GAME = 1 APP_TETRIS_GAME = 1 APP_RAYCAST_GAME = 1 +APP_VIDEO_POKER = 1 # APP_RAYCAST_GAME = 1 APP_CLOCK = 1 APP_SPECTRUM_ANALYZER = 1 @@ -284,6 +285,12 @@ CFLAGS += -DAPP_BOX_MOVER SRV_GUI = 1 endif +APP_VIDEO_POKER ?= 0 +ifeq ($(APP_VIDEO_POKER),1) +CFLAGS += -DAPP_VIDEO_POKER +SRV_GUI = 1 +endif + APP_SPECTRUM_ANALYZER ?= 0 ifeq ($(APP_SPECTRUM_ANALYZER), 1) CFLAGS += -DAPP_SPECTRUM_ANALYZER diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c deleted file mode 100644 index eee577d77f1..00000000000 --- a/applications/box_mover/box_mover.c +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include "assets_icons.h" -#include - - -/* 0x01,0x00,0xa4,0x01 -typedef struct { - uint8_t is_compressed; - uint8_t reserved; - uint16_t compressed_buff_size; -} FuriHalCompressHeader; -*/ - -const uint8_t _I_BoxMover_128x64_0[] = {0x01,0x00,0xa4,0x01,0x00,0x78,0x03,0xc0,0x1e,0x00,0xab,0x00,0x3f,0xbf,0x90,0x30,0x29,0xfc,0x23,0xfe,0x0c,0x1e,0x0c,0x12,0x99,0xf8,0x78,0x3d,0x27,0xff,0x8c,0x78,0x3d,0x3c,0x10,0x3b,0xf0,0x3d,0x2f,0xe0,0xf1,0xe3,0x83,0xcf,0xf0,0x0a,0x18,0x08,0x3c,0xef,0x13,0xc8,0xf7,0x1c,0x10,0x71,0xf0,0x88,0xc1,0xc1,0xed,0xef,0x07,0x97,0x00,0x18,0x33,0xe9,0xf0,0x3e,0xbf,0x10,0x10,0x88,0x8c,0x84,0x1e,0xbf,0xe0,0x39,0x06,0xc4,0x7c,0x3f,0x01,0x81,0x13,0xc4,0x1e,0x98,0x03,0x60,0x84,0x46,0xf8,0x43,0x13,0xf9,0x03,0xd0,0x38,0x21,0x12,0x87,0x8c,0x08,0xfe,0x20,0xf4,0xbe,0x04,0x49,0x02,0x20,0x11,0x17,0xbc,0x78,0x22,0x41,0xd1,0xc0,0x10,0x04,0x9e,0xd7,0xe1,0x71,0x0f,0x47,0xc0,0x0f,0x5f,0x70,0x3c,0x7c,0xde,0x38,0x1a,0x04,0xaf,0x90,0x63,0xfb,0xe1,0xbf,0xe2,0xe2,0x10,0x88,0x3d,0x7c,0xe0,0xf1,0x83,0x0f,0x84,0xde,0x24,0xe1,0x07,0xaa,0xfc,0xa0,0xdf,0xce,0x08,0xb8,0x44,0x22,0x0f,0x4c,0xf3,0x7c,0xa0,0xdc,0xcf,0xb8,0x50,0x67,0xe0,0xf3,0x77,0xac,0x1a,0x18,0xfd,0x12,0x81,0x03,0xca,0x7e,0x0f,0x1c,0x18,0x3c,0xff,0x8f,0xf3,0x07,0x94,0x7f,0xc1,0x83,0x07,0xa7,0x62,0x0e,0xee,0x20,0x78,0x80,0x18,0x1e,0x31,0x8c,0xfa,0x44,0x41,0xf9,0xfc,0x17,0x08,0x3f,0x2c,0x00,0x63,0x07,0xf8,0x3f,0xff,0xdf,0xf0,0x02,0x43,0xc1,0xff,0x06,0x8e,0x03,0xfb,0xf0,0x0f,0xef,0x04,0x7c,0x1e,0x90,0xe8,0x74,0x7d,0xbc,0x3c,0x08,0x08,0x3c,0x70,0x10,0xf0,0x7b,0x43,0xe3,0x80,0xf2,0x87,0x1a,0x06,0x18,0x0f,0x68,0x3c,0x60,0x1e,0xb0,0x00,0x7a,0xc1,0xb8,0xe0,0xf1,0xfc,0x4c,0x41,0xf3,0x04,0xe3,0xce,0x3c,0x40,0xff,0x07,0xd6,0x3a,0x28,0x0f,0x31,0xfc,0x83,0xd3,0x81,0x81,0x37,0x88,0x3d,0xe2,0x00,0xf3,0x3f,0x90,0x3f,0x07,0xf4,0x0f,0x32,0x7d,0x83,0xc6,0xf1,0xf2,0x07,0xf8,0x3e,0xe3,0x20,0xf1,0xf8,0x03,0xf2,0x0e,0x0f,0x1c,0x00,0x3c,0x61,0xc0,0xf5,0x83,0x83,0xc6,0x1f,0x7c,0x07,0x9d,0xf0,0x1e,0x9e,0x08,0x18,0x3c,0x63,0xf7,0xe0,0x79,0xfc,0x20,0x20,0xf3,0xfc,0x40,0x3f,0xdf,0xf0,0x02,0x43,0xf8,0x10,0xf0,0x79,0xcf,0xc1,0xf1,0x00,0x9f,0x03,0xcb,0x81,0x07,0x07,0xcb,0x4c,0x41,0xe2,0x2e,0x10,0x7c,0x86,0xc4,0x1e,0x22,0x31,0x07,0xcc,0x02,0x3f,0x60,0x21,0x90,0x02,0xbf,0x16,0x03,0x19,0x00,0x2b,0xc1,0x63,0x41,0x90,0x02,0xc6,0x86,0x00,0xbf,0xe4,0x0c,0x1f,0xab,0xf3,0x00,0x78,0x03,0xc0,0x1f,0x00,}; -const uint8_t* _I_BoxMover_128x64[] = {_I_BoxMover_128x64_0}; -const Icon I_BoxMover_128x64 = {.width=128,.height=64,.frame_count=1,.frame_rate=0,.frames=_I_BoxMover_128x64}; -int moves; //Count moves. Text testing. -//const uint8_t _I_Splash_128x64_0[] = { -int splash; //Have we seen the title - -typedef struct { - int x; - int y; - int sizex; - int sizey; - -} BoxMoverModel; - -typedef struct { - BoxMoverModel* model; - osMutexId_t* model_mutex; - - osMessageQueueId_t event_queue; - - ViewPort* view_port; - Gui* gui; -} BoxMover; - -void shake(void){ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); - } - -void draw_callback(Canvas* canvas, void* ctx){ - - BoxMover* box_mover = ctx; - furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); - if(splash==0) - { - //canvas_draw_icon(canvas, 22, 20, &I_UsbTree_48x22); //testing :) - canvas_draw_icon(canvas, 0, 0, &I_BoxMover_128x64); - osMutexRelease(box_mover->model_mutex); // lol - } - else{ - canvas_clear(canvas); - canvas_draw_box(canvas, box_mover->model->x,box_mover->model->y, box_mover->model->sizex, box_mover->model->sizey); - char buffer[13]; - snprintf(buffer, sizeof(buffer), "Moves: %u", moves); - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontPrimary); - canvas_draw_str_aligned(canvas, 5, 5, AlignLeft, AlignTop, buffer); - osMutexRelease(box_mover->model_mutex); - } -} - -void input_callback(InputEvent* input, void* ctx){ - BoxMover* box_mover = ctx; - osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); -} - -BoxMover* box_mover_alloc(){ - BoxMover* instance = malloc(sizeof(BoxMover)); - instance->model = malloc(sizeof(BoxMoverModel)); - instance->model->x = 10; - instance->model->y = 10; - instance->model->sizex = 4; - instance->model->sizey = 4; - moves=0; - splash=0; - -instance->model_mutex = osMutexNew(NULL); - instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); - instance->view_port = view_port_alloc(); - view_port_draw_callback_set(instance->view_port, draw_callback, instance); - - view_port_input_callback_set(instance->view_port, input_callback, instance); - - - instance->gui = furi_record_open("gui"); - gui_add_view_port(instance->gui, instance->view_port, GuiLayerFullscreen); - - - - return instance; -} - -void box_mover_free(BoxMover* instance){ - view_port_enabled_set(instance->view_port,false); - gui_remove_view_port(instance->gui, instance->view_port); - furi_record_close("gui"); - view_port_free(instance->view_port); - osMessageQueueDelete(instance->event_queue); - osMutexDelete(instance->model_mutex); - - free(instance->model); - free(instance); -} - - -int32_t box_mover_app(void* p){ - UNUSED(p); - BoxMover* box_mover = box_mover_alloc(); - - - InputEvent event; - for(bool processing = true; processing;){ - osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); - furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); - if(status==osOK){ - if(event.type==InputTypePress){ - if(splash==0){splash=1;} - switch(event.key){ - case InputKeyUp: - if (box_mover->model->y >= 1){ - box_mover->model->y-=2; - moves++; - } - else{ - shake(); - } - break; - case InputKeyDown: - if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ // So we're trying to see if it's even or odd, to determine how much to offset the bounds check by, since we're doing this based of the square origin+its size. idk. - box_mover->model->y+=2; - moves++; - } - else{ - shake(); - } - break; - case InputKeyLeft: - if (box_mover->model->x >= 1){ - box_mover->model->x-=2; - moves++; - } - else{ - shake(); - } - break; - case InputKeyRight: - if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ - box_mover->model->x+=2; - moves++; - } - else{ - shake(); - } - break; - case InputKeyOk: - if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ - if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ - if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ - box_mover->model->sizex+=1; - box_mover->model->sizey+=1; - //TODO - also check the box will not grow past boundary. - } - else - shake(); - } - else - shake(); - } - else - shake(); - - - break; - case InputKeyBack: - processing = false; - break; - - } - } - - } - osMutexRelease(box_mover->model_mutex); - view_port_update(box_mover->view_port); - } - - - - box_mover_free(box_mover); - return 0; -} - - - - diff --git a/scripts/User/iconencode.py b/scripts/User/iconencode.py index 409327c2058..67ba05d1baf 100644 --- a/scripts/User/iconencode.py +++ b/scripts/User/iconencode.py @@ -54,7 +54,10 @@ def padded_hex(i, l): # a bit ugly. framename="_I_"+infile+"_"+dims - +print(len(b)) +#d=len(b) +# if b > 255 split 0x1234 into 0x34,0x12 +#d=hex(len(b)) char_out = "const uint8_t "+framename+"_0[] = {"+ str(c) + ",};" char_out2 = "const uint8_t "+framename+"[] = {"+framename+"_0};" From 8d439c4cb02c9f98945f204e6e12e99abd30f4f6 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Mon, 13 Jun 2022 11:10:05 -0700 Subject: [PATCH 45/91] Still a bit messy. But it seems to be good now. --- applications/VideoPoker/poker.c | 117 ++++++++++++++++++++++---------- 1 file changed, 82 insertions(+), 35 deletions(-) diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c index 61da1f22d1e..1b625250068 100644 --- a/applications/VideoPoker/poker.c +++ b/applications/VideoPoker/poker.c @@ -19,7 +19,7 @@ A lot of it could be cleaned up or optimized. As is, it does what it wanted and doesn't seem to have major issues, so that's pretty good. Game logic is handled during input and this is a bit of a mess of nested ifs. Sometimes duplicate cards will show up. there is a function to test this. I should use it better. - +After losing, bet is set to 10 eve */ #define TAG "Video Poker" @@ -45,19 +45,16 @@ typedef struct { Gui* gui; card hand[5]; card shand[5]; + card deck[52]; int held[5]; int score; int pot; int GameState; int selected; + int bet; + int minbet; } PokerPlayer; -/* GameState -0=Splash/help, OK button (later on up/down for rules or settings) -1=cards down, betting enabled, left/right to change bet, OK to confirm -2=first hand, holding enabled, left/right to pick card, OK to hold/unhold card, down to confirm -3=second hand, only confirm to claim rewards -4=game over/won -*/ + card deck[52] = { /* index, card name, suit, gone */ @@ -78,13 +75,27 @@ card deck[52] = { {6, "7", 3, 0}, {7, "8", 3, 0}, {8, "9", 3, 0}, {9, "10", 3, 0}, {10, "J", 3, 0}, {11, "Q", 3, 0}, {12, "K", 3, 0}, {13, "A", 3, 0}, }; +/* +int score_low = 1000; + int score_high = 1000; + int minbet = 10; + int betmultiplier = 1; + */ +/* GameState +0=Splash/help, OK button (later on up/down for rules or settings) +1=cards down, betting enabled, left/right to change bet, OK to confirm +2=first hand, holding enabled, left/right to pick card, OK to hold/unhold card, down to confirm +3=second hand, only confirm to claim rewards +4=game over/won +*/ + /* -Calculated Header: 0x01,0x00,0xa4,0x01 +Image Format 0x01 = Compressed 0x00 = Reserved Section 0xa4,0x01 = 0x1a4, or, 420 - the size of the compressed array, minus this header. Rest of the data is char array output from heatshrink of the original XBM char array. - +Calculated Header: 0x01,0x00,0xa4,0x01 from furi_hal_compress.c typedef struct { uint8_t is_compressed; @@ -93,7 +104,49 @@ typedef struct { } FuriHalCompressHeader; */ -const uint8_t _I_Splash_128x64_0[] = {0x01,0x00,0x8a,0x02,0x00,0x78,0x02,0x60,0xe0,0x54,0xc0,0x03,0x9f,0xc0,0x0f,0x5a,0x04,0x04,0x1e,0xdf,0x08,0x78,0x0c,0x60,0xc0,0x21,0x90,0x40,0xa3,0x00,0xf5,0xfe,0x61,0xc1,0xe9,0x1e,0x8e,0x59,0xf0,0x02,0x24,0x9f,0x70,0xc0,0x63,0x03,0x01,0x0c,0x0b,0xc1,0x80,0xbc,0x83,0xd3,0x3f,0x63,0x98,0x03,0xcf,0x88,0x02,0x1c,0x31,0x5d,0x38,0xf6,0x19,0xc0,0xa0,0xfc,0x93,0x13,0x12,0xf0,0x38,0x76,0x08,0xc7,0x00,0x1e,0x5e,0x8b,0xcc,0x32,0x86,0x0f,0x4f,0x0c,0x80,0x06,0x20,0x72,0xe4,0x5e,0x33,0xd4,0x73,0xf2,0x5d,0xe2,0x10,0xef,0xe6,0x02,0x0f,0x07,0x84,0x4c,0x33,0xd2,0x70,0x79,0xd8,0x2e,0x11,0x88,0x3d,0xff,0xc1,0xc7,0x83,0xc4,0x20,0x10,0xc9,0x18,0x3d,0x27,0x18,0x8c,0x3c,0xde,0xe1,0xe6,0x87,0x7e,0x0c,0x62,0x12,0x10,0x01,0xce,0x31,0x9c,0x39,0x9c,0x62,0x67,0x0f,0x83,0x7f,0x27,0xe0,0xf5,0x8c,0x71,0xbc,0x31,0x8c,0xc4,0xe2,0x1e,0x62,0x1e,0x02,0xe0,0x80,0x05,0x1c,0xe1,0xdc,0x23,0x97,0xc8,0xe4,0x5c,0x12,0x50,0x40,0x7a,0x43,0x38,0x77,0x88,0xf4,0x36,0x3d,0x1f,0x04,0x94,0x20,0x1e,0x98,0xce,0x0d,0xbe,0x37,0x0d,0xcd,0xbd,0x0c,0x7e,0xbe,0xce,0x07,0x1f,0xf3,0xfc,0xf8,0xb2,0x8d,0x30,0x20,0x53,0xbe,0x60,0x06,0x03,0x78,0xf0,0x06,0x4c,0x1e,0x34,0x10,0x29,0x5e,0x05,0x0f,0x00,0xa0,0x40,0x24,0x20,0x52,0x76,0x88,0x01,0xc1,0xe3,0x11,0x05,0xc3,0xe9,0x20,0x10,0x97,0x01,0xcf,0xc1,0xf2,0x81,0x3f,0xe7,0xfc,0x66,0xf4,0x02,0xf1,0xc0,0x3f,0xdf,0xf0,0x30,0xc6,0x1e,0xe5,0xff,0x81,0xf0,0x3f,0xe5,0xb2,0x80,0x7f,0xc1,0xe5,0x1c,0x03,0x0f,0xe3,0xff,0x1f,0xf8,0x02,0x48,0x00,0x31,0xfe,0x0b,0xa4,0x61,0xcc,0x62,0xfc,0x4f,0xe3,0x0f,0x31,0x41,0x0e,0x02,0x07,0x01,0x07,0x8a,0xb4,0xa3,0x84,0x71,0x8f,0xff,0x20,0x77,0x00,0x78,0x95,0x46,0x06,0x13,0x10,0x78,0xef,0x3f,0x5f,0xfc,0xff,0xea,0x07,0xf0,0x37,0x90,0x3c,0x78,0x00,0xf2,0xae,0x7f,0x77,0xf7,0xaf,0xec,0x0f,0x88,0x41,0x1b,0x06,0x02,0x03,0xc0,0x02,0x8c,0x08,0x5c,0x37,0xff,0xa9,0x3c,0x7b,0xcc,0x52,0xe0,0x70,0x7c,0x31,0x89,0xe4,0xff,0xfb,0xff,0xdf,0x8c,0x46,0x03,0x1f,0x34,0x17,0x83,0xe1,0x71,0x8f,0x6f,0xe7,0xe0,0xc1,0x8f,0xfd,0x20,0x18,0x65,0x59,0x47,0xaf,0x9b,0x8b,0x9e,0x6f,0xe7,0x1f,0x16,0x0c,0x3e,0x3d,0x00,0xe4,0x43,0xd1,0xe5,0x3f,0xe6,0x6e,0xfb,0x39,0x88,0x67,0xea,0xff,0xc5,0x22,0x8f,0xc0,0xf0,0x41,0x71,0xe7,0x76,0xf9,0x98,0x48,0x64,0x17,0x59,0x38,0x05,0x8f,0xc0,0xd0,0x5f,0xe8,0x0f,0x1a,0xdb,0xe6,0xb1,0xd1,0xa0,0x50,0x85,0x59,0x7e,0x16,0x05,0x06,0x80,0x71,0xbf,0xf7,0x19,0x85,0x99,0x74,0x6d,0x31,0x02,0x10,0x88,0x7c,0xdd,0xdb,0x84,0x62,0x7c,0x0f,0x38,0xe5,0xf0,0x1e,0x97,0xce,0x67,0xbc,0xb6,0x40,0xa3,0x98,0x00,0xc5,0x76,0x53,0x8c,0x67,0x1e,0x07,0x0e,0x63,0x0a,0xe4,0x9c,0x62,0x0f,0x11,0x41,0x95,0x88,0x1e,0x41,0xd1,0x8c,0x49,0x80,0xe6,0x00,0x50,0xb8,0xa3,0x07,0xf1,0x7f,0x06,0xb8,0x00,0x61,0xce,0xb2,0x9c,0x53,0x01,0xf3,0xf0,0x55,0x97,0xd0,0x3f,0x40,0x03,0xfd,0x33,0xc8,0x01,0x71,0x92,0x78,0x80,0x2f,0x80,0x6f,0x20,0x03,0xff,0x23,0xe7,0x02,0x02,0x18,0x01,0xa3,0x91,0x00,0x18,0xc3,0x20,0x91,0xc0,0x7c,0x7f,0x83,0x42,0xaa,0x1f,0xe0,0xbe,0x60,0x46,0xa2,0x81,0xe2,0x24,0x21,0xf9,0x54,0x14,0x18,0x9e,0x3f,0xe4,0x29,0x00,0x12,0x0e,0xb0,0x28,0x50,0x3c,0x60,0x50,0x85,0xf4,0x7f,0xb8,0x3f,0xf3,0xf8,0x83,0xe0,0x00,0x38,0x6e,0x0c,0xc3,0xf2,0x2f,0x94,0x09,0x07,0xc7,0xf7,0x3f,0xfe,0x0d,0xc4,0x00,0xfc,0x4c,0x05,0x86,0x15,0x23,0x92,0x03,0xe7,0xf9,0x80,0x0f,0x97,0x52,0x0c,0x2f,0xb1,0xf8,0xe3,0x01,0xf3,0x82,0x27,0x8d,0xe6,0x41,0x1c,0x17,0xcf,0xfc,0x3e,0x64,0xf8,}; +const uint8_t _I_Splash_128x64_0[] = { + 0x01, 0x00, 0x8a, 0x02, 0x00, 0x78, 0x02, 0x60, 0xe0, 0x54, 0xc0, 0x03, 0x9f, 0xc0, 0x0f, 0x5a, + 0x04, 0x04, 0x1e, 0xdf, 0x08, 0x78, 0x0c, 0x60, 0xc0, 0x21, 0x90, 0x40, 0xa3, 0x00, 0xf5, 0xfe, + 0x61, 0xc1, 0xe9, 0x1e, 0x8e, 0x59, 0xf0, 0x02, 0x24, 0x9f, 0x70, 0xc0, 0x63, 0x03, 0x01, 0x0c, + 0x0b, 0xc1, 0x80, 0xbc, 0x83, 0xd3, 0x3f, 0x63, 0x98, 0x03, 0xcf, 0x88, 0x02, 0x1c, 0x31, 0x5d, + 0x38, 0xf6, 0x19, 0xc0, 0xa0, 0xfc, 0x93, 0x13, 0x12, 0xf0, 0x38, 0x76, 0x08, 0xc7, 0x00, 0x1e, + 0x5e, 0x8b, 0xcc, 0x32, 0x86, 0x0f, 0x4f, 0x0c, 0x80, 0x06, 0x20, 0x72, 0xe4, 0x5e, 0x33, 0xd4, + 0x73, 0xf2, 0x5d, 0xe2, 0x10, 0xef, 0xe6, 0x02, 0x0f, 0x07, 0x84, 0x4c, 0x33, 0xd2, 0x70, 0x79, + 0xd8, 0x2e, 0x11, 0x88, 0x3d, 0xff, 0xc1, 0xc7, 0x83, 0xc4, 0x20, 0x10, 0xc9, 0x18, 0x3d, 0x27, + 0x18, 0x8c, 0x3c, 0xde, 0xe1, 0xe6, 0x87, 0x7e, 0x0c, 0x62, 0x12, 0x10, 0x01, 0xce, 0x31, 0x9c, + 0x39, 0x9c, 0x62, 0x67, 0x0f, 0x83, 0x7f, 0x27, 0xe0, 0xf5, 0x8c, 0x71, 0xbc, 0x31, 0x8c, 0xc4, + 0xe2, 0x1e, 0x62, 0x1e, 0x02, 0xe0, 0x80, 0x05, 0x1c, 0xe1, 0xdc, 0x23, 0x97, 0xc8, 0xe4, 0x5c, + 0x12, 0x50, 0x40, 0x7a, 0x43, 0x38, 0x77, 0x88, 0xf4, 0x36, 0x3d, 0x1f, 0x04, 0x94, 0x20, 0x1e, + 0x98, 0xce, 0x0d, 0xbe, 0x37, 0x0d, 0xcd, 0xbd, 0x0c, 0x7e, 0xbe, 0xce, 0x07, 0x1f, 0xf3, 0xfc, + 0xf8, 0xb2, 0x8d, 0x30, 0x20, 0x53, 0xbe, 0x60, 0x06, 0x03, 0x78, 0xf0, 0x06, 0x4c, 0x1e, 0x34, + 0x10, 0x29, 0x5e, 0x05, 0x0f, 0x00, 0xa0, 0x40, 0x24, 0x20, 0x52, 0x76, 0x88, 0x01, 0xc1, 0xe3, + 0x11, 0x05, 0xc3, 0xe9, 0x20, 0x10, 0x97, 0x01, 0xcf, 0xc1, 0xf2, 0x81, 0x3f, 0xe7, 0xfc, 0x66, + 0xf4, 0x02, 0xf1, 0xc0, 0x3f, 0xdf, 0xf0, 0x30, 0xc6, 0x1e, 0xe5, 0xff, 0x81, 0xf0, 0x3f, 0xe5, + 0xb2, 0x80, 0x7f, 0xc1, 0xe5, 0x1c, 0x03, 0x0f, 0xe3, 0xff, 0x1f, 0xf8, 0x02, 0x48, 0x00, 0x31, + 0xfe, 0x0b, 0xa4, 0x61, 0xcc, 0x62, 0xfc, 0x4f, 0xe3, 0x0f, 0x31, 0x41, 0x0e, 0x02, 0x07, 0x01, + 0x07, 0x8a, 0xb4, 0xa3, 0x84, 0x71, 0x8f, 0xff, 0x20, 0x77, 0x00, 0x78, 0x95, 0x46, 0x06, 0x13, + 0x10, 0x78, 0xef, 0x3f, 0x5f, 0xfc, 0xff, 0xea, 0x07, 0xf0, 0x37, 0x90, 0x3c, 0x78, 0x00, 0xf2, + 0xae, 0x7f, 0x77, 0xf7, 0xaf, 0xec, 0x0f, 0x88, 0x41, 0x1b, 0x06, 0x02, 0x03, 0xc0, 0x02, 0x8c, + 0x08, 0x5c, 0x37, 0xff, 0xa9, 0x3c, 0x7b, 0xcc, 0x52, 0xe0, 0x70, 0x7c, 0x31, 0x89, 0xe4, 0xff, + 0xfb, 0xff, 0xdf, 0x8c, 0x46, 0x03, 0x1f, 0x34, 0x17, 0x83, 0xe1, 0x71, 0x8f, 0x6f, 0xe7, 0xe0, + 0xc1, 0x8f, 0xfd, 0x20, 0x18, 0x65, 0x59, 0x47, 0xaf, 0x9b, 0x8b, 0x9e, 0x6f, 0xe7, 0x1f, 0x16, + 0x0c, 0x3e, 0x3d, 0x00, 0xe4, 0x43, 0xd1, 0xe5, 0x3f, 0xe6, 0x6e, 0xfb, 0x39, 0x88, 0x67, 0xea, + 0xff, 0xc5, 0x22, 0x8f, 0xc0, 0xf0, 0x41, 0x71, 0xe7, 0x76, 0xf9, 0x98, 0x48, 0x64, 0x17, 0x59, + 0x38, 0x05, 0x8f, 0xc0, 0xd0, 0x5f, 0xe8, 0x0f, 0x1a, 0xdb, 0xe6, 0xb1, 0xd1, 0xa0, 0x50, 0x85, + 0x59, 0x7e, 0x16, 0x05, 0x06, 0x80, 0x71, 0xbf, 0xf7, 0x19, 0x85, 0x99, 0x74, 0x6d, 0x31, 0x02, + 0x10, 0x88, 0x7c, 0xdd, 0xdb, 0x84, 0x62, 0x7c, 0x0f, 0x38, 0xe5, 0xf0, 0x1e, 0x97, 0xce, 0x67, + 0xbc, 0xb6, 0x40, 0xa3, 0x98, 0x00, 0xc5, 0x76, 0x53, 0x8c, 0x67, 0x1e, 0x07, 0x0e, 0x63, 0x0a, + 0xe4, 0x9c, 0x62, 0x0f, 0x11, 0x41, 0x95, 0x88, 0x1e, 0x41, 0xd1, 0x8c, 0x49, 0x80, 0xe6, 0x00, + 0x50, 0xb8, 0xa3, 0x07, 0xf1, 0x7f, 0x06, 0xb8, 0x00, 0x61, 0xce, 0xb2, 0x9c, 0x53, 0x01, 0xf3, + 0xf0, 0x55, 0x97, 0xd0, 0x3f, 0x40, 0x03, 0xfd, 0x33, 0xc8, 0x01, 0x71, 0x92, 0x78, 0x80, 0x2f, + 0x80, 0x6f, 0x20, 0x03, 0xff, 0x23, 0xe7, 0x02, 0x02, 0x18, 0x01, 0xa3, 0x91, 0x00, 0x18, 0xc3, + 0x20, 0x91, 0xc0, 0x7c, 0x7f, 0x83, 0x42, 0xaa, 0x1f, 0xe0, 0xbe, 0x60, 0x46, 0xa2, 0x81, 0xe2, + 0x24, 0x21, 0xf9, 0x54, 0x14, 0x18, 0x9e, 0x3f, 0xe4, 0x29, 0x00, 0x12, 0x0e, 0xb0, 0x28, 0x50, + 0x3c, 0x60, 0x50, 0x85, 0xf4, 0x7f, 0xb8, 0x3f, 0xf3, 0xf8, 0x83, 0xe0, 0x00, 0x38, 0x6e, 0x0c, + 0xc3, 0xf2, 0x2f, 0x94, 0x09, 0x07, 0xc7, 0xf7, 0x3f, 0xfe, 0x0d, 0xc4, 0x00, 0xfc, 0x4c, 0x05, + 0x86, 0x15, 0x23, 0x92, 0x03, 0xe7, 0xf9, 0x80, 0x0f, 0x97, 0x52, 0x0c, 0x2f, 0xb1, 0xf8, 0xe3, + 0x01, 0xf3, 0x82, 0x27, 0x8d, 0xe6, 0x41, 0x1c, 0x17, 0xcf, 0xfc, 0x3e, 0x64, 0xf8, +}; const uint8_t* _I_Splash_128x64[] = {_I_Splash_128x64_0}; const Icon I_Splash_128x64 = {.width = 128, .height = 64, .frame_count = 1, .frame_rate = 0, .frames = _I_Splash_128x64}; @@ -176,6 +229,8 @@ const uint8_t* _I_spade_7x8[] = {_I_spade_7x8_0}; const Icon I_spade_7x8 = {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_spade_7x8}; +// They only included Numeric Profont22 glyphs and I don't want to fuck up the font embeds right now sooo.. + const uint8_t _I_King_7x8_0[] = { 0x01, 0x00, 0x1a, 0x00, 0xc1, 0xc0, 0xf8, 0x70, 0x1f, 0x1c, 0x02, 0xe7, 0x00, 0x9d, 0xc0, 0x23, 0xf0, 0x08, 0x78, 0x0c, 0x80, 0xe2, 0x0b, 0x10, 0x78, 0x84, 0xc4, 0x2e, 0x20, 0x01, @@ -232,13 +287,8 @@ const uint8_t* _I_Ten_7x8[] = {_I_Ten_7x8_0}; const Icon I_Ten_7x8 = {.width = 18, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Ten_7x8}; -// King 26 0xc1,0xc0,0xf8,0x70,0x1f,0x1c,0x02,0xe7,0x00,0x9d,0xc0,0x23,0xf0,0x08,0x78,0x0c,0x80,0xe2,0x0b,0x10,0x78,0x84,0xc4,0x2e,0x20,0x01, -// Queen 19 0xfe,0x40,0x3f,0xd0,0x1c,0x3c,0x0c,0x01,0x76,0x38,0x1f,0x8e,0x07,0xc7,0x81,0x85,0x47,0xf9,0x01, -// Jack 13 0x80,0x40,0xc0,0x3a,0x00,0x5c,0x3c,0x0f,0xfd,0x01,0xfe,0x40,0x00, -// Ace 19 0x98,0x40,0x2f,0x00,0x12,0xe6,0x00,0x4b,0x0d,0x01,0x00,0x8c,0x0e,0x07,0xff,0x00,0x90,0x01,0xc0, -// 10 41 0x86,0x7f,0x00,0x43,0xfe,0x80,0xc3,0xf0,0xf0,0x38,0x7e,0x0e,0x07,0x0c,0xe1,0x80,0x87,0xc6,0x02,0x1b,0x98,0x08,0x67,0x60,0x21,0x8f,0x80,0x86,0x1e,0x02,0x18,0x38,0x08,0x43,0x43,0x7f,0x10,0x0d,0xfc,0x4c,0x20, - const char* StateName[10] = { + /* use this for the status line and put in better wording */ "Intro", // should never see this "Select Bet", // cards are face down "Choose Cards", // cards are revealed, player can choose which to hold @@ -250,14 +300,6 @@ int Poker_Title; //Have we seen the title const char* suitname[4] = {"C", "D", "H", "S"}; -int score_low = 1000; -int score_high = 1000; - -int minbet = 10; -int bet = 10; - -int betmultiplier = 1; - #define AllAmerican 0 #define TensOrBetter 1 #define BonusPoker 2 @@ -545,7 +587,7 @@ void poker_draw_callback(Canvas* canvas, void* ctx) { /* Draw the Cards */ if(poker_player->GameState == 1) { - snprintf(buffer, sizeof(buffer), "Bet:%d", bet); + snprintf(buffer, sizeof(buffer), "Bet:%d", poker_player->bet); canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); snprintf(buffer, sizeof(buffer), "<*> Place Bet"); canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); @@ -562,7 +604,7 @@ void poker_draw_callback(Canvas* canvas, void* ctx) { } else if(poker_player->GameState == 2 || poker_player->GameState == 3) { - snprintf(buffer, sizeof(buffer), "Pot:%d", bet); + snprintf(buffer, sizeof(buffer), "Pot:%d", poker_player->bet); canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); snprintf(buffer, sizeof(buffer), "<*> Select Hold"); canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); @@ -857,6 +899,9 @@ PokerPlayer* poker_player_alloc() { poker_player->view_port = view_port_alloc(); poker_player->selected = 0; poker_player->GameState = 0; + poker_player->bet = 10; + poker_player->minbet = 10; + playcard( poker_player); /* Get things rolling before the player gets into the game. This will preload the hand. */ view_port_draw_callback_set(poker_player->view_port, poker_draw_callback, poker_player); @@ -906,8 +951,8 @@ int32_t video_poker_app(void* p) { break; case InputKeyLeft: if(poker_player->GameState == 1) { - if(bet > minbet + 10) { - bet -= 10; + if(poker_player->bet >= poker_player->minbet + 10) { + poker_player->bet -= 10; } } else if(poker_player->selected > 0 && poker_player->GameState == 2) { poker_player->selected--; @@ -918,8 +963,8 @@ int32_t video_poker_app(void* p) { break; case InputKeyRight: if(poker_player->GameState == 1) { - if(bet < poker_player->score + 10) { - bet += 10; + if(poker_player->bet < poker_player->score + 10) { + poker_player->bet += 10; } } if(poker_player->selected < 4 && poker_player->GameState == 2) { @@ -933,7 +978,7 @@ int32_t video_poker_app(void* p) { if(poker_player->GameState == 0) { poker_player->GameState = 1; } else if(poker_player->GameState == 1) { - poker_player->score -= bet; + poker_player->score -= poker_player->bet; poker_player->GameState = 2; } else if(poker_player->GameState == 2) { poker_player->held[poker_player->selected] = @@ -941,11 +986,12 @@ int32_t video_poker_app(void* p) { ->held[poker_player->selected]; //cursed and bad pls replace } else if(poker_player->GameState == 3) { if(recognize(poker_player) != 9) { - poker_player->score += bet * paytable[recognize(poker_player)]; + poker_player->score += + poker_player->bet * paytable[recognize(poker_player)]; } poker_player->GameState = 1; - if(bet > poker_player->score) { - bet = poker_player->score; + if(poker_player->bet > poker_player->score) { + poker_player->bet = poker_player->score; } poker_player->held[0] = 0; poker_player->held[1] = 0; @@ -974,3 +1020,4 @@ int32_t video_poker_app(void* p) { poker_player_free(poker_player); return 0; } + From 19e5dc29b12bbd057204c4635e840f2174c6e467 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 10 Jun 2022 01:02:10 -0700 Subject: [PATCH 46/91] Update README.md --- README.md | 76 ++++--------------------------------------------------- 1 file changed, 5 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index 88d19cdcbe3..be0bf3d1f31 100644 --- a/README.md +++ b/README.md @@ -1,73 +1,7 @@ -# [Flipper Zero Firmware](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/ReadMe.md) <= READ THIS READ ME -- ****This software is for experimental purposes only and is not meant for any illegal activity/purposes. We do not condone illegal activity and strongly encourage keeping transmissions to legal/valid uses allowed by law.** -- FLASH STOCK FIRST BEFORE UPDATING TO CUSTOM FIRMWARE -- BUILD WITH COMPACT FLAG SINCE IT IS TOO LARGE -- CH0NG, CH33CH and N00BY rename your flipper. +Do not use this. +Go for an upstream project. +This is a personal sandbox/learning/testing build. -# Clone the Repository +Anything I think is worthwhile will become PR -You should clone with -```shell -$ git clone --recursive https://github.com/RogueMaster/flipperzero-firmware-wPlugins.git -$ docker-compose up -d -$ docker-compose exec dev make DEBUG=0 COMPACT=1 -``` - -Latest Updates: -- Latest DEV changes -- Fixed Actual PIN Lock (By RogueMaster) -- Added [Chip8 Emulator (By mega8bit)](https://github.com/mega8bit/flipperzero-firmware) Updated by ESurge To Work. -- - Add a folder to SD card named `chip8` -- - [Get GAMES HERE](https://johnearnest.github.io/chip8Archive/) -- - Let us know if you got any to work by submitting an Issue! LOL -- Updated [assets/resources/nfc/assets/mf_classic_dict.nfc](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/nfc/assets/mf_classic_dict.nfc) -- Added [RayCast (Bt Zlo)](https://github.com/flipperdevices/flipperzero-firmware/tree/zlo/raycast-game-engine) (Restart To Exit) - -**Special Instructions:** -- Download these files into the subghz/assets folder on your SD card. Edit the two `_map` files to contain your specific subghz (.SUB) files. -- - Note 1: If you don't have a subghz/assets folder, you should ensure you have made at least one clean flash with stock firmware and your SD card installed in order to ensure the database structure is built, otherwise it will not exist for alternative forks. -- - Note 2: /any is a special keyword signifying either /int (internal storage) or /ext (external storage). -- - Note 3: the changes you are making to the `_map` files is to point to the location of the specific assets of the touchtunes folder as well as the universal RF map apps which you will have to develop or compile seperately and are not a part of this repo. -- - Note 4: /any is effectively root, so the folder structure should start "/any/subghz/assets" and not what is based on the repo below do not blindly copy the repo it will not work. -- - [assets/resources/subghz/assets/universal_rf_map](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/subghz/assets/universal_rf_map) -- - [assets/resources/subghz/assets/touchtunes_map](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/subghz/assets/touchtunes_map) -- - [assets/resources/subghz/assets/setting_user](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/subghz/assets/setting_user) -- Download this file into the nfc/assets folder on your SD card. -- - [assets/resources/nfc/assets/mf_classic_dict.nfc](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/nfc/assets/mf_classic_dict.nfc) -- Add a folder to SD card named `wav_player` (for 8bit 2ch unsigned wav files) -- Add a folder to SD card named `music_player` (FMF and RTTTL/TXT files) - -Special shout out to these libraries for giving us more fun: -- https://github.com/Gioman101/FlipperAmiibo -- https://github.com/jimilinuxguy/flipperzero-touchtunes -- https://github.com/Lucaslhm/AmiiboFlipperConverter -- https://github.com/MuddledBox/FlipperZeroCases -- https://github.com/MuddledBox/FlipperZeroSub-GHz -- https://github.com/neverfa11ing/FlipperMusicRTTTL -- https://github.com/UberGuidoZ/Flipper -- https://github.com/UberGuidoZ/Flipper-IRDB -- https://johnearnest.github.io/chip8Archive/ - -Added Features: -- Actual PIN Lock (By RogueMaster) -- Added 90s Timeout for Backlight Time (By RogueMaster) -- Keeloq update from [Xorist](https://github.com/xorist/FlipperX) -- Added New SubGHZ Scanning image with Pikachu [Thanks to Panzer00Z](https://github.com/Panzer00Z/flipperzero-firmware/blob/3a548ea9bb181c9348d8afb427890c411456134e/assets/icons/SubGhz/Scanning_123x52.png) - -Plugins: -- [Chip8 Emulator (By mega8bit)](https://github.com/mega8bit/flipperzero-firmware) Updated by ESurge To Work. -- [Clock/Stopwatch (By CompaqDisc, Stopwatch & Sound Alert By RogueMaster)](https://gist.github.com/CompaqDisc/4e329c501bd03c1e801849b81f48ea61) -- [Dice Roller Including SEX/WAR/8BALL/WEED DICE (By RogueMaster)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/applications/dice/dice.c) -- [Flappy Bird (By DroomOne)](https://github.com/DroomOne/flipperzero-firmware/tree/dev/applications/flappy_bird) -- [HID Analyzer (By Ownasaurus)](https://github.com/Ownasaurus/flipperzero-firmware/tree/hid-analyzer/applications/hid_analyzer) -- [Menu Changes and Icons (By Redlink)](https://github.com/redlink2/flipperzero-firmware/tree/menuChanges) -- [Mouse Jiggler (By Jacob-Tate)(Original By MuddleBox)](https://github.com/Jacob-Tate/flipperzero-firmware/blob/dev/applications/mouse_jiggler/mouse_jiggler.c) Updated by Jacob-Tate To Work -- [RayCast (Bt Zlo)](https://github.com/flipperdevices/flipperzero-firmware/tree/zlo/raycast-game-engine) -- [RF Remix (By ESurge)(Original By jimilinuxguy)](https://github.com/ESurge/flipperzero-firmware-unirfremix) -- [Spectrum Analyzer (By jolcese)](https://github.com/jolcese/flipperzero-firmware/tree/spectrum/applications/spectrum_analyzer) -- [Tanks (By Alexgr13)](https://github.com/alexgr13/flipperzero-firmware/tree/fork/dev/applications/tanks-game) Updated by RogueMaster To Work -- [Tetris (By jeffplang)](https://github.com/jeffplang/flipperzero-firmware/tree/tetris_game/applications/tetris_game) -- [Touch Tunes Remote (By jimilinuxguy)](https://github.com/jimilinuxguy/flipperzero-universal-rf-remote/tree/028d615c83f059bb2c905530ddb3d4efbd3cbcae/applications/jukebox) -- [WAV Player (By Zlo)](https://github.com/flipperdevices/flipperzero-firmware/tree/zlo/wav-player) Updated by Atmanos & RogueMaster To Work - -Thank you, [MuddleBox](https://github.com/MuddledBox/flipperzero-firmware), [Eng1n33r](https://github.com/Eng1n33r/flipperzero-firmware), [WeTox-Team](https://github.com/wetox-team/flipperzero-firmware) & of course, most of all [Flipper Devices](https://github.com/flipperdevices/flipperzero-firmware)! +This will likley break or components will exist in a messy state. From fd472510dbb5ea1c1ac82a7f3d152ee2304d79a8 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 10 Jun 2022 01:03:09 -0700 Subject: [PATCH 47/91] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index be0bf3d1f31..0e15396b518 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ -Do not use this. +## +**Do not use this.** Go for an upstream project. This is a personal sandbox/learning/testing build. - +## Anything I think is worthwhile will become PR This will likley break or components will exist in a messy state. From c2ca751088cf8e0bfc3faab41f477b50dc7c25ec Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 10 Jun 2022 01:04:56 -0700 Subject: [PATCH 48/91] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e15396b518..ec0eaf3e905 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,6 @@ Go for an upstream project. This is a personal sandbox/learning/testing build. ## -Anything I think is worthwhile will become PR +Anything I think is worthwhile will become PR once polished up. This will likley break or components will exist in a messy state. From 6978355a6d822f028e7f4d1157ccbd5363146ca2 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Mon, 13 Jun 2022 11:53:49 -0700 Subject: [PATCH 49/91] Attribution ;) --- applications/VideoPoker/poker.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c index 1b625250068..29170810efe 100644 --- a/applications/VideoPoker/poker.c +++ b/applications/VideoPoker/poker.c @@ -8,6 +8,10 @@ #include "assets_icons.h" #include +/* Core game logic from +https://github.com/Yaoir/VideoPoker-C +*/ + /* KNOWN BUGS This has been converted from a standalone PC console app to flipper All of the original input/output handing code has been ripped out From db25fe0e7c7918e00195be5dc9ca125ceb40ff2e Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 3 Jun 2022 10:58:36 -0700 Subject: [PATCH 50/91] Improve directions on how to find dimensions, which are kinda important for images. --- scripts/User/ReadMe.md | 31 +++++++++++++++++++++++++++++++ scripts/User/decode.py | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 9139b00fef2..fb70138adfc 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -1,3 +1,4 @@ +<<<<<<< HEAD encode.py decode.py A set of python3 scripts for processing the Flipper image files. @@ -18,6 +19,36 @@ If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE Encode an .xbm file into .xb encode.py input_image output_image That's it. +======= +##################################### +encode.py +decode.py + +A set of python3 scripts for processing the Flipper image files. + +##################################### +PREREQUISITES + +You'll need heatshrink installed - a small embedded/RTOS compression and decompression library +You can get that here https://github.com/atomicobject/heatshrink + +##################################### +HOW TO USE + +## +Decode a .mb into .xbm: +decode.py input_image output_image [width] [height] +Dimensions are not stored in .bm so you need to specify +If you have the meta.txt available for the animation set the dimensions will be in here. +It may also be part of the directory name for the animation files as well. + +If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. + +## +Encode an .xbm file into .xb +encode.py input_image output_image +That's it. +>>>>>>> ed6b23b0 (Improve directions on how to find dimensions, which are kinda important for images.) diff --git a/scripts/User/decode.py b/scripts/User/decode.py index dd557f0256b..21c4a353d5d 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -27,9 +27,9 @@ def padded_hex(i, l): parser.add_argument('outfile', metavar='o', help='File to write to') parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", - help='Width of the image') + help='Width of the image. Find from meta.txt or directory name') parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", - help='Height of the image') + help='Height of the image. Find from meta.txt or directory name') args = vars(parser.parse_args()) From 5bb8432b66958fbb176f409bc74b0d27fe56f315 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 3 Jun 2022 11:08:50 -0700 Subject: [PATCH 51/91] encode will print out image dimensions --- scripts/User/ReadMe.md | 1 + scripts/User/encode.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index fb70138adfc..27f3ac6f2ce 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -47,6 +47,7 @@ If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE ## Encode an .xbm file into .xb encode.py input_image output_image +You will also get the image dimensions for use in meta.txt That's it. >>>>>>> ed6b23b0 (Improve directions on how to find dimensions, which are kinda important for images.) diff --git a/scripts/User/encode.py b/scripts/User/encode.py index 43d04063c31..d3b7a21e7cd 100644 --- a/scripts/User/encode.py +++ b/scripts/User/encode.py @@ -21,8 +21,11 @@ output = subprocess.check_output(["cat", args["infile"]]) f = io.StringIO(output.decode().strip()) +print("Image Dimensions:") width = int(f.readline().strip().split(" ")[2]) height = int(f.readline().strip().split(" ")[2]) +print("Height:", height) +print("Width: ", width) data = f.read().strip().replace("\n", "").replace(" ", "").split("=")[1][:-1] data_str = data[1:-1].replace(",", " ").replace("0x", "") From 1caa4227ac2772bafd31ec3272b11c318f3f9f00 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 3 Jun 2022 11:20:49 -0700 Subject: [PATCH 52/91] QOL --- scripts/User/decode.py | 2 +- scripts/User/encode.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/User/decode.py b/scripts/User/decode.py index 21c4a353d5d..f3b83a12e99 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -49,7 +49,7 @@ def padded_hex(i, l): unpad=fileStream[4:] else: if(fileStream[0:1] == bytes([0x00])): - unpad=fileStream[2:] + unpad=fileStream[3:] diff --git a/scripts/User/encode.py b/scripts/User/encode.py index d3b7a21e7cd..c1fcc4b0f8b 100644 --- a/scripts/User/encode.py +++ b/scripts/User/encode.py @@ -23,9 +23,10 @@ f = io.StringIO(output.decode().strip()) print("Image Dimensions:") width = int(f.readline().strip().split(" ")[2]) +print("W: ", width) height = int(f.readline().strip().split(" ")[2]) -print("Height:", height) -print("Width: ", width) +print("H: ", height) + data = f.read().strip().replace("\n", "").replace(" ", "").split("=")[1][:-1] data_str = data[1:-1].replace(",", " ").replace("0x", "") From 5992e09c405eb52cae694f10f940fcf6360f6a19 Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 3 Jun 2022 11:10:23 -0700 Subject: [PATCH 53/91] Update ReadMe.md --- scripts/User/ReadMe.md | 57 ++++++++++++------------------------------ 1 file changed, 16 insertions(+), 41 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 27f3ac6f2ce..28abdc5cfda 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -1,55 +1,30 @@ -<<<<<<< HEAD +##################################### encode.py decode.py -A set of python3 scripts for processing the Flipper image files. +A set of python3 scripts for processing the Flipper image files. +##################################### PREREQUISITES + + You'll need heatshrink installed - a small embedded/RTOS compression and decompression library You can get that here https://github.com/atomicobject/heatshrink - +##################################### HOW TO USE + +## Decode a .mb into .xbm: -decode.py input_image output_image [width] [height] -Dimensions are not stored in .bm so you need to specify. -If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. +decode.py input_image output_image [width] [height] +Dimensions are not stored in .bm so you need to specify +If you have the meta.txt available for the animation set the dimensions will be in here. +It may also be part of the directory name for the animation files as well. +If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. +## Encode an .xbm file into .xb encode.py input_image output_image -That's it. -======= -##################################### -encode.py -decode.py - -A set of python3 scripts for processing the Flipper image files. - -##################################### -PREREQUISITES - -You'll need heatshrink installed - a small embedded/RTOS compression and decompression library -You can get that here https://github.com/atomicobject/heatshrink - -##################################### -HOW TO USE - -## -Decode a .mb into .xbm: -decode.py input_image output_image [width] [height] -Dimensions are not stored in .bm so you need to specify -If you have the meta.txt available for the animation set the dimensions will be in here. -It may also be part of the directory name for the animation files as well. - -If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. - -## -Encode an .xbm file into .xb -encode.py input_image output_image -You will also get the image dimensions for use in meta.txt -That's it. ->>>>>>> ed6b23b0 (Improve directions on how to find dimensions, which are kinda important for images.) - - - +You will also get the image dimensions for use in meta.txt +That's it. From e6c6108bed4907341912cdd4e8e9746c8da3bc41 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 00:53:24 -0700 Subject: [PATCH 54/91] New: decoder for heatshrunk char array icons. You'll likely need to trim some bytes off the start. the format here is a bit different than elsewhere. --- scripts/User/decode.py | 2 ++ scripts/User/encode.py | 2 ++ scripts/User/icondecode.py | 66 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 scripts/User/icondecode.py diff --git a/scripts/User/decode.py b/scripts/User/decode.py index f3b83a12e99..01b405c0d95 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -70,3 +70,5 @@ def padded_hex(i, l): data=width_out+height_out+bytes_out w.write(data) +r.close() +w.close() \ No newline at end of file diff --git a/scripts/User/encode.py b/scripts/User/encode.py index c1fcc4b0f8b..d2d533ea3f7 100644 --- a/scripts/User/encode.py +++ b/scripts/User/encode.py @@ -45,3 +45,5 @@ else: data = b"\x00" + data_bin w.write(data) +r.close() +w.close() diff --git a/scripts/User/icondecode.py b/scripts/User/icondecode.py new file mode 100644 index 00000000000..ffc00eafdfd --- /dev/null +++ b/scripts/User/icondecode.py @@ -0,0 +1,66 @@ +import logging +import argparse +import subprocess +import io +import os +import sys + +def padded_hex(i, l): + given_int = i + given_len = l + + hex_result = hex(given_int)[2:] # remove '0x' from beginning of str + num_hex_chars = len(hex_result) + extra_zeros = '0' * (given_len - num_hex_chars) # may not get used.. + + return ('0x' + hex_result if num_hex_chars == given_len else + '?' * given_len if num_hex_chars > given_len else + '0x' + extra_zeros + hex_result if num_hex_chars < given_len else + None) + + +parser = argparse.ArgumentParser(description='Turn icon char arrays back into .xbm') + +parser.add_argument('infile', metavar='i', + help='Input file') +parser.add_argument('outfile', metavar='o', + help='File to write to') +parser.add_argument('Trim', metavar='T', type=int, nargs="?", default="0", + help='Number of bytes off the start/header to trim. Multiples of 2 required.') +parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", + help='Width of the image. Find from meta.txt or directory name') +parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", + help='Height of the image. Find from meta.txt or directory name') + +args = vars(parser.parse_args()) + +r = open(args["infile"],"r") +w = open(args["outfile"],"w") +imageWidth=args["Width"] +imageHeight=args["Height"] +trimStart=args["Trim"] + +output = subprocess.check_output(["cat", args["infile"]]) #yes this is terrible. +f = io.StringIO(output.decode().strip()) + +data = f.read().strip() +data_str = data[1:-1].replace(",", "").replace("0x", "") +data_bin = bytearray.fromhex(data_str[trimStart:]) + +data_decoded_str = subprocess.check_output( + ["heatshrink", "-d","-w8","-l4"], input=data_bin +) + +b=list(data_decoded_str) + +c=', '.join(padded_hex(my_int,2) for my_int in b) + +width_out = "#define icon_width "+ str(imageWidth) + "\n" +height_out = "#define icon_height "+ str(imageHeight) + "\n" +bytes_out = "static unsigned char icon_bits[] = {"+ str(c) + "};" + +data=width_out+height_out+bytes_out + +w.write(data) +r.close() +w.close() \ No newline at end of file From 5dedb8a6626543d21cf708ba0dbfa5cfedaa3d37 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 01:08:57 -0700 Subject: [PATCH 55/91] help info --- scripts/User/ReadMe.md | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 scripts/User/ReadMe.md diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md deleted file mode 100644 index 28abdc5cfda..00000000000 --- a/scripts/User/ReadMe.md +++ /dev/null @@ -1,30 +0,0 @@ -##################################### -encode.py -decode.py - -A set of python3 scripts for processing the Flipper image files. - -##################################### -PREREQUISITES - - -You'll need heatshrink installed - a small embedded/RTOS compression and decompression library -You can get that here https://github.com/atomicobject/heatshrink - -##################################### -HOW TO USE - -## -Decode a .mb into .xbm: -decode.py input_image output_image [width] [height] -Dimensions are not stored in .bm so you need to specify -If you have the meta.txt available for the animation set the dimensions will be in here. -It may also be part of the directory name for the animation files as well. - -If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. - -## -Encode an .xbm file into .xb -encode.py input_image output_image -You will also get the image dimensions for use in meta.txt -That's it. From f59a4a108734f26b956b58677542d7209dfd4b18 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 01:11:48 -0700 Subject: [PATCH 56/91] re-arrange params --- scripts/User/icondecode.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/User/icondecode.py b/scripts/User/icondecode.py index ffc00eafdfd..85d2de1c7d2 100644 --- a/scripts/User/icondecode.py +++ b/scripts/User/icondecode.py @@ -25,13 +25,12 @@ def padded_hex(i, l): help='Input file') parser.add_argument('outfile', metavar='o', help='File to write to') -parser.add_argument('Trim', metavar='T', type=int, nargs="?", default="0", - help='Number of bytes off the start/header to trim. Multiples of 2 required.') parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", help='Width of the image. Find from meta.txt or directory name') parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", help='Height of the image. Find from meta.txt or directory name') - +parser.add_argument('Trim', metavar='T', type=int, nargs="?", default="8", + help='Number of bytes off the start/header to trim. Multiples of 2 required.') args = vars(parser.parse_args()) r = open(args["infile"],"r") @@ -62,5 +61,4 @@ def padded_hex(i, l): data=width_out+height_out+bytes_out w.write(data) -r.close() -w.close() \ No newline at end of file +w.close() From 6e507afbc6b11fa0793708fa60138b31f3e4127d Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 01:18:01 -0700 Subject: [PATCH 57/91] QOL --- scripts/User/icondecode.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/User/icondecode.py b/scripts/User/icondecode.py index 85d2de1c7d2..241831510f2 100644 --- a/scripts/User/icondecode.py +++ b/scripts/User/icondecode.py @@ -42,8 +42,8 @@ def padded_hex(i, l): output = subprocess.check_output(["cat", args["infile"]]) #yes this is terrible. f = io.StringIO(output.decode().strip()) -data = f.read().strip() -data_str = data[1:-1].replace(",", "").replace("0x", "") +data = f.read().strip().replace(";","").replace("{","").replace("}","") +data_str = data.replace(",", "").replace("0x", "") data_bin = bytearray.fromhex(data_str[trimStart:]) data_decoded_str = subprocess.check_output( From 281bde17c970aa5c58c8c9338a7b43003542ae7d Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 02:55:07 -0700 Subject: [PATCH 58/91] icon encoder added --- scripts/User/iconencode.py | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 scripts/User/iconencode.py diff --git a/scripts/User/iconencode.py b/scripts/User/iconencode.py new file mode 100644 index 00000000000..fd35502b6f2 --- /dev/null +++ b/scripts/User/iconencode.py @@ -0,0 +1,61 @@ +import logging +import argparse +import subprocess +import io +import os +import sys + +def padded_hex(i, l): + given_int = i + given_len = l + + hex_result = hex(given_int)[2:] # remove '0x' from beginning of str + num_hex_chars = len(hex_result) + extra_zeros = '0' * (given_len - num_hex_chars) # may not get used.. + + return ('0x' + hex_result if num_hex_chars == given_len else + '?' * given_len if num_hex_chars > given_len else + '0x' + extra_zeros + hex_result if num_hex_chars < given_len else + None) + + +parser = argparse.ArgumentParser(description='Turn icon char arrays back into .xbm') + +parser.add_argument('infile', metavar='i', + help='Input file') +parser.add_argument('Width', metavar='W', type=int, nargs="?", default="128", + help='Width of the image. Find from meta.txt or directory name') +parser.add_argument('Height', metavar='H', type=int, nargs="?", default="64", + help='Height of the image. Find from meta.txt or directory name') +args = vars(parser.parse_args()) + +r = open(args["infile"],"r") +infile=args["infile"].split(".")[0] + +imageWidth=args["Width"] +imageHeight=args["Height"] +dims=str(imageWidth)+"x"+str(imageHeight) + +output = subprocess.check_output(["cat", args["infile"]]) #yes this is terrible. +f = io.StringIO(output.decode().strip()) + +data = f.read().strip().replace(";","").replace("{","").replace("}","") +data_str = data.replace(",", "").replace("0x", "") +data_bin = bytearray.fromhex(data_str) + +data_encoded_str = subprocess.check_output( + ["heatshrink", "-e","-w8","-l4"], input=data_bin +) + +b=list(data_encoded_str) + +c=','.join(padded_hex(my_int,2) for my_int in b) + +# a bit ugly. +char_out = "const uint8_t _I_"+infile+"_"+dims+"_0[] = {"+ str(c) + ",};" +char_out2 = "const uint8_t* const _I_" +infile+"{_I_"+infile+"};" +#data=bytes_out +print(char_out) +print(char_out2) +#w.write(data) +#w.close() From 20abbcaf26b09885bf4324ed446629e3b54421c4 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 03:09:16 -0700 Subject: [PATCH 59/91] cleanup --- scripts/User/iconencode.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/User/iconencode.py b/scripts/User/iconencode.py index fd35502b6f2..409327c2058 100644 --- a/scripts/User/iconencode.py +++ b/scripts/User/iconencode.py @@ -52,8 +52,12 @@ def padded_hex(i, l): c=','.join(padded_hex(my_int,2) for my_int in b) # a bit ugly. -char_out = "const uint8_t _I_"+infile+"_"+dims+"_0[] = {"+ str(c) + ",};" -char_out2 = "const uint8_t* const _I_" +infile+"{_I_"+infile+"};" + +framename="_I_"+infile+"_"+dims + + +char_out = "const uint8_t "+framename+"_0[] = {"+ str(c) + ",};" +char_out2 = "const uint8_t "+framename+"[] = {"+framename+"_0};" #data=bytes_out print(char_out) print(char_out2) From 5b19fe3c6c5c671bfbd76eaa6239007aab297c5b Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Mon, 6 Jun 2022 13:47:57 -0700 Subject: [PATCH 60/91] I can't count --- scripts/User/decode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/User/decode.py b/scripts/User/decode.py index 01b405c0d95..f6779d967f3 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -49,7 +49,7 @@ def padded_hex(i, l): unpad=fileStream[4:] else: if(fileStream[0:1] == bytes([0x00])): - unpad=fileStream[3:] + unpad=fileStream[2:] From 31ceca33c3d427b3fba094797570f0493c87a6f9 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Wed, 8 Jun 2022 22:21:49 -0700 Subject: [PATCH 61/91] box tutorial --- applications/applications.c | 9 +++ applications/applications.mk | 7 ++ applications/box_mover/box_mover.c | 106 +++++++++++++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100644 applications/box_mover/box_mover.c diff --git a/applications/applications.c b/applications/applications.c index eb203c970a8..44a905b9c86 100644 --- a/applications/applications.c +++ b/applications/applications.c @@ -50,6 +50,7 @@ extern int32_t music_player_app(void* p); extern int32_t snake_game_app(void* p); extern int32_t tetris_game_app(void *p); extern int32_t clock_app(void *p); +extern int32_t box_mover_app(void* p); // extern int32_t floopper_bloopper(void* p); extern int32_t raycast_game_app(void* p); extern int32_t spectrum_analyzer_app(void* p); @@ -366,6 +367,14 @@ const FlipperApplication FLIPPER_GAMES[] = { .flags =FlipperApplicationFlagDefault}, #endif +#ifdef APP_ZOMBIEZ + {.app = zombiez_app, + .name = "Zombiez", + .stack_size = 2048, + .icon = &A_Plugins_14, + .flags = FlipperApplicationFlagDefault}, +#endif + }; const size_t FLIPPER_GAMES_COUNT = COUNT_OF(FLIPPER_GAMES); diff --git a/applications/applications.mk b/applications/applications.mk index 3e1714e0b8a..c17254a30a9 100644 --- a/applications/applications.mk +++ b/applications/applications.mk @@ -49,6 +49,7 @@ APP_MUSIC_PLAYER = 1 APP_SNAKE_GAME = 1 APP_TETRIS_GAME = 1 APP_RAYCAST_GAME = 1 +# APP_RAYCAST_GAME = 1 APP_CLOCK = 1 APP_SPECTRUM_ANALYZER = 1 APP_FLAPPY_GAME = 1 @@ -278,6 +279,12 @@ CFLAGS += -DAPP_SNAKE_GAME SRV_GUI = 1 endif +APP_BOX_MOVER ?= 0 +ifeq ($(APP_BOX_MOVER),1) +CFLAGS += -DAPP_BOX_MOVER +SRV_GUI = 1 +endif + APP_SPECTRUM_ANALYZER ?= 0 ifeq ($(APP_SPECTRUM_ANALYZER), 1) CFLAGS += -DAPP_SPECTRUM_ANALYZER diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c new file mode 100644 index 00000000000..0739cd1ffc5 --- /dev/null +++ b/applications/box_mover/box_mover.c @@ -0,0 +1,106 @@ +#include +#include +#include + +typedef struct { + int x; + int y; +} BoxMoverModel; + +typedef struct { + BoxMoverModel* model; + osMutexId_t* model_mutex; + + osMessageQueueId_t event_queue; + + ViewPort* view_port; + Gui* gui; +} BoxMover; + +BoxMover* box_mover_alloc(){ + BoxMover* instance = malloc(sizeof(BoxMover)); + instance->model = malloc(sizeof(BoxMoverModel)); + instance->model->x = 10; + instance->model->y = 10; + + instance->view_port = view_port_alloc(); + view_port_draw_callback_set(instance->view_port, draw_callback, instance); + + view_port_input_callback_set(instance->view_port, input_callback, instance); + instance->model_mutex = osMutexNew(NULL); + + instance->gui = furi_record_open("gui"); + gui_add_view_port(instance->view_port, GuiLayerFullscreen); + + instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); + + return instance; +} + +void box_mover_free(BoxMover* instance){ + view_port_enabled_set(instance->view_port,false); + gui_remove_view_port(instance->gui, view_port); + furi_record_close("gui"); + osMessageQueueDelete(instance->event_queue); + osMutexDelete(instance->model_mutex); + view_port_free(instance->view_port); + free(instance->model); + free(instance); +} + +int32_t box_mover_app(void* p){ + UNUSED(p); + BoxMover* box_mover = box_mver_alloc(); + + box_mover_free(box_mover) + + for(bool processing = true; processing;){ + osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); + furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); + if(status==osOK){ + if(event.type==InputTypePress){ + switch(event.key){ + case InputKeyUp: + box_mover->model->y-=2; + break; + case InputKeyDown: + box_mover->model->y+=2; + break; + case InputKeyLeft: + box_mover->model->x-=2; + break; + case InputKeyRight: + box_mover->model->x+=2; + break; + case InputKeyOk: + case InputKeyBack: + processing = false; + break; + } + } + } + osMutexRElease(box_mover->model_mutex); + view_port_update(box_mover->view_port); + } + + + box_mover_free(box_mover) + return 0; +} + +void draw_callback(Canvas* cancas, void* ctx){ + BoxMover *box_mover = ctx; + furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); + + canvas_draw_box(canvas, box_mover->x,box_mover->y, 4, 4); + + osReleaseMutex(box_mover->model_mutex); +} + +void input_callback(InputEvent* input, osMessageQueueId_t event_queue){ + BoxMover* box_mover = ctx; + osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); + +} + + From 52f29dfe11cfd0e943daa9c0f3055c82af649b45 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Thu, 9 Jun 2022 00:59:20 -0700 Subject: [PATCH 62/91] Box Mover but added stuff --- applications/box_mover/box_mover.c | 104 +++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 27 deletions(-) diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c index 0739cd1ffc5..fc3366d5951 100644 --- a/applications/box_mover/box_mover.c +++ b/applications/box_mover/box_mover.c @@ -1,10 +1,15 @@ #include #include +#include #include +#include +#include typedef struct { int x; int y; + int sizex; + int sizey; } BoxMoverModel; typedef struct { @@ -17,43 +22,66 @@ typedef struct { Gui* gui; } BoxMover; + + +void draw_callback(Canvas* canvas, void* ctx){ + BoxMover* box_mover = ctx; + furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); + + canvas_draw_box(canvas, box_mover->model->x,box_mover->model->y, box_mover->model->sizex, box_mover->model->sizey); + + osMutexRelease(box_mover->model_mutex); +} + +void input_callback(InputEvent* input, void* ctx){ + BoxMover* box_mover = ctx; + osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); + +} + BoxMover* box_mover_alloc(){ BoxMover* instance = malloc(sizeof(BoxMover)); instance->model = malloc(sizeof(BoxMoverModel)); instance->model->x = 10; instance->model->y = 10; + instance->model->sizex = 4; + instance->model->sizey = 4; +instance->model_mutex = osMutexNew(NULL); + instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); instance->view_port = view_port_alloc(); view_port_draw_callback_set(instance->view_port, draw_callback, instance); view_port_input_callback_set(instance->view_port, input_callback, instance); - instance->model_mutex = osMutexNew(NULL); + instance->gui = furi_record_open("gui"); - gui_add_view_port(instance->view_port, GuiLayerFullscreen); + gui_add_view_port(instance->gui, instance->view_port, GuiLayerFullscreen); + - instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); return instance; } void box_mover_free(BoxMover* instance){ view_port_enabled_set(instance->view_port,false); - gui_remove_view_port(instance->gui, view_port); + gui_remove_view_port(instance->gui, instance->view_port); furi_record_close("gui"); + view_port_free(instance->view_port); osMessageQueueDelete(instance->event_queue); osMutexDelete(instance->model_mutex); - view_port_free(instance->view_port); + free(instance->model); free(instance); } + int32_t box_mover_app(void* p){ UNUSED(p); - BoxMover* box_mover = box_mver_alloc(); + BoxMover* box_mover = box_mover_alloc(); - box_mover_free(box_mover) + InputEvent event; for(bool processing = true; processing;){ osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); @@ -61,46 +89,68 @@ int32_t box_mover_app(void* p){ if(event.type==InputTypePress){ switch(event.key){ case InputKeyUp: - box_mover->model->y-=2; + if (box_mover->model->y >= 1) + box_mover->model->y-=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } break; case InputKeyDown: - box_mover->model->y+=2; - break; + if (box_mover->model->y <= (64-(box_mover->model->sizey+1))) + box_mover->model->y+=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } + break; case InputKeyLeft: - box_mover->model->x-=2; + if (box_mover->model->x >= 1) + box_mover->model->x-=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } break; case InputKeyRight: - box_mover->model->x+=2; + if (box_mover->model->x <= (128-(box_mover->model->sizex+1))) + box_mover->model->x+=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } break; case InputKeyOk: + if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ + box_mover->model->sizex+=1; + box_mover->model->sizey+=1; + } + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } + + break; case InputKeyBack: processing = false; break; } } } - osMutexRElease(box_mover->model_mutex); + osMutexRelease(box_mover->model_mutex); view_port_update(box_mover->view_port); } - box_mover_free(box_mover) + box_mover_free(box_mover); return 0; } -void draw_callback(Canvas* cancas, void* ctx){ - BoxMover *box_mover = ctx; - furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); - canvas_draw_box(canvas, box_mover->x,box_mover->y, 4, 4); - - osReleaseMutex(box_mover->model_mutex); -} - -void input_callback(InputEvent* input, osMessageQueueId_t event_queue){ - BoxMover* box_mover = ctx; - osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); - -} From 10cef4b507d2d4cd8d26a148c5545051ea742360 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Thu, 9 Jun 2022 01:37:03 -0700 Subject: [PATCH 63/91] Improved bounds checks --- applications/box_mover/box_mover.c | 48 ++++++++++++++++-------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c index fc3366d5951..f70ba0f5571 100644 --- a/applications/box_mover/box_mover.c +++ b/applications/box_mover/box_mover.c @@ -22,7 +22,11 @@ typedef struct { Gui* gui; } BoxMover; - +void shake(void){ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } void draw_callback(Canvas* canvas, void* ctx){ BoxMover* box_mover = ctx; @@ -92,48 +96,47 @@ int32_t box_mover_app(void* p){ if (box_mover->model->y >= 1) box_mover->model->y-=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyDown: - if (box_mover->model->y <= (64-(box_mover->model->sizey+1))) + if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))) // So we're trying to see if it's even or odd, to determine how much to offset the bounds check by, since we're doing this based of the square origin+its size. idk. box_mover->model->y+=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyLeft: if (box_mover->model->x >= 1) box_mover->model->x-=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyRight: - if (box_mover->model->x <= (128-(box_mover->model->sizex+1))) + if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))) box_mover->model->x+=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyOk: if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ - box_mover->model->sizex+=1; - box_mover->model->sizey+=1; + if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ + if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ + box_mover->model->sizex+=1; + box_mover->model->sizey+=1; + //TODO - also check the box will not grow past boundary. + } + else + shake(); + } + else + shake(); } - else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); - } + else + shake(); + break; case InputKeyBack: @@ -147,6 +150,7 @@ int32_t box_mover_app(void* p){ } + box_mover_free(box_mover); return 0; } From e0378e8f4976502b574b16b1116fd99e9949a565 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Thu, 9 Jun 2022 10:14:33 -0700 Subject: [PATCH 64/91] Video Poker game --- applications/box_mover/box_mover.c | 160 ----------------------------- 1 file changed, 160 deletions(-) delete mode 100644 applications/box_mover/box_mover.c diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c deleted file mode 100644 index f70ba0f5571..00000000000 --- a/applications/box_mover/box_mover.c +++ /dev/null @@ -1,160 +0,0 @@ -#include -#include -#include -#include -#include -#include - -typedef struct { - int x; - int y; - int sizex; - int sizey; -} BoxMoverModel; - -typedef struct { - BoxMoverModel* model; - osMutexId_t* model_mutex; - - osMessageQueueId_t event_queue; - - ViewPort* view_port; - Gui* gui; -} BoxMover; - -void shake(void){ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); - } - -void draw_callback(Canvas* canvas, void* ctx){ - BoxMover* box_mover = ctx; - furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); - - canvas_draw_box(canvas, box_mover->model->x,box_mover->model->y, box_mover->model->sizex, box_mover->model->sizey); - - osMutexRelease(box_mover->model_mutex); -} - -void input_callback(InputEvent* input, void* ctx){ - BoxMover* box_mover = ctx; - osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); - -} - -BoxMover* box_mover_alloc(){ - BoxMover* instance = malloc(sizeof(BoxMover)); - instance->model = malloc(sizeof(BoxMoverModel)); - instance->model->x = 10; - instance->model->y = 10; - instance->model->sizex = 4; - instance->model->sizey = 4; - -instance->model_mutex = osMutexNew(NULL); - instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); - instance->view_port = view_port_alloc(); - view_port_draw_callback_set(instance->view_port, draw_callback, instance); - - view_port_input_callback_set(instance->view_port, input_callback, instance); - - - instance->gui = furi_record_open("gui"); - gui_add_view_port(instance->gui, instance->view_port, GuiLayerFullscreen); - - - - return instance; -} - -void box_mover_free(BoxMover* instance){ - view_port_enabled_set(instance->view_port,false); - gui_remove_view_port(instance->gui, instance->view_port); - furi_record_close("gui"); - view_port_free(instance->view_port); - osMessageQueueDelete(instance->event_queue); - osMutexDelete(instance->model_mutex); - - free(instance->model); - free(instance); -} - - -int32_t box_mover_app(void* p){ - UNUSED(p); - BoxMover* box_mover = box_mover_alloc(); - - - InputEvent event; - for(bool processing = true; processing;){ - osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); - furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); - if(status==osOK){ - if(event.type==InputTypePress){ - switch(event.key){ - case InputKeyUp: - if (box_mover->model->y >= 1) - box_mover->model->y-=2; - else{ - shake(); - } - break; - case InputKeyDown: - if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))) // So we're trying to see if it's even or odd, to determine how much to offset the bounds check by, since we're doing this based of the square origin+its size. idk. - box_mover->model->y+=2; - else{ - shake(); - } - break; - case InputKeyLeft: - if (box_mover->model->x >= 1) - box_mover->model->x-=2; - else{ - shake(); - } - break; - case InputKeyRight: - if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))) - box_mover->model->x+=2; - else{ - shake(); - } - break; - case InputKeyOk: - if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ - if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ - if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ - box_mover->model->sizex+=1; - box_mover->model->sizey+=1; - //TODO - also check the box will not grow past boundary. - } - else - shake(); - } - else - shake(); - } - else - shake(); - - - break; - case InputKeyBack: - processing = false; - break; - } - } - } - osMutexRelease(box_mover->model_mutex); - view_port_update(box_mover->view_port); - } - - - - box_mover_free(box_mover); - return 0; -} - - - - From d94e64cffb2764c341d5d951be7d09ba64791a5a Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Mon, 13 Jun 2022 02:11:29 -0700 Subject: [PATCH 65/91] INITIAL Video Poker - it works! It's messy! --- applications/VideoPoker/poker.c | 1026 ------------------------------- applications/applications.c | 4 +- applications/applications.mk | 7 + scripts/User/iconencode.py | 5 +- 4 files changed, 14 insertions(+), 1028 deletions(-) delete mode 100644 applications/VideoPoker/poker.c diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c deleted file mode 100644 index ba3a4e24518..00000000000 --- a/applications/VideoPoker/poker.c +++ /dev/null @@ -1,1026 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include "assets_icons.h" -#include - -/* Core game logic from -https://github.com/Yaoir/VideoPoker-C -*/ - -/* KNOWN BUGS -This has been converted from a standalone PC console app to flipper -All of the original input/output handing code has been ripped out -Original code also used TONS of defines and everything was a global. -I have not completed cleaning up and moving globals to members. - -It's not super well written but I think it at least meets a minimum expectation of quality -A lot of it could be cleaned up or optimized. -As is, it does what it wanted and doesn't seem to have major issues, so that's pretty good. -Game logic is handled during input and this is a bit of a mess of nested ifs. -Sometimes duplicate cards will show up. there is a function to test this. I should use it better. -After losing, bet is set to 10 eve -*/ - -#define TAG "Video Poker" - -void Poker_Shaker(void) { - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); -} - -typedef struct { - int index; /* cards value, minus 1 */ - char* sym; /* text appearance */ - int suit; /* card's suit (see just below) */ - int gone; /* true if it's been dealt */ - int held; /* for hand */ -} card; - -typedef struct { - osMutexId_t* model_mutex; - osMessageQueueId_t event_queue; - ViewPort* view_port; - Gui* gui; - card hand[5]; - card shand[5]; - card deck[52]; - int held[5]; - int score; - int pot; - int GameState; - int selected; - int bet; - int minbet; -} PokerPlayer; - - -card deck[52] = { - /* index, card name, suit, gone */ - /* Clubs:0 Diamonds:1 Hearts: 2 Spades: 3 */ - {1, "2", 0, 0}, {2, "3", 0, 0}, {3, "4", 0, 0}, {4, "5", 0, 0}, {5, "6", 0, 0}, - {6, "7", 0, 0}, {7, "8", 0, 0}, {8, "9", 0, 0}, {9, "10", 0, 0}, {10, "J", 0, 0}, - {11, "Q", 0, 0}, {12, "K", 0, 0}, {13, "A", 0, 0}, - - {1, "2", 1, 0}, {2, "3", 1, 0}, {3, "4", 1, 0}, {4, "5", 1, 0}, {5, "6", 1, 0}, - {6, "7", 1, 0}, {7, "8", 1, 0}, {8, "9", 1, 0}, {9, "10", 1, 0}, {10, "J", 1, 0}, - {11, "Q", 1, 0}, {12, "K", 1, 0}, {13, "A", 1, 0}, - - {1, "2", 2, 0}, {2, "3", 2, 0}, {3, "4", 2, 0}, {4, "5", 2, 0}, {5, "6", 2, 0}, - {6, "7", 2, 0}, {7, "8", 2, 0}, {8, "9", 2, 0}, {9, "10", 2, 0}, {10, "J", 2, 0}, - {11, "Q", 2, 0}, {12, "K", 2, 0}, {13, "A", 2, 0}, - - {1, "2", 3, 0}, {2, "3", 3, 0}, {3, "4", 3, 0}, {4, "5", 3, 0}, {5, "6", 3, 0}, - {6, "7", 3, 0}, {7, "8", 3, 0}, {8, "9", 3, 0}, {9, "10", 3, 0}, {10, "J", 3, 0}, - {11, "Q", 3, 0}, {12, "K", 3, 0}, {13, "A", 3, 0}, -}; -/* -int score_low = 1000; - int score_high = 1000; - int minbet = 10; - int betmultiplier = 1; - */ -/* GameState -0=Splash/help, OK button (later on up/down for rules or settings) -1=cards down, betting enabled, left/right to change bet, OK to confirm -2=first hand, holding enabled, left/right to pick card, OK to hold/unhold card, down to confirm -3=second hand, only confirm to claim rewards -4=game over/won -*/ - -/* -Image Format -0x01 = Compressed -0x00 = Reserved Section -0xa4,0x01 = 0x1a4, or, 420 - the size of the compressed array, minus this header. -Rest of the data is char array output from heatshrink of the original XBM char array. -Calculated Header: 0x01,0x00,0xa4,0x01 -from furi_hal_compress.c -typedef struct { - uint8_t is_compressed; - uint8_t reserved; - uint16_t compressed_buff_size; -} FuriHalCompressHeader; -*/ - -const uint8_t _I_Splash_128x64_0[] = { - 0x01, 0x00, 0x8a, 0x02, 0x00, 0x78, 0x02, 0x60, 0xe0, 0x54, 0xc0, 0x03, 0x9f, 0xc0, 0x0f, 0x5a, - 0x04, 0x04, 0x1e, 0xdf, 0x08, 0x78, 0x0c, 0x60, 0xc0, 0x21, 0x90, 0x40, 0xa3, 0x00, 0xf5, 0xfe, - 0x61, 0xc1, 0xe9, 0x1e, 0x8e, 0x59, 0xf0, 0x02, 0x24, 0x9f, 0x70, 0xc0, 0x63, 0x03, 0x01, 0x0c, - 0x0b, 0xc1, 0x80, 0xbc, 0x83, 0xd3, 0x3f, 0x63, 0x98, 0x03, 0xcf, 0x88, 0x02, 0x1c, 0x31, 0x5d, - 0x38, 0xf6, 0x19, 0xc0, 0xa0, 0xfc, 0x93, 0x13, 0x12, 0xf0, 0x38, 0x76, 0x08, 0xc7, 0x00, 0x1e, - 0x5e, 0x8b, 0xcc, 0x32, 0x86, 0x0f, 0x4f, 0x0c, 0x80, 0x06, 0x20, 0x72, 0xe4, 0x5e, 0x33, 0xd4, - 0x73, 0xf2, 0x5d, 0xe2, 0x10, 0xef, 0xe6, 0x02, 0x0f, 0x07, 0x84, 0x4c, 0x33, 0xd2, 0x70, 0x79, - 0xd8, 0x2e, 0x11, 0x88, 0x3d, 0xff, 0xc1, 0xc7, 0x83, 0xc4, 0x20, 0x10, 0xc9, 0x18, 0x3d, 0x27, - 0x18, 0x8c, 0x3c, 0xde, 0xe1, 0xe6, 0x87, 0x7e, 0x0c, 0x62, 0x12, 0x10, 0x01, 0xce, 0x31, 0x9c, - 0x39, 0x9c, 0x62, 0x67, 0x0f, 0x83, 0x7f, 0x27, 0xe0, 0xf5, 0x8c, 0x71, 0xbc, 0x31, 0x8c, 0xc4, - 0xe2, 0x1e, 0x62, 0x1e, 0x02, 0xe0, 0x80, 0x05, 0x1c, 0xe1, 0xdc, 0x23, 0x97, 0xc8, 0xe4, 0x5c, - 0x12, 0x50, 0x40, 0x7a, 0x43, 0x38, 0x77, 0x88, 0xf4, 0x36, 0x3d, 0x1f, 0x04, 0x94, 0x20, 0x1e, - 0x98, 0xce, 0x0d, 0xbe, 0x37, 0x0d, 0xcd, 0xbd, 0x0c, 0x7e, 0xbe, 0xce, 0x07, 0x1f, 0xf3, 0xfc, - 0xf8, 0xb2, 0x8d, 0x30, 0x20, 0x53, 0xbe, 0x60, 0x06, 0x03, 0x78, 0xf0, 0x06, 0x4c, 0x1e, 0x34, - 0x10, 0x29, 0x5e, 0x05, 0x0f, 0x00, 0xa0, 0x40, 0x24, 0x20, 0x52, 0x76, 0x88, 0x01, 0xc1, 0xe3, - 0x11, 0x05, 0xc3, 0xe9, 0x20, 0x10, 0x97, 0x01, 0xcf, 0xc1, 0xf2, 0x81, 0x3f, 0xe7, 0xfc, 0x66, - 0xf4, 0x02, 0xf1, 0xc0, 0x3f, 0xdf, 0xf0, 0x30, 0xc6, 0x1e, 0xe5, 0xff, 0x81, 0xf0, 0x3f, 0xe5, - 0xb2, 0x80, 0x7f, 0xc1, 0xe5, 0x1c, 0x03, 0x0f, 0xe3, 0xff, 0x1f, 0xf8, 0x02, 0x48, 0x00, 0x31, - 0xfe, 0x0b, 0xa4, 0x61, 0xcc, 0x62, 0xfc, 0x4f, 0xe3, 0x0f, 0x31, 0x41, 0x0e, 0x02, 0x07, 0x01, - 0x07, 0x8a, 0xb4, 0xa3, 0x84, 0x71, 0x8f, 0xff, 0x20, 0x77, 0x00, 0x78, 0x95, 0x46, 0x06, 0x13, - 0x10, 0x78, 0xef, 0x3f, 0x5f, 0xfc, 0xff, 0xea, 0x07, 0xf0, 0x37, 0x90, 0x3c, 0x78, 0x00, 0xf2, - 0xae, 0x7f, 0x77, 0xf7, 0xaf, 0xec, 0x0f, 0x88, 0x41, 0x1b, 0x06, 0x02, 0x03, 0xc0, 0x02, 0x8c, - 0x08, 0x5c, 0x37, 0xff, 0xa9, 0x3c, 0x7b, 0xcc, 0x52, 0xe0, 0x70, 0x7c, 0x31, 0x89, 0xe4, 0xff, - 0xfb, 0xff, 0xdf, 0x8c, 0x46, 0x03, 0x1f, 0x34, 0x17, 0x83, 0xe1, 0x71, 0x8f, 0x6f, 0xe7, 0xe0, - 0xc1, 0x8f, 0xfd, 0x20, 0x18, 0x65, 0x59, 0x47, 0xaf, 0x9b, 0x8b, 0x9e, 0x6f, 0xe7, 0x1f, 0x16, - 0x0c, 0x3e, 0x3d, 0x00, 0xe4, 0x43, 0xd1, 0xe5, 0x3f, 0xe6, 0x6e, 0xfb, 0x39, 0x88, 0x67, 0xea, - 0xff, 0xc5, 0x22, 0x8f, 0xc0, 0xf0, 0x41, 0x71, 0xe7, 0x76, 0xf9, 0x98, 0x48, 0x64, 0x17, 0x59, - 0x38, 0x05, 0x8f, 0xc0, 0xd0, 0x5f, 0xe8, 0x0f, 0x1a, 0xdb, 0xe6, 0xb1, 0xd1, 0xa0, 0x50, 0x85, - 0x59, 0x7e, 0x16, 0x05, 0x06, 0x80, 0x71, 0xbf, 0xf7, 0x19, 0x85, 0x99, 0x74, 0x6d, 0x31, 0x02, - 0x10, 0x88, 0x7c, 0xdd, 0xdb, 0x84, 0x62, 0x7c, 0x0f, 0x38, 0xe5, 0xf0, 0x1e, 0x97, 0xce, 0x67, - 0xbc, 0xb6, 0x40, 0xa3, 0x98, 0x00, 0xc5, 0x76, 0x53, 0x8c, 0x67, 0x1e, 0x07, 0x0e, 0x63, 0x0a, - 0xe4, 0x9c, 0x62, 0x0f, 0x11, 0x41, 0x95, 0x88, 0x1e, 0x41, 0xd1, 0x8c, 0x49, 0x80, 0xe6, 0x00, - 0x50, 0xb8, 0xa3, 0x07, 0xf1, 0x7f, 0x06, 0xb8, 0x00, 0x61, 0xce, 0xb2, 0x9c, 0x53, 0x01, 0xf3, - 0xf0, 0x55, 0x97, 0xd0, 0x3f, 0x40, 0x03, 0xfd, 0x33, 0xc8, 0x01, 0x71, 0x92, 0x78, 0x80, 0x2f, - 0x80, 0x6f, 0x20, 0x03, 0xff, 0x23, 0xe7, 0x02, 0x02, 0x18, 0x01, 0xa3, 0x91, 0x00, 0x18, 0xc3, - 0x20, 0x91, 0xc0, 0x7c, 0x7f, 0x83, 0x42, 0xaa, 0x1f, 0xe0, 0xbe, 0x60, 0x46, 0xa2, 0x81, 0xe2, - 0x24, 0x21, 0xf9, 0x54, 0x14, 0x18, 0x9e, 0x3f, 0xe4, 0x29, 0x00, 0x12, 0x0e, 0xb0, 0x28, 0x50, - 0x3c, 0x60, 0x50, 0x85, 0xf4, 0x7f, 0xb8, 0x3f, 0xf3, 0xf8, 0x83, 0xe0, 0x00, 0x38, 0x6e, 0x0c, - 0xc3, 0xf2, 0x2f, 0x94, 0x09, 0x07, 0xc7, 0xf7, 0x3f, 0xfe, 0x0d, 0xc4, 0x00, 0xfc, 0x4c, 0x05, - 0x86, 0x15, 0x23, 0x92, 0x03, 0xe7, 0xf9, 0x80, 0x0f, 0x97, 0x52, 0x0c, 0x2f, 0xb1, 0xf8, 0xe3, - 0x01, 0xf3, 0x82, 0x27, 0x8d, 0xe6, 0x41, 0x1c, 0x17, 0xcf, 0xfc, 0x3e, 0x64, 0xf8, -}; -const uint8_t* _I_Splash_128x64[] = {_I_Splash_128x64_0}; -const Icon I_Splash_128x64 = - {.width = 128, .height = 64, .frame_count = 1, .frame_rate = 0, .frames = _I_Splash_128x64}; - -const uint8_t _I_BadEnd_128x64_0[] = { - 0x01, 0x00, 0xDF, 0x01, 0x00, 0x2c, 0x12, 0x01, 0x02, 0x80, 0x40, 0x70, 0x10, 0x0a, 0x04, 0x02, - 0x41, 0x3e, 0xcf, 0x63, 0xfb, 0xfe, 0xc8, 0x18, 0x3e, 0x6f, 0xdb, 0xfc, 0xf8, 0x3c, 0x60, 0xe0, - 0xf9, 0xb3, 0x6c, 0xf3, 0x3c, 0x1b, 0x6c, 0x18, 0x5f, 0x40, 0xf1, 0xe7, 0xdb, 0xc1, 0xf4, 0x2f, - 0x10, 0x78, 0xdb, 0xbc, 0xdf, 0xf0, 0x04, 0x59, 0x81, 0xe3, 0xc1, 0xb6, 0x41, 0x83, 0xd1, 0x00, - 0xbf, 0x6c, 0xc9, 0xe6, 0x0f, 0x91, 0xf8, 0x9b, 0xcc, 0x1f, 0x20, 0x06, 0x07, 0xf8, 0x3e, 0x0b, - 0x32, 0x00, 0x50, 0x88, 0xc4, 0x20, 0x10, 0x85, 0xfd, 0x03, 0xfc, 0x1f, 0xe0, 0xff, 0x07, 0xf9, - 0x7f, 0xc3, 0xdc, 0x89, 0x10, 0x7d, 0x00, 0x04, 0x1f, 0xe0, 0xfd, 0xfc, 0x40, 0xc1, 0xfb, 0x07, - 0x8e, 0x2f, 0xf3, 0x9f, 0x00, 0xb0, 0x7f, 0x97, 0xf6, 0x0a, 0x11, 0x10, 0xa3, 0xec, 0x10, 0x21, - 0x32, 0x07, 0xd0, 0x18, 0x40, 0xa2, 0x0f, 0xb0, 0x20, 0x81, 0xc4, 0x1f, 0xeb, 0xfa, 0xbf, 0x84, - 0x86, 0x01, 0xc8, 0x5f, 0xd0, 0x0c, 0x81, 0xe2, 0x05, 0x10, 0x7e, 0xdc, 0xc1, 0xf5, 0x01, 0xe0, - 0x41, 0xf2, 0x17, 0xf0, 0x7d, 0xaf, 0x0a, 0x7e, 0x0f, 0xbf, 0x84, 0x7f, 0x21, 0x1f, 0x2b, 0x8e, - 0x3c, 0xbe, 0xd3, 0xf0, 0x78, 0xc4, 0xfa, 0x0b, 0xf2, 0x00, 0x08, 0x81, 0xa1, 0xf3, 0x08, 0x9f, - 0xc0, 0x1e, 0x57, 0x00, 0x7b, 0x60, 0x60, 0x3e, 0x08, 0x4f, 0x80, 0x1e, 0x59, 0x05, 0xc1, 0x03, - 0xce, 0xc3, 0x00, 0x2f, 0x88, 0x3c, 0xe2, 0x10, 0x20, 0x78, 0xbd, 0xc6, 0xff, 0x7c, 0x8c, 0x0e, - 0x48, 0x1e, 0x90, 0x48, 0x47, 0xe2, 0x06, 0x1b, 0x1e, 0x3c, 0x1c, 0x1e, 0x80, 0x01, 0x93, 0xad, - 0x06, 0x1e, 0x0a, 0x28, 0x04, 0x18, 0x1e, 0x81, 0xe1, 0x90, 0x20, 0x46, 0x49, 0xa9, 0x91, 0x3e, - 0x46, 0xf8, 0x0f, 0xac, 0x48, 0x3c, 0xb0, 0x82, 0x52, 0x07, 0xa1, 0x08, 0x43, 0xe5, 0x72, 0x93, - 0x41, 0x7e, 0x01, 0x01, 0x07, 0xc7, 0x8a, 0x97, 0xa9, 0x39, 0x88, 0xa0, 0x7f, 0x00, 0xf2, 0x08, - 0x0c, 0x03, 0x25, 0x54, 0x88, 0xe9, 0x66, 0x11, 0xc2, 0x99, 0x9e, 0x07, 0xff, 0x13, 0x90, 0x7f, - 0xb2, 0x60, 0xf2, 0xaa, 0x79, 0x1b, 0xe5, 0x01, 0xfe, 0x1f, 0xca, 0x41, 0x08, 0xb0, 0xd4, 0xe2, - 0x33, 0x9c, 0x9f, 0x13, 0xff, 0x07, 0xc0, 0x0c, 0x04, 0x1e, 0x54, 0x08, 0x40, 0x64, 0x80, 0x03, - 0x84, 0xff, 0xc0, 0x68, 0x10, 0x0f, 0x80, 0x3d, 0x13, 0xc2, 0x00, 0x28, 0x25, 0xfa, 0x00, 0x0f, - 0x76, 0x60, 0x83, 0xcc, 0x04, 0x20, 0xc1, 0x07, 0xaf, 0xc8, 0x52, 0x52, 0x00, 0x7a, 0x2f, 0xcc, - 0x16, 0x31, 0x30, 0x49, 0x48, 0x17, 0xe5, 0x20, 0xc0, 0x23, 0xce, 0x81, 0x80, 0x88, 0xe6, 0x24, - 0x7c, 0x69, 0xc0, 0xd0, 0xa2, 0x1c, 0x00, 0x79, 0x85, 0x07, 0xe3, 0xa4, 0xb0, 0x4a, 0x64, 0xa0, - 0xf3, 0x57, 0x9d, 0x82, 0x01, 0x80, 0x84, 0x54, 0xb2, 0x19, 0x48, 0x91, 0x90, 0xa2, 0x1f, 0x00, - 0x79, 0x0f, 0x87, 0x80, 0x0f, 0x44, 0x21, 0x03, 0xd0, 0x3e, 0x26, 0x01, 0xa6, 0x44, 0x2c, 0x79, - 0xc0, 0x79, 0xb3, 0xc4, 0xbe, 0x5e, 0x01, 0x08, 0x80, 0x09, 0x56, 0x20, 0x01, 0x98, 0x03, 0xc4, - 0xfe, 0x51, 0x0b, 0xf8, 0x3c, 0xf8, 0x00, 0x32, 0x9c, 0x7f, 0x01, 0xe8, 0x1f, 0x40, 0x21, 0xd7, - 0x81, 0xfb, 0x80, 0xcf, 0x8f, 0x44, 0x1e, 0x7c, 0x88, 0x38, 0x28, 0x70, 0xe4, 0x92, 0xff, 0xc7, - 0xef, 0x1f, 0x80, -}; -const uint8_t* _I_BadEnd_128x64[] = {_I_BadEnd_128x64_0}; -const Icon I_BadEnd_128x64 = - {.width = 128, .height = 64, .frame_count = 1, .frame_rate = 0, .frames = _I_BadEnd_128x64}; - -const uint8_t _I_Hand_12x10_0[] = { - 0x01, 0x00, 0x11, 0x00, 0x8c, 0x40, 0x25, 0x00, 0x16, 0xb4, 0x40, - 0x35, 0x10, 0x1d, 0x5c, 0x1b, 0x5b, 0x0a, 0x84, 0xc2, 0x80, -}; -const uint8_t* _I_Hand_12x10[] = {_I_Hand_12x10_0}; -const Icon I_Hand_12x10 = - {.width = 12, .height = 10, .frame_count = 1, .frame_rate = 0, .frames = _I_Hand_12x10}; - -const uint8_t _I_CardBack_22x35_0[] = { - 0x01, 0x00, 0x23, 0x00, 0xfe, 0x7f, 0xe1, 0xf0, 0x28, 0x04, 0x43, 0xe3, 0xff, - 0x91, 0xea, 0x75, 0x52, 0x6a, 0xad, 0x56, 0x5b, 0xad, 0xd5, 0x4a, 0x80, 0xbe, - 0x05, 0xf0, 0x2f, 0x81, 0x7c, 0x0b, 0x45, 0x32, 0x2c, 0x91, 0x7c, 0x8c, 0xa4, -}; -const uint8_t* _I_CardBack_22x35[] = {_I_CardBack_22x35_0}; -const Icon I_CardBack_22x35 = - {.width = 22, .height = 35, .frame_count = 1, .frame_rate = 0, .frames = _I_CardBack_22x35}; - -//uncompressed but lol -const uint8_t _I_club_7x8_0[] = {0x00, 0x08, 0x1c, 0x1c, 0x6b, 0x7f, 0x36, 0x08, 0x1c}; -const uint8_t* _I_club_7x8[] = {_I_club_7x8_0}; -const Icon I_club_7x8 = - {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_club_7x8}; - -//uncompressed but lol -const uint8_t _I_diamond_7x8_0[] = {0x00, 0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08}; -const uint8_t* _I_diamond_7x8[] = {_I_diamond_7x8_0}; -const Icon I_diamond_7x8 = - {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_diamond_7x8}; - -//uncompressed -const uint8_t _I_hearts_7x8_0[] = {0x00, 0x00, 0x36, 0x7f, 0x7f, 0x7f, 0x3e, 0x1c, 0x08}; -const uint8_t* _I_hearts_7x8[] = {_I_hearts_7x8_0}; -const Icon I_hearts_7x8 = - {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_hearts_7x8}; - -//uncompressed -const uint8_t _I_spade_7x8_0[] = {0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x7f, 0x36, 0x08, 0x1c}; -const uint8_t* _I_spade_7x8[] = {_I_spade_7x8_0}; -const Icon I_spade_7x8 = - {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_spade_7x8}; - -// They only included Numeric Profont22 glyphs and I don't want to fuck up the font embeds right now sooo.. - -const uint8_t _I_King_7x8_0[] = { - 0x01, 0x00, 0x1a, 0x00, 0xc1, 0xc0, 0xf8, 0x70, 0x1f, 0x1c, 0x02, 0xe7, 0x00, 0x9d, 0xc0, - 0x23, 0xf0, 0x08, 0x78, 0x0c, 0x80, 0xe2, 0x0b, 0x10, 0x78, 0x84, 0xc4, 0x2e, 0x20, 0x01, -}; -const uint8_t* _I_King_7x8[] = {_I_King_7x8_0}; -const Icon I_King_7x8 = - {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_King_7x8}; - -const uint8_t _I_Queen_7x8_0[] = { - 0x01, 0x00, 0x13, 0x00, 0xfe, 0x40, 0x3f, 0xd0, 0x1c, 0x3c, 0x0c, 0x01, - 0x76, 0x38, 0x1f, 0x8e, 0x07, 0xc7, 0x81, 0x85, 0x47, 0xf9, 0x01, -}; -const uint8_t* _I_Queen_7x8[] = {_I_Queen_7x8_0}; -const Icon I_Queen_7x8 = - {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Queen_7x8}; - -const uint8_t _I_Jack_7x8_0[] = { - 0x01, - 0x00, - 0x0D, - 0x00, - 0x80, - 0x40, - 0xc0, - 0x3a, - 0x00, - 0x5c, - 0x3c, - 0x0f, - 0xfd, - 0x01, - 0xfe, - 0x40, - 0x00, -}; -const uint8_t* _I_Jack_7x8[] = {_I_Jack_7x8_0}; -const Icon I_Jack_7x8 = - {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Jack_7x8}; - -const uint8_t _I_Ace_7x8_0[] = { - 0x01, 0x00, 0x13, 0x00, 0x98, 0x40, 0x2f, 0x00, 0x12, 0xe6, 0x00, 0x4b, - 0x0d, 0x01, 0x00, 0x8c, 0x0e, 0x07, 0xff, 0x00, 0x90, 0x01, 0xc0, -}; -const uint8_t* _I_Ace_7x8[] = {_I_Ace_7x8_0}; -const Icon I_Ace_7x8 = - {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Ace_7x8}; - -const uint8_t _I_Ten_7x8_0[] = { - 0x01, 0x00, 0x29, 0x00, 0x86, 0x7f, 0x00, 0x43, 0xfe, 0x80, 0xc3, 0xf0, 0xf0, 0x38, 0x7e, - 0x0e, 0x07, 0x0c, 0xe1, 0x80, 0x87, 0xc6, 0x02, 0x1b, 0x98, 0x08, 0x67, 0x60, 0x21, 0x8f, - 0x80, 0x86, 0x1e, 0x02, 0x18, 0x38, 0x08, 0x43, 0x43, 0x7f, 0x10, 0x0d, 0xfc, 0x4c, 0x20, -}; -const uint8_t* _I_Ten_7x8[] = {_I_Ten_7x8_0}; -const Icon I_Ten_7x8 = - {.width = 18, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Ten_7x8}; - -const char* StateName[10] = { - /* use this for the status line and put in better wording */ - "Intro", // should never see this - "Select Bet", // cards are face down - "Choose Cards", // cards are revealed, player can choose which to hold - "Good Luck!" // cards are replaced, payouts here. -}; - -//const uint8_t _I_Splash_128x64_0[] = { -int Poker_Title; //Have we seen the title - -const char* suitname[4] = {"C", "D", "H", "S"}; - -#define AllAmerican 0 -#define TensOrBetter 1 -#define BonusPoker 2 -#define DoubleBonus 3 -#define DoubleBonusBonus 4 -#define JacksOrBetter 5 /* default */ -#define JacksOrBetter95 6 -#define JacksOrBetter86 7 -#define JacksOrBetter85 8 -#define JacksOrBetter75 9 -#define JacksOrBetter65 10 -/* If you add another game, increment NUMGAMES: */ -#define NUMGAMES 11 - -/* - The game in play. Default is Jacks or Better, - which is coded into initialization of static data -*/ - -int game = JacksOrBetter; - -const char* gamenames[NUMGAMES] = { - "All American", - "Tens or Better", - "Bonus Poker", - "Double Bonus", - "Double Bonus Bonus", - "Jacks or Better", - "9/5 Jacks or Better", - "8/6 Jacks or Better", - "8/5 Jacks or Better", - "7/5 Jacks or Better", - "6/5 Jacks or Better"}; - -/* Sanity check: check that there are no duplicate cards in hand */ - -void playcard(PokerPlayer* app) { - int i, c, crd; - - int hold[5]; - hold[5] = 2; - // int digit; - c = 1; - c++; - c = hold[5]; /* FIX for unused-but-set-variable */ - /* initialize deck */ - for(i = 0; i < 52; i++) deck[i].gone = 0; - - /* initialize hold[] */ - for(i = 0; i < 5; i++) hold[i] = 1; - - /* app->score -= bet; */ - - for(i = 0; i < 5; i++) { - /* find a card not already dealt */ - do crd = random() % 52; - while(deck[crd].gone); - hold[i] = 1; - deck[crd].gone = 1; - if(!app->held[i]) { - app->hand[i] = deck[crd]; - } - } -} - -int check_for_dupes(PokerPlayer* app) { - int i, j; - - for(i = 0; i < 5; i++) { - for(j = i + 1; j < 5; j++) { - if(app->hand[i].index == app->hand[j].index && app->hand[i].suit == app->hand[j].suit) - return 0; - } - } - - return 1; -} - -/* Functions that recognize winning hands */ - -/* - Flush: - returns 1 if the sorted hand is a flush -*/ - -int flush(PokerPlayer* app) { - if(app->shand[0].suit == app->shand[1].suit && app->shand[1].suit == app->shand[2].suit && - app->shand[2].suit == app->shand[3].suit && app->shand[3].suit == app->shand[4].suit) - return 1; - - return 0; -} - -/* - Straight: - returns 1 if the sorted hand is a straight -*/ - -int straight(PokerPlayer* app) { - if(app->shand[1].index == app->shand[0].index + 1 && - app->shand[2].index == app->shand[1].index + 1 && - app->shand[3].index == app->shand[2].index + 1 && - app->shand[4].index == app->shand[3].index + 1) - return 1; - - /* Ace low straight: Ace, 2, 3, 4, 5 */ - - if(app->shand[4].index == 13 && app->shand[0].index == 1 && app->shand[1].index == 2 && - app->shand[2].index == 3 && app->shand[3].index == 4) - return 1; - - return 0; -} - -/* - Four of a kind: - the middle 3 all match, and the first or last matches those -*/ - -int four(PokerPlayer* app) { - if((app->shand[1].index == app->shand[2].index && - app->shand[2].index == app->shand[3].index) && - (app->shand[0].index == app->shand[2].index || app->shand[4].index == app->shand[2].index)) - return 1; - - return 0; -} - -/* - Full house: - 3 of a kind and a pair -*/ - -int full(PokerPlayer* app) { - if(app->shand[0].index == app->shand[1].index && - (app->shand[2].index == app->shand[3].index && app->shand[3].index == app->shand[4].index)) - return 1; - - if(app->shand[3].index == app->shand[4].index && - (app->shand[0].index == app->shand[1].index && app->shand[1].index == app->shand[2].index)) - return 1; - - return 0; -} - -/* - Three of a kind: - it can appear 3 ways -*/ - -int three(PokerPlayer* app) { - if(app->shand[0].index == app->shand[1].index && app->shand[1].index == app->shand[2].index) - return 1; - - if(app->shand[1].index == app->shand[2].index && app->shand[2].index == app->shand[3].index) - return 1; - - if(app->shand[2].index == app->shand[3].index && app->shand[3].index == app->shand[4].index) - return 1; - - return 0; -} - -/* - Two pair: - it can appear in 3 ways -*/ - -int twopair(PokerPlayer* app) { - if(((app->shand[0].index == app->shand[1].index) && - (app->shand[2].index == app->shand[3].index)) || - ((app->shand[0].index == app->shand[1].index) && - (app->shand[3].index == app->shand[4].index)) || - ((app->shand[1].index == app->shand[2].index) && - (app->shand[3].index == app->shand[4].index))) - return 1; - - return 0; -} - -/* - Two of a kind (pair), jacks or better - or if the game is Tens or Better, 10s or better. -*/ - -int two(PokerPlayer* app) { - int min = 10; - - if(game == TensOrBetter) min = 9; - - if(app->shand[0].index == app->shand[1].index && app->shand[1].index >= min) return 1; - if(app->shand[1].index == app->shand[2].index && app->shand[2].index >= min) return 1; - if(app->shand[2].index == app->shand[3].index && app->shand[3].index >= min) return 1; - if(app->shand[3].index == app->shand[4].index && app->shand[4].index >= min) return 1; - - return 0; -} - -int paytable[10] = { - 800, /* royal flush: 800 */ - 50, /* straight flush: 50 */ - 25, /* 4 of a kind: 25 */ - 9, /* full house: 9 */ - 6, /* flush: 6 */ - 4, /* straight: 4 */ - 3, /* 3 of a kind: 3 */ - 2, /* two pair: 2 */ - 1, /* jacks or better: 1 */ - 0 /* nothing */ -}; - -const char* handname[10] = { - "Royal Flush", - "Straight Flush", - "Four of a Kind", - "Full House", - "Flush", - "Straight", - "Three of a Kind", - "Two Pair", - "Pair", - "Nothing", -}; - -int recognize(PokerPlayer* app) { - int i, j, f = 0; - int min = 100; - card tmp[5]; - int st = 0, fl = 0; - - /* Sort hand into sorted hand (app->shand) */ - - /* make copy of hand */ - for(i = 0; i < 5; i++) tmp[i] = app->hand[i]; - - for(i = 0; i < 5; i++) { - /* put lowest card in hand into next place in app->shand */ - - for(j = 0; j < 5; j++) - if(tmp[j].index <= min) { - min = tmp[j].index; - f = j; - } - - app->shand[i] = tmp[f]; - tmp[f].index = 100; /* larger than any card */ - min = 100; - } - - /* royal and straight flushes, strait, and flush */ - - fl = flush(app); - st = straight(app); - - if(st && fl && app->shand[0].index == 9) return 0; - if(st && fl) return 1; - if(four(app)) return 2; - if(full(app)) return 3; - if(fl) return 4; - if(st) return 5; - if(three(app)) return 6; - if(twopair(app)) return 7; - if(two(app)) return 8; - - /* Nothing */ - - return 9; -} - -void poker_draw_callback(Canvas* canvas, void* ctx) { - PokerPlayer* poker_player = ctx; - furi_check(osMutexAcquire(poker_player->model_mutex, osWaitForever) == osOK); - canvas_clear(canvas); - char buffer[25]; - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontSecondary); - - /* Magic Begins */ - - /* Status Info */ - if(poker_player->GameState != 0 && poker_player->GameState != 4) { - snprintf(buffer, sizeof(buffer), "%d", poker_player->score); - canvas_draw_str_aligned(canvas, 127, 0, AlignRight, AlignTop, buffer); - } - - /* Draw the Cards */ - if(poker_player->GameState == 1) { - snprintf(buffer, sizeof(buffer), "Bet:%d", poker_player->bet); - canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); - snprintf(buffer, sizeof(buffer), "<*> Place Bet"); - canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); - canvas_draw_icon(canvas, 5, 18, &I_CardBack_22x35); - - canvas_draw_icon(canvas, 29, 18, &I_CardBack_22x35); - - canvas_draw_icon(canvas, 53, 18, &I_CardBack_22x35); - - canvas_draw_icon(canvas, 77, 18, &I_CardBack_22x35); - - canvas_draw_icon(canvas, 101, 18, &I_CardBack_22x35); - - } - - else if(poker_player->GameState == 2 || poker_player->GameState == 3) { - snprintf(buffer, sizeof(buffer), "Pot:%d", poker_player->bet); - canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); - snprintf(buffer, sizeof(buffer), "<*> Select Hold"); - canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); - - /* snprintf( - buffer, - sizeof(buffer), - "%s:%ix", - handname[recognize(poker_player)], - paytable[recognize(poker_player)]); - canvas_draw_str_aligned(canvas, 5, 5, AlignLeft, AlignTop, buffer); */ - - poker_player->held[0] ? canvas_draw_rbox(canvas, 5, 18, 22, 35, 3) : - canvas_draw_rframe(canvas, 5, 18, 22, 35, 3); - - poker_player->held[1] ? canvas_draw_rbox(canvas, 29, 18, 22, 35, 3) : - canvas_draw_rframe(canvas, 29, 18, 22, 35, 3); - - poker_player->held[2] ? canvas_draw_rbox(canvas, 53, 18, 22, 35, 3) : - canvas_draw_rframe(canvas, 53, 18, 22, 35, 3); - - poker_player->held[3] ? canvas_draw_rbox(canvas, 77, 18, 22, 35, 3) : - canvas_draw_rframe(canvas, 77, 18, 22, 35, 3); - - poker_player->held[4] ? canvas_draw_rbox(canvas, 101, 18, 22, 35, 3) : - canvas_draw_rframe(canvas, 101, 18, 22, 35, 3); - - //shameful - poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - - if(poker_player->hand[0].suit == 0) // club - canvas_draw_icon(canvas, 18, 43, &I_club_7x8); - - if(poker_player->hand[0].suit == 1) // diamond - canvas_draw_icon(canvas, 18, 43, &I_diamond_7x8); - - if(poker_player->hand[0].suit == 2) // heart - canvas_draw_icon(canvas, 18, 43, &I_hearts_7x8); - - if(poker_player->hand[0].suit == 3) // spade - canvas_draw_icon(canvas, 18, 43, &I_spade_7x8); - - //canvas_draw_str_aligned(canvas, 25, 49, AlignRight, AlignBottom, buffer); - - poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - - if(poker_player->hand[1].suit == 0) // club - canvas_draw_icon(canvas, 42, 43, &I_club_7x8); - - if(poker_player->hand[1].suit == 1) // diamond - canvas_draw_icon(canvas, 42, 43, &I_diamond_7x8); - - if(poker_player->hand[1].suit == 2) // heart - canvas_draw_icon(canvas, 42, 43, &I_hearts_7x8); - - if(poker_player->hand[1].suit == 3) // spade - canvas_draw_icon(canvas, 42, 43, &I_spade_7x8); - - //canvas_draw_str_aligned(canvas, 49, 49, AlignRight, AlignBottom, buffer); - - poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - - if(poker_player->hand[2].suit == 0) // club - canvas_draw_icon(canvas, 66, 43, &I_club_7x8); - - if(poker_player->hand[2].suit == 1) // diamond - canvas_draw_icon(canvas, 66, 43, &I_diamond_7x8); - - if(poker_player->hand[2].suit == 2) // heart - canvas_draw_icon(canvas, 66, 43, &I_hearts_7x8); - - if(poker_player->hand[2].suit == 3) // spade - canvas_draw_icon(canvas, 66, 43, &I_spade_7x8); - - // canvas_draw_str_aligned(canvas, 73, 49, AlignRight, AlignBottom, buffer); - - poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - - if(poker_player->hand[3].suit == 0) // club - canvas_draw_icon(canvas, 90, 43, &I_club_7x8); - - if(poker_player->hand[3].suit == 1) // diamond - canvas_draw_icon(canvas, 90, 43, &I_diamond_7x8); - - if(poker_player->hand[3].suit == 2) // heart - canvas_draw_icon(canvas, 90, 43, &I_hearts_7x8); - - if(poker_player->hand[3].suit == 3) // spade - canvas_draw_icon(canvas, 90, 43, &I_spade_7x8); - - // canvas_draw_str_aligned(canvas, 97, 49, AlignRight, AlignBottom, buffer); - - poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - - if(poker_player->hand[4].suit == 0) // club - canvas_draw_icon(canvas, 113, 43, &I_club_7x8); - - if(poker_player->hand[4].suit == 1) // diamond - canvas_draw_icon(canvas, 113, 43, &I_diamond_7x8); - - if(poker_player->hand[4].suit == 2) // heart - canvas_draw_icon(canvas, 113, 43, &I_hearts_7x8); - - if(poker_player->hand[4].suit == 3) // spade - canvas_draw_icon(canvas, 113, 43, &I_spade_7x8); - - //canvas_draw_str_align-ed(canvas, 120, 50, AlignRight, AlignBottom, buffer); - - canvas_set_font(canvas, FontBigNumbers); - if(poker_player->hand[0].index >= 1 && poker_player->hand[0].index <= 8) { - poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[0].sym); - canvas_draw_str_aligned(canvas, 7, 22, AlignLeft, AlignTop, buffer); - } else { - poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - if(poker_player->hand[0].index == 9) // Ten - canvas_draw_icon(canvas, 7, 22, &I_Ten_7x8); - - if(poker_player->hand[0].index == 10) // Jack - canvas_draw_icon(canvas, 7, 22, &I_Jack_7x8); - - if(poker_player->hand[0].index == 11) // Queen - canvas_draw_icon(canvas, 7, 22, &I_Queen_7x8); - - if(poker_player->hand[0].index == 12) // King - canvas_draw_icon(canvas, 7, 22, &I_King_7x8); - - if(poker_player->hand[0].index == 13) // ace - canvas_draw_icon(canvas, 7, 22, &I_Ace_7x8); - } - if(poker_player->hand[1].index >= 0 && poker_player->hand[1].index <= 8) { - poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[1].sym); - canvas_draw_str_aligned(canvas, 31, 22, AlignLeft, AlignTop, buffer); - } else { - /* bitmap time */ - poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - if(poker_player->hand[1].index == 9) // Ten - canvas_draw_icon(canvas, 31, 22, &I_Ten_7x8); - - if(poker_player->hand[1].index == 10) // Jack - canvas_draw_icon(canvas, 31, 22, &I_Jack_7x8); - - if(poker_player->hand[1].index == 11) // Queen - canvas_draw_icon(canvas, 31, 22, &I_Queen_7x8); - - if(poker_player->hand[1].index == 12) // King - canvas_draw_icon(canvas, 31, 22, &I_King_7x8); - - if(poker_player->hand[1].index == 13) // ace - canvas_draw_icon(canvas, 31, 22, &I_Ace_7x8); - } - if(poker_player->hand[2].index >= 0 && poker_player->hand[2].index <= 8) { - poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[2].sym); - canvas_draw_str_aligned(canvas, 55, 22, AlignLeft, AlignTop, buffer); - } else { - /* bitmap time */ - poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - if(poker_player->hand[2].index == 9) // Ten - canvas_draw_icon(canvas, 55, 22, &I_Ten_7x8); - - if(poker_player->hand[2].index == 10) // Jack - canvas_draw_icon(canvas, 55, 22, &I_Jack_7x8); - - if(poker_player->hand[2].index == 11) // Queen - canvas_draw_icon(canvas, 55, 22, &I_Queen_7x8); - - if(poker_player->hand[2].index == 12) // King - canvas_draw_icon(canvas, 55, 22, &I_King_7x8); - - if(poker_player->hand[2].index == 13) // ace - canvas_draw_icon(canvas, 55, 22, &I_Ace_7x8); - } - if(poker_player->hand[3].index >= 0 && poker_player->hand[3].index <= 8) { - poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[3].sym); - canvas_draw_str_aligned(canvas, 79, 22, AlignLeft, AlignTop, buffer); - } else { - /* bitmap time */ - poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - if(poker_player->hand[3].index == 9) // Ten - canvas_draw_icon(canvas, 79, 22, &I_Ten_7x8); - - if(poker_player->hand[3].index == 10) // Jack - canvas_draw_icon(canvas, 79, 22, &I_Jack_7x8); - - if(poker_player->hand[3].index == 11) // Queen - canvas_draw_icon(canvas, 79, 22, &I_Queen_7x8); - - if(poker_player->hand[3].index == 12) // King - canvas_draw_icon(canvas, 79, 22, &I_King_7x8); - - if(poker_player->hand[3].index == 13) // ace - canvas_draw_icon(canvas, 79, 22, &I_Ace_7x8); - } - if(poker_player->hand[4].index >= 0 && poker_player->hand[4].index <= 8) { - poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[4].sym); - canvas_draw_str_aligned(canvas, 103, 22, AlignLeft, AlignTop, buffer); - } else { - /* bitmap time */ - poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : - canvas_set_color(canvas, ColorBlack); - if(poker_player->hand[4].index == 9) // Ten - canvas_draw_icon(canvas, 103, 22, &I_Ten_7x8); - - if(poker_player->hand[4].index == 10) // Jack - canvas_draw_icon(canvas, 103, 22, &I_Jack_7x8); - - if(poker_player->hand[4].index == 11) // Queen - canvas_draw_icon(canvas, 103, 22, &I_Queen_7x8); - - if(poker_player->hand[4].index == 12) // King - canvas_draw_icon(canvas, 103, 22, &I_King_7x8); - - if(poker_player->hand[4].index == 13) // ace - canvas_draw_icon(canvas, 103, 22, &I_Ace_7x8); - } - - /* Draw the Select hand */ - if(poker_player->GameState == 2) { - canvas_set_color(canvas, ColorBlack); - if(poker_player->selected == 0) { - canvas_draw_icon(canvas, 11, 54, &I_Hand_12x10); - } - - if(poker_player->selected == 1) { - canvas_draw_icon(canvas, 35, 54, &I_Hand_12x10); - } - - if(poker_player->selected == 2) { - canvas_draw_icon(canvas, 58, 54, &I_Hand_12x10); - } - - if(poker_player->selected == 3) { - canvas_draw_icon(canvas, 83, 54, &I_Hand_12x10); - } - - if(poker_player->selected == 4) { - canvas_draw_icon(canvas, 109, 54, &I_Hand_12x10); - } - } - } // GameState 2 or 3 - - canvas_set_color(canvas, ColorBlack); - canvas_set_font(canvas, FontSecondary); - if(poker_player->GameState == 3) { - snprintf( - buffer, - sizeof(buffer), - "%s:%ix", - handname[recognize(poker_player)], - paytable[recognize(poker_player)]); - canvas_draw_str_aligned(canvas, 63, 63, AlignCenter, AlignBottom, buffer); - } - if(poker_player->GameState == 0) { - canvas_draw_icon(canvas, 0, 0, &I_Splash_128x64); - } - if(poker_player->GameState == 4) { - canvas_draw_icon(canvas, 0, 0, &I_BadEnd_128x64); - } - - osMutexRelease(poker_player->model_mutex); -} - -void poker_input_callback(InputEvent* input, void* ctx) { - PokerPlayer* poker_player = ctx; - osMessageQueuePut(poker_player->event_queue, input, 0, osWaitForever); -} - -PokerPlayer* poker_player_alloc() { - PokerPlayer* poker_player = malloc(sizeof(PokerPlayer)); - - poker_player->score = 1000; - poker_player->model_mutex = osMutexNew(NULL); - poker_player->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); - poker_player->view_port = view_port_alloc(); - poker_player->selected = 0; - poker_player->GameState = 0; - poker_player->bet = 10; - poker_player->minbet = 10; - - playcard( - poker_player); /* Get things rolling before the player gets into the game. This will preload the hand. */ - view_port_draw_callback_set(poker_player->view_port, poker_draw_callback, poker_player); - - view_port_input_callback_set(poker_player->view_port, poker_input_callback, poker_player); - - poker_player->gui = furi_record_open("gui"); - gui_add_view_port(poker_player->gui, poker_player->view_port, GuiLayerFullscreen); - - return poker_player; -} - -void poker_player_free(PokerPlayer* poker_player) { - view_port_enabled_set(poker_player->view_port, false); - gui_remove_view_port(poker_player->gui, poker_player->view_port); - furi_record_close("gui"); - view_port_free(poker_player->view_port); - osMessageQueueDelete(poker_player->event_queue); - osMutexDelete(poker_player->model_mutex); - - free(poker_player); -} - -int32_t video_poker_app(void* p) { - UNUSED(p); - PokerPlayer* poker_player = poker_player_alloc(); - - InputEvent event; - for(bool processing = true; processing;) { - osStatus_t status = osMessageQueueGet(poker_player->event_queue, &event, NULL, 100); - furi_check(osMutexAcquire(poker_player->model_mutex, osWaitForever) == osOK); - if(status == osOK) { - if(event.type == InputTypePress) { - switch(event.key) { - case InputKeyUp: - Poker_Shaker(); - break; - case InputKeyDown: - if(poker_player->GameState == 2) { - playcard(poker_player); - if(check_for_dupes(poker_player) == 0) { - playcard(poker_player); - } - - poker_player->GameState = 3; - } - break; - case InputKeyLeft: - if(poker_player->GameState == 1) { - if(poker_player->bet >= poker_player->minbet + 10) { - poker_player->bet -= 10; - } - } else if(poker_player->selected > 0 && poker_player->GameState == 2) { - poker_player->selected--; - } // Move hand left/right - else if(poker_player->selected == 0 && poker_player->GameState == 2) { - poker_player->selected = 4; //wraparound - } - break; - case InputKeyRight: - if(poker_player->GameState == 1) { - if(poker_player->bet < poker_player->score + 10) { - poker_player->bet += 10; - } - } - if(poker_player->selected < 4 && poker_player->GameState == 2) { - poker_player->selected++; - } // Move hand left/right - else if(poker_player->selected == 4 && poker_player->GameState == 2) { - poker_player->selected = 0; //wraparound - } - break; - case InputKeyOk: - if(poker_player->GameState == 0) { - poker_player->GameState = 1; - } else if(poker_player->GameState == 1) { - poker_player->score -= poker_player->bet; - poker_player->GameState = 2; - } else if(poker_player->GameState == 2) { - poker_player->held[poker_player->selected] = - !poker_player - ->held[poker_player->selected]; //cursed and bad pls replace - } else if(poker_player->GameState == 3) { - if(recognize(poker_player) != 9) { - poker_player->score += - poker_player->bet * paytable[recognize(poker_player)]; - } - poker_player->GameState = 1; - if(poker_player->bet > poker_player->score) { - poker_player->bet = poker_player->score; - } - poker_player->held[0] = 0; - poker_player->held[1] = 0; - poker_player->held[2] = 0; - poker_player->held[3] = 0; - poker_player->held[4] = 0; - if(poker_player->score <= 0) { - poker_player->GameState = 4; - } - playcard(poker_player); // shuffle shuffle - } else if(poker_player->GameState == 4) { - Poker_Shaker(); - processing = false; - } - break; - case InputKeyBack: - processing = false; - break; - } - } - } - osMutexRelease(poker_player->model_mutex); - view_port_update(poker_player->view_port); - } - - poker_player_free(poker_player); - return 0; -} diff --git a/applications/applications.c b/applications/applications.c index 44a905b9c86..1fad43e4f7b 100644 --- a/applications/applications.c +++ b/applications/applications.c @@ -50,7 +50,8 @@ extern int32_t music_player_app(void* p); extern int32_t snake_game_app(void* p); extern int32_t tetris_game_app(void *p); extern int32_t clock_app(void *p); -extern int32_t box_mover_app(void* p); +//extern int32_t box_mover_app(void* p); +extern int32_t video_poker_app(void* p); // extern int32_t floopper_bloopper(void* p); extern int32_t raycast_game_app(void* p); extern int32_t spectrum_analyzer_app(void* p); @@ -359,6 +360,7 @@ const FlipperApplication FLIPPER_GAMES[] = { .flags = FlipperApplicationFlagDefault}, #endif + #ifdef APP_VIDEO_POKER {.app = video_poker_app, .name = "Video Poker", diff --git a/applications/applications.mk b/applications/applications.mk index c17254a30a9..64f8918b1d5 100644 --- a/applications/applications.mk +++ b/applications/applications.mk @@ -49,6 +49,7 @@ APP_MUSIC_PLAYER = 1 APP_SNAKE_GAME = 1 APP_TETRIS_GAME = 1 APP_RAYCAST_GAME = 1 +APP_VIDEO_POKER = 1 # APP_RAYCAST_GAME = 1 APP_CLOCK = 1 APP_SPECTRUM_ANALYZER = 1 @@ -285,6 +286,12 @@ CFLAGS += -DAPP_BOX_MOVER SRV_GUI = 1 endif +APP_VIDEO_POKER ?= 0 +ifeq ($(APP_VIDEO_POKER),1) +CFLAGS += -DAPP_VIDEO_POKER +SRV_GUI = 1 +endif + APP_SPECTRUM_ANALYZER ?= 0 ifeq ($(APP_SPECTRUM_ANALYZER), 1) CFLAGS += -DAPP_SPECTRUM_ANALYZER diff --git a/scripts/User/iconencode.py b/scripts/User/iconencode.py index 409327c2058..67ba05d1baf 100644 --- a/scripts/User/iconencode.py +++ b/scripts/User/iconencode.py @@ -54,7 +54,10 @@ def padded_hex(i, l): # a bit ugly. framename="_I_"+infile+"_"+dims - +print(len(b)) +#d=len(b) +# if b > 255 split 0x1234 into 0x34,0x12 +#d=hex(len(b)) char_out = "const uint8_t "+framename+"_0[] = {"+ str(c) + ",};" char_out2 = "const uint8_t "+framename+"[] = {"+framename+"_0};" From 1a80d506f751c389f12611bd3f7c202fb9bbe4ce Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Mon, 13 Jun 2022 11:10:05 -0700 Subject: [PATCH 66/91] Still a bit messy. But it seems to be good now. --- applications/VideoPoker/poker.c | 1023 +++++++++++++++++++++++++++++++ 1 file changed, 1023 insertions(+) create mode 100644 applications/VideoPoker/poker.c diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c new file mode 100644 index 00000000000..1b625250068 --- /dev/null +++ b/applications/VideoPoker/poker.c @@ -0,0 +1,1023 @@ +#include +#include +#include +#include +#include +#include +#include +#include "assets_icons.h" +#include + +/* KNOWN BUGS +This has been converted from a standalone PC console app to flipper +All of the original input/output handing code has been ripped out +Original code also used TONS of defines and everything was a global. +I have not completed cleaning up and moving globals to members. + +It's not super well written but I think it at least meets a minimum expectation of quality +A lot of it could be cleaned up or optimized. +As is, it does what it wanted and doesn't seem to have major issues, so that's pretty good. +Game logic is handled during input and this is a bit of a mess of nested ifs. +Sometimes duplicate cards will show up. there is a function to test this. I should use it better. +After losing, bet is set to 10 eve +*/ + +#define TAG "Video Poker" + +void Poker_Shaker(void) { + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); +} + +typedef struct { + int index; /* cards value, minus 1 */ + char* sym; /* text appearance */ + int suit; /* card's suit (see just below) */ + int gone; /* true if it's been dealt */ + int held; /* for hand */ +} card; + +typedef struct { + osMutexId_t* model_mutex; + osMessageQueueId_t event_queue; + ViewPort* view_port; + Gui* gui; + card hand[5]; + card shand[5]; + card deck[52]; + int held[5]; + int score; + int pot; + int GameState; + int selected; + int bet; + int minbet; +} PokerPlayer; + + +card deck[52] = { + /* index, card name, suit, gone */ + /* Clubs:0 Diamonds:1 Hearts: 2 Spades: 3 */ + {1, "2", 0, 0}, {2, "3", 0, 0}, {3, "4", 0, 0}, {4, "5", 0, 0}, {5, "6", 0, 0}, + {6, "7", 0, 0}, {7, "8", 0, 0}, {8, "9", 0, 0}, {9, "10", 0, 0}, {10, "J", 0, 0}, + {11, "Q", 0, 0}, {12, "K", 0, 0}, {13, "A", 0, 0}, + + {1, "2", 1, 0}, {2, "3", 1, 0}, {3, "4", 1, 0}, {4, "5", 1, 0}, {5, "6", 1, 0}, + {6, "7", 1, 0}, {7, "8", 1, 0}, {8, "9", 1, 0}, {9, "10", 1, 0}, {10, "J", 1, 0}, + {11, "Q", 1, 0}, {12, "K", 1, 0}, {13, "A", 1, 0}, + + {1, "2", 2, 0}, {2, "3", 2, 0}, {3, "4", 2, 0}, {4, "5", 2, 0}, {5, "6", 2, 0}, + {6, "7", 2, 0}, {7, "8", 2, 0}, {8, "9", 2, 0}, {9, "10", 2, 0}, {10, "J", 2, 0}, + {11, "Q", 2, 0}, {12, "K", 2, 0}, {13, "A", 2, 0}, + + {1, "2", 3, 0}, {2, "3", 3, 0}, {3, "4", 3, 0}, {4, "5", 3, 0}, {5, "6", 3, 0}, + {6, "7", 3, 0}, {7, "8", 3, 0}, {8, "9", 3, 0}, {9, "10", 3, 0}, {10, "J", 3, 0}, + {11, "Q", 3, 0}, {12, "K", 3, 0}, {13, "A", 3, 0}, +}; +/* +int score_low = 1000; + int score_high = 1000; + int minbet = 10; + int betmultiplier = 1; + */ +/* GameState +0=Splash/help, OK button (later on up/down for rules or settings) +1=cards down, betting enabled, left/right to change bet, OK to confirm +2=first hand, holding enabled, left/right to pick card, OK to hold/unhold card, down to confirm +3=second hand, only confirm to claim rewards +4=game over/won +*/ + +/* +Image Format +0x01 = Compressed +0x00 = Reserved Section +0xa4,0x01 = 0x1a4, or, 420 - the size of the compressed array, minus this header. +Rest of the data is char array output from heatshrink of the original XBM char array. +Calculated Header: 0x01,0x00,0xa4,0x01 +from furi_hal_compress.c +typedef struct { + uint8_t is_compressed; + uint8_t reserved; + uint16_t compressed_buff_size; +} FuriHalCompressHeader; +*/ + +const uint8_t _I_Splash_128x64_0[] = { + 0x01, 0x00, 0x8a, 0x02, 0x00, 0x78, 0x02, 0x60, 0xe0, 0x54, 0xc0, 0x03, 0x9f, 0xc0, 0x0f, 0x5a, + 0x04, 0x04, 0x1e, 0xdf, 0x08, 0x78, 0x0c, 0x60, 0xc0, 0x21, 0x90, 0x40, 0xa3, 0x00, 0xf5, 0xfe, + 0x61, 0xc1, 0xe9, 0x1e, 0x8e, 0x59, 0xf0, 0x02, 0x24, 0x9f, 0x70, 0xc0, 0x63, 0x03, 0x01, 0x0c, + 0x0b, 0xc1, 0x80, 0xbc, 0x83, 0xd3, 0x3f, 0x63, 0x98, 0x03, 0xcf, 0x88, 0x02, 0x1c, 0x31, 0x5d, + 0x38, 0xf6, 0x19, 0xc0, 0xa0, 0xfc, 0x93, 0x13, 0x12, 0xf0, 0x38, 0x76, 0x08, 0xc7, 0x00, 0x1e, + 0x5e, 0x8b, 0xcc, 0x32, 0x86, 0x0f, 0x4f, 0x0c, 0x80, 0x06, 0x20, 0x72, 0xe4, 0x5e, 0x33, 0xd4, + 0x73, 0xf2, 0x5d, 0xe2, 0x10, 0xef, 0xe6, 0x02, 0x0f, 0x07, 0x84, 0x4c, 0x33, 0xd2, 0x70, 0x79, + 0xd8, 0x2e, 0x11, 0x88, 0x3d, 0xff, 0xc1, 0xc7, 0x83, 0xc4, 0x20, 0x10, 0xc9, 0x18, 0x3d, 0x27, + 0x18, 0x8c, 0x3c, 0xde, 0xe1, 0xe6, 0x87, 0x7e, 0x0c, 0x62, 0x12, 0x10, 0x01, 0xce, 0x31, 0x9c, + 0x39, 0x9c, 0x62, 0x67, 0x0f, 0x83, 0x7f, 0x27, 0xe0, 0xf5, 0x8c, 0x71, 0xbc, 0x31, 0x8c, 0xc4, + 0xe2, 0x1e, 0x62, 0x1e, 0x02, 0xe0, 0x80, 0x05, 0x1c, 0xe1, 0xdc, 0x23, 0x97, 0xc8, 0xe4, 0x5c, + 0x12, 0x50, 0x40, 0x7a, 0x43, 0x38, 0x77, 0x88, 0xf4, 0x36, 0x3d, 0x1f, 0x04, 0x94, 0x20, 0x1e, + 0x98, 0xce, 0x0d, 0xbe, 0x37, 0x0d, 0xcd, 0xbd, 0x0c, 0x7e, 0xbe, 0xce, 0x07, 0x1f, 0xf3, 0xfc, + 0xf8, 0xb2, 0x8d, 0x30, 0x20, 0x53, 0xbe, 0x60, 0x06, 0x03, 0x78, 0xf0, 0x06, 0x4c, 0x1e, 0x34, + 0x10, 0x29, 0x5e, 0x05, 0x0f, 0x00, 0xa0, 0x40, 0x24, 0x20, 0x52, 0x76, 0x88, 0x01, 0xc1, 0xe3, + 0x11, 0x05, 0xc3, 0xe9, 0x20, 0x10, 0x97, 0x01, 0xcf, 0xc1, 0xf2, 0x81, 0x3f, 0xe7, 0xfc, 0x66, + 0xf4, 0x02, 0xf1, 0xc0, 0x3f, 0xdf, 0xf0, 0x30, 0xc6, 0x1e, 0xe5, 0xff, 0x81, 0xf0, 0x3f, 0xe5, + 0xb2, 0x80, 0x7f, 0xc1, 0xe5, 0x1c, 0x03, 0x0f, 0xe3, 0xff, 0x1f, 0xf8, 0x02, 0x48, 0x00, 0x31, + 0xfe, 0x0b, 0xa4, 0x61, 0xcc, 0x62, 0xfc, 0x4f, 0xe3, 0x0f, 0x31, 0x41, 0x0e, 0x02, 0x07, 0x01, + 0x07, 0x8a, 0xb4, 0xa3, 0x84, 0x71, 0x8f, 0xff, 0x20, 0x77, 0x00, 0x78, 0x95, 0x46, 0x06, 0x13, + 0x10, 0x78, 0xef, 0x3f, 0x5f, 0xfc, 0xff, 0xea, 0x07, 0xf0, 0x37, 0x90, 0x3c, 0x78, 0x00, 0xf2, + 0xae, 0x7f, 0x77, 0xf7, 0xaf, 0xec, 0x0f, 0x88, 0x41, 0x1b, 0x06, 0x02, 0x03, 0xc0, 0x02, 0x8c, + 0x08, 0x5c, 0x37, 0xff, 0xa9, 0x3c, 0x7b, 0xcc, 0x52, 0xe0, 0x70, 0x7c, 0x31, 0x89, 0xe4, 0xff, + 0xfb, 0xff, 0xdf, 0x8c, 0x46, 0x03, 0x1f, 0x34, 0x17, 0x83, 0xe1, 0x71, 0x8f, 0x6f, 0xe7, 0xe0, + 0xc1, 0x8f, 0xfd, 0x20, 0x18, 0x65, 0x59, 0x47, 0xaf, 0x9b, 0x8b, 0x9e, 0x6f, 0xe7, 0x1f, 0x16, + 0x0c, 0x3e, 0x3d, 0x00, 0xe4, 0x43, 0xd1, 0xe5, 0x3f, 0xe6, 0x6e, 0xfb, 0x39, 0x88, 0x67, 0xea, + 0xff, 0xc5, 0x22, 0x8f, 0xc0, 0xf0, 0x41, 0x71, 0xe7, 0x76, 0xf9, 0x98, 0x48, 0x64, 0x17, 0x59, + 0x38, 0x05, 0x8f, 0xc0, 0xd0, 0x5f, 0xe8, 0x0f, 0x1a, 0xdb, 0xe6, 0xb1, 0xd1, 0xa0, 0x50, 0x85, + 0x59, 0x7e, 0x16, 0x05, 0x06, 0x80, 0x71, 0xbf, 0xf7, 0x19, 0x85, 0x99, 0x74, 0x6d, 0x31, 0x02, + 0x10, 0x88, 0x7c, 0xdd, 0xdb, 0x84, 0x62, 0x7c, 0x0f, 0x38, 0xe5, 0xf0, 0x1e, 0x97, 0xce, 0x67, + 0xbc, 0xb6, 0x40, 0xa3, 0x98, 0x00, 0xc5, 0x76, 0x53, 0x8c, 0x67, 0x1e, 0x07, 0x0e, 0x63, 0x0a, + 0xe4, 0x9c, 0x62, 0x0f, 0x11, 0x41, 0x95, 0x88, 0x1e, 0x41, 0xd1, 0x8c, 0x49, 0x80, 0xe6, 0x00, + 0x50, 0xb8, 0xa3, 0x07, 0xf1, 0x7f, 0x06, 0xb8, 0x00, 0x61, 0xce, 0xb2, 0x9c, 0x53, 0x01, 0xf3, + 0xf0, 0x55, 0x97, 0xd0, 0x3f, 0x40, 0x03, 0xfd, 0x33, 0xc8, 0x01, 0x71, 0x92, 0x78, 0x80, 0x2f, + 0x80, 0x6f, 0x20, 0x03, 0xff, 0x23, 0xe7, 0x02, 0x02, 0x18, 0x01, 0xa3, 0x91, 0x00, 0x18, 0xc3, + 0x20, 0x91, 0xc0, 0x7c, 0x7f, 0x83, 0x42, 0xaa, 0x1f, 0xe0, 0xbe, 0x60, 0x46, 0xa2, 0x81, 0xe2, + 0x24, 0x21, 0xf9, 0x54, 0x14, 0x18, 0x9e, 0x3f, 0xe4, 0x29, 0x00, 0x12, 0x0e, 0xb0, 0x28, 0x50, + 0x3c, 0x60, 0x50, 0x85, 0xf4, 0x7f, 0xb8, 0x3f, 0xf3, 0xf8, 0x83, 0xe0, 0x00, 0x38, 0x6e, 0x0c, + 0xc3, 0xf2, 0x2f, 0x94, 0x09, 0x07, 0xc7, 0xf7, 0x3f, 0xfe, 0x0d, 0xc4, 0x00, 0xfc, 0x4c, 0x05, + 0x86, 0x15, 0x23, 0x92, 0x03, 0xe7, 0xf9, 0x80, 0x0f, 0x97, 0x52, 0x0c, 0x2f, 0xb1, 0xf8, 0xe3, + 0x01, 0xf3, 0x82, 0x27, 0x8d, 0xe6, 0x41, 0x1c, 0x17, 0xcf, 0xfc, 0x3e, 0x64, 0xf8, +}; +const uint8_t* _I_Splash_128x64[] = {_I_Splash_128x64_0}; +const Icon I_Splash_128x64 = + {.width = 128, .height = 64, .frame_count = 1, .frame_rate = 0, .frames = _I_Splash_128x64}; + +const uint8_t _I_BadEnd_128x64_0[] = { + 0x01, 0x00, 0xDF, 0x01, 0x00, 0x2c, 0x12, 0x01, 0x02, 0x80, 0x40, 0x70, 0x10, 0x0a, 0x04, 0x02, + 0x41, 0x3e, 0xcf, 0x63, 0xfb, 0xfe, 0xc8, 0x18, 0x3e, 0x6f, 0xdb, 0xfc, 0xf8, 0x3c, 0x60, 0xe0, + 0xf9, 0xb3, 0x6c, 0xf3, 0x3c, 0x1b, 0x6c, 0x18, 0x5f, 0x40, 0xf1, 0xe7, 0xdb, 0xc1, 0xf4, 0x2f, + 0x10, 0x78, 0xdb, 0xbc, 0xdf, 0xf0, 0x04, 0x59, 0x81, 0xe3, 0xc1, 0xb6, 0x41, 0x83, 0xd1, 0x00, + 0xbf, 0x6c, 0xc9, 0xe6, 0x0f, 0x91, 0xf8, 0x9b, 0xcc, 0x1f, 0x20, 0x06, 0x07, 0xf8, 0x3e, 0x0b, + 0x32, 0x00, 0x50, 0x88, 0xc4, 0x20, 0x10, 0x85, 0xfd, 0x03, 0xfc, 0x1f, 0xe0, 0xff, 0x07, 0xf9, + 0x7f, 0xc3, 0xdc, 0x89, 0x10, 0x7d, 0x00, 0x04, 0x1f, 0xe0, 0xfd, 0xfc, 0x40, 0xc1, 0xfb, 0x07, + 0x8e, 0x2f, 0xf3, 0x9f, 0x00, 0xb0, 0x7f, 0x97, 0xf6, 0x0a, 0x11, 0x10, 0xa3, 0xec, 0x10, 0x21, + 0x32, 0x07, 0xd0, 0x18, 0x40, 0xa2, 0x0f, 0xb0, 0x20, 0x81, 0xc4, 0x1f, 0xeb, 0xfa, 0xbf, 0x84, + 0x86, 0x01, 0xc8, 0x5f, 0xd0, 0x0c, 0x81, 0xe2, 0x05, 0x10, 0x7e, 0xdc, 0xc1, 0xf5, 0x01, 0xe0, + 0x41, 0xf2, 0x17, 0xf0, 0x7d, 0xaf, 0x0a, 0x7e, 0x0f, 0xbf, 0x84, 0x7f, 0x21, 0x1f, 0x2b, 0x8e, + 0x3c, 0xbe, 0xd3, 0xf0, 0x78, 0xc4, 0xfa, 0x0b, 0xf2, 0x00, 0x08, 0x81, 0xa1, 0xf3, 0x08, 0x9f, + 0xc0, 0x1e, 0x57, 0x00, 0x7b, 0x60, 0x60, 0x3e, 0x08, 0x4f, 0x80, 0x1e, 0x59, 0x05, 0xc1, 0x03, + 0xce, 0xc3, 0x00, 0x2f, 0x88, 0x3c, 0xe2, 0x10, 0x20, 0x78, 0xbd, 0xc6, 0xff, 0x7c, 0x8c, 0x0e, + 0x48, 0x1e, 0x90, 0x48, 0x47, 0xe2, 0x06, 0x1b, 0x1e, 0x3c, 0x1c, 0x1e, 0x80, 0x01, 0x93, 0xad, + 0x06, 0x1e, 0x0a, 0x28, 0x04, 0x18, 0x1e, 0x81, 0xe1, 0x90, 0x20, 0x46, 0x49, 0xa9, 0x91, 0x3e, + 0x46, 0xf8, 0x0f, 0xac, 0x48, 0x3c, 0xb0, 0x82, 0x52, 0x07, 0xa1, 0x08, 0x43, 0xe5, 0x72, 0x93, + 0x41, 0x7e, 0x01, 0x01, 0x07, 0xc7, 0x8a, 0x97, 0xa9, 0x39, 0x88, 0xa0, 0x7f, 0x00, 0xf2, 0x08, + 0x0c, 0x03, 0x25, 0x54, 0x88, 0xe9, 0x66, 0x11, 0xc2, 0x99, 0x9e, 0x07, 0xff, 0x13, 0x90, 0x7f, + 0xb2, 0x60, 0xf2, 0xaa, 0x79, 0x1b, 0xe5, 0x01, 0xfe, 0x1f, 0xca, 0x41, 0x08, 0xb0, 0xd4, 0xe2, + 0x33, 0x9c, 0x9f, 0x13, 0xff, 0x07, 0xc0, 0x0c, 0x04, 0x1e, 0x54, 0x08, 0x40, 0x64, 0x80, 0x03, + 0x84, 0xff, 0xc0, 0x68, 0x10, 0x0f, 0x80, 0x3d, 0x13, 0xc2, 0x00, 0x28, 0x25, 0xfa, 0x00, 0x0f, + 0x76, 0x60, 0x83, 0xcc, 0x04, 0x20, 0xc1, 0x07, 0xaf, 0xc8, 0x52, 0x52, 0x00, 0x7a, 0x2f, 0xcc, + 0x16, 0x31, 0x30, 0x49, 0x48, 0x17, 0xe5, 0x20, 0xc0, 0x23, 0xce, 0x81, 0x80, 0x88, 0xe6, 0x24, + 0x7c, 0x69, 0xc0, 0xd0, 0xa2, 0x1c, 0x00, 0x79, 0x85, 0x07, 0xe3, 0xa4, 0xb0, 0x4a, 0x64, 0xa0, + 0xf3, 0x57, 0x9d, 0x82, 0x01, 0x80, 0x84, 0x54, 0xb2, 0x19, 0x48, 0x91, 0x90, 0xa2, 0x1f, 0x00, + 0x79, 0x0f, 0x87, 0x80, 0x0f, 0x44, 0x21, 0x03, 0xd0, 0x3e, 0x26, 0x01, 0xa6, 0x44, 0x2c, 0x79, + 0xc0, 0x79, 0xb3, 0xc4, 0xbe, 0x5e, 0x01, 0x08, 0x80, 0x09, 0x56, 0x20, 0x01, 0x98, 0x03, 0xc4, + 0xfe, 0x51, 0x0b, 0xf8, 0x3c, 0xf8, 0x00, 0x32, 0x9c, 0x7f, 0x01, 0xe8, 0x1f, 0x40, 0x21, 0xd7, + 0x81, 0xfb, 0x80, 0xcf, 0x8f, 0x44, 0x1e, 0x7c, 0x88, 0x38, 0x28, 0x70, 0xe4, 0x92, 0xff, 0xc7, + 0xef, 0x1f, 0x80, +}; +const uint8_t* _I_BadEnd_128x64[] = {_I_BadEnd_128x64_0}; +const Icon I_BadEnd_128x64 = + {.width = 128, .height = 64, .frame_count = 1, .frame_rate = 0, .frames = _I_BadEnd_128x64}; + +const uint8_t _I_Hand_12x10_0[] = { + 0x01, 0x00, 0x11, 0x00, 0x8c, 0x40, 0x25, 0x00, 0x16, 0xb4, 0x40, + 0x35, 0x10, 0x1d, 0x5c, 0x1b, 0x5b, 0x0a, 0x84, 0xc2, 0x80, +}; +const uint8_t* _I_Hand_12x10[] = {_I_Hand_12x10_0}; +const Icon I_Hand_12x10 = + {.width = 12, .height = 10, .frame_count = 1, .frame_rate = 0, .frames = _I_Hand_12x10}; + +const uint8_t _I_CardBack_22x35_0[] = { + 0x01, 0x00, 0x23, 0x00, 0xfe, 0x7f, 0xe1, 0xf0, 0x28, 0x04, 0x43, 0xe3, 0xff, + 0x91, 0xea, 0x75, 0x52, 0x6a, 0xad, 0x56, 0x5b, 0xad, 0xd5, 0x4a, 0x80, 0xbe, + 0x05, 0xf0, 0x2f, 0x81, 0x7c, 0x0b, 0x45, 0x32, 0x2c, 0x91, 0x7c, 0x8c, 0xa4, +}; +const uint8_t* _I_CardBack_22x35[] = {_I_CardBack_22x35_0}; +const Icon I_CardBack_22x35 = + {.width = 22, .height = 35, .frame_count = 1, .frame_rate = 0, .frames = _I_CardBack_22x35}; + +//uncompressed but lol +const uint8_t _I_club_7x8_0[] = {0x00, 0x08, 0x1c, 0x1c, 0x6b, 0x7f, 0x36, 0x08, 0x1c}; +const uint8_t* _I_club_7x8[] = {_I_club_7x8_0}; +const Icon I_club_7x8 = + {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_club_7x8}; + +//uncompressed but lol +const uint8_t _I_diamond_7x8_0[] = {0x00, 0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08}; +const uint8_t* _I_diamond_7x8[] = {_I_diamond_7x8_0}; +const Icon I_diamond_7x8 = + {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_diamond_7x8}; + +//uncompressed +const uint8_t _I_hearts_7x8_0[] = {0x00, 0x00, 0x36, 0x7f, 0x7f, 0x7f, 0x3e, 0x1c, 0x08}; +const uint8_t* _I_hearts_7x8[] = {_I_hearts_7x8_0}; +const Icon I_hearts_7x8 = + {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_hearts_7x8}; + +//uncompressed +const uint8_t _I_spade_7x8_0[] = {0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x7f, 0x36, 0x08, 0x1c}; +const uint8_t* _I_spade_7x8[] = {_I_spade_7x8_0}; +const Icon I_spade_7x8 = + {.width = 7, .height = 8, .frame_count = 1, .frame_rate = 0, .frames = _I_spade_7x8}; + +// They only included Numeric Profont22 glyphs and I don't want to fuck up the font embeds right now sooo.. + +const uint8_t _I_King_7x8_0[] = { + 0x01, 0x00, 0x1a, 0x00, 0xc1, 0xc0, 0xf8, 0x70, 0x1f, 0x1c, 0x02, 0xe7, 0x00, 0x9d, 0xc0, + 0x23, 0xf0, 0x08, 0x78, 0x0c, 0x80, 0xe2, 0x0b, 0x10, 0x78, 0x84, 0xc4, 0x2e, 0x20, 0x01, +}; +const uint8_t* _I_King_7x8[] = {_I_King_7x8_0}; +const Icon I_King_7x8 = + {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_King_7x8}; + +const uint8_t _I_Queen_7x8_0[] = { + 0x01, 0x00, 0x13, 0x00, 0xfe, 0x40, 0x3f, 0xd0, 0x1c, 0x3c, 0x0c, 0x01, + 0x76, 0x38, 0x1f, 0x8e, 0x07, 0xc7, 0x81, 0x85, 0x47, 0xf9, 0x01, +}; +const uint8_t* _I_Queen_7x8[] = {_I_Queen_7x8_0}; +const Icon I_Queen_7x8 = + {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Queen_7x8}; + +const uint8_t _I_Jack_7x8_0[] = { + 0x01, + 0x00, + 0x0D, + 0x00, + 0x80, + 0x40, + 0xc0, + 0x3a, + 0x00, + 0x5c, + 0x3c, + 0x0f, + 0xfd, + 0x01, + 0xfe, + 0x40, + 0x00, +}; +const uint8_t* _I_Jack_7x8[] = {_I_Jack_7x8_0}; +const Icon I_Jack_7x8 = + {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Jack_7x8}; + +const uint8_t _I_Ace_7x8_0[] = { + 0x01, 0x00, 0x13, 0x00, 0x98, 0x40, 0x2f, 0x00, 0x12, 0xe6, 0x00, 0x4b, + 0x0d, 0x01, 0x00, 0x8c, 0x0e, 0x07, 0xff, 0x00, 0x90, 0x01, 0xc0, +}; +const uint8_t* _I_Ace_7x8[] = {_I_Ace_7x8_0}; +const Icon I_Ace_7x8 = + {.width = 10, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Ace_7x8}; + +const uint8_t _I_Ten_7x8_0[] = { + 0x01, 0x00, 0x29, 0x00, 0x86, 0x7f, 0x00, 0x43, 0xfe, 0x80, 0xc3, 0xf0, 0xf0, 0x38, 0x7e, + 0x0e, 0x07, 0x0c, 0xe1, 0x80, 0x87, 0xc6, 0x02, 0x1b, 0x98, 0x08, 0x67, 0x60, 0x21, 0x8f, + 0x80, 0x86, 0x1e, 0x02, 0x18, 0x38, 0x08, 0x43, 0x43, 0x7f, 0x10, 0x0d, 0xfc, 0x4c, 0x20, +}; +const uint8_t* _I_Ten_7x8[] = {_I_Ten_7x8_0}; +const Icon I_Ten_7x8 = + {.width = 18, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Ten_7x8}; + +const char* StateName[10] = { + /* use this for the status line and put in better wording */ + "Intro", // should never see this + "Select Bet", // cards are face down + "Choose Cards", // cards are revealed, player can choose which to hold + "Good Luck!" // cards are replaced, payouts here. +}; + +//const uint8_t _I_Splash_128x64_0[] = { +int Poker_Title; //Have we seen the title + +const char* suitname[4] = {"C", "D", "H", "S"}; + +#define AllAmerican 0 +#define TensOrBetter 1 +#define BonusPoker 2 +#define DoubleBonus 3 +#define DoubleBonusBonus 4 +#define JacksOrBetter 5 /* default */ +#define JacksOrBetter95 6 +#define JacksOrBetter86 7 +#define JacksOrBetter85 8 +#define JacksOrBetter75 9 +#define JacksOrBetter65 10 +/* If you add another game, increment NUMGAMES: */ +#define NUMGAMES 11 + +/* + The game in play. Default is Jacks or Better, + which is coded into initialization of static data +*/ + +int game = JacksOrBetter; + +const char* gamenames[NUMGAMES] = { + "All American", + "Tens or Better", + "Bonus Poker", + "Double Bonus", + "Double Bonus Bonus", + "Jacks or Better", + "9/5 Jacks or Better", + "8/6 Jacks or Better", + "8/5 Jacks or Better", + "7/5 Jacks or Better", + "6/5 Jacks or Better"}; + +/* Sanity check: check that there are no duplicate cards in hand */ + +void playcard(PokerPlayer* app) { + int i, c, crd; + + int hold[5]; + hold[5] = 2; + // int digit; + c = 1; + c++; + c = hold[5]; /* FIX for unused-but-set-variable */ + /* initialize deck */ + for(i = 0; i < 52; i++) deck[i].gone = 0; + + /* initialize hold[] */ + for(i = 0; i < 5; i++) hold[i] = 1; + + /* app->score -= bet; */ + + for(i = 0; i < 5; i++) { + /* find a card not already dealt */ + do crd = random() % 52; + while(deck[crd].gone); + hold[i] = 1; + deck[crd].gone = 1; + if(!app->held[i]) { + app->hand[i] = deck[crd]; + } + } +} + +int check_for_dupes(PokerPlayer* app) { + int i, j; + + for(i = 0; i < 5; i++) { + for(j = i + 1; j < 5; j++) { + if(app->hand[i].index == app->hand[j].index && app->hand[i].suit == app->hand[j].suit) + return 0; + } + } + + return 1; +} + +/* Functions that recognize winning hands */ + +/* + Flush: + returns 1 if the sorted hand is a flush +*/ + +int flush(PokerPlayer* app) { + if(app->shand[0].suit == app->shand[1].suit && app->shand[1].suit == app->shand[2].suit && + app->shand[2].suit == app->shand[3].suit && app->shand[3].suit == app->shand[4].suit) + return 1; + + return 0; +} + +/* + Straight: + returns 1 if the sorted hand is a straight +*/ + +int straight(PokerPlayer* app) { + if(app->shand[1].index == app->shand[0].index + 1 && + app->shand[2].index == app->shand[1].index + 1 && + app->shand[3].index == app->shand[2].index + 1 && + app->shand[4].index == app->shand[3].index + 1) + return 1; + + /* Ace low straight: Ace, 2, 3, 4, 5 */ + + if(app->shand[4].index == 13 && app->shand[0].index == 1 && app->shand[1].index == 2 && + app->shand[2].index == 3 && app->shand[3].index == 4) + return 1; + + return 0; +} + +/* + Four of a kind: + the middle 3 all match, and the first or last matches those +*/ + +int four(PokerPlayer* app) { + if((app->shand[1].index == app->shand[2].index && + app->shand[2].index == app->shand[3].index) && + (app->shand[0].index == app->shand[2].index || app->shand[4].index == app->shand[2].index)) + return 1; + + return 0; +} + +/* + Full house: + 3 of a kind and a pair +*/ + +int full(PokerPlayer* app) { + if(app->shand[0].index == app->shand[1].index && + (app->shand[2].index == app->shand[3].index && app->shand[3].index == app->shand[4].index)) + return 1; + + if(app->shand[3].index == app->shand[4].index && + (app->shand[0].index == app->shand[1].index && app->shand[1].index == app->shand[2].index)) + return 1; + + return 0; +} + +/* + Three of a kind: + it can appear 3 ways +*/ + +int three(PokerPlayer* app) { + if(app->shand[0].index == app->shand[1].index && app->shand[1].index == app->shand[2].index) + return 1; + + if(app->shand[1].index == app->shand[2].index && app->shand[2].index == app->shand[3].index) + return 1; + + if(app->shand[2].index == app->shand[3].index && app->shand[3].index == app->shand[4].index) + return 1; + + return 0; +} + +/* + Two pair: + it can appear in 3 ways +*/ + +int twopair(PokerPlayer* app) { + if(((app->shand[0].index == app->shand[1].index) && + (app->shand[2].index == app->shand[3].index)) || + ((app->shand[0].index == app->shand[1].index) && + (app->shand[3].index == app->shand[4].index)) || + ((app->shand[1].index == app->shand[2].index) && + (app->shand[3].index == app->shand[4].index))) + return 1; + + return 0; +} + +/* + Two of a kind (pair), jacks or better + or if the game is Tens or Better, 10s or better. +*/ + +int two(PokerPlayer* app) { + int min = 10; + + if(game == TensOrBetter) min = 9; + + if(app->shand[0].index == app->shand[1].index && app->shand[1].index >= min) return 1; + if(app->shand[1].index == app->shand[2].index && app->shand[2].index >= min) return 1; + if(app->shand[2].index == app->shand[3].index && app->shand[3].index >= min) return 1; + if(app->shand[3].index == app->shand[4].index && app->shand[4].index >= min) return 1; + + return 0; +} + +int paytable[10] = { + 800, /* royal flush: 800 */ + 50, /* straight flush: 50 */ + 25, /* 4 of a kind: 25 */ + 9, /* full house: 9 */ + 6, /* flush: 6 */ + 4, /* straight: 4 */ + 3, /* 3 of a kind: 3 */ + 2, /* two pair: 2 */ + 1, /* jacks or better: 1 */ + 0 /* nothing */ +}; + +const char* handname[10] = { + "Royal Flush", + "Straight Flush", + "Four of a Kind", + "Full House", + "Flush", + "Straight", + "Three of a Kind", + "Two Pair", + "Pair", + "Nothing", +}; + +int recognize(PokerPlayer* app) { + int i, j, f = 0; + int min = 100; + card tmp[5]; + int st = 0, fl = 0; + + /* Sort hand into sorted hand (app->shand) */ + + /* make copy of hand */ + for(i = 0; i < 5; i++) tmp[i] = app->hand[i]; + + for(i = 0; i < 5; i++) { + /* put lowest card in hand into next place in app->shand */ + + for(j = 0; j < 5; j++) + if(tmp[j].index <= min) { + min = tmp[j].index; + f = j; + } + + app->shand[i] = tmp[f]; + tmp[f].index = 100; /* larger than any card */ + min = 100; + } + + /* royal and straight flushes, strait, and flush */ + + fl = flush(app); + st = straight(app); + + if(st && fl && app->shand[0].index == 9) return 0; + if(st && fl) return 1; + if(four(app)) return 2; + if(full(app)) return 3; + if(fl) return 4; + if(st) return 5; + if(three(app)) return 6; + if(twopair(app)) return 7; + if(two(app)) return 8; + + /* Nothing */ + + return 9; +} + +void poker_draw_callback(Canvas* canvas, void* ctx) { + PokerPlayer* poker_player = ctx; + furi_check(osMutexAcquire(poker_player->model_mutex, osWaitForever) == osOK); + canvas_clear(canvas); + char buffer[25]; + canvas_set_color(canvas, ColorBlack); + canvas_set_font(canvas, FontSecondary); + + /* Magic Begins */ + + /* Status Info */ + if(poker_player->GameState != 0 && poker_player->GameState != 4) { + snprintf(buffer, sizeof(buffer), "%d", poker_player->score); + canvas_draw_str_aligned(canvas, 127, 0, AlignRight, AlignTop, buffer); + } + + /* Draw the Cards */ + if(poker_player->GameState == 1) { + snprintf(buffer, sizeof(buffer), "Bet:%d", poker_player->bet); + canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); + snprintf(buffer, sizeof(buffer), "<*> Place Bet"); + canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); + canvas_draw_icon(canvas, 5, 18, &I_CardBack_22x35); + + canvas_draw_icon(canvas, 29, 18, &I_CardBack_22x35); + + canvas_draw_icon(canvas, 53, 18, &I_CardBack_22x35); + + canvas_draw_icon(canvas, 77, 18, &I_CardBack_22x35); + + canvas_draw_icon(canvas, 101, 18, &I_CardBack_22x35); + + } + + else if(poker_player->GameState == 2 || poker_player->GameState == 3) { + snprintf(buffer, sizeof(buffer), "Pot:%d", poker_player->bet); + canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); + snprintf(buffer, sizeof(buffer), "<*> Select Hold"); + canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); + + /* snprintf( + buffer, + sizeof(buffer), + "%s:%ix", + handname[recognize(poker_player)], + paytable[recognize(poker_player)]); + canvas_draw_str_aligned(canvas, 5, 5, AlignLeft, AlignTop, buffer); */ + + poker_player->held[0] ? canvas_draw_rbox(canvas, 5, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 5, 18, 22, 35, 3); + + poker_player->held[1] ? canvas_draw_rbox(canvas, 29, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 29, 18, 22, 35, 3); + + poker_player->held[2] ? canvas_draw_rbox(canvas, 53, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 53, 18, 22, 35, 3); + + poker_player->held[3] ? canvas_draw_rbox(canvas, 77, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 77, 18, 22, 35, 3); + + poker_player->held[4] ? canvas_draw_rbox(canvas, 101, 18, 22, 35, 3) : + canvas_draw_rframe(canvas, 101, 18, 22, 35, 3); + + //shameful + poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[0].suit == 0) // club + canvas_draw_icon(canvas, 18, 43, &I_club_7x8); + + if(poker_player->hand[0].suit == 1) // diamond + canvas_draw_icon(canvas, 18, 43, &I_diamond_7x8); + + if(poker_player->hand[0].suit == 2) // heart + canvas_draw_icon(canvas, 18, 43, &I_hearts_7x8); + + if(poker_player->hand[0].suit == 3) // spade + canvas_draw_icon(canvas, 18, 43, &I_spade_7x8); + + //canvas_draw_str_aligned(canvas, 25, 49, AlignRight, AlignBottom, buffer); + + poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[1].suit == 0) // club + canvas_draw_icon(canvas, 42, 43, &I_club_7x8); + + if(poker_player->hand[1].suit == 1) // diamond + canvas_draw_icon(canvas, 42, 43, &I_diamond_7x8); + + if(poker_player->hand[1].suit == 2) // heart + canvas_draw_icon(canvas, 42, 43, &I_hearts_7x8); + + if(poker_player->hand[1].suit == 3) // spade + canvas_draw_icon(canvas, 42, 43, &I_spade_7x8); + + //canvas_draw_str_aligned(canvas, 49, 49, AlignRight, AlignBottom, buffer); + + poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[2].suit == 0) // club + canvas_draw_icon(canvas, 66, 43, &I_club_7x8); + + if(poker_player->hand[2].suit == 1) // diamond + canvas_draw_icon(canvas, 66, 43, &I_diamond_7x8); + + if(poker_player->hand[2].suit == 2) // heart + canvas_draw_icon(canvas, 66, 43, &I_hearts_7x8); + + if(poker_player->hand[2].suit == 3) // spade + canvas_draw_icon(canvas, 66, 43, &I_spade_7x8); + + // canvas_draw_str_aligned(canvas, 73, 49, AlignRight, AlignBottom, buffer); + + poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[3].suit == 0) // club + canvas_draw_icon(canvas, 90, 43, &I_club_7x8); + + if(poker_player->hand[3].suit == 1) // diamond + canvas_draw_icon(canvas, 90, 43, &I_diamond_7x8); + + if(poker_player->hand[3].suit == 2) // heart + canvas_draw_icon(canvas, 90, 43, &I_hearts_7x8); + + if(poker_player->hand[3].suit == 3) // spade + canvas_draw_icon(canvas, 90, 43, &I_spade_7x8); + + // canvas_draw_str_aligned(canvas, 97, 49, AlignRight, AlignBottom, buffer); + + poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + + if(poker_player->hand[4].suit == 0) // club + canvas_draw_icon(canvas, 113, 43, &I_club_7x8); + + if(poker_player->hand[4].suit == 1) // diamond + canvas_draw_icon(canvas, 113, 43, &I_diamond_7x8); + + if(poker_player->hand[4].suit == 2) // heart + canvas_draw_icon(canvas, 113, 43, &I_hearts_7x8); + + if(poker_player->hand[4].suit == 3) // spade + canvas_draw_icon(canvas, 113, 43, &I_spade_7x8); + + //canvas_draw_str_align-ed(canvas, 120, 50, AlignRight, AlignBottom, buffer); + + canvas_set_font(canvas, FontBigNumbers); + if(poker_player->hand[0].index >= 1 && poker_player->hand[0].index <= 8) { + poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[0].sym); + canvas_draw_str_aligned(canvas, 7, 22, AlignLeft, AlignTop, buffer); + } else { + poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[0].index == 9) // Ten + canvas_draw_icon(canvas, 7, 22, &I_Ten_7x8); + + if(poker_player->hand[0].index == 10) // Jack + canvas_draw_icon(canvas, 7, 22, &I_Jack_7x8); + + if(poker_player->hand[0].index == 11) // Queen + canvas_draw_icon(canvas, 7, 22, &I_Queen_7x8); + + if(poker_player->hand[0].index == 12) // King + canvas_draw_icon(canvas, 7, 22, &I_King_7x8); + + if(poker_player->hand[0].index == 13) // ace + canvas_draw_icon(canvas, 7, 22, &I_Ace_7x8); + } + if(poker_player->hand[1].index >= 0 && poker_player->hand[1].index <= 8) { + poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[1].sym); + canvas_draw_str_aligned(canvas, 31, 22, AlignLeft, AlignTop, buffer); + } else { + /* bitmap time */ + poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[1].index == 9) // Ten + canvas_draw_icon(canvas, 31, 22, &I_Ten_7x8); + + if(poker_player->hand[1].index == 10) // Jack + canvas_draw_icon(canvas, 31, 22, &I_Jack_7x8); + + if(poker_player->hand[1].index == 11) // Queen + canvas_draw_icon(canvas, 31, 22, &I_Queen_7x8); + + if(poker_player->hand[1].index == 12) // King + canvas_draw_icon(canvas, 31, 22, &I_King_7x8); + + if(poker_player->hand[1].index == 13) // ace + canvas_draw_icon(canvas, 31, 22, &I_Ace_7x8); + } + if(poker_player->hand[2].index >= 0 && poker_player->hand[2].index <= 8) { + poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[2].sym); + canvas_draw_str_aligned(canvas, 55, 22, AlignLeft, AlignTop, buffer); + } else { + /* bitmap time */ + poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[2].index == 9) // Ten + canvas_draw_icon(canvas, 55, 22, &I_Ten_7x8); + + if(poker_player->hand[2].index == 10) // Jack + canvas_draw_icon(canvas, 55, 22, &I_Jack_7x8); + + if(poker_player->hand[2].index == 11) // Queen + canvas_draw_icon(canvas, 55, 22, &I_Queen_7x8); + + if(poker_player->hand[2].index == 12) // King + canvas_draw_icon(canvas, 55, 22, &I_King_7x8); + + if(poker_player->hand[2].index == 13) // ace + canvas_draw_icon(canvas, 55, 22, &I_Ace_7x8); + } + if(poker_player->hand[3].index >= 0 && poker_player->hand[3].index <= 8) { + poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[3].sym); + canvas_draw_str_aligned(canvas, 79, 22, AlignLeft, AlignTop, buffer); + } else { + /* bitmap time */ + poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[3].index == 9) // Ten + canvas_draw_icon(canvas, 79, 22, &I_Ten_7x8); + + if(poker_player->hand[3].index == 10) // Jack + canvas_draw_icon(canvas, 79, 22, &I_Jack_7x8); + + if(poker_player->hand[3].index == 11) // Queen + canvas_draw_icon(canvas, 79, 22, &I_Queen_7x8); + + if(poker_player->hand[3].index == 12) // King + canvas_draw_icon(canvas, 79, 22, &I_King_7x8); + + if(poker_player->hand[3].index == 13) // ace + canvas_draw_icon(canvas, 79, 22, &I_Ace_7x8); + } + if(poker_player->hand[4].index >= 0 && poker_player->hand[4].index <= 8) { + poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[4].sym); + canvas_draw_str_aligned(canvas, 103, 22, AlignLeft, AlignTop, buffer); + } else { + /* bitmap time */ + poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : + canvas_set_color(canvas, ColorBlack); + if(poker_player->hand[4].index == 9) // Ten + canvas_draw_icon(canvas, 103, 22, &I_Ten_7x8); + + if(poker_player->hand[4].index == 10) // Jack + canvas_draw_icon(canvas, 103, 22, &I_Jack_7x8); + + if(poker_player->hand[4].index == 11) // Queen + canvas_draw_icon(canvas, 103, 22, &I_Queen_7x8); + + if(poker_player->hand[4].index == 12) // King + canvas_draw_icon(canvas, 103, 22, &I_King_7x8); + + if(poker_player->hand[4].index == 13) // ace + canvas_draw_icon(canvas, 103, 22, &I_Ace_7x8); + } + + /* Draw the Select hand */ + if(poker_player->GameState == 2) { + canvas_set_color(canvas, ColorBlack); + if(poker_player->selected == 0) { + canvas_draw_icon(canvas, 11, 54, &I_Hand_12x10); + } + + if(poker_player->selected == 1) { + canvas_draw_icon(canvas, 35, 54, &I_Hand_12x10); + } + + if(poker_player->selected == 2) { + canvas_draw_icon(canvas, 58, 54, &I_Hand_12x10); + } + + if(poker_player->selected == 3) { + canvas_draw_icon(canvas, 83, 54, &I_Hand_12x10); + } + + if(poker_player->selected == 4) { + canvas_draw_icon(canvas, 109, 54, &I_Hand_12x10); + } + } + } // GameState 2 or 3 + + canvas_set_color(canvas, ColorBlack); + canvas_set_font(canvas, FontSecondary); + if(poker_player->GameState == 3) { + snprintf( + buffer, + sizeof(buffer), + "%s:%ix", + handname[recognize(poker_player)], + paytable[recognize(poker_player)]); + canvas_draw_str_aligned(canvas, 63, 63, AlignCenter, AlignBottom, buffer); + } + if(poker_player->GameState == 0) { + canvas_draw_icon(canvas, 0, 0, &I_Splash_128x64); + } + if(poker_player->GameState == 4) { + canvas_draw_icon(canvas, 0, 0, &I_BadEnd_128x64); + } + + osMutexRelease(poker_player->model_mutex); +} + +void poker_input_callback(InputEvent* input, void* ctx) { + PokerPlayer* poker_player = ctx; + osMessageQueuePut(poker_player->event_queue, input, 0, osWaitForever); +} + +PokerPlayer* poker_player_alloc() { + PokerPlayer* poker_player = malloc(sizeof(PokerPlayer)); + + poker_player->score = 1000; + poker_player->model_mutex = osMutexNew(NULL); + poker_player->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); + poker_player->view_port = view_port_alloc(); + poker_player->selected = 0; + poker_player->GameState = 0; + poker_player->bet = 10; + poker_player->minbet = 10; + + playcard( + poker_player); /* Get things rolling before the player gets into the game. This will preload the hand. */ + view_port_draw_callback_set(poker_player->view_port, poker_draw_callback, poker_player); + + view_port_input_callback_set(poker_player->view_port, poker_input_callback, poker_player); + + poker_player->gui = furi_record_open("gui"); + gui_add_view_port(poker_player->gui, poker_player->view_port, GuiLayerFullscreen); + + return poker_player; +} + +void poker_player_free(PokerPlayer* poker_player) { + view_port_enabled_set(poker_player->view_port, false); + gui_remove_view_port(poker_player->gui, poker_player->view_port); + furi_record_close("gui"); + view_port_free(poker_player->view_port); + osMessageQueueDelete(poker_player->event_queue); + osMutexDelete(poker_player->model_mutex); + + free(poker_player); +} + +int32_t video_poker_app(void* p) { + UNUSED(p); + PokerPlayer* poker_player = poker_player_alloc(); + + InputEvent event; + for(bool processing = true; processing;) { + osStatus_t status = osMessageQueueGet(poker_player->event_queue, &event, NULL, 100); + furi_check(osMutexAcquire(poker_player->model_mutex, osWaitForever) == osOK); + if(status == osOK) { + if(event.type == InputTypePress) { + switch(event.key) { + case InputKeyUp: + Poker_Shaker(); + break; + case InputKeyDown: + if(poker_player->GameState == 2) { + playcard(poker_player); + if(check_for_dupes(poker_player) == 0) { + playcard(poker_player); + } + + poker_player->GameState = 3; + } + break; + case InputKeyLeft: + if(poker_player->GameState == 1) { + if(poker_player->bet >= poker_player->minbet + 10) { + poker_player->bet -= 10; + } + } else if(poker_player->selected > 0 && poker_player->GameState == 2) { + poker_player->selected--; + } // Move hand left/right + else if(poker_player->selected == 0 && poker_player->GameState == 2) { + poker_player->selected = 4; //wraparound + } + break; + case InputKeyRight: + if(poker_player->GameState == 1) { + if(poker_player->bet < poker_player->score + 10) { + poker_player->bet += 10; + } + } + if(poker_player->selected < 4 && poker_player->GameState == 2) { + poker_player->selected++; + } // Move hand left/right + else if(poker_player->selected == 4 && poker_player->GameState == 2) { + poker_player->selected = 0; //wraparound + } + break; + case InputKeyOk: + if(poker_player->GameState == 0) { + poker_player->GameState = 1; + } else if(poker_player->GameState == 1) { + poker_player->score -= poker_player->bet; + poker_player->GameState = 2; + } else if(poker_player->GameState == 2) { + poker_player->held[poker_player->selected] = + !poker_player + ->held[poker_player->selected]; //cursed and bad pls replace + } else if(poker_player->GameState == 3) { + if(recognize(poker_player) != 9) { + poker_player->score += + poker_player->bet * paytable[recognize(poker_player)]; + } + poker_player->GameState = 1; + if(poker_player->bet > poker_player->score) { + poker_player->bet = poker_player->score; + } + poker_player->held[0] = 0; + poker_player->held[1] = 0; + poker_player->held[2] = 0; + poker_player->held[3] = 0; + poker_player->held[4] = 0; + if(poker_player->score <= 0) { + poker_player->GameState = 4; + } + playcard(poker_player); // shuffle shuffle + } else if(poker_player->GameState == 4) { + Poker_Shaker(); + processing = false; + } + break; + case InputKeyBack: + processing = false; + break; + } + } + } + osMutexRelease(poker_player->model_mutex); + view_port_update(poker_player->view_port); + } + + poker_player_free(poker_player); + return 0; +} + From 188f6268c05c18c9e6eac08c2cf39d78711474cc Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 10 Jun 2022 01:02:10 -0700 Subject: [PATCH 67/91] Update README.md --- README.md | 77 ------------------------------------------------------- 1 file changed, 77 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 31fabbaef4e..00000000000 --- a/README.md +++ /dev/null @@ -1,77 +0,0 @@ -# [Flipper Zero Firmware](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/ReadMe.md) <= READ THIS READ ME -- ****This software is for experimental purposes only and is not meant for any illegal activity/purposes. We do not condone illegal activity and strongly encourage keeping transmissions to legal/valid uses allowed by law.** -- FLASH STOCK FIRST BEFORE UPDATING TO CUSTOM FIRMWARE -- BUILD WITH COMPACT FLAG SINCE IT IS TOO LARGE -- CH0NG, CH33CH and N00BY rename your flipper. - -# Clone the Repository - -You should clone with -```shell -$ git clone --recursive https://github.com/RogueMaster/flipperzero-firmware-wPlugins.git -$ docker-compose up -d -$ docker-compose exec dev make DEBUG=0 COMPACT=1 -``` - -Latest Updates: -- Fix for Raycast exit thanks to redlink2 -- [NTAG21x complete emulation Thanks To GMMan](https://github.com/flipperdevices/flipperzero-firmware/pull/1313), AMIIBO NOW WORK FULLY! -- Latest DEV changes up to adffe20b -- Added [Chip8 Emulator (By mega8bit)](https://github.com/mega8bit/flipperzero-firmware) Updated by ESurge To Work. -- - Add a folder to SD card named `chip8` -- - [Get GAMES HERE](https://johnearnest.github.io/chip8Archive/) -- - Let us know if you got any to work by submitting an Issue! LOL (Probably removing from build 6/15) -- Added [Video Poker (By PixlEmly)](https://github.com/PixlEmly/flipperzero-firmware-testing/blob/unleashed/applications/VideoPoker/poker.c) - -**Special Instructions:** -- Download these files into the subghz/assets folder on your SD card. Edit the two `_map` files to contain your specific subghz (.SUB) files. -- - Note 1: If you don't have a subghz/assets folder, you should ensure you have made at least one clean flash with stock firmware and your SD card installed in order to ensure the database structure is built, otherwise it will not exist for alternative forks. -- - Note 2: /any is a special keyword signifying either /int (internal storage) or /ext (external storage). -- - Note 3: the changes you are making to the `_map` files is to point to the location of the specific assets of the touchtunes folder as well as the universal RF map apps which you will have to develop or compile seperately and are not a part of this repo. -- - Note 4: /any is effectively root, so the folder structure should start "/any/subghz/assets" and not what is based on the repo below do not blindly copy the repo it will not work. -- - [assets/resources/subghz/assets/universal_rf_map](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/subghz/assets/universal_rf_map) -- - [assets/resources/subghz/assets/touchtunes_map](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/subghz/assets/touchtunes_map) -- - [assets/resources/subghz/assets/setting_user](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/subghz/assets/setting_user) -- Download this file into the nfc/assets folder on your SD card. -- - [assets/resources/nfc/assets/mf_classic_dict.nfc](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/nfc/assets/mf_classic_dict.nfc) -- Add a folder to SD card named `wav_player` (for 8bit 2ch unsigned wav files) -- Add a folder to SD card named `music_player` (FMF and RTTTL/TXT files) - -Special shout out to these libraries for giving us more fun: -- https://github.com/Gioman101/FlipperAmiibo -- https://github.com/jimilinuxguy/flipperzero-touchtunes -- https://github.com/Lucaslhm/AmiiboFlipperConverter -- https://github.com/MuddledBox/FlipperZeroCases -- https://github.com/MuddledBox/FlipperZeroSub-GHz -- https://github.com/neverfa11ing/FlipperMusicRTTTL -- https://github.com/UberGuidoZ/Flipper -- https://github.com/UberGuidoZ/Flipper-IRDB - -Added Features: -- Actual PIN Lock (By RogueMaster) -- Added 90s Timeout for Backlight Time (By RogueMaster) -- Default scan names will have timestamp instead of random name assigned (By RogueMaster) -- Keeloq update from [Xorist](https://github.com/xorist/FlipperX) -- SubGHz Protocols (Keeloq, Nice Flor, Star Line) updates from [Eng1n33r](https://github.com/Eng1n33r/flipperzero-firmware) -- Added Flashing the firmware using the blackmagic board with make blackmagic_load [From WeTox](https://github.com/wetox-team/flipperzero-firmware) -- Removing T5577 passwords via the cli command rfid clear_pass_t5577 using a dictionary attack [From WeTox](https://github.com/wetox-team/flipperzero-firmware) -- Added New SubGHZ Scanning image with Pikachu [Thanks to Panzer00Z](https://github.com/Panzer00Z/flipperzero-firmware/blob/3a548ea9bb181c9348d8afb427890c411456134e/assets/icons/SubGhz/Scanning_123x52.png) - -Plugins: -- [Chip8 Emulator (By mega8bit)](https://github.com/mega8bit/flipperzero-firmware) Updated by ESurge To Work. -- [Clock/Stopwatch (By CompaqDisc, Stopwatch & Sound Alert By RogueMaster)](https://gist.github.com/CompaqDisc/4e329c501bd03c1e801849b81f48ea61) -- [Dice Roller Including SEX/WAR/8BALL/WEED DICE (By RogueMaster)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/applications/dice/dice.c) -- [Flappy Bird (By DroomOne)](https://github.com/DroomOne/flipperzero-firmware/tree/dev/applications/flappy_bird) -- [HID Analyzer (By Ownasaurus)](https://github.com/Ownasaurus/flipperzero-firmware/tree/hid-analyzer/applications/hid_analyzer) -- [Menu Changes and Icons (By Redlink)](https://github.com/redlink2/flipperzero-firmware/tree/menuChanges) -- [Mouse Jiggler (By Jacob-Tate)(Original By MuddleBox)](https://github.com/Jacob-Tate/flipperzero-firmware/blob/dev/applications/mouse_jiggler/mouse_jiggler.c) Updated by Jacob-Tate To Work -- [RayCast (Bt Zlo)](https://github.com/flipperdevices/flipperzero-firmware/tree/zlo/raycast-game-engine) -- [RF Remix (By ESurge)(Original By jimilinuxguy)](https://github.com/ESurge/flipperzero-firmware-unirfremix) -- [Spectrum Analyzer (By jolcese)](https://github.com/jolcese/flipperzero-firmware/tree/spectrum/applications/spectrum_analyzer) -- [Tanks (By Alexgr13)](https://github.com/alexgr13/flipperzero-firmware/tree/fork/dev/applications/tanks-game) Updated by RogueMaster To Work -- [Tetris (By jeffplang)](https://github.com/jeffplang/flipperzero-firmware/tree/tetris_game/applications/tetris_game) -- [Touch Tunes Remote (By jimilinuxguy)](https://github.com/jimilinuxguy/flipperzero-universal-rf-remote/tree/028d615c83f059bb2c905530ddb3d4efbd3cbcae/applications/jukebox) -- [Video Poker (By PixlEmly)](https://github.com/PixlEmly/flipperzero-firmware-testing/blob/unleashed/applications/VideoPoker/poker.c) -- [WAV Player (By Zlo)](https://github.com/flipperdevices/flipperzero-firmware/tree/zlo/wav-player) Updated by Atmanos & RogueMaster To Work - -Thank you, [MuddleBox](https://github.com/MuddledBox/flipperzero-firmware), [Eng1n33r](https://github.com/Eng1n33r/flipperzero-firmware), [WeTox-Team](https://github.com/wetox-team/flipperzero-firmware) & of course, most of all [Flipper Devices](https://github.com/flipperdevices/flipperzero-firmware)! From b389bb2621e0c2dc85057f61c1ff01334cc67984 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 3 Jun 2022 10:58:36 -0700 Subject: [PATCH 68/91] Improve directions on how to find dimensions, which are kinda important for images. --- scripts/User/ReadMe.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 scripts/User/ReadMe.md diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md new file mode 100644 index 00000000000..15fd6b715d3 --- /dev/null +++ b/scripts/User/ReadMe.md @@ -0,0 +1,31 @@ +##################################### +encode.py +decode.py + +A set of python3 scripts for processing the Flipper image files. + +##################################### +PREREQUISITES + +You'll need heatshrink installed - a small embedded/RTOS compression and decompression library +You can get that here https://github.com/atomicobject/heatshrink + +##################################### +HOW TO USE + +## +Decode a .mb into .xbm: +decode.py input_image output_image [width] [height] +Dimensions are not stored in .bm so you need to specify +If you have the meta.txt available for the animation set the dimensions will be in here. +It may also be part of the directory name for the animation files as well. + +If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. + +## +Encode an .xbm file into .xb +encode.py input_image output_image +That's it. + + + From 7488ea8f9a23e4e57c53e5a81b36824312d61166 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 3 Jun 2022 11:08:50 -0700 Subject: [PATCH 69/91] encode will print out image dimensions --- scripts/User/ReadMe.md | 1 + scripts/User/encode.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 15fd6b715d3..0f7060c734d 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -25,6 +25,7 @@ If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE ## Encode an .xbm file into .xb encode.py input_image output_image +You will also get the image dimensions for use in meta.txt That's it. diff --git a/scripts/User/encode.py b/scripts/User/encode.py index d2d533ea3f7..356067e9382 100644 --- a/scripts/User/encode.py +++ b/scripts/User/encode.py @@ -25,8 +25,8 @@ width = int(f.readline().strip().split(" ")[2]) print("W: ", width) height = int(f.readline().strip().split(" ")[2]) -print("H: ", height) - +print("Height:", height) +print("Width: ", width) data = f.read().strip().replace("\n", "").replace(" ", "").split("=")[1][:-1] data_str = data[1:-1].replace(",", " ").replace("0x", "") From 700cf51e44fd3fe18ee1fb4eb0fdb7db4c98cc57 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Fri, 3 Jun 2022 11:20:49 -0700 Subject: [PATCH 70/91] QOL --- scripts/User/decode.py | 2 +- scripts/User/encode.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/User/decode.py b/scripts/User/decode.py index f6779d967f3..01b405c0d95 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -49,7 +49,7 @@ def padded_hex(i, l): unpad=fileStream[4:] else: if(fileStream[0:1] == bytes([0x00])): - unpad=fileStream[2:] + unpad=fileStream[3:] diff --git a/scripts/User/encode.py b/scripts/User/encode.py index 356067e9382..d2d533ea3f7 100644 --- a/scripts/User/encode.py +++ b/scripts/User/encode.py @@ -25,8 +25,8 @@ width = int(f.readline().strip().split(" ")[2]) print("W: ", width) height = int(f.readline().strip().split(" ")[2]) -print("Height:", height) -print("Width: ", width) +print("H: ", height) + data = f.read().strip().replace("\n", "").replace(" ", "").split("=")[1][:-1] data_str = data[1:-1].replace(",", " ").replace("0x", "") From 05e7669911b69bc7a516f1e79c6c49f39349d6c5 Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 3 Jun 2022 11:10:23 -0700 Subject: [PATCH 71/91] Update ReadMe.md --- scripts/User/ReadMe.md | 61 ++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 0f7060c734d..78c14872783 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -1,32 +1,29 @@ -##################################### -encode.py -decode.py - -A set of python3 scripts for processing the Flipper image files. - -##################################### -PREREQUISITES - -You'll need heatshrink installed - a small embedded/RTOS compression and decompression library -You can get that here https://github.com/atomicobject/heatshrink - -##################################### -HOW TO USE - -## -Decode a .mb into .xbm: -decode.py input_image output_image [width] [height] -Dimensions are not stored in .bm so you need to specify -If you have the meta.txt available for the animation set the dimensions will be in here. -It may also be part of the directory name for the animation files as well. - -If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. - -## -Encode an .xbm file into .xb -encode.py input_image output_image -You will also get the image dimensions for use in meta.txt -That's it. - - - +##################################### +encode.py +decode.py + +A set of python3 scripts for processing the Flipper image files. + +##################################### +PREREQUISITES + + +You'll need heatshrink installed - a small embedded/RTOS compression and decompression library +You can get that here https://github.com/atomicobject/heatshrink + +##################################### +HOW TO USE + +## +Decode a .mb into .xbm: +decode.py input_image output_image [width] [height] +Dimensions are not stored in .bm so you need to specify +If you have the meta.txt available for the animation set the dimensions will be in here. +It may also be part of the directory name for the animation files as well. + +If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. + +## +Encode an .xbm file into .xb +encode.py input_image output_image +You will also get the image dimensions for use in meta.txt From 9231898ce24f56cbcce5bdee11255d1d7ba80a19 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 00:53:24 -0700 Subject: [PATCH 72/91] New: decoder for heatshrunk char array icons. You'll likely need to trim some bytes off the start. the format here is a bit different than elsewhere. --- scripts/User/icondecode.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/User/icondecode.py b/scripts/User/icondecode.py index 241831510f2..df980239527 100644 --- a/scripts/User/icondecode.py +++ b/scripts/User/icondecode.py @@ -31,6 +31,7 @@ def padded_hex(i, l): help='Height of the image. Find from meta.txt or directory name') parser.add_argument('Trim', metavar='T', type=int, nargs="?", default="8", help='Number of bytes off the start/header to trim. Multiples of 2 required.') + args = vars(parser.parse_args()) r = open(args["infile"],"r") @@ -42,8 +43,8 @@ def padded_hex(i, l): output = subprocess.check_output(["cat", args["infile"]]) #yes this is terrible. f = io.StringIO(output.decode().strip()) -data = f.read().strip().replace(";","").replace("{","").replace("}","") -data_str = data.replace(",", "").replace("0x", "") +data = f.read().strip() +data_str = data[1:-1].replace(",", "").replace("0x", "") data_bin = bytearray.fromhex(data_str[trimStart:]) data_decoded_str = subprocess.check_output( @@ -61,4 +62,5 @@ def padded_hex(i, l): data=width_out+height_out+bytes_out w.write(data) +r.close() w.close() From 71efb77eb9f4999e2d4fb73a5bc225d96ca338ea Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 01:08:57 -0700 Subject: [PATCH 73/91] help info --- scripts/User/ReadMe.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 78c14872783..6382d323f2b 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -1,7 +1,8 @@ ##################################### encode.py decode.py - +icondecode.py + A set of python3 scripts for processing the Flipper image files. ##################################### @@ -15,6 +16,8 @@ You can get that here https://github.com/atomicobject/heatshrink HOW TO USE ## +# decode. + Decode a .mb into .xbm: decode.py input_image output_image [width] [height] Dimensions are not stored in .bm so you need to specify @@ -24,6 +27,16 @@ It may also be part of the directory name for the animation files as well. If you do not enter anything here it will assume 128x64. THIS WILL NOT ALWAYS BE CORRECT. ## +# encode Encode an .xbm file into .xb encode.py input_image output_image You will also get the image dimensions for use in meta.txt +That's it. + +## +# icondecode +Decompress an icon asset (as found in assets_icons.c and elsewhere) +icondecodepy input_image output_image [trim] [width] [height] +The icons in this file have a different header format. This will need to be trimmed. +A value of 8 for trim appears to be correct. +As with regular decoding, the width and height are not listed - but can be found in code/const/variable/etc names. From 669eb2dfdde234ce1ba31d9ff234740586260ba3 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 01:11:48 -0700 Subject: [PATCH 74/91] re-arrange params --- scripts/User/icondecode.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/User/icondecode.py b/scripts/User/icondecode.py index df980239527..f74f6556acc 100644 --- a/scripts/User/icondecode.py +++ b/scripts/User/icondecode.py @@ -31,7 +31,6 @@ def padded_hex(i, l): help='Height of the image. Find from meta.txt or directory name') parser.add_argument('Trim', metavar='T', type=int, nargs="?", default="8", help='Number of bytes off the start/header to trim. Multiples of 2 required.') - args = vars(parser.parse_args()) r = open(args["infile"],"r") From 9e479666050574b4ec056bdd5a3b9f90b2048160 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 01:18:01 -0700 Subject: [PATCH 75/91] QOL --- scripts/User/ReadMe.md | 6 ++++++ scripts/User/icondecode.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 6382d323f2b..361dc414475 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -40,3 +40,9 @@ icondecodepy input_image output_image [trim] [width] [height] The icons in this file have a different header format. This will need to be trimmed. A value of 8 for trim appears to be correct. As with regular decoding, the width and height are not listed - but can be found in code/const/variable/etc names. +copy just the char array. The script does not care if the curly braces or semicolon are in place. +i.e. the following are all acceptable and equivalent. +{0x00,0x08,0x1C,0x3E,0x7F,}; +{0x00,0x08,0x1C,0x3E,0x7F,} +0x00,0x08,0x1C,0x3E,0x7F + diff --git a/scripts/User/icondecode.py b/scripts/User/icondecode.py index f74f6556acc..59654526997 100644 --- a/scripts/User/icondecode.py +++ b/scripts/User/icondecode.py @@ -42,8 +42,8 @@ def padded_hex(i, l): output = subprocess.check_output(["cat", args["infile"]]) #yes this is terrible. f = io.StringIO(output.decode().strip()) -data = f.read().strip() -data_str = data[1:-1].replace(",", "").replace("0x", "") +data = f.read().strip().replace(";","").replace("{","").replace("}","") +data_str = data.replace(",", "").replace("0x", "") data_bin = bytearray.fromhex(data_str[trimStart:]) data_decoded_str = subprocess.check_output( From 3522512db11393ee17294338b2dadcf73dc2d449 Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 4 Jun 2022 01:34:45 -0700 Subject: [PATCH 76/91] Update ReadMe.md --- scripts/User/ReadMe.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 361dc414475..8df11c69ba9 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -41,8 +41,8 @@ The icons in this file have a different header format. This will need to be trim A value of 8 for trim appears to be correct. As with regular decoding, the width and height are not listed - but can be found in code/const/variable/etc names. copy just the char array. The script does not care if the curly braces or semicolon are in place. -i.e. the following are all acceptable and equivalent. -{0x00,0x08,0x1C,0x3E,0x7F,}; -{0x00,0x08,0x1C,0x3E,0x7F,} -0x00,0x08,0x1C,0x3E,0x7F +i.e. the following are all acceptable and equivalent. +{0x00,0x08,0x1C,0x3E,0x7F,}; +{0x00,0x08,0x1C,0x3E,0x7F,} +0x00,0x08,0x1C,0x3E,0x7F From 42aee38a51b08236153009b6b94dde555e6ffbfe Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sat, 4 Jun 2022 03:08:46 -0700 Subject: [PATCH 77/91] s --- scripts/User/ReadMe.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 8df11c69ba9..cb1c161d4a1 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -1,7 +1,8 @@ ##################################### encode.py decode.py -icondecode.py +iconencode.py +icondecode.py A set of python3 scripts for processing the Flipper image files. @@ -33,6 +34,11 @@ encode.py input_image output_image You will also get the image dimensions for use in meta.txt That's it. +## +# iconencode +Compress an icon asset from an XBM to a compressed char array ready to paste +Will assume dimensions of 128x64 + ## # icondecode Decompress an icon asset (as found in assets_icons.c and elsewhere) From b19339016706e697db500e8b6103624a2a2ff95c Mon Sep 17 00:00:00 2001 From: Emily Date: Sat, 4 Jun 2022 03:11:39 -0700 Subject: [PATCH 78/91] Update ReadMe.md --- scripts/User/ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index cb1c161d4a1..fb51d3d7283 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -5,7 +5,7 @@ iconencode.py icondecode.py A set of python3 scripts for processing the Flipper image files. - +These work as-is but I am rolling in improvements. ##################################### PREREQUISITES From 9c139cffebd76ee89229cfa416d3796558f38f0e Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sun, 5 Jun 2022 11:32:48 -0700 Subject: [PATCH 79/91] Update ReadMe.md --- scripts/User/ReadMe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index fb51d3d7283..875b6a017c7 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -5,7 +5,7 @@ iconencode.py icondecode.py A set of python3 scripts for processing the Flipper image files. -These work as-is but I am rolling in improvements. +These work as-is but I am rolling in improvements. ##################################### PREREQUISITES From 1365c21ab4c6039c877ccba45a89aa262b1cb566 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Sun, 5 Jun 2022 11:45:40 -0700 Subject: [PATCH 80/91] Update ReadMe.md --- scripts/User/ReadMe.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 875b6a017c7..499ec094f7a 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -36,8 +36,9 @@ That's it. ## # iconencode -Compress an icon asset from an XBM to a compressed char array ready to paste -Will assume dimensions of 128x64 +Compress an icon asset from an XBM to a compressed char array ready to paste +Will assume dimensions of 128x64 +There is a small header on these I haven't determined the format of, so this won't work as is yet. ## # icondecode From 975c8ab96482f2f9f297f41b36c0ce3883fe0008 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Mon, 6 Jun 2022 13:47:57 -0700 Subject: [PATCH 81/91] I can't count --- scripts/User/decode.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/User/decode.py b/scripts/User/decode.py index 01b405c0d95..f6779d967f3 100644 --- a/scripts/User/decode.py +++ b/scripts/User/decode.py @@ -49,7 +49,7 @@ def padded_hex(i, l): unpad=fileStream[4:] else: if(fileStream[0:1] == bytes([0x00])): - unpad=fileStream[3:] + unpad=fileStream[2:] From 78dd160ef41850a022f6c593a6a64f7aef5ab144 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Wed, 8 Jun 2022 22:21:49 -0700 Subject: [PATCH 82/91] box tutorial --- applications/applications.c | 6 ++ applications/applications.mk | 4 ++ applications/box_mover/box_mover.c | 106 +++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 applications/box_mover/box_mover.c diff --git a/applications/applications.c b/applications/applications.c index 1fad43e4f7b..725fb309786 100644 --- a/applications/applications.c +++ b/applications/applications.c @@ -360,10 +360,16 @@ const FlipperApplication FLIPPER_GAMES[] = { .flags = FlipperApplicationFlagDefault}, #endif +<<<<<<< HEAD #ifdef APP_VIDEO_POKER {.app = video_poker_app, .name = "Video Poker", +======= +#ifdef APP_BOX_MOVER + {.app = box_mover_app, + .name = "Box Mover", +>>>>>>> 5adddb8c (box tutorial) .stack_size = 1024, .icon = &A_Plugins_14, .flags =FlipperApplicationFlagDefault}, diff --git a/applications/applications.mk b/applications/applications.mk index 64f8918b1d5..7f13049f1b3 100644 --- a/applications/applications.mk +++ b/applications/applications.mk @@ -48,6 +48,7 @@ APP_UPDATER = 1 APP_MUSIC_PLAYER = 1 APP_SNAKE_GAME = 1 APP_TETRIS_GAME = 1 +<<<<<<< HEAD APP_RAYCAST_GAME = 1 APP_VIDEO_POKER = 1 # APP_RAYCAST_GAME = 1 @@ -286,12 +287,15 @@ CFLAGS += -DAPP_BOX_MOVER SRV_GUI = 1 endif +<<<<<<< HEAD APP_VIDEO_POKER ?= 0 ifeq ($(APP_VIDEO_POKER),1) CFLAGS += -DAPP_VIDEO_POKER SRV_GUI = 1 endif +======= +>>>>>>> 5adddb8c (box tutorial) APP_SPECTRUM_ANALYZER ?= 0 ifeq ($(APP_SPECTRUM_ANALYZER), 1) CFLAGS += -DAPP_SPECTRUM_ANALYZER diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c new file mode 100644 index 00000000000..0739cd1ffc5 --- /dev/null +++ b/applications/box_mover/box_mover.c @@ -0,0 +1,106 @@ +#include +#include +#include + +typedef struct { + int x; + int y; +} BoxMoverModel; + +typedef struct { + BoxMoverModel* model; + osMutexId_t* model_mutex; + + osMessageQueueId_t event_queue; + + ViewPort* view_port; + Gui* gui; +} BoxMover; + +BoxMover* box_mover_alloc(){ + BoxMover* instance = malloc(sizeof(BoxMover)); + instance->model = malloc(sizeof(BoxMoverModel)); + instance->model->x = 10; + instance->model->y = 10; + + instance->view_port = view_port_alloc(); + view_port_draw_callback_set(instance->view_port, draw_callback, instance); + + view_port_input_callback_set(instance->view_port, input_callback, instance); + instance->model_mutex = osMutexNew(NULL); + + instance->gui = furi_record_open("gui"); + gui_add_view_port(instance->view_port, GuiLayerFullscreen); + + instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); + + return instance; +} + +void box_mover_free(BoxMover* instance){ + view_port_enabled_set(instance->view_port,false); + gui_remove_view_port(instance->gui, view_port); + furi_record_close("gui"); + osMessageQueueDelete(instance->event_queue); + osMutexDelete(instance->model_mutex); + view_port_free(instance->view_port); + free(instance->model); + free(instance); +} + +int32_t box_mover_app(void* p){ + UNUSED(p); + BoxMover* box_mover = box_mver_alloc(); + + box_mover_free(box_mover) + + for(bool processing = true; processing;){ + osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); + furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); + if(status==osOK){ + if(event.type==InputTypePress){ + switch(event.key){ + case InputKeyUp: + box_mover->model->y-=2; + break; + case InputKeyDown: + box_mover->model->y+=2; + break; + case InputKeyLeft: + box_mover->model->x-=2; + break; + case InputKeyRight: + box_mover->model->x+=2; + break; + case InputKeyOk: + case InputKeyBack: + processing = false; + break; + } + } + } + osMutexRElease(box_mover->model_mutex); + view_port_update(box_mover->view_port); + } + + + box_mover_free(box_mover) + return 0; +} + +void draw_callback(Canvas* cancas, void* ctx){ + BoxMover *box_mover = ctx; + furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); + + canvas_draw_box(canvas, box_mover->x,box_mover->y, 4, 4); + + osReleaseMutex(box_mover->model_mutex); +} + +void input_callback(InputEvent* input, osMessageQueueId_t event_queue){ + BoxMover* box_mover = ctx; + osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); + +} + + From 42cd856dec296644b362918a0e136931bcc26c20 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Thu, 9 Jun 2022 00:59:20 -0700 Subject: [PATCH 83/91] Box Mover but added stuff --- applications/box_mover/box_mover.c | 104 +++++++++++++++++++++-------- 1 file changed, 77 insertions(+), 27 deletions(-) diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c index 0739cd1ffc5..fc3366d5951 100644 --- a/applications/box_mover/box_mover.c +++ b/applications/box_mover/box_mover.c @@ -1,10 +1,15 @@ #include #include +#include #include +#include +#include typedef struct { int x; int y; + int sizex; + int sizey; } BoxMoverModel; typedef struct { @@ -17,43 +22,66 @@ typedef struct { Gui* gui; } BoxMover; + + +void draw_callback(Canvas* canvas, void* ctx){ + BoxMover* box_mover = ctx; + furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); + + canvas_draw_box(canvas, box_mover->model->x,box_mover->model->y, box_mover->model->sizex, box_mover->model->sizey); + + osMutexRelease(box_mover->model_mutex); +} + +void input_callback(InputEvent* input, void* ctx){ + BoxMover* box_mover = ctx; + osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); + +} + BoxMover* box_mover_alloc(){ BoxMover* instance = malloc(sizeof(BoxMover)); instance->model = malloc(sizeof(BoxMoverModel)); instance->model->x = 10; instance->model->y = 10; + instance->model->sizex = 4; + instance->model->sizey = 4; +instance->model_mutex = osMutexNew(NULL); + instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); instance->view_port = view_port_alloc(); view_port_draw_callback_set(instance->view_port, draw_callback, instance); view_port_input_callback_set(instance->view_port, input_callback, instance); - instance->model_mutex = osMutexNew(NULL); + instance->gui = furi_record_open("gui"); - gui_add_view_port(instance->view_port, GuiLayerFullscreen); + gui_add_view_port(instance->gui, instance->view_port, GuiLayerFullscreen); + - instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); return instance; } void box_mover_free(BoxMover* instance){ view_port_enabled_set(instance->view_port,false); - gui_remove_view_port(instance->gui, view_port); + gui_remove_view_port(instance->gui, instance->view_port); furi_record_close("gui"); + view_port_free(instance->view_port); osMessageQueueDelete(instance->event_queue); osMutexDelete(instance->model_mutex); - view_port_free(instance->view_port); + free(instance->model); free(instance); } + int32_t box_mover_app(void* p){ UNUSED(p); - BoxMover* box_mover = box_mver_alloc(); + BoxMover* box_mover = box_mover_alloc(); - box_mover_free(box_mover) + InputEvent event; for(bool processing = true; processing;){ osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); @@ -61,46 +89,68 @@ int32_t box_mover_app(void* p){ if(event.type==InputTypePress){ switch(event.key){ case InputKeyUp: - box_mover->model->y-=2; + if (box_mover->model->y >= 1) + box_mover->model->y-=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } break; case InputKeyDown: - box_mover->model->y+=2; - break; + if (box_mover->model->y <= (64-(box_mover->model->sizey+1))) + box_mover->model->y+=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } + break; case InputKeyLeft: - box_mover->model->x-=2; + if (box_mover->model->x >= 1) + box_mover->model->x-=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } break; case InputKeyRight: - box_mover->model->x+=2; + if (box_mover->model->x <= (128-(box_mover->model->sizex+1))) + box_mover->model->x+=2; + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } break; case InputKeyOk: + if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ + box_mover->model->sizex+=1; + box_mover->model->sizey+=1; + } + else{ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } + + break; case InputKeyBack: processing = false; break; } } } - osMutexRElease(box_mover->model_mutex); + osMutexRelease(box_mover->model_mutex); view_port_update(box_mover->view_port); } - box_mover_free(box_mover) + box_mover_free(box_mover); return 0; } -void draw_callback(Canvas* cancas, void* ctx){ - BoxMover *box_mover = ctx; - furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); - canvas_draw_box(canvas, box_mover->x,box_mover->y, 4, 4); - - osReleaseMutex(box_mover->model_mutex); -} - -void input_callback(InputEvent* input, osMessageQueueId_t event_queue){ - BoxMover* box_mover = ctx; - osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); - -} From de014f32093c7d9a25667eed4310a1eafb20a7ce Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Thu, 9 Jun 2022 01:37:03 -0700 Subject: [PATCH 84/91] Improved bounds checks --- applications/box_mover/box_mover.c | 48 ++++++++++++++++-------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c index fc3366d5951..f70ba0f5571 100644 --- a/applications/box_mover/box_mover.c +++ b/applications/box_mover/box_mover.c @@ -22,7 +22,11 @@ typedef struct { Gui* gui; } BoxMover; - +void shake(void){ + NotificationApp* notification = furi_record_open("notification"); + notification_message(notification, &sequence_single_vibro); + furi_record_close("notification"); + } void draw_callback(Canvas* canvas, void* ctx){ BoxMover* box_mover = ctx; @@ -92,48 +96,47 @@ int32_t box_mover_app(void* p){ if (box_mover->model->y >= 1) box_mover->model->y-=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyDown: - if (box_mover->model->y <= (64-(box_mover->model->sizey+1))) + if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))) // So we're trying to see if it's even or odd, to determine how much to offset the bounds check by, since we're doing this based of the square origin+its size. idk. box_mover->model->y+=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyLeft: if (box_mover->model->x >= 1) box_mover->model->x-=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyRight: - if (box_mover->model->x <= (128-(box_mover->model->sizex+1))) + if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))) box_mover->model->x+=2; else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); + shake(); } break; case InputKeyOk: if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ - box_mover->model->sizex+=1; - box_mover->model->sizey+=1; + if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ + if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ + box_mover->model->sizex+=1; + box_mover->model->sizey+=1; + //TODO - also check the box will not grow past boundary. + } + else + shake(); + } + else + shake(); } - else{ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); - } + else + shake(); + break; case InputKeyBack: @@ -147,6 +150,7 @@ int32_t box_mover_app(void* p){ } + box_mover_free(box_mover); return 0; } From 87d2a6957f5a6b9a5036b131cc7451ff5b2133e1 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Mon, 13 Jun 2022 11:53:49 -0700 Subject: [PATCH 85/91] Attribution ;) --- applications/VideoPoker/poker.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c index 1b625250068..29170810efe 100644 --- a/applications/VideoPoker/poker.c +++ b/applications/VideoPoker/poker.c @@ -8,6 +8,10 @@ #include "assets_icons.h" #include +/* Core game logic from +https://github.com/Yaoir/VideoPoker-C +*/ + /* KNOWN BUGS This has been converted from a standalone PC console app to flipper All of the original input/output handing code has been ripped out From d1580e055437b1a00591b4a2227213344d932a6c Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Wed, 15 Jun 2022 23:13:12 -0700 Subject: [PATCH 86/91] nuke and cleanup --- applications/box_mover/box_mover.c | 160 ----------------------------- 1 file changed, 160 deletions(-) delete mode 100644 applications/box_mover/box_mover.c diff --git a/applications/box_mover/box_mover.c b/applications/box_mover/box_mover.c deleted file mode 100644 index f70ba0f5571..00000000000 --- a/applications/box_mover/box_mover.c +++ /dev/null @@ -1,160 +0,0 @@ -#include -#include -#include -#include -#include -#include - -typedef struct { - int x; - int y; - int sizex; - int sizey; -} BoxMoverModel; - -typedef struct { - BoxMoverModel* model; - osMutexId_t* model_mutex; - - osMessageQueueId_t event_queue; - - ViewPort* view_port; - Gui* gui; -} BoxMover; - -void shake(void){ - NotificationApp* notification = furi_record_open("notification"); - notification_message(notification, &sequence_single_vibro); - furi_record_close("notification"); - } - -void draw_callback(Canvas* canvas, void* ctx){ - BoxMover* box_mover = ctx; - furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever)==osOK); - - canvas_draw_box(canvas, box_mover->model->x,box_mover->model->y, box_mover->model->sizex, box_mover->model->sizey); - - osMutexRelease(box_mover->model_mutex); -} - -void input_callback(InputEvent* input, void* ctx){ - BoxMover* box_mover = ctx; - osMessageQueuePut(box_mover->event_queue, input, 0, osWaitForever); - -} - -BoxMover* box_mover_alloc(){ - BoxMover* instance = malloc(sizeof(BoxMover)); - instance->model = malloc(sizeof(BoxMoverModel)); - instance->model->x = 10; - instance->model->y = 10; - instance->model->sizex = 4; - instance->model->sizey = 4; - -instance->model_mutex = osMutexNew(NULL); - instance->event_queue = osMessageQueueNew(8, sizeof(InputEvent), NULL); - instance->view_port = view_port_alloc(); - view_port_draw_callback_set(instance->view_port, draw_callback, instance); - - view_port_input_callback_set(instance->view_port, input_callback, instance); - - - instance->gui = furi_record_open("gui"); - gui_add_view_port(instance->gui, instance->view_port, GuiLayerFullscreen); - - - - return instance; -} - -void box_mover_free(BoxMover* instance){ - view_port_enabled_set(instance->view_port,false); - gui_remove_view_port(instance->gui, instance->view_port); - furi_record_close("gui"); - view_port_free(instance->view_port); - osMessageQueueDelete(instance->event_queue); - osMutexDelete(instance->model_mutex); - - free(instance->model); - free(instance); -} - - -int32_t box_mover_app(void* p){ - UNUSED(p); - BoxMover* box_mover = box_mover_alloc(); - - - InputEvent event; - for(bool processing = true; processing;){ - osStatus_t status = osMessageQueueGet(box_mover->event_queue, &event, NULL, 100); - furi_check(osMutexAcquire(box_mover->model_mutex, osWaitForever) == osOK); - if(status==osOK){ - if(event.type==InputTypePress){ - switch(event.key){ - case InputKeyUp: - if (box_mover->model->y >= 1) - box_mover->model->y-=2; - else{ - shake(); - } - break; - case InputKeyDown: - if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))) // So we're trying to see if it's even or odd, to determine how much to offset the bounds check by, since we're doing this based of the square origin+its size. idk. - box_mover->model->y+=2; - else{ - shake(); - } - break; - case InputKeyLeft: - if (box_mover->model->x >= 1) - box_mover->model->x-=2; - else{ - shake(); - } - break; - case InputKeyRight: - if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))) - box_mover->model->x+=2; - else{ - shake(); - } - break; - case InputKeyOk: - if (box_mover->model->sizex<=50 && box_mover->model->sizey<=50){ - if (box_mover->model->x <= (127-(box_mover->model->sizex+(box_mover->model->sizex % 2 != 0)))){ - if (box_mover->model->y <= (63-(box_mover->model->sizey+(box_mover->model->sizey % 2 != 0)))){ - box_mover->model->sizex+=1; - box_mover->model->sizey+=1; - //TODO - also check the box will not grow past boundary. - } - else - shake(); - } - else - shake(); - } - else - shake(); - - - break; - case InputKeyBack: - processing = false; - break; - } - } - } - osMutexRelease(box_mover->model_mutex); - view_port_update(box_mover->view_port); - } - - - - box_mover_free(box_mover); - return 0; -} - - - - From 84739fd4f9c4c0c81b8063cd8f90d48d5cf16ceb Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Wed, 15 Jun 2022 23:14:19 -0700 Subject: [PATCH 87/91] nuke and cleanup II --- applications/VideoPoker/poker.c | 1 - applications/applications.mk | 16 +--------------- null.d | 1 - 3 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 null.d diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c index 29170810efe..ba3a4e24518 100644 --- a/applications/VideoPoker/poker.c +++ b/applications/VideoPoker/poker.c @@ -1024,4 +1024,3 @@ int32_t video_poker_app(void* p) { poker_player_free(poker_player); return 0; } - diff --git a/applications/applications.mk b/applications/applications.mk index 880c4267531..abb3eb4df38 100644 --- a/applications/applications.mk +++ b/applications/applications.mk @@ -49,8 +49,6 @@ APP_MUSIC_PLAYER = 1 APP_SNAKE_GAME = 1 APP_TETRIS_GAME = 1 APP_RAYCAST_GAME = 1 -APP_VIDEO_POKER = 1 -# APP_RAYCAST_GAME = 1 APP_CLOCK = 1 APP_SPECTRUM_ANALYZER = 1 APP_FLAPPY_GAME = 1 @@ -280,18 +278,6 @@ CFLAGS += -DAPP_SNAKE_GAME SRV_GUI = 1 endif -APP_BOX_MOVER ?= 0 -ifeq ($(APP_BOX_MOVER),1) -CFLAGS += -DAPP_BOX_MOVER -SRV_GUI = 1 -endif - -APP_VIDEO_POKER ?= 0 -ifeq ($(APP_VIDEO_POKER),1) -CFLAGS += -DAPP_VIDEO_POKER -SRV_GUI = 1 -endif - APP_SPECTRUM_ANALYZER ?= 0 ifeq ($(APP_SPECTRUM_ANALYZER), 1) CFLAGS += -DAPP_SPECTRUM_ANALYZER @@ -465,4 +451,4 @@ endif SRV_STORAGE ?= 0 ifeq ($(SRV_STORAGE), 1) CFLAGS += -DSRV_STORAGE -endif +endif \ No newline at end of file diff --git a/null.d b/null.d deleted file mode 100644 index ff21f306ebc..00000000000 --- a/null.d +++ /dev/null @@ -1 +0,0 @@ -null.o: /dev/null From 8aa2f0d972f69653373b7d7317d6f205746e1a9c Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Wed, 15 Jun 2022 23:15:13 -0700 Subject: [PATCH 88/91] nuke and cleanup III --- README.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000000..8d82894c1f9 --- /dev/null +++ b/README.md @@ -0,0 +1,72 @@ +# [Flipper Zero Firmware](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/ReadMe.md) <= READ THIS READ ME +- ****This software is for experimental purposes only and is not meant for any illegal activity/purposes. We do not condone illegal activity and strongly encourage keeping transmissions to legal/valid uses allowed by law.** +- FLASH STOCK FIRST BEFORE UPDATING TO CUSTOM FIRMWARE +- BUILD WITH COMPACT FLAG SINCE IT IS TOO LARGE +- CH0NG, CH33CH and N00BY rename your flipper. + +# Clone the Repository + +You should clone with +```shell +$ git clone --recursive https://github.com/RogueMaster/flipperzero-firmware-wPlugins.git +$ docker-compose up -d +$ docker-compose exec dev make DEBUG=0 COMPACT=1 +``` + +Latest Updates: +- Fixed [Added 90s Timeout for Backlight Time (By RogueMaster)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/applications/notification/notification_settings_app.c) +- Removed [Chip8 Emulator (By mega8bit & dwdraugr)](https://github.com/mega8bit/flipperzero-firmware) [Updated by ESurge To Work.](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/tree/0.60.2-adffe20b-0614-RM/applications/chip8) Per [dwdraugr](https://github.com/dwdraugr/flipper-chip/commit/741d7fb99939d74353a99c14ea21636daae1da14), "Controlling are unavailable, because CHIP-8 using specific async event management. But we tried :)". +- Latest DEV changes for [Amiibo (Thanks to GMMan)](https://github.com/flipperdevices/flipperzero-firmware/pull/1313) and [7618c8ba](https://github.com/flipperdevices/flipperzero-firmware/commit/7618c8ba6ffe3026858373f8346b052dd45193ef) +- Changed touchtunes_map to be named touchtunes_map.txt, be sure to update your files! + +**Special Instructions:** +- Download these files into the subghz/assets folder on your SD card. Edit the two `_map` files to contain your specific subghz (.SUB) files. +- - Note 1: If you don't have a subghz/assets folder, you should ensure you have made at least one clean flash with stock firmware and your SD card installed in order to ensure the database structure is built, otherwise it will not exist for alternative forks. +- - Note 2: /any is a special keyword signifying either /int (internal storage) or /ext (external storage). +- - Note 3: the changes you are making to the `_map` files is to point to the location of the specific assets of the touchtunes folder as well as the universal RF map apps which you will have to develop or compile seperately and are not a part of this repo. +- - Note 4: /any is effectively root, so the folder structure should start "/any/subghz/assets" and not what is based on the repo below do not blindly copy the repo it will not work. +- - [assets/resources/subghz/assets/universal_rf_map.txt](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/subghz/assets/universal_rf_map.txt) +- - [assets/resources/subghz/assets/touchtunes_map.txt](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/subghz/assets/touchtunes_map.txt) +- - [assets/resources/subghz/assets/setting_user](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/subghz/assets/setting_user) +- Download this file into the nfc/assets folder on your SD card. +- - [assets/resources/nfc/assets/mf_classic_dict.nfc](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/assets/resources/nfc/assets/mf_classic_dict.nfc) +- Add a folder to SD card named `wav_player` (for 8bit 2ch unsigned wav files) +- Add a folder to SD card named `music_player` (FMF and RTTTL/TXT files) + +Special shout out to these libraries for giving us more fun: +- https://github.com/Gioman101/FlipperAmiibo +- https://github.com/jimilinuxguy/flipperzero-touchtunes +- https://github.com/Lucaslhm/AmiiboFlipperConverter +- https://github.com/MuddledBox/FlipperZeroCases +- https://github.com/MuddledBox/FlipperZeroSub-GHz +- https://github.com/neverfa11ing/FlipperMusicRTTTL +- https://github.com/UberGuidoZ/Flipper +- https://github.com/UberGuidoZ/Flipper-IRDB + +Added Features: +- [Actual PIN Lock (By RogueMaster)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/applications/desktop/desktop.c) +- [Added 90s Timeout for Backlight Time (By RogueMaster)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/applications/notification/notification_settings_app.c) +- [Default scan names will have timestamp instead of random name assigned (By RogueMaster)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/lib/toolbox/random_name.c) +- Keeloq update from [Xorist](https://github.com/xorist/FlipperX) +- SubGHz Protocols (Keeloq, Nice Flor, Star Line) updates from [Eng1n33r](https://github.com/Eng1n33r/flipperzero-firmware) +- Added Flashing the firmware using the blackmagic board with make blackmagic_load [From WeTox](https://github.com/wetox-team/flipperzero-firmware) +- Removing T5577 passwords via the cli command rfid clear_pass_t5577 using a dictionary attack [From WeTox](https://github.com/wetox-team/flipperzero-firmware) +- Added New SubGHZ Scanning image with Pikachu [Thanks to Panzer00Z](https://github.com/Panzer00Z/flipperzero-firmware/blob/3a548ea9bb181c9348d8afb427890c411456134e/assets/icons/SubGhz/Scanning_123x52.png) + +Plugins: +- [Clock/Stopwatch (By CompaqDisc, Stopwatch & Sound Alert By RogueMaster)](https://gist.github.com/CompaqDisc/4e329c501bd03c1e801849b81f48ea61) +- [Dice Roller Including SEX/WAR/8BALL/WEED DICE (By RogueMaster)](https://github.com/RogueMaster/flipperzero-firmware-wPlugins/blob/unleashed/applications/dice/dice.c) +- [Flappy Bird (By DroomOne)](https://github.com/DroomOne/flipperzero-firmware/tree/dev/applications/flappy_bird) +- [HID Analyzer (By Ownasaurus)](https://github.com/Ownasaurus/flipperzero-firmware/tree/hid-analyzer/applications/hid_analyzer) +- [Menu Changes and Icons (By Redlink)](https://github.com/redlink2/flipperzero-firmware/tree/menuChanges) +- [Mouse Jiggler (By Jacob-Tate)(Original By MuddleBox)](https://github.com/Jacob-Tate/flipperzero-firmware/blob/dev/applications/mouse_jiggler/mouse_jiggler.c) Updated by Jacob-Tate To Work +- [RayCast (Bt Zlo)](https://github.com/flipperdevices/flipperzero-firmware/tree/zlo/raycast-game-engine) +- [RF Remix (By ESurge)(Original By jimilinuxguy)](https://github.com/ESurge/flipperzero-firmware-unirfremix) +- [Spectrum Analyzer (By jolcese)](https://github.com/jolcese/flipperzero-firmware/tree/spectrum/applications/spectrum_analyzer) +- [Tanks (By Alexgr13)](https://github.com/alexgr13/flipperzero-firmware/tree/fork/dev/applications/tanks-game) Updated by RogueMaster To Work +- [Tetris (By jeffplang)](https://github.com/jeffplang/flipperzero-firmware/tree/tetris_game/applications/tetris_game) +- [Touch Tunes Remote (By jimilinuxguy)](https://github.com/jimilinuxguy/flipperzero-universal-rf-remote/tree/028d615c83f059bb2c905530ddb3d4efbd3cbcae/applications/jukebox) +- [Video Poker (By PixlEmly)](https://github.com/PixlEmly/flipperzero-firmware-testing/blob/unleashed/applications/VideoPoker/poker.c) +- [WAV Player (By Zlo)](https://github.com/flipperdevices/flipperzero-firmware/tree/zlo/wav-player) Updated by Atmanos & RogueMaster To Work + +Thank you, [MuddleBox](https://github.com/MuddledBox/flipperzero-firmware), [Eng1n33r](https://github.com/Eng1n33r/flipperzero-firmware), [WeTox-Team](https://github.com/wetox-team/flipperzero-firmware) & of course, most of all [Flipper Devices](https://github.com/flipperdevices/flipperzero-firmware)! From a506b196309eafebf0ee72312cb308db4bf2d903 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Wed, 15 Jun 2022 23:17:01 -0700 Subject: [PATCH 89/91] nuke and cleanup IV --- applications/applications.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/applications/applications.c b/applications/applications.c index 6b857caf196..c8a9b4c5194 100644 --- a/applications/applications.c +++ b/applications/applications.c @@ -50,8 +50,6 @@ extern int32_t music_player_app(void* p); extern int32_t snake_game_app(void* p); extern int32_t tetris_game_app(void *p); extern int32_t clock_app(void *p); -//extern int32_t box_mover_app(void* p); -extern int32_t video_poker_app(void* p); // extern int32_t floopper_bloopper(void* p); extern int32_t raycast_game_app(void* p); extern int32_t spectrum_analyzer_app(void* p); @@ -360,7 +358,6 @@ const FlipperApplication FLIPPER_GAMES[] = { .flags = FlipperApplicationFlagDefault}, #endif - #ifdef APP_VIDEO_POKER {.app = video_poker_app, .name = "Video Poker", @@ -369,14 +366,6 @@ const FlipperApplication FLIPPER_GAMES[] = { .flags =FlipperApplicationFlagDefault}, #endif -#ifdef APP_ZOMBIEZ - {.app = zombiez_app, - .name = "Zombiez", - .stack_size = 2048, - .icon = &A_Plugins_14, - .flags = FlipperApplicationFlagDefault}, -#endif - }; const size_t FLIPPER_GAMES_COUNT = COUNT_OF(FLIPPER_GAMES); @@ -689,4 +678,4 @@ const FlipperApplication FLIPPER_SETTINGS_APPS[] = { #endif }; -const size_t FLIPPER_SETTINGS_APPS_COUNT = COUNT_OF(FLIPPER_SETTINGS_APPS); +const size_t FLIPPER_SETTINGS_APPS_COUNT = COUNT_OF(FLIPPER_SETTINGS_APPS); \ No newline at end of file From 33804106008ad50b423367bf6f5bc49ca6d37937 Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Wed, 15 Jun 2022 23:19:11 -0700 Subject: [PATCH 90/91] Poker cleaned up, less globals, better alignment, some comments --- applications/VideoPoker/poker.c | 249 ++++++++++++++------------------ 1 file changed, 107 insertions(+), 142 deletions(-) diff --git a/applications/VideoPoker/poker.c b/applications/VideoPoker/poker.c index ba3a4e24518..406871b91b2 100644 --- a/applications/VideoPoker/poker.c +++ b/applications/VideoPoker/poker.c @@ -16,19 +16,15 @@ This has been converted from a standalone PC console app to flipper All of the original input/output handing code has been ripped out Original code also used TONS of defines and everything was a global. -I have not completed cleaning up and moving globals to members. - -It's not super well written but I think it at least meets a minimum expectation of quality -A lot of it could be cleaned up or optimized. -As is, it does what it wanted and doesn't seem to have major issues, so that's pretty good. +As is, it does what I wanted and doesn't seem to have major issues, so that's pretty good. Game logic is handled during input and this is a bit of a mess of nested ifs. Sometimes duplicate cards will show up. there is a function to test this. I should use it better. -After losing, bet is set to 10 eve + */ #define TAG "Video Poker" -void Poker_Shaker(void) { +static void Shake(void) { NotificationApp* notification = furi_record_open("notification"); notification_message(notification, &sequence_single_vibro); furi_record_close("notification"); @@ -40,16 +36,17 @@ typedef struct { int suit; /* card's suit (see just below) */ int gone; /* true if it's been dealt */ int held; /* for hand */ -} card; +} PokerPlayer_card; typedef struct { osMutexId_t* model_mutex; osMessageQueueId_t event_queue; ViewPort* view_port; Gui* gui; - card hand[5]; - card shand[5]; - card deck[52]; + PokerPlayer_card hand[5]; + PokerPlayer_card shand[5]; + PokerPlayer_card deck[52]; + int GameType; /* What rules are we using */ int held[5]; int score; int pot; @@ -59,8 +56,46 @@ typedef struct { int minbet; } PokerPlayer; +/* GameState +0=Splash/help, OK button (later on up/down for rules or settings) +1=cards down, betting enabled, left/right to change bet, OK to confirm +2=first hand, holding enabled, left/right to pick card, OK to hold/unhold card, down to confirm +3=second hand, only confirm to claim rewards +4=game over/won +*/ + +/* +#define AllAmerican 0 +#define TensOrBetter 1 +#define BonusPoker 2 +#define DoubleBonus 3 +#define DoubleBonusBonus 4 +#define JacksOrBetter 5 +#define JacksOrBetter95 6 +#define JacksOrBetter86 7 +#define JacksOrBetter85 8 +#define JacksOrBetter75 9 +#define JacksOrBetter65 10 +#define NUMGAMES 11 +*/ +/* + The game in play. Default is Jacks or Better, + which is coded into initialization of static data +*/ +const char* gamenames[11] = { + "All American", + "Tens or Better", + "Bonus Poker", + "Double Bonus", + "Double Bonus Bonus", + "Jacks or Better", + "9/5 Jacks or Better", + "8/6 Jacks or Better", + "8/5 Jacks or Better", + "7/5 Jacks or Better", + "6/5 Jacks or Better"}; -card deck[52] = { +PokerPlayer_card deck[52] = { /* index, card name, suit, gone */ /* Clubs:0 Diamonds:1 Hearts: 2 Spades: 3 */ {1, "2", 0, 0}, {2, "3", 0, 0}, {3, "4", 0, 0}, {4, "5", 0, 0}, {5, "6", 0, 0}, @@ -79,19 +114,8 @@ card deck[52] = { {6, "7", 3, 0}, {7, "8", 3, 0}, {8, "9", 3, 0}, {9, "10", 3, 0}, {10, "J", 3, 0}, {11, "Q", 3, 0}, {12, "K", 3, 0}, {13, "A", 3, 0}, }; -/* -int score_low = 1000; - int score_high = 1000; - int minbet = 10; - int betmultiplier = 1; - */ -/* GameState -0=Splash/help, OK button (later on up/down for rules or settings) -1=cards down, betting enabled, left/right to change bet, OK to confirm -2=first hand, holding enabled, left/right to pick card, OK to hold/unhold card, down to confirm -3=second hand, only confirm to claim rewards -4=game over/won -*/ + + /* Image Format @@ -100,7 +124,7 @@ Image Format 0xa4,0x01 = 0x1a4, or, 420 - the size of the compressed array, minus this header. Rest of the data is char array output from heatshrink of the original XBM char array. Calculated Header: 0x01,0x00,0xa4,0x01 -from furi_hal_compress.c +from furi_hal_compress.c: typedef struct { uint8_t is_compressed; uint8_t reserved; @@ -291,56 +315,10 @@ const uint8_t* _I_Ten_7x8[] = {_I_Ten_7x8_0}; const Icon I_Ten_7x8 = {.width = 18, .height = 14, .frame_count = 1, .frame_rate = 0, .frames = _I_Ten_7x8}; -const char* StateName[10] = { - /* use this for the status line and put in better wording */ - "Intro", // should never see this - "Select Bet", // cards are face down - "Choose Cards", // cards are revealed, player can choose which to hold - "Good Luck!" // cards are replaced, payouts here. -}; - -//const uint8_t _I_Splash_128x64_0[] = { -int Poker_Title; //Have we seen the title - -const char* suitname[4] = {"C", "D", "H", "S"}; - -#define AllAmerican 0 -#define TensOrBetter 1 -#define BonusPoker 2 -#define DoubleBonus 3 -#define DoubleBonusBonus 4 -#define JacksOrBetter 5 /* default */ -#define JacksOrBetter95 6 -#define JacksOrBetter86 7 -#define JacksOrBetter85 8 -#define JacksOrBetter75 9 -#define JacksOrBetter65 10 -/* If you add another game, increment NUMGAMES: */ -#define NUMGAMES 11 - -/* - The game in play. Default is Jacks or Better, - which is coded into initialization of static data -*/ - -int game = JacksOrBetter; - -const char* gamenames[NUMGAMES] = { - "All American", - "Tens or Better", - "Bonus Poker", - "Double Bonus", - "Double Bonus Bonus", - "Jacks or Better", - "9/5 Jacks or Better", - "8/6 Jacks or Better", - "8/5 Jacks or Better", - "7/5 Jacks or Better", - "6/5 Jacks or Better"}; /* Sanity check: check that there are no duplicate cards in hand */ -void playcard(PokerPlayer* app) { +static void playcard(PokerPlayer* app) { int i, c, crd; int hold[5]; @@ -369,7 +347,7 @@ void playcard(PokerPlayer* app) { } } -int check_for_dupes(PokerPlayer* app) { +static int check_for_dupes(PokerPlayer* app) { int i, j; for(i = 0; i < 5; i++) { @@ -389,7 +367,7 @@ int check_for_dupes(PokerPlayer* app) { returns 1 if the sorted hand is a flush */ -int flush(PokerPlayer* app) { +static int flush(PokerPlayer* app) { if(app->shand[0].suit == app->shand[1].suit && app->shand[1].suit == app->shand[2].suit && app->shand[2].suit == app->shand[3].suit && app->shand[3].suit == app->shand[4].suit) return 1; @@ -402,7 +380,7 @@ int flush(PokerPlayer* app) { returns 1 if the sorted hand is a straight */ -int straight(PokerPlayer* app) { +static int straight(PokerPlayer* app) { if(app->shand[1].index == app->shand[0].index + 1 && app->shand[2].index == app->shand[1].index + 1 && app->shand[3].index == app->shand[2].index + 1 && @@ -423,7 +401,7 @@ int straight(PokerPlayer* app) { the middle 3 all match, and the first or last matches those */ -int four(PokerPlayer* app) { +static int four(PokerPlayer* app) { if((app->shand[1].index == app->shand[2].index && app->shand[2].index == app->shand[3].index) && (app->shand[0].index == app->shand[2].index || app->shand[4].index == app->shand[2].index)) @@ -437,7 +415,7 @@ int four(PokerPlayer* app) { 3 of a kind and a pair */ -int full(PokerPlayer* app) { +static int full(PokerPlayer* app) { if(app->shand[0].index == app->shand[1].index && (app->shand[2].index == app->shand[3].index && app->shand[3].index == app->shand[4].index)) return 1; @@ -454,7 +432,7 @@ int full(PokerPlayer* app) { it can appear 3 ways */ -int three(PokerPlayer* app) { +static int three(PokerPlayer* app) { if(app->shand[0].index == app->shand[1].index && app->shand[1].index == app->shand[2].index) return 1; @@ -472,7 +450,7 @@ int three(PokerPlayer* app) { it can appear in 3 ways */ -int twopair(PokerPlayer* app) { +static int twopair(PokerPlayer* app) { if(((app->shand[0].index == app->shand[1].index) && (app->shand[2].index == app->shand[3].index)) || ((app->shand[0].index == app->shand[1].index) && @@ -489,10 +467,10 @@ int twopair(PokerPlayer* app) { or if the game is Tens or Better, 10s or better. */ -int two(PokerPlayer* app) { +static int two(PokerPlayer* app) { int min = 10; - if(game == TensOrBetter) min = 9; + if(app->GameType == 1) min = 9; if(app->shand[0].index == app->shand[1].index && app->shand[1].index >= min) return 1; if(app->shand[1].index == app->shand[2].index && app->shand[2].index >= min) return 1; @@ -502,7 +480,7 @@ int two(PokerPlayer* app) { return 0; } -int paytable[10] = { +static int paytable[10] = { 800, /* royal flush: 800 */ 50, /* straight flush: 50 */ 25, /* 4 of a kind: 25 */ @@ -528,10 +506,10 @@ const char* handname[10] = { "Nothing", }; -int recognize(PokerPlayer* app) { +static int recognize(PokerPlayer* app) { int i, j, f = 0; int min = 100; - card tmp[5]; + PokerPlayer_card tmp[5]; int st = 0, fl = 0; /* Sort hand into sorted hand (app->shand) */ @@ -589,38 +567,30 @@ void poker_draw_callback(Canvas* canvas, void* ctx) { canvas_draw_str_aligned(canvas, 127, 0, AlignRight, AlignTop, buffer); } - /* Draw the Cards */ + /* Start of game. Cards are face down, bet can be changed */ if(poker_player->GameState == 1) { snprintf(buffer, sizeof(buffer), "Bet:%d", poker_player->bet); canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); snprintf(buffer, sizeof(buffer), "<*> Place Bet"); canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); - canvas_draw_icon(canvas, 5, 18, &I_CardBack_22x35); - canvas_draw_icon(canvas, 29, 18, &I_CardBack_22x35); + canvas_draw_icon(canvas, 5, 18, &I_CardBack_22x35); + canvas_draw_icon(canvas, 29, 18, &I_CardBack_22x35); canvas_draw_icon(canvas, 53, 18, &I_CardBack_22x35); - canvas_draw_icon(canvas, 77, 18, &I_CardBack_22x35); - canvas_draw_icon(canvas, 101, 18, &I_CardBack_22x35); } +/* Cards are turned face up. Bet is deducted and put in th pot. Show the selector hand */ else if(poker_player->GameState == 2 || poker_player->GameState == 3) { snprintf(buffer, sizeof(buffer), "Pot:%d", poker_player->bet); canvas_draw_str_aligned(canvas, 0, 0, AlignLeft, AlignTop, buffer); snprintf(buffer, sizeof(buffer), "<*> Select Hold"); canvas_draw_str_aligned(canvas, 0, 9, AlignLeft, AlignTop, buffer); - /* snprintf( - buffer, - sizeof(buffer), - "%s:%ix", - handname[recognize(poker_player)], - paytable[recognize(poker_player)]); - canvas_draw_str_aligned(canvas, 5, 5, AlignLeft, AlignTop, buffer); */ - +/* Normal or inverse to indicate selection - cards*/ poker_player->held[0] ? canvas_draw_rbox(canvas, 5, 18, 22, 35, 3) : canvas_draw_rframe(canvas, 5, 18, 22, 35, 3); @@ -636,7 +606,7 @@ void poker_draw_callback(Canvas* canvas, void* ctx) { poker_player->held[4] ? canvas_draw_rbox(canvas, 101, 18, 22, 35, 3) : canvas_draw_rframe(canvas, 101, 18, 22, 35, 3); - //shameful +/* Normal or inverse to indicate selection - card suit and value */ poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); @@ -652,8 +622,6 @@ void poker_draw_callback(Canvas* canvas, void* ctx) { if(poker_player->hand[0].suit == 3) // spade canvas_draw_icon(canvas, 18, 43, &I_spade_7x8); - //canvas_draw_str_aligned(canvas, 25, 49, AlignRight, AlignBottom, buffer); - poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); @@ -669,7 +637,6 @@ void poker_draw_callback(Canvas* canvas, void* ctx) { if(poker_player->hand[1].suit == 3) // spade canvas_draw_icon(canvas, 42, 43, &I_spade_7x8); - //canvas_draw_str_aligned(canvas, 49, 49, AlignRight, AlignBottom, buffer); poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); @@ -686,7 +653,6 @@ void poker_draw_callback(Canvas* canvas, void* ctx) { if(poker_player->hand[2].suit == 3) // spade canvas_draw_icon(canvas, 66, 43, &I_spade_7x8); - // canvas_draw_str_aligned(canvas, 73, 49, AlignRight, AlignBottom, buffer); poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); @@ -703,7 +669,6 @@ void poker_draw_callback(Canvas* canvas, void* ctx) { if(poker_player->hand[3].suit == 3) // spade canvas_draw_icon(canvas, 90, 43, &I_spade_7x8); - // canvas_draw_str_aligned(canvas, 97, 49, AlignRight, AlignBottom, buffer); poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); @@ -720,127 +685,126 @@ void poker_draw_callback(Canvas* canvas, void* ctx) { if(poker_player->hand[4].suit == 3) // spade canvas_draw_icon(canvas, 113, 43, &I_spade_7x8); - //canvas_draw_str_align-ed(canvas, 120, 50, AlignRight, AlignBottom, buffer); - + /* Card Value. Profont_22 does not include letters (AJQK), and "10" is too big. These are bitmaps. */ canvas_set_font(canvas, FontBigNumbers); if(poker_player->hand[0].index >= 1 && poker_player->hand[0].index <= 8) { poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[0].sym); - canvas_draw_str_aligned(canvas, 7, 22, AlignLeft, AlignTop, buffer); + canvas_draw_str_aligned(canvas, 8, 21, AlignLeft, AlignTop, buffer); } else { poker_player->held[0] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); if(poker_player->hand[0].index == 9) // Ten - canvas_draw_icon(canvas, 7, 22, &I_Ten_7x8); + canvas_draw_icon(canvas, 7, 21, &I_Ten_7x8); if(poker_player->hand[0].index == 10) // Jack - canvas_draw_icon(canvas, 7, 22, &I_Jack_7x8); + canvas_draw_icon(canvas, 8, 21, &I_Jack_7x8); if(poker_player->hand[0].index == 11) // Queen - canvas_draw_icon(canvas, 7, 22, &I_Queen_7x8); + canvas_draw_icon(canvas, 8, 21, &I_Queen_7x8); if(poker_player->hand[0].index == 12) // King - canvas_draw_icon(canvas, 7, 22, &I_King_7x8); + canvas_draw_icon(canvas, 8, 21, &I_King_7x8); if(poker_player->hand[0].index == 13) // ace - canvas_draw_icon(canvas, 7, 22, &I_Ace_7x8); + canvas_draw_icon(canvas, 8, 21, &I_Ace_7x8); } if(poker_player->hand[1].index >= 0 && poker_player->hand[1].index <= 8) { poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[1].sym); - canvas_draw_str_aligned(canvas, 31, 22, AlignLeft, AlignTop, buffer); + canvas_draw_str_aligned(canvas, 32, 21, AlignLeft, AlignTop, buffer); } else { /* bitmap time */ poker_player->held[1] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); if(poker_player->hand[1].index == 9) // Ten - canvas_draw_icon(canvas, 31, 22, &I_Ten_7x8); + canvas_draw_icon(canvas, 31, 21, &I_Ten_7x8); if(poker_player->hand[1].index == 10) // Jack - canvas_draw_icon(canvas, 31, 22, &I_Jack_7x8); + canvas_draw_icon(canvas, 32, 21, &I_Jack_7x8); if(poker_player->hand[1].index == 11) // Queen - canvas_draw_icon(canvas, 31, 22, &I_Queen_7x8); + canvas_draw_icon(canvas, 32, 21, &I_Queen_7x8); if(poker_player->hand[1].index == 12) // King - canvas_draw_icon(canvas, 31, 22, &I_King_7x8); + canvas_draw_icon(canvas, 32, 21, &I_King_7x8); if(poker_player->hand[1].index == 13) // ace - canvas_draw_icon(canvas, 31, 22, &I_Ace_7x8); + canvas_draw_icon(canvas, 32, 21, &I_Ace_7x8); } if(poker_player->hand[2].index >= 0 && poker_player->hand[2].index <= 8) { poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[2].sym); - canvas_draw_str_aligned(canvas, 55, 22, AlignLeft, AlignTop, buffer); + canvas_draw_str_aligned(canvas, 56, 21, AlignLeft, AlignTop, buffer); } else { /* bitmap time */ poker_player->held[2] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); if(poker_player->hand[2].index == 9) // Ten - canvas_draw_icon(canvas, 55, 22, &I_Ten_7x8); + canvas_draw_icon(canvas, 55, 21, &I_Ten_7x8); if(poker_player->hand[2].index == 10) // Jack - canvas_draw_icon(canvas, 55, 22, &I_Jack_7x8); + canvas_draw_icon(canvas, 56, 21, &I_Jack_7x8); if(poker_player->hand[2].index == 11) // Queen - canvas_draw_icon(canvas, 55, 22, &I_Queen_7x8); + canvas_draw_icon(canvas, 56, 21, &I_Queen_7x8); if(poker_player->hand[2].index == 12) // King - canvas_draw_icon(canvas, 55, 22, &I_King_7x8); + canvas_draw_icon(canvas, 56, 21, &I_King_7x8); if(poker_player->hand[2].index == 13) // ace - canvas_draw_icon(canvas, 55, 22, &I_Ace_7x8); + canvas_draw_icon(canvas, 56, 21, &I_Ace_7x8); } if(poker_player->hand[3].index >= 0 && poker_player->hand[3].index <= 8) { poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[3].sym); - canvas_draw_str_aligned(canvas, 79, 22, AlignLeft, AlignTop, buffer); + canvas_draw_str_aligned(canvas, 80, 21, AlignLeft, AlignTop, buffer); } else { /* bitmap time */ poker_player->held[3] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); if(poker_player->hand[3].index == 9) // Ten - canvas_draw_icon(canvas, 79, 22, &I_Ten_7x8); + canvas_draw_icon(canvas, 79, 21, &I_Ten_7x8); if(poker_player->hand[3].index == 10) // Jack - canvas_draw_icon(canvas, 79, 22, &I_Jack_7x8); + canvas_draw_icon(canvas, 80, 21, &I_Jack_7x8); if(poker_player->hand[3].index == 11) // Queen - canvas_draw_icon(canvas, 79, 22, &I_Queen_7x8); + canvas_draw_icon(canvas, 80, 21, &I_Queen_7x8); if(poker_player->hand[3].index == 12) // King - canvas_draw_icon(canvas, 79, 22, &I_King_7x8); + canvas_draw_icon(canvas, 80, 21, &I_King_7x8); if(poker_player->hand[3].index == 13) // ace - canvas_draw_icon(canvas, 79, 22, &I_Ace_7x8); + canvas_draw_icon(canvas, 80, 21, &I_Ace_7x8); } if(poker_player->hand[4].index >= 0 && poker_player->hand[4].index <= 8) { poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); snprintf(buffer, sizeof(buffer), "%s", poker_player->hand[4].sym); - canvas_draw_str_aligned(canvas, 103, 22, AlignLeft, AlignTop, buffer); + canvas_draw_str_aligned(canvas, 104, 21, AlignLeft, AlignTop, buffer); } else { /* bitmap time */ poker_player->held[4] ? canvas_set_color(canvas, ColorWhite) : canvas_set_color(canvas, ColorBlack); if(poker_player->hand[4].index == 9) // Ten - canvas_draw_icon(canvas, 103, 22, &I_Ten_7x8); + canvas_draw_icon(canvas, 103, 21, &I_Ten_7x8); if(poker_player->hand[4].index == 10) // Jack - canvas_draw_icon(canvas, 103, 22, &I_Jack_7x8); + canvas_draw_icon(canvas, 104, 21, &I_Jack_7x8); if(poker_player->hand[4].index == 11) // Queen - canvas_draw_icon(canvas, 103, 22, &I_Queen_7x8); + canvas_draw_icon(canvas, 104, 21, &I_Queen_7x8); if(poker_player->hand[4].index == 12) // King - canvas_draw_icon(canvas, 103, 22, &I_King_7x8); + canvas_draw_icon(canvas, 104, 21, &I_King_7x8); if(poker_player->hand[4].index == 13) // ace - canvas_draw_icon(canvas, 103, 22, &I_Ace_7x8); + canvas_draw_icon(canvas, 104, 21, &I_Ace_7x8); } /* Draw the Select hand */ @@ -877,13 +841,13 @@ void poker_draw_callback(Canvas* canvas, void* ctx) { "%s:%ix", handname[recognize(poker_player)], paytable[recognize(poker_player)]); - canvas_draw_str_aligned(canvas, 63, 63, AlignCenter, AlignBottom, buffer); + canvas_draw_str_aligned(canvas, 63, 61, AlignCenter, AlignBottom, buffer); } - if(poker_player->GameState == 0) { - canvas_draw_icon(canvas, 0, 0, &I_Splash_128x64); + if(poker_player->GameState == 0) { + canvas_draw_icon(canvas, 0, 0, &I_Splash_128x64); /* Initial launch */ } if(poker_player->GameState == 4) { - canvas_draw_icon(canvas, 0, 0, &I_BadEnd_128x64); + canvas_draw_icon(canvas, 0, 0, &I_BadEnd_128x64); /* Just Lost The Game */ } osMutexRelease(poker_player->model_mutex); @@ -941,7 +905,7 @@ int32_t video_poker_app(void* p) { if(event.type == InputTypePress) { switch(event.key) { case InputKeyUp: - Poker_Shaker(); + Shake(); break; case InputKeyDown: if(poker_player->GameState == 2) { @@ -1007,7 +971,7 @@ int32_t video_poker_app(void* p) { } playcard(poker_player); // shuffle shuffle } else if(poker_player->GameState == 4) { - Poker_Shaker(); + Shake(); processing = false; } break; @@ -1024,3 +988,4 @@ int32_t video_poker_app(void* p) { poker_player_free(poker_player); return 0; } + From 9867e000a9f3b447ffb22f23e29e92135567ccad Mon Sep 17 00:00:00 2001 From: Emily Blunts Date: Wed, 15 Jun 2022 23:23:23 -0700 Subject: [PATCH 91/91] Update to scripts --- scripts/User/ReadMe.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/User/ReadMe.md b/scripts/User/ReadMe.md index 499ec094f7a..2c8cbf86bc3 100644 --- a/scripts/User/ReadMe.md +++ b/scripts/User/ReadMe.md @@ -38,7 +38,21 @@ That's it. # iconencode Compress an icon asset from an XBM to a compressed char array ready to paste Will assume dimensions of 128x64 -There is a small header on these I haven't determined the format of, so this won't work as is yet. +Header works like this, you'll have to do this manually for now! + +Image Header Format Example +0x01 = Compressed +0x00 = Reserved Section +0xa4,0x01 = 0x1a4, or, 420 - the size of the compressed array, minus this header. Just count the commas ;) +Rest of the data is char array output from heatshrink of the original XBM char array. +Calculated Header: 0x01,0x00,0xa4,0x01 +from furi_hal_compress.c: +typedef struct { + uint8_t is_compressed; + uint8_t reserved; + uint16_t compressed_buff_size; +} FuriHalCompressHeader; + ## # icondecode