-Question-

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Anonymous

-Question-

Post by Anonymous »

Hey, i ahve some questions,so.....
Okay here i go:
1)How(or what code i need) to make q-basic play wav,midi,or mp3 music formats?.
2)How can i put in q-basic paints(jpg,bmp)?

Thanks in advance....
:arrow:
Z!re
Veteran
Posts: 887
Joined: Wed Aug 04, 2004 11:15 am

Post by Z!re »

1) You need sound code, so you can send to the soundcard, and then you nede to get the format of Wav, Mid.. you cannot play MP3 in QB itself, it's just too slow. Do a search for DMALIB, or WavPlay

2) You use this code:

Code: Select all

DEFINT A-Z
TYPE BMPHeaderType
 ID AS STRING * 2
 Size AS LONG
 RSV1 AS INTEGER
 RSV2 AS INTEGER
 offset AS LONG
 HORZ AS LONG
 WID AS LONG
 HEI AS LONG
 PLANES AS INTEGER
 BPP AS INTEGER
 COMPRESSION AS LONG
 IMAGESIZE AS LONG
 xRes AS LONG
 yRes AS LONG
 CLRUSED AS LONG
 CLRIMPORT AS LONG
 Pal AS STRING * 1024
END TYPE
DECLARE SUB LoadBMP (DestSeg%, SegxRes%, SegyRes%, File$, sX%, sY%, SwitchPal%, Trans%)


CLS : SCREEN 13

LoadBMP &HA000, 320, 200, "MyPic.BMP", 0, 0, 1, -1
'&HA000 = Video Segment, the segment of the screen
'320 and 200 is the resolution of the videosegment, in screen 13
'"MyPic.BMP" is just a BMP file, must be 256 color
'0, 0 is the top, left location to start drawing the image from
'1 is if it should change the palette to that in the BMP (0 is no)
'-1 is the color to treat as transperent, -1 means all will be drawn

SUB LoadBMP (DestSeg%, SegxRes%, SegyRes%, File$, sX, sY, SwitchPal%, Trans%)
DIM bmp AS BMPHeaderType
f% = FREEFILE
OPEN File$ FOR BINARY AS #f%
GET #f%, , bmp
IF SwitchPal% THEN
 pall$ = bmp.Pal
 IF LEN(pall$) = 1024 THEN
  OUT &H3C8, 0
  FOR I% = 1 TO 1024 STEP 4
   b% = ASC(MID$(pall$, I%, 1)) \ 4
   g% = ASC(MID$(pall$, I% + 1, 1)) \ 4
   r% = ASC(MID$(pall$, I% + 2, 1)) \ 4
   OUT &H3C9, r%
   OUT &H3C9, g%
   OUT &H3C9, b%
  NEXT I%
 END IF
END IF
Byte$ = SPACE$(bmp.WID)
DEF SEG = DestSeg%
wide% = bmp.WID - 1
Hite% = bmp.HEI - 1
offs& = LOC(f) + 1
FOR y% = Hite% TO 0 STEP -1
 IF sY + y >= 0 AND sY + y < SegyRes THEN
  GET #f%, offs&, Byte$
  FOR x% = 0 TO wide%
   IF sX + x >= 0 AND sX + x < SegxRes THEN
    c% = ASC(MID$(Byte$, x% + 1, 1))
    IF c% <> Trans% THEN
     POKE (sX% + x%) + (sY% + y%) * (SegxRes + 0&), c%
    END IF
   END IF
  NEXT x%
 END IF
 offs& = offs& + bmp.WID
NEXT y%
CLOSE #f
DEF SEG
END SUB
I have left this dump.
Guest

Post by Guest »

:D omg!thnx anyway.
Nodtveidt
Veteran
Posts: 826
Joined: Sun Jul 25, 2004 4:24 am
Location: Quebradillas, PR
Contact:

Post by Nodtveidt »

The only way to play MP3s through QB is by using a DS4QB variant.
Anonymous

Post by Anonymous »

And then I wish DS4QB didn't have that file-access information exchange... it doesn't always work :(
Post Reply