#include "compiler.h"
#include "i286.h"
#include "memory.h"
#include "pccore.h"
#include "iocore.h"
#include "bios.h"
#include "biosmem.h"
#include "rsbios.h"
void bios0x0c(void) {
UINT16 doff;
UINT16 dseg;
REG8 flag;
BYTE data;
BYTE stat;
REG16 pos;
REG16 cnt;
doff = GETBIOSMEM16(MEMW_RS_CH0_OFST);
dseg = GETBIOSMEM16(MEMW_RS_CH0_SEG);
flag = i286_membyte_read(dseg, doff + R_FLAG);
data = iocore_inp8(0x30); // データ引き取り
stat = iocore_inp8(0x32) & 0xfc; // ステータス
stat |= (iocore_inp8(0x33) & 3);
#if 0
if (stat & 0x38) {
iocore_out8(0x32, flag | 0x10);
}
#endif
if (!(flag & RFLAG_BFULL)) {
// SI/SO変換
if (mem[MEMB_RS_S_FLAG] & 0x80) {
if (data >= 0x20) {
if (mem[MEMB_RS_S_FLAG] & 0x10) {
data |= 0x80;
}
else {
data &= 0x7f;
}
}
else if (data == RSCODE_SO) {
mem[MEMB_RS_S_FLAG] |= 0x10;
iocore_out8(0x00, 0x20);
return;
}
else if (data == RSCODE_SI) {
mem[MEMB_RS_S_FLAG] &= ~0x10;
iocore_out8(0x00, 0x20);
return;
}
}
// DELコードの扱い
if (mem[MEMB_RS_D_FLAG] & 0x01) { // CH0 -> bit0
if (((data & 0x7f) == 0x7f) && (mem[MEMB_MSW3] & 0x80)) {
data = 0;
}
}
// データ投棄
pos = i286_memword_read(dseg, doff + R_PUTP);
i286_memword_write(dseg, pos, (UINT16)((data << 8) | stat));
// 次のポインタをストア
pos = (UINT16)(pos + 2);
if (pos >= i286_memword_read(dseg, doff + R_TAILP)) {
pos = i286_memword_read(dseg, doff + R_HEADP);
}
i286_memword_write(dseg, doff + R_PUTP, pos);
// カウンタのインクリメント
cnt = (UINT16)(i286_memword_read(dseg, doff + R_CNT) + 1);
i286_memword_write(dseg, doff + R_CNT, cnt);
// オーバーフローを見張る
if (pos == i286_memword_read(dseg, doff + R_GETP)) {
flag |= RFLAG_BFULL;
}
// XOFFを送信?
if (((flag & (RFLAG_XON | RFLAG_XOFF)) == RFLAG_XON) &&
(cnt >= i286_memword_read(dseg, doff + R_XON))) {
iocore_out8(0x30, RSCODE_XOFF);
flag |= RFLAG_XOFF;
}
}
else {
i286_membyte_write(dseg, doff + R_CMD,
(REG8)(i286_membyte_read(dseg, doff + R_CMD) | RFLAG_BOVF));
}
i286_membyte_write(dseg, doff + R_INT,
(REG8)(i286_membyte_read(dseg, doff + R_INT) | RINT_INT));
i286_membyte_write(dseg, doff + R_FLAG, flag);
iocore_out8(0x00, 0x20);
}
RetroPC.NET-CVS <cvs@retropc.net>