home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TopWare 18: Liquid
/
Image.iso
/
liquid
/
top1161
/
gfxload.bas
< prev
next >
Wrap
BASIC Source File
|
1994-03-02
|
10KB
|
396 lines
'
' GFX Load V3.13
'
' (c) 1993 by Magic Power-Ware!
'
' Diese Routinen gehören zum Shareware-Programm
'
' SpriteEditor 3.17
'
' von Magic Power-Ware!
'
DECLARE FUNCTION Exist (File$)
DECLARE SUB GFXLoad (DateiName$, x, y)
DECLARE SUB PalLoad (FileName$, lo, hi, PalMem%())
DECLARE SUB FastGFXLoad (DateiName$, x, y)
DIM PalMem(255, 3) AS INTEGER
SCREEN 13 ' *** Auf Grafikmode 13 umschalten
' *** VGA 320x200 Pixel, 256 Farben
GFXLoad "BUBBLE.GFX", 100, 100 ' *** Grafik BUBBLE.GFX (sollte bei
' *** diesem Paket dabeisein) an
' *** Position x=100 : y=100 zeigen
a$ = "STINK.GFX" ' *** a$ auf Filename setzen
x = -13 ' *** x auf -13 setzen
y = 33 ' *** y auf 33 setzen
GFXLoad a$, x, y ' *** Grafik a$ an Position x, y
' *** zeigen. Das - bei x gibt an,
' *** daß der eingeles. Darstellungs-
' *** Code in a$ abgelegt werden
' *** soll.
LOCATE 1, 1
PRINT "Bildhöhe: "; y ' *** Werte darstellen
PRINT "Bildbreite: "; x
LOCATE 7
PRINT "BildCode: "; a$
SOUND 1000, 1 ' *** Auf Tastendruck warten.
DO
LOOP WHILE INKEY$ = ""
CLS
FOR i = 1 TO 256 ' *** Bild vervielfältigen
x = INT(RND * 320) ' *** Zufallspositionen
y = INT(RND * 200)
b$ = "C" + LTRIM$(STR$(INT(RND * 256))) + MID$(a$, 4)
' *** Bearbeiten natürlich möglich.
' *** in diesem Beispiel die Ersten
' *** drei Zeichen (Farbe)
PSET (x, y), POINT(x, y)
DRAW b$ ' *** Mit DRAW darstellen
NEXT i
SOUND 1000, 1 ' *** Auf Tastendruck warten.
DO
LOOP WHILE INKEY$ = ""
CLS
GFXLoad "SMILE.GFX", 100, 100 ' *** Grafik SMILE.GFX (sollte bei
' *** diesem Paket dabeisein) an
' *** Position x=100 : y=100 zeigen
' *** (Mehrfarbige Grafik!)
SOUND 1000, 1 ' *** Auf Tastendruck warten.
DO ' *** Palette des Bildes stimmt
LOOP WHILE INKEY$ = "" ' *** noch nicht!
PalLoad "SMILE.PAL", 32, 64, PalMem() ' *** Palette SMILE.PAL (sollte bei
' *** diesem Paket dabeisein) wird
' *** eingeladen und dargestellt.
' *** Die eingelesenen RGB-Werte
' *** werden in das Array PalMem
' *** geschrieben (ggf. zum Weiter-
' *** verwenden). Beim Einlesen
' *** werden nur die Farben 32 bis
' *** 64 berücksichtigt.
SOUND 1000, 1 ' *** Auf Tastendruck warten.
DO
LOOP WHILE INKEY$ = ""
END ' *** Beenden
ISError: ' *** Von EXIST (File$) benötigt!!!
RESUME NEXT
FUNCTION Exist (File$)
ON ERROR GOTO ISError:
aaa = FREEFILE
OPEN File$ FOR BINARY AS aaa
abc = LOF(aaa)
CLOSE aaa
IF abc > 1 THEN
Exist = abc
ELSE
Exist = 0
KILL File$
END IF
END FUNCTION
SUB FastGFXLoad (DateiName$, x, y)
aaa = FREEFILE
IF Exist(DateiName$) < 2 THEN
x = 0
y = 0
EXIT SUB
END IF
OPEN DateiName$ FOR INPUT AS aaa
PSET (x, y), POINT(x, y)
DO
LINE INPUT #1, a$
LOOP WHILE a$ <> "[DATABLOCK]"
DateiName$ = ""
DO
LINE INPUT #aaa, a$
IF a$ = "[DATAENDE]" THEN EXIT DO
DRAW a$
LOOP
CLOSE aaa
END SUB
SUB GFXLoad (DateiName$, x, y)
aaa = FREEFILE
IF Exist(DateiName$) < 2 THEN
x = 0
y = 0
EXIT SUB
END IF
IF x < 0 THEN
Flag = -1
x = x * SGN(x)
END IF
OPEN DateiName$ FOR INPUT AS aaa
LINE INPUT #aaa, a$
PSET (x, y), POINT(x, y)
xp = x
yp = y
IF LEFT$(a$, 6) = "CZ-GFX" THEN
GOTO newsystem:
END IF
PSET (x - 1, y - 1), POINT(x - 1, y - 1)
xp = x - 1
yp = y - 1
LINE INPUT #aaa, b$
x = VAL(b$)
LINE INPUT #aaa, b$
y = VAL(b$)
IF LEFT$(a$, 3) = "QBD" THEN
LINE INPUT #aaa, a$
DRAW a$
ELSEIF LEFT$(a$, 3) = "CZS" THEN
FOR i% = 1 TO y
LINE INPUT #aaa, a$
FOR m% = 1 TO x
PSET (xp + m%, yp + i%), ASC(MID$(a$, m%, 1)) - 16
NEXT m%
NEXT i%
ELSE
x = 0
y = 0
END IF
CLOSE aaa
EXIT SUB
newsystem:
DO
LINE INPUT #1, a$
a$ = UCASE$(a$)
LOOP WHILE a$ <> "[INFOBLOCK]"
DO
LINE INPUT #1, a$
a$ = RTRIM$(LTRIM$(UCASE$(a$)))
IF LEFT$(a$, 5) = "MODE=" THEN
Mode$ = MID$(a$, 6)
ELSEIF LEFT$(a$, 8) = "VERSION=" THEN
Version$ = MID$(a$, 9)
IF Version$ > "3.00" THEN
x = 0
y = 0
EXIT SUB
END IF
ELSEIF LEFT$(a$, 6) = "WIDTH=" THEN
x = VAL(MID$(a$, 7))
ELSEIF LEFT$(a$, 7) = "HEIGHT=" THEN
y = VAL(MID$(a$, 8))
END IF
LOOP WHILE a$ <> ""
DO
LINE INPUT #1, a$
LOOP WHILE a$ <> "[DATABLOCK]"
IF Mode$ = "BITMAP" THEN
DO
LINE INPUT #aaa, a$
IF a$ = "[DATAENDE]" THEN EXIT DO
FOR m% = 0 TO LEN(a$) - 1
r = ASC(MID$(a$, m% + 1, 1))
IF r = 1 THEN r = 0
PSET (xp + m%, yp + i%), r
NEXT m%
i% = i% + 1
LOOP
CLOSE 1
ELSEIF Mode$ = "QBDRAW" THEN
DateiName$ = ""
DO
LINE INPUT #aaa, a$
IF a$ = "[DATAENDE]" THEN EXIT DO
IF Flag = -1 THEN
DateiName$ = DateiName$ + a$
END IF
DRAW a$
LOOP
END IF
CLOSE aaa
END SUB
SUB PalLoad (FileName$, lo, hi, PalMem() AS INTEGER)
aaa = FREEFILE
IF Exist(FileName$) THEN
OPEN FileName$ FOR INPUT AS aaa
LINE INPUT #aaa, a$
IF a$ <> "CZ-PAL" THEN
CLOSE aaa
EXIT SUB
END IF
DO
LINE INPUT #aaa, a$
LOOP WHILE a$ <> "[INFOBLOCK]"
DO
LINE INPUT #aaa, a$
a$ = UCASE$(a$)
IF LEFT$(a$, 6) = "COUNT=" THEN
Count = VAL(MID$(a$, 7))
END IF
IF LEFT$(a$, 8) = "VERSION=" THEN
Version$ = MID$(a$, 9)
IF Version$ = "SPECIAL" THEN GOTO SpecialLoad:
IF Version$ > "3.13" THEN
CLOSE aaa
EXIT SUB
END IF
END IF
LOOP WHILE a$ <> "[DATABLOCK]"
IF Version$ = "3.00" THEN
DO
LINE INPUT #aaa, a$
IF a$ = "[DATAENDE]" THEN EXIT DO
IF INSTR(a$, "[") > 1 AND INSTR(a$, "]") > 1 AND INSTR(a$, "=") > 1 THEN
Farbe = VAL(a$)
RGB = VAL(MID$(a$, INSTR(a$, "[") + 1))
Wert = VAL(MID$(a$, INSTR(a$, "=") + 1))
IF Farbe <= hi AND Farbe >= lo AND RGB < 4 AND Wert < 64 THEN
PalMem(Farbe, RGB) = INT(Wert)
END IF
END IF
LOOP
CLOSE 1
FOR i% = lo TO hi
PALETTE i%, PalMem(i%, 1) + PalMem(i%, 2) * 256 + PalMem(i%, 3) * 65536
NEXT i%
ELSEIF Version$ = "3.01" THEN
DO
LINE INPUT #aaa, a$
IF a$ = "[DATAENDE]" THEN EXIT DO
IF INSTR(a$, "r") > 1 AND INSTR(a$, "g") > 1 AND INSTR(a$, "b") > 1 AND INSTR(a$, "=") > 1 THEN
Farbe = VAL(a$)
r = VAL(MID$(a$, INSTR(a$, "r") + 1))
g = VAL(MID$(a$, INSTR(a$, "g") + 1))
b = VAL(MID$(a$, INSTR(a$, "b") + 1))
IF Farbe <= hi AND Farbe >= lo AND r < 64 AND g < 64 AND b < 64 THEN
PalMem(Farbe, 1) = INT(r)
PalMem(Farbe, 2) = INT(g)
PalMem(Farbe, 3) = INT(b)
END IF
END IF
LOOP
CLOSE aaa
FOR i% = lo TO hi
PALETTE i%, PalMem(i%, 1) + PalMem(i%, 2) * 256 + PalMem(i%, 3) * 65536
NEXT i%
ELSEIF Version$ = "3.12" THEN
DO
LINE INPUT #aaa, a$
IF a$ = "[DATAENDE]" THEN EXIT DO
Farbe = VAL(a$)
r = VAL(LTRIM$(MID$(a$, 7, 3)))
g = VAL(LTRIM$(MID$(a$, 10, 3)))
b = VAL(LTRIM$(MID$(a$, 14, 3)))
IF Farbe <= hi AND Farbe >= lo AND r < 64 AND g < 64 AND b < 64 THEN
PalMem(Farbe, 1) = INT(r)
PalMem(Farbe, 2) = INT(g)
PalMem(Farbe, 3) = INT(b)
END IF
LOOP
CLOSE aaa
FOR i% = lo TO hi
PALETTE i%, PalMem(i%, 1) + PalMem(i%, 2) * 256 + PalMem(i%, 3) * 65536
NEXT i%
ELSEIF Version$ = "3.13" THEN
DO
LINE INPUT #aaa, a$
IF a$ = "[DATAENDE]" THEN EXIT DO
Farbe = VAL(a$)
r = ASC(MID$(a$, 5, 1)) - 64
g = ASC(MID$(a$, 6, 1)) - 64
b = ASC(MID$(a$, 7, 1)) - 64
IF Farbe <= hi AND Farbe >= lo AND r < 64 AND g < 64 AND b < 64 THEN
PalMem(Farbe, 1) = INT(r)
PalMem(Farbe, 2) = INT(g)
PalMem(Farbe, 3) = INT(b)
END IF
LOOP
CLOSE aaa
FOR i% = lo TO hi
PALETTE i%, PalMem(i%, 1) + PalMem(i%, 2) * 256 + PalMem(i%, 3) * 65536
NEXT i%
END IF
END IF
EXIT SUB
SpecialLoad:
DO
LINE INPUT #aaa, a$
a$ = UCASE$(a$)
LOOP WHILE a$ <> "[DATABLOCK]"
DO
LINE INPUT #aaa, a$
IF a$ <> "" THEN
PALETTE lo, VAL(a$)
lo = lo + 1
END IF
LOOP WHILE EOF(aaa) = 0
CLOSE aaa
END SUB