home *** CD-ROM | disk | FTP | other *** search
- comment ;-)
-
- Smiley comment, eh?
-
- This program is devoted to show LBMs. There was need for a viewer for
- standard VGAs which can handle 256 pixel tall Amiga pictures.
- Here it is.
- The 320*255½ video mode was experimentally worked out with Robert
- Schmidt's Tweak Ten.
- As I noticed, it's impossible to make a full 320*256 resolution
- on a standard VGA. Possible for Tseng cards (of course), but for
- example, the Trident boards didn't like it at all. However,
- the 320*255+0.5 mode worked everywhere. (It's refreshing frequency
- is about 57 Hz.)
- Summa summarum, at 256 pixel tall pictures the last row is half-height.
-
- If this proggy doesn't show a valid LBM picture, it's probably because:
-
- -LBM is 'ILBM'-type, not 'PBM '
- -LBM isn't 320 pixel wide
- -LBM isn't packed with method 1
- -LBM is masked
- -You don't own a VGA or 386 ;-)
-
-
-
- o equ offset ;Useful abbrevations to
- b equ byte ptr ;optimize coding time
- w equ word ptr
- d equ dword ptr
-
- a segment
- assume cs:a,ds:a
- org 100h
- ;-----------------------------------------------
- go:
- push sp ;Test 286
- pop ax
- xor ax,sp ;AL will be 0
- jne error ;No 286
- .286
- mov ah,1ah ;Test VGA (AL=0)
- int 10h
- cmp al,1ah
- jne error ;No VGA
- cmp bl,7
- jb error ;No VGA
-
- push 3000h ;Test 386
- popf ;(This does for us the CLD too)
- pushf
- pop ax
- test ax,3000h
- je error ;No 386
- .386
- ;-----------------------------------------------
- mov di,81h ;Prepare for command line check
- movzx ecx,b ds:[di-1] ;Fetch parameter string length
- mov al,' '
- rep scasb ;Skip spaces
- jcxz error ;Exit if wasn't any parameter
- mov dx,di ;Save parameter's address
- dec dx ;(file's name)
- repne scasb ;Seek to filename's end
-
- mov ax,3d00h ;Prepare AX for file opening
- stosb ;Put 0 after file's name
- int 21h ;Open file
- jb error ;Exit on bad filename
-
- lea sp,$ ;Make safe stack
- ;(Prevent picture from being
- ;overwritten by the stack)
-
- mov bx,o freemem
- push bx ;Save freemem's offset
- call adjustds ;Align DS to freemem
-
- xchg bx,ax ;Put file's handle to bx
- cwd ;Offset for data (DX will be 0)
- mov cx,08000h ;Read 8000h bytes in one step
- loadloop:
- mov ah,3fh ;Prepare for file reading
- int 21h ;Read file
- or ax,ax ;AX=0: file read over
- je loadready
- mov ax,ds ;Adjust DS
- add ax,0800h
- mov ds,ax
- jmp loadloop
- loadready:
- mov ah,3eh ;Close file
- int 21h
-
- ;-----------------------------------------------
- push cs
- pop ds bx ;Get picture address (freemem)
-
- cmp d [bx],'MROF' ;Check IFF signature (FORM)
- jne error
- cmp d [bx+8],' MBP' ;Check picture type (PBM)
- jne error
- cmp w [bx+20],4001h ;Check: width=320?
- je noerror
-
- ;-----------------------------------------------
- error:
- mov dx,o msg ;Fetch error message's address
- mov ah,9
- int 21h ;Write error message
- int 20h ;Exit COM program
-
- ;-----------------------------------------------
- noerror:
- movzx eax,w [bx+22] ;Get picture's height
- xchg ah,al ;Big->little endian conversion
- imul ax,40 ;Put number of pixels to EBP
- imul ebp,eax,8 ;(height*320)
- neg ax ;Calculate starting screen
- add ah,40 ;offset: (128-height/2)*80
- push ax ;Save screen offset
- ;(Pictures which are not 256
- ;tall, will be dispalyed on
- ;the middle of the screen)
-
- cmp b [bx+1eh],1 ;Check: packing=1? (CmpByteRun)
- jne error
-
- call blank ;Avoid filckering (Carry=0)
- mov ax,0013h ;Init 320*200*256 mode
- int 10h
- call blank ;Avoid flickering (again)
-
- mov si,o regset ;Init 320*256 tweaked mode
- mov dl,0c2h
- outsb
- mov dl,0c4h
- outsw
- mov cx,feed_3d4_length
- mov dl,0d4h
- rep outsw
-
- ;-----------------------------------------------
- mov eax,'PAMC' ;Seek to CMAP
- call searchchunk
-
- mov al,0 ;Prepare palette
- mov ch,3
- mov dl,0c8h
- out dx,al
- inc dx
- loadpal:
- lodsb
- shr al,2
- out dx,al ;Load palette
- loop loadpal
-
- ;-----------------------------------------------
- mov eax,'YDOB' ;Seek to BODY
- call searchchunk
-
- push 0a000h ;Prepare for video operations
- pop es
-
- xor ax,ax ;Clear lower 256k video memory
- mov ch,80h ;CL=0...
- rep stosw ;(DI is even)
-
- mov dl,0c4h ;Prepare plane enable register
- mov al,2 ;DH=3...
- out dx,al
- inc dx
- mov al,11h ;Prepare plane enable mask
-
- pop di ;Retrieve screen offset
- unpack:
- mov bx,si ;Adjust DS:SI
- and si,0fh ;to maintain 'huge' pointer
- call adjustds ;(SI<10h always)
-
- movzx cx,b [si] ;Get control byte
- inc si
- or cl,cl ;Test control byte
- js replicated ;Jump if 'Replicated' ( <0 ),
- ;stay if 'Stored'
- inc cx
- sub ebp,ecx ;Adjust pixel counter
- jb memok ;Exit if all the pixels are out
- storeloop:
- out dx,al ;Send mask
- movsb ;Send pixel
- rol al,1 ;Adjust mask
- adc di,0ffffh ;Adjust video offset
- loop storeloop
- jmp unpack
-
- replicated:
- neg cl
- inc cx
- sub ebp,ecx ;Adjust pixel counter
- jb memok ;Exit if all the pixels are out
- mov ah,[si] ;Get pixel
- inc si
- replicloop:
- out dx,al ;Send mask
- mov es:[di],ah ;Send pixel
- rol al,1 ;Adjust mask
- adc di,0 ;Adjust video offset
- loop replicloop
- jmp unpack
-
- ;-----------------------------------------------
- memok:
- call blank ;Turn the sceen on (Carry=1)
- cbw ;AH will be 0
- int 16h ;Wait for a key
-
- call blank ;Avoid youknowhat... (Carry=0)
- mov ax,3 ;Init 80*25 textmode
- int 10h
- int 20h ;Exit COM program
-
-
-
- ;-----------------------------------------------
- adjustds:
- shr bx,4 ;Adjust DS to point DS:BX
- mov cx,ds
- add cx,bx
- mov ds,cx
- ret
-
-
-
- ;-----------------------------------------------
- blank:
- mov ax,2101h ;Turn on/off the screen,
- jnb turn_off ;depending on Carry Flag
-
- mov dl,0dah
- retrace:
- in al,dx
- test al,8
- je retrace
- mov ax,0101h
- turn_off:
- mov dx,03c4h
- out dx,ax
- ret
-
-
-
- ;-----------------------------------------------
- searchchunk:
- mov di,o freemem+28h ;The chunk's address after BMHD
- seekchunk:
- scasd ;Check type
- je chunkfound
-
- mov bx,[di+2] ;Get length
- xchg bh,bl ;Big->little endian conversion
- lea di,[bx+di+4] ;Next chunk's address to DI
- and bx,1 ;Chunks are word-aligned!
- add di,bx
- jmp seekchunk
- chunkfound:
- lea si,[di+4] ;Chunk's data address to SI
- ret
-
-
-
- ;This register set kicks the
- ;card to 320*255½ tweaked mode
- ;(256 isn't suitable for some
- ;non-Tseng cards)
- regset db 0e3h,4,6
- feed3d4 db 11h,0,6,20h,7,3eh,10h,0ffh,12h,0feh,15h,0ffh,16h,10h
- db 14h,0,17h,0e3h
- feed_3d4_length equ ($-feed3d4)/2
-
- msg db 13,10
- db 'Viewer by Ervin / AbaddoN',13,10
- db 'Use: lbm256 file.ext',13,10
- db 'Minimal config: 386+VGA',13,10
- db 'The file must be 320 pixel wide ''PBM ''-type IFF',13,10,'$'
-
- align 16
- freemem label byte
-
- a ends
- end go
-