| version 1.3, 2003/10/25 11:37:40 | version 1.7, 2004/01/13 05:30:58 | 
| 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 85  void nevent_progress(void) { | Line 85  void nevent_progress(void) { | 
 | } | } | 
 | item->flag |= NEVENT_SETEVENT; | item->flag |= NEVENT_SETEVENT; | 
 | item->flag &= ~(NEVENT_ENABLE); | item->flag &= ~(NEVENT_ENABLE); | 
 |  | //                      TRACEOUT(("event = %x", curid)); | 
 | } | } | 
 | } | } | 
 | nevent.readyevents = eventnum; | nevent.readyevents = eventnum; | 
| I286_BASECLOCK = nextbase; | CPU_BASECLOCK = nextbase; | 
| I286_REMCLOCK += nextbase; | CPU_REMCLOCK += nextbase; | 
 | nevent_execute(); | nevent_execute(); | 
| //      TRACEOUT((buf, "nextbase = %d (%d)", nextbase, I286_REMCLOCK)); | //      TRACEOUT(("nextbase = %d (%d)", nextbase, CPU_REMCLOCK)); | 
 | } | } | 
 |  |  | 
 |  |  | 
| Line 142  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 176  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)); | 
 | } | } | 
 | } | } | 
 |  |  | 
 | void nevent_setbyms(UINT id, SINT32 ms, NEVENTCB proc, BOOL absolute) { | void nevent_setbyms(UINT id, SINT32 ms, NEVENTCB proc, BOOL absolute) { | 
 |  |  | 
| nevent_set(id, (pc.realclock / 1000) * ms, proc, absolute); | nevent_set(id, (pccore.realclock / 1000) * ms, proc, absolute); | 
 | } | } | 
 |  |  | 
 | BOOL nevent_iswork(UINT id) { | BOOL nevent_iswork(UINT id) { | 
| Line 208  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 216  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; | 
 | } | } | 
 | } | } | 
 |  |  |