Hi,
Thanks for the tutorial, it runs nicely !
This was the first page i stumble upon :
http://www.petesqbsite.com/sections/tutorials/tuts/interrupts.html
But i get an error here (overflow)
Offset% = VAL("&H" + HEX$(320 * y%)) ' Hack to get integers bigger than 32767
Hint : load the source code to get the line breaks....and remove the "amp" stuff.
Here it is :
'$INCLUDE: 'qb.bi'
TYPE BMPHeaderType
id AS STRING * 2 'Should be "BM"
size AS LONG 'Size of the data
rr1 AS INTEGER '
rr2 AS INTEGER '
offset AS LONG 'Position of start of pixel data
horz AS LONG '
wid AS LONG 'Image width
hei AS LONG 'Image height
planes AS INTEGER '
bpp AS INTEGER 'Should read 8 for a 256 colour image
pakbyte AS LONG '
imagebytes AS LONG 'Width*Height
xres AS LONG '
yres AS LONG '
colch AS LONG '
ic AS LONG '
pal AS STRING * 1024 'Stored as <Blue, Green, Red, 0>
END TYPE
DIM inregs AS RegTypeX ' Data IN
DIM outregs AS RegTypeX ' Data OUT
DIM FileHandle AS INTEGER ' Handle used to reference the BMP file
DIM BMPHeader AS BmpHeaderType ' The BMP header
file$ = "demo.bmp" + CHR$(0) ' BMP file. DOS requires us to append a CHR$(0).
inregs.AX = &H3D00 ' Open the File
inregs.DS = VARSEG(file$) ' Segment address of the string
inregs.DX = SADD(file$) ' Offset address of the string (we use SADD
' when working with variable length strings)
CALL InterruptX(&H21, inregs, outregs)
IF outregs.FLAGS AND 1 THEN ' Check it opened ok
PRINT "Error opening >> " + file$
BEEP: END
END IF
FileHandle = outregs.AX ' Save the file handle
inregs.AX = &H3F00 ' Read in the header
inregs.BX = FileHandle
inregs.CX = 1078
inregs.DS = VARSEG(BMPHeader)
inregs.DX = VARPTR(BMPHeader)
CALL InterruptX(&H21, inregs, outregs)
SCREEN 13 ' Set dislay mode
a$ = BMPHeader.pal ' Change the palette
OUT &H3C8, 0
FOR i% = 1 TO 1024 STEP 4
b% = ASC(MID$(a$, i%, 1)) \ 4 'blue
g% = ASC(MID$(a$, i% + 1, 1)) \ 4 'green
r% = ASC(MID$(a$, i% + 2, 1)) \ 4 'red
OUT &H3C9, r%
OUT &H3C9, g%
OUT &H3C9, b%
NEXT
PixelBuffer$ = SPACE$(BMPHeader.wid)
iHeight% = BMPHeader.hei - 1
Segment% = &HA000 ' Address of SCREEN 13 memory
inregs.AX = &H3F00
inregs.BX = FileHandle
inregs.CX = BMPHeader.wid
FOR y% = iHeight% TO 0 STEP -1
Offset% = VAL("&H" + HEX$(320& * y%)) ' Hack to get integers bigger than 32767
inregs.DS = Segment%
inregs.DX = Offset%
CALL InterruptX(&H21, inregs, outregs)
NEXT y%
inregs.DS = 0 ' Close the file
inregs.DX = 0
inregs.AX = &H3E00
inregs.BX = FileHandle
CALL InterruptX(&H21, inregs, outregs)
SLEEP
=========
Thanks,
L