NESe (pronounced "Nessie") is a NES emulator based on the e6502 emulator, also written in C with a focus on speed and portability for use on embedded platforms, especially ARM.
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.

70 lines
1.3KB

  1. #ifndef F6502_H_
  2. #define F6502_H_
  3. #include "serdes.h"
  4. #include <stdbool.h>
  5. #include <stdint.h>
  6. #include "memory.h"
  7. typedef enum {
  8. f6502_Status_C = 0b00000001,
  9. f6502_Status_Z = 0b00000010,
  10. f6502_Status_I = 0b00000100,
  11. f6502_Status_D = 0b00001000,
  12. f6502_Status_B = 0b00010000,
  13. f6502_Status_1 = 0b00100000,
  14. f6502_Status_V = 0b01000000,
  15. f6502_Status_N = 0b10000000,
  16. } f6502_Status_Flag;
  17. #define f6502_Base_Stack (0x0100U)
  18. #define f6502_Vector_IRQ (0xFFFEU)
  19. #define f6502_Vector_Reset (0xFFFCU)
  20. #define f6502_Vector_NMI (0xFFFAU)
  21. typedef struct __attribute__ ((__packed__)) {
  22. uint16_t PC;
  23. uint8_t S;
  24. uint8_t A;
  25. uint8_t X;
  26. uint8_t Y;
  27. uint8_t P;
  28. } f6502_Registers;
  29. typedef enum {
  30. f6502_Int_NMI = 0b00000001,
  31. f6502_Int_IRQ = 0b00000010,
  32. f6502_Int_NMI_Serviced = 0b10000000,
  33. } f6502_Interrupt;
  34. struct f6502_Core {
  35. // Static
  36. f6502_Registers registers;
  37. f6502_Interrupt interrupts;
  38. // Specific
  39. nes_Memory memory;
  40. // Don't care
  41. uint64_t clocks;
  42. };
  43. typedef struct f6502_Core f6502_Core;
  44. void f6502_init(f6502_Core*);
  45. void f6502_reset(f6502_Core*);
  46. int f6502_step(f6502_Core*, int clocks);
  47. void f6502_set_NMI(f6502_Core*, bool active);
  48. void f6502_set_IRQ(f6502_Core*, bool active);
  49. extern const Serdes_Item f6502_serdes[];
  50. #endif // F6502_H_