Rev 4 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4 | Rev 16 | ||
---|---|---|---|
Line 4576... | Line 4576... | ||
4576 | ColorKey[DDCKEY_SRCBLT] := ddck; |
4576 | ColorKey[DDCKEY_SRCBLT] := ddck; |
4577 | end; |
4577 | end; |
4578 | 4578 | ||
4579 | {additional pixel routines like turbopixels} |
4579 | {additional pixel routines like turbopixels} |
4580 | 4580 | ||
- | 4581 | { |
|
- | 4582 | procedure TDirectDrawSurface.PutPixel8(x, y, color: Integer); |
|
- | 4583 | var |
|
- | 4584 | SurfacePtr: PByte; |
|
- | 4585 | PixelOffset: Integer; |
|
- | 4586 | begin |
|
- | 4587 | SurfacePtr := FLockSurfaceDesc.lpSurface; |
|
- | 4588 | PixelOffset := x + y * FLockSurfaceDesc.dwWidth; |
|
- | 4589 | SurfacePtr[PixelOffset] := color and $FF; // set pixel (lo byte of color) |
|
- | 4590 | end;} |
|
- | 4591 | ||
4581 | procedure TDirectDrawSurface.PutPixel8(x, y, color: Integer); assembler; |
4592 | procedure TDirectDrawSurface.PutPixel8(x, y, color: Integer); assembler; |
4582 | { on entry: self = eax, x = edx, y = ecx, color = ? } |
4593 | { on entry: self = eax, x = edx, y = ecx, color = ? } |
4583 | asm |
4594 | asm |
4584 | push esi // must maintain esi |
4595 | push esi // must maintain esi |
4585 | mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface// set to surface |
4596 | mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface// set to surface |
Line 4591... | Line 4602... | ||
4591 | mov ds:[esi],cl // set pixel (lo byte of ecx) |
4602 | mov ds:[esi],cl // set pixel (lo byte of ecx) |
4592 | pop esi // restore esi |
4603 | pop esi // restore esi |
4593 | //ret // return |
4604 | //ret // return |
4594 | end; |
4605 | end; |
4595 | 4606 | ||
- | 4607 | { |
|
- | 4608 | procedure TDirectDrawSurface.PutPixel16(x, y, color: Integer); |
|
- | 4609 | var |
|
- | 4610 | pPixel: PWord; |
|
- | 4611 | begin |
|
- | 4612 | pPixel := PWord(Integer(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface) + |
|
- | 4613 | x * 2 + y * TDirectDrawSurface(Self).FLockSurfaceDesc.lPitch); |
|
- | 4614 | pPixel^ := color; |
|
- | 4615 | end; |
|
- | 4616 | } |
|
- | 4617 | ||
4596 | procedure TDirectDrawSurface.PutPixel16(x, y, color: Integer); assembler; |
4618 | procedure TDirectDrawSurface.PutPixel16(x, y, color: Integer); assembler; |
4597 | { on entry: self = eax, x = edx, y = ecx, color = ? } |
4619 | { on entry: self = eax, x = edx, y = ecx, color = ? } |
4598 | asm |
4620 | asm |
4599 | push esi |
4621 | push esi |
4600 | mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface |
4622 | mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface |
Line 4607... | Line 4629... | ||
4607 | mov ds:[esi],cx |
4629 | mov ds:[esi],cx |
4608 | pop esi |
4630 | pop esi |
4609 | //ret |
4631 | //ret |
4610 | end; |
4632 | end; |
4611 | 4633 | ||
- | 4634 | { |
|
- | 4635 | procedure TDirectDrawSurface.PutPixel24(x, y, color: Integer); |
|
- | 4636 | var |
|
- | 4637 | pPixel: PByte; |
|
- | 4638 | dwPitch: DWORD; |
|
- | 4639 | dwColor: DWORD; |
|
- | 4640 | begin |
|
- | 4641 | pPixel := PByte(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface); |
|
- | 4642 | Inc(pPixel, x * 3); |
|
- | 4643 | dwPitch := TDirectDrawSurface(Self).FLockSurfaceDesc.lPitch; |
|
- | 4644 | Inc(pPixel, y * dwPitch); |
|
- | 4645 | dwColor := color and $FFFFFF; |
|
- | 4646 | pPixel[0] := Byte(dwColor); |
|
- | 4647 | pPixel[1] := Byte(dwColor shr 8); |
|
- | 4648 | pPixel[2] := Byte(dwColor shr 16); |
|
- | 4649 | end; |
|
- | 4650 | } |
|
- | 4651 | ||
4612 | procedure TDirectDrawSurface.PutPixel24(x, y, color: Integer); assembler; |
4652 | procedure TDirectDrawSurface.PutPixel24(x, y, color: Integer); assembler; |
4613 | { on entry: self = eax, x = edx, y = ecx, color = ? } |
4653 | { on entry: self = eax, x = edx, y = ecx, color = ? } |
4614 | asm |
4654 | asm |
4615 | push esi |
4655 | push esi |
4616 | mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface |
4656 | mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface |
Line 4626... | Line 4666... | ||
4626 | mov ds:[esi+1],ecx |
4666 | mov ds:[esi+1],ecx |
4627 | pop esi |
4667 | pop esi |
4628 | //ret |
4668 | //ret |
4629 | end; |
4669 | end; |
4630 | 4670 | ||
- | 4671 | { |
|
- | 4672 | procedure TDirectDrawSurface.PutPixel24(x, y, color: Integer); |
|
- | 4673 | var |
|
- | 4674 | offset: Integer; |
|
- | 4675 | pixelColor: LongInt; |
|
- | 4676 | begin |
|
- | 4677 | offset := (y * TDirectDrawSurface(Self).FLockSurfaceDesc.lpitch) + (x * 3); |
|
- | 4678 | pixelColor := color and $FFFFFF; |
|
- | 4679 | Move(pixelColor, PByte(Integer(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface) + offset)^, 3); |
|
- | 4680 | end; |
|
- | 4681 | } |
|
- | 4682 | ||
4631 | procedure TDirectDrawSurface.PutPixel32(x, y, color: Integer); assembler; |
4683 | procedure TDirectDrawSurface.PutPixel32(x, y, color: Integer); assembler; |
4632 | { on entry: self = eax, x = edx, y = ecx, color = ? } |
4684 | { on entry: self = eax, x = edx, y = ecx, color = ? } |
4633 | asm |
4685 | asm |
4634 | push esi |
4686 | push esi |
4635 | mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface |
4687 | mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface |
Line 4654... | Line 4706... | ||
4654 | 24: PutPixel24(x, y, value); |
4706 | 24: PutPixel24(x, y, value); |
4655 | 32: PutPixel32(x, y, value); |
4707 | 32: PutPixel32(x, y, value); |
4656 | end; |
4708 | end; |
4657 | end; |
4709 | end; |
4658 | 4710 | ||
- | 4711 | { |
|
- | 4712 | function TDirectDrawSurface.GetPixel8(x, y: Integer): Integer; |
|
- | 4713 | var |
|
- | 4714 | Pixel: Byte; |
|
- | 4715 | PixelPtr: PByte; |
|
- | 4716 | begin |
|
- | 4717 | PixelPtr := PByte(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface + x + (y * TDirectDrawSurface(Self).FLockSurfaceDesc.lpitch)); |
|
- | 4718 | Pixel := PixelPtr^; |
|
- | 4719 | Result := Pixel; |
|
- | 4720 | end; |
|
- | 4721 | ||
- | 4722 | function TDirectDrawSurface.GetPixel16(x, y: Integer): Integer; |
|
- | 4723 | var |
|
- | 4724 | Pixel: Word; |
|
- | 4725 | PixelPtr: PWord; |
|
- | 4726 | begin |
|
- | 4727 | PixelPtr := PWord(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface + (x * 2) + (y * TDirectDrawSurface(Self).FLockSurfaceDesc.lpitch)); |
|
- | 4728 | Pixel := PixelPtr^; |
|
- | 4729 | Result := Pixel; |
|
- | 4730 | end; |
|
- | 4731 | ||
- | 4732 | function TDirectDrawSurface.GetPixel24(x, y: Integer): Integer; |
|
- | 4733 | var |
|
- | 4734 | Pixel: array[0..2] of Byte; |
|
- | 4735 | PixelPtr: PByte; |
|
- | 4736 | begin |
|
- | 4737 | PixelPtr := PByte(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface + (x * 3) + (y * TDirectDrawSurface(Self).FLockSurfaceDesc.lpitch)); |
|
- | 4738 | Pixel[0] := PixelPtr^; |
|
- | 4739 | Pixel[1] := (PixelPtr+1)^; |
|
- | 4740 | Pixel[2] := (PixelPtr+2)^; |
|
- | 4741 | Result := Pixel[0] or (Pixel[1] shl 8) or (Pixel[2] shl 16); |
|
- | 4742 | end; |
|
- | 4743 | ||
- | 4744 | function TDirectDrawSurface.GetPixel32(x, y: Integer): Integer; |
|
- | 4745 | var |
|
- | 4746 | Pixel: Integer; |
|
- | 4747 | PixelPtr: PInteger; |
|
- | 4748 | begin |
|
- | 4749 | PixelPtr := PInteger(TDirectDrawSurface(Self).FLockSurfaceDesc.lpSurface + (x * 4) + (y * TDirectDrawSurface(Self).FLockSurfaceDesc.lpitch)); |
|
- | 4750 | Pixel := PixelPtr^; |
|
- | 4751 | Result := Pixel; |
|
- | 4752 | end; |
|
- | 4753 | } |
|
- | 4754 | ||
4659 | function TDirectDrawSurface.GetPixel8(x, y: Integer): Integer; assembler; |
4755 | function TDirectDrawSurface.GetPixel8(x, y: Integer): Integer; assembler; |
4660 | { on entry: self = eax, x = edx, y = ecx, result = eax } |
4756 | { on entry: self = eax, x = edx, y = ecx, result = eax } |
4661 | asm |
4757 | asm |
4662 | push esi // myst maintain esi |
4758 | push esi // myst maintain esi |
4663 | mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface // set to surface |
4759 | mov esi,TDirectDrawSurface[eax].FLockSurfaceDesc.lpSurface // set to surface |
Line 4829... | Line 4925... | ||
4829 | Pixel[x, y] := SaveRGB((Alpha * (aR - cr) shr 8) + cr, // R alpha |
4925 | Pixel[x, y] := SaveRGB((Alpha * (aR - cr) shr 8) + cr, // R alpha |
4830 | (Alpha * (aG - cg) shr 8) + cg, // G alpha |
4926 | (Alpha * (aG - cg) shr 8) + cg, // G alpha |
4831 | (Alpha * (aB - cb) shr 8) + cb); // B alpha |
4927 | (Alpha * (aB - cb) shr 8) + cb); // B alpha |
4832 | end; |
4928 | end; |
4833 | 4929 | ||
- | 4930 | { |
|
- | 4931 | function Conv24to16(Color: Integer): Word; |
|
- | 4932 | var |
|
- | 4933 | r, g, b: Byte; |
|
- | 4934 | begin |
|
- | 4935 | r := (Color shr 16) and $FF; |
|
- | 4936 | g := (Color shr 8) and $FF; |
|
- | 4937 | b := Color and $FF; |
|
- | 4938 | Result := ((r shr 3) shl 11) or ((g shr 2) shl 5) or (b shr 3); |
|
- | 4939 | end; |
|
- | 4940 | } |
|
- | 4941 | ||
4834 | function Conv24to16(Color: Integer): Word; register; |
4942 | function Conv24to16(Color: Integer): Word; register; |
4835 | asm |
4943 | asm |
4836 | mov ecx,eax |
4944 | mov ecx,eax |
4837 | shl eax,24 |
4945 | shl eax,24 |
4838 | shr eax,27 |
4946 | shr eax,27 |
Line 4937... | Line 5045... | ||
4937 | end; |
5045 | end; |
4938 | inc(dy); |
5046 | inc(dy); |
4939 | end; |
5047 | end; |
4940 | end; |
5048 | end; |
4941 | 5049 | ||
- | 5050 | { |
|
- | 5051 | function Conv16to24(Color: Word): Integer; |
|
- | 5052 | var |
|
- | 5053 | r, g, b: Byte; |
|
- | 5054 | begin |
|
- | 5055 | r := (Color shr 11) and $1F; |
|
- | 5056 | g := (Color shr 5) and $3F; |
|
- | 5057 | b := Color and $1F; |
|
- | 5058 | Result := (r shl 19) or (g shl 10) or (b shl 3); |
|
- | 5059 | end; |
|
- | 5060 | } |
|
- | 5061 | ||
4942 | function Conv16to24(Color: Word): Integer; register; |
5062 | function Conv16to24(Color: Word): Integer; register; |
4943 | asm |
5063 | asm |
4944 | xor edx,edx |
5064 | xor edx,edx |
4945 | mov dx,ax |
5065 | mov dx,ax |
4946 | 5066 |