1
0
Fork 0

add PCJr-compatible keyboard layer;

add support for PCJr cartridges


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2402
This commit is contained in:
Sebastian Strohhäcker 2005-12-04 21:17:29 +00:00
parent 6ede5e436f
commit 90d6d74f99
5 changed files with 91 additions and 46 deletions

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos_programs.cpp,v 1.47 2005-11-28 16:12:30 qbix79 Exp $ */
/* $Id: dos_programs.cpp,v 1.48 2005-12-04 21:17:28 c2woody Exp $ */
#include <stdlib.h>
#include <string.h>
@ -440,49 +440,53 @@ public:
return;
}
WriteOut(MSG_Get("PROGRAM_BOOT_BOOT"), drive);
bootSector bootarea;
imageDiskList[drive-65]->Read_Sector(0,0,1,(Bit8u *)&bootarea);
for(i=0;i<512;i++) real_writeb(0, 0x7c00 + i, bootarea.rawdata[i]);
if ((bootarea.rawdata[0]==0x50) && (bootarea.rawdata[1]==0x43) && (bootarea.rawdata[2]==0x6a) && (bootarea.rawdata[3]==0x72)) {
if (machine!=MCH_PCJR) WriteOut(MSG_Get("PROGRAM_BOOT_CART_WO_PCJR"));
else {
Bit8u rombuf[65536];
fseek(usefile,0x200L, SEEK_SET);
fread(rombuf, 1, rombytesize-0x200, usefile);
fclose(usefile);
/* write cartridge data into ROM */
Bit16u romseg=0xe000;
if ((rombuf[7]==0x42) && (rombuf[8]==0x41) && (rombuf[9]==0x53) && (rombuf[10]==0x49)) {
/* BASIC rom, doesn't work though */
romseg=0xf600;
}
for(i=0;i<rombytesize;i++) phys_writeb((romseg<<4)+i,rombuf[i]);
SegSet16(cs, 0);
reg_ip = 0x7c00;
SegSet16(ds, 0);
SegSet16(ss, 0);//Buckrogers Booter
reg_esp = 0x400;
SegSet16(es, 0);
reg_esi = 0;
reg_ecx = 1;
reg_ebp = 0;
reg_eax = 0;
reg_edx = 0; //Head 0 drive 0
reg_ebx= 0x7c00; //Real code is probably uses bx to load the image
//DEBUG_EnableDebugger();
/* run cartridge setup */
SegSet16(ds,romseg);
SegSet16(es,romseg);
SegSet16(ss,0x8000);
reg_esp=0xfffe;
CALLBACK_RunRealFar(romseg,0x0003);
/* Most likely a PCJr ROM */
/* Write it to E000:0000 */
/* Code inoperable at the moment */
/* boot cartridge (int18) */
SegSet16(cs,mem_readw(0x62));
reg_ip = mem_readw(0x60);
}
} else {
WriteOut(MSG_Get("PROGRAM_BOOT_BOOT"), drive);
for(i=0;i<512;i++) real_writeb(0, 0x7c00 + i, bootarea.rawdata[i]);
/*
Bit8u rombuff[65536];
fseek(tmpfile,512L, SEEK_SET);
rombytesize-=512;
fread(rombuff, 1, rombytesize, tmpfile);
fclose(tmpfile);
for(i=0;i<rombytesize;i++) real_writeb(0xe000,i,rombuff[i]);
SegSet16(cs,0xe000);
SegSet16(ds,0x0060);
SegSet16(es,0x0060);
SegSet16(ss,0x0060);
reg_ip = 0x0;
reg_sp = 0x0;
reg_cx = 0xffff;
DEBUG_EnableDebugger();
*/
SegSet16(cs, 0);
reg_ip = 0x7c00;
SegSet16(ds, 0);
SegSet16(ss, 0);//Buckrogers Booter
reg_esp = 0x400;
SegSet16(es, 0);
reg_esi = 0;
reg_ecx = 1;
reg_ebp = 0;
reg_eax = 0;
reg_edx = 0; //Head 0 drive 0
reg_ebx= 0x7c00; //Real code probably uses bx to load the image
//DEBUG_EnableDebugger();
}
}
};
@ -959,6 +963,7 @@ void DOS_SetupPrograms(void) {
MSG_Add("PROGRAM_BOOT_IMAGE_OPEN","Opening image file: %s\n");
MSG_Add("PROGRAM_BOOT_IMAGE_NOT_OPEN","Cannot open %s");
MSG_Add("PROGRAM_BOOT_BOOT","Booting from drive %c...\n");
MSG_Add("PROGRAM_BOOT_CART_WO_PCJR","PCJr cartridge found, but machine is not PCJr");
MSG_Add("PROGRAM_IMGMOUNT_SPECIFY_DRIVE","Must specify drive letter to mount image at.\n");
MSG_Add("PROGRAM_IMGMOUNT_SPECIFY2","Must specify drive number (0 or 3) to mount image at (0,1=fda,fdb;2,3=hda,hdb).\n");

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: keyboard.cpp,v 1.33 2005-09-18 19:50:03 c2woody Exp $ */
/* $Id: keyboard.cpp,v 1.34 2005-12-04 21:17:29 c2woody Exp $ */
#include "dosbox.h"
#include "keyboard.h"
@ -56,7 +56,8 @@ static struct {
static void KEYBOARD_SetPort60(Bit8u val) {
keyb.p60changed=true;
keyb.p60data=val;
PIC_ActivateIRQ(1);
if (machine==MCH_PCJR) PIC_ActivateIRQ(6);
else PIC_ActivateIRQ(1);
}
static void KEYBOARD_TransferBuffer(Bitu val) {

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: pic.cpp,v 1.31 2005-04-21 21:06:27 qbix79 Exp $ */
/* $Id: pic.cpp,v 1.32 2005-12-04 21:17:29 c2woody Exp $ */
#include <list>
@ -47,6 +47,7 @@ struct PIC_Controller {
bool special;
bool auto_eoi;
bool rotate_on_auto_eoi;
bool single;
bool request_issr;
Bit8u vector_base;
};
@ -79,11 +80,11 @@ static void write_command(Bitu port,Bitu val,Bitu iolen) {
static Bit16u IRQ_priority_table[16] =
{ 0,1,2,8,9,10,11,12,13,14,15,3,4,5,6,7 };
if (GCC_UNLIKELY(val&0x10)) { // ICW1 issued
if (val&0x02) E_Exit("PIC: single mode not handled"); // (would have to skip ICW3)
if (val&0x04) E_Exit("PIC: 4 byte interval not handled");
if (val&0x08) E_Exit("PIC: level triggered mode not handled");
if (val&0xe0) E_Exit("PIC: 8080/8085 mode not handled");
pic->icw_index=1; // next is ICW3
pic->single=val&0x02;
pic->icw_index=1; // next is ICW2
pic->icw_words=2 + (val&0x01); // =3 if ICW4 needed
} else if (GCC_UNLIKELY(val&0x08)) { // OCW3 issued
if (val&0x04) E_Exit("PIC: poll command not handled");
@ -160,6 +161,10 @@ static void write_data(Bitu port,Bitu val,Bitu iolen) {
else PIC_IRQCheck&=~(1 << (i+irq_base));
}
}
if (machine==MCH_PCJR) {
/* irq6 cannot be disabled as it serves as pseudo-NMI */
irqs[6].masked=false;
}
if(irqs[2].masked != old_irq2_mask) {
/* Irq 2 mask has changed recheck second pic */
for(i=8;i<=15;i++) {
@ -178,6 +183,7 @@ static void write_data(Bitu port,Bitu val,Bitu iolen) {
irqs[i+irq_base].vector=(val&0xf8)+i;
};
if(pic->icw_index++ >= pic->icw_words) pic->icw_index=0;
else if(pic->single) pic->icw_index=3; /* skip ICW3 in single mode */
break;
case 2: /* icw 3 */
LOG(LOG_PIC,LOG_NORMAL)("%d:ICW 3 %X",port==0x21 ? 0 : 1,val);
@ -525,6 +531,7 @@ public:
pics[i].rotate_on_auto_eoi=false;
pics[i].request_issr=false;
pics[i].special=false;
pics[i].single=false;
pics[i].icw_index=0;
pics[i].icw_words=0;
}
@ -542,6 +549,10 @@ public:
irqs[1].masked=false; /* Enable Keyboard IRQ */
irqs[2].masked=false; /* Enable second pic */
irqs[8].masked=false; /* Enable RTC IRQ */
if (machine==MCH_PCJR) {
/* Enable IRQ6 (replacement for the NMI for PCJr) */
irqs[6].masked=false;
}
ReadHandler[0].Install(0x20,read_command,IO_MB);
ReadHandler[1].Install(0x21,read_data,IO_MB);
WriteHandler[0].Install(0x20,write_command,IO_MB);

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: bios.cpp,v 1.52 2005-12-02 13:10:18 c2woody Exp $ */
/* $Id: bios.cpp,v 1.53 2005-12-04 21:17:29 c2woody Exp $ */
#include "dosbox.h"
#include "mem.h"
@ -789,6 +789,13 @@ void BIOS_ZeroExtendedSize(bool in) {
if(other_memsystems < 0) other_memsystems=0;
}
#define RAM_REFRESH_DELAY 16.7f
static void RAMRefresh_Event(Bitu val) {
PIC_ActivateIRQ(5);
PIC_AddEvent(RAMRefresh_Event,RAM_REFRESH_DELAY);
}
void BIOS_SetupKeyboard(void);
void BIOS_SetupDisks(void);
@ -964,7 +971,8 @@ public:
IO_Write(0x70,0x30);
size_extended=IO_Read(0x71);
IO_Write(0x70,0x31);
size_extended|=(IO_Read(0x71) << 8);
size_extended|=(IO_Read(0x71) << 8);
if (machine==MCH_PCJR) PIC_AddEvent(RAMRefresh_Event,RAM_REFRESH_DELAY);
}
~BIOS(){
/* abort DAC playing */

View file

@ -25,7 +25,7 @@
#include "inout.h"
static Bitu call_int16,call_irq1;
static Bitu call_int16,call_irq1,call_irq6;
/* Nice table from BOCHS i should feel bad for ripping this */
#define none 0
@ -438,6 +438,21 @@ irq1_return:
return CBRET_NONE;
}
static bool pcjr_extended_key=false;
static Bitu IRQ6_Handler(void) {
Bit8u scancode=IO_Read(0x60);
Bit16u old_ax=reg_ax;
if (pcjr_extended_key) reg_ax=scancode<<8;
else reg_al=scancode;
pcjr_extended_key=(scancode==0xe0);
/* call the real keyboard IRQ now, with the scancode in AL */
CALLBACK_RunRealInt(0x09);
reg_ax=old_ax;
IO_Write(0x20,0x20);
return CBRET_NONE;
}
/* check whether key combination is enhanced or not,
translate key if necessary */
static bool IsEnhancedKey(Bit16u &key) {
@ -592,6 +607,11 @@ void BIOS_SetupKeyboard(void) {
RealSetVec(0x16,CALLBACK_RealPointer(call_int16));
CALLBACK_Setup(call_irq1,&IRQ1_Handler,CB_IRET,"keyboard irq");
RealSetVec(0x9,CALLBACK_RealPointer(call_irq1));
if (machine==MCH_PCJR) {
call_irq6=CALLBACK_Allocate();
CALLBACK_Setup(call_irq6,&IRQ6_Handler,CB_IRET,"PCJr kb irq");
RealSetVec(0x0e,CALLBACK_RealPointer(call_irq6));
}
/* bring the all port operations outside the callback */
phys_writeb(CB_BASE+(call_irq1<<4)+0x00,(Bit8u)0x50); // push ax