/* * Copyright (C) 2002 The DOSBox Team * * 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 * GNU Library General Public License for more details. * * 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. */ #include #include #include "dosbox.h" #include "callback.h" #include "mem.h" #include "cpu.h" /* CallBack are located at 0xC800:0 And they are 16 bytes each and you can define them to behave in certain ways like a far return or and IRET */ CallBack_Handler CallBack_Handlers[CB_MAX]; static Bitu call_stop,call_idle,call_default; static Bitu illegal_handler(void) { E_Exit("Illegal CallBack Called"); return 1; } Bitu CALLBACK_Allocate(void) { for (Bitu i=0;(i=CB_MAX) return false; switch (type) { case CB_RETF: real_writeb((Bit16u)CB_SEG,(callback<<4),(Bit8u)0xFE); //GRP 4 real_writeb((Bit16u)CB_SEG,(callback<<4)+1,(Bit8u)0x38); //Extra Callback instruction real_writew((Bit16u)CB_SEG,(callback<<4)+2,callback); //The immediate word real_writeb((Bit16u)CB_SEG,(callback<<4)+4,(Bit8u)0xCB); //A RETF Instruction break; case CB_IRET: real_writeb((Bit16u)CB_SEG,(callback<<4),(Bit8u)0xFE); //GRP 4 real_writeb((Bit16u)CB_SEG,(callback<<4)+1,(Bit8u)0x38); //Extra Callback instruction real_writew((Bit16u)CB_SEG,(callback<<4)+2,callback); //The immediate word real_writeb((Bit16u)CB_SEG,(callback<<4)+4,(Bit8u)0xCF); //An IRET Instruction break; default: E_Exit("CALLBACK:Setup:Illegal type %d",type); } CallBack_Handlers[callback]=handler; return true; } void CALLBACK_Init(void) { Bitu i; for (i=0;i