Qbasicnews.com

Full Version: Bitmaps trouble
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
when I run this code the bitmap that is loaded is a little bit streaky and upside down. I can't figure out what is wrong with it, the Qbasic code works correctly, the port is doing weird ass things

SCREEN 13
dim bpl as double, ypl as double, xpl as double, attr as byte
OPEN "pal.vga" FOR INPUT AS #1
FOR a = 0 TO 255
INPUT #1, r
INPUT #1, g
INPUT #1, b
PALETTE a,(b * 65536 + g * 256 + r)
NEXT
CLOSE
open "c:\outside.bmp" for binary as #1
GET #1, 19, xsz: GET #1, 23, ysz
FOR ypl = 1 TO ysz
IF ypl > 200 THEN EXIT FOR
FOR xpl = 1 TO xsz
IF xpl > 320 THEN EXIT FOR
bpl = LOF(1) - (ypl * (3 - (xsz + 3) MOD 4)) - ypl * xsz + xpl
GET #1, bpl, attr
PSET (xpl - 1, ypl - 1), attr
NEXT
NEXT
CLOSE #1
sleep


This is the original source that does work
(QBasic)

'$DYNAMIC
DEFINT A-Z
SCREEN 13
OPEN "pal.vga" FOR INPUT AS #1
FOR a = 0 TO 255
INPUT #1, r
INPUT #1, g
INPUT #1, b
PALETTE a,(b * 65536 + g * 256 + r)
NEXT
CLOSE
open "c:\outside.bmp" for binary as #1
GET #1, 19, xsz: GET #1, 23, ysz
FOR ypl& = 1 TO ysz
IF ypl& > 200 THEN EXIT FOR
FOR xpl& = 1 TO xsz
IF xpl& > 320 THEN EXIT FOR
bpl& = LOF(1) - (ypl& * (3 - (xsz + 3) MOD 4)) - ypl& * xsz + xpl&
GET #1, bpl&, attr
PSET (xpl& - 1, ypl& - 1), attr
NEXT
NEXT
CLOSE #1
You declared the GET'ed variables as DOUBLE's in the FB version but they are undeclared in the QB version, meaning they will be 16-bit integers as a DEFINT A-Z was used in the top.