2002-07-27 13:08:48 +00:00
|
|
|
/*
|
2021-01-14 18:29:34 +00:00
|
|
|
* Copyright (C) 2002-2021 The DOSBox Team
|
2002-07-27 13:08:48 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2004-08-04 09:12:57 +00:00
|
|
|
* GNU General Public License for more details.
|
2002-07-27 13:08:48 +00:00
|
|
|
*
|
2019-01-25 14:09:58 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-07-27 13:08:48 +00:00
|
|
|
*/
|
|
|
|
|
2004-12-28 16:13:26 +00:00
|
|
|
|
2005-03-24 20:59:04 +00:00
|
|
|
#ifndef DOSBOX_CALLBACK_H
|
|
|
|
#define DOSBOX_CALLBACK_H
|
2002-07-27 13:08:48 +00:00
|
|
|
|
2005-03-24 20:59:04 +00:00
|
|
|
#ifndef DOSBOX_MEM_H
|
|
|
|
#include "mem.h"
|
|
|
|
#endif
|
2002-07-27 13:08:48 +00:00
|
|
|
|
|
|
|
typedef Bitu (*CallBack_Handler)(void);
|
|
|
|
extern CallBack_Handler CallBack_Handlers[];
|
|
|
|
|
2021-09-02 08:13:48 -07:00
|
|
|
enum {
|
|
|
|
CB_RETN,
|
|
|
|
CB_RETF,
|
|
|
|
CB_RETF8,
|
|
|
|
CB_RETF_STI,
|
|
|
|
CB_RETF_CLI,
|
|
|
|
CB_IRET,
|
|
|
|
CB_IRETD,
|
|
|
|
CB_IRET_STI,
|
|
|
|
CB_IRET_EOI_PIC1,
|
|
|
|
CB_IRQ0,
|
|
|
|
CB_IRQ1,
|
|
|
|
CB_IRQ9,
|
|
|
|
CB_IRQ12,
|
|
|
|
CB_IRQ12_RET,
|
|
|
|
CB_IRQ6_PCJR,
|
|
|
|
CB_MOUSE,
|
|
|
|
CB_INT29,
|
|
|
|
CB_INT16,
|
|
|
|
CB_HOOKABLE,
|
|
|
|
CB_TDE_IRET,
|
|
|
|
CB_IPXESR,
|
|
|
|
CB_IPXESR_RET,
|
|
|
|
CB_INT21,
|
|
|
|
CB_INT13,
|
|
|
|
CB_VESA_WAIT,
|
|
|
|
CB_VESA_PM
|
|
|
|
};
|
2002-07-27 13:08:48 +00:00
|
|
|
|
2009-06-11 16:05:17 +00:00
|
|
|
#define CB_MAX 128
|
|
|
|
#define CB_SIZE 32
|
|
|
|
#define CB_SEG 0xF000
|
|
|
|
#define CB_SOFFSET 0x1000
|
2002-07-27 13:08:48 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
CBRET_NONE=0,CBRET_STOP=1
|
|
|
|
};
|
|
|
|
|
|
|
|
extern Bit8u lastint;
|
2006-07-24 19:06:55 +00:00
|
|
|
|
2021-10-03 21:37:36 -05:00
|
|
|
static inline RealPt CALLBACK_RealPointer(Bitu callback) {
|
2009-06-11 16:05:17 +00:00
|
|
|
return RealMake(CB_SEG,(Bit16u)(CB_SOFFSET+callback*CB_SIZE));
|
2002-07-27 13:08:48 +00:00
|
|
|
}
|
2021-10-03 21:37:36 -05:00
|
|
|
static inline PhysPt CALLBACK_PhysPointer(Bitu callback) {
|
2009-06-11 16:05:17 +00:00
|
|
|
return PhysMake(CB_SEG,(Bit16u)(CB_SOFFSET+callback*CB_SIZE));
|
2006-07-24 19:06:55 +00:00
|
|
|
}
|
|
|
|
|
2021-10-03 21:37:36 -05:00
|
|
|
static inline PhysPt CALLBACK_GetBase(void) {
|
2009-06-11 16:05:17 +00:00
|
|
|
return (CB_SEG << 4) + CB_SOFFSET;
|
2006-04-22 15:25:45 +00:00
|
|
|
}
|
2002-07-27 13:08:48 +00:00
|
|
|
|
|
|
|
Bitu CALLBACK_Allocate();
|
|
|
|
|
|
|
|
void CALLBACK_Idle(void);
|
|
|
|
|
|
|
|
|
|
|
|
void CALLBACK_RunRealInt(Bit8u intnum);
|
|
|
|
void CALLBACK_RunRealFar(Bit16u seg,Bit16u off);
|
|
|
|
|
2006-07-24 19:06:55 +00:00
|
|
|
bool CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,const char* descr);
|
2006-04-22 15:25:45 +00:00
|
|
|
Bitu CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,PhysPt addr,const char* descr);
|
2002-07-27 13:08:48 +00:00
|
|
|
|
2003-11-09 16:44:27 +00:00
|
|
|
const char* CALLBACK_GetDescription(Bitu callback);
|
2002-07-27 13:08:48 +00:00
|
|
|
bool CALLBACK_Free(Bitu callback);
|
|
|
|
|
|
|
|
void CALLBACK_SCF(bool val);
|
|
|
|
void CALLBACK_SZF(bool val);
|
2009-08-23 17:24:54 +00:00
|
|
|
void CALLBACK_SIF(bool val);
|
2004-12-28 16:13:26 +00:00
|
|
|
|
|
|
|
extern Bitu call_priv_io;
|
|
|
|
|
2020-07-11 11:10:54 +02:00
|
|
|
class CALLBACK_HandlerObject {
|
2005-03-24 20:59:04 +00:00
|
|
|
private:
|
|
|
|
bool installed;
|
2009-06-11 16:05:17 +00:00
|
|
|
Bitu m_callback;
|
2020-07-11 11:10:54 +02:00
|
|
|
enum { NONE, SETUP, SETUPAT } m_type;
|
|
|
|
struct {
|
2005-03-24 20:59:04 +00:00
|
|
|
RealPt old_vector;
|
2020-07-11 11:10:54 +02:00
|
|
|
uint8_t interrupt;
|
2005-03-24 20:59:04 +00:00
|
|
|
bool installed;
|
|
|
|
} vectorhandler;
|
2020-07-11 11:10:54 +02:00
|
|
|
|
2005-03-24 20:59:04 +00:00
|
|
|
public:
|
2020-07-11 11:10:54 +02:00
|
|
|
CALLBACK_HandlerObject()
|
|
|
|
: installed(false),
|
|
|
|
m_callback(0),
|
|
|
|
m_type(NONE),
|
|
|
|
vectorhandler{0, 0, false}
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual ~CALLBACK_HandlerObject();
|
2009-06-11 16:05:17 +00:00
|
|
|
|
2005-07-30 09:49:29 +00:00
|
|
|
//Install and allocate a callback.
|
2006-04-22 15:25:45 +00:00
|
|
|
void Install(CallBack_Handler handler,Bitu type,const char* description);
|
|
|
|
void Install(CallBack_Handler handler,Bitu type,PhysPt addr,const char* description);
|
2009-06-11 16:05:17 +00:00
|
|
|
|
2011-06-17 14:28:00 +00:00
|
|
|
void Uninstall();
|
|
|
|
|
2005-07-30 09:49:29 +00:00
|
|
|
//Only allocate a callback number
|
|
|
|
void Allocate(CallBack_Handler handler,const char* description=0);
|
2009-06-11 16:05:17 +00:00
|
|
|
Bit16u Get_callback() {
|
|
|
|
return (Bit16u)m_callback;
|
|
|
|
}
|
|
|
|
RealPt Get_RealPointer() {
|
|
|
|
return CALLBACK_RealPointer(m_callback);
|
|
|
|
}
|
2005-03-24 20:59:04 +00:00
|
|
|
void Set_RealVec(Bit8u vec);
|
|
|
|
};
|
|
|
|
#endif
|