Appendix A. PModeLib Reference

Table of Contents
A.1 Global Variables
A.2 Global Constants and Limits
A.3 Initialization and Shutdown
A.4 Simulate Real-Mode Interrupt
A.5 Memory Handling
A.6 General File Handling
A.7 Graphics File Handling
A.8 Interrupt, IRQ, and Callback Wrappers
A.9 Text Mode Functions
A.10 High-Resolution VBE/AF Graphics Functions
A.11 NetBIOS Networking
A.12 IP "Sockets" Networking (TCP/IP, UDP/IP)
A.13 Sound Programming
A.14 DMA Functions
A.15 Miscelleanous Utility Functions

All functions declared in C-style use the C calling convention (parameters on stack; return value in EAX/AX/AL; EAX, EBX, ECX, and EDX may be clobbered) and also have the function name prepended with a underscore ( _ ). Parameters and return values specified in C format obey the following size conventions:

Important: Pointer parameters take the address of the variable, not the contents.

The 32-bit C calling convention is described in much more detail in Chapter 8. See Section 18.2 to learn about the proc and invoke macros, which simplify both writing functions that use the C calling convention and calling PModeLib functions.

A.1 Global Variables

There are a number of global variables defined by the library. Some of these act as implicit inputs into functions such as DPMI_Int.

DPMI_Regs

Not really a variable in and of itself, it's the offset of the start of the entire DPMI Registers structure used by DPMI_Int. The layout of DPMI_Regs is identical to the layout described in the reference page for DPMI function 0300h.

dword DPMI_EAX

The EAX/AX/AL (depending on access size) member of DPMI_Regs.

dword DPMI_EBX

The EBX/BX/BL (depending on access size) member of DPMI_Regs.

dword DPMI_ECX

The ECX/CX/CL (depending on access size) member of DPMI_Regs.

dword DPMI_EDX

The EDX/DX/DL (depending on access size) member of DPMI_Regs.

dword DPMI_ESI

The ESI/SI (depending on access size) member of DPMI_Regs.

dword DPMI_EDI

The EDI/DI (depending on access size) member of DPMI_Regs.

dword DPMI_EBP

The EBP/BP (depending on access size) member of DPMI_Regs.

word DPMI_SP

The SP member of DPMI_Regs. It's usually not necessary to set this.

word DPMI_FLAGS

The processor flags member of DPMI_Regs.

word DPMI_DS

The DS segment member of DPMI_Regs. Set to _Transfer_Buf_Seg value in LibInit().

word DPMI_ES

The ES segment member of DPMI_Regs. Set to _Transfer_Buf_Seg value in LibInit().

word DPMI_FS

The FS segment member of DPMI_Regs. Set to _Transfer_Buf_Seg value in LibInit().

word DPMI_GS

The GS segment member of DPMI_Regs. Set to _Transfer_Buf_Seg value in LibInit().

word DPMI_SS

The SS segment member of DPMI_Regs. It's usually not necessary to set this.

word _Transfer_Buf

Protected mode selector of real mode transfer buffer. See Section 17.3.3 for details on why a transfer buffer is necessary.

word _Transfer_Buf_Seg

Real mode segment of real mode transfer buffer. See Section 17.3.3 for details on why a transfer buffer is necessary.

_ScratchBlock

Protected mode selector of 1 MB scratch buffer. This buffer is used by several library routines but is free for temporary program use between library calls. Don't expect the contents of this block to be preserved over a library call.

_NetTransferSel

Protected mode selector of NetBIOS transfer area. The transfer area contains the RXBuffer and TXBuffer receive and transmit buffers. Used by the NetBIOS functions described in Section A.11.

_textsel

Protected mode selector of text mode video memory.