From: leslie Date: Fri, 13 Jun 2008 00:48:57 +0000 (+0800) Subject: nagra: simplify map cycles handling X-Git-Tag: 0.9.1~67 X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=0621acab2aab03d8ec7b140099f26c25874b0f45;p=sasc-ng.git nagra: simplify map cycles handling --- diff --git a/systems/nagra/nagra2-0101.c b/systems/nagra/nagra2-0101.c index a45b8a9..5bfb805 100644 --- a/systems/nagra/nagra2-0101.c +++ b/systems/nagra/nagra2-0101.c @@ -171,6 +171,7 @@ void cMap0101::DoMap(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(); @@ -180,7 +181,7 @@ void cMap0101::DoMap(int f, unsigned char *data, int l) AddMapCycles(282); BN_clear(C); WS_END(); - AddMapCycles(898-282-288); + cycles=898; MAP_IRQ_END(); break; case 0x22: @@ -355,6 +356,8 @@ void cMap0101::DoMap(int f, unsigned char *data, int l) PRINTF(L_SYS_MAP,"0101: unsupported call %02x",f); break; } + if(!interrupted && cycles) + cycles-=MapCycles()-startcycles; } // -- cN2Prov0101 -------------------------------------------------------------- @@ -381,6 +384,7 @@ protected: virtual void Stepper(void); virtual void TimerHandler(unsigned int num); virtual void AddMapCycles(unsigned int num); + virtual unsigned int MapCycles(void) { return Cycles(); } public: cN2Prov0101(int Id, int Flags); virtual bool PostProcAU(int id, unsigned char *data); diff --git a/systems/nagra/nagra2-0501.c b/systems/nagra/nagra2-0501.c index d249d76..1bfe95f 100644 --- a/systems/nagra/nagra2-0501.c +++ b/systems/nagra/nagra2-0501.c @@ -137,7 +137,6 @@ bool cN2Prov0501::ProcessMap(int f) switch(f) { case SETSIZE: DoMap(f,0,Get(0x48)); - AddCycles(MapCycles()); break; case IMPORT_J: case IMPORT_A: @@ -147,7 +146,6 @@ bool cN2Prov0501::ProcessMap(int f) case IMPORT_LAST: addr=HILO(0x44); GetMem(addr,tmp,dl,0); DoMap(f,tmp,l); - AddCycles(MapCycles()); break; case EXPORT_J: case EXPORT_A: @@ -157,7 +155,6 @@ bool cN2Prov0501::ProcessMap(int f) case EXPORT_LAST: addr=HILO(0x44); DoMap(f,tmp,l); SetMem(addr,tmp,dl,0); - AddCycles(MapCycles()); break; case SWAP_A: case SWAP_B: @@ -165,7 +162,6 @@ bool cN2Prov0501::ProcessMap(int f) case SWAP_D: addr=HILO(0x44); GetMem(addr,tmp,dl,0); DoMap(f,tmp,l); SetMem(addr,tmp,dl,0); - AddCycles(MapCycles()); break; case CLEAR_A: case CLEAR_B: @@ -178,7 +174,6 @@ bool cN2Prov0501::ProcessMap(int f) case COPY_C_D: case COPY_D_C: DoMap(f); - AddCycles(MapCycles()); break; case 0x37: GetMem(HILO(0x44),tmp,dl,0); @@ -199,6 +194,7 @@ bool cN2Prov0501::ProcessMap(int f) PRINTF(L_SYS_EMU,"%04x: map call %02x not emulated",id,f); return false; } + if(cycles>0) AddMapCycles(cycles); return true; } diff --git a/systems/nagra/nagra2.h b/systems/nagra/nagra2.h index 1d8db71..19bc507 100644 --- a/systems/nagra/nagra2.h +++ b/systems/nagra/nagra2.h @@ -160,8 +160,8 @@ protected: // int GetOpSize(int l); bool DoMap(int f, unsigned char *data=0, int l=0); - unsigned int MapCycles() { return cycles; } virtual void AddMapCycles(unsigned int num) {} + virtual unsigned int MapCycles(void) { return 0; } public: cMapCore(void); virtual ~cMapCore() {}