home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Hack-Phreak Scene Programs
/
cleanhpvac.zip
/
cleanhpvac
/
S1P_I2R.ZIP
/
I2R.ASM
< prev
next >
Wrap
Assembly Source File
|
1994-05-08
|
8KB
|
452 lines
; I2R sourcefile
; Unreal/SURPRISE! PRODUCTIONS
DATA SEGMENT USE16 PUBLIC PARA 'DATA'
kool label
dw 32000 dup (0)
DATA ENDS
PALETA SEGMENT USE16 PUBLIC PARA 'DATA'
pall label
db 300h dup (0)
db 2000 dup (0)
PALETA ENDS
CODE SEGMENT
.286c
ASSUME CS:CODE, DS:DATA
JUMPS
handle0 dw 0 ; Place for handles of files
handle1 dw 0
handle2 dw 0
errormess: ; Message if error
mov ah,09h
mov dx,seg CODE
mov ds,dx
lea dx,text ; USAGE: NAME
int 21h
mov ax,4c01h
int 21h
Start: pusha
mov si,080h ; Start of parameter
cmp byte ptr [si],0 ; Check length of parameter
jz errormess ; zero? No parameter!
mov cl,byte ptr [si] ; how many characters
dec cl ; minus 1 [there was 1 space char]
mov ch,0 ; erase high value
inc si ; next character [skip space]
mov ax,seg CODE ; set the segment
mov es,ax
mov di,offset pa1 ; space for the 1st parameter
Petlad: inc si ; next character
mov al,byte ptr [si] ; take it to al
mov byte ptr es:[di],al ; save into space
inc di ; increase pointer
loop Petlad ; copy the parameter
mov si,offset pa1
mov di,offset pa2
mov bx,offset pa3
mov cx,22 ; max 22 chars [no way]
KopiujF:mov al,byte ptr es:[si] ; take char
mov byte ptr es:[di],al ; copy to param 2
mov byte ptr es:[bx],al ; and to param 3
inc si ; Increase pointer
inc di ; ---=---
inc bx ; ---=---
loop KopiujF
mov di,offset pa2 ; Search for '.' in param 2
mov cx,24
Szukaj: mov al,byte ptr es:[di]
inc di
cmp al,'.'
jne Szukaj
mov byte ptr es:[di],'r' ; replace old extension to RAW
mov byte ptr es:[di+1],'a'
mov byte ptr es:[di+2],'w'
mov byte ptr es:[di+3],0 ;mark of end of filename [ASCIIZ]
mov di,offset pa3 ; Search for '.' in param 3
mov cx,24
Szukaj2:mov al,byte ptr es:[di]
inc di
cmp al,'.'
jne Szukaj2
mov byte ptr es:[di],'p' ; Replace old to new PAL
mov byte ptr es:[di+1],'a'
mov byte ptr es:[di+2],'l'
mov byte ptr es:[di+3],0 ; Mark of end of filename [ASCIIZ]
mov ax,13h ; 320 * 200 *256
int 10h
mov ah,3dh ; Open file
mov dx,seg CODE
mov ds,dx
mov dx,offset pa1 ; Adress to ASCIIZ filename
mov al,0 ; Read
int 21h
mov handle0,ax ; handle
mov bx,handle0
mov ax,4202h ; Set to end of file
mov cx,0 ; We do it to know the length
mov dx,0 ; of a file.
int 21h
mov cx,ax ; Length of file in cx
push cx ; store for usage in line 115
mov bx,handle0 ; Set counter back to position 0
mov ax,4200h
mov cx,0
mov dx,0
int 21h
pop cx ; Take length
mov ax,seg data ; segment whereto
mov ds,ax
lea dx,kool ; offset whereto
mov ah,3fh
mov bx,handle0
int 21h ; Read cx bytes
mov ax,data
mov ds,ax
lea si,kool
call Show2sc ;Show IFF PBM to Screen
call ramk ; Wait 1 Ramk [Why? Bcoz!]
call ReadPal ; Read the palette and copy to PALL
mov ah,3ch ; Create file ????.PAL
mov cx,0
mov dx,seg CODE
mov ds,dx
mov dx,offset pa3
int 21h
mov handle2,ax ; Store handle
mov bx,handle2 ; Restore handle
mov dx,seg PALETA
mov ds,dx
mov dx,offset PALL
mov cx,300h
mov ah,40h ; Write 768 bytes of palette
int 21h
mov ax,0 ; Set everything to 0 to prevent
mov es,ax ; trash on screen
mov di,0
mov si,0
mov ah,3ch ; Create file ????.RAW
mov cx,0
mov dx,seg CODE
mov ds,dx
lea dx,pa2
int 21h
mov handle1,ax ; Store handle
mov bx,handle1 ; restore handle. Why not to use
; mov bx,ax? Bcoz You can now insert
; some lines between. 100% safety
mov dx,0a000h ; From where reading
mov ds,dx
mov dx,0
mov cx,64000 ; How many bytes
mov ah,40h ; Write
int 21h ; Just do it!
mov ah,3eh ; Close file
mov bx,handle0
int 21h
mov ah,3eh ; Close
mov bx,handle1
int 21h
mov ah,3eh ; CLose
mov bx,handle2
int 21h
Fini: popa ;Finito!
mov ax,3 ; Restore 3rd video mode
int 10h
mov si,0 ; Write report to screen
mov di,0 ; It's kinda strange [such mess]
mov ah,09h ; but now it would be easy to
mov dx,seg CODE ; change anything...
mov ds,dx
lea dx,pl1
int 21h
mov ah,09h
mov dx,seg CODE
mov ds,dx
lea dx,pl2
int 21h
mov ah,09h
mov dx,seg CODE
mov ds,dx
lea dx,pl3
int 21h
mov ah,09h
mov dx,seg CODE
mov ds,dx
lea dx,pl4
int 21h
mov ax,4c00h ; Quit with errorcode 0
int 21h
text: db '>> IFF 2 RAW converter by Unreal/SURPRISE! PRODUCTIONS (f)ree 1994, POLAND <<',13,10
db 'Usage: NAME.LBM [dont`t forget to put EXTENSION with `.`! ',13,10
db ' The program makes RAW file of the PBM one , output: NAME +.RAW',13,10
db 'and writes palette in NAME +.PAL',13,10,'$'
pl1: db '>> IFF 2 RAW converter by Unreal/SURPRISE! PRODUCTIONS (f)ree 1994, POLAND <<',13,10
db ' Success!! Converted IFF PBM file...[ '
pa1: db ' ',0,13,'$'
pl2: db ' to RAW file .......................[ '
pa2: db ' ',0,13,'$'
pl3: db ' with palette in file in ...........[ '
pa3: db ' ',0,13,10,'$'
pl4: db ' Thanks for choosing Surprise! Look forward to see next utils! ',13,10
pl5: db ' S!P Util Zone - 100% safety or Your money back! ',13,10,'$'
Offset2BODY dw 0
Offset2CMAP dw 0
CurrentDs dw 0
CurrentSi dw 0
ReadPal:
mov ax,seg PALETA ; Set seg:ofs to PALETTE place
mov es,ax
mov di,offset PALL
mov ax,seg DATA
mov ds,ax
mov si,offset kool
call Search4CMAP ; Find CMAP
mov si,offset2CMAP
add si,4
mov cx,300h
Ojej: mov al,[si]
shr al,2
mov es:[di],al
inc si
inc di
loop Ojej ;no more ojejs
ret
;ds seg -picture, offset 2 cmap- offset for CMAP
Show2Sc:mov CurrentDs,ds
mov CurrentSi,si
call Search4PBM
mov CurrentDs,ds
mov CurrentSi,si
call Search4CMAP
mov ds,CurrentDs
mov si,CurrentSi
call SetColors
mov ds,CurrentDs
mov si,CurrentSi
call Search4BODY
mov ds,CurrentDs
mov si,CurrentSi
call show256
ret
SetColors:
mov si,Offset2CMAP
add si,4
mov al,0ffh
mov dx,03c6h
out dx,al
xor ax,ax
mov dx,3c8h
out dx,al
mov cx,0300h
inc dx
CSET: mov al,[si]
shr al,2
out dx,al
inc si
loop CSET
ret
Search4CMAP:
mov cx,5000
CMAPSearch:
mov ax,word ptr ds:[si]
xchg ah,al
cmp ax,'CM'
je CM_Found
add si,2
loop CMAPSearch
jmp NoIFF
CM_Found:
add si,2
mov ax,word ptr ds:[si]
xchg ah,al
cmp ax,'AP'
jne NoIFF
add si,2
mov Offset2CMAP,si
ret
Search4PBM:
mov cx,5000
PSearch:
mov ax,word ptr ds:[si]
xchg ah,al
cmp ax,'PB'
je PB_Found
add si,2
loop PSearch
jmp NoIFF
PB_Found:
add si,2
mov ax,word ptr ds:[si]
xchg ah,al
cmp ax,'M '
jne NoIFF
add si,2
ret
Search4BODY:
mov cx,5000
Search: mov ax,word ptr ds:[si]
xchg ah,al
cmp ax,'BO'
je BO_Found
add si,2
loop Search
jmp NoIFF
ret
BO_Found:
mov ax,word ptr ds:[si+2]
xchg ah,al
cmp ax,'DY'
jne NoIFF
mov Offset2BODY,si
TEND: ret
NoIFF_T:
db 'IFF 2 RAW converter by Unreal/Substance. (s)uck 1994, POLAND',13,10
db 'Sorry, the file doesn`t appear to be IFF PBM file! ',13,10,'$'
NoIFF: mov ax,3
int 10h
mov ah,09h
mov dx,seg CODE
mov ds,dx
lea dx,NoIFF_T
int 21h
mov ax,4c01h
int 21h
;________________________________________________________
show256: mov ah,12h
mov al,1
mov bl,36h
int 10h
xor si,si
mov si,Offset2BODY
add si,8
mov ax,0a000h
mov es,ax
mov di,000
mov cx,64000
Show1Ln:
CLD
mov al,byte ptr ds:[si]
cmp al,0
jl Nizsze
jge Wyzsze
NoMatt:
loop Show1Ln
Kn: mov ah,12h
mov al,0
mov bl,36h
int 10h
ret
Wyzsze:
cbw
mov dx,cx
inc dx
mov cx,ax
inc cx
WPUNR: inc si
mov al,byte ptr ds:[si]
mov byte ptr es:[di],al
inc di
dec dx
cmp dx,0
je Kn
loop WPUNR
inc si
mov cx,dx
jmp NoMatt
NiZsze:
neg al
cbw
mov dx,cx
inc dx
mov cx,ax
inc si
inc cx
mov al,byte ptr ds:[si]
WPUNR1: mov byte ptr es:[di],al
inc di
dec dx
cmp dx,0
je Kn
loop WPUNR1
inc si
mov cx,dx
cmp di,60000
je Kn
jmp NoMatt
RAMK: pusha
mov dx,03dah
C: in al,dx
test al,8
jz c
C1: in al,dx
test al,8
jnz c1
popa
ret
CODE ENDS
end start