| 1 | #ifndef __PCEFAST_PCECD_Drive_H |
| 2 | #define __PCEFAST_PCECD_Drive_H |
| 3 | |
| 4 | #include "../include/blip/Blip_Buffer.h" |
| 5 | |
| 6 | typedef int32 pcecd_drive_timestamp_t; |
| 7 | |
| 8 | struct pcecd_drive_bus_t |
| 9 | { |
| 10 | // Data bus(FIXME: we should have a variable for the target and the initiator, and OR them together to be truly accurate). |
| 11 | uint8 DB; |
| 12 | |
| 13 | uint32 signals; |
| 14 | }; |
| 15 | |
| 16 | extern pcecd_drive_bus_t cd_bus; // Don't access this structure directly by name outside of pcecd_drive.c, but use the macros below. |
| 17 | |
| 18 | // Signals under our(the "target") control. |
| 19 | #define PCECD_Drive_IO_mask 0x001 |
| 20 | #define PCECD_Drive_CD_mask 0x002 |
| 21 | #define PCECD_Drive_MSG_mask 0x004 |
| 22 | #define PCECD_Drive_REQ_mask 0x008 |
| 23 | #define PCECD_Drive_BSY_mask 0x010 |
| 24 | |
| 25 | // Signals under the control of the initiator(not us!) |
| 26 | #define PCECD_Drive_kingRST_mask 0x020 |
| 27 | #define PCECD_Drive_kingACK_mask 0x040 |
| 28 | #define PCECD_Drive_kingSEL_mask 0x100 |
| 29 | |
| 30 | #define BSY_signal ((const bool)(cd_bus.signals & PCECD_Drive_BSY_mask)) |
| 31 | #define ACK_signal ((const bool)(cd_bus.signals & PCECD_Drive_kingACK_mask)) |
| 32 | #define RST_signal ((const bool)(cd_bus.signals & PCECD_Drive_kingRST_mask)) |
| 33 | #define MSG_signal ((const bool)(cd_bus.signals & PCECD_Drive_MSG_mask)) |
| 34 | #define SEL_signal ((const bool)(cd_bus.signals & PCECD_Drive_kingSEL_mask)) |
| 35 | #define REQ_signal ((const bool)(cd_bus.signals & PCECD_Drive_REQ_mask)) |
| 36 | #define IO_signal ((const bool)(cd_bus.signals & PCECD_Drive_IO_mask)) |
| 37 | #define CD_signal ((const bool)(cd_bus.signals & PCECD_Drive_CD_mask)) |
| 38 | |
| 39 | #define DB_signal ((const uint8)cd_bus.DB) |
| 40 | |
| 41 | #define PCECD_Drive_GetDB() DB_signal |
| 42 | #define PCECD_Drive_GetBSY() BSY_signal |
| 43 | #define PCECD_Drive_GetIO() IO_signal |
| 44 | #define PCECD_Drive_GetCD() CD_signal |
| 45 | #define PCECD_Drive_GetMSG() MSG_signal |
| 46 | #define PCECD_Drive_GetREQ() REQ_signal |
| 47 | |
| 48 | // Should we phase out getting these initiator-driven signals like this(the initiator really should keep track of them itself)? |
| 49 | #define PCECD_Drive_GetACK() ACK_signal |
| 50 | #define PCECD_Drive_GetRST() RST_signal |
| 51 | #define PCECD_Drive_GetSEL() SEL_signal |
| 52 | |
| 53 | void PCECD_Drive_Power(pcecd_drive_timestamp_t system_timestamp); |
| 54 | void PCECD_Drive_SetDB(uint8 data); |
| 55 | |
| 56 | // These PCECD_Drive_Set* functions are kind of misnomers, at least in comparison to the PCECD_Drive_Get* functions... |
| 57 | // They will set/clear the bits corresponding to the KING's side of the bus. |
| 58 | void PCECD_Drive_SetACK(bool set); |
| 59 | void PCECD_Drive_SetSEL(bool set); |
| 60 | void PCECD_Drive_SetRST(bool set); |
| 61 | |
| 62 | uint32 PCECD_Drive_Run(pcecd_drive_timestamp_t); |
| 63 | void PCECD_Drive_ResetTS(void); |
| 64 | |
| 65 | enum |
| 66 | { |
| 67 | PCECD_Drive_IRQ_DATA_TRANSFER_DONE = 1, |
| 68 | PCECD_Drive_IRQ_DATA_TRANSFER_READY, |
| 69 | PCECD_Drive_IRQ_MAGICAL_REQ, |
| 70 | }; |
| 71 | |
| 72 | void PCECD_Drive_GetCDDAValues(int16 &left, int16 &right); |
| 73 | |
| 74 | void PCECD_Drive_SetLog(void (*logfunc)(const char *, const char *, ...)) MDFN_COLD; |
| 75 | void PCECD_Drive_Init(int CDDATimeDiv, Blip_Buffer *leftbuf, Blip_Buffer *rightbuf, uint32 TransferRate, uint32 SystemClock, void (*IRQFunc)(int), void (*SSCFunc)(uint8, int)) MDFN_COLD; |
| 76 | void PCECD_Drive_Close(void) MDFN_COLD; |
| 77 | |
| 78 | void PCECD_Drive_SetTransferRate(uint32 TransferRate); |
| 79 | void PCECD_Drive_SetCDDAVolume(unsigned vol); // vol of 65536 = 1.0 = maximum. |
| 80 | int PCECD_Drive_StateAction(StateMem *sm, int load, int data_only, const char *sname); |
| 81 | |
| 82 | void PCECD_Drive_SetDisc(bool tray_open, CDIF *cdif, bool no_emu_side_effects = false) MDFN_COLD; |
| 83 | |
| 84 | #endif |