BG2-GEN.PAS 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. {$G+}
  2. Uses Graph;
  3. const
  4. table :array [0..15] of byte = (0,1,2,Yellow,Blue,5,6,7,8,9,10,Yellow,LightBlue,13,14,15);
  5. { table : array [0..15] of byte = (0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);}
  6. type
  7. ReadBuf = array [0..13999] of byte;
  8. var
  9. inp,outp : file;
  10. R,G,B,A : ^ReadBuf;
  11. Size : Word;
  12. k,i,j,pos: word;
  13. x,y : word;
  14. val,nR,nG,nB,nA : byte;
  15. { gD,gM : Integer;}
  16. Procedure Mega;
  17. begin
  18. pos := 0;
  19. for i := 1 to y shr 1 do
  20. begin
  21. for j := 1 to x shr 3 do
  22. begin
  23. nR := 0;nG := 0;nB := 0;nA := 0;
  24. for k := 1 to 4 do
  25. begin
  26. BlockRead(INP,val,1);
  27. nR:=nR shl 1;nG:=nG shl 1;nB:=nB shl 1;nA:=nA shl 1;
  28. nA := nA or ((table[(val shr 4) and $F] and 8) shr 3);
  29. nR := nR or ((table[(val shr 4) and $F] and 4) shr 2);
  30. nG := nG or ((table[(val shr 4) and $F] and 2) shr 1);
  31. nB := nB or (table[(val shr 4) and $F] and 1);
  32. nR:=nR shl 1;nG:=nG shl 1;nB:=nB shl 1;nA:=nA shl 1;
  33. nA := nA or ((table[val and $F] and 8) shr 3);
  34. nR := nR or ((table[val and $F] and 4) shr 2);
  35. nG := nG or ((table[val and $F] and 2) shr 1);
  36. nB := nB or (table[val and $F] and 1);
  37. end;
  38. R^[pos]:=nR; G^[pos]:=nG; B^[pos]:=nB; A^[pos]:=nA;
  39. inc(pos);
  40. end;
  41. Seek(INP,FilePos(INP)-640);
  42. end;
  43. end;
  44. Procedure Mega2;
  45. begin
  46. BlockWrite(OUTP,B^,Size shr 2);
  47. BlockWrite(OUTP,G^,Size shr 2);
  48. BlockWrite(OUTP,R^,Size shr 2);
  49. BlockWrite(OUTP,A^,Size shr 2);
  50. end;
  51. begin
  52. { gD:=VGA;
  53. gM:=VGAMed;
  54. InitGraph(gD,gM,'');}
  55. Assign(outp,'BG2.dat');
  56. ReWrite(outp,1);
  57. Assign(inp,'BG.bmp');
  58. Reset(inp,1);
  59. New(R);New(G);New(B);New(A);
  60. Seek(INP,$12);
  61. BlockRead(inp,x,4);
  62. BlockRead(inp,y,4);
  63. Seek(Inp,FileSize(INP)-(640 div 2));
  64. i:=2;
  65. BlockWrite(OUTP,i,1);
  66. Size := SizeOf(readBuf)*4;
  67. BlockWrite(OUTP,Size,2);
  68. i:=0;
  69. BlockWrite(OUTP,i,2);
  70. BlockWrite(OUTP,i,2);
  71. i:=640;
  72. BlockWrite(OUTP,i,2);
  73. i:=y shr 1;
  74. BlockWrite(OUTP,i,2);
  75. Mega;
  76. WriteLn('Done(1)');
  77. Mega2;
  78. BlockWrite(OUTP,Size,2);
  79. i:=0;
  80. BlockWrite(OUTP,i,2);
  81. i:=y shr 1;
  82. BlockWrite(OUTP,i,2);
  83. i:=640;
  84. BlockWrite(OUTP,i,2);
  85. i:=y shr 1;
  86. BlockWrite(OUTP,i,2);
  87. Mega;
  88. WriteLn('Done(2)');
  89. Mega2;
  90. Close(INP);
  91. Close(OUTP);
  92. Dispose(R);Dispose(G);Dispose(B);Dispose(A);
  93. end.
  94. Procedure GetImage(ypos,ysize:word;toP : pointer);assembler;
  95. var
  96. Beg:pointer;
  97. size : word;
  98. asm
  99. push ds
  100. mov bx, 0A000h
  101. mov ax, ypos {Calculate ypos}
  102. push ax
  103. shl ax, 4 {1}
  104. pop cx
  105. shl cx, 6 {2}
  106. add ax, cx {1 and 2 -> mul 640/8}
  107. push ax
  108. shr ax, 4
  109. add bx, ax
  110. pop ax
  111. and ax, 0Fh
  112. mov word ptr Beg, ax
  113. mov word ptr Beg+2, bx
  114. les di, toP
  115. mov ax, 0005h
  116. mov dx, 03CEH
  117. out dx, ax
  118. mov dx, 03C4h
  119. mov bx, ysize
  120. push bx
  121. shl bx, 5
  122. pop ax
  123. shl ax, 3
  124. add bx, ax
  125. mov size, bx
  126. mov bx, 0102h
  127. @1:
  128. mov ax, bx
  129. add bx, 0100h
  130. out dx, ax
  131. push ds
  132. lds si, Beg
  133. mov cx, size
  134. repe movsw
  135. pop ds
  136. cmp bx, 502h
  137. jne @1
  138. mov dx, 3C4H
  139. mov ax, 0F02h
  140. out dx, ax
  141. pop ds
  142. end;