home *** CD-ROM | disk | FTP | other *** search
/ PDA Software Library / pdasoftwarelib.iso / HP95_100 / GRAPHICS / LXPIC / DEMO.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-10-22  |  6.5 KB  |  185 lines

  1. ;-------------------------------------------------------------- 
  2. ;This is an assembly source code example, on how to use LXPIC
  3. ;as a subroutine using intrasegment calls to LXPIC. This
  4. ;enables you to write tiny COM files which display pictures as
  5. ;you like it. See 'PROGRAMMERS INTERFACE' in LXPIC.DOC for
  6. ;further information.
  7. ;
  8. ;This example shows, how to fill a whole screen with an icon.  
  9. ;To provide LXPIC with a picture filename, the command tail of
  10. ;DEMO is simply copied to the command tail of LXPIC. To see,
  11. ;how DEMO works, proceed as follows:
  12. ;
  13. ;-Create the directory C:\PIC
  14. ;-Copy LXPIC.COM, LXPIC.ICN and DEMO.COM to C:\PIC
  15. ;-Change the directory to C:\PIC 
  16. ;-Enter DEMO LXPIC.ICN at the command line.
  17. ;-Press any key to exit DEMO
  18. ;
  19. ;If you want to change the code of DEMO.ASM, you have to 
  20. ;assemble and link as follows, to create the new DEMO.COM file:
  21. ;
  22. ;Using Turbo Assembler/Linker
  23. ;
  24. ; tasm demo.asm;             (creates demo.obj)
  25. ; tlink /t demo.obj;         (creates demo.com)
  26. ;
  27. ;Using Microsoft Assembler/Linker
  28. ;
  29. ; masm demo.asm;             (creates demo.obj)
  30. ; link demo.obj;             (creates demo.exe)
  31. ; exe2bin demo.exe demo.com  (creates demo.com)
  32. ;
  33. ;You must create a COM file. You cannot use the intermediate
  34. ;EXE file, because of different PSP length and structure.
  35. ;------------------------------------------------------------------------------
  36.  
  37. .186                   ;allow pusha and popa 
  38. cseg   segment 'code'
  39. assume cs:cseg,ds:cseg,es:cseg
  40. org    100h
  41.  
  42. MODE   EQU   00000000b ;0,0,0,HPRES,AZOOM,CENTER,INVERS,CLS
  43. ZOOM   EQU   0         ;no zoom
  44. LINE   EQU   0         ;start pixelline
  45. COLUMN EQU   0         ;start pixelcolumn
  46. X_DEL  EQU   48        ;advance X_DEL pixelcolumns
  47. Y_DEL  EQU   36        ;advance Y_DEL pixellines
  48. ITFADR EQU   0458h     ;interface start adresse
  49.  
  50.   start:               ;start of program
  51. call   load            ;load LXPIC
  52. jc     ende            ;load error
  53. call   select          ;select picture file
  54. jc     ende            ;select file error
  55. call   screen          ;get/set screen mode
  56. mov    cx,LINE         ;start pixelline
  57. mov    dx,COLUMN       ;start pixelcolumn
  58.   _loop:
  59. mov    ah,MODE         ;mode byte
  60. mov    al,ZOOM         ;zoom factor
  61. call   picture         ;fill in interface and display picture
  62.  
  63.  ;---------------------;multiple output start
  64.  add    dx,X_DEL       ;increment column
  65.  cmp    dx,640         ;screen width reached?
  66.  jl     _loop          ;no, display next
  67.  xor    dx,dx          ;restart with column 0
  68.  add    cx,Y_DEL       ;increment line
  69.  cmp    cx,200         ;screen hight reached?
  70.  jl     _loop          ;no, display next
  71.  ;---------------------;multiple output end
  72.  
  73. call   wait_key        ;wait for any key
  74.   ende:
  75. mov    ah,4ch          ;exit program...
  76. int    21h             ;...using DOS
  77.  
  78. ;--------------------------------------------------------------
  79. ;------SUBROUTINES---------------------------------------------
  80. ;--------------------------------------------------------------
  81.   screen:              ;get/set screen mode
  82. mov    ah,0fh          ;get actual sreen mode
  83. int    10h
  84. mov    smode,al        ;store actual screen mode
  85. mov    ax,6            ;set CGA graphics mode
  86. int    10h
  87. ret
  88. ;--------------------------------------------------------------
  89.   wait_key:            ;wait for any key
  90. xor    ax,ax
  91. int    16h             ;waits for key
  92. xor    ah,ah           ;ah=0
  93. mov    al,smode        ;get old screen mode
  94. int    10h             ;set old screen mode
  95. ret
  96. smode  db 0            ;place to store screen mode
  97. ;--------------------------------------------------------------
  98.   picture:             ;fill in interface and display picture
  99. pusha
  100. push   es
  101. push   ds
  102.  
  103. ;----------------------;fill in interface
  104. push   ds
  105. xor    bx,bx
  106. mov    ds,bx           ;ds=0
  107. mov    bx,ITFADR       ;bx=offset interface
  108. mov    byte ptr[bx+0],3;set selection flag=return via RET
  109. mov    [bx+1],ah       ;set mode
  110. mov    [bx+2],al       ;set zoom
  111. mov    [bx+3],cx       ;set pixelline
  112. mov    [bx+5],dx       ;set pixelcolumn
  113. pop    ds 
  114. ;----------------------;display picture
  115. lea    bx,lxpic        ;offset LXPIC
  116. mov    ax,param        ;segment adresse LXPIC
  117. sub    ax,16           ;segment adresse PSP
  118. mov    es,ax           ;load es with PSP
  119. mov    ds,ax           ;load ds with PSP
  120. call   bx              ;intrasegment CALL LXPIC
  121. pop    ds              ;restore ds for lea dx,error
  122. or     al,al           ;al=LXPIC return code
  123. je     pic_e           ;if al=0
  124. lea    dx,error        ;if al not 0: display error...
  125. mov    ah,9            ;...using DOS
  126. int    21h
  127.   pic_e:
  128. pop    es
  129. popa
  130. ret
  131. error  db'LXPIC error$';error text 
  132. ;--------------------------------------------------------------
  133.   select:              ;select a picture filename
  134. pusha
  135. mov    si,80h          ;offset DEMO command tail
  136. lea    di,tail         ;offset LXPIC command tail
  137. xor    ch,ch           ;ch=0      
  138. mov    cl,[si]         ;has DEMO command tail...
  139. or     cl,cl           ;...length=0?
  140. je     sel_e           ;yes, display syntax
  141. add    cx,2            ;else copy the whole tail...
  142. rep    movsb           ;...from DEMO to LXPIC 
  143. clc                    ;no carry flag
  144. popa
  145. ret
  146.   sel_e:
  147. lea    dx,syntax       ;display syntax...
  148. mov    ah,9            ;...using DOS
  149. int    21h
  150. stc                    ;set carry flag
  151. popa
  152. ret
  153. syntax db'Syntax: DEMO [path]file.[BMP|GIF|ICN|PCX]$'
  154. ;--------------------------------------------------------------
  155.   load:                ;load LXPIC within same segment
  156. pusha
  157. lea    ax,lxpic        ;convert LXPIC offset...
  158. shr    ax,4            ;...in paragraphs...
  159. mov    bx,cs           ;...and add CS
  160. add    ax,bx           ;absolute LXPIC segment load address...
  161. mov    param,ax        ;...as 1.param
  162. lea    bx,param        ;load param offset
  163. lea    dx,_lxpic       ;load pathname offset of LXPIC
  164. mov    ax,4b03h        ;load LXPIC at segment:0000
  165. int    21h
  166. jnc    load_e          ;no load error
  167. mov    ah,9            ;display error...
  168. int    21h             ;...using DOS
  169. stc                    ;set carry flag
  170.   load_e:
  171. popa
  172. ret
  173.  
  174. ;---load Data--------------------------------------------------
  175. _lxpic db 'C:\PIC\LXPIC.COM',0,'not found$'
  176. param  dw 0,0
  177.  
  178. ;---PSP and LXPIC code placeholder-----------------------------
  179. ALIGN  16                   ;dummy PSP starts at this segment
  180. tail   equ this word+ 80h   ;command tail in dummy LXPIC PSP
  181. lxpic  equ this word+100h   ;LXPIC code starts here
  182.  
  183. cseg   ends
  184.        end start
  185.