home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / asm32 / system.doc < prev    next >
Text File  |  1994-02-20  |  17KB  |  608 lines

  1.  
  2. *****************************  SYSTEM  *************************************
  3.  
  4. ASM32 system subroutines Copyright (C) 1993 Douglas Herr
  5. all rights reserved
  6.  
  7.  
  8. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  9.  
  10. COLOR16:     calculate color value for palette register
  11. Source:      color16.asm
  12.  
  13. Call with:   EBX pointing to red value (0-3), green value (0-3)
  14.              and blue value (0-3); see also Palette16
  15. Returns:     AH = color value for 16-color palette register
  16. Uses:        AH
  17. Supports:    VGA 16-color modes (text or graphics)
  18.              EGA 16-color modes, except with CGA monitor
  19. Example:
  20.  
  21. extrn   color16:near
  22.  
  23. include dataseg.inc
  24.  
  25. c16     db 3                  ; brightest red
  26.         db 1                  ; dim green
  27.         db 0                  ; no blue
  28.  
  29. @curseg ends
  30.  
  31. include codeseg.inc
  32.         .
  33.         .
  34.         .
  35.         lea   ebx,c16
  36.         call  color16
  37.  
  38.  
  39.  
  40. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  41.  
  42. EXENAME:     determine the full path and filename of the executing program
  43. Source:      exename.asm (strlen.asm)
  44.  
  45. Call with:   no parameters
  46. Returns:     EBX pointing to the the name of the executing program,
  47.              including drive and full path.
  48.              The filename returned is an ASCIIZ string in the low heap,
  49.              and may be mixed upper- and lower-case characters.  When you
  50.              are done with the string you may release the memory it
  51.              occupies with HFREE.
  52. Uses:        EBX, flags
  53. Example:
  54.  
  55. extrn   exename:near
  56.  
  57. include codeseg.inc
  58.  
  59.         .
  60.         .
  61.         .
  62.         call  exename         ; string returned at [EBX] in low heap
  63.  
  64.  
  65.  
  66. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  67.  
  68. EXESIZE:     determine size of .EXE program
  69. Source:      exesize.asm
  70.  
  71. Call with:   [EDX] pointing to ASCIIZ .EXE filename
  72. Returns:     if CF = 1, AX = DOS error code
  73.                         if AX = 0, not an EXE-format file
  74.              if CF = 0, EAX = bytes in .EXE file loaded by DOS program
  75.                         loader and by CauseWay
  76.              Note that additional data may be copied to the end of a DOS
  77.              .EXE file with the DOS COPY /B command.  This is handy for
  78.              help screens or other such data that you want to keep with
  79.              the .EXE file, but that you don't want to be loaded in memory
  80.              with the program.  If you do copy additional data to the .EXE
  81.              file, EXESize will report only the portion of the file loaded
  82.              in RAM by the DOS program loader and CauseWay, while FSize (in
  83.              DISK.DOC) reports the entire file size.
  84. Uses:        EAX, flags
  85. Example:
  86.  
  87. ;
  88. ; code used to test EXEsize
  89. ;
  90. include model.inc
  91.  
  92. public  testcode
  93. extrn   exename:near, exesize:near
  94. extrn   strndup:near, i4tostr:near
  95. extrn   tprint:near, getkey:near
  96.  
  97. include dataseg.inc
  98. extrn   pspseg:word
  99. space   db 20 dup(0)
  100. @curseg ends
  101.  
  102. include codeseg.inc
  103. testcode        proc near
  104.         mov     es,pspseg
  105.         call    exename         ; get name of this program
  106.         call    strndup         ; copy to near heap
  107.                                 ; startup code was assembled with /DHEAP
  108.         mov     edx,ebx         ; [EDX] -> EXE filename
  109.         call    exesize         ; EAX = EXE program size
  110.         lea     esi,space
  111.         call    i4tostr         ; convert to ASCIIZ string
  112.         xor     edx,edx         ; point to UL corner of screen
  113.         mov     ah,12           ; "can't miss it" color
  114.         call    tprint          ; print it
  115.         call    getkey          ; don't scroll off screen yet
  116.         ret                     ; go back to calling code
  117. testcode        endp
  118.  
  119. @curseg ends
  120.         end
  121.  
  122.  
  123. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  124.  
  125. FLOPPIES:    determine the number of floppy disk drives intalled
  126. Source:      floppies.asm
  127.  
  128. Call with:   no parameters
  129. Returns:     AX = number of floppy drives
  130. Uses:        AX; all other registers and flags are saved
  131. Example:
  132.  
  133. include model.inc
  134.  
  135. extrn   floppies:near
  136.  
  137. include codeseg.inc
  138.  
  139. myproc  proc   near
  140.         .
  141.         call   floppies
  142.  
  143.  
  144.  
  145. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  146.  
  147. FLOPPYTYPE:  determine the type of floppy disk drives intalled
  148. Source:      floptype.asm
  149.  
  150. Call with:   DL = drive number (0 = drive A:)
  151. Returns:     AX = floppy drive type
  152.               0 = invalid drive number
  153.               1 = 360k
  154.               2 = 1.2M
  155.               3 = 720k
  156.               4 = 1.44M
  157. Uses:        AX, flags
  158. Example:
  159.  
  160. include model.inc
  161.  
  162. public  myproc
  163. extrn   floppytype:near
  164.  
  165. .data
  166. drive_number   db 0
  167.  
  168. .code
  169. myproc  proc
  170.         .
  171.         mov    dl,drive_number
  172.         call   floppytype
  173.         or     ax,ax
  174.         jz     bad_drive_number
  175.  
  176. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  177.  
  178. GETCPU:      detects cpu type
  179. Source:      getcpu.asm
  180.  
  181. Call with:   no parameters
  182. Returns:     AX = 3 if 386 (SX or DX)
  183.              AX = 4 if 486 (SX or DX)
  184. Uses:        AX
  185. Example:     call   getcpu
  186.  
  187.  
  188.  
  189. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  190.  
  191. GETCRT:      determines active monitor type
  192. Source:      getcrt.asm ($herc.asm, isevga.asm)
  193.  
  194. Call with:   no parameters
  195. Returns:     AX = code for active video system
  196.              CGA = -1
  197.              MDA = 0
  198.              EGA mono = 0100h
  199.              VGA mono = 0300h
  200.              EGA color = 1
  201.              MCGA = 2
  202.              VGA color = 3
  203.              HGC = 128
  204.              HGC+ = 144
  205.              InColor = 208
  206.              Note: GetCRT may be re-assembled with the /DNOHERC switch
  207.              to eliminate code which detects Hercules equipment
  208. Uses:        AX
  209. Supports:    CGA, MCGA, MDA, HGC, HGC+, InColor, EGA, VGA
  210. Example:     call    getcrt
  211.  
  212.  
  213.  
  214. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  215.  
  216. INSERT:      control INSERT key status
  217. Source:      insert.asm (cw$info.asm)
  218.  
  219. Call with:   AL = 0 to turn INSERT off in BIOS data area
  220.              AL = 1 to turn INSERT on in BIOS data area
  221. Returns:     nothing
  222. Uses:        nothing
  223. Example:
  224.  
  225. include codeseg.inc
  226.  
  227. extrn   insert:near
  228.  
  229. ; code
  230.  
  231.         mov     al,1         ; turn INSERT on in BIOS data area
  232.         call    insert
  233.  
  234.  
  235.  
  236. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  237.  
  238. ISANSI:      determines if ANSI or compatible is loaded and active
  239. Source:      isansi.asm
  240.  
  241. Call with:   no parameters
  242. Returns:     CF = 1 if no ANSI device driver loaded and active
  243.              CF = 0 if ANSI loaded and active
  244. Uses:        CF
  245. Example:
  246.  
  247. include codeseg.inc
  248.  
  249. extrn   isansi:near
  250.  
  251. ; code
  252.         .
  253.         .
  254.         .
  255.         call   isansi         ; let's see if ansi.sys is loaded
  256.         jc     no_ansi        ; jump if not
  257.  
  258.  
  259.  
  260. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  261.  
  262. ISATT:       determines if an ATT 6300-type display card is installed
  263.              this equipment is like a CGA except that it has an additional
  264.              640 x 400 2-color graphics mode (mode 40h)
  265. Source:      isatt.asm ($6845.asm, isevga.asm)
  266.  
  267. Call with:   no parameters
  268. Returns:     if CF = 1, ATT 6300 display not present
  269.              if CF = 0, ATT 6300 display is installed
  270. Uses:        flags
  271. Example:
  272.  
  273. public  cgamode
  274.  
  275. include codeseg.inc
  276.  
  277. extrn   isatt:near
  278.  
  279. ; code
  280. cgamode proc    near
  281.         mov     ax,06h             ; default: set CGA mode
  282.         call    isatt              ; see if mode 40h is available
  283.         jc      short set_mode     ;  nope
  284.         mov     ax,40h             ; use ATT 6300 mode 40h
  285. set_mode:
  286.         mov     v86r_ax,ax
  287.         mov     al,10h             ; use BIOS to set mode
  288.         int     30h
  289.         ret
  290.  
  291. cgamode endp
  292.  
  293. @curseg ends
  294.         end
  295.  
  296.  
  297. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  298.  
  299. ISEVGA:      determines if an EGA or VGA is installed
  300. Source:      isevga.asm
  301.  
  302. Call with:   no parameters
  303. Returns:     if CF = 1, no EGA or VGA
  304.              if CF = 0
  305.                DX = video memory in kbytes
  306.                AL = monitor type
  307.                 AL = -1 if monitor is CGA
  308.                 AL = 0 if monitor is monochrome
  309.                 AL = 1 if monitor is EGA or better
  310.  
  311.                AH = EGA/VGA flag
  312.                 AH = 1 if EGA
  313.                 AH = 3 if VGA
  314.  
  315. Uses:        AX, DX, CF
  316. Example:
  317.  
  318. include codeseg.inc
  319.  
  320. extrn   isevga:near
  321.  
  322. ; code
  323.         .
  324.         .
  325.         .
  326.         call   isevga
  327.         jc     no_evga
  328.  
  329.  
  330.  
  331. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  332.  
  333. ISHERC:      determines if a Hercules card or compatible is installed
  334.              and if so, determines if it is the active video system.
  335. Source:      isherc.asm ($herc.asm)
  336.  
  337. Call with:   no parameters
  338. Returns:     if CF = 1, no Hercules or compatible installed
  339.              if CF = 0, AX = Hercules model
  340.              128 = Hercules Graphics Card or compatible; active
  341.              144 = Hercules Graphics Card Plus; active
  342.              208 = Hercules InColor card; active
  343.              -128 = Hercules Graphics Card or compatible; not active
  344.              -144 = Hercules Graphics Card Plus; not active
  345.              -208 = Hercules InColor card; not active
  346. Uses:        AX, CF; all other flags and registers are saved
  347. Example:
  348.  
  349. include codeseg.inc
  350.  
  351. extrn   isherc:near
  352.  
  353. ; code
  354.         .
  355.         .
  356.         .
  357.         call  isherc
  358.         jc    no_herc
  359.  
  360.  
  361. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  362.  
  363. ISMONO:      detects a monochrome-compatible video card
  364.              this is handy in 2-monitor systems.
  365. Source:      $6845.asm
  366.  
  367. Call with:   no parameters
  368. Returns:     if CF = 1, no monochrome monitor
  369.              if CF = 0, monochrome monitor is installed
  370.                         including Hercules InColor
  371. Uses:        flags
  372. Supports:    MDA, EGA & VGA MONO, HGC, HGC+, InColor
  373. Example:
  374.  
  375. include codeseg.inc
  376.  
  377. extrn   ismono:near
  378.  
  379. ; code
  380.         .
  381.         .
  382.         .
  383.         call  ismono
  384.         jc    no_monochrome
  385.  
  386.  
  387.  
  388. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  389.  
  390. ISMOUSE:     determines if a mouse is installed
  391. Source:      ismouse.asm (asmflags.asm)
  392.  
  393. Call with:   no parameters
  394. Returns:     if CF = 0, AX = number of mouse buttons
  395.              if CF = 1, no mouse or mouse driver not installed
  396. Uses:        AX, flags
  397. Example:
  398.  
  399. include  codeseg.inc
  400.  
  401. extrn    ismouse:near
  402.  
  403. ; code
  404.         .
  405.         .
  406.         .
  407.         call    ismouse
  408.         jc      no_mouse
  409.  
  410.  
  411.  
  412. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  413.  
  414. ISSEVGA:     determines if a Super EGA or Super VGA is installed
  415. Source:      issevga.asm
  416.  
  417. Call with:   no parameters
  418. Returns:     if CF = 1, no Super EGA or Super VGA recognized by ASM32
  419.  
  420.              if CF = 0
  421.  
  422.               if AH = 1: (Super EGA)
  423.                AL = 1 if Paradise EGA 480
  424.                AL = 2 if Everex EGA
  425.  
  426.               if AH = 3: (Super VGA)
  427.                AL = 1 if Paradise VGA
  428.                AL = 3 if Tseng VGA chipset
  429.                AL = 4 if Oak VGA
  430.                AL = 5 if Western Digital VGA chipset
  431.  
  432.              See also IsEVGA and WhichVGA
  433. Uses:        AX, CF
  434. Example:
  435.  
  436. include codeseg.inc
  437.  
  438. extrn   issevga:near
  439.  
  440. ; code
  441.         .
  442.         .
  443.         .
  444.         call   issevga
  445.         jc     no_superevga
  446.  
  447.  
  448.  
  449. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  450.  
  451. MATHCHIP:    determines if x87 math coprocessor is installed
  452. Source:      mathchip.asm
  453.  
  454. Call with:   no parameters
  455. Returns:     AX = code for x87 model
  456.              0 = not installed
  457.              2 = 287                   ; earliest 386 computers used 287
  458.              3 = 387 (DX or SX)
  459.              4 = 487 (DX or SX)
  460.              If the coprocessor is present, it is initilaized by MathChip.
  461. Uses:        AX, all x87 registers
  462. Example:     call  mathchip
  463.  
  464.  
  465.  
  466.  
  467. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  468.  
  469. MOUSESAVE:   save mouse state
  470. Source:      moussave.asm
  471.  
  472. MOUSERESTORE:restore previously saved mouse state
  473. Source:      moussave.asm
  474.  
  475.              MouseSave and MouseRestore are handy when you have installed a
  476.              mouse event handler and you will be using the SYSTEM command,
  477.              where some other program may reset or otherwise change the
  478.              mouse event trapping.
  479.  
  480.              MouseSave allocates a buffer, saves the mouse state in the
  481.              buffer, resets the mouse driver and returns the buffer address.
  482.  
  483.              MouseRestore restores a specified mouse state and releases the
  484.              buffer.  Both MouseSave and MouseRestore assume that you already
  485.              know there is a mouse in the system.
  486.  
  487. Call with:   MouseSave: no paramerters
  488.              MouseRestore: AX = buffer address returned by MouseSave
  489. Returns:     if CF = 1, AH = DOS error code
  490.              if CF = 0, no error; MouseSave returns buffer address in AX
  491. Uses:        AX, flags
  492. Example:
  493.  
  494. include model.inc
  495. extrn   msave:near, mrestore:near
  496.  
  497. include dataseg.inc
  498. save_mouse dw 0
  499. @curseg    ends
  500.  
  501. include codeseg.inc
  502.  
  503.         .
  504.         .
  505.         .
  506.  
  507. ; save the mouse driver state
  508. ; I've already checked to see if there's a mouse
  509.         call    mousesave
  510.         jc      dos_error
  511.         mov     save_mouse,ax
  512.         .
  513.         .
  514. ; some other subroutine has messed with the mouse
  515.         mov     ax,save_mouse   ; buffer address from previous MSave
  516.         call    mouserestore
  517.         jc      dos_error
  518.  
  519.  
  520.  
  521. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  522.  
  523. PALETTE16:   change palette in EGA, VGA or SVGA 16-color mode
  524.              changing the palette changes the actual color associated
  525.              with a color attribute
  526. Source:      palet16.asm
  527.  
  528. Call with:   BH = color value (see Color16 in SYSTEM.DOC)
  529.              BL = color attribute to map color to (0-0Fh)
  530.              restore default palette with BX = 0FFFFh
  531. Returns:     nothing
  532. Uses:        nothing
  533. Supports:    EGA, VGA, SVGA 16-color modes, text or graphics
  534.              except EGA with CGA monitor
  535. Example:
  536.  
  537. include codeseg.inc
  538.  
  539. extrn   color16:near, palette16:near
  540.  
  541. ; data
  542. c16     db 3                  ; brightest red
  543.         db 1                  ; dim green
  544.         db 0                  ; no blue
  545.  
  546. ; code
  547.         .
  548.         .
  549.         .
  550.         lea   ebx,c16
  551.         call  color16
  552.         mov   bh,ah           ; color value in BH
  553.         mov   bl,15           ; color attribute 0Fh
  554.         call  palette16
  555.  
  556.  
  557.  
  558. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  559.  
  560. USE32K:      limit Hercules equipment to 32k memory (128k on InColor)
  561. USE64K:      allow full 64k on HGC and HGC+ (256k on InColor)
  562. Source:      $herc.asm
  563.  
  564. Requires Hercules or compatible
  565.  
  566. Call with:   no parameters
  567.              Use32k is equivalent to the Hercules "half" configuration
  568.              Use64k is equivalent to the Hercules "full" configuration
  569.              ASM32's default is "half".  Use this configuration if you
  570.              have a 2-monitor system, unless you are using the Hercules
  571.              CGA card. 
  572. Returns:     nothing
  573. Uses:        nothing
  574. Example:     ; in this example I'm determining if a Hercules is installed
  575.              ; and setting the configuration to "full"
  576.  
  577.  
  578. extrn   IsHerc:near
  579. extrn   Use64k:near
  580.  
  581. include codeseg.inc
  582.  
  583.         .
  584.         .
  585.         .
  586.         call  IsHerc
  587.         jc    no_herc
  588.         or    ax,ax
  589.  
  590. ; use_only_half if HGC is not default monitor
  591.         js    short use_only_half
  592.         call  use64k          ; else use all Hercules memory
  593. use_only_half:
  594.  
  595.  
  596. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  597.  
  598. WHICHVGA:    determine if VGAKIT-compatible SuperVGA is installed
  599.              See SVGA16 and SVGA256 in MODE.DOC.
  600. Source:      whichvga.asm ($banks.asm)
  601.  
  602. Call with:   no parameters
  603. Returns:     if VGAKIT-compatible Super VGA is installed, AX <> 0.
  604.              if no VGAKIT equipment is installed, AX = 0.
  605. Uses:        AX
  606. Example:     see SVGA16 in MODE.DOC
  607.  
  608.