buffer.tex 1.5 KB

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