forked from travisgoodspeed/maskromtool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgatodecodermsp430.cpp
51 lines (42 loc) · 1.36 KB
/
gatodecodermsp430.cpp
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
#include "gatodecodermsp430.h"
#include <QDebug>
/* This decoder is a work in progress, and it probably doesn't work yet.
*/
GatoDecoderMSP430::GatoDecoderMSP430(){
name="msp430";
}
QByteArray GatoDecoderMSP430::decode(GatoROM *gr){
QByteArray ba;
uint32_t adr=0;
//Q_ASSERT(gr->outputcols==128);
//qDebug()<<gr->outputcols<<"output columns";
if(gr->outputcols!=128)
return ba;
for(unsigned int row=0; row<gr->outputrows; row++){
//Each row contains some 16-bit words.
//This order is probably wrong.
//for(unsigned int word=7; word>0; word--){
for(unsigned int word=0; word<8; word++){
uint32_t w=0;
//for(unsigned int bit=15; bit>0; bit--){
for(unsigned int bit=0; bit<16; bit++){
//qDebug()<<"row"<<row<<"word"<<word<<"bit"<<bit;
GatoBit *gb=gr->outputbits[row][bit*8+word];
if(!gb){
qDebug()<<"Bit"<<bit<<"of row"<<row<<"is null.";
exit(1);
}
//Mark the address and bit.
gb->adr=adr+w/8;
gb->mask=1<<(bit%8);
int b=gb->getVal();
w=(w<<1)|b;
}
ba.append(w&0xFF);
adr++;
ba.append((w>>8)&0xFF);
adr++;
}
}
return ba;
}