OSDN Git Service

[General] More merge upstream 2015-11-30.
[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 #include "../../common.h"
12
13 // ---------------------------------------------------------------------------
14
15 namespace FM
16 {
17         class Timer
18         {
19         public:
20                 void    Reset();
21                 bool    Count(int32 clock);
22                 int32   GetNextEvent();
23         
24         protected:
25                 virtual void SetStatus(uint bit) = 0;
26                 virtual void ResetStatus(uint bit) = 0;
27
28                 void    SetTimerPrescaler(int32 p);
29                 void    SetTimerA(uint addr, uint data);
30                 void    SetTimerB(uint data);
31                 void    SetTimerControl(uint data);
32                 
33                 void SaveState(void *f);
34                 bool LoadState(void *f);
35                 
36                 uint8   status;
37                 uint8   regtc;
38                 // Refer from XM7. Thanks Ryu.
39                 bool    timera_enable;
40                 bool    timerb_enable;
41         private:
42                 virtual void TimerA() {}
43                 uint8   regta[2];
44                 
45                 int32   timera, timera_count;
46                 int32   timerb, timerb_count;
47                 int32   prescaler;
48         };
49
50 // ---------------------------------------------------------------------------
51 //      \8f\89\8aú\89»
52 //
53 inline void Timer::Reset()
54 {
55         timera_count = 0;
56         timerb_count = 0;
57         timera_enable = false;
58         timerb_enable = false;
59 }
60
61 } // namespace FM
62
63 #endif // FM_TIMER_H