2
0

buffer.pp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. uses
  2. go32;
  3. procedure dosalloc(var selector : word;
  4. var segment : word; size : longint);
  5. var
  6. res : longint;
  7. begin
  8. res := global_dos_alloc(size);
  9. selector := word(res);
  10. segment := word(res shr 16);
  11. end;
  12. procedure dosfree(selector : word);
  13. begin
  14. global_dos_free(selector);
  15. end;
  16. type
  17. VBEInfoBuf = packed record
  18. Signature : array[0..3] of char;
  19. Version : Word;
  20. reserved : array[0..505] of byte;
  21. end;
  22. var
  23. selector,
  24. segment : Word;
  25. r : trealregs;
  26. infobuf : VBEInfoBuf;
  27. begin
  28. fillchar(r, sizeof(r), 0);
  29. fillchar(infobuf, sizeof(VBEInfoBuf), 0);
  30. dosalloc(selector, segment, sizeof(VBEInfoBuf));
  31. if (int31error<>0) then begin
  32. Writeln('Error while allocating real mode memory, halting');
  33. halt;
  34. end;
  35. infobuf.Signature := 'VBE2';
  36. dosmemput(segment, 0, infobuf, sizeof(infobuf));
  37. r.ax := $4f00; r.es := segment;
  38. realintr($10, r);
  39. dosmemget(segment, 0, infobuf, sizeof(infobuf));
  40. dosfree(selector);
  41. if (r.ax <> $4f) then begin
  42. Writeln('VBE BIOS extension not available, function call ',
  43. 'failed');
  44. halt;
  45. end;
  46. if (infobuf.signature[0] = 'V') and
  47. (infobuf.signature[1] = 'E') and
  48. (infobuf.signature[2] = 'S') and
  49. (infobuf.signature[3] = 'A') then begin
  50. Writeln('VBE version ', hi(infobuf.version), '.',
  51. lo(infobuf.version), ' detected');
  52. end;
  53. end.