Mercurial > hg > dmlib
comparison tools/lib64gfx.c @ 2171:a39bf85308e5
Add helper function dmC64GetOpType() and use it to display operator type
name instead of just number.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 11 Jun 2019 07:38:44 +0300 |
parents | 9a9493809b3a |
children | de88333acc44 |
comparison
equal
deleted
inserted
replaced
2170:7c4c9013e412 | 2171:a39bf85308e5 |
---|---|
901 else | 901 else |
902 return NULL; | 902 return NULL; |
903 } | 903 } |
904 | 904 |
905 | 905 |
906 const char *dmC64GetOpType(const int type) | |
907 { | |
908 static const char *typeNames[DO_LAST] = | |
909 { | |
910 "COPY", | |
911 "SET_MEM", | |
912 "SET_OP", | |
913 "SET_MEM_HI", | |
914 "SET_MEM_LO", | |
915 | |
916 "FUNC", | |
917 "CHAR_CFG", | |
918 }; | |
919 if (type >= 0 && type < DO_LAST) | |
920 return typeNames[type]; | |
921 else | |
922 return "ERROR"; | |
923 } | |
924 | |
925 | |
906 const DMC64MemBlock * dmC64GetOpMemBlock(const DMC64Image *img, const int subject, const int bank) | 926 const DMC64MemBlock * dmC64GetOpMemBlock(const DMC64Image *img, const int subject, const int bank) |
907 { | 927 { |
908 if (bank >= 0 && bank < img->nbanks) | 928 if (bank >= 0 && bank < img->nbanks) |
909 { | 929 { |
910 switch (subject) | 930 switch (subject) |
952 // Is the operation inside the bounds? | 972 // Is the operation inside the bounds? |
953 size = dmC64GetOpSubjectSize(op, fmt->format); | 973 size = dmC64GetOpSubjectSize(op, fmt->format); |
954 if (op->type == DO_COPY && op->offs + size > buf->len + 1) | 974 if (op->type == DO_COPY && op->offs + size > buf->len + 1) |
955 { | 975 { |
956 return dmError(DMERR_INVALID_DATA, | 976 return dmError(DMERR_INVALID_DATA, |
957 "Decode SRC out of bounds, op #%d type=%d, subj=%s, offs=%d ($%04x), " | 977 "Decode SRC out of bounds, op #%d type=%s, subj=%s, offs=%d ($%04x), " |
958 "bank=%d, size=%d ($%04x) @ %d ($%04x)\n", | 978 "bank=%d, size=%d ($%04x) @ %d ($%04x)\n", |
959 i, op->type, subjname, op->offs, op->offs, op->bank, | 979 i, dmC64GetOpType(op->type), subjname, op->offs, op->offs, op->bank, |
960 size, size, buf->len, buf->len); | 980 size, size, buf->len, buf->len); |
961 } | 981 } |
962 | 982 |
963 src = buf->data + op->offs; | 983 src = buf->data + op->offs; |
964 | 984 |
1009 dmMemset(blk->data + op->offs2, op->offs, size); | 1029 dmMemset(blk->data + op->offs2, op->offs, size); |
1010 break; | 1030 break; |
1011 | 1031 |
1012 default: | 1032 default: |
1013 return dmError(DMERR_INTERNAL, | 1033 return dmError(DMERR_INTERNAL, |
1014 "Unhandled op type %d in " | 1034 "Unhandled op type %s in " |
1015 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", | 1035 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", |
1016 op->type, i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); | 1036 dmC64GetOpType(op->type), i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); |
1017 } | 1037 } |
1018 break; | 1038 break; |
1019 | 1039 |
1020 case DS_D020: | 1040 case DS_D020: |
1021 case DS_BGCOL: | 1041 case DS_BGCOL: |
1042 value = *src & 0x0f; | 1062 value = *src & 0x0f; |
1043 break; | 1063 break; |
1044 | 1064 |
1045 default: | 1065 default: |
1046 return dmError(DMERR_INTERNAL, | 1066 return dmError(DMERR_INTERNAL, |
1047 "Unhandled op type %d in " | 1067 "Unhandled op type %s in " |
1048 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", | 1068 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", |
1049 op->type, i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); | 1069 dmC64GetOpType(op->type), i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); |
1050 } | 1070 } |
1051 switch (op->subject) | 1071 switch (op->subject) |
1052 { | 1072 { |
1053 case DS_D020: img->d020 = value; break; | 1073 case DS_D020: img->d020 = value; break; |
1054 case DS_BGCOL: | 1074 case DS_BGCOL: |
1211 // This operation makes no sense in encoding, so do nothing | 1231 // This operation makes no sense in encoding, so do nothing |
1212 break; | 1232 break; |
1213 | 1233 |
1214 default: | 1234 default: |
1215 return dmError(DMERR_INTERNAL, | 1235 return dmError(DMERR_INTERNAL, |
1216 "Unhandled op type %d in " | 1236 "Unhandled op type %s in " |
1217 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", | 1237 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", |
1218 op->type, i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); | 1238 dmC64GetOpType(op->type), i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); |
1219 } | 1239 } |
1220 break; | 1240 break; |
1221 | 1241 |
1222 case DS_D020: | 1242 case DS_D020: |
1223 case DS_BGCOL: | 1243 case DS_BGCOL: |
1253 // Do nothing in this case | 1273 // Do nothing in this case |
1254 break; | 1274 break; |
1255 | 1275 |
1256 default: | 1276 default: |
1257 return dmError(DMERR_INTERNAL, | 1277 return dmError(DMERR_INTERNAL, |
1258 "Unhandled op type %d in " | 1278 "Unhandled op type %s in " |
1259 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", | 1279 "op #%d, offs=%d ($%04x), bank=%d, size=%d ($%04x) @ %d ($%04x)\n", |
1260 op->type, i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); | 1280 dmC64GetOpType(op->type), i, op->offs, op->offs, op->bank, size, size, buf->len, buf->len); |
1261 } | 1281 } |
1262 break; | 1282 break; |
1263 | 1283 |
1264 default: | 1284 default: |
1265 return dmError(DMERR_INTERNAL, | 1285 return dmError(DMERR_INTERNAL, |