| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#ifndef DOSBOX_CALLBACK_H |
| 22 |
#define DOSBOX_CALLBACK_H |
| 23 |
|
| 24 |
#ifndef DOSBOX_MEM_H |
| 25 |
#include "mem.h" |
| 26 |
#endif |
| 27 |
|
| 28 |
typedef Bitu (*CallBack_Handler)(void); |
| 29 |
extern CallBack_Handler CallBack_Handlers[]; |
| 30 |
|
| 31 |
enum { CB_RETN,CB_RETF,CB_RETF8,CB_IRET,CB_IRETD,CB_IRET_STI,CB_IRET_EOI_PIC1, |
| 32 |
CB_IRQ0,CB_IRQ1,CB_IRQ9,CB_IRQ12,CB_IRQ12_RET,CB_IRQ6_PCJR,CB_MOUSE, |
| 33 |
CB_INT29,CB_INT16,CB_HOOKABLE,CB_TDE_IRET,CB_IPXESR,CB_IPXESR_RET, |
| 34 |
CB_INT21 }; |
| 35 |
|
| 36 |
#define CB_MAX 128 |
| 37 |
#define CB_SIZE 32 |
| 38 |
#define CB_SEG 0xF000 |
| 39 |
#define CB_SOFFSET 0x1000 |
| 40 |
|
| 41 |
enum { |
| 42 |
CBRET_NONE=0,CBRET_STOP=1 |
| 43 |
}; |
| 44 |
|
| 45 |
extern Bit8u lastint; |
| 46 |
|
| 47 |
static INLINE RealPt CALLBACK_RealPointer(Bitu callback) { |
| 48 |
return RealMake(CB_SEG,(Bit16u)(CB_SOFFSET+callback*CB_SIZE)); |
| 49 |
} |
| 50 |
static INLINE PhysPt CALLBACK_PhysPointer(Bitu callback) { |
| 51 |
return PhysMake(CB_SEG,(Bit16u)(CB_SOFFSET+callback*CB_SIZE)); |
| 52 |
} |
| 53 |
|
| 54 |
static INLINE PhysPt CALLBACK_GetBase(void) { |
| 55 |
return (CB_SEG << 4) + CB_SOFFSET; |
| 56 |
} |
| 57 |
|
| 58 |
Bitu CALLBACK_Allocate(); |
| 59 |
|
| 60 |
void CALLBACK_Idle(void); |
| 61 |
|
| 62 |
|
| 63 |
void CALLBACK_RunRealInt(Bit8u intnum); |
| 64 |
void CALLBACK_RunRealFar(Bit16u seg,Bit16u off); |
| 65 |
|
| 66 |
bool CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,const char* descr); |
| 67 |
Bitu CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,PhysPt addr,const char* descr); |
| 68 |
|
| 69 |
const char* CALLBACK_GetDescription(Bitu callback); |
| 70 |
bool CALLBACK_Free(Bitu callback); |
| 71 |
|
| 72 |
void CALLBACK_SCF(bool val); |
| 73 |
void CALLBACK_SZF(bool val); |
| 74 |
void CALLBACK_SIF(bool val); |
| 75 |
|
| 76 |
extern Bitu call_priv_io; |
| 77 |
|
| 78 |
|
| 79 |
class CALLBACK_HandlerObject{ |
| 80 |
private: |
| 81 |
bool installed; |
| 82 |
Bitu m_callback; |
| 83 |
enum {NONE,SETUP,SETUPAT} m_type; |
| 84 |
struct { |
| 85 |
RealPt old_vector; |
| 86 |
Bit8u interrupt; |
| 87 |
bool installed; |
| 88 |
} vectorhandler; |
| 89 |
public: |
| 90 |
CALLBACK_HandlerObject():installed(false),m_type(NONE) { |
| 91 |
vectorhandler.installed=false; |
| 92 |
} |
| 93 |
~CALLBACK_HandlerObject(); |
| 94 |
|
| 95 |
|
| 96 |
void Install(CallBack_Handler handler,Bitu type,const char* description); |
| 97 |
void Install(CallBack_Handler handler,Bitu type,PhysPt addr,const char* description); |
| 98 |
|
| 99 |
|
| 100 |
void Allocate(CallBack_Handler handler,const char* description=0); |
| 101 |
Bit16u Get_callback() { |
| 102 |
return (Bit16u)m_callback; |
| 103 |
} |
| 104 |
RealPt Get_RealPointer() { |
| 105 |
return CALLBACK_RealPointer(m_callback); |
| 106 |
} |
| 107 |
void Set_RealVec(Bit8u vec); |
| 108 |
}; |
| 109 |
#endif |