From 8806971ad1599eb4dc96a1c7947644d5b394b392 Mon Sep 17 00:00:00 2001 From: anon Date: Mon, 26 May 2008 21:19:00 +0800 Subject: [PATCH] nagra: add cpu exception handling --- systems/nagra/cpu.c | 39 ++++++++++++++++++++++++++++++++++++++- systems/nagra/cpu.h | 8 +++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/systems/nagra/cpu.c b/systems/nagra/cpu.c index 7c7554e..da46c6d 100644 --- a/systems/nagra/cpu.c +++ b/systems/nagra/cpu.c @@ -144,6 +144,8 @@ c6805::c6805(void) { cc.c=0; cc.z=0; cc.n=0; cc.i=0; cc.h=0; cc.v=1; pc=0; a=0; x=0; y=0; cr=dr=0; sp=spHi=0x100; spLow=0xC0; hasReadHandler=hasWriteHandler=false; + exptPending=false; timerDisable=0; exptBase=0x4000; + for(int i=0; i0) { clockcycles+=num; - TimerHandler(num); + if(timerDisable>0) { + timerDisable-=num; + if(timerDisable<0) timerDisable=0; + } + if(!timerDisable) + TimerHandler(num); } } @@ -306,6 +313,24 @@ void c6805::ResetCycles(void) clockcycles=0; } +void c6805::RaiseException(int num) +{ + if(num>(bit))&1) @@ -100,7 +101,7 @@ public: class c6805 { private: - unsigned short pc, sp, spHi, spLow; + unsigned short pc, sp, spHi, spLow, exptBase; unsigned short bp[MAX_BREAKPOINTS], numBp; unsigned char mapMap[(MAX_PAGES+1)*PAGE_SIZE]; cMap *mapper[MAX_MAPPER]; @@ -108,6 +109,8 @@ private: int pageMap[256]; bool indirect; unsigned int clockcycles; + bool exptPending, expt[EXPT_MAX]; + int timerDisable; // void InitMapper(void); void ClearMapper(void); @@ -149,6 +152,9 @@ protected: void ResetCycles(void); void AddCycles(unsigned int num); unsigned int Cycles(void) { return clockcycles; } + void RaiseException(int num); + void SetExptBase(unsigned short base); + void DisableTimers(int num); virtual void Stepper(void)=0; virtual void WriteHandler(unsigned char seg, unsigned short ea, unsigned char &op) {} virtual void ReadHandler(unsigned char seg, unsigned short ea, unsigned char &op) {} -- 2.39.5