/* * cmdport.c -- command port i/o routine * * Copyright (C) 1997 by Sony Computer Entertainment * All rights Reserved */ #include #include #include "cbuffer.h" #include "getioadr.h" #include "misc.h" #include "cmdport.h" #include "rs.h" extern void check_exit(); unsigned char oldcomsts; static int cmdportfree; static cbuffer outcbuf; int cmdport_init(long baud) { long bps; bps = baud; rs_open( &bps, psxbase, irqvect, irqmask); clean_cbuffer(outcbuf); return OK; } void cmdport_term() { rs_close(); } int scan_cmd_port() { unsigned char outch; static time_t starttime = 0; if( !is_empty_cbuffer(outcbuf) ) { get_cbuffer(outcbuf,outch); rs_putch(outch); } return 0; } int get_cmd_port() { unsigned char inch; DWORD bytesRead; ReadFile(hFile, (LPVOID)&inch, 1, &bytesRead, NULL); return inch; } void put_cmd_port(int ch) { if( !is_full_cbuffer(outcbuf) ) { put_cbuffer(outcbuf, ch); } }