OSDN Git Service

[VM][General] Merge upstream 2016-03-01. (Pahse 1).
[csp-qt/common_source_project-fm7.git] / source / src / vm / fmgen / fmtimer.h
1 // ---------------------------------------------------------------------------
2 //      FM sound generator common timer module
3 //      Copyright (C) cisc 1998, 2000.
4 // ---------------------------------------------------------------------------
5 //      $Id: fmtimer.h,v 1.2 2003/04/22 13:12:53 cisc Exp $
6
7 #ifndef FM_TIMER_H
8 #define FM_TIMER_H
9
10 #include "types.h"
11
12 // ---------------------------------------------------------------------------
13
14 namespace FM
15 {
16         class Timer
17         {
18         public:
19                 void    Reset();
20                 bool    Count(int32 clock);
21                 int32   GetNextEvent();
22         
23         protected:
24                 virtual void SetStatus(uint bit) = 0;
25                 virtual void ResetStatus(uint bit) = 0;
26
27                 void    SetTimerPrescaler(int32 p);
28                 void    SetTimerA(uint addr, uint data);
29                 void    SetTimerB(uint data);
30                 void    SetTimerControl(uint data);
31                 
32                 void SaveState(void *f);
33                 bool LoadState(void *f);
34                 
35                 uint8   status;
36                 uint8   regtc;
37         private:
38                 virtual void TimerA() {}
39                 uint8   regta[2];
40                 
41                 int32   timera, timera_count;
42                 int32   timerb, timerb_count;
43                 int32   prescaler;
44         };
45
46 // ---------------------------------------------------------------------------
47 //      \8f\89\8aú\89»
48 //
49 inline void Timer::Reset()
50 {
51         timera_count = 0;
52         timerb_count = 0;
53 }
54
55 } // namespace FM
56
57 #endif // FM_TIMER_H