Diff for /np2/nevent.c between versions 1.4 and 1.6

version 1.4, 2003/11/13 15:33:05 version 1.6, 2003/12/08 00:55:30
Line 1 Line 1
 #include        "compiler.h"  #include        "compiler.h"
 #include        "i286.h"  #include        "cpucore.h"
 #include        "pccore.h"  #include        "pccore.h"
   
   
Line 16  void nevent_get1stevent(void) { Line 16  void nevent_get1stevent(void) {
   
         // 最短のイベントのクロック数をセット          // 最短のイベントのクロック数をセット
         if (nevent.readyevents) {          if (nevent.readyevents) {
                 I286_BASECLOCK = nevent.item[nevent.level[0]].clock;                  CPU_BASECLOCK = nevent.item[nevent.level[0]].clock;
         }          }
         else {          else {
                 // イベントがない場合のクロック数をセット                  // イベントがない場合のクロック数をセット
                 I286_BASECLOCK = NEVENT_MAXCLOCK;                  CPU_BASECLOCK = NEVENT_MAXCLOCK;
         }          }
   
         // カウンタへセット          // カウンタへセット
         I286_REMCLOCK = I286_BASECLOCK;          CPU_REMCLOCK = CPU_BASECLOCK;
 }  }
   
 static void nevent_execute(void) {  static void nevent_execute(void) {
Line 64  void nevent_progress(void) { Line 64  void nevent_progress(void) {
         UINT            curid;          UINT            curid;
         NEVENTITEM      item;          NEVENTITEM      item;
   
         I286_CLOCK += I286_BASECLOCK;          CPU_CLOCK += CPU_BASECLOCK;
         eventnum = 0;          eventnum = 0;
         nextbase = NEVENT_MAXCLOCK;          nextbase = NEVENT_MAXCLOCK;
         for (i=0; i<nevent.readyevents; i++) {          for (i=0; i<nevent.readyevents; i++) {
                 curid = nevent.level[i];                  curid = nevent.level[i];
                 item = &nevent.item[curid];                  item = &nevent.item[curid];
                 item->clock -= I286_BASECLOCK;                  item->clock -= CPU_BASECLOCK;
                 if (item->clock > 0) {                  if (item->clock > 0) {
                         // イベント待ち中                          // イベント待ち中
                         nevent.level[eventnum++] = curid;                          nevent.level[eventnum++] = curid;
Line 89  void nevent_progress(void) { Line 89  void nevent_progress(void) {
                 }                  }
         }          }
         nevent.readyevents = eventnum;          nevent.readyevents = eventnum;
         I286_BASECLOCK = nextbase;          CPU_BASECLOCK = nextbase;
         I286_REMCLOCK += nextbase;          CPU_REMCLOCK += nextbase;
         nevent_execute();          nevent_execute();
 //      TRACEOUT(("nextbase = %d (%d)", nextbase, I286_REMCLOCK));  //      TRACEOUT(("nextbase = %d (%d)", nextbase, CPU_REMCLOCK));
 }  }
   
   
Line 143  void nevent_set(UINT id, SINT32 eventclo Line 143  void nevent_set(UINT id, SINT32 eventclo
         UINT            eventid;          UINT            eventid;
         UINT            i;          UINT            i;
   
         clock = I286_BASECLOCK - I286_REMCLOCK;  //      TRACEOUT(("event %d - %xclocks", id, eventclock));
   
           clock = CPU_BASECLOCK - CPU_REMCLOCK;
         item = &nevent.item[id];          item = &nevent.item[id];
         item->proc = proc;          item->proc = proc;
         item->flag = 0;          item->flag = 0;
Line 177  void nevent_set(UINT id, SINT32 eventclo Line 179  void nevent_set(UINT id, SINT32 eventclo
   
         // もし最短イベントだったら...          // もし最短イベントだったら...
         if (eventid == 0) {          if (eventid == 0) {
                 clock = I286_BASECLOCK - item->clock;                  clock = CPU_BASECLOCK - item->clock;
                 I286_BASECLOCK -= clock;                  CPU_BASECLOCK -= clock;
                 I286_REMCLOCK -= clock;                  CPU_REMCLOCK -= clock;
 //              TRACEOUT(("reset nextbase -%d (%d)", clock, I286_REMCLOCK));  //              TRACEOUT(("reset nextbase -%d (%d)", clock, CPU_REMCLOCK));
         }          }
 }  }
   
Line 209  SINT32 nevent_getremain(UINT id) { Line 211  SINT32 nevent_getremain(UINT id) {
         // 現在進行してるイベントを検索          // 現在進行してるイベントを検索
         for (i=0; i<nevent.readyevents; i++) {          for (i=0; i<nevent.readyevents; i++) {
                 if (nevent.level[i] == id) {                  if (nevent.level[i] == id) {
                         return(nevent.item[id].clock - (I286_BASECLOCK - I286_REMCLOCK));                          return(nevent.item[id].clock - (CPU_BASECLOCK - CPU_REMCLOCK));
                 }                  }
         }          }
         return(-1);          return(-1);
Line 217  SINT32 nevent_getremain(UINT id) { Line 219  SINT32 nevent_getremain(UINT id) {
   
 void nevent_forceexit(void) {  void nevent_forceexit(void) {
   
         if (I286_REMCLOCK > 0) {          if (CPU_REMCLOCK > 0) {
                 I286_BASECLOCK -= I286_REMCLOCK;                  CPU_BASECLOCK -= CPU_REMCLOCK;
                 I286_REMCLOCK = 0;                  CPU_REMCLOCK = 0;
         }          }
 }  }
   

Removed from v.1.4  
changed lines
  Added in v.1.6


RetroPC.NET-CVS <cvs@retropc.net>