The code is kind of long but I can try to give a look... Im reading opcodes and operands from a file.
So at the end of this if tree I have created an array "ex_data[i]" with a size dependant on the opcoade read from the file.
Code:
if (opcode == 0) {
f_dx(&numbers, operand);
}
else if (opcode == 1) {
f_dy(d, &numbers, operand);
}
else if (opcode == 2) {
f_dt(d, &numbers, operand);
}
else if(opcode == 3){
int hold;
//dectect extended dx dy dt
if ( ((operand & 0x30) >> 4) != 0 ) {
hold = ((operand & 0x30) >> 4);
//convert 3 to 4
if (hold == 3) hold = 4;
//printf("%d\n", hold);
unsigned char ex_data[hold];
//get bytes
for (int i = 0; i < hold; i++) {
c = fgetc(in);
ex_data[i] = c;
printf("%02x\n", ex_data[i]);
}
}
ex_handler(operand, &numbers);
}
I need to pass this array to the function ex_handeler at the bottom so it can be processed. I havent written the code yet... I have just done a little house keeping.
here is the ex_handeler function:
Code:
void ex_handler(int op, Numbers *numbers){
//check for pen
if ( ((op & 0x30) >> 4) == 0 && ((op & 0x0c) >> 2) == 0){
//printf("Pen Working\n");
f_pen(numbers);
}
//printf("ex workng\n");
}