fb:porticula NoPaste
Simpler PCX-Loader
Uploader: | chutullu |
Datum/Zeit: | 16.10.2005 16:58:02 |
REM Hinweis:
REM ---------
REM (p) by chutullu 2004; chutullu2@yahoo.de
REM ----------------------------------------------------
REM Loader ist auf PCX Files der Version 3.0 und der Groesse 320 x 200
REM optimiert. Die Headerinformationen sind nur zu Dokumentationszwecken
REM enthalten.
REM
TYPE pcxHeader
Kennung AS STRING * 1: REM offset 1
Version AS STRING * 1: REM offset 2
rle AS STRING * 1: REM offset 3
bpp AS STRING * 1: REM offset 4
scr AS STRING * 8: REM offset 5
Swidth AS STRING * 2: REM offset 13
Sheight AS STRING * 2: REM offset 15
pal AS STRING * 48: REM offset 17
res1 AS STRING * 1: REM offset 65
plan AS STRING * 1: REM offset 66
bpl AS STRING * 2: REM offset 67
Apal AS STRING * 2: REM offset 69
res2 AS STRING * 58: REM offset 71
END TYPE
TYPE pcxPal
r AS STRING * 1
g AS STRING * 1
b AS STRING * 1
END TYPE
DIM PCX AS pcxHeader
DIM pal AS pcxPal
DIM lo$, lco$, x, y, xMax, yMax
DIM pcxName$
pcxName$ = "bg.pcx": REM hier den Bildname eintragen
xMax = 320: REM Hoehe
yMax = 200: REM Breite
CLS
PRINT "simple pcxLOADer fuer 320 x 200 x 265"
PRINT "-------------------------------------"
DO: LOOP UNTIL INKEY$ > ""
SCREEN 13
OPEN pcxName$ FOR BINARY AS #255
REM header auslesen
GET #255, , PCX
REM letzten 767 Byte der Datei sind die Palette
REM
REM DAC Info
REM --------
REM Ports: &h3c8 - Pixel Write Address
REM &h3c9 - Pixel Color Value
REM
SEEK #255, LOF(255) - 767:
FOR col = 0 TO 255
GET #255, , pal
OUT &H3C8, col: REM Farbwert (0..255)
OUT &H3C9, ASC(pal.r) \ 4: REM Rotanteil
OUT &H3C9, ASC(pal.g) \ 4: REM Gruenanteil
OUT &H3C9, ASC(pal.b) \ 4: REM Blauanteil
NEXT col
SEEK #255, 129
lo$ = STRING$(1, " ")
lco$ = STRING$(1, " ")
x = 0: y = 0
REM fuer Hoehe/Breite koennten auch Headerinformationen benutzt werden,
REM um Bilder die nicht dem Format 320x200 entsprechen darzustellen
REM Schreibt die Daten direkt in den Bildschirmspeicher
DEF SEG = &HA000
DO
GET #255, , lo$
akt = ASC(lo$)
IF akt > 191 THEN
GET #255, , lco$
col = ASC(lco$)
'via BASIC
'LINE (x, y)-STEP(akt - 192, 0), col
'direkt in den Bildschirmspeicher
FOR i% = 0 TO akt - 192
POKE y * 320 + x + i%, col
NEXT i%
x = x + akt - 192
ELSE
col = akt
'via BASIC
'PSET (x, y), col
'direkt in Bildschirmspeicher
POKE y * 320 + x, col
x = x + 1
END IF
IF x >= xMax THEN
x = 0: y = y + 1
END IF
LOOP UNTIL y >= yMax
DEF SEG
CLOSE #255
REM wait4key
DO: LOOP UNTIL INKEY$ > ""