Metropoli BBS
VIEWER: pcx2tbf.asm MODE: TEXT (ASCII)
; 386POWER example program #1.

        .386p
code32 segment para public use32
       assume cs:code32,ds:code32

include 386power.inc
include 386file.inc
include 386arg.inc
include pcx.inc
include 386video.inc
include pattern.inc
include chtil.inc

public  _Main
        align byte
        
nomem   db 'Not enough memory for .TBF buffer',CR,LF,'$'
nopars2 db 'file name for .TBF destination not found',CR,LF 
nopars  db 'Not enough file names on command line',CR,LF
        db 'PCX2TBF needs to be called this way:',CR,LF
        db '   PCX2TBF file.PCX file.TBF',CR,LF,CR,LF
        db 'And remember that the file extensions are not checked!'
        db CR,LF,CR,LF,'$'
badpcx  db 'Not a valid PCX file',CR,LF,'$'

PatBase dd 0
        
_Main:  sti
        call _ArgInit
        mov eax,TILESIZE*70
        mov _386Return,offset nomem
        call _GetLoMem
        jc orrore
        mov PatBase,eax
        call _ArgFile
        mov _386Return,offset nopars
        cmp byte ptr [esi],0
        je orrore
        mov _DispX,320
        mov _ScrX,320
        mov _DispY,200
        mov _ScrY,200
        call _SetXVDMode
        mov eax,0
        mov edx,0
        call _DisplayStart
        call _PcxLoad
        mov _386Return,offset badpcx
        cmp _PcxDecoded,0
        je orrore
        call _PageFlip0
        ; fetch tile bitmaps
        mov esi,_ScrBase
        mov edi,PatBase
        mov edx,0
p_row:        
        mov eax,0
p_col:        
        call _GetPat
        add eax,32
        cmp eax,320
        jb p_col
        add edx,26
        cmp edx,182
        jb p_row
        ; now write .TBF file
        call _ArgFile
        mov _386Return, offset nopars2
        cmp byte ptr [esi],0
        je orrore
        mov _386Return,offset _386Terminator 
        ; If we got here, no errors. But we let the last word to _FSave.
        mov eax,TILESIZE*70
        mov edi,PatBase
        call _FSave
orrore:
        jmp _Exit
code32  ends
        end

[ RETURN TO DIRECTORY ]