Trying to learn C by making modifications to a large program is going to be a frustrating experience for you.
Prototype your ideas in a completely separate program.
Code:
#include <stdio.h>
#include <string.h>
// if you ever see <?> printed, you did something wrong with your decoding
// it's better than seeing garbage or a crash.
void test ( const char *data ) {
const char *type="<?>" , *type0="<?>" , *type2="<?>" , *type3="<?>" ;
unsigned char name[11] = { 0 }, zxarray[2] = { 0 };
int offset = 0, arr1 = 0, arr2 = 0, arr3 = 0 ;
unsigned int data_adress = 0, zxlength = 0 ;
if (data[0] == 0x00) {
type0 = "headerblock";
}
else {
type0 = "data__block";
}
/* Flag byte is 0x00 for headers */
//if( data[0] != 0x00 ) goto normal;
type3="" ;
/* dat[0] is actualy zxdata[-1] */
data_adress = 256 * data[14+1] + data[13+1] ; /* 16bit value CODE startadres AND basic startadres 'LINE xxxxx' */
zxlength = 256 * data[12+1] + data[11+1] ;
zxarray[1]= data[14+1];
arr1 = zxarray[1]/32 ;
arr2 = arr1 * 32 ;
arr3 = zxarray[1]-arr2 ;
zxarray[2] = 64+arr3 ;
switch( data[1] ) {
case 0x00: type = "Program";
if ( data_adress < 10000 ) {
type2 = " LINE " ; /* line is OR bigger then 9999 OR smaller then 1000 */
type3 = data_adress ; /* only given if AUTOSTART is enabled by value data_adress */
}
break;
case 0x01: type = "Number array" ; type2 = " DATA " ; char *strcat (const char *type2, char *zxarray[2] ); type3 = "() " ; break;
case 0x02: type = "Character array" ; type2 = " DATA " ; char *strcat (const char *type2, char *zxarray[2] ); type3 = "$()" ; break;
case 0x03: type = "Bytes";
type2 = " CODE ";
if (data_adress == 16384 && zxlength == 6912 ) type2 = " SCREEN$ ";
type3 = data_adress;
break;
}
printf("%s | %s: \"%s\" %s %s , %d" ,type0, type, "noname", type2, type3, zxlength );
}
int main ( ) {
// add as many variations of these as you feel you need
const char d1[] = {
0x00, 0x00, 0x00, 0x00, 0x00, // 0 to 4
0x00, 0x00, 0x00, 0x00, 0x00, // 5 to 9
0x00, 0x00, 0x00, 0x00, 0x00, // 10 to 15 - these seem very interesting to you
};
test(d1);
return 0;
}
Focus on getting this to compile and run as a separate standalone console program.
Some thoughts:
zxarray is declared with 2 elements, yet you access [1] and [2] indices.
Arrays start at [0], not [1].
Also, you seem to want to use zxarray as a string (either printing, or with strcat).
But you need to make sure it has a \0 stored in the array.
So if you want two printable characters at [0] and [1], then [2] must be a \0 character.
This implies that you need at least char zxarray[3] to begin with.