buffer.pp 1.4 KB

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