This repository has been archived by the owner on Jul 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSystem.h
79 lines (58 loc) · 2.33 KB
/
System.h
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
/*
* System.h
* mindstormssimulation
*
* Created by Torsten Kammer on 26.04.10
* Copyright 2010 RWTH Aachen University All rights reserved.
*
*/
#include <cstdint>
class NetworkInterface;
class VMMemory;
class VFileSystem;
class RXEFile;
class System
{
NetworkInterface *networkInterface;
VMMemory *memory;
VFileSystem* fileSystem;
const RXEFile* file;
uint8_t lowspeedOutputBuffer[16];
int bytesReady;
unsigned ticksSinceStart;
const unsigned ticksPerMillisecond = 100;
// Debug only
static const char *nameForInputPartID(unsigned ID);
static const char *nameForOutputPartID(unsigned ID);
// Communication (mainly with ultrasound sensor)
int CheckLSStatus(int port, int &bytesReady);
int LSRead(int port, uint8_t *buffer, int bufferLength);
int LSWrite(int port, const uint8_t *buffer, int bufferLength, int bytesExpectedBack);
// Sound support: Makes sure no invalid filenames get used.
bool sanitizeFilename(unsigned dstocEntry, char *bufferOut);
// file support
unsigned int FileOpenRead(unsigned param); // 0x00
unsigned int FileOpenWrite(unsigned param); // 0x01
unsigned int FileOpenAppend(unsigned param); // 0x02
unsigned int FileRead(unsigned param); // 0x03
unsigned int FileWrite(unsigned param); // 0x04
unsigned int FileClose(unsigned param); // 0x05
unsigned int FileResolveHandle(unsigned param); // 0x06
unsigned int FileRename(unsigned param); // 0x07
unsigned int FileDelete(unsigned param); // 0x08
public:
System(const RXEFile* file);
void setNetworkInterface(NetworkInterface *anInterface) { networkInterface = anInterface; };
// Called by interpreted code
void syscall(unsigned callID, unsigned paramClusterDSTOCIndex);
void setInputConfiguration(unsigned port, unsigned property, unsigned value);
unsigned getInputConfiguration(unsigned port, unsigned property);
void setOutputConfiguration(unsigned port, unsigned property, unsigned value);
int getOutputConfiguration(unsigned port, unsigned property);
unsigned getTimeSinceStart() const { return ticksSinceStart / ticksPerMillisecond; }
unsigned ticksPerMilis() const { return ticksPerMillisecond; }
void tickIt() { ticksSinceStart += 1; }
void tickIt(unsigned value) { ticksSinceStart += value; }
unsigned getTicks() const { return ticksSinceStart; }
VMMemory* getMemory() { return memory; }
};