| 1005 | static const byte actorColorsMMC64[] = { |
| 1006 | 0, 7, 2, 6, 9, 1, 3, 7, 7, 1, 1, 9, 1, 4, 5, 5, |
| 1007 | 4, 1, 0, 5, 4, 2, 2, 7, 7, 0, 6, 6, 6, 6, 6, 6 |
| 1008 | }; |
| 1009 | |
| 1011 | // TODO: |
| 1012 | // C64 seems to have at most 8 limbs |
| 1013 | // if you disable this you will get into the debugger |
| 1014 | // when the meteor should be displayed |
| 1015 | // maybe a bug? check this |
| 1016 | if (limb >= 8) |
| 1017 | return 0; |
| 1018 | |
| 1019 | if (limb == 0) { |
| 1020 | _draw_top = 200; |
| 1021 | _draw_bottom = 0; |
| 1022 | } |
| 1023 | |
| 1024 | // TODO: |
| 1025 | // get out how animations are handled |
| 1026 | byte unk1 = (_loaded._animCmds + (/* walking(0) or idle(1) */1*32) + newDirToOldDir(a->getFacing()) * 8)[limb]; |
| 1027 | byte unk2 = _loaded._frameOffsets[_loaded._frameOffsets[limb] + (unk1 & 0x7f)]; |
| 1028 | bool flipped = newDirToOldDir(a->getFacing()) == 0; |
| 1029 | |
| 1030 | byte p1 = _loaded._frameOffsets[unk2]; |
| 1031 | byte temp1 = _loaded._baseptr[p1]; |
| 1032 | byte temp2 = temp1 + _loaded._dataOffsets[4]; |
| 1033 | int offL = _loaded._baseptr[temp1 + 2]; |
| 1034 | int offH = _loaded._baseptr[temp2]; |
| 1035 | int off = (offH << 8) + offL; |
| 1036 | |
| 1037 | const byte *data = _loaded._baseptr + off; |
| 1038 | const byte actorColors[] = { |
| 1039 | 0, 10, actorColorsMMC64[_actorID], 0 |
| 1040 | }; |
| 1041 | |
| 1042 | int width = *data++; |
| 1043 | int height = *data++; |
| 1044 | int offsetX = *data++; |
| 1045 | int offsetY = *data++; |
| 1046 | // int byte5 = *data++; |
| 1047 | // int byte6 = *data++; |
| 1048 | // debug(3, "byte5: %d", byte5); |
| 1049 | // debug(3, "byte6: %d", byte6); |
| 1050 | data += 2; |
| 1051 | |
| 1052 | if (!width || !height) |
| 1053 | return 0; |
| 1054 | |
| 1055 | int xpos = 0; |
| 1056 | int ypos = _loaded._maxHeight - offsetY; |
| 1057 | |
| 1058 | if (flipped) { |
| 1059 | if (offsetX) |
| 1060 | xpos -= (offsetX-1) * 8; |
| 1061 | } else { |
| 1062 | xpos += offsetX * 8; |
| 1063 | } |
| 1064 | |
| 1065 | // + 4 could be commented, because maybe the _actorX position is |
| 1066 | // wrong, I looked at the scumm-c64 interpreter by lloyd |
| 1067 | // and there Bernhard is directly on the right in the intro |
| 1068 | // but here in ScummVM he is 4 pixel left of the other position. |
| 1069 | xpos += _actorX - (a->_width / 2) + 4; |
| 1070 | ypos += _actorY - _loaded._maxHeight; |
| 1071 | |
| 1072 | if (flipped) { |
| 1073 | for (int y = 0; y < height; ++y) { |
| 1074 | for (int x = 0; x < width; ++x) { |
| 1075 | byte c = data[y*width+x]; |
| 1076 | byte b, d; |
| 1077 | byte *dest = &(((byte*)_out.pixels)[((y + ypos) * _out.pitch) + ((width - x) * 8) + xpos - 1]); |
| 1078 | dest += 8; |
| 1079 | |
| 1080 | for (int i = 6; i >= 0; i -= 2) { |
| 1081 | if ((d = (c >> i) & 0x03)) { |
| 1082 | b = actorColors[d]; |
| 1083 | *dest-- = b; |
| 1084 | *dest-- = b; |
| 1085 | continue; |
| 1086 | } |
| 1087 | dest -= 2; |
| 1088 | } |
| 1089 | } |
| 1090 | } |
| 1091 | } else { |
| 1092 | for (int y = 0; y < height; ++y) { |
| 1093 | for (int x = 0; x < width; ++x) { |
| 1094 | byte c = data[y*width+x]; |
| 1095 | byte b, d; |
| 1096 | byte *dest = &(((byte*)_out.pixels)[((y + ypos) * _out.pitch) + ((x * 8) + xpos)]); |
| 1097 | |
| 1098 | for (int i = 6; i >= 0; i -= 2) { |
| 1099 | if ((d = (c >> i) & 0x03)) { |
| 1100 | b = actorColors[d]; |
| 1101 | *dest++ = b; |
| 1102 | *dest++ = b; |
| 1103 | continue; |
| 1104 | } |
| 1105 | dest += 2; |
| 1106 | } |
| 1107 | } |
| 1108 | } |
| 1109 | } |
| 1110 | |
| 1111 | _draw_top = MIN(_draw_top, ypos); |
| 1112 | _draw_bottom = MAX(_draw_bottom, ypos+height); |
| 1113 | // if +4 above is NOT commented here +(flipped ? 4 : 0) can be commented out |
| 1114 | // and other way round |
| 1115 | _vm->markRectAsDirty(kMainVirtScreen, xpos, xpos+(width*8)/*+(flipped ? 4 : 0)*/, ypos, ypos+height, _actorID); |
| 1116 | |
1013 | | static const byte actorColorsMMC64[] = { |
1014 | | 0, 7, 2, 6, 9, 1, 3, 7, 7, 1, 1, 9, 1, 4, 5, 5, |
1015 | | 4, 1, 0, 5, 4, 2, 2, 7, 7, 0, 6, 6, 6, 6, 6, 6 |
1016 | | }; |
1017 | | |