comparison src/adplug/core/diskopl.cxx @ 955:4709ce4e209e trunk

[svn] Run indent -ts4 -nut -bli0 -cdw on this messy lot. Upstream is not consistent with whitespace anyway, no loss there.
author chainsaw
date Sat, 14 Apr 2007 15:23:50 -0700
parents 3da1b8942b8b
children
comparison
equal deleted inserted replaced
954:d7a6fd179cd2 955:4709ce4e209e
20 */ 20 */
21 21
22 #include "diskopl.h" 22 #include "diskopl.h"
23 23
24 //static const unsigned short note_table[12] = {363,385,408,432,458,485,514,544,577,611,647,686}; 24 //static const unsigned short note_table[12] = {363,385,408,432,458,485,514,544,577,611,647,686};
25 const unsigned char CDiskopl::op_table[9] = {0x00, 0x01, 0x02, 0x08, 0x09, 0x0a, 0x10, 0x11, 0x12}; 25 const unsigned char
26 CDiskopl::op_table[9] =
27 { 0x00, 0x01, 0x02, 0x08, 0x09, 0x0a, 0x10, 0x11, 0x12 };
26 28
27 CDiskopl::CDiskopl(std::string filename) 29 CDiskopl::CDiskopl (std::string filename):old_freq (0.0f), del (1),
28 : old_freq(0.0f), del(1), nowrite(false) 30 nowrite (false)
29 { 31 {
30 unsigned short clock = 0xffff; 32 unsigned short
33 clock = 0xffff;
31 34
32 currType = TYPE_OPL3; 35 currType = TYPE_OPL3;
33 f = fopen(filename.c_str(),"wb"); 36 f = fopen (filename.c_str (), "wb");
34 fwrite("RAWADATA",8,1,f); 37 fwrite ("RAWADATA", 8, 1, f);
35 fwrite(&clock,sizeof(clock),1,f); 38 fwrite (&clock, sizeof (clock), 1, f);
36 } 39 }
37 40
38 CDiskopl::~CDiskopl() 41 CDiskopl::~CDiskopl ()
39 { 42 {
40 fclose(f); 43 fclose (f);
41 } 44 }
42 45
43 void CDiskopl::update(CPlayer *p) 46 void
47 CDiskopl::update (CPlayer * p)
44 { 48 {
45 unsigned short clock; 49 unsigned short clock;
46 unsigned int wait; 50 unsigned int wait;
47 51
48 if(p->getrefresh() != old_freq) { 52 if (p->getrefresh () != old_freq)
49 old_freq = p->getrefresh(); 53 {
50 del = wait = (unsigned int)(18.2f / old_freq); 54 old_freq = p->getrefresh ();
51 clock = (unsigned short)(1192737/(old_freq*(wait+1))); 55 del = wait = (unsigned int) (18.2f / old_freq);
52 fputc(0,f); fputc(2,f); 56 clock = (unsigned short) (1192737 / (old_freq * (wait + 1)));
53 fwrite(&clock,2,1,f); 57 fputc (0, f);
58 fputc (2, f);
59 fwrite (&clock, 2, 1, f);
54 } 60 }
55 if(!nowrite) { 61 if (!nowrite)
56 fputc(del+1,f); 62 {
57 fputc(0,f); 63 fputc (del + 1, f);
64 fputc (0, f);
58 } 65 }
59 } 66 }
60 67
61 void CDiskopl::setchip(int n) 68 void
69 CDiskopl::setchip (int n)
62 { 70 {
63 Copl::setchip(n); 71 Copl::setchip (n);
64 72
65 if(!nowrite) { 73 if (!nowrite)
66 fputc(currChip + 1, f); 74 {
67 fputc(2, f); 75 fputc (currChip + 1, f);
76 fputc (2, f);
68 } 77 }
69 } 78 }
70 79
71 void CDiskopl::write(int reg, int val) 80 void
81 CDiskopl::write (int reg, int val)
72 { 82 {
73 if(!nowrite) 83 if (!nowrite)
74 diskwrite(reg,val); 84 diskwrite (reg, val);
75 } 85 }
76 86
77 void CDiskopl::init() 87 void
88 CDiskopl::init ()
78 { 89 {
79 for (int i=0;i<9;i++) { // stop instruments 90 for (int i = 0; i < 9; i++)
80 diskwrite(0xb0 + i,0); // key off 91 { // stop instruments
81 diskwrite(0x80 + op_table[i],0xff); // fastest release 92 diskwrite (0xb0 + i, 0); // key off
93 diskwrite (0x80 + op_table[i], 0xff); // fastest release
82 } 94 }
83 diskwrite(0xbd,0); // clear misc. register 95 diskwrite (0xbd, 0); // clear misc. register
84 } 96 }
85 97
86 void CDiskopl::diskwrite(int reg, int val) 98 void
99 CDiskopl::diskwrite (int reg, int val)
87 { 100 {
88 fputc(val,f); 101 fputc (val, f);
89 fputc(reg,f); 102 fputc (reg, f);
90 } 103 }