'=========================================================================== ' Subject: DISPLAY ARRAYS TO MEMORY Date: 01-07-97 (00:33) ' Author: Nathan Barkei Code: QB, QBasic, PDS ' Origin: alt.lang.basic Packet: GRAPHICS.ABC '=========================================================================== 'From: preekout@aol.com (PreekOUT) 'Newsgroups: alt.lang.basic 'Subject: Re: Sprite masking... 'Date: 7 Jan 1997 00:33:11 GMT '' '' Video Image Munger '' v1.0d4 '' By Nathan Barkei '' Created 24L96 '' '' '' Purpose: Display arrays to memory by comparison of bits '' '' sprite name, offset, xpos, ypos, mode of placement, backcolor '' '' DEFINT A-Z SUB placegra (Sprite(), image, x, y, mode, tpc) imagewidth = Sprite(image) / 8 imageheight = Sprite(image + 1) WWIDTH = imagewidth '' ''CHECK IF OUTSIDE SCREEN WIDTH '' wx = x IF x < 0 THEN WWIDTH = imagewidth + x wx = 0 sourceofs = ABS(x) ELSEIF x + imagewidth > 320 THEN WWIDTH = 320 - x END IF '' '' ERROR 5 IS A GEN ERROR REDIF ALL ERROR 5 ARE INTERNAL VIDEO MUNGE ERRORS '' IF WWIDTH < 0 THEN ERROR 5 wheight = imageheight wy = y IF y < 0 THEN wheight = imageheight + y wy = 0 sourceofs = sourceofs + (ABS(y) * imagewidth) ELSEIF y + imageheight > 200 THEN wheight = 200 - y END IF IF wheight < 0 THEN ERROR 5 '' '' MAKE NEW ARRAY FOR MUNGE DATA '' elements = ((WWIDTH + 1) \ 2) * wheight + 1 REDIM wimage(elements) GET (wx, wy)-(wx - 1 + WWIDTH, wy - 1 + wheight), wimage wsegment = VARSEG(wimage(0)) woffset = 4 elmperimg = ((imagewidth + 1) \ 2) * imageheight + 2 startelm = image sourceseg = VARSEG(Sprite(startelm)) sourceofs = sourceofs + VARPTR(Sprite(startelm)) + 4 '' ''SELECT TYPE OF OPPERATION '' SELECT CASE mode '' ''IN FRONT OF PIX NOT BIT 00 '' CASE 0 FOR py = 1 TO wheight FOR PX = 0 TO WWIDTH - 1 DEF SEG = sourceseg sc = PEEK(sourceofs + PX) IF sc THEN DEF SEG = wsegment POKE woffset + PX, sc END IF NEXT woffset = woffset + WWIDTH sourceofs = sourceofs + imagewidth NEXT '' ''TRANSPOSED ONTO ALL BIT 00 '' CASE 1 FOR py = 1 TO wheight FOR PX = 0 TO WWIDTH - 1 DEF SEG = sourceseg sc = PEEK(sourceofs + PX) DEF SEG = wsegment wc = PEEK(woffset + PX) IF wc = 0 THEN POKE woffset + PX, sc END IF NEXT woffset = woffset + WWIDTH sourceofs = sourceofs + imagewidth NEXT '' ''PLACED WITH BIT 00 AS BCOLOR '' CASE 2 FOR py = 1 TO wheight FOR PX = 0 TO WWIDTH - 1 DEF SEG = sourceseg sc = PEEK(sourceofs + PX) IF sc THEN DEF SEG = wsegment POKE woffset + PX, sc END IF IF sc = 0 THEN DEF SEG = wsegment POKE woffset + PX, tpc END IF NEXT woffset = woffset + WWIDTH sourceofs = sourceofs + imagewidth NEXT '' ''JUST SHOW EVERYTHING '' CASE 3 FOR py = 1 TO wheight FOR PX = 0 TO WWIDTH - 1 DEF SEG = sourceseg sc = PEEK(sourceofs + PX) DEF SEG = wsegment wc = PEEK(woffset + PX) POKE woffset + PX, sc NEXT woffset = woffset + WWIDTH sourceofs = sourceofs + imagewidth NEXT END SELECT '' ''PLACE WORK ARRAY '' PUT (wx, wy), wimage, PSET END SUB