(x, y, width, height, sock, display, depth)
| 22 | } |
| 23 | |
| 24 | decodeRect(x, y, width, height, sock, display, depth) { |
| 25 | if (this._length === 0) { |
| 26 | if (sock.rQwait("ZLib data length", 4)) { |
| 27 | return false; |
| 28 | } |
| 29 | this._length = sock.rQshift32(); |
| 30 | } |
| 31 | if (sock.rQwait("Zlib data", this._length)) { |
| 32 | return false; |
| 33 | } |
| 34 | |
| 35 | const data = sock.rQshiftBytes(this._length, false); |
| 36 | |
| 37 | this._inflator.setInput(data); |
| 38 | |
| 39 | for (let ty = y; ty < y + height; ty += ZRLE_TILE_HEIGHT) { |
| 40 | let th = Math.min(ZRLE_TILE_HEIGHT, y + height - ty); |
| 41 | |
| 42 | for (let tx = x; tx < x + width; tx += ZRLE_TILE_WIDTH) { |
| 43 | let tw = Math.min(ZRLE_TILE_WIDTH, x + width - tx); |
| 44 | |
| 45 | const tileSize = tw * th; |
| 46 | const subencoding = this._inflator.inflate(1)[0]; |
| 47 | if (subencoding === 0) { |
| 48 | // raw data |
| 49 | const data = this._readPixels(tileSize); |
| 50 | display.blitImage(tx, ty, tw, th, data, 0, false); |
| 51 | } else if (subencoding === 1) { |
| 52 | // solid |
| 53 | const background = this._readPixels(1); |
| 54 | display.fillRect(tx, ty, tw, th, [background[0], background[1], background[2]]); |
| 55 | } else if (subencoding >= 2 && subencoding <= 16) { |
| 56 | const data = this._decodePaletteTile(subencoding, tileSize, tw, th); |
| 57 | display.blitImage(tx, ty, tw, th, data, 0, false); |
| 58 | } else if (subencoding === 128) { |
| 59 | const data = this._decodeRLETile(tileSize); |
| 60 | display.blitImage(tx, ty, tw, th, data, 0, false); |
| 61 | } else if (subencoding >= 130 && subencoding <= 255) { |
| 62 | const data = this._decodeRLEPaletteTile(subencoding - 128, tileSize); |
| 63 | display.blitImage(tx, ty, tw, th, data, 0, false); |
| 64 | } else { |
| 65 | throw new Error('Unknown subencoding: ' + subencoding); |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | this._length = 0; |
| 70 | return true; |
| 71 | } |
| 72 | |
| 73 | _getBitsPerPixelInPalette(paletteSize) { |
| 74 | if (paletteSize <= 2) { |
nothing calls this directly
no test coverage detected