Human68k CUI emulator with sound.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

okim6258.h 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include <stdint.h>
  3. struct okim6258 {
  4. uint8_t status;
  5. uint32_t master_clock; /* master clock frequency */
  6. uint32_t divider; /* master clock divider */
  7. uint8_t adpcm_type; /* 3/4 bit ADPCM select */
  8. uint8_t data_in; /* ADPCM data-in register */
  9. uint8_t nibble_shift; /* nibble select */
  10. uint8_t output_bits, internal_10_bit;
  11. int32_t output_mask;
  12. // Valley Bell: Added a small queue to prevent race conditions.
  13. uint8_t data_buf[8];
  14. uint8_t data_in_last;
  15. uint8_t data_buf_pos;
  16. // Data Empty Values:
  17. // 00 - data written, but not read yet
  18. // 01 - read data, waiting for next write
  19. // 02 - tried to read, but had no data
  20. uint8_t data_empty;
  21. // Valley Bell: Added pan
  22. uint8_t pan;
  23. int32_t last_smpl;
  24. int32_t signal;
  25. int32_t step;
  26. uint8_t clock_buffer[0x04];
  27. uint32_t initial_clock;
  28. uint8_t initial_div;
  29. };
  30. #define FOSC_DIV_BY_1024 0
  31. #define FOSC_DIV_BY_768 1
  32. #define FOSC_DIV_BY_512 2
  33. #define TYPE_3BITS 0
  34. #define TYPE_4BITS 1
  35. #define OUTPUT_10BITS 0
  36. #define OUTPUT_12BITS 1
  37. int okim6258_init(struct okim6258 *chip, int clock, int divider, int adpcm_type, int output_12bits);
  38. void okim6258_stop(struct okim6258 *chip);
  39. void okim6258_reset(struct okim6258 *chip);
  40. void okim6258_set_divider(struct okim6258 *chip, int val);
  41. void okim6258_set_clock(struct okim6258 *chip, int val);
  42. int okim6258_get_vclk(struct okim6258 *chip);
  43. void okim6258_update(struct okim6258 *chip, int16_t **outputs, int samples);
  44. void okim6258_write(struct okim6258 *chip, uint8_t Port, uint8_t Data);
  45. void okim6258_set_options(struct okim6258 *chip, uint16_t options);