scpu.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. class sCPU : public CPU {
  2. public:
  3. void enter();
  4. #include "core/core.hpp"
  5. #include "dma/dma.hpp"
  6. #include "memory/memory.hpp"
  7. #include "mmio/mmio.hpp"
  8. #include "timing/timing.hpp"
  9. enum DmaState { DmaInactive, DmaRun, DmaCpuSync };
  10. struct {
  11. //core
  12. uint8 opcode;
  13. bool in_opcode;
  14. bool wai_lock;
  15. bool interrupt_pending;
  16. uint16 interrupt_vector;
  17. unsigned clock_count;
  18. unsigned line_clocks;
  19. //timing
  20. bool irq_lock;
  21. bool alu_lock;
  22. unsigned dram_refresh_position;
  23. bool nmi_valid;
  24. bool nmi_line;
  25. bool nmi_transition;
  26. bool nmi_pending;
  27. bool nmi_hold;
  28. bool irq_valid;
  29. bool irq_line;
  30. bool irq_transition;
  31. bool irq_pending;
  32. bool irq_hold;
  33. //DMA
  34. unsigned dma_counter;
  35. unsigned dma_clocks;
  36. bool dma_pending;
  37. bool hdma_pending;
  38. bool hdma_mode; //0 = init, 1 = run
  39. DmaState dma_state;
  40. //MMIO
  41. //$2181-$2183
  42. uint32 wram_addr;
  43. //$4016-$4017
  44. bool joypad_strobe_latch;
  45. uint32 joypad1_bits;
  46. uint32 joypad2_bits;
  47. //$4200
  48. bool nmi_enabled;
  49. bool hirq_enabled, virq_enabled;
  50. bool auto_joypad_poll;
  51. //$4201
  52. uint8 pio;
  53. //$4202-$4203
  54. uint8 mul_a, mul_b;
  55. //$4204-$4206
  56. uint16 div_a;
  57. uint8 div_b;
  58. //$4207-$420a
  59. uint16 hirq_pos, virq_pos;
  60. //$4214-$4217
  61. uint16 r4214;
  62. uint16 r4216;
  63. //$4218-$421f
  64. uint8 joy1l, joy1h;
  65. uint8 joy2l, joy2h;
  66. uint8 joy3l, joy3h;
  67. uint8 joy4l, joy4h;
  68. } status;
  69. void power();
  70. void reset();
  71. sCPU();
  72. ~sCPU();
  73. };