Created
November 6, 2021 22:46
-
-
Save vijfhoek/7dd380343840c569fcd10cd11f0f0beb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Generated by cobc 3.1.2.0 */ | |
/* Generated from day06b.cob */ | |
/* Generated at nov 06 2021 23:45:03 */ | |
/* GnuCOBOL build date Dec 24 2020 19:08:58 */ | |
/* GnuCOBOL package date Dec 23 2020 12:04:58 UTC */ | |
/* Compile command cobc -C day06b.cob */ | |
#include <stdio.h> | |
#include <string.h> | |
#define COB_KEYWORD_INLINE __inline | |
#include <libcob.h> | |
#define COB_SOURCE_FILE "day06b.cob" | |
#define COB_PACKAGE_VERSION "3.1.2" | |
#define COB_PATCH_LEVEL 0 | |
#define COB_MODULE_FORMATTED_DATE "nov 06 2021 23:45:03" | |
#define COB_MODULE_DATE 20211106 | |
#define COB_MODULE_TIME 234503 | |
/* Global variables */ | |
#include "day06b.c.h" | |
/* Function prototypes */ | |
int day06 (void); | |
static int day06_ (const int); | |
static void day06_module_init (cob_module *module); | |
/* Functions */ | |
/* PROGRAM-ID 'day06' */ | |
/* ENTRY 'day06' */ | |
int | |
day06 () | |
{ | |
return day06_ (0); | |
} | |
static int | |
day06_ (const int entry) | |
{ | |
/* Program local variables */ | |
#include "day06b.c.l.h" | |
/* Start of function code */ | |
/* CANCEL callback */ | |
if (unlikely(entry < 0)) { | |
if (entry == -10) | |
goto P_dump; | |
if (entry == -20) | |
goto P_clear_decimal; | |
goto P_cancel; | |
} | |
/* Check initialized, check module allocated, */ | |
/* set global pointer, */ | |
/* push module stack, save call parameter count */ | |
if (cob_module_global_enter (&module, &cob_glob_ptr, 0, entry, 0)) | |
return -1; | |
/* Set address of module parameter list */ | |
module->cob_procedure_params = cob_procedure_params; | |
/* Set frame stack pointer */ | |
frame_ptr = frame_stack; | |
frame_ptr->perform_through = 0; | |
frame_ptr->return_address_ptr = &&P_cgerror; | |
/* Initialize rest of program */ | |
if (unlikely(initialized == 0)) { | |
goto P_initialize; | |
} | |
P_ret_initialize: | |
/* Increment module active */ | |
module->module_active++; | |
/* Entry dispatch */ | |
goto l_2; | |
/* PROCEDURE DIVISION */ | |
/* Line: 29 : Entry day06 : day06b.cob */ | |
l_2:; | |
/* Line: 30 : ACCEPT : day06b.cob */ | |
cob_accept (&f_8); | |
/* Line: 31 : PERFORM : day06b.cob */ | |
for (;;) | |
{ | |
if (((int)cob_cmp (&f_8, &cob_all_space) == 0)) | |
break; | |
/* PERFORM input-loop-para */ | |
frame_ptr++; | |
frame_ptr->perform_through = 5; | |
frame_ptr->return_address_ptr = &&l_10; | |
goto l_5; | |
l_10: | |
frame_ptr--; | |
} | |
/* Line: 33 : MOVE : day06b.cob */ | |
memcpy (b_18, "0000000001", 10); | |
/* Line: 34 : PERFORM : day06b.cob */ | |
for (;;) | |
{ | |
if (((int)cob_cmp_numdisp (b_18, 10, 1000LL, 0) > 0)) | |
break; | |
/* PERFORM count-outer-para */ | |
frame_ptr++; | |
frame_ptr->perform_through = 8; | |
frame_ptr->return_address_ptr = &&l_11; | |
goto l_8; | |
l_11: | |
frame_ptr--; | |
} | |
/* Line: 35 : DISPLAY : day06b.cob */ | |
cob_display (0, 1, 1, &f_24); | |
/* Line: 37 : STOP RUN : day06b.cob */ | |
cob_stop_run (b_2); | |
/* Line: 39 : Paragraph input-loop-para : day06b.cob */ | |
l_5:; | |
/* Line: 42 : IF : day06b.cob */ | |
if (((int)memcmp (b_8 + 0, (cob_u8_ptr)"turn on", 7) == 0)) | |
{ | |
/* Line: 43 : MOVE : day06b.cob */ | |
memcpy (b_9, "turn on ", 10); | |
/* Line: 44 : MOVE : day06b.cob */ | |
cob_move (COB_SET_FLD(f0, 100 - 8, b_8 + 8, &a_1), &f_10); | |
} | |
else | |
{ | |
/* ELSE */ | |
/* Line: 45 : IF : day06b.cob */ | |
if (((int)memcmp (b_8 + 0, (cob_u8_ptr)"turn off", 8) == 0)) | |
{ | |
/* Line: 46 : MOVE : day06b.cob */ | |
memcpy (b_9, "turn off ", 10); | |
/* Line: 47 : MOVE : day06b.cob */ | |
cob_move (COB_SET_FLD(f0, 100 - 9, b_8 + 9, &a_1), &f_10); | |
} | |
else | |
{ | |
/* ELSE */ | |
/* Line: 48 : IF : day06b.cob */ | |
if (((int)cob_cmp (COB_SET_FLD(f0, 7, b_8 + 0, &a_1), (cob_field *)&c_1) == 0)) | |
{ | |
/* Line: 49 : MOVE : day06b.cob */ | |
memcpy (b_9, "toggle ", 10); | |
/* Line: 50 : MOVE : day06b.cob */ | |
cob_move (COB_SET_FLD(f0, 100 - 7, b_8 + 7, &a_1), &f_10); | |
} | |
} | |
} | |
/* Line: 53 : UNSTRING : day06b.cob */ | |
cob_unstring_init (&f_10, NULL, 1); | |
cob_unstring_delimited ((cob_field *)&c_2, 0); | |
cob_unstring_into (&f_11, 0, 0); | |
cob_unstring_into (&f_12, 0, 0); | |
cob_unstring_finish (); | |
/* Line: 56 : UNSTRING : day06b.cob */ | |
cob_unstring_init (&f_11, NULL, 1); | |
cob_unstring_delimited ((cob_field *)&c_3, 0); | |
cob_unstring_into (&f_13, 0, 0); | |
cob_unstring_into (&f_15, 0, 0); | |
cob_unstring_finish (); | |
/* Line: 57 : UNSTRING : day06b.cob */ | |
cob_unstring_init (&f_12, NULL, 1); | |
cob_unstring_delimited ((cob_field *)&c_3, 0); | |
cob_unstring_into (&f_14, 0, 0); | |
cob_unstring_into (&f_16, 0, 0); | |
cob_unstring_finish (); | |
/* Line: 59 : MOVE : day06b.cob */ | |
memcpy (b_18, b_15, 10); | |
/* Line: 60 : PERFORM : day06b.cob */ | |
for (;;) | |
{ | |
if (((int)memcmp (b_18, b_16, 10) > 0)) | |
break; | |
/* PERFORM outer-loop-para */ | |
frame_ptr++; | |
frame_ptr->perform_through = 6; | |
frame_ptr->return_address_ptr = &&l_12; | |
goto l_6; | |
l_12: | |
frame_ptr--; | |
} | |
/* Line: 62 : ACCEPT : day06b.cob */ | |
cob_accept (&f_8); | |
/* Implicit PERFORM return */ | |
if (frame_ptr->perform_through == 5) | |
goto *frame_ptr->return_address_ptr; | |
/* Line: 64 : Paragraph outer-loop-para : day06b.cob */ | |
l_6:; | |
/* Line: 65 : MOVE : day06b.cob */ | |
memcpy (b_17, b_13, 10); | |
/* Line: 66 : PERFORM : day06b.cob */ | |
for (;;) | |
{ | |
if (((int)memcmp (b_17, b_14, 10) > 0)) | |
break; | |
/* PERFORM inner-loop-para */ | |
frame_ptr++; | |
frame_ptr->perform_through = 7; | |
frame_ptr->return_address_ptr = &&l_13; | |
goto l_7; | |
l_13: | |
frame_ptr--; | |
} | |
/* Line: 67 : ADD : day06b.cob */ | |
cob_add_int (&f_18, 1, 0); | |
/* Implicit PERFORM return */ | |
if (frame_ptr->perform_through == 6) | |
goto *frame_ptr->return_address_ptr; | |
/* Line: 69 : Paragraph inner-loop-para : day06b.cob */ | |
l_7:; | |
/* Line: 70 : IF : day06b.cob */ | |
if (((int)cob_cmp (&f_9, (cob_field *)&c_4) == 0)) | |
{ | |
/* Line: 71 : ADD : day06b.cob */ | |
cob_add_int (COB_SET_FLD(f0, 10, b_20 + 10 * (cob_get_int (cob_intr_binop (&f_17, '+', (cob_field *)&c_5)) - 1) + 10000 * (cob_get_int (cob_intr_binop (&f_18, '+', (cob_field *)&c_5)) - 1), &a_2), 1, 0); | |
} | |
else | |
{ | |
/* ELSE */ | |
/* Line: 72 : IF : day06b.cob */ | |
if ((((int)cob_cmp (&f_9, (cob_field *)&c_6) == 0) && | |
((int)cob_cmp_numdisp (b_20 + 10 * (cob_get_int (cob_intr_binop (&f_17, '+', (cob_field *)&c_5)) - 1) + 10000 * (cob_get_int (cob_intr_binop (&f_18, '+', (cob_field *)&c_5)) - 1), 10, 0LL, 0) > 0))) | |
{ | |
/* Line: 73 : SUBTRACT : day06b.cob */ | |
cob_sub_int (COB_SET_FLD(f0, 10, b_20 + 10 * (cob_get_int (cob_intr_binop (&f_17, '+', (cob_field *)&c_5)) - 1) + 10000 * (cob_get_int (cob_intr_binop (&f_18, '+', (cob_field *)&c_5)) - 1), &a_2), 1, 0); | |
} | |
else | |
{ | |
/* ELSE */ | |
/* Line: 74 : IF : day06b.cob */ | |
if (((int)cob_cmp (&f_9, (cob_field *)&c_1) == 0)) | |
{ | |
/* Line: 75 : ADD : day06b.cob */ | |
cob_add_int (COB_SET_FLD(f0, 10, b_20 + 10 * (cob_get_int (cob_intr_binop (&f_17, '+', (cob_field *)&c_5)) - 1) + 10000 * (cob_get_int (cob_intr_binop (&f_18, '+', (cob_field *)&c_5)) - 1), &a_2), 2, 0); | |
} | |
} | |
} | |
/* Line: 78 : ADD : day06b.cob */ | |
cob_add_int (&f_17, 1, 0); | |
/* Implicit PERFORM return */ | |
if (frame_ptr->perform_through == 7) | |
goto *frame_ptr->return_address_ptr; | |
/* Line: 80 : Paragraph count-outer-para : day06b.cob */ | |
l_8:; | |
/* Line: 81 : MOVE : day06b.cob */ | |
memcpy (b_17, "0000000001", 10); | |
/* Line: 82 : PERFORM : day06b.cob */ | |
for (;;) | |
{ | |
if (((int)cob_cmp_numdisp (b_17, 10, 1000LL, 0) > 0)) | |
break; | |
/* PERFORM count-inner-para */ | |
frame_ptr++; | |
frame_ptr->perform_through = 9; | |
frame_ptr->return_address_ptr = &&l_14; | |
goto l_9; | |
l_14: | |
frame_ptr--; | |
} | |
/* Line: 83 : ADD : day06b.cob */ | |
cob_add_int (&f_18, 1, 0); | |
/* Implicit PERFORM return */ | |
if (frame_ptr->perform_through == 8) | |
goto *frame_ptr->return_address_ptr; | |
/* Line: 85 : Paragraph count-inner-para : day06b.cob */ | |
l_9:; | |
/* Line: 86 : ADD : day06b.cob */ | |
cob_add (&f_24, COB_SET_FLD(f0, 10, b_20 + 10 * (cob_get_int (&f_17) - 1) + 10000 * (cob_get_int (&f_18) - 1), &a_2), 0); | |
/* Line: 87 : ADD : day06b.cob */ | |
cob_add_int (&f_17, 1, 0); | |
/* Implicit PERFORM return */ | |
if (frame_ptr->perform_through == 9) | |
goto *frame_ptr->return_address_ptr; | |
/* Program exit */ | |
/* Decrement module active count */ | |
if (module->module_active) { | |
module->module_active--; | |
} | |
/* Pop module stack */ | |
cob_module_leave (module); | |
/* Program return */ | |
return b_2; | |
P_cgerror: | |
cob_fatal_error (COB_FERROR_CODEGEN); | |
/* Program initialization */ | |
P_initialize: | |
cob_check_version (COB_SOURCE_FILE, COB_PACKAGE_VERSION, COB_PATCH_LEVEL); | |
day06_module_init (module); | |
module->crt_status = NULL; | |
/* Initialize cancel callback */ | |
cob_set_cancel (module); | |
/* Initialize WORKING-STORAGE */ | |
b_2 = 0; | |
memset (b_8, 32, 100); | |
memset (b_9, 32, 10); | |
memset (b_10, 32, 100); | |
memset (b_11, 32, 100); | |
memset (b_12, 32, 100); | |
memset (b_13, 48, 10); | |
memset (b_14, 48, 10); | |
memset (b_15, 48, 10); | |
memset (b_16, 48, 10); | |
memset (b_17, 48, 10); | |
memset (b_18, 48, 10); | |
*(cob_u8_ptr)(b_19) = 48; | |
/* initialize first record for FILLER 1 */ | |
/* initialize first record for FILLER 2 */ | |
memset (b_20, 48, 10); | |
/* copy initialized record for FILLER 2 to later occurrences */ | |
{ | |
cob_u8_ptr b_ptr = b_20; | |
memcpy (b_ptr + 10, b_ptr, 10); /* FILLER 2: 2 thru 2 */ | |
memcpy (b_ptr + 20, b_ptr, 20); /* FILLER 2: 3 thru 4 */ | |
memcpy (b_ptr + 40, b_ptr, 40); /* FILLER 2: 5 thru 8 */ | |
memcpy (b_ptr + 80, b_ptr, 80); /* FILLER 2: 9 thru 16 */ | |
memcpy (b_ptr + 160, b_ptr, 160); /* FILLER 2: 17 thru 32 */ | |
memcpy (b_ptr + 320, b_ptr, 320); /* FILLER 2: 33 thru 64 */ | |
memcpy (b_ptr + 640, b_ptr, 640); /* FILLER 2: 65 thru 128 */ | |
memcpy (b_ptr + 1280, b_ptr, 1280); /* FILLER 2: 129 thru 256 */ | |
memcpy (b_ptr + 2560, b_ptr, 2560); /* FILLER 2: 257 thru 512 */ | |
memcpy (b_ptr + 5120, b_ptr, 4880); /* FILLER 2: 513 thru 1000 */ | |
} | |
/* copy initialized record for FILLER 1 to later occurrences */ | |
{ | |
cob_u8_ptr b_ptr = b_20; | |
memcpy (b_ptr + 10000, b_ptr, 10000); /* FILLER 1: 2 thru 2 */ | |
memcpy (b_ptr + 20000, b_ptr, 20000); /* FILLER 1: 3 thru 4 */ | |
memcpy (b_ptr + 40000, b_ptr, 40000); /* FILLER 1: 5 thru 8 */ | |
memcpy (b_ptr + 80000, b_ptr, 80000); /* FILLER 1: 9 thru 16 */ | |
memcpy (b_ptr + 160000, b_ptr, 160000); /* FILLER 1: 17 thru 32 */ | |
memcpy (b_ptr + 320000, b_ptr, 320000); /* FILLER 1: 33 thru 64 */ | |
memcpy (b_ptr + 640000, b_ptr, 640000); /* FILLER 1: 65 thru 128 */ | |
memcpy (b_ptr + 1280000, b_ptr, 1280000); /* FILLER 1: 129 thru 256 */ | |
memcpy (b_ptr + 2560000, b_ptr, 2560000); /* FILLER 1: 257 thru 512 */ | |
memcpy (b_ptr + 5120000, b_ptr, 4880000); /* FILLER 1: 513 thru 1000 */ | |
} | |
memset (b_24, 48, 10); | |
if (0 == 1) goto P_cgerror; | |
initialized = 1; | |
goto P_ret_initialize; | |
P_dump: | |
return 0; | |
/* CANCEL callback handling */ | |
P_cancel: | |
if (!initialized) | |
return 0; | |
if (module && module->module_active) | |
cob_fatal_error (COB_FERROR_CANCEL); | |
b_2 = 0; | |
cob_module_free (&module); | |
initialized = 0; | |
P_clear_decimal: | |
return 0; | |
} | |
/* End PROGRAM-ID 'day06' */ | |
/* Initialize module structure for day06 */ | |
static void day06_module_init (cob_module *module) | |
{ | |
module->module_name = "day06"; | |
module->module_formatted_date = COB_MODULE_FORMATTED_DATE; | |
module->module_source = COB_SOURCE_FILE; | |
module->module_entry.funcptr = (void *(*)())day06; | |
module->module_cancel.funcptr = (void *(*)())day06_; | |
module->module_ref_count = NULL; | |
module->module_path = &cob_module_path; | |
module->module_active = 0; | |
module->module_date = COB_MODULE_DATE; | |
module->module_time = COB_MODULE_TIME; | |
module->module_type = 0; | |
module->module_param_cnt = 0; | |
module->ebcdic_sign = 0; | |
module->decimal_point = '.'; | |
module->currency_symbol = '$'; | |
module->numeric_separator = ','; | |
module->flag_filename_mapping = 1; | |
module->flag_binary_truncate = 1; | |
module->flag_pretty_display = 1; | |
module->flag_host_sign = 0; | |
module->flag_no_phys_canc = 0; | |
module->flag_main = 0; | |
module->flag_fold_call = 0; | |
module->flag_exit_program = 0; | |
module->flag_debug_trace = 0; | |
module->flag_dump_ready = 0; | |
module->module_stmt = 0; | |
module->module_sources = NULL; | |
} | |
/* End functions */ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Generated by cobc 3.1.2.0 */ | |
/* Generated from day06b.cob */ | |
/* Generated at nov 06 2021 23:45:03 */ | |
/* GnuCOBOL build date Dec 24 2020 19:08:58 */ | |
/* GnuCOBOL package date Dec 23 2020 12:04:58 UTC */ | |
/* Compile command cobc -C day06b.cob */ | |
/* Module path */ | |
static const char *cob_module_path = NULL; | |
/* Number of call parameters */ | |
static int cob_call_params = 0; | |
/* Attributes */ | |
static const cob_field_attr a_1 = {0x21, 0, 0, 0x0000, NULL}; | |
static const cob_field_attr a_2 = {0x10, 10, 0, 0x0000, NULL}; | |
static const cob_field_attr a_3 = {0x21, 0, 0, 0x1000, NULL}; | |
static const cob_field_attr a_4 = {0x10, 1, 0, 0x1000, NULL}; | |
static const cob_field_attr cob_all_attr = {0x22, 0, 0, 0, NULL}; | |
/* Constants */ | |
static const cob_field c_1 = {6, (cob_u8_ptr)"toggle", &a_3}; | |
static const cob_field c_2 = {9, (cob_u8_ptr)" through ", &a_3}; | |
static const cob_field c_3 = {1, (cob_u8_ptr)",", &a_3}; | |
static const cob_field c_4 = {7, (cob_u8_ptr)"turn on", &a_3}; | |
static const cob_field c_5 = {1, (cob_u8_ptr)"1", &a_4}; | |
static const cob_field c_6 = {8, (cob_u8_ptr)"turn off", &a_3}; | |
static cob_field cob_all_space = {1, (cob_u8_ptr)" ", &cob_all_attr}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Generated by cobc 3.1.2.0 */ | |
/* Generated from day06b.cob */ | |
/* Generated at nov 06 2021 23:45:03 */ | |
/* GnuCOBOL build date Dec 24 2020 19:08:58 */ | |
/* GnuCOBOL package date Dec 23 2020 12:04:58 UTC */ | |
/* Compile command cobc -C day06b.cob */ | |
/* Program local variables for 'day06' */ | |
/* Module initialization indicator */ | |
static unsigned int initialized = 0; | |
/* Module structure pointer */ | |
static cob_module *module = NULL; | |
/* Global variable pointer */ | |
cob_global *cob_glob_ptr; | |
/* Local cob_field items */ | |
cob_field f0; | |
/* Call parameters */ | |
cob_field *cob_procedure_params[1]; | |
/* Perform frame stack */ | |
struct cob_frame *frame_ptr; | |
struct cob_frame frame_stack[255]; | |
/* Data storage */ | |
static int b_2; /* RETURN-CODE */ | |
static cob_u8_t b_8[100] __attribute__((aligned)); /* input-line */ | |
static cob_u8_t b_9[10] __attribute__((aligned)); /* action */ | |
static cob_u8_t b_10[100] __attribute__((aligned)); /* coords */ | |
static cob_u8_t b_11[100] __attribute__((aligned)); /* start-coords */ | |
static cob_u8_t b_12[100] __attribute__((aligned)); /* end-coords */ | |
static cob_u8_t b_13[10] __attribute__((aligned)); /* start-x */ | |
static cob_u8_t b_14[10] __attribute__((aligned)); /* end-x */ | |
static cob_u8_t b_15[10] __attribute__((aligned)); /* start-y */ | |
static cob_u8_t b_16[10] __attribute__((aligned)); /* end-y */ | |
static cob_u8_t b_17[10] __attribute__((aligned)); /* x */ | |
static cob_u8_t b_18[10] __attribute__((aligned)); /* y */ | |
static cob_u8_t b_19[1] __attribute__((aligned)); /* temp */ | |
static cob_u8_t b_20[10000000] __attribute__((aligned)); /* matrix-table */ | |
static cob_u8_t b_24[10] __attribute__((aligned)); /* brightness */ | |
/* End of local data storage */ | |
/* Fields (local) */ | |
static cob_field f_8 = {100, b_8, &a_1}; /* input-line */ | |
static cob_field f_9 = {10, b_9, &a_1}; /* action */ | |
static cob_field f_10 = {100, b_10, &a_1}; /* coords */ | |
static cob_field f_11 = {100, b_11, &a_1}; /* start-coords */ | |
static cob_field f_12 = {100, b_12, &a_1}; /* end-coords */ | |
static cob_field f_13 = {10, b_13, &a_2}; /* start-x */ | |
static cob_field f_14 = {10, b_14, &a_2}; /* end-x */ | |
static cob_field f_15 = {10, b_15, &a_2}; /* start-y */ | |
static cob_field f_16 = {10, b_16, &a_2}; /* end-y */ | |
static cob_field f_17 = {10, b_17, &a_2}; /* x */ | |
static cob_field f_18 = {10, b_18, &a_2}; /* y */ | |
static cob_field f_24 = {10, b_24, &a_2}; /* brightness */ | |
/* End of fields */ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
identification division. | |
program-id. day06. | |
data division. | |
working-storage section. | |
01 input-line pic x(100). | |
01 action pic x(10). | |
01 coords pic x(100). | |
01 start-coords pic x(100). | |
01 end-coords pic x(100). | |
01 start-x pic 9(10). | |
01 end-x pic 9(10). | |
01 start-y pic 9(10). | |
01 end-y pic 9(10). | |
01 x pic 9(10). | |
01 y pic 9(10). | |
01 temp pic 9. | |
01 matrix-table. | |
05 occurs 1000 times. | |
10 occurs 1000 times. | |
15 matrix pic 9(10) value 0. | |
01 brightness pic 9(10). | |
procedure division. | |
accept input-line. | |
perform input-loop-para until input-line = SPACE. | |
move 1 to y. | |
perform count-outer-para until y > 1000. | |
display brightness. | |
stop run. | |
input-loop-para. | |
* display input-line. | |
if input-line(1:7) = "turn on" then | |
move "turn on" to action | |
move input-line(9:) to coords | |
else if input-line(1:8) = "turn off" then | |
move "turn off" to action | |
move input-line(10:) to coords | |
else if input-line(1:7) = "toggle" then | |
move "toggle" to action | |
move input-line(8:) to coords | |
end-if. | |
unstring coords delimited by " through " | |
into start-coords, end-coords. | |
unstring start-coords delimited by "," into start-x, start-y | |
unstring end-coords delimited by "," into end-x, end-y | |
move start-y to y. | |
perform outer-loop-para until y > end-y. | |
accept input-line. | |
outer-loop-para. | |
move start-x to x. | |
perform inner-loop-para until x > end-x. | |
add 1 to y. | |
inner-loop-para. | |
if action = "turn on" then | |
add 1 to matrix(y + 1, x + 1) | |
else if action = "turn off" and matrix(y + 1, x + 1) > 0 then | |
subtract 1 from matrix(y + 1, x + 1) | |
else if action = "toggle" then | |
add 2 to matrix(y + 1, x + 1) | |
end-if. | |
add 1 to x. | |
count-outer-para. | |
move 1 to x. | |
perform count-inner-para until x > 1000. | |
add 1 to y. | |
count-inner-para. | |
add matrix(y, x) to brightness. | |
add 1 to x. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment