Metropoli BBS
VIEWER: qlib.inc MODE: TEXT (ASCII)
.386
.387
.model flat,c  ;back to using C calling convention !!!
assume fs:flat,gs:flat    ;MASM thought you won't need these in flat mode!!!
                          ; by default they are assumed to ERROR !!!!

#include _str_.tmp  ;used by PASM for strings within ASM code

.code
dos4gwint3 macro
  .if _dosXtyp==DOSX_DOS4GW
    int 3  ;call debugger if loaded
  .endif
endm
_int3_ proto   ;Same thing as dos4gwint3 macro except this is a func (for C)
getint proto v:byte    ;ax:edx=segment:offset
setint proto v:byte,s:word,off:dword
getrmint proto v:byte  ;ax:dx=segment:offset
setrmint proto v:byte,s:word,off:word
alloc_callback proto off:dword,calls:dword,typ:byte   ;off=your_proc  calls=offset rmcs callstruct <>
  CB_RETF equ 0
  CB_IRET equ 1
free_callback proto _seg:word,off:word
_iret proto calls:dword  ;used to end a callback proc, iret stack frame
_retf proto calls:dword  ;used to end a callback proc, retf stack frame
alloc_phys proto :dword,:dword
free_phys proto :dword
lock_ram proto off:dword,siz:dword
unlock_ram proto off:dword,siz:dword
lock_all proto :byte    ;returns amount locked

irq_enable proto irqn:byte
irq_disable proto irqn:byte

pack_init proto,siz:word,packs:word  ;siz=# of entries(files)alloced for
pack_uninit proto
pack_open proto,strg:dword  ;opens a packed file
pack_open_hdr proto,strg:dword,hdr:dword  ;opens a packed file (w/ header already loaded)
pack_close proto,:word
.data
externdef _os_typ:byte
externdef _os_ver_major:byte
externdef _os_ver_minor:byte
externdef _dos_ver_major:byte
externdef _dos_ver_minor:byte
externdef _dosXver:word   ;version (BCD coded)
externdef _dosXtyp:byte   ;DOS extender type (0=PMODEW 1=DOS/4GW 2=DOS32)
  DOSX_PMODEW equ 0
  DOSX_DOS4GW equ 1
  DOSX_DOS32 equ 2        ;not implemented any more
  DOSX_UNKNOWN equ 255
externdef errno:word
externdef selcode:word
externdef seldata:word
externdef selzero:word
externdef _environ:dword    ;relative addr
externdef _psp:dword        ;relative addr to PSP
externdef _dta:dword        ;relative addr to DTA  (it's not in your PSP)
externdef _base:dword       ;base of program
externdef _fpu:byte         ;80387?
externdef _8087:byte        ;WATCOM support
externdef _argstr:byte ;129 dup (?)
externdef _argv:dword ;64 dup (?)
externdef _argc:byte
externdef _pmmode:byte
  SRV_UNKNOWN equ 0ffh
  SRV_DPMI equ 3
  SRV_VCPI equ 2
  SRV_XMS equ 1
  SRV_RAW equ 0
externdef _filename:dword
externdef _ds_:word
externdef _es_:word
externdef _8kbufferseg:word
externdef _8kbuffer:dword
externdef _processor:byte  ; processor type : 3=386 4=486 5=586
externdef _cpu:byte        ; processor type : same
externdef _ansi_sys:byte   ; Ansi.sys loaded?

NULL equ 0
ERROR equ -1
NULLPROC proto

callstruct struct   ;50 bytes  (32h)
  _edi dd ?     ;0
  _esi dd ?     ;4
  _ebp dd ?     ;8
  _res dd ?     ;0ch reserved
  _ebx dd ?     ;10h
  _edx dd ?     ;14h
  _ecx dd ?     ;18h
  _eax dd ?     ;1ch
  _flg dw ?     ;20h flags
  _es dw ?      ;22h segments (NOT selectors)
  _ds dw ?      ;24h "
  _fs dw ?      ;26h "
  _gs dw ?      ;28h "
  _ip dw ?      ;2ah ignored in some calls
  _cs dw ?      ;2ch "
  _sp dw ?      ;2eh must be 0 to use system stacks
  _ss dw ?      ;30h "
callstruct ends

qptr equ qword ptr
dptr equ dword ptr
wptr equ word ptr
bptr equ byte ptr

dma_s struct
  siz dd ?      ;00h    DWORD   region size
  off dd ?      ;04h    DWORD   offset
  sel dw ?      ;08h    WORD    segment/selector
  id dw ?       ;0Ah    WORD    buffer ID
  phys dd ?     ;0Ch    DWORD   physical address
  dmach dw ?    ; This is used by QLIB only!
dma_s ends

dma_alloc64 proto dmas:dword  ;max=64k
dma_alloc128 proto dmas:dword ;max=128k
dma_free proto dmas:dword

;Win95+ funcs
win95_title_set proto,:dword
win95_title_get proto,:dword,:dword
win95_vmtitle_set proto,:dword
win95_vmtitle_get proto,:dword,:dword
win95_close_enable proto
win95_close_disable proto
win95_close_query proto
win95_close_ack proto
win95_close_cancel proto

WIN95_CLOSE_NOACK equ 0
WIN95_CLOSE_ACK equ 1

.code
include callp.inc

;INVOKE sucks!
;so I made callp macro which does exactly what masm's INVOKE does but mine
; works!
;may not be as fast but it always works!! (now that I got all the bugs out)
;plus you can call proc whose addr is held in a variable. Couldn't do that
;before.
;this is slower because all vars are widen to dwords even if not needed

;CALLP Ver 1.05
; NEW ver 1.05 : Fixed a bug in destroy_ax thingy (QLIB v2.01)
; NEW ver 1.04 : Now capable of pushing REAL 10 (QLIB v2.00 Beta#4)
; NEW ver 1.03 : Fixed a bug I added in Ver 1.02 (stupid!) (push (a3) is bad)
;              : Sept 7/96
; NEW ver 1.02 : Fixed major bug !!! if arg was offset x+4 size was == 8 ???
;              : also capable of FWORD (aug 25/96)
; NEW ver 1.01 : Now capable of pushing REAL 8 and other bugs fixed

; Known bugs : as of Nov 30/96 I've found too many bugs and now have designed
;              it garbage.  I don't know how to fix these bugs
; 1) if there is a forward reference in the varargs then MASM causes an error
; 2) callp never uses movsx which is bad!
; see callp.inc if you wanna look at it

; Too many bugs, that cannot be fixed cause MASM sux!
; Use callp on your own risk, if you know when you can't use INVOKE use this


[ RETURN TO DIRECTORY ]