//Copyright © Hotwright Inc. 2022
#include "ascii_defs_in.h"

// for debugging in software
extern void _user();

#define bool _Bool

bool read_data= 0;
bool write_data = 0;
bool next_data = 0;

bool din0;
bool din1;
bool din2;
bool din3;
bool din4;
bool din5;
bool din6;
bool din7;
bool next_wrap_around;
bool valid;

void main() {
    _user(0); // set input
  // get rid of non-letters in front
  while (!(lower_case | upper_case)) {

  if (valid == 1) {
    read_data = 1, next_data = 1;
    read_data = 0, next_data = 0;
   }
  else read_data = 0, write_data = 0, next_data = 0;
  }
  // do the rest
  while(1) {
  if (valid == 1) {
    _user(1); // set input
    if ((lower_case | upper_case)) {
      write_data = 1, read_data = 1, next_data = 0;
      write_data = 0, read_data = 0;
    }
    else if (next_wrap_around == 0) {
      next_data = 1;
    }
    else {
      read_data = 1;
      read_data = 0;
    }
   }
  else read_data = 0, write_data = 0, next_data = 0;
  }
}

