This file is indexed.

/usr/include/tse3/plt/RiscOS.cpp is in libtse3-dev 0.3.1-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
 * @(#)RiscOS.cpp 3.00 20 July 1999
 *
 * Copyright (c) 2000 Pete Goodliffe (pete@cthree.org)
 *
 * This file is part of TSE3 - the Trax Sequencer Engine version 3.00.
 *
 * This library is modifiable/redistributable under the terms of the GNU
 * General Public License.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; see the file COPYING. If not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 */

#include "tse3/platform/RiscOS.h"
#include "tse3/platform/midisswis.h"
#include "kernel.h"

using namespace TSE3;
using namespace TSE3::Plt;

/*
 * NB:
 *
 * This is all hypothetical code since I've not been able to test it on a
 * RISC OS platform. There isn't a decent C++ compiler, and the Acorn CFront
 * isn't quite good enough ;-)
 *
 * I include it here for completeness, and to exorcise the demons.
 *
 */


/******************************************************************************
 * RISC OS MidiSchedulerFactory class
 *****************************************************************************/

MidiSchedulerFactory::MidiSchedulerFactory(bool b)
{
}


MidiSchedulerFactory::~MidiSchedulerFactory()
{
}


MidiScheduler *MidiSchedulerFactory::createScheduler()
{
    return new RiscOsMidiScheduler();
}


/******************************************************************************
 * RiscOsMidiScheduler class
 *****************************************************************************/

RiscOsMidiScheduler::RiscOsMidiScheduler()
{
    std::cout << "RiscOsMidiScheduler created ("
              << implementationName() << ")\n";
    _swix(MIDI_Init, _IN(0) | _OUT(0), 0, &(maxPort));
    for (int p = 0; p < maxPort; ++p)
    {
        addPort(p, false, p);
    }
}


RiscOsMidiScheduler::~RiscOsMidiScheduler()
{
    std::cout << "** RiscOsMidiScheduler deleted.\n";
}


const char *RiscOSMidiScheduler::impl_implementationName() const
{
    return "RiscOsMidiScheduler version 0.00 [dev].";
}


const char *NullMidiScheduler::impl_portName(int /*port*/) const
{
    return "RISC OS MIDI port";
}


const char *NullMidiScheduler::impl_portType(int /*port*/) const
{
    return "RISC OS MIDI port";
}


bool NullMidiScheduler::impl_portReadable(int /*port*/) const
{
    return true;
}


bool NullMidiScheduler::impl_portWriteable(int /*port*/) const
{
    return true;
}


void RiscOsMidiScheduler::impl_tx(MidiCommand mc)
{
    std::cout << "RiscOsMidiScheduler::tx - (now): "
              << mc.status << " on (" << mc.channel
              << "," << mc.port << ") with " << mc.data1
              << ", " << mc.data2 << "\n";
    int command = mc.channel
                + (mc.status << 4)
                + (mc.data1  << 8)
                + (mc.data2  << 16)
                + (mc.port   << 28)
    _swix(MIDI_TxCommand, _INR(0,1), command, 0);
}


void RiscOsMidiScheduler::impl_start(Clock start)
{
    std::cout << "RiscOsMidiScheduler::start(" << start << ")\n";

    // start the fast clock
    if (_tempo == 0) _tempo = 120;
    _swix(MIDI_FastClock, _INR(0,1), 2500 / _tempo, 0);

    // start the interface sending timing clocks then send a midi stop
    //   so that the instrument doesn't play itself away!
    _swix(MIDI_TxStart, 0);
    _swix(MIDI_TxCommand, _INR(0,1), 0xfc, 0);

    clockStarted(start);
}


void RiscOsMidiScheduler::impl_stop(Clock stop)
{
    std::cout << "RiscOsMidiScheduler::stopped at " << stop << "\n";
    _swix(MIDI_TxStop, 0);
    clockStopped(stop);
}


void RiscOsMidiScheduler::impl_moveTo(Clock moveTime, Clock newTime)
{
    clockMoved(moveTime, newTime);
}


Clock RiscOsMidiScheduler::impl_clock()
{
    int fcval;
    _swix(MIDI_FastClock, _IN(0) | _OUT(1), -1, &fcval);
    return msToClock(fcval);
}


int RiscOsMidiScheduler::impl_msecs()
{
    int fcval;
    _swix(MIDI_FastClock, _IN(0) | _OUT(1), -1, &fcval);
    return fcval;
}


void RiscOsMidiScheduler::impl_setTempo(int newTempo, Clock changeTime)
{
    tempoChanged(newTempo, changeTime);
}


bool RiscOsMidiScheduler::impl_eventWaiting()
{
    // find input buffer size              // SHOULD THIS BE HELD IN VARIABLE?
    int buffer_size;
    _swix(MIDI_SetBufferSize, _INR(0,1) | _OUT(0), 0, 0, &buffer_size);

    for (int n = 0; n <= maxPort; ++n)
    {
        // find number of free bytes in input buffer
        int bufsize;
        _swix(MIDI_InqBufferSize, _IN(0) | _OUT(0), n<<1, &bufsize);

        // event waiting if the two aren't equal
        if (buffer_size != bufsize) return 1;
    }

    return 0; // all buffers empty
}


MidiEvent RiscOsMidiScheduler::impl_rx()
{
    int c /*command*/, t /*time*/;
    _swix(MIDI_RxCommand, _IN(0) | _OUTR(0,1), -1, &c, &t);

    // return false if no event is pending
    if (c == 0) return MidiEvent();

    return MidiEvent(MidiCommand((c>>4)&0xf0, c&0xf, (c>>28)&0xf,
                                 (c>>8)&0x7f, (c>>16)&0x7f),
                     msToClock(t));
    remoteControl(e);
    return e;
}


void RiscOsMidiScheduler::impl_tx(MidiEvent e)
{

    if (e.event.data.status == MidiCommand_Invalid) return;
    std::cout << "RiscOsMidiScheduler::tx - " << e.event.time << ": "
              << e.event.data.status << " on (" << e.event.data.channel
              << "," << e.event.data.port << ") with " << e.event.data.data1
              << ", " << e.event.data.data2 << "\n";
    int command = mc.channel
                + (mc.status << 4)
                + (mc.data1  << 8)
                + (mc.data2  << 16)
                + (mc.port   << 28)
    _swix(MIDI_TxCommand, _INR(0,1), command, clockToMs(time));
}


void RiscOSMidiScheduler::impl_txSysEx(int port,
                                       const unsigned char *data, size_t size)
{
    std::cout << "RiscOsMidiScheduler::txByte - (now) " << byte << "\n";
    _swix(MIDI_TxByte, _IN(0), MidiSystem_SysExStart); // XXX port
    for (size_t n = 0; n < size; n++)
    {
        _swix(MIDI_TxByte, _IN(0), data[n]);
    }
    _swix(MIDI_TxByte, _IN(0), MidiSystem_SysExStop);
}