home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / emmexmpl.seq < prev    next >
Text File  |  1991-02-08  |  5KB  |  118 lines

  1. \ EMMEXMPL.SEQ          Example EMM usage               by Tom Zimmer
  2.  
  3. comment:
  4.  
  5.         This file contains an example of how to use the Expanded Memory
  6.         inferface defined in the file EXPANDED.SEQ.  This file also
  7.         illustrates the SEQUENCE of the commands required to access
  8.         EMM.
  9.  
  10. comment;
  11.  
  12. \ EMM status code evaluator, prints the error code for any error received.
  13.  
  14. : ?emm          ( --- )                 \ test the most recent emm operation
  15.         @> emm-status 0= if exit then   \ leave, there is no problem.
  16.         @> emm-status >r
  17.         r@ $80 = abort" Serious EMM software problem."
  18.         r@ $81 = abort" Serious EMM hardware problem."
  19.         r@ $82 = abort" The EMM system is BUSY."
  20.         r@ $83 = abort" EMM can't find the handle specified."
  21.         r@ $84 = abort" Invalid function code passed to EMM."
  22.         r@ $85 = abort" No handles are currently available."
  23.         r@ $86 = abort" A mapping context restoration error detected."
  24.         r@ $87 =
  25.         r@ $88 =
  26.               or abort" Requested pages exceeds available pages."
  27.         r@ $89 = abort" Could not allocate ANY pages."
  28.         r@ $8A = abort" Logical page to map is not in allocated range."
  29.         r@ $8B = abort" Physical page specified is not valid."
  30.         r@ $8C = abort" The mapping context save area is full."
  31.         r@ $8D = abort" Attempt to save context of already saved handle."
  32.         r@ $8E = abort" Attempt to restore context without saving first."
  33.         r@ $8F = abort" Subfunction passed is not defined."
  34.         r> cr ." Received EMM error code " u. abort ;
  35.  
  36. 0 value mxemm
  37. 0 value emmhandle
  38. 0 value emmver
  39.  
  40. : emm-sample    ( --- )
  41. ( 1 )   emm-present?                            \ is there any EMM in system?
  42.         0= abort" No Expanded memory available!"
  43.  
  44. ( 2 )   emm-page-frame ?emm                             \ set the page frame
  45.  
  46. ( 3 )   emm-get-version ?emm 255 and                    \ get the EMM version
  47.         cr ." Expanded Memory Version " dup h. =: emmver \ save EMM version
  48.  
  49.         \ check the EMM version to be sure it is compatible
  50. ( 4 )   emmver $30 < abort" The EMM version must be 3 or higher!"
  51.  
  52. ( 5 )   emm-total-pages ?emm                            \ What is total pages
  53.         cr ." Total Pages of EMM " .
  54.  
  55. ( 6 )   emm-avail-pages ?emm                            \ get available EMM
  56.         cr ." Available Pages of EMM " dup . =: mxemm   \ set MAX EMM value
  57.  
  58.         \ check here to see if there is enough EMM available
  59. ( 7 )   mxemm 2 < abort" Need at least 2 pages of EMM!"
  60.  
  61.         cr ." Allocating " mxemm . ." Pages of EMM."
  62. ( 8 )   mxemm emm-alloc-pages ?emm =: emmhandle         \ allocate the pages
  63.  
  64. ( 9 )
  65. [ comment:
  66.         Access the EMM in your program using EMM-MAP-PAGES. The
  67.         parameters required by EMM-MAP-PAGES are: Logical Page,
  68.         Physical Page, and EMM Handle. The Logical page is a value in
  69.         the range zero (0) to the number of allocated pages minus one
  70.         (1). The Physical page is a value in the range zero (0) to
  71.         three (3), where each page is 16k bytes starting at offset
  72.         $0000, $4000, $8000 & $C000 from the Page Frame Base address.
  73.         Up to these four physical pages (64k bytes) can be accessed
  74.         without having to perform another EMM call to get more pages.
  75.         The EMM Handle is the handle number returned by the
  76.         EMM-ALLOC-PAGES call. Be sure to use ?EMM or its equivelant
  77.         after each EMM call to verify operation is continuing according
  78.         to plan.
  79. comment;
  80. ]
  81.         cr ." Writing patterns to EMM, one moment..."
  82.         mxemm 0                                   \ fill EMM with pattern
  83.         ?do     i 0 emmhandle emm-map-pages ?emm  \ get a page & chk for err
  84.                 ?emm: 0 4000                      \ start of EMM for 16k len
  85.                 7 flip                            \ attribute in high byte
  86.                 i $30 +                           \ changing pattern value
  87.                 255 and                           \ clip to character
  88.                 or                                \ or in attribute
  89.                 LFILLW                            \ fill WORDS with pattern
  90.         loop
  91.  
  92.         cr ." Done creating patterns"
  93.         cr ." Now I will move the patterns to the screen as fast as I can."
  94.         cr ." Press a key to see the patterns"
  95.         key drop                                  \ wait for user
  96.  
  97.         0 0 emmhandle emm-map-pages ?emm          \ get first page
  98.         video-seg @ 0 ?emm: 0 4000 cmovel         \ save current screen
  99.  
  100.         mxemm 0                                   \ move pages to screen FAST
  101.         ?do     i 0 emmhandle emm-map-pages ?emm  \ get a page
  102.                 ?emm: 0 video-seg @ 0 4000 cmovel \ move it to screen
  103.         loop
  104.  
  105.         0 0 emmhandle emm-map-pages ?emm          \ get first page again
  106.         ?emm: 0 video-seg @ 0 4000 cmovel         \ restore screen
  107.  
  108.         cr
  109.         cr ." Pretty FAST HUH?"
  110.         cr ." Deallocating " mxemm . ." Pages of EMM Handle "
  111.         emmhandle .
  112.  
  113. ( 10 )  emmhandle emm-dealloc-pages ?emm          \ deallocate the space
  114.         cr ." That's ALL Folks!"
  115.         cr ;
  116.  
  117.  
  118.