home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / S1P_I2R.ZIP / I2R.ASM < prev    next >
Assembly Source File  |  1994-05-08  |  8KB  |  452 lines

  1. ; I2R sourcefile
  2. ; Unreal/SURPRISE! PRODUCTIONS
  3.  
  4. DATA SEGMENT USE16 PUBLIC PARA 'DATA'
  5. kool    label
  6.     dw 32000 dup (0)
  7. DATA ENDS
  8. PALETA SEGMENT USE16 PUBLIC PARA 'DATA'
  9. pall label
  10.     db 300h dup (0)
  11.     db 2000 dup (0)
  12. PALETA ENDS
  13.  
  14. CODE SEGMENT
  15. .286c
  16. ASSUME CS:CODE, DS:DATA
  17. JUMPS
  18.  
  19. handle0 dw 0                ; Place for handles of files
  20. handle1 dw 0
  21. handle2 dw 0
  22.  
  23. errormess:                ; Message if error
  24.     mov    ah,09h
  25.     mov    dx,seg CODE
  26.     mov    ds,dx
  27.     lea    dx,text            ; USAGE: NAME
  28.     int    21h
  29.     mov    ax,4c01h
  30.     int    21h    
  31.  
  32. Start:    pusha
  33.  
  34.     mov    si,080h            ; Start of parameter
  35.     cmp    byte ptr [si],0        ; Check length of parameter
  36.     jz    errormess        ; zero? No parameter!
  37.  
  38.     mov    cl,byte ptr [si]    ; how many characters
  39.     dec    cl            ; minus 1 [there was 1 space char]
  40.     mov    ch,0            ; erase high value
  41.     inc    si            ; next character [skip space]
  42.     mov    ax,seg CODE        ; set the segment
  43.     mov    es,ax
  44.     mov     di,offset pa1        ; space for the 1st parameter
  45.  
  46. Petlad:    inc    si            ; next character
  47.     mov    al,byte ptr [si]    ; take it to al
  48.     mov    byte ptr es:[di],al    ; save into space
  49.     inc    di            ; increase pointer
  50.     loop    Petlad            ; copy the parameter
  51.  
  52.     mov    si,offset pa1
  53.     mov    di,offset pa2
  54.     mov    bx,offset pa3
  55.  
  56.     mov    cx,22            ; max 22 chars [no way]
  57. KopiujF:mov    al,byte ptr es:[si]    ; take char
  58.     mov    byte ptr es:[di],al    ; copy to param 2
  59.     mov    byte ptr es:[bx],al    ; and to param 3
  60.     inc    si            ; Increase pointer
  61.     inc    di            ; ---=---
  62.     inc    bx            ; ---=---
  63.     loop    KopiujF
  64.  
  65.  
  66.     mov    di,offset pa2        ; Search for '.' in param 2
  67.     mov    cx,24
  68. Szukaj:    mov    al,byte ptr es:[di]
  69.     inc    di
  70.     cmp    al,'.'
  71.     jne    Szukaj
  72.     mov    byte ptr es:[di],'r'    ; replace old extension to RAW
  73.     mov    byte ptr es:[di+1],'a'
  74.     mov    byte ptr es:[di+2],'w'
  75.     mov    byte ptr es:[di+3],0    ;mark of end of filename [ASCIIZ]
  76.  
  77.  
  78.     mov    di,offset pa3        ; Search for '.' in param 3
  79.     mov    cx,24
  80. Szukaj2:mov    al,byte ptr es:[di]
  81.     inc    di
  82.     cmp    al,'.'
  83.     jne    Szukaj2
  84.     mov    byte ptr es:[di],'p'    ; Replace old to new PAL
  85.     mov    byte ptr es:[di+1],'a'
  86.     mov    byte ptr es:[di+2],'l'
  87.     mov    byte ptr es:[di+3],0    ; Mark of end of filename [ASCIIZ]
  88.  
  89.     mov    ax,13h            ; 320 * 200 *256
  90.     int    10h
  91.  
  92.     mov    ah,3dh            ; Open file
  93.     mov    dx,seg CODE    
  94.     mov    ds,dx
  95.     mov    dx,offset pa1        ; Adress to ASCIIZ filename
  96.     mov    al,0            ; Read
  97.     int    21h
  98.     mov    handle0,ax        ; handle
  99.  
  100.  
  101.     mov    bx,handle0
  102.     mov    ax,4202h        ; Set to end of file
  103.     mov    cx,0            ; We do it to know the length
  104.     mov    dx,0            ; of a file.
  105.     int    21h
  106.     mov    cx,ax            ; Length of file in cx
  107.     push    cx            ; store for usage in line 115
  108.     mov    bx,handle0        ; Set counter back to position 0
  109.     mov    ax,4200h
  110.     mov    cx,0
  111.     mov    dx,0
  112.     int    21h
  113.  
  114.  
  115.     pop    cx            ; Take length
  116.     mov    ax,seg data        ; segment whereto
  117.     mov    ds,ax
  118.     lea    dx,kool            ; offset whereto
  119.     mov    ah,3fh
  120.     mov    bx,handle0
  121.     int    21h            ; Read cx bytes 
  122.     
  123.     
  124.  
  125.     mov    ax,data
  126.     mov    ds,ax
  127.     lea    si,kool
  128.     call    Show2sc            ;Show IFF PBM to Screen
  129.     call    ramk            ; Wait 1 Ramk [Why? Bcoz!]
  130.     call    ReadPal            ; Read the palette and copy to PALL
  131.  
  132.     mov    ah,3ch            ; Create file ????.PAL
  133.     mov    cx,0
  134.     mov    dx,seg CODE
  135.     mov    ds,dx
  136.     mov    dx,offset pa3
  137.     int    21h
  138.     mov    handle2,ax        ; Store handle
  139.  
  140.     mov    bx,handle2        ; Restore handle
  141.     mov    dx,seg PALETA
  142.     mov    ds,dx
  143.     mov    dx,offset PALL
  144.     mov    cx,300h
  145.     mov    ah,40h            ; Write 768 bytes of palette
  146.     int    21h
  147.  
  148.     mov    ax,0            ; Set everything to 0 to prevent
  149.     mov    es,ax            ; trash on screen
  150.     mov    di,0
  151.     mov    si,0
  152.  
  153.     mov    ah,3ch            ; Create file ????.RAW
  154.     mov    cx,0
  155.     mov    dx,seg CODE
  156.     mov    ds,dx
  157.     lea    dx,pa2
  158.     int    21h
  159.     mov    handle1,ax        ; Store handle
  160.  
  161.     mov    bx,handle1        ; restore handle. Why not to use
  162.                     ; mov bx,ax? Bcoz You can now insert
  163.                     ; some lines between. 100% safety
  164.     mov    dx,0a000h        ; From where reading
  165.     mov    ds,dx
  166.     mov    dx,0
  167.     mov    cx,64000        ; How many bytes
  168.     mov    ah,40h            ; Write
  169.     int    21h            ; Just do it!
  170.  
  171.  
  172.     mov    ah,3eh            ; Close file
  173.     mov    bx,handle0
  174.     int    21h
  175.  
  176.     mov    ah,3eh            ; Close
  177.     mov    bx,handle1
  178.     int    21h
  179.  
  180.  
  181.     mov    ah,3eh            ; CLose
  182.     mov    bx,handle2
  183.     int    21h
  184.  
  185. Fini:    popa                ;Finito!
  186.     mov    ax,3            ; Restore 3rd video mode
  187.     int    10h
  188.  
  189.     mov    si,0            ; Write report to screen
  190.     mov    di,0            ; It's kinda strange [such mess]
  191.     mov    ah,09h            ; but now it would be easy to
  192.     mov    dx,seg CODE        ; change anything...
  193.     mov    ds,dx
  194.     lea    dx,pl1
  195.     int    21h
  196.     mov    ah,09h
  197.     mov    dx,seg CODE
  198.     mov    ds,dx
  199.     lea    dx,pl2
  200.     int    21h
  201.     mov    ah,09h
  202.     mov    dx,seg CODE
  203.     mov    ds,dx
  204.     lea    dx,pl3
  205.     int    21h
  206.     mov    ah,09h
  207.     mov    dx,seg CODE
  208.     mov    ds,dx
  209.     lea    dx,pl4
  210.     int    21h
  211.  
  212.     mov    ax,4c00h        ; Quit with errorcode 0
  213.     int    21h
  214.  
  215.  
  216. text: db '>> IFF 2 RAW converter by Unreal/SURPRISE! PRODUCTIONS (f)ree 1994, POLAND <<',13,10
  217.       db 'Usage: NAME.LBM [dont`t forget to put EXTENSION with `.`! ',13,10
  218.       db ' The program makes RAW file of the PBM one , output: NAME +.RAW',13,10
  219.       db 'and writes palette in NAME +.PAL',13,10,'$'
  220. pl1:  db '>> IFF 2 RAW converter by Unreal/SURPRISE! PRODUCTIONS (f)ree 1994, POLAND <<',13,10
  221.       db '                   Success!! Converted IFF PBM file...[ '
  222. pa1:  db '                           ',0,13,'$'
  223. pl2:  db '                   to RAW file .......................[ '
  224. pa2:  db '                           ',0,13,'$'
  225. pl3:  db '                   with palette in file in ...........[ '
  226. pa3:  db '                           ',0,13,10,'$'
  227. pl4:  db '           Thanks for choosing Surprise! Look forward to see next utils! ',13,10
  228. pl5:  db '                   S!P Util Zone - 100% safety or Your money back! ',13,10,'$'
  229.  
  230.  
  231. Offset2BODY dw 0
  232. Offset2CMAP dw 0
  233. CurrentDs   dw 0
  234. CurrentSi   dw 0
  235.  
  236. ReadPal:
  237.     mov    ax,seg PALETA        ; Set seg:ofs to PALETTE place
  238.     mov    es,ax
  239.     mov    di,offset PALL
  240.  
  241.     mov    ax,seg DATA
  242.     mov    ds,ax
  243.     mov    si,offset kool
  244.     call    Search4CMAP        ; Find CMAP
  245.  
  246.     mov    si,offset2CMAP
  247.  
  248.     add    si,4
  249.  
  250.     mov    cx,300h
  251. Ojej:    mov    al,[si]
  252.     shr    al,2
  253.     mov    es:[di],al
  254.     inc    si
  255.     inc    di
  256.     loop    Ojej    ;no more ojejs
  257.     ret
  258.  
  259. ;ds seg -picture, offset 2 cmap-  offset for CMAP
  260. Show2Sc:mov    CurrentDs,ds
  261.     mov    CurrentSi,si
  262.     call    Search4PBM
  263.     mov    CurrentDs,ds
  264.     mov    CurrentSi,si
  265.     call    Search4CMAP
  266.     mov    ds,CurrentDs
  267.     mov    si,CurrentSi
  268.     call    SetColors
  269.     mov    ds,CurrentDs
  270.     mov    si,CurrentSi
  271.     call    Search4BODY
  272.     mov    ds,CurrentDs
  273.     mov    si,CurrentSi
  274.     call    show256
  275.     ret
  276. SetColors:
  277.     mov    si,Offset2CMAP
  278.     add    si,4
  279.     mov    al,0ffh
  280.     mov    dx,03c6h
  281.     out    dx,al
  282.  
  283.     xor    ax,ax
  284.     mov     dx,3c8h 
  285.     out      dx,al 
  286.     mov    cx,0300h
  287.     inc      dx 
  288.  
  289. CSET:    mov    al,[si]
  290.     shr    al,2
  291.     out      dx,al 
  292.     inc    si
  293.     loop    CSET
  294.  
  295.     ret
  296.  
  297. Search4CMAP:
  298.     mov    cx,5000
  299. CMAPSearch:
  300.     mov    ax,word ptr ds:[si]
  301.     xchg    ah,al
  302.     cmp    ax,'CM'
  303.     je    CM_Found
  304.     add    si,2
  305.     loop    CMAPSearch
  306.     jmp    NoIFF
  307. CM_Found:
  308.     add    si,2
  309.     mov    ax,word ptr ds:[si]
  310.     xchg    ah,al
  311.     cmp    ax,'AP'
  312.     jne    NoIFF
  313.     add    si,2
  314.     mov    Offset2CMAP,si
  315.     ret
  316.  
  317. Search4PBM:
  318.     mov    cx,5000
  319. PSearch:
  320.     mov    ax,word ptr ds:[si]
  321.     xchg    ah,al
  322.     cmp    ax,'PB'
  323.     je    PB_Found
  324.     add    si,2
  325.     loop    PSearch
  326.     jmp    NoIFF
  327. PB_Found:
  328.     add    si,2
  329.     mov    ax,word ptr ds:[si]
  330.     xchg    ah,al
  331.     cmp    ax,'M '
  332.     jne    NoIFF
  333.     add    si,2
  334.     ret
  335.  
  336. Search4BODY:
  337.     mov    cx,5000
  338. Search:    mov    ax,word ptr ds:[si]
  339.     xchg    ah,al
  340.     cmp    ax,'BO'
  341.     je    BO_Found
  342.     add    si,2
  343.     loop    Search
  344.     jmp    NoIFF
  345.     ret
  346. BO_Found:
  347.     mov    ax,word ptr ds:[si+2]
  348.     xchg    ah,al
  349.     cmp    ax,'DY'
  350.     jne    NoIFF
  351.     mov    Offset2BODY,si
  352. TEND:    ret
  353. NoIFF_T: 
  354.   db 'IFF 2 RAW converter by Unreal/Substance. (s)uck 1994, POLAND',13,10
  355.     db 'Sorry, the file doesn`t appear to be IFF PBM file! ',13,10,'$'
  356. NoIFF:    mov    ax,3
  357.     int    10h
  358.     mov    ah,09h
  359.     mov    dx,seg CODE
  360.     mov    ds,dx
  361.     lea    dx,NoIFF_T
  362.     int    21h
  363.     mov    ax,4c01h
  364.     int    21h    
  365.  
  366. ;________________________________________________________
  367. show256:    mov    ah,12h
  368.     mov    al,1
  369.     mov    bl,36h
  370.     int    10h
  371.     xor    si,si
  372.     mov    si,Offset2BODY
  373.     add    si,8
  374.     mov    ax,0a000h
  375.     mov    es,ax
  376.     mov    di,000
  377.     mov    cx,64000
  378.  
  379. Show1Ln:
  380.     CLD    
  381.  
  382.     mov    al,byte ptr ds:[si]
  383.     cmp    al,0
  384.     jl    Nizsze
  385.     jge    Wyzsze
  386.  
  387. NoMatt: 
  388.     loop    Show1Ln
  389. Kn:    mov    ah,12h
  390.     mov    al,0
  391.     mov    bl,36h
  392.     int    10h
  393.     ret
  394.  
  395.  
  396. Wyzsze:    
  397.     cbw
  398.     mov    dx,cx
  399.     inc    dx
  400.     mov    cx,ax
  401.     inc    cx
  402. WPUNR:    inc    si
  403.     mov    al,byte ptr ds:[si]
  404.     mov    byte ptr es:[di],al
  405.     inc    di
  406.     dec    dx
  407.     cmp    dx,0
  408.     je    Kn
  409.  
  410.     loop    WPUNR
  411.     inc    si
  412.  
  413.     mov    cx,dx
  414.     jmp    NoMatt
  415.     
  416. NiZsze:
  417.     neg    al
  418.     cbw
  419.     mov    dx,cx
  420.     inc    dx
  421.  
  422.     mov    cx,ax
  423.     inc    si
  424.     inc    cx
  425.     mov    al,byte ptr ds:[si]
  426. WPUNR1:    mov    byte ptr es:[di],al
  427.     inc    di
  428.     dec    dx
  429.     cmp    dx,0
  430.     je    Kn
  431.  
  432.     loop    WPUNR1
  433.     inc    si
  434.  
  435.     mov    cx,dx
  436.     cmp    di,60000
  437.     je    Kn
  438.     jmp    NoMatt
  439. RAMK:    pusha
  440.     mov    dx,03dah
  441. C:    in    al,dx
  442.     test    al,8
  443.     jz    c
  444. C1:    in    al,dx
  445.     test    al,8
  446.     jnz    c1
  447.     popa
  448.     ret
  449.  
  450. CODE ENDS
  451. end start
  452.