#pragma once

#include "xm.h"

namespace interpreter {

constexpr int max_channels = 64;

struct channel_state {
  uint8_t instrument;
  uint8_t keyon;
};

struct interpreter_state {
  int interrupt_clock;
  int tick_rate;
  int ticks_per_line;
  int tick;
  int pattern_order_table_index;
  int pattern_break;
  int pattern_index;
  int line_index;
  int next_line_index; // within the current pattern
  bool paused;
  bool tmp_paused;

  struct xm_state xm;

  struct channel_state channel[max_channels];
};

extern struct interpreter_state state;
void interrupt();
void init(float clock_multiplier);
void pause();
void unpause();

}
