////////////////////////////////////////////////////////////////////// // // // nexus.pas: The Nexus for the Mappy VM core // // Contains additional interface code between the MVM user // // interface and the MVM core, such as log writing, the core // // options system, and audio/video callbacks. // // // // The contents of this file are subject to the Bottled Light // // Public License Version 1.0 (the "License"); you may not use this // // file except in compliance with the License. You may obtain a // // copy of the License at http://www.bottledlight.com/BLPL/ // // // // Software distributed under the License is distributed on an // // "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or // // implied. See the License for the specific language governing // // rights and limitations under the License. // // // // The Original Code is the Mappy VM Core, released April 1st, 2003 // // The Initial Developer of the Original Code is Bottled Light, // // Inc. Portions created by Bottled Light, Inc. are Copyright // // (C) 2001 - 2003 Bottled Light, Inc. All Rights Reserved. // // // // Author(s): // // Michael Noland (joat), michael@bottledlight.com // // // // Changelog: // // 1.0: First public release (April 1st, 2003) // // // // Notes: // // None at present. // // // ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// unit nexus; ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// interface //////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// uses SysUtils, Classes, AddressSpace; ////////////////////////////////////////////////////////////////////// procedure OnSoundReady(data: pointer; length: integer); procedure OnVideoReady(y: integer; sline: Puint16); procedure logWrite(st: string); procedure logWriteLn(st: string); procedure addOption(st: string; option: Pboolean; default: boolean); ////////////////////////////////////////////////////////////////////// var options: TStringList; cbSoundReady: TvmOnSoundReady; cbVideoReady: TvmOnVideoReady; cbConsoleReady: TvmOnConsoleReady; logDMATransfers: boolean; logSoftwareInterrupts: boolean; logIORegisters: boolean; logInvalidStates: boolean; ////////////////////////////////////////////////////////////////////// // Exported Functions //////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// procedure vmSetOnSound(callback: TvmOnSoundReady); procedure vmSetOnVideo(callback: TvmOnVideoReady); procedure vmSetOnConsole(callback: TvmOnConsoleReady); function vmGetOption(st: PChar): boolean; procedure vmSetOption(st: PChar; enabled: boolean); ////////////////////////////////////////////////////////////////////// exports vmSetOnSound, vmSetOnVideo, vmSetOnConsole, vmGetOption, vmSetOption; ////////////////////////////////////////////////////////////////////// implementation /////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// procedure logWrite(st: string); begin if Assigned(cbConsoleReady) then cbConsoleReady(PChar(st)); end; ////////////////////////////////////////////////////////////////////// procedure logWriteLn(st: string); begin logWrite(st + #10); end; ////////////////////////////////////////////////////////////////////// procedure addOption(st: string; option: Pboolean; default: boolean); begin option^ := default; options.AddObject(Uppercase(st), TObject(option)); end; ////////////////////////////////////////////////////////////////////// function vmGetOption(st: PChar): boolean; var i: integer; begin i := options.IndexOf(Uppercase(st)); if i > -1 then Result := Pboolean(options.Objects[i])^ else Result := false; end; ////////////////////////////////////////////////////////////////////// procedure vmSetOption(st: PChar; enabled: boolean); var i: integer; begin i := options.IndexOf(Uppercase(st)); if i > -1 then Pboolean(options.Objects[i])^ := enabled; end; ////////////////////////////////////////////////////////////////////// procedure OnSoundReady(data: pointer; length: integer); begin if Assigned(cbSoundReady) then cbSoundReady(data, length); end; ////////////////////////////////////////////////////////////////////// procedure OnVideoReady(y: integer; sline: Puint16); begin if Assigned(cbVideoReady) then cbVideoReady(y, sline); end; ////////////////////////////////////////////////////////////////////// procedure vmSetOnSound(callback: TvmOnSoundReady); begin cbSoundReady := callback; end; ////////////////////////////////////////////////////////////////////// procedure vmSetOnVideo(callback: TvmOnVideoReady); begin cbVideoReady := callback; end; ////////////////////////////////////////////////////////////////////// procedure vmSetOnConsole(callback: TvmOnConsoleReady); begin cbConsoleReady := callback; end; ////////////////////////////////////////////////////////////////////// end. //////////////////////////////////////////////////////////////////////