| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#ifndef DOSBOX_INOUT_H |
| 22 |
#define DOSBOX_INOUT_H |
| 23 |
|
| 24 |
#define IO_MAX (64*1024+3) |
| 25 |
|
| 26 |
#define IO_MB 0x1 |
| 27 |
#define IO_MW 0x2 |
| 28 |
#define IO_MD 0x4 |
| 29 |
#define IO_MA (IO_MB | IO_MW | IO_MD ) |
| 30 |
|
| 31 |
typedef Bitu IO_ReadHandler(Bitu port,Bitu iolen); |
| 32 |
typedef void IO_WriteHandler(Bitu port,Bitu val,Bitu iolen); |
| 33 |
|
| 34 |
extern IO_WriteHandler * io_writehandlers[3][IO_MAX]; |
| 35 |
extern IO_ReadHandler * io_readhandlers[3][IO_MAX]; |
| 36 |
|
| 37 |
void IO_RegisterReadHandler(Bitu port,IO_ReadHandler * handler,Bitu mask,Bitu range=1); |
| 38 |
void IO_RegisterWriteHandler(Bitu port,IO_WriteHandler * handler,Bitu mask,Bitu range=1); |
| 39 |
|
| 40 |
void IO_FreeReadHandler(Bitu port,Bitu mask,Bitu range=1); |
| 41 |
void IO_FreeWriteHandler(Bitu port,Bitu mask,Bitu range=1); |
| 42 |
|
| 43 |
void IO_WriteB(Bitu port,Bitu val); |
| 44 |
void IO_WriteW(Bitu port,Bitu val); |
| 45 |
void IO_WriteD(Bitu port,Bitu val); |
| 46 |
|
| 47 |
Bitu IO_ReadB(Bitu port); |
| 48 |
Bitu IO_ReadW(Bitu port); |
| 49 |
Bitu IO_ReadD(Bitu port); |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
class IO_Base{ |
| 54 |
protected: |
| 55 |
bool installed; |
| 56 |
Bitu m_port, m_mask,m_range; |
| 57 |
public: |
| 58 |
IO_Base():installed(false){}; |
| 59 |
}; |
| 60 |
class IO_ReadHandleObject: private IO_Base{ |
| 61 |
public: |
| 62 |
void Install(Bitu port,IO_ReadHandler * handler,Bitu mask,Bitu range=1); |
| 63 |
~IO_ReadHandleObject(); |
| 64 |
}; |
| 65 |
class IO_WriteHandleObject: private IO_Base{ |
| 66 |
public: |
| 67 |
void Install(Bitu port,IO_WriteHandler * handler,Bitu mask,Bitu range=1); |
| 68 |
~IO_WriteHandleObject(); |
| 69 |
}; |
| 70 |
|
| 71 |
static INLINE void IO_Write(Bitu port,Bit8u val) { |
| 72 |
IO_WriteB(port,val); |
| 73 |
} |
| 74 |
static INLINE Bit8u IO_Read(Bitu port){ |
| 75 |
return (Bit8u)IO_ReadB(port); |
| 76 |
} |
| 77 |
|
| 78 |
#endif |