<commit_before>#include "standard.h"

#include <cstdio>
#include <cassert>
#include <cstring>

JOY_Standard::JOY_Standard(const char* label)
: buttons {{0}}
, label(label)
{}

u8 JOY_Standard::read(u16 addr) {
  (void) addr;

  if (this->curr_btn > 7 || this->strobe)
    return 0x01;

  return this->buttons.step[this->curr_btn++] & 0x01;
}

u8 JOY_Standard::peek(u16 addr) const {
  (void) addr;

  if (this->curr_btn > 7 || this->strobe)
    return 0x01;

  return this->buttons.step[this->curr_btn] & 0x01;
}

void JOY_Standard::write(u16 addr, u8 val) {
  (void) addr;

  this->strobe = val & 0x01;
  this->curr_btn = 0;
}

void JOY_Standard::set_button(const char* btn, bool state) {
  fprintf(stderr,
    "[JOY_Standard][%s] %s : %s\n",
    this->label,
    btn,
    state ? "ON" : "OFF"
  );

  if (!strcmp("A",      btn)) this->buttons.btn.A      = state; return;
  if (!strcmp("B",      btn)) this->buttons.btn.B      = state; return;
  if (!strcmp("Start",  btn)) this->buttons.btn.Start  = state; return;
  if (!strcmp("Select", btn)) this->buttons.btn.Select = state; return;
  if (!strcmp("Up",     btn)) this->buttons.btn.Up     = state; return;
  if (!strcmp("Down",   btn)) this->buttons.btn.Down   = state; return;
  if (!strcmp("Left",   btn)) this->buttons.btn.Left   = state; return;
  if (!strcmp("Right",  btn)) this->buttons.btn.Right  = state; return;

  fprintf(stderr, "[JOY_Standard] Setting invalid button '%s'\n", btn);
  assert(false);
}<commit_msg>fixed a very silly mistake<commit_after>#include "standard.h"

#include <cstdio>
#include <cassert>
#include <cstring>

JOY_Standard::JOY_Standard(const char* label)
: buttons {{0}}
, label(label)
{}

u8 JOY_Standard::read(u16 addr) {
  (void) addr;

  if (this->curr_btn > 7 || this->strobe)
    return 0x01;

  return this->buttons.step[this->curr_btn++] & 0x01;
}

u8 JOY_Standard::peek(u16 addr) const {
  (void) addr;

  if (this->curr_btn > 7 || this->strobe)
    return 0x01;

  return this->buttons.step[this->curr_btn] & 0x01;
}

void JOY_Standard::write(u16 addr, u8 val) {
  (void) addr;

  this->strobe = val & 0x01;
  this->curr_btn = 0;
}

void JOY_Standard::set_button(const char* btn, bool state) {
  fprintf(stderr,
    "[JOY_Standard][%s] %s : %s\n",
    this->label,
    btn,
    state ? "ON" : "OFF"
  );

  if (!strcmp("A",      btn)) { this->buttons.btn.A      = state; return; }
  if (!strcmp("B",      btn)) { this->buttons.btn.B      = state; return; }
  if (!strcmp("Start",  btn)) { this->buttons.btn.Start  = state; return; }
  if (!strcmp("Select", btn)) { this->buttons.btn.Select = state; return; }
  if (!strcmp("Up",     btn)) { this->buttons.btn.Up     = state; return; }
  if (!strcmp("Down",   btn)) { this->buttons.btn.Down   = state; return; }
  if (!strcmp("Left",   btn)) { this->buttons.btn.Left   = state; return; }
  if (!strcmp("Right",  btn)) { this->buttons.btn.Right  = state; return; }

  fprintf(stderr, "[JOY_Standard] Setting invalid button '%s'\n", btn);
  assert(false);
}
{'fraction_non_alphanumeric': 0.1903494176372712, 'fraction_numerical': 0.018635607321131446, 'mean_word_length': 3.6033690658499236, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '912128', 'n_tokens_mistral': 1167, 'n_tokens_neox': 1137, 'n_words': 256}