/* * Copyright (C) 2002-2004 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 "dosbox.h" #include "inout.h" #define IO_MAX 1024 static struct IO_Block { IO_WriteBHandler * write_b[IO_MAX]; IO_WriteWHandler * write_w[IO_MAX]; IO_WriteDHandler * write_d[IO_MAX]; IO_ReadBHandler * read_b[IO_MAX]; IO_ReadWHandler * read_w[IO_MAX]; IO_ReadDHandler * read_d[IO_MAX]; } io; void IO_WriteB(Bitu port,Bit8u val) { if (port(val),port); io.write_b[port]=IO_WriteBBlocked; } void IO_WriteDefaultW(Bit32u port,Bit16u val) { io.write_b[port](port,(Bit8u)val); io.write_b[port+1](port+1,(Bit8u)(val>>8)); } void IO_WriteDefaultD(Bit32u port,Bit32u val) { io.write_b[port](port,(Bit8u)val); io.write_b[port+1](port+1,(Bit8u)(val>>8)); io.write_b[port+2](port+2,(Bit8u)(val>>16)); io.write_b[port+3](port+3,(Bit8u)(val>>24)); } void IO_RegisterReadBHandler(Bitu port,IO_ReadBHandler * handler) { if (port>=IO_MAX) return; io.read_b[port]=handler; } void IO_RegisterReadWHandler(Bitu port,IO_ReadWHandler * handler) { if (port>=IO_MAX) return; io.read_w[port]=handler; } void IO_RegisterReadDHandler(Bitu port,IO_ReadDHandler * handler) { if (port>=IO_MAX) return; io.read_d[port]=handler; } void IO_RegisterWriteBHandler(Bitu port,IO_WriteBHandler * handler) { if (port>=IO_MAX) return; io.write_b[port]=handler; } void IO_RegisterWriteWHandler(Bitu port,IO_WriteWHandler * handler) { if (port>=IO_MAX) return; io.write_w[port]=handler; } void IO_RegisterWriteDHandler(Bitu port,IO_WriteDHandler * handler) { if (port>=IO_MAX) return; io.write_d[port]=handler; } void IO_FreeReadHandler(Bitu port) { if (port>=IO_MAX) return; io.read_b[port]=IO_ReadDefaultB; io.read_w[port]=IO_ReadDefaultW; io.read_d[port]=IO_ReadDefaultD; } void IO_FreeWriteHandler(Bitu port) { if (port>=IO_MAX) return; io.write_b[port]=IO_WriteDefaultB; io.write_w[port]=IO_WriteDefaultW; io.write_d[port]=IO_WriteDefaultD; } void IO_Init(Section * sect) { for (Bitu i=0;i