aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2011-07-13 20:42:30 +1000
committerPaul Gilbert2011-07-13 20:42:30 +1000
commitc3c8032c42958f73ef4370fb0476fd0f5a7e30dd (patch)
tree72f339494da45e4efbaf16c80d31cf595b946aab /engines
parent9dc2cb87d98c801a773659af37dd1b84d73f4888 (diff)
downloadscummvm-rg350-c3c8032c42958f73ef4370fb0476fd0f5a7e30dd.tar.gz
scummvm-rg350-c3c8032c42958f73ef4370fb0476fd0f5a7e30dd.tar.bz2
scummvm-rg350-c3c8032c42958f73ef4370fb0476fd0f5a7e30dd.zip
CGE: Implemented Bitmap::xShow method
Diffstat (limited to 'engines')
-rw-r--r--engines/cge/vga13h.cpp125
1 files changed, 47 insertions, 78 deletions
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index eab50660dd..ec616a2551 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -1213,84 +1213,53 @@ void Vga::copyPage(uint16 d, uint16 s) {
//--------------------------------------------------------------------------
void Bitmap::xShow(int16 x, int16 y) {
- /*
- uint8 rmsk = x % 4,
- mask = 1 << rmsk,
- *scr = VGA::Page[1] + y * (SCR_WID / 4) + x / 4;
- uint8 *m = (char *) M;
- uint8 *v = V;
-
- asm push bx
- asm push si
- asm push ds
-
- asm cld
- asm les di,scr
- asm lds si,v
- asm mov bx,m
-
- asm mov al,0x02 // map mask register
- asm mov ah,mask
-
- plane:
- // enable output plane
- asm mov dx,VGASEQ_
- asm out dx,ax
- asm push ax
-
- // select input plane
- asm mov dx,VGAGRA_
- asm mov al,0x04 // read map select register
- asm mov ah,rmsk
- asm out dx,ax
-
- asm push di
-
- block:
- asm lodsw
- asm mov cx,ax
- asm and ch,0x3F
- asm test ah,0xC0
- asm jz endpl
- asm jns skip
- asm jnp incsi // replicate?
- asm add si,cx // skip over data block
- asm dec si // fix it before following inc
-
- incsi:
- asm inc si
- tint:
- asm mov al,es:[di]
- //-----------------------------------------------
- // asm xlat ss:0 // unsupported with BASM!
- __emit__(0x36, 0xD7); // this stands for above!
- //-----------------------------------------------
- asm stosb
- asm loop tint
- asm jmp block
-
- skip:
- asm add di,cx
- asm jmp block
-
- endpl:
- asm pop di
- asm pop ax
- asm inc rmsk
- asm shl ah,1
- asm test ah,0x10
- asm jz x_chk
- asm mov ah,0x01
- asm mov rmsk,0
- asm inc di
- x_chk:
- asm cmp ah,mask
- asm jne plane
- asm pop ds
- asm pop si
- asm pop bx
- */
- warning("STUB: BITMAP::xShow");
+ const byte *srcP = (const byte *)_v;
+ byte *destEndP = (byte *)Vga::_page[1]->pixels + (SCR_WID * SCR_HIG);
+ byte *lookupTable = _m;
+
+ // Loop through processing data for each plane. The game originally ran in plane mapped mode, where a
+ // given plane holds each fourth pixel sequentially. So to handle an entire picture, each plane's data
+ // must be decompressed and inserted into the surface
+ for (int planeCtr = 0; planeCtr < 4; ++planeCtr) {
+ byte *destP = (byte *)Vga::_page[1]->getBasePtr(x + planeCtr, y);
+
+ for (;;) {
+ uint16 v = READ_LE_UINT16(srcP);
+ srcP += 2;
+ int cmd = v >> 14;
+ int count = v & 0x3FFF;
+
+ if (cmd == 0) {
+ // End of image
+ break;
+ }
+
+ assert(destP < destEndP);
+
+ if (cmd == 2)
+ ++srcP;
+ else if (cmd == 3)
+ srcP += count;
+
+ // Handle a set of pixels
+ while (count-- > 0) {
+ // Transfer operation
+ switch (cmd) {
+ case 1:
+ // SKIP
+ break;
+ case 2:
+ case 3:
+ // TINT
+ *destP = lookupTable[*destP];
+ break;
+ }
+
+ // Move to next dest position
+ destP += 4;
+ }
+ }
+ }
}