mirror of
https://github.com/retro100/dosbox-wii.git
synced 2024-12-26 10:31:50 +01:00
Fixed! Virtual .com files work perfectly now, command line arguments and all. DOS games probably work a lot better too.
This time no work-arounds, or wii-specific sections, just messy code. If you can tell me how to properly declare a packed structure on the Wii (and other platforms), I can make the code less messy.
This commit is contained in:
parent
0447edac43
commit
63c5a10292
File diff suppressed because one or more lines are too long
@ -286,19 +286,19 @@ public:
|
|||||||
|
|
||||||
void SaveVectors (void);
|
void SaveVectors (void);
|
||||||
void RestoreVectors (void);
|
void RestoreVectors (void);
|
||||||
void SetSize (Bit16u size) { sSave(sPSP,next_seg,size); };
|
void SetSize (Bit16u size) { SaveIt(2,0x02,size); /*sSave(sPSP,next_seg,size);*/ };
|
||||||
Bit16u GetSize (void) { return (Bit16u)sGet(sPSP,next_seg); };
|
Bit16u GetSize (void) { return (Bit16u)GetIt(2,0x02); /*sGet(sPSP,next_seg);*/ };
|
||||||
void SetEnvironment (Bit16u envseg) { sSave(sPSP,environment,envseg); };
|
void SetEnvironment (Bit16u envseg) { SaveIt(2,0x2c,envseg);/*sSave(sPSP,environment,envseg);*/ };
|
||||||
Bit16u GetEnvironment (void) { return (Bit16u)sGet(sPSP,environment); };
|
Bit16u GetEnvironment (void) { return (Bit16u)GetIt(2,0x2c);/*return (Bit16u)sGet(sPSP,environment);*/ };
|
||||||
Bit16u GetSegment (void) { return seg; };
|
Bit16u GetSegment (void) { return seg; };
|
||||||
void SetFileHandle (Bit16u index, Bit8u handle);
|
void SetFileHandle (Bit16u index, Bit8u handle);
|
||||||
Bit8u GetFileHandle (Bit16u index);
|
Bit8u GetFileHandle (Bit16u index);
|
||||||
void SetParent (Bit16u parent) { sSave(sPSP,psp_parent,parent); };
|
void SetParent (Bit16u parent) { SaveIt(2,0x16,parent); /*sSave(sPSP,psp_parent,parent);*/ };
|
||||||
Bit16u GetParent (void) { return (Bit16u)sGet(sPSP,psp_parent); };
|
Bit16u GetParent (void) { return (Bit16u)GetIt(2,0x16);/*sGet(sPSP,psp_parent);*/ };
|
||||||
void SetStack (RealPt stackpt) { sSave(sPSP,stack,stackpt); };
|
void SetStack (RealPt stackpt) { SaveIt(4,0x2e,stackpt); /*sSave(sPSP,stack,stackpt);*/ };
|
||||||
RealPt GetStack (void) { return sGet(sPSP,stack); };
|
RealPt GetStack (void) { return GetIt(4,0x2e);/*sGet(sPSP,stack);*/ };
|
||||||
void SetInt22 (RealPt int22pt) { sSave(sPSP,int_22,int22pt); };
|
void SetInt22 (RealPt int22pt) { SaveIt(4,0x0A,int22pt);/*sSave(sPSP,int_22,int22pt);*/ };
|
||||||
RealPt GetInt22 (void) { return sGet(sPSP,int_22); };
|
RealPt GetInt22 (void) { return GetIt(4,0x0A); /*sGet(sPSP,int_22);*/ };
|
||||||
void SetFCB1 (RealPt src);
|
void SetFCB1 (RealPt src);
|
||||||
void SetFCB2 (RealPt src);
|
void SetFCB2 (RealPt src);
|
||||||
void SetCommandTail (RealPt src);
|
void SetCommandTail (RealPt src);
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include "dos_inc.h"
|
#include "dos_inc.h"
|
||||||
#include "support.h"
|
#include "support.h"
|
||||||
|
|
||||||
|
|
||||||
void DOS_ParamBlock::Clear(void) {
|
void DOS_ParamBlock::Clear(void) {
|
||||||
memset(&exec,0,sizeof(exec));
|
memset(&exec,0,sizeof(exec));
|
||||||
memset(&overlay,0,sizeof(overlay));
|
memset(&overlay,0,sizeof(overlay));
|
||||||
@ -176,32 +175,45 @@ void DOS_PSP::MakeNew(Bit16u mem_size) {
|
|||||||
// DOS_PSP prevpsp(dos.psp());
|
// DOS_PSP prevpsp(dos.psp());
|
||||||
/* Clear it first */
|
/* Clear it first */
|
||||||
Bitu i;
|
Bitu i;
|
||||||
for (i=0;i<sizeof(sPSP);i++) mem_writeb(pt+i,0);
|
for (i=0;i<0x100;i++) mem_writeb(pt+i,0);
|
||||||
// Set size
|
// Set size
|
||||||
sSave(sPSP,next_seg,seg+mem_size);
|
SaveIt(2,0x02,seg+mem_size);
|
||||||
|
//sSave(sPSP,next_seg,seg+mem_size);
|
||||||
/* far call opcode */
|
/* far call opcode */
|
||||||
sSave(sPSP,far_call,0xea);
|
SaveIt(1,0x05,0xea);
|
||||||
|
//sSave(sPSP,far_call,0xea);
|
||||||
// far call to interrupt 0x21 - faked for bill & ted
|
// far call to interrupt 0x21 - faked for bill & ted
|
||||||
// lets hope nobody really uses this address
|
// lets hope nobody really uses this address
|
||||||
sSave(sPSP,cpm_entry,RealMake(0xDEAD,0xFFFF));
|
SaveIt(4,0x06,RealMake(0xDEAD,0xFFFF));
|
||||||
|
//sSave(sPSP,cpm_entry,RealMake(0xDEAD,0xFFFF));
|
||||||
/* Standard blocks,int 20 and int21 retf */
|
/* Standard blocks,int 20 and int21 retf */
|
||||||
sSave(sPSP,exit[0],0xcd);
|
SaveIt(1,0x00,0xcd); // INT...
|
||||||
sSave(sPSP,exit[1],0x20);
|
//sSave(sPSP,exit[0],0xcd);
|
||||||
sSave(sPSP,service[0],0xcd);
|
SaveIt(1,0x01,0x20); // ...20H
|
||||||
sSave(sPSP,service[1],0x21);
|
//sSave(sPSP,exit[1],0x20);
|
||||||
sSave(sPSP,service[2],0xcb);
|
SaveIt(1,0x50,0xcd); // INT
|
||||||
|
SaveIt(1,0x51,0x21); // ...21H
|
||||||
|
SaveIt(1,0x52,0xcb); // RETF
|
||||||
|
//sSave(sPSP,service[0],0xcd);
|
||||||
|
//sSave(sPSP,service[1],0x21);
|
||||||
|
//sSave(sPSP,service[2],0xcb);
|
||||||
/* psp and psp-parent */
|
/* psp and psp-parent */
|
||||||
sSave(sPSP,psp_parent,dos.psp());
|
SaveIt(2,0x16,dos.psp());
|
||||||
sSave(sPSP,prev_psp,0xffffffff);
|
SaveIt(4,0x38,0xffffffff);
|
||||||
sSave(sPSP,dos_version,0x0005);
|
SaveIt(2,0x40,0x0005);
|
||||||
|
//sSave(sPSP,psp_parent,dos.psp());
|
||||||
|
//sSave(sPSP,prev_psp,0xffffffff);
|
||||||
|
//sSave(sPSP,dos_version,0x0005);
|
||||||
/* terminate 22,break 23,crititcal error 24 address stored */
|
/* terminate 22,break 23,crititcal error 24 address stored */
|
||||||
SaveVectors();
|
SaveVectors();
|
||||||
|
|
||||||
/* FCBs are filled with 0 */
|
/* FCBs are filled with 0 */
|
||||||
// ....
|
// ....
|
||||||
/* Init file pointer and max_files */
|
/* Init file pointer and max_files */
|
||||||
sSave(sPSP,file_table,RealMake(seg,offsetof(sPSP,files)));
|
SaveIt(4,0x34,RealMake(seg,offsetof(sPSP,files)));
|
||||||
sSave(sPSP,max_files,20);
|
//sSave(sPSP,file_table,RealMake(seg,offsetof(sPSP,files)));
|
||||||
|
SaveIt(2,0x32,20);
|
||||||
|
//sSave(sPSP,max_files,20);
|
||||||
for (i=0;i<20;i++) SetFileHandle(i,0xff);
|
for (i=0;i<20;i++) SetFileHandle(i,0xff);
|
||||||
|
|
||||||
/* User Stack pointer */
|
/* User Stack pointer */
|
||||||
@ -211,29 +223,35 @@ void DOS_PSP::MakeNew(Bit16u mem_size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bit8u DOS_PSP::GetFileHandle(Bit16u index) {
|
Bit8u DOS_PSP::GetFileHandle(Bit16u index) {
|
||||||
if (index>=sGet(sPSP,max_files)) return 0xff;
|
if (index>=GetIt(2,0x32)) return 0xff;
|
||||||
PhysPt files=Real2Phys(sGet(sPSP,file_table));
|
PhysPt files=Real2Phys(GetIt(4,0x34));
|
||||||
|
/*if (index>=sGet(sPSP,max_files)) return 0xff;
|
||||||
|
PhysPt files=Real2Phys(sGet(sPSP,file_table));*/
|
||||||
return mem_readb(files+index);
|
return mem_readb(files+index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DOS_PSP::SetFileHandle(Bit16u index, Bit8u handle) {
|
void DOS_PSP::SetFileHandle(Bit16u index, Bit8u handle) {
|
||||||
if (index<sGet(sPSP,max_files)) {
|
if (index<GetIt(2,0x32)) {
|
||||||
PhysPt files=Real2Phys(sGet(sPSP,file_table));
|
PhysPt files=Real2Phys(GetIt(4,0x34));
|
||||||
mem_writeb(files+index,handle);
|
mem_writeb(files+index,handle);
|
||||||
}
|
}
|
||||||
|
/*if (index<sGet(sPSP,max_files)) {
|
||||||
|
PhysPt files=Real2Phys(sGet(sPSP,file_table));
|
||||||
|
mem_writeb(files+index,handle);
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
Bit16u DOS_PSP::FindFreeFileEntry(void) {
|
Bit16u DOS_PSP::FindFreeFileEntry(void) {
|
||||||
PhysPt files=Real2Phys(sGet(sPSP,file_table));
|
PhysPt files=Real2Phys(GetIt(4,0x34));
|
||||||
for (Bit16u i=0;i<sGet(sPSP,max_files);i++) {
|
for (Bit16u i=0;i<GetIt(2,0x32);i++) {
|
||||||
if (mem_readb(files+i)==0xff) return i;
|
if (mem_readb(files+i)==0xff) return i;
|
||||||
}
|
}
|
||||||
return 0xff;
|
return 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bit16u DOS_PSP::FindEntryByHandle(Bit8u handle) {
|
Bit16u DOS_PSP::FindEntryByHandle(Bit8u handle) {
|
||||||
PhysPt files=Real2Phys(sGet(sPSP,file_table));
|
PhysPt files=Real2Phys(GetIt(4,0x34));
|
||||||
for (Bit16u i=0;i<sGet(sPSP,max_files);i++) {
|
for (Bit16u i=0;i<GetIt(2,0x32);i++) {
|
||||||
if (mem_readb(files+i)==handle) return i;
|
if (mem_readb(files+i)==handle) return i;
|
||||||
}
|
}
|
||||||
return 0xFF;
|
return 0xFF;
|
||||||
@ -264,40 +282,47 @@ void DOS_PSP::CopyFileTable(DOS_PSP* srcpsp,bool createchildpsp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DOS_PSP::CloseFiles(void) {
|
void DOS_PSP::CloseFiles(void) {
|
||||||
for (Bit16u i=0;i<sGet(sPSP,max_files);i++) {
|
for (Bit16u i=0;i<GetIt(2,0x32);i++) {
|
||||||
DOS_CloseFile(i);
|
DOS_CloseFile(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DOS_PSP::SaveVectors(void) {
|
void DOS_PSP::SaveVectors(void) {
|
||||||
/* Save interrupt 22,23,24 */
|
/* Save interrupt 22,23,24 */
|
||||||
sSave(sPSP,int_22,RealGetVec(0x22));
|
SaveIt(4,0x0A,RealGetVec(0x22));
|
||||||
sSave(sPSP,int_23,RealGetVec(0x23));
|
SaveIt(4,0x0E,RealGetVec(0x23));
|
||||||
sSave(sPSP,int_24,RealGetVec(0x24));
|
SaveIt(4,0x12,RealGetVec(0x24));
|
||||||
|
//sSave(sPSP,int_22,RealGetVec(0x22));
|
||||||
|
//sSave(sPSP,int_23,RealGetVec(0x23));
|
||||||
|
//sSave(sPSP,int_24,RealGetVec(0x24));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DOS_PSP::RestoreVectors(void) {
|
void DOS_PSP::RestoreVectors(void) {
|
||||||
/* Restore interrupt 22,23,24 */
|
/* Restore interrupt 22,23,24 */
|
||||||
RealSetVec(0x22,sGet(sPSP,int_22));
|
RealSetVec(0x22,GetIt(4,0x0A));
|
||||||
RealSetVec(0x23,sGet(sPSP,int_23));
|
RealSetVec(0x23,GetIt(4,0x0E));
|
||||||
RealSetVec(0x24,sGet(sPSP,int_24));
|
RealSetVec(0x24,GetIt(4,0x12));
|
||||||
|
|
||||||
|
//RealSetVec(0x22,sGet(sPSP,int_22));
|
||||||
|
//RealSetVec(0x23,sGet(sPSP,int_23));
|
||||||
|
//RealSetVec(0x24,sGet(sPSP,int_24));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DOS_PSP::SetCommandTail(RealPt src) {
|
void DOS_PSP::SetCommandTail(RealPt src) {
|
||||||
if (src) { // valid source
|
if (src) { // valid source
|
||||||
MEM_BlockCopy(pt+offsetof(sPSP,cmdtail),Real2Phys(src),128);
|
MEM_BlockCopy(pt+128,Real2Phys(src),128);
|
||||||
} else { // empty
|
} else { // empty
|
||||||
sSave(sPSP,cmdtail.count,0x00);
|
SaveIt(1,128,0);
|
||||||
mem_writeb(pt+offsetof(sPSP,cmdtail.buffer),0x0d);
|
mem_writeb(pt+129,0x0d);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void DOS_PSP::SetFCB1(RealPt src) {
|
void DOS_PSP::SetFCB1(RealPt src) {
|
||||||
if (src) MEM_BlockCopy(PhysMake(seg,offsetof(sPSP,fcb1)),Real2Phys(src),16);
|
if (src) MEM_BlockCopy(PhysMake(seg,0x5c),Real2Phys(src),16);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DOS_PSP::SetFCB2(RealPt src) {
|
void DOS_PSP::SetFCB2(RealPt src) {
|
||||||
if (src) MEM_BlockCopy(PhysMake(seg,offsetof(sPSP,fcb2)),Real2Phys(src),16);
|
if (src) MEM_BlockCopy(PhysMake(seg,0x6c),Real2Phys(src),16);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DOS_PSP::SetNumFiles(Bit16u fileNum) {
|
bool DOS_PSP::SetNumFiles(Bit16u fileNum) {
|
||||||
@ -306,13 +331,16 @@ bool DOS_PSP::SetNumFiles(Bit16u fileNum) {
|
|||||||
fileNum+=2; // Add a few more files for safety
|
fileNum+=2; // Add a few more files for safety
|
||||||
Bit16u para = (fileNum/16)+((fileNum%16)>0);
|
Bit16u para = (fileNum/16)+((fileNum%16)>0);
|
||||||
RealPt data = RealMake(DOS_GetMemory(para),0);
|
RealPt data = RealMake(DOS_GetMemory(para),0);
|
||||||
sSave(sPSP,file_table,data);
|
SaveIt(4,0x34,data);
|
||||||
sSave(sPSP,max_files,fileNum);
|
//sSave(sPSP,file_table,data);
|
||||||
|
SaveIt(2,0x32,fileNum);
|
||||||
|
//sSave(sPSP,max_files,fileNum);
|
||||||
Bit16u i;
|
Bit16u i;
|
||||||
for (i=0; i<20; i++) SetFileHandle(i,sGet(sPSP,files[i]));
|
for (i=0; i<20; i++) SetFileHandle(i,GetIt(1,0x18+i*1)/*sGet(sPSP,files[i])*/);
|
||||||
for (i=20; i<fileNum; i++) SetFileHandle(i,0xFF);
|
for (i=20; i<fileNum; i++) SetFileHandle(i,0xFF);
|
||||||
} else {
|
} else {
|
||||||
sSave(sPSP,max_files,fileNum);
|
SaveIt(2,0x32,fileNum);
|
||||||
|
//sSave(sPSP,max_files,fileNum);
|
||||||
};
|
};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,7 @@ static Bit8u exe_block[]={
|
|||||||
0xbc,0x00,0x04, //MOV SP,0x400 decrease stack size
|
0xbc,0x00,0x04, //MOV SP,0x400 decrease stack size
|
||||||
0xbb,0x40,0x00, //MOV BX,0x040 for memory resize
|
0xbb,0x40,0x00, //MOV BX,0x040 for memory resize
|
||||||
0xb4,0x4a, //MOV AH,0x4A Resize memory block
|
0xb4,0x4a, //MOV AH,0x4A Resize memory block
|
||||||
#ifdef HW_RVL
|
|
||||||
0x90,0x90, // NOP, NOP... this prevents an invalid opcode crash in the core
|
|
||||||
#else
|
|
||||||
0xcd,0x21, //INT 0x21
|
0xcd,0x21, //INT 0x21
|
||||||
#endif
|
|
||||||
//pos 12 is callback number
|
//pos 12 is callback number
|
||||||
0xFE,0x38,0x00,0x00, //CALLBack number
|
0xFE,0x38,0x00,0x00, //CALLBack number
|
||||||
0xb8,0x00,0x4c, //Mov ax,4c00
|
0xb8,0x00,0x4c, //Mov ax,4c00
|
||||||
|
Loading…
Reference in New Issue
Block a user