Article ID: 101516
Article Last Modified on 8/16/2005
REDIM tmp(0 TO (BitPlaneSize - 1) \ 4) AS LONG ' allocate memory
DEF SEG = VARSEG(tmp(0))
BLOAD f$, VARPTR(tmp(0))
DIM j AS LONG
FOR j = 0 TO BitPlaneSize - 1
DEF SEG = VARSEG(tmp(0))
DIM byte AS INTEGER
byte = PEEK(VARPTR(tmp(0)) + j)
DEF SEG = VideoPageSegment
POKE j, byte
NEXT
REDIM tmp(0) AS LONG ' deallocate memory
' put the next statement at the module level, all on one line
DECLARE SUB fmemcpy CDECL ALIAS "__fmemcpy" (BYVAL o%, BYVAL s%,
SEG s AS ANY, BYVAL n%)
...
REDIM tmp(0 TO (BitPlaneSize - 1) \ 4) AS LONG ' allocate memory
DEF SEG = VARSEG(tmp(0))
BLOAD f$, VARPTR(tmp(0))
CALL fmemcpy(0, VideoPageSegment, tmp(0), BitPlaneSize)
REDIM tmp(0) AS LONG ' deallocate memory
DECLARE SUB BSAVEImage ()
DECLARE SUB BLOADImage ()
CONST BitPlaneSize = 28000 ' Amount of disk space needed to save one
' bit plane (in bytes) for SCREEN 9.
CONST VideoPageSegment = &HA800 ' Beginning of page 1 for
' SCREEN 9 in video memory.
CONST FileName = "IMAGE"
SCREEN 9, , 1, 1 ' Set the visual and active pages to 1.
CLS
LINE (50, 50)-(150, 150),, BF ' Draw a solid box on the screen.
CALL BSAVEImage
CLS
PRINT "Press any key to reload the image "
WHILE INKEY$ = "": WEND
CALL BLOADImage
WHILE INKEY$ = "": WEND
END
SUB BLOADImage
FOR i% = 0 TO 3
OUT &H3C4, 2 ' Indicates index to Map Register.
OUT &H3C5, 2 ^ i% ' Select the bit plane to load into.
f$ = FileName + CHR$(i% + 48) + ".GRA"
' replace the following two statements with the code for one
' of the workarounds
DEF SEG = VideoPageSegment
BLOAD f$, 0
NEXT i%
DEF SEG
END SUB
SUB BSAVEImage
DEF SEG = VideoPageSegment
FOR i% = 0 TO 3
OUT &H3CE, 4 ' Select Read Map Select Register.
OUT &H3CF, i% ' Select the bit plane to save.
f$ = FileName + CHR$(i% + 48) + ".GRA"
BSAVE f$, 0, BitPlaneSize
NEXT i%
DEF SEG
END SUB
Keywords: kbprb KB101516