// -- cMap0101 ----------------------------------------------------------------
-#define MAP_IRQ_BEGIN() interruptible=true; try {
-#define MAP_IRQ_END() } catch(int) { interrupted=true; } interruptible=false;
-
class cMap0101 : public cMapCore {
private:
static const unsigned char primes[];
static const unsigned short coef22[][32];
- bool interruptible, interrupted;
#ifdef HAS_AUXSRV
cAuxSrv aux;
#endif
//
void MakePrime(BIGNUM *n, unsigned char *residues);
protected:
- void DoMap(int f, unsigned char *data=0, int l=0);
- bool Interruptible(void) { return interruptible; }
- bool Interrupted(void) { return interrupted; }
-public:
- cMap0101(void) { interruptible=false; }
+ bool Map(int f, unsigned char *data, int l);
};
const unsigned char cMap0101::primes[] = {
} while(!isPrime);
}
-void cMap0101::DoMap(int f, unsigned char *data, int l)
+bool cMap0101::Map(int f, unsigned char *data, int l)
{
- PRINTF(L_SYS_MAP,"0101: calling function %02X",f);
l=GetOpSize(l);
- cycles=0; interrupted=false;
- unsigned int startcycles=MapCycles();
switch(f) {
case 0x21:
- MAP_IRQ_BEGIN();
AddMapCycles(288);
WS_START(1);
MakeJ0(J,D,C);
BN_clear(C);
WS_END();
cycles=898;
- MAP_IRQ_END();
break;
case 0x22:
if(BN_is_zero(D)) { cycles=639-6; break; }
break;
}
default:
- if(!cMapCore::DoMap(f,data,l))
- PRINTF(L_SYS_MAP,"0101: unsupported call %02x",f);
- break;
+ return false;
}
- if(!interrupted && cycles)
- cycles-=MapCycles()-startcycles;
+ return true;
}
// -- cN2Prov0101 --------------------------------------------------------------
mecmAddr[0]=0x91d7; mecmAddr[1]=0x92d7; mecmKeyId=0x106;
seedSize=10;
desSize=16; hwMapper=0;
+ SetMapIdent(Id);
}
void cN2Prov0101::DynamicHD(unsigned char *hd, const unsigned char *ed)
return false;
}
c6805::a=0; c6805::x=0; c6805::y=0;
- if(cycles>0) AddMapCycles(cycles);
return true;
}
// -- cMap0501 -----------------------------------------------------------------
class cMap0501 : public cMapCore {
-private:
- int mId;
protected:
- void DoMap(int f, unsigned char *data=0, int l=0);
-public:
- cMap0501(int Id);
+ bool Map(int f, unsigned char *data, int l);
};
-cMap0501::cMap0501(int Id)
-{
- mId=Id|0x100;
-}
-
-void cMap0501::DoMap(int f, unsigned char *data, int l)
+bool cMap0501::Map(int f, unsigned char *data, int l)
{
- PRINTF(L_SYS_MAP,"%04x: calling function %02X",mId,f);
l=GetOpSize(l);
- cycles=0;
switch(f) {
case 0x37:
I.GetLE(data,l<<3);
MonMul(B,I,B);
break;
default:
- if(!cMapCore::DoMap(f,data,l))
- PRINTF(L_SYS_MAP,"%04x: unsupported call %02x",mId,f);
- break;
+ return false;
}
+ return true;
}
// -- cN2Prov0501 --------------------------------------------------------------
cN2Prov0501::cN2Prov0501(int Id, int Flags)
:cN2Prov(Id,Flags)
-,cMap0501(Id)
{
hwMapper=0; hasMaprom=false;
+ SetMapIdent(Id);
}
bool cN2Prov0501::Algo(int algo, const unsigned char *hd, unsigned char *hw)
PRINTF(L_SYS_EMU,"%04x: map call %02x not emulated",id,f);
return false;
}
- if(cycles>0) AddMapCycles(cycles);
return true;
}
// -- cMap4101 -----------------------------------------------------------------
class cMap4101 : public cMapCore {
-private:
- int mId;
protected:
- void DoMap(int f, unsigned char *data=0, int l=0);
-public:
- cMap4101(int Id);
+ bool Map(int f, unsigned char *data, int l);
};
-cMap4101::cMap4101(int Id)
-{
- mId=Id|0x100;
-}
-
-void cMap4101::DoMap(int f, unsigned char *data, int l)
+bool cMap4101::Map(int f, unsigned char *data, int l)
{
- PRINTF(L_SYS_MAP,"%04x: calling function %02X",mId,f);
switch(f) {
case 0x58:
{
cMapCore::DoMap(0x44,data);
break;
default:
- if(!cMapCore::DoMap(f,data,l))
- PRINTF(L_SYS_MAP,"%04x: unsupported call %02x",mId,f);
- break;
+ return false;
}
+ return true;
}
// -- cN2Prov4101 ----------------------------------------------------------------
cN2Prov4101::cN2Prov4101(int Id, int Flags)
:cN2Prov(Id,Flags)
-,cMap4101(Id)
{
hasWriteHandler=true;
+ SetMapIdent(Id);
}
bool cN2Prov4101::PostProcAU(int id, unsigned char *data)
cMapCore::cMapCore(void)
{
- last=1;
+ last=1; mapid=0;
regs[0]=&J; regs[1]=&A; regs[2]=&B; regs[3]=&C; regs[4]=&D;
+ interruptible=false;
}
void cMapCore::MonInit(int bits)
return l!=0 ? l : wordsize;
}
-bool cMapCore::DoMap(int f, unsigned char *data, int l)
+void cMapCore::DoMap(int f, unsigned char *data, int l)
+{
+ PRINTF(L_SYS_MAP,"%04x: calling function %02X",mapid,f);
+ cycles=0;
+ unsigned int startcycles=MapCycles();
+ interrupted=false; interruptible=true;
+ try {
+ if(!Map(f,data,l) && !MapGeneric(f,data,l))
+ PRINTF(L_SYS_MAP,"%04x: unsupported call %02x",mapid,f);
+ } catch(int) { interrupted=true; }
+ interruptible=false;
+ if(!interrupted && cycles)
+ AddMapCycles(MapCycles()-startcycles);
+}
+
+bool cMapCore::MapGeneric(int f, unsigned char *data, int l)
{
const int l1=GetOpSize(l);
const int dl=l1<<3;
- cycles=0;
switch(f) {
case SETSIZE:
cycles=(l>17 ? 459 : (l ? 475 : 454))-6;
class cMapCore : public cMapMath {
private:
- int last;
+ int mapid, last;
cBN e;
cMapReg *regs[5];
+ bool interruptible, interrupted;
+ //
+ bool MapGeneric(int f, unsigned char *data, int l);
protected:
unsigned int cycles;
cBN Px, Py, Pz,Qx, Qy, Qz; // 0x00,0x20,0x40,0x60,0x80,0x180
void CurveInit(BIGNUM *a);
//
int GetOpSize(int l);
- bool DoMap(int f, unsigned char *data=0, int l=0);
+ void DoMap(int f, unsigned char *data=0, int l=0);
+ virtual bool Map(int f, unsigned char *data, int l) { return false; }
+ void SetMapIdent(int Mapid) { mapid=Mapid; }
+ bool Interruptible(void) { return interruptible; }
+ bool Interrupted(void) { return interrupted; }
virtual void AddMapCycles(unsigned int num) {}
virtual unsigned int MapCycles(void) { return 0; }
public: