-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgalangfcard.h
More file actions
44 lines (38 loc) · 1.46 KB
/
galangfcard.h
File metadata and controls
44 lines (38 loc) · 1.46 KB
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
#ifndef GALANGFCARD_H
#define GALANGFCARD_H
/* DirecTV's F-Card is a Motorola 68HC05 with its opcodes scrambled
* and one bit flipped. This is performed on the input to the
* instruction fetch latch, so it applies to the opcode bytes but not
* to the parameter bytes.
*
* From tv-crypt in 1995, Chris Gerlinsky found this explanation:
* "Only the op-codes are scrambled, not the operands. The bit order
* (MSB to LSB) is 76453012. Then the opcode is xored with 10000000b"
*
* We'll implement this by inheriting the standard 6805 instructions,
* then performing the flips and reordering in the constructor after
* calling the patent's 6805 constructor.
*
* We also override the rawencode and rawdecode methods, which is necessary
* for those few opcodes that contain a bitfield parameter.
*/
#include "galang6805.h"
class GALangFCard : public GALang6805
{
public:
GALangFCard();
//Raw encode function, used by parameters but not opcodes.
void rawencode(uint64_t adr, QByteArray &bytes,
GAParserOperand op,
int inslen,
GAParameter *param,
int64_t vals
) override;
//Raw decode function, used by parameters but not by opcodes.
int64_t rawdecode(GAParameter *param, uint64_t adr,
const char *bytes, int inslen) override;
private:
//Helpfully also an unscrambling function!
uint8_t scramble(uint8_t b);
};
#endif // GALANGFCARD_H