Wanim.asm 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. include_macros equ 1
  2. include include.asm
  3. start32data
  4. dump_name db "sky"
  5. dn_h db "0"
  6. dn_t db "0"
  7. dn_u db "0"
  8. db ".anm",0
  9. screen_copy dd 0
  10. screen_ptr dd 0
  11. lpf_data1 db "LPF "
  12. dw 256,1 ;maxlps, no frames
  13. dd 1 ;no records
  14. dw 256 ;maxrecsperlp
  15. dw 1280 ;lpftableoffset
  16. db "ANIM"
  17. dw 320 ;width
  18. dw 200 ;height
  19. db 0 ;variant
  20. db 0 ;version
  21. db 0 ;haslastdelta
  22. db 0 ;lastdeltavalid
  23. db 0 ;pixel type
  24. db 1 ;compressiontype
  25. db 0 ;otherrecsperfrm
  26. db 1 ;bitmaptype
  27. lpf_data1_end db 0 dup (0)
  28. ; db 32 dup (0) ;recordtypes
  29. lpf_data2 dd 1 ;nframes
  30. dw 20 ;framespersecond
  31. lpf_data2_end db 0 dup (0)
  32. ; db 29*2 dup (0) ;pad
  33. ;
  34. ; db 128 dup (0) ;cycles
  35. ; db 1024 dup (0) ;palette
  36. lpf_data3 dw 0,1,64019 ;lpf table
  37. lpf_data3_end db 0 dup (0)
  38. ; dw 255*3 dup (0)
  39. lpf_data4 dw 0,1,64019,0,64019 ;frame header
  40. dd 10042h
  41. lpf_data4_end db 0 dup (0)
  42. ; dw 0ff80h
  43. ; db 0bfh
  44. ; db 16383 dup (7) ;pixels
  45. ;
  46. ; dw 0ff80h
  47. ; db 0bfh
  48. ; db 16383 dup (8) ;pixels
  49. ;
  50. ; dw 0ff80h
  51. ; db 0bfh
  52. ; db 16383 dup (9) ;pixels
  53. ;
  54. ; dw 380h
  55. ; db 0bah
  56. ; db 14851 dup (10) ;pixels
  57. ;
  58. ; db 80h
  59. ; dw 0
  60. ;
  61. ; db 1507 dup (0) ;pad to 65k
  62. data_16383 dw 0ff80h
  63. db 0bfh
  64. data_14851 dw 380h
  65. db 0bah
  66. data_end db 80h
  67. dw 0
  68. end32data
  69. start32code
  70. do_screen_dump proc
  71. ; Make a copy of the screen
  72. mov eax,64000
  73. call my_malloc
  74. mov [screen_copy],eax
  75. mov [screen_ptr],eax
  76. mov edi,eax ;clear an area to use for writing
  77. mov ecx,2000/4
  78. clear eax
  79. rep stosd
  80. try_file: mov edx,offset dump_name
  81. mov ax,3d00h ;does the file exist
  82. dos_int
  83. jc not_there
  84. mov ebx,eax ;close file
  85. mov ah,3eh
  86. dos_int
  87. inc [dn_u]
  88. cmp [dn_u],'9'+1
  89. jc try_file
  90. mov [dn_u],'0'
  91. inc [dn_t]
  92. cmp [dn_t],'9'+1
  93. jc try_file
  94. mov [dn_t],'0'
  95. inc [dn_h]
  96. jmp try_file
  97. not_there: mov ah,3ch ;create the file
  98. clear ecx
  99. mov edx,offset dump_name
  100. dos_int
  101. jc dump_error
  102. ; Write header
  103. mov edx,offset lpf_data1
  104. mov ecx,offset lpf_data1_end
  105. sub ecx,edx
  106. mov ebx,eax
  107. mov ah,40h
  108. dos_int
  109. jc dump_error
  110. mov ecx,32 ;record types
  111. mov edx,[screen_copy]
  112. mov ah,40h
  113. dos_int
  114. jc dump_error
  115. mov edx,offset lpf_data2
  116. mov ecx,offset lpf_data2_end
  117. sub ecx,edx
  118. mov ah,40h
  119. dos_int
  120. jc dump_error
  121. mov ecx,58+128 ;pad / cycles
  122. mov edx,[screen_copy]
  123. mov ah,40h
  124. dos_int
  125. jc dump_error
  126. ; Convert the palette
  127. mov esi,[work_palette]
  128. mov edi,[screen_copy]
  129. add edi,20000
  130. push edi
  131. mov ecx,256
  132. clear eax
  133. con_col: lodsb
  134. shl ax,2
  135. mov 2[edi],al
  136. lodsb
  137. shl ax,2
  138. mov 1[edi],al
  139. lodsb
  140. shl ax,2
  141. mov [edi],al
  142. lea edi,4[edi]
  143. loop con_col
  144. mov ecx,1024
  145. pop edx
  146. mov ah,40h
  147. dos_int
  148. mov edx,offset lpf_data3
  149. mov ecx,offset lpf_data3_end
  150. sub ecx,edx
  151. mov ah,40h
  152. dos_int
  153. jc dump_error
  154. mov ecx,255*6 ;lpf table
  155. mov edx,[screen_copy]
  156. mov ah,40h
  157. dos_int
  158. jc dump_error
  159. mov edx,offset lpf_data4
  160. mov ecx,offset lpf_data4_end
  161. sub ecx,edx
  162. mov ah,40h
  163. dos_int
  164. jc dump_error
  165. ; copy screen
  166. mov edi,[screen_copy]
  167. push ds
  168. mov ds,[screen_segment]
  169. clear esi
  170. mov ecx,64000/4
  171. rep movsd
  172. pop ds
  173. ; Write data
  174. mov ecx,16383
  175. mov edx,offset data_16383
  176. call write_block
  177. mov ecx,16383
  178. mov edx,offset data_16383
  179. call write_block
  180. mov ecx,16383
  181. mov edx,offset data_16383
  182. call write_block
  183. mov ecx,14851
  184. mov edx,offset data_14851
  185. call write_block
  186. mov ecx,3
  187. mov edx,offset data_end
  188. mov ah,40h
  189. dos_int
  190. mov ah,3eh ;and close the file
  191. dos_int
  192. dump_error: mov eax,[screen_copy]
  193. call my_free
  194. ret
  195. do_screen_dump endp
  196. write_block proc
  197. push ecx
  198. mov ecx,3
  199. mov ah,40h
  200. dos_int
  201. pop ecx
  202. mov edx,[screen_ptr]
  203. add [screen_ptr],ecx
  204. mov ah,40h
  205. dos_int
  206. ret
  207. write_block endp
  208. end32code
  209. end
  210.