Rev 762 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 762 | Rev 775 | ||
---|---|---|---|
Line 5... | Line 5... | ||
5 | 5 | ||
Line 6... | Line 6... | ||
6 | 6 | ||
7 | interface |
7 | interface |
8 | 8 | ||
9 | 9 | ||
10 | procedure ImagePut(var Screen, ImageBuffer; X, Y: Integer; Winx1, Winy1, Winx2, Winy2: Word); |
10 | procedure ImagePut(var Screen, ImageBuffer; X, Y, WinX1, WinY1, WinX2, WinY2: Integer); |
11 | procedure ImagePutTransparent(var Screen, ImageBuffer; X, Y: Integer; Winx1, Winy1, Winx2, Winy2: Word); |
11 | procedure ImagePutTransparent(var Screen, ImageBuffer; X, Y, WinX1, WinY1, WinX2, WinY2: Integer); |
12 | procedure ImageFill(var ImageBuffer; SizeX, SizeY: Word; Value: Byte); |
12 | procedure ImageFill(var ImageBuffer; SizeX, SizeY: Word; Value: Byte); |
13 | function ImageSizeX(var ImageBuffer): Word; |
13 | function ImageSizeX(var ImageBuffer): Word; |
14 | function ImageSizeY(var ImageBuffer): Word; |
14 | function ImageSizeY(var ImageBuffer): Word; |
Line -... | Line 15... | ||
- | 15 | procedure ImageStringGet(Source: String; var FontData, Buffer; ColorOffs: Byte); |
|
15 | procedure ImageStringGet(Source: String; var FontData, Buffer; ColorOffs: Byte); |
16 | procedure ScreenApply(var Buffer); |
16 | procedure ScreenApply(var Buffer); |
17 | procedure ImageClear(var Buffer); |
17 | procedure ImageClear(var Buffer); |
18 | procedure ScreenMode(Mode: Integer); |
18 | procedure ScreenMode(Mode: Integer); |
19 | |
- | 20 | function ScanToChar(Code: Word): Char; |
|
- | 21 | procedure KeyboardInitialize; |
|
- | 22 | function Keypressed: Boolean; |
|
19 | 23 | function ReadKey: Word; |
|
- | 24 | procedure KeyboardFlush; |
|
- | 25 | ||
- | 26 | procedure MouseInitialize; |
|
- | 27 | function MSMouseInArea(x1, y1, x2, y2: Integer): Boolean; |
|
- | 28 | function MSMouseDriverExist: Boolean; |
|
Line 20... | Line 29... | ||
20 | procedure KeyboardInitialize; |
29 | procedure MSMouseGetXY(var x, y: Integer); |
21 | function Keypressed: Boolean; |
30 | function MSMouseButtonStatusGet: Word; |
22 | function ReadKey: Word; |
31 | function MSMouseButtonWasPressed(Button: Word; var x, y: Integer): Boolean; |
23 | procedure KeyboardFlush; |
32 | function MSMouseButtonWasReleased(Button: Word; var x, y: Integer): Boolean; |
Line 37... | Line 46... | ||
37 | function DataIdentical(var Array1, Array2; Count: Word; Array1Offset, Array2Offset: Word): Boolean; |
46 | function DataIdentical(var Array1, Array2; Count: Word; Array1Offset, Array2Offset: Word): Boolean; |
38 | function SetInterrupt(Int: Byte; NewAddress: Pointer): Pointer; |
47 | function SetInterrupt(Int: Byte; NewAddress: Pointer): Pointer; |
39 | procedure FadeClear; |
48 | procedure FadeClear; |
40 | procedure FadeTo(pal: Pointer); |
49 | procedure FadeTo(pal: Pointer); |
41 | procedure DecompressRepByte(var InArray, OutArray; InArraySize: Word; var OutArraySize: Word); |
50 | procedure DecompressRepByte(var InArray, OutArray; InArraySize: Word; var OutArraySize: Word); |
42 | function MSMouseInArea(x1, y1, x2, y2: Integer): Boolean; |
- | |
43 | function MSMouseDriverExist: Boolean; |
- | |
44 | procedure MSMouseGetXY(var x, y: Integer); |
- | |
45 | function MSMouseButtonStatusGet: Word; |
- | |
46 | function MSMouseButtonWasPressed(Button: Word; var x, y: Integer): Boolean; |
- | |
47 | function MSMouseButtonWasReleased(Button: Word; var x, y: Integer): Boolean; |
- | |
48 | procedure MSMouseSetXY(x, y: Integer); |
- | |
49 | function GetInterrupt(Int: Byte): Pointer; |
- | |
Line -... | Line 51... | ||
- | 51 | ||
- | 52 | function GetInterrupt(Int: Byte): Pointer; |
|
50 | 53 | procedure WaitForEvent(Timeout: DWord = 0); |
|
51 | procedure AssignFile(var AFile: File; AFileName: String); |
54 | procedure AssignFile(var AFile: File; AFileName: String); |
Line 52... | Line 55... | ||
52 | function LastDosTick(): Longword; |
55 | function LastDosTick(): Longword; |
Line 290... | Line 293... | ||
290 | 293 | ||
291 | Paint; |
294 | Paint; |
Line 292... | Line 295... | ||
292 | end; |
295 | end; |
293 | 296 | ||
294 | 297 | ||
295 | procedure ImagePut(var Screen, ImageBuffer; X, Y: Integer; WinX1, WinY1, WinX2, WinY2: Word); |
298 | procedure ImagePut(var Screen, ImageBuffer; X, Y, WinX1, WinY1, WinX2, WinY2: Integer); |
296 | var |
299 | var |
297 | Width, Height: Word; |
300 | Width, Height: Longint; |
298 | I, J, K: Integer; |
301 | I, J, K: Integer; |
299 | P: Pointer; |
302 | P: Pointer; |
Line 307... | Line 310... | ||
307 | if (I >= 0) and (I < BUFFER_HEIGHT) and (I >= WinY1) and (I <= WinY2) then |
310 | if (I >= 0) and (I < BUFFER_HEIGHT) and (I >= WinY1) and (I <= WinY2) then |
308 | begin |
311 | begin |
309 | if X < WinX1 then |
312 | if X < WinX1 then |
310 | J := WinX1 - X else |
313 | J := WinX1 - X else |
311 | J := 0; |
314 | J := 0; |
- | 315 | if X + Width - 1 > WinX2 then |
|
- | 316 | K := WinX2 - X - J + 1 else |
|
312 | K := Width - J; |
317 | K := Width - J; |
313 | if WinX1 + K - 1 > WinX2 then |
- | |
314 | K := WinX2 - WinX1 + 1; |
- | |
315 | Move((P + J)^, (@Screen + I * BUFFER_WIDTH + X + J)^, K); |
318 | Move((P + J)^, (@Screen + I * BUFFER_WIDTH + X + J)^, K); |
316 | end; |
319 | end; |
317 | Inc(P, Width); |
320 | Inc(P, Width); |
318 | end; |
321 | end; |
319 | end; |
322 | end; |
Line 320... | Line 323... | ||
320 | 323 | ||
321 | 324 | ||
322 | procedure ImagePutTransparent(var Screen, ImageBuffer; X, Y: Integer; Winx1, Winy1, Winx2, Winy2: Word); |
325 | procedure ImagePutTransparent(var Screen, ImageBuffer; X, Y, WinX1, WinY1, WinX2, WinY2: Integer); |
323 | var |
326 | var |
324 | Width, Height: Word; |
327 | Width, Height: Longint; |
325 | I, J, K, L: Integer; |
328 | I, J, K, L: Integer; |
326 | PI, PO: PByte; |
329 | PI, PO: PByte; |
327 | begin |
330 | begin |
Line 335... | Line 338... | ||
335 | if (I >= 0) and (I < BUFFER_HEIGHT) and (I >= WinY1) and (I <= WinY2) then |
338 | if (I >= 0) and (I < BUFFER_HEIGHT) and (I >= WinY1) and (I <= WinY2) then |
336 | begin |
339 | begin |
337 | if X < WinX1 then |
340 | if X < WinX1 then |
338 | J := WinX1 - X else |
341 | J := WinX1 - X else |
339 | J := 0; |
342 | J := 0; |
- | 343 | if X + Width - 1 > WinX2 then |
|
- | 344 | K := WinX2 - X - J + 1 else |
|
340 | K := Width - J; |
345 | K := Width - J; |
341 | if WinX1 + K - 1 > WinX2 then |
- | |
342 | K := WinX2 - WinX1 + 1; |
- | |
Line 343... | Line 346... | ||
343 | 346 | ||
344 | Inc(PI, J); |
347 | Inc(PI, J); |
345 | PO := @Screen + I * BUFFER_WIDTH + X + J; |
348 | PO := @Screen + I * BUFFER_WIDTH + X + J; |
346 | for L := 1 to K do |
349 | for L := 1 to K do |
Line 476... | Line 479... | ||
476 | end; |
479 | end; |
477 | end; |
480 | end; |
Line -... | Line 481... | ||
- | 481 | ||
- | 482 | ||
- | 483 | ||
- | 484 | function ScanToChar(Code: Word): Char; |
|
- | 485 | var |
|
- | 486 | I: Word; |
|
- | 487 | begin |
|
- | 488 | for I := Low(ScanToCharTable) to High(ScanToCharTable) do |
|
- | 489 | with ScanToCharTable[I] do |
|
- | 490 | if Scan = Code then |
|
- | 491 | begin |
|
- | 492 | if not CapsPressed then |
|
- | 493 | if not ShiftDown then |
|
- | 494 | Result := CL else |
|
- | 495 | Result := CU |
|
- | 496 | else |
|
- | 497 | if not ShiftDown then |
|
- | 498 | if not Caps then |
|
- | 499 | Result := CL else |
|
- | 500 | Result := CU |
|
- | 501 | else |
|
- | 502 | if not Caps then |
|
- | 503 | Result := CL else |
|
- | 504 | Result := CL; |
|
- | 505 | Exit; |
|
- | 506 | end; |
|
478 | 507 | Result := #0; |
|
479 | 508 | end; |
|
480 | 509 | ||
481 | procedure KeyboardInitialize; |
510 | procedure KeyboardInitialize; |
Line 567... | Line 596... | ||
567 | 596 | ||
568 | procedure KeyboardFlush; |
597 | procedure KeyboardFlush; |
569 | begin |
598 | begin |
Line -... | Line 599... | ||
- | 599 | end; |
|
- | 600 | ||
570 | end; |
601 | procedure ProcessKeyboard; |
- | 602 | begin |
|
- | 603 | LastKeyEvent := TranslateKey(kos_getkey()); |
|
- | 604 | end; |
|
- | 605 | ||
- | 606 | ||
- | 607 | ||
- | 608 | const |
|
- | 609 | MK_LBUTTON = 1; |
|
- | 610 | MK_RBUTTON = 2; |
|
- | 611 | MK_MBUTTON = 4; |
|
571 | 612 | MouseButtonsCount = 3; |
|
- | 613 | ||
- | 614 | var |
|
- | 615 | MouseButtonsState : DWord; |
|
- | 616 | MouseButtonsPressed : array[1..MouseButtonsCount] of DWord; |
|
- | 617 | MouseButtonsReleased: array[1..MouseButtonsCount] of DWord; |
|
- | 618 | ||
- | 619 | ||
572 | function ScanToChar(Code: Word): Char; |
620 | procedure ProcessMouse; |
- | 621 | var |
|
- | 622 | I: Longint; |
|
573 | var |
623 | Buttons, ButtonMask: DWord; |
574 | I: Word; |
- | |
575 | begin |
624 | NowPressed, WasPressed: Boolean; |
- | 625 | begin |
|
576 | for I := Low(ScanToCharTable) to High(ScanToCharTable) do |
626 | Buttons := kos_getmousebuttons(); |
577 | with ScanToCharTable[I] do |
627 | |
578 | if Scan = Code then |
628 | for I := 1 to MouseButtonsCount do |
579 | begin |
629 | begin |
580 | if not CapsPressed then |
630 | ButtonMask := 1 shl (I - 1); |
581 | if not ShiftDown then |
- | |
582 | Result := CL else |
631 | NowPressed := (Buttons and ButtonMask) <> 0; |
583 | Result := CU |
- | |
584 | else |
- | |
585 | if not ShiftDown then |
632 | WasPressed := (MouseButtonsState and ButtonMask) <> 0; |
586 | if not Caps then |
- | |
587 | Result := CL else |
- | |
588 | Result := CU |
- | |
589 | else |
633 | |
590 | if not Caps then |
- | |
591 | Result := CL else |
- | |
592 | Result := CL; |
634 | if NowPressed and not WasPressed then Inc(MouseButtonsPressed[I]) else |
- | 635 | if not NowPressed and WasPressed then Inc(MouseButtonsReleased[I]); |
|
593 | Exit; |
636 | end; |
594 | end; |
637 | |
Line -... | Line 638... | ||
- | 638 | MouseButtonsState := Buttons; |
|
- | 639 | end; |
|
- | 640 | ||
- | 641 | procedure MouseInitialize; |
|
- | 642 | var |
|
- | 643 | I: Longint; |
|
- | 644 | begin |
|
- | 645 | MouseButtonsState := kos_getmousebuttons(); |
|
- | 646 | for I := 1 to MouseButtonsCount do |
|
- | 647 | begin |
|
- | 648 | MouseButtonsPressed[I] := 0; |
|
- | 649 | MouseButtonsReleased[I] := 0; |
|
- | 650 | end; |
|
- | 651 | ProcessMouse; |
|
- | 652 | end; |
|
- | 653 | ||
- | 654 | function MSMouseInArea(x1, y1, x2, y2: Integer): Boolean; |
|
- | 655 | var |
|
- | 656 | X, Y: Integer; |
|
- | 657 | begin |
|
- | 658 | MSMouseGetXY(X, Y); |
|
- | 659 | Result := (X >= x1) and (X <= x2) and (Y >= y1) and (Y <= y2); |
|
- | 660 | end; |
|
- | 661 | ||
- | 662 | function MSMouseDriverExist: Boolean; |
|
- | 663 | begin |
|
- | 664 | Result := True; |
|
- | 665 | end; |
|
- | 666 | ||
- | 667 | procedure MSMouseGetXY(var X, Y: Integer); |
|
- | 668 | var |
|
- | 669 | WinPos: TKosPoint; |
|
- | 670 | begin |
|
- | 671 | WinPos := kos_getmousewinpos(); |
|
- | 672 | ||
- | 673 | X := Round(Double(WinPos.X) * BUFFER_WIDTH / ScreenWidth); |
|
- | 674 | if X < 0 then X := 0 else |
|
- | 675 | if X >= BUFFER_WIDTH then X := BUFFER_WIDTH - 1; |
|
- | 676 | ||
- | 677 | Y := Round(Double(WinPos.Y) * BUFFER_HEIGHT / ScreenHeight); |
|
- | 678 | if Y < 0 then Y := 0 else |
|
- | 679 | if Y >= BUFFER_HEIGHT then Y := BUFFER_HEIGHT - 1; |
|
- | 680 | end; |
|
- | 681 | ||
- | 682 | function MSMouseButtonStatusGet: Word; |
|
- | 683 | begin |
|
- | 684 | Result := Word(kos_getmousebuttons()); |
|
- | 685 | end; |
|
- | 686 | ||
- | 687 | function MSMouseButtonWasPressed(Button: Word; var x, y: Integer): Boolean; |
|
- | 688 | begin |
|
- | 689 | Inc(Button); |
|
- | 690 | if Button < MouseButtonsCount then |
|
- | 691 | begin |
|
- | 692 | Result := MouseButtonsPressed[Button] > 0; |
|
- | 693 | MouseButtonsPressed[Button] := 0; |
|
- | 694 | end else |
|
- | 695 | Result := False; |
|
- | 696 | MSMouseGetXY(x, y); |
|
- | 697 | end; |
|
- | 698 | ||
- | 699 | function MSMouseButtonWasReleased(Button: Word; var x, y: Integer): Boolean; |
|
- | 700 | begin |
|
- | 701 | Inc(Button); |
|
- | 702 | if Button < MouseButtonsCount then |
|
- | 703 | begin |
|
- | 704 | Result := MouseButtonsReleased[Button] > 0; |
|
- | 705 | MouseButtonsReleased[Button] := 0; |
|
- | 706 | end else |
|
- | 707 | Result := False; |
|
- | 708 | MSMouseGetXY(x, y); |
|
- | 709 | end; |
|
- | 710 | ||
- | 711 | procedure MSMouseSetXY(x, y: Integer); |
|
- | 712 | begin |
|
- | 713 | end; |
|
Line 595... | Line 714... | ||
595 | Result := #0; |
714 | |
596 | end; |
715 | |
597 | 716 | ||
598 | 717 | ||
Line 810... | Line 929... | ||
810 | end; |
929 | end; |
811 | end; |
930 | end; |
812 | end; |
931 | end; |
Line 813... | Line -... | ||
813 | - | ||
814 | - | ||
815 | function MSMouseInArea(x1, y1, x2, y2: Integer): Boolean; |
- | |
816 | begin |
- | |
817 | Result := False; |
- | |
818 | end; |
- | |
819 | - | ||
820 | function MSMouseDriverExist: Boolean; |
- | |
821 | begin |
- | |
822 | Result := True; |
- | |
823 | end; |
- | |
824 | - | ||
825 | procedure MSMouseGetXY(var x, y: Integer); |
- | |
826 | begin |
- | |
827 | end; |
932 | |
828 | 933 | ||
829 | function MSMouseButtonStatusGet: Word; |
934 | function GetInterrupt(Int: Byte): Pointer; |
830 | begin |
935 | begin |
Line 831... | Line -... | ||
831 | Result := 0; |
- | |
832 | end; |
- | |
833 | - | ||
834 | function MSMouseButtonWasPressed(Button: Word; var x, y: Integer): Boolean; |
- | |
Line 835... | Line 936... | ||
835 | begin |
936 | Result := nil; |
- | 937 | end; |
|
- | 938 | ||
836 | Result := False; |
939 | |
- | 940 | procedure WaitForEvent(Timeout: DWord = 0); |
|
- | 941 | var |
|
- | 942 | Event: Word; |
|
837 | end; |
943 | begin |
- | 944 | kos_maskevents(ME_PAINT or ME_KEYBOARD or ME_MOUSE); |
|
- | 945 | Event := kos_waitevent(Timeout); |
|
838 | 946 | case Event of |
|
839 | function MSMouseButtonWasReleased(Button: Word; var x, y: Integer): Boolean; |
- | |
840 | begin |
- | |
841 | Result := False; |
- | |
842 | end; |
947 | SE_PAINT: Paint; |
Line 843... | Line -... | ||
843 | - | ||
844 | procedure MSMouseSetXY(x, y: Integer); |
- | |
845 | begin |
- | |
846 | end; |
- | |
847 | - | ||
848 | 948 | SE_KEYBOARD: ProcessKeyboard; |
|
849 | function GetInterrupt(Int: Byte): Pointer; |
949 | SE_MOUSE: ProcessMouse; |
850 | begin |
950 | end; |
851 | Result := nil; |
951 | end; |
Line -... | Line 952... | ||
- | 952 | ||
852 | end; |
953 | |
853 | 954 | procedure AssignFile(var AFile: File; AFileName: String); |
|
854 | procedure AssignFile(var AFile: File; AFileName: String); |
955 | begin |
855 | begin |
956 | Assign(AFile, IncludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0))) + AFileName); |