'=========================================================================== ' Subject: PB PCX DECODER Date: 10-21-95 (18:54) ' Author: Dave Navarro, Jr. Code: PB ' Origin: FidoNet POWER_BAS Echo Packet: GRAPHICS.ABC '=========================================================================== 'Decode PCX files 'by Dave Navarro, Jr. DEFINT A-Z TYPE PcxHeader Mfg AS BYTE Ver AS BYTE Enc AS BYTE Bpp AS BYTE XMin AS INTEGER YMin AS INTEGER XMax AS INTEGER YMax AS INTEGER Hres AS INTEGER Vres AS INTEGER Pal AS STRING * 48 Resrv AS BYTE ColPl AS BYTE Bpl AS INTEGER PalTyp AS INTEGER Filler AS STRING * 58 END TYPE DIM Header AS PcxHeader DIM ByteBuffer AS BYTE OPEN "B",1,"TMP.PCX" GET# 1,,Header IF Header.Mfg <> 10 AND Header.Ver <> 5 THEN PRINT "Not a 256 color PCX file!" END END IF Tmp& = LOF(1) - 768 SEEK# 1, Tmp& GET$ 1,768,Palete$ FOR I = 1 TO 768 Tmp? = ASC(MID$(Palete$,I,1)) SHIFT RIGHT Tmp?,2 MID$(Palete$,I,1)=CHR$(Tmp?) NEXT I SEEK# 1, 128 Wid = Header.Xmax - Header.Xmin + 1 Dep = Header.Ymax - Header.Ymin + 1 Byt = Header.Bpl PRINT Wid;"x";Dep;"x";2^Header.Bpp I$=INPUT$(1) Mode13 1 REG 1, &H1012 REG 2, 0 REG 3, 256 REG 4, STRPTR(Palete$) REG 9, STRSEG(Palete$) CALL INTERRUPT &H10 FOR Y = 0 TO Dep - 1 FOR X = 0 TO Byt - 1 GET# 1,,ByteBuffer ByteBuffer = ByteBuffer AND &HFF IF (ByteBuffer AND &HC0) = &HC0 THEN Times = ByteBuffer AND &H3F GET# 1,,ByteBuffer FOR I = 1 TO Times PlotPixel ByteBuffer NEXT I ELSE PlotPixel ByteBuffer END IF NEXT X NEXT Y CLOSE 1 BEEP I$=INPUT$(1) Mode13 0 END SUB PlotPixel(Z AS BYTE) SHARED Wid STATIC X, Y DEF SEG = &HA000 POKE Y*320+X, Z DEF SEG INCR X IF X > Wid THEN X = 0 INCR Y END IF END SUB SUB Mode13(Bool) IF Bool THEN REG 1, &H0013 ELSE REG 1, &H0003 END IF CALL INTERRUPT &H10 END SUB