dosbox-wii/include/callback.h

99 lines
2.8 KiB
C
Raw Normal View History

2009-05-02 23:03:37 +02:00
/*
2009-05-03 00:28:34 +02:00
* Copyright (C) 2002-2007 The DOSBox Team
2009-05-02 23:03:37 +02: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
2009-05-03 00:02:15 +02:00
* GNU General Public License for more details.
2009-05-02 23:03:37 +02: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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
2009-05-03 00:28:34 +02:00
/* $Id: callback.h,v 1.19 2007/01/08 19:45:37 qbix79 Exp $ */
2009-05-02 23:03:37 +02:00
2009-05-03 00:18:08 +02:00
#ifndef DOSBOX_CALLBACK_H
#define DOSBOX_CALLBACK_H
#ifndef DOSBOX_MEM_H
#include "mem.h"
#endif
2009-05-02 23:03:37 +02:00
typedef Bitu (*CallBack_Handler)(void);
extern CallBack_Handler CallBack_Handlers[];
2009-05-03 00:28:34 +02:00
enum { CB_RETN,CB_RETF,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_INT29,CB_INT16,CB_HOOKABLE,CB_TDE_IRET,CB_IPXESR,CB_IPXESR_RET };
2009-05-02 23:03:37 +02:00
2009-05-03 00:28:34 +02:00
#define CB_MAX 128
#define CB_SIZE 32
#define CB_SEG 0xF100
2009-05-02 23:03:37 +02:00
enum {
CBRET_NONE=0,CBRET_STOP=1
};
extern Bit8u lastint;
2009-05-03 00:28:34 +02:00
2009-05-02 23:03:37 +02:00
INLINE RealPt CALLBACK_RealPointer(Bitu callback) {
2009-05-03 00:28:34 +02:00
return RealMake(CB_SEG,callback*CB_SIZE);
}
INLINE PhysPt CALLBACK_PhysPointer(Bitu callback) {
return PhysMake(CB_SEG,callback*CB_SIZE);
}
INLINE PhysPt CALLBACK_GetBase(void) {
return CB_SEG << 4;
2009-05-02 23:03:37 +02:00
}
Bitu CALLBACK_Allocate();
void CALLBACK_Idle(void);
void CALLBACK_RunRealInt(Bit8u intnum);
void CALLBACK_RunRealFar(Bit16u seg,Bit16u off);
2009-05-03 00:28:34 +02:00
bool CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,const char* descr);
Bitu CALLBACK_Setup(Bitu callback,CallBack_Handler handler,Bitu type,PhysPt addr,const char* descr);
2009-05-02 23:03:37 +02:00
2009-05-02 23:53:27 +02:00
const char* CALLBACK_GetDescription(Bitu callback);
2009-05-02 23:03:37 +02:00
bool CALLBACK_Free(Bitu callback);
void CALLBACK_SCF(bool val);
void CALLBACK_SZF(bool val);
2009-05-03 00:18:08 +02:00
extern Bitu call_priv_io;
class CALLBACK_HandlerObject{
private:
bool installed;
Bit16u m_callback;
enum {NONE,SETUP,SETUPAT} m_type;
struct {
RealPt old_vector;
Bit8u interrupt;
bool installed;
} vectorhandler;
public:
CALLBACK_HandlerObject():installed(false),m_type(NONE){vectorhandler.installed=false;}
~CALLBACK_HandlerObject();
//Install and allocate a callback.
2009-05-03 00:28:34 +02:00
void Install(CallBack_Handler handler,Bitu type,const char* description);
void Install(CallBack_Handler handler,Bitu type,PhysPt addr,const char* description);
2009-05-03 00:18:08 +02:00
//Only allocate a callback number
void Allocate(CallBack_Handler handler,const char* description=0);
Bit16u Get_callback(){return m_callback;}
2009-05-03 00:28:34 +02:00
RealPt Get_RealPointer(){ return CALLBACK_RealPointer(m_callback);}
2009-05-03 00:18:08 +02:00
void Set_RealVec(Bit8u vec);
};
#endif