| 1 | #include "VramTiledView.h" |
| 2 | #include "VDPDataStore.h" |
| 3 | #include "Convert.h" |
| 4 | #include "ranges.h" |
| 5 | #include <QPainter> |
| 6 | #include <algorithm> |
| 7 | #include <cstdio> |
| 8 | |
| 9 | VramTiledView::VramTiledView(QWidget* parent) |
| 10 | : QWidget(parent) |
| 11 | , image(512, 512, QImage::Format_RGB32) |
| 12 | { |
| 13 | ranges::fill(msxPalette, qRgb(80, 80, 80)); |
| 14 | setZoom(1.0f); |
| 15 | |
| 16 | // Mouse update events when mouse is moved over the image, Quibus likes this |
| 17 | // better than my preferred click-on-the-image. |
| 18 | setMouseTracking(true); |
| 19 | } |
| 20 | |
| 21 | void VramTiledView::setZoom(float zoom) |
| 22 | { |
| 23 | zoomFactor = std::max(1.0f, zoom); |
| 24 | if (vramBase) { |
| 25 | const auto* regs = VDPDataStore::instance().getRegsPointer(); |
| 26 | lines = (forcedScreenRows != 0.0f) ? int(8 * forcedScreenRows) : (regs[9] & 128 ? 212 : 192); |
| 27 | } else { |
| 28 | lines = (forcedScreenRows != 0.0f) ? int(8 * forcedScreenRows) : 192; |
| 29 | } |
| 30 | int imageW = screenMode == 0 ? 40 * 6 * 2 |
| 31 | : screenMode == 80 ? 80 * 6 |
| 32 | : 512; |
| 33 | setFixedSize(int(zoomFactor * float(imageW)), |
| 34 | int(zoomFactor * float(lines) * 2)); |
| 35 | update(); |
| 36 | } |
| 37 | |
| 38 | void VramTiledView::decode() |
| 39 | { |
| 40 | if (!vramBase) return; |
| 41 | |
| 42 | //also everytime we decode we adjust height of widget to the correct screenheight |
| 43 | const auto* regs = VDPDataStore::instance().getRegsPointer(); |
| 44 | lines = (forcedScreenRows != 0.0f) ? int(8 * forcedScreenRows) : (regs[9] & 128 ? 212 : 192); |
| 45 | int imageW = screenMode == 0 ? 40 * 6 * 2 |
| 46 | : screenMode == 80 ? 80 * 6 |
| 47 | : 512; |
| 48 | setFixedSize(int(zoomFactor * float(imageW)), |
| 49 | int(zoomFactor * float(lines) * 2)); |
| 50 | |
| 51 | image.fill(Qt::gray); |
| 52 | |
| 53 | switch (tableToShow) { |
| 54 | case 0: |
| 55 | decodePatternTable(); |
| 56 | break; |
| 57 | case 1: |
| 58 | decodeNameTable(); |
| 59 | break; |
| 60 | case 2: |
| 61 | decodeNameTable(); |
| 62 | overLayNameTable(); |
| 63 | break; |
| 64 | } |
| 65 | |
| 66 | horiStep = charWidth * ((screenMode == 80 && tableToShow > 0) ? 1 : 2); |
| 67 | |
| 68 | if (drawGrid && screenMode != 255) { |
| 69 | QPainter qp(&image); |
| 70 | qp.setPen(QColor(55, 55, 55, 128)); |
| 71 | for (int yy = 15; yy < 16 * screenHeight; yy += 16) { |
| 72 | qp.drawLine(0, yy, horiStep * screenWidth - 1, yy); |
| 73 | } |
| 74 | for (int xx = horiStep - 1; xx < horiStep * screenWidth; xx += horiStep) { |
| 75 | qp.drawLine(xx, 0, xx, 16*screenHeight - 1); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | pixImage = QPixmap::fromImage(image); |
| 80 | update(); |
| 81 | } |
| 82 | |
| 83 | void VramTiledView::decodePalette() |
| 84 | { |
| 85 | if (!palette) return; |
| 86 | //printf("VramTiledView::decodePallet palletpointer %p \n", palette); |
| 87 | |
| 88 | for (int i = 0; i < 16; ++i) { |
| 89 | int r = (palette[2 * i + 0] & 0xf0) >> 4; |
| 90 | int b = (palette[2 * i + 0] & 0x0f); |
| 91 | int g = (palette[2 * i + 1] & 0x0f); |
| 92 | |
| 93 | auto scale = [](int x) { return (x >> 1) | (x << 2) | (x << 5); }; |
| 94 | msxPalette[i] = qRgb(scale(r), scale(g), scale(b)); |
| 95 | //printf("VramTiledView::decodePallet color %d => r %d g %d b %d \n", i, r, g, b); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | void VramTiledView::decodePatternTable() |
| 100 | { |
| 101 | screenWidth = 32; |
| 102 | screenHeight = 8; // 32 * 8 => 256 chars by default |
| 103 | charWidth = 8; |
| 104 | |
| 105 | switch (screenMode) { |
| 106 | case 0: |
| 107 | case 80: |
| 108 | charWidth = 6; |
| 109 | decodePatternTableRegularChars(); |
| 110 | break; |
| 111 | case 2: |
| 112 | case 4: |
| 113 | screenHeight = 24; |
| 114 | [[fallthrough]]; |
| 115 | case 1: |
| 116 | decodePatternTableRegularChars(); |
| 117 | break; |
| 118 | case 3: |
| 119 | // Since patterns in multicolor are 2 color nibles they act more like a 'colortable' |
| 120 | // and to avoid too much special case in the generic decodePatternTableRegularChars() |
| 121 | // this has been seperated in a single method. |
| 122 | decodePatternTableMultiColor(); |
| 123 | return; |
| 124 | default: |
| 125 | warningImage(); |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | void VramTiledView::warningImage() |
| 130 | { |
| 131 | QPainter qp(&image); |
| 132 | qp.setPen(Qt::black); |
| 133 | qp.drawText(16, 16, "Not a tile based screenmode! Please use the 'Bitmapped VRAM' viewer."); |
| 134 | } |
| 135 | |
| 136 | void VramTiledView::decodeNameTable() |
| 137 | { |
| 138 | const auto* regs = VDPDataStore::instance().getRegsPointer(); |
| 139 | |
| 140 | screenWidth = 32; |
| 141 | charWidth = 8; |
| 142 | screenHeight = (forcedScreenRows != 0.0f) ? int(forcedScreenRows + 0.5) : (regs[9] & 128 ? 27 : 24); // Check LN bit of vdp reg #9 to determine screenheight |
| 143 | |
| 144 | switch (screenMode) { |
| 145 | case 0: |
| 146 | screenWidth = 40; |
| 147 | charWidth = 6; |
| 148 | decodeNameTableRegularChars(); |
| 149 | break; |
| 150 | case 80: |
| 151 | screenWidth = 80; |
| 152 | charWidth = 6; |
| 153 | decodeNameTableRegularChars(); |
| 154 | break; |
| 155 | case 4: |
| 156 | case 1: |
| 157 | case 2: |
| 158 | decodeNameTableRegularChars(); |
| 159 | break; |
| 160 | case 3: |
| 161 | decodeNameTableMultiColor(); |
| 162 | return; |
| 163 | default: |
| 164 | warningImage(); |
| 165 | } |
| 166 | |
| 167 | } |
| 168 | |
| 169 | void VramTiledView::overLayNameTable() |
| 170 | { |
| 171 | if (screenMode == 255) return; // No overlay if not tile based! |
| 172 | |
| 173 | // screenwidth, screenheight, charwidth are all calculated by decodeNameTable already... |
| 174 | |
| 175 | // Now draw the char numbers from the overlay over all the chars |
| 176 | QImage overlayimage(":/overlay.png"); |
| 177 | QPainter qp(&image); |
| 178 | int pWidth = screenMode != 80 ? 2 : 1; |
| 179 | |
| 180 | for (int charY = 0; charY < screenHeight; ++charY) { |
| 181 | for (int charX = 0; charX < screenWidth; ++charX) { |
| 182 | int ch = vramBase[nameTableAddress + charX + charY * screenWidth]; |
| 183 | int x = 6 * ((ch >> 4) & 15); |
| 184 | int y = (ch == highlightChar ? 8 : 0); // White letters or red variant if highlighted |
| 185 | qp.drawImage(pWidth * charX * charWidth, 16 * charY, overlayimage, x, y, 5, 8); |
| 186 | x = 6 * (ch & 15); |
| 187 | if (screenMode != 80) { |
| 188 | qp.drawImage(pWidth * charX * charWidth + 6, charY * 16, overlayimage, x, y, 5, 8); // draw to the right |
| 189 | } else { |
| 190 | qp.drawImage(pWidth * charX * charWidth, charY * 16 + 7, overlayimage, x, y, 5, 8); // draw below |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | void VramTiledView::setPixel1x2(int x, int y, QRgb c) |
| 197 | { |
| 198 | image.setPixel(x, 2 * y + 0, c); |
| 199 | image.setPixel(x, 2 * y + 1, c); |
| 200 | } |
| 201 | |
| 202 | void VramTiledView::setPixel2x2(int x, int y, QRgb c) |
| 203 | { |
| 204 | image.setPixel(2 * x + 0, 2 * y + 0, c); |
| 205 | image.setPixel(2 * x + 1, 2 * y + 0, c); |
| 206 | image.setPixel(2 * x + 0, 2 * y + 1, c); |
| 207 | image.setPixel(2 * x + 1, 2 * y + 1, c); |
| 208 | } |
| 209 | |
| 210 | |
| 211 | QRgb VramTiledView::getColor(int c) |
| 212 | { |
| 213 | // TODO do we need to look at the TP bit??? |
| 214 | return msxPalette[c ? c : (tpBit ? 0 : borderColor)]; |
| 215 | } |
| 216 | |
| 217 | const uint8_t *VramTiledView::getPaletteSource() const |
| 218 | { |
| 219 | return palette; |
| 220 | } |
| 221 | |
| 222 | int VramTiledView::getScreenMode() const |
| 223 | { |
| 224 | return screenMode; |
| 225 | } |
| 226 | |
| 227 | void VramTiledView::setHighlightChar(int value) |
| 228 | { |
| 229 | if (highlightChar == value) return; |
| 230 | |
| 231 | highlightChar = value; |
| 232 | decode(); |
| 233 | |
| 234 | if (vramBase == nullptr || value < 0 || value > 255) return; |
| 235 | |
| 236 | // Count how many 'value'-characters there are in the nametable |
| 237 | int count = 0; |
| 238 | for (int i = 0; i < screenHeight * screenWidth; ++i) { |
| 239 | if (vramBase[nameTableAddress + i] == value) { |
| 240 | count++; |
| 241 | } |
| 242 | } |
| 243 | emit highlightCount(value & 255, count); |
| 244 | } |
| 245 | |
| 246 | void VramTiledView::setForcedScreenRows(float value) |
| 247 | { |
| 248 | if (forcedScreenRows == value) return; |
| 249 | |
| 250 | forcedScreenRows = value; |
| 251 | setZoom(zoomFactor); // Redo fixed size of widget |
| 252 | decode(); |
| 253 | } |
| 254 | |
| 255 | void VramTiledView::setUseBlink(bool value) |
| 256 | { |
| 257 | if (useBlink == value) return; |
| 258 | useBlink = value; |
| 259 | decode(); |
| 260 | } |
| 261 | |
| 262 | void VramTiledView::setTpBit(bool value) |
| 263 | { |
| 264 | if (tpBit == value) return; |
| 265 | tpBit = value; |
| 266 | decode(); |
| 267 | } |
| 268 | |
| 269 | void VramTiledView::decodePatternTableRegularChars() |
| 270 | { |
| 271 | for (int charY = 0; charY < screenHeight; ++charY) { |
| 272 | for (int charX = 0; charX < screenWidth; ++charX) { |
| 273 | drawCharAt(charX + charY * screenWidth, charX, charY); |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | void VramTiledView::decodePatternTableMultiColor() |
| 279 | { |
| 280 | for (int charY = 0; charY < screenHeight; ++charY) { |
| 281 | for (int charX = 0; charX < screenWidth; ++charX) { |
| 282 | for (int charRow = 0; charRow < 8; ++charRow) { |
| 283 | int ch = vramBase[patternTableAddress + 8 * (charX + charY * screenWidth) + charRow]; |
| 284 | QRgb col = getColor(ch >> 4); |
| 285 | setPixel2x2(8 * charX + 0, 8 * charY + charRow, col); |
| 286 | setPixel2x2(8 * charX + 1, 8 * charY + charRow, col); |
| 287 | setPixel2x2(8 * charX + 2, 8 * charY + charRow, col); |
| 288 | setPixel2x2(8 * charX + 3, 8 * charY + charRow, col); |
| 289 | col = getColor(ch & 15); |
| 290 | setPixel2x2(8 * charX + 4, 8 * charY + charRow, col); |
| 291 | setPixel2x2(8 * charX + 5, 8 * charY + charRow, col); |
| 292 | setPixel2x2(8 * charX + 6, 8 * charY + charRow, col); |
| 293 | setPixel2x2(8 * charX + 7, 8 * charY + charRow, col); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | void VramTiledView::decodeNameTableRegularChars() |
| 300 | { |
| 301 | for (int charY = 0; charY < screenHeight; ++charY) { |
| 302 | for (int charX = 0; charX < screenWidth; ++charX) { |
| 303 | int ch = vramBase[nameTableAddress + charX + charY * screenWidth]; |
| 304 | // special case screen2/screen4a since they have 3*256 chars |
| 305 | if (charY > 7 && (screenMode == 2 || screenMode == 4)) { |
| 306 | ch += 256 * (charY >> 3); |
| 307 | } |
| 308 | drawCharAt(ch, charX, charY); |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | void VramTiledView::decodeNameTableMultiColor() |
| 314 | { |
| 315 | for (int charY = 0; charY < screenHeight; ++charY) { |
| 316 | for (int charX = 0; charX < screenWidth; ++charX) { |
| 317 | uint8_t ch = vramBase[nameTableAddress + charX + charY * screenWidth]; |
| 318 | for (int charRow = 0; charRow < 8; ++charRow) { |
| 319 | uint8_t patternByte = vramBase[patternTableAddress + 8 * ch + 2 * (charY & 3) + (charRow >> 2)]; |
| 320 | QRgb col = getColor(patternByte >> 4); |
| 321 | setPixel2x2(8 * charX + 0, 8 * charY + charRow, col); |
| 322 | setPixel2x2(8 * charX + 1, 8 * charY + charRow, col); |
| 323 | setPixel2x2(8 * charX + 2, 8 * charY + charRow, col); |
| 324 | setPixel2x2(8 * charX + 3, 8 * charY + charRow, col); |
| 325 | col = getColor(patternByte & 15); |
| 326 | setPixel2x2(8 * charX + 4, 8 * charY + charRow, col); |
| 327 | setPixel2x2(8 * charX + 5, 8 * charY + charRow, col); |
| 328 | setPixel2x2(8 * charX + 6, 8 * charY + charRow, col); |
| 329 | setPixel2x2(8 * charX + 7, 8 * charY + charRow, col); |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | uint8_t VramTiledView::getCharColorByte(int character, int x, int y, int row) |
| 336 | { |
| 337 | const auto* regs = VDPDataStore::instance().getRegsPointer(); |
| 338 | uint8_t colorByte = regs[7]; |
| 339 | switch (screenMode) { |
| 340 | case 0: |
| 341 | break; |
| 342 | case 80: |
| 343 | // If blink bit set then show alternate colors |
| 344 | if (useBlink && (tableToShow > 0) && |
| 345 | (vramBase[colorTableAddress + (x >> 3) + 10 * y] & (1 << (7 - (7 & x))))) { |
| 346 | colorByte = regs[12]; |
| 347 | } |
| 348 | break; |
| 349 | case 2: |
| 350 | case 4: |
| 351 | colorByte = vramBase[colorTableAddress + 8 * character + row]; |
| 352 | break; |
| 353 | case 1: |
| 354 | colorByte = vramBase[colorTableAddress + (character >> 3)]; |
| 355 | break; |
| 356 | case 3: |
| 357 | //decodePatternTableMultiColor(); |
| 358 | colorByte = 0xf0; |
| 359 | } |
| 360 | return colorByte; |
| 361 | } |
| 362 | |
| 363 | void VramTiledView::drawCharAt(int character, int x, int y) |
| 364 | { |
| 365 | for (int charRow = 0; charRow < 8; ++charRow) { |
| 366 | uint8_t patternByte = vramBase[patternTableAddress + 8 * character + charRow]; |
| 367 | for (int charCol = 0; charCol < charWidth; ++charCol) { |
| 368 | uint8_t mask = 1 << (7 - charCol); |
| 369 | uint8_t colors = getCharColorByte(character, x, y, charRow); |
| 370 | QRgb col = getColor(patternByte & mask ? (colors >> 4) : (colors & 15)); |
| 371 | if (screenMode == 80 && tableToShow > 0) { |
| 372 | setPixel1x2(x * charWidth + charCol, 8 * y + charRow, col); |
| 373 | } else { |
| 374 | setPixel2x2(x * charWidth + charCol, 8 * y + charRow, col); |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | void VramTiledView::drawCharAtImage(int character, int x, int y, QImage& image) |
| 381 | { |
| 382 | QPainter qp(&image); |
| 383 | qp.setPen(Qt::NoPen); |
| 384 | for (int charRow = 0; charRow < 8; ++charRow) { |
| 385 | uint8_t patternByte = vramBase[patternTableAddress + 8 * character + charRow]; |
| 386 | for (int charCol = 0; charCol < 8; ++charCol) { // Always draw the 8 bits even for screen 0 |
| 387 | uint8_t mask = 1 << (7 - charCol); |
| 388 | uint8_t colors = getCharColorByte(character, x, y, charRow); |
| 389 | QRgb col = getColor(patternByte & mask ? (colors >> 4) : (colors & 15)); |
| 390 | // local setPixel4x4 routine :-) |
| 391 | qp.setBrush(QColor(col)); |
| 392 | qp.drawRect(4 * charCol, 4 * charRow, 4, 4); |
| 393 | } |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | void VramTiledView::setTabletoShow(int value) |
| 398 | { |
| 399 | if (tableToShow == value) return; |
| 400 | tableToShow = value; |
| 401 | decode(); |
| 402 | } |
| 403 | |
| 404 | void VramTiledView::setDrawGrid(bool value) |
| 405 | { |
| 406 | if (drawGrid == value) return; |
| 407 | drawGrid = value; |
| 408 | decode(); |
| 409 | } |
| 410 | |
| 411 | unsigned VramTiledView::getColorTableAddress() const |
| 412 | { |
| 413 | return colorTableAddress; |
| 414 | } |
| 415 | |
| 416 | unsigned VramTiledView::getPatternTableAddress() const |
| 417 | { |
| 418 | return patternTableAddress; |
| 419 | } |
| 420 | |
| 421 | unsigned VramTiledView::getNameTableAddress() const |
| 422 | { |
| 423 | return nameTableAddress; |
| 424 | } |
| 425 | |
| 426 | void VramTiledView::paintEvent(QPaintEvent* /*event*/) |
| 427 | { |
| 428 | QRect srcRect(0, 0, 512, 2 * lines); |
| 429 | QRect dstRect(0, 0, int(512 * zoomFactor), int(2 * float(lines) * zoomFactor)); |
| 430 | QPainter qp(this); |
| 431 | //qp.drawImage(rect(), image, srcRect); |
| 432 | qp.drawPixmap(dstRect, pixImage, srcRect); |
| 433 | } |
| 434 | |
| 435 | void VramTiledView::refresh() |
| 436 | { |
| 437 | decodePalette(); |
| 438 | decode(); |
| 439 | } |
| 440 | |
| 441 | QString VramTiledView::byteAsPattern(uint8_t byte) |
| 442 | { |
| 443 | QString val; |
| 444 | for (int i = 7; i >= 0; --i) { |
| 445 | val.append(QChar(byte & (1 << i) ? '1' : '.')); |
| 446 | } |
| 447 | val.append(QString(" %1").arg(hexValue(byte, 2))); |
| 448 | return val; |
| 449 | } |
| 450 | |
| 451 | QString VramTiledView::textInfo(int x, int y, int character) |
| 452 | { |
| 453 | QString info("Generator Data Color data\n"); |
| 454 | |
| 455 | // Now the initial color data to be displayed |
| 456 | const auto* regs = VDPDataStore::instance().getRegsPointer(); |
| 457 | QString colordata = QString("- VDP reg 7 is %1").arg(hexValue(regs[7], 2)); |
| 458 | // If blink bit set then show alternate colors |
| 459 | if (screenMode == 80 && useBlink && (tableToShow > 0) && |
| 460 | (vramBase[colorTableAddress + (x >> 3) + 10 * y] & (1 << (7 - (7 & x))))) |
| 461 | { |
| 462 | colordata = QString("- VDP reg 12 is %1").arg(hexValue(regs[12], 2)); |
| 463 | } else if (screenMode == 1) { |
| 464 | colordata = QString("- %1: %2").arg( |
| 465 | hexValue(colorTableAddress + (character >> 3), 4), |
| 466 | hexValue(vramBase[colorTableAddress+(character >> 3)], 2)); |
| 467 | } else if (screenMode == 3) { |
| 468 | colordata = QString("- not used"); |
| 469 | } |
| 470 | |
| 471 | // Now build the text |
| 472 | for (int charRow = 0; charRow < 8; ++charRow) { |
| 473 | int addr = patternTableAddress + 8 * character + charRow; |
| 474 | // Color data changes per line for screen 2 and 4 |
| 475 | if (screenMode == 2 || screenMode == 4) { |
| 476 | colordata = QString(" %1: %2").arg( |
| 477 | hexValue(colorTableAddress + 8 * character + charRow, 4), |
| 478 | hexValue(vramBase[colorTableAddress + 8 * character + charRow], 2)); |
| 479 | } |
| 480 | |
| 481 | info.append(QString("%1: %2 %3\n").arg( |
| 482 | hexValue(addr, 4), |
| 483 | byteAsPattern(vramBase[addr]), |
| 484 | colordata)); |
| 485 | colordata.clear(); |
| 486 | } |
| 487 | return info; |
| 488 | } |
| 489 | |
| 490 | void VramTiledView::mousePressEvent(QMouseEvent* e) |
| 491 | { |
| 492 | if (auto i = infoFromMouseEvent(e)) { |
| 493 | emit imageClicked(i->x, i->y, i->character, textInfo(i->x, i->y, i->character)); |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | void VramTiledView::mouseMoveEvent(QMouseEvent* e) |
| 498 | { |
| 499 | if (auto i = infoFromMouseEvent(e)) { |
| 500 | emit imageHovered(i->x, i->y, i->character); |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | std::optional<VramTiledView::MouseEventInfo> VramTiledView::infoFromMouseEvent(QMouseEvent* e) |
| 505 | { |
| 506 | if (!vramBase) return {}; |
| 507 | |
| 508 | // I see negative y-coords sometimes, so for safety clip the coords |
| 509 | int x = std::clamp(int(float(e->x()) / zoomFactor), 0, 511); |
| 510 | int y = std::clamp(int(float(e->y()) / zoomFactor) / 2, 0, 255); |
| 511 | if (x >= horiStep * screenWidth) return {}; |
| 512 | if (y >= 8 * screenHeight) return {}; |
| 513 | |
| 514 | x = int(x / horiStep); |
| 515 | y = int(y / 8); |
| 516 | int character = 0; |
| 517 | switch (tableToShow) { |
| 518 | case 0: |
| 519 | character = x + y * screenWidth; |
| 520 | if (!(screenMode == 2 || screenMode == 4)) { |
| 521 | character &= 255; |
| 522 | } |
| 523 | break; |
| 524 | case 1: |
| 525 | case 2: |
| 526 | character = vramBase[nameTableAddress + x + y * screenWidth]; |
| 527 | if (screenMode == 2 || screenMode == 4) { |
| 528 | character += 256 * int(y / 8); |
| 529 | } |
| 530 | break; |
| 531 | } |
| 532 | return MouseEventInfo{x, y, character}; |
| 533 | } |
| 534 | |
| 535 | void VramTiledView::setBorderColor(int value) |
| 536 | { |
| 537 | borderColor = std::clamp(value, 0, 15); |
| 538 | refresh(); |
| 539 | } |
| 540 | |
| 541 | void VramTiledView::setScreenMode(int mode) |
| 542 | { |
| 543 | screenMode = mode; |
| 544 | decode(); |
| 545 | } |
| 546 | |
| 547 | void VramTiledView::setVramSource(const uint8_t* adr) |
| 548 | { |
| 549 | vramBase = adr; |
| 550 | refresh(); |
| 551 | } |
| 552 | |
| 553 | void VramTiledView::setNameTableAddress(int adr) |
| 554 | { |
| 555 | nameTableAddress = adr; |
| 556 | decode(); |
| 557 | } |
| 558 | |
| 559 | void VramTiledView::setPatternTableAddress(int adr) |
| 560 | { |
| 561 | patternTableAddress = adr; |
| 562 | decode(); |
| 563 | } |
| 564 | |
| 565 | void VramTiledView::setColorTableAddress(int adr) |
| 566 | { |
| 567 | colorTableAddress = adr; |
| 568 | decode(); |
| 569 | } |
| 570 | |
| 571 | void VramTiledView::setPaletteSource(const uint8_t* adr) |
| 572 | { |
| 573 | if (palette == adr) return; |
| 574 | palette = adr; |
| 575 | refresh(); |
| 576 | } |