Working on playing sounds through stereo.

Discuss whatever you want here--both QB and non-QB related. Anything from the DEF INT command to the meaning of life!

Moderators: Pete, Mods

Post Reply
TRANERAECK
Coder
Posts: 29
Joined: Thu Mar 24, 2011 3:08 am

Working on playing sounds through stereo.

Post by TRANERAECK » Mon Nov 21, 2011 12:00 pm

Check my latest post: :P
Last edited by TRANERAECK on Thu Dec 01, 2011 4:24 pm, edited 1 time in total.

TRANERAECK
Coder
Posts: 29
Joined: Thu Mar 24, 2011 3:08 am

FORGOT something

Post by TRANERAECK » Mon Nov 21, 2011 9:37 pm

THE stuff I posted Before was dumb. :oops:
Last edited by TRANERAECK on Thu Dec 01, 2011 4:25 pm, edited 1 time in total.

TRANERAECK
Coder
Posts: 29
Joined: Thu Mar 24, 2011 3:08 am

Have SUBSYS identity

Post by TRANERAECK » Mon Nov 21, 2011 10:06 pm

There is a SUBSYS listed it is 103C2802 AND has rev 1001 as one of the device controls. IF ANYONE knows the corresponding address or can compute this to a number between 0 - 65172 it would help for I think this is for the reg addr and data addr where they will differ by 1 number; hence the 1001 entry. Ok if 103C2802 is a number between 0 - 65172 anyone with this code should be able to play sound through the stereo speakers.

See did not know what I am talking about.... :wink: I am dumb.... :oops:
Last edited by TRANERAECK on Thu Dec 01, 2011 4:26 pm, edited 1 time in total.

TRANERAECK
Coder
Posts: 29
Joined: Thu Mar 24, 2011 3:08 am

Here is some of it finished.

Post by TRANERAECK » Mon Nov 21, 2011 10:50 pm

The stuff is in the new post. :twisted:
Last edited by TRANERAECK on Thu Dec 01, 2011 4:25 pm, edited 1 time in total.

TRANERAECK
Coder
Posts: 29
Joined: Thu Mar 24, 2011 3:08 am

IF IT WAS TO WORK???

Post by TRANERAECK » Thu Dec 01, 2011 4:23 pm

HERE is the real play a sound!!!!!!!!!!!!!!!! Graphics is great in QBASIC you could define the pixel with WINDOW and a SCREEN setup but sound? Well have it. You have to use the WINMM.DLL and here is how:

Code: Select all

REM PROGRAM: SOUN3.BAS
REM PROGRAMMER: Gregory Lyons
REM Uses info found at www.bytes.com replier James to
REM 	-question how to play sound in .net
REM Uses Jabaco program for accessing winmm.dll
REM JABACO PROGRAM: SNDCALL.EXE

DECLARE SUB NameWav(FileName AS STRING, SYNCH AS INTEGER)

PRINT"What wave file would you like to play?"
INPUT"Please list full path->"; FileName$
PRINT"Would you like to run it asynchronously or not?"
PRINT"SIMPLE Y or N->";
SYNCH$ = INPUT$(1)
IF SYNCH$ = "" OR SYNCH$ <> "Y" THEN SYNCH$ = "N"
IF SYNCH$ = "Y" OR SYNCH$ = "y" THEN SYNCH = 1
IF SYNCH$ = "N" OR SYNCH$ = "n" THEN SYNCH = 0
CALL NameWav(FileName$, SYNCH)
SHELL "SNDCALL.EXE"
END

SUB NameWav(WavName AS STRING, PLAYTYPE AS INTEGER)
	OPEN "somefilename" FOR OUTPUT AS #1
		WRITE #1 WavName$; PLAYTYPE
	CLOSE #1
END SUB

Here is the SUB ROUTINE AND PROGRAM FOR VB6 OR JABACO:
Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Integer, ByVal dwFlags As Integer) As Integer
Declare Sub PlayAudio(ByVal FileName As String, ByVal Synch As Integer)

OPEN "thefilefromQBASIC"
OBTAIN FileName AND Synch
CALL PlayAudio(FileName$, Synch)
END

Sub PlayAudio(ByVal FileName As String)
'//call win32api function to play audio (wav) file alert
Dim retval As Integer
retval = PlaySound(FileName, 0, Synch)
'last param is SND_SYNC as integer
'value set to 0 plays sound Synchronously (waits until sound ends before
playing next)
'value set to 1 plays sound Asynchronously (does not wait to play next
sound)
PRINT retval
End Sub
 
There it is QBASIC is awesome!!!!!!!!!!!!!!!!! :twisted:
Last edited by TRANERAECK on Sat Dec 03, 2011 12:13 am, edited 1 time in total.

User avatar
burger2227
Veteran
Posts: 2368
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Thu Dec 01, 2011 5:05 pm

That code is for VB, not Qbasic...

Why do you SHELL to SNDCALL.EXE?


QB64 code:

Code: Select all

DECLARE DYNAMIC LIBRARY "winmm"
  FUNCTION PlaySound% ALIAS PlaySoundA (lpszName AS STRING, BYVAL hModule AS INTEGER, BYVAL dwFlags AS INTEGER)
END DECLARE

LINE INPUT "Enter WAV sound file name: ", FileName$
PRINT "Play asynchronously?(Y/N) ";
K$ = UCASE$(INPUT$(1))
PRINT K$
IF K$ = "Y" THEN Synch = 1 ELSE Synch = 0

retval% = PlaySound(FileName$, 0, Synch)
Just add the Library code to a Qbasic BAS program and compile it in QB64.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

TRANERAECK
Coder
Posts: 29
Joined: Thu Mar 24, 2011 3:08 am

Found this code on a website

Post by TRANERAECK » Fri Dec 02, 2011 11:52 pm

I cannot get the VB code to work because I researched Randall L Glass in PowerBasic and the call to winmm.dll is going through kernel32.dll and there are miscellaneous characters to use with winmm.dll such as a note atthe end of winmm.dll entry when called. Check powerbasic call dll from there website the values are in DllData.dat. Open it with notepad and see what the dll needs for the computer to recognize play wave. Also I found this interesting I have the QB64 code from source forge and their compiler doesn't work made in QB4.5 as it is claimed. The compiler is 562KB all QB files are 64KB or less then you use another module. Cheesecake Basic is the closest thing I see to a complete compiler from QB. Anywho, here is something that may work if the OUT and INP is set right I called my version &H106 and I do not know the other call base unit for the sound to work I got nothing out of my speaker on this but the game is cool good idea for simple space shooter. Here it is:

Code: Select all

'Name      : Targets.bas ver 1.1
'Purpose   : Demonstraits using fx sounds in a Qbasic/QuickBASIC game.
'Date      : 1/24/97
'Finalized : 1/25/97
'Author    : Tim Truman
'Copyright (c) 1997  Nocturnal Creations. All Rights Reserved

'Changes from ver 1.0 :
'Allows speed setting. Change below to suit version of basic.

'Note: In order to run in QuickBASIC 4.5 you must load the QB.QLB library.
'      Example: QB /l QB.QLB

TYPE sprite
  x  AS INTEGER
  y  AS INTEGER
  xl AS INTEGER
  yl AS INTEGER
  w AS INTEGER
  h AS INTEGER
  c AS INTEGER
  mem1 AS INTEGER
  mem2 AS INTEGER
  alive AS INTEGER
END TYPE

DECLARE SUB DoBoss ()
DECLARE SUB Docollisions ()
DECLARE SUB Eraseimages ()
DECLARE SUB DoExplosions ()
DECLARE SUB DoLazer ()
DECLARE SUB DoScore ()
DECLARE SUB DoShip ()
DECLARE SUB DoStars ()
DECLARE SUB DoTarget ()
DECLARE SUB Mouse (func%)
DECLARE SUB playsfx (sfx$)
DECLARE SUB Showimages ()
DECLARE FUNCTION Bbox (x1%, y1%, w1%, h1%, x2%, y2%, w2%, h2%)


CONST True = -1
CONST False = 0

COMMON SHARED level%, levelflag%, score&, targetcounter%
COMMON SHARED _MOUSEX%, mousey%, mouseb%, Speed%

DIM SHARED c$(8)   'FM register information for 9 channels
c$(0) = "&hB0&h20&h23&h40&h43&h60&h63&h80&h83&hA0&HBD&HC0&HE0&HE3&hB0"
c$(1) = "&hB1&h21&h24&h41&h44&h61&h64&h81&h84&hA1&HBD&HC1&HE1&HE4&hB1"
c$(2) = "&hB2&h22&h25&h42&h45&h62&h65&h82&h85&hA2&HBD&HC2&HE2&HE5&hB2"
c$(3) = "&hB3&h28&h2B&h48&h4B&h68&h6B&h88&h8B&hA3&HBD&HC3&HE8&HEB&hB3"
c$(4) = "&hB4&h29&h2C&h49&h4C&h69&h6C&h89&h8C&hA4&HBD&HC4&HE9&HEC&hB4"
c$(5) = "&hB5&h2A&h2D&h4A&h4D&h6A&h6D&h8A&h8D&hA5&HBD&HC5&HEA&HED&hB5"
c$(6) = "&hB6&h30&h33&h50&h53&h70&h73&h90&h93&hA6&HBD&HC6&HF0&HF3&hB6"
c$(7) = "&hB7&h31&h34&h51&h54&h71&h74&h91&h94&hA7&HBD&HC7&HF1&HF4&hB7"
c$(8) = "&hB8&h32&h35&h52&h55&h72&h75&h92&h95&hA8&HBD&HC8&HF2&HF5&hB8"

DIM SHARED sfx$(25)                   'dim array to hold 26 sounds
OPEN "various.sfx" FOR INPUT AS #1    'open the .SFX file
FOR sfxnum% = 0 TO 25                 'load all sounds
 INPUT #1, sfx$(sfxnum%)              'load sound into string
NEXT                                  'next
CLOSE #1                              'close the file

DIM SHARED Mcode%(0 TO 56)           'array for machine code
DEF SEG = VARSEG(Mcode%(0))          'set array segment
offset% = VARPTR(Mcode%(0))          'set array address
FOR i% = 0 TO 56                     'read in machine code
 READ byte%
 POKE offset% + i%, byte%            'poke byte into array
NEXT

DIM SHARED shipimage%(0 TO 260)      'array for ship image
FOR i% = 0 TO 260                    'first element to last
 READ shipimage%(i%)                 'read element
NEXT

DIM SHARED ship AS sprite
DIM SHARED lazer AS sprite           'array for ship lazer
DIM SHARED target(4) AS sprite       'array for for targets
DIM SHARED expl(5) AS sprite         'array for for explosions

PRINT " Thanks for trying Targets. "
PRINT " You should have recieved this version of Targets"
PRINT " with a shareware copy of 'FX' the Sound effects editor."
PRINT " If you don't have FX your missing out on trying a great program."
PRINT " FX makes adding sound effects to your Qbasic(r) programs easy. "
PRINT " If you would like a shareware copy of FX send me a note"
PRINT " at AOL:TimTruman,Internet:TimTruman@aol.com or CompuServe:74734,2203."
PRINT ""
PRINT "                     Targets Ver 1.0"
PRINT ""
PRINT " To play game :"
PRINT " Move mouse to move ship. Press left mouse button to fire."
PRINT " Press ESC to quit game."
PRINT " "
PRINT " Press any key to continue"
DO: LOOP UNTIL LEN(INKEY$)

SCREEN 7, , 1, 0

CLS

Mouse 0                              'initalize mouse
_MOUSEX% = 160: mousey% = 100         'mouse start
Mouse 4                              'set mouse position

ship.mem1 = 3                 'number of ship lives
ship.alive = True             'so ship will appear
ship.w = 25: ship.h = 32      'set width and height for collision detection
level% = 1                    'level start
Speed% = 3                    'About 3 for Qbasic and 6 for QuickBasic

playsfx sfx$(6)

DO
 Mouse 3
 DoStars
 DoShip
 DoTarget
 DoLazer
 PCOPY 1, 0
 Eraseimages
 DoExplosions
 Docollisions
LOOP UNTIL ship.mem1 = 0 OR INKEY$ = CHR$(27) OR level% = 20


SCREEN 7, , 0, 0
DoScore
LOCATE 10, 1
playsfx sfx$(5)               'play sound effect
PRINT "                Game Over         "
PRINT
PRINT "        Thanks for playing Targets."
PRINT
PRINT "        Press any key to continue. "
DO: LOOP UNTIL LEN(INKEY$)
SCREEN 0, 0, 0


'machine language for mouse
DATA &H55,&H89,&HE5,&H8B,&H5E,&H0C,&H8B,&H07,&H50,&H8B
DATA &H5E,&H0A,&H8B,&H07,&H50,&H8B,&H5E,&H08,&H8B,&H0F
DATA &H8B,&H5E,&H06,&H8B,&H17,&H5B,&H58,&H1E,&H07,&HCD
DATA &H33,&H53,&H8B,&H5E,&H0C,&H89,&H07,&H58,&H8B,&H5E
DATA &H0A,&H89,&H07,&H8B,&H5E,&H08,&H89,&H0F,&H8B,&H5E
DATA &H06,&H89,&H17,&H5D,&HCA,&H08,&H00


'ship image data
DATA &H20,&H20
DATA &H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000
DATA &H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000
DATA &H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000
DATA &H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000
DATA &H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000
DATA &H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000
DATA &H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000
DATA &H0000,&H0000,&H0080,&H0000,&H0080,&H0000,&H0080,&H0000,&H0000
DATA &H0000,&H0080,&H0000,&H0080,&H0000,&H0080,&H0000,&H0000,&H0100
DATA &H0040,&H0100,&H0040,&H0100,&H0040,&H0000,&H0080,&H0100,&H0040
DATA &H0100,&H0040,&H0100,&H0040,&H0000,&H0080,&H0100,&H0040,&H0100
DATA &H0040,&H0100,&H0040,&H0000,&H0080,&H0200,&H0020,&H0300,&H0060
DATA &H0300,&H0060,&H0100,&H00C0,&H0200,&H0020,&H0300,&H0060,&H0300
DATA &H0060,&H0100,&H00C0,&H0200,&H0020,&H0300,&H0060,&H0300,&H0060
DATA &H0100,&H00C0,&H0400,&H0000,&H0700,&H0070,&H0700,&H0070,&H0300
DATA &H00E0,&H0400,&H0000,&H0700,&H0070,&H0700,&H0070,&H0300,&H00E0
DATA &H0800,&H0088,&H0800,&H0088,&H0800,&H0088,&H0700,&H0070,&H0800
DATA &H0088,&H0800,&H0088,&H0800,&H0088,&H0700,&H0070,&H1000,&H0084
DATA &H1000,&H0084,&H1000,&H0084,&H0F00,&H0078,&H1001,&H4084,&H1001
DATA &H4084,&H1001,&H4084,&H0F00,&H0078,&H2101,&H4042,&H2101,&H4042
DATA &H2101,&H4042,&H1E00,&H00BC,&H4101,&H4041,&H4101,&H4041,&H4101
DATA &H4041,&H3E00,&H00BE,&H8101,&HC040,&H8101,&HC040,&H8101,&HC040
DATA &H7E00,&H00BF,&H0101,&H4040,&H0101,&H4040,&H0101,&H4040,&HFE00
DATA &H80BF,&H0302,&H2060,&H0302,&H2060,&H0302,&H2060,&HFC01,&HC09F
DATA &H0304,&H1060,&H0304,&H1060,&H0304,&H1060,&HFC03,&HE09F,&H030A
DATA &H2860,&H030A,&H2860,&H030A,&H2860,&HFC05,&HD09F,&H0311,&H4460
DATA &H0311,&H4460,&H0311,&H4460,&HFC0E,&HB89F,&H833F,&HFE60,&H833F
DATA &HFE60,&H833F,&HFE60,&H7C00,&H009F,&H7F00,&H00FF,&H7F00,&H00FF
DATA &H7F00,&H00FF,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000,&H0000

FUNCTION Bbox (x1%, y1%, w1%, h1%, x2%, y2%, w2%, h2%)
'Checks for collisions using the bounding box method.
'Expects constants True and False to be defined in Main.
'Returns True if collision , False if no collision.


IF (x1% >= x2% + w2%) OR (x2% > x1% + w1%) OR (y1% > y2% + h2%) OR (y2% > y1% + h1%) THEN
 Bbox = False
ELSE
 Bbox = True
END IF


END FUNCTION

SUB Docollisions



'check for target hits with lazer
FOR i = 0 TO UBOUND(target)
IF target(i).alive = True THEN
  IF Bbox(lazer.x, lazer.y, lazer.w, lazer.h, target(i).x, target(i).y, target(i).w, target(i).h) THEN
    playsfx sfx$(1)               'play sound effect
    lazer.alive = False
    target(i).alive = False
    score& = score& + 20
    DoScore
    FOR e = 0 TO UBOUND(expl)
     IF expl(e).alive = False THEN
      expl(e).alive = True
      expl(e).x = target(i).x
      expl(e).y = target(i).y
      EXIT FOR
     END IF
    NEXT
  END IF
 END IF
NEXT

'check for target hits with ship
FOR i = 0 TO UBOUND(target)
 IF target(i).alive = True THEN
  IF Bbox(ship.x, ship.y + ship.h / 2, ship.w, ship.h, target(i).x, target(i).y, target(i).w, target(i).h) THEN
    ship.alive = False
    target(i).alive = False
    playsfx sfx$(4)               'play sound effect
    FOR n = 1 TO 15
    FOR e = 0 TO UBOUND(expl)
     IF expl(e).alive = False THEN
      expl(e).alive = True
      expl(e).x = ship.x + RND * 20
      expl(e).y = ship.y + RND * 20
      EXIT FOR
     END IF
   NEXT
   NEXT
  END IF
 END IF
NEXT


END SUB

SUB DoExplosions

FOR i = 0 TO UBOUND(expl)
IF expl(i).alive THEN
  
   IF expl(i).mem1 <14> 3 THEN
    expl(i).mem2 = expl(i).mem2 + 1
    CIRCLE (expl(i).x, expl(i).y), expl(i).mem2, 0
   END IF
   IF expl(i).mem2 = 15 THEN
     expl(i).alive = False
     expl(i).mem1 = 0:   expl(i).mem2 = 0
     IF ship.alive = False THEN DoScore
   END IF

END IF

NEXT
END SUB

SUB DoLazer

 IF mouseb% = 1 THEN    'Fire weapon
  IF lazer.alive = False THEN
   lazer.alive = True
   lazer.x = _MOUSEX% + 6
   lazer.y = 178
   lazer.w = 24
   lazer.h = 5
   playsfx sfx$(0)               'play sound effect
  END IF
 END IF


IF lazer.alive THEN
  lazer.xl = lazer.x   'save last position for erase
  lazer.yl = lazer.y

  LINE (lazer.x, lazer.y)-(lazer.x, lazer.y - lazer.h), 14, BF
  LINE (lazer.x + 20, lazer.y)-(lazer.x + 20, lazer.y - lazer.h), 14, BF

  lazer.y = lazer.y - 3

  IF lazer.y <20> 287 THEN _MOUSEX% = 287      'keep image on screen
 IF mousey% > 167 THEN mousey% = 167      'ditto
 ship.x = _MOUSEX%: ship.y = 160:
 IF ship.alive THEN
  PUT (ship.x, ship.y), shipimage%(0), PSET
 END IF

END SUB

SUB DoStars


STATIC bgcolor, fgcolor, velocity
STATIC ns AS INTEGER, oldstarx()  AS INTEGER, oldstary() AS INTEGER
STATIC starx() AS INTEGER, stary() AS INTEGER, starspeed() AS INTEGER

IF ns = 0 THEN        ' First time here initialize values
 ns = 10
 DIM oldstarx(ns)   AS INTEGER
 DIM oldstary(ns)   AS INTEGER
 DIM starx(ns)      AS INTEGER
 DIM stary(ns)      AS INTEGER
 DIM starspeed(ns)  AS INTEGER

 FOR c = 0 TO ns
   stary(c) = (RND * 170) + 20
   starx(c) = RND * 319
   starspeed(c) = (RND * 2) + 1
 NEXT
    
END IF


FOR c = 0 TO ns

 IF oldstary(c) >= 199 THEN   'need a new star
   stary(c) = 20
   starx(c) = RND * 319
   starspeed(c) = (RND * 2) + 1
   oldstary(c) = stary(c)
 END IF
 oldstary(c) = stary(c)      '  save position to erase oldstar
 oldstarx(c) = starx(c)
 stary(c) = stary(c) + starspeed(c)  ' move star
 PSET (starx(c), stary(c)), 7  ' write star to screen
 PSET (oldstarx(c), oldstary(c)), 0

NEXT


END SUB

SUB DoTarget

FOR i = 0 TO UBOUND(target)

IF target(i).alive = False AND levelflag% = False THEN 'generate a new target
  target(i).alive = True
  target(i).x = (RND * 240) + 40
  target(i).y = (RND * 90) + 20
  target(i).c = 0
  target(i).mem1 = -6
  target(i).mem2 = -1
  target(i).w = 1
  target(i).h = 6
  targetcounter% = targetcounter% + 1
  playsfx sfx$(2)
END IF

IF target(i).alive = True THEN
target(i).xl = target(i).x: target(i).yl = target(i).y
target(i).c = (target(i).c + 1) MOD Speed%
IF target(i).c = 0 THEN
  target(i).mem1 = target(i).mem1 + 1
  target(i).mem2 = target(i).mem2 + 1
  IF target(i).mem1 = 0 THEN target(i).mem1 = -6
  IF target(i).mem2 = 0 THEN target(i).mem2 = -6
  target(i).w = target(i).w + 1
  IF target(i).w > 10 THEN
   target(i).w = 10
   SELECT CASE level%                             'movement patterns
   CASE 1, 2
   target(i).y = target(i).y + 2
   CASE 3
   target(i).x = target(i).x - 1
   target(i).y = target(i).y + 2
   CASE 4
   target(i).x = target(i).x + 1
   target(i).y = target(i).y + 2
   CASE 5
   IF target(i).mem1 MOD 2 THEN target(i).x = target(i).x - 2
   IF target(i).x MOD 2 = 0 THEN target(i).y = target(i).y + 3
   CASE 6
   IF target(i).mem1 MOD 2 THEN target(i).x = target(i).x + 2
   IF target(i).x MOD 2 = 0 THEN target(i).y = target(i).y + 3
   CASE 7
   target(i).x = target(i).x - target(i).mem1
   target(i).y = target(i).y + 2
   CASE 8
   target(i).x = target(i).x + target(i).mem1
   target(i).y = target(i).y + 2
   CASE 9
   target(i).x = target(i).x + target(i).mem1
   target(i).y = target(i).y - target(i).mem1
   CASE 10
   target(i).x = target(i).x - target(i).mem1
   target(i).y = target(i).y - target(i).mem1
   CASE 11, 12
   target(i).y = target(i).y - 3
   CASE 13, 14
   target(i).y = target(i).y - target(i).mem2 + 1
   CASE 15, 16
   target(i).y = target(i).y + 4
   CASE 17, 18
   IF target(i).mem1 MOD 4 THEN target(i).x = target(i).x + 4
   IF target(i).x MOD 2 = 0 THEN target(i).y = target(i).y + 6
   CASE 19, 20
   IF target(i).mem1 MOD 2 THEN target(i).x = target(i).x - 4
   IF target(i).x MOD 2 = 0 THEN target(i).y = target(i).y + 6

  END SELECT

  IF target(i).y > 199 - target(i).h OR target(i).y < 15 THEN target(i).alive = False
  IF target(i).x <10> 319 THEN target(i).alive = False
 END IF
END IF

SELECT CASE level%
CASE 1, 3, 5, 7, 9, 11, 13, 15, 17, 19
 LINE (target(i).x, target(i).y)-(target(i).x + target(i).w, target(i).y + target(i).h), 9, B
CASE 2, 4, 6, 8, 10, 12, 14, 16, 18, 20
 CIRCLE (target(i).x + target(i).w / 2, target(i).y), target(i).w, 9, target(i).mem1, target(i).mem2
END SELECT

END IF

NEXT

END SUB

SUB Eraseimages

  IF ship.alive THEN
   PUT (ship.x, ship.y), shipimage%(0)
  END IF

  LINE (lazer.xl, lazer.yl)-(lazer.xl, lazer.yl - lazer.h), 0, BF
  LINE (lazer.xl + 20, lazer.yl)-(lazer.xl + 20, lazer.yl - lazer.h), 0, BF

  FOR i = 0 TO UBOUND(target)
   SELECT CASE level%
   CASE 1, 3, 5, 7, 9, 11, 13, 15, 17, 19
   LINE (target(i).x, target(i).y)-(target(i).x + target(i).w, target(i).y + target(i).h), 0, B
   CASE 2, 4, 6, 8, 10, 12, 14, 16, 18, 20
   CIRCLE (target(i).x + target(i).w / 2, target(i).y), target(i).w, 0, target(i).mem1, target(i).mem2
   END SELECT
   IF target(i).alive THEN test% = test + 1
  NEXT
  IF test% = 0 THEN DoScore   'test for level change


END SUB

SUB Mouse (func%)


DEF SEG = VARSEG(Mcode%(0))          'set array segment
offset% = VARPTR(Mcode%(0))          'get array address


SELECT CASE func%

CASE 0  'reset mouse driver
 
  ax% = 0: bx% = 0: cx% = 0: dx% = 0
  CALL Absolute(ax%, bx%, cx%, dx%, offset%)
  IF ax% = 0 THEN
   ' PRINT "No mouse detected!"
   ' PRINT "Sorry, this program requires a mouse."
   ' END
  ELSE
    'PRINT "Mouse found"
  END IF


CASE 1    'mouse cursor on
  ax% = 1: bx% = 0: cx% = 0: dx% = 0
  CALL Absolute(ax%, bx%, cx%, dx%, offset%)

CASE 2    'mouse cursor off
  ax% = 2: bx% = 0: cx% = 0: dx% = 0
  CALL Absolute(ax%, bx%, cx%, dx%, offset%)

CASE 3    'get mouse statsus

  ax% = 3: bx% = 0: cx% = 0: dx% = 0
  CALL Absolute(ax%, bx%, cx%, dx%, offset%)
  mouseb% = bx%
  _MOUSEX% = cx% / 2
  mousey% = dx%


END SELECT

DEF SEG

END SUB

SUB playsfx (sfx$)


'Plays the sfx$ that is sent to it.
'Sub routine expects the c$() array (channel info) to be global.

chan% = VAL(MID$(sfx$, 61, 4))
FOR in = 1 TO 60 STEP 4
  reg$ = MID$(c$(chan%), in, 4): reg% = VAL(reg$)
  dat$ = MID$(sfx$, in, 4): dat% = VAL(dat$)
  OUT &H388, reg%: FOR d% = 1 TO 6: b% = INP(&H388): NEXT
  OUT &H389, dat%: FOR d% = 1 TO 35: b% = INP(&H388): NEXT
NEXT


END SUB

VARIOUS.SFX FILE IS HERE:
"&H00&H00&H00&H00&H00&HF0&H5C&H78&H06&H0F&HC0&H0E&H00&H03&H37&H0"
"&H00&HC0&H40&H00&H00&HC1&HC5&HB4&HD4&H74&HC0&H00&H00&H00&H21&H1"
"&H00&H0C&H01&H06&H02&H5E&H8D&H5B&H9F&H80&HC0&H08&H00&H00&H36&H4"
"&H00&H03&H03&H00&H03&HF2&HE3&H23&H25&H25&HC0&H00&H00&H00&H3F&H3"
"&H00&H80&H00&H00&H00&HF0&HB9&HA2&H04&H89&HC0&H0E&H00&H00&H20&H1"
"&H00&H00&H00&H00&H00&H82&H34&HA2&HC7&H89&HC0&H02&H00&H02&H24&H0"
"&H00&H00&H00&H03&H00&H42&H81&HA9&H23&H06&HC0&H06&H01&H01&H2A&H3"
"&H00&H00&H00&H03&H03&H82&H75&HA9&H28&H25&HC0&H02&H00&H00&H3F&H0"
"&H00&H00&H00&H03&H03&H82&H75&HA4&H24&H25&HC0&H04&H00&H00&H2F&H0"
"&H00&H0F&H00&H03&H03&H82&H72&HA9&H28&H25&HC0&H0E&H03&H03&H3F&H0"
"&H00&H04&H00&H00&H00&H85&H00&HCF&H00&HFF&HC0&H09&H01&H00&H33&H0"
"&H00&H06&H00&H03&H03&HEC&HE2&H28&H28&H00&HC0&H01&H00&H00&H39&H0"
"&H00&H00&H00&H03&H03&H82&H73&HA9&H28&H25&HC0&H04&H01&H03&H23&H0"
"&H00&H40&H00&H00&H00&H45&HC2&H64&H04&HF4&HC0&H00&H00&H03&H25&H0"
"&H00&H00&H00&H03&H00&HA3&H54&HA5&HA6&HDC&HC0&H00&H00&H00&H27&H0"
"&H00&H00&H00&H03&H03&H64&H65&HA9&H68&H25&HC0&H05&H01&H01&H33&H0"
"&H00&HC0&HC0&H03&H03&H64&H65&HA9&H68&H25&HC0&H05&H01&H01&H33&H0"
"&H00&H00&H00&H00&H03&H56&H65&HAB&HA1&H25&HC0&H00&H00&H00&H27&H0"
"&H00&H00&H00&H00&H03&H4D&HAC&H49&H18&H25&HC0&H02&H01&H01&H3B&H0"
"&H00&H00&H00&H00&H00&HA4&H10&H49&H58&H89&HC0&H01&H01&H03&H24&H1"
"&H00&H00&H00&H00&H00&H82&H34&HA2&HC7&H89&HC0&H0E&H00&H03&H20&H0"
"&H00&H00&H00&H00&H1E&H49&H88&H5B&H2F&H00&HC0&H07&H03&H00&H2E&H0"
"&H00&H00&H00&H00&H1E&H55&H88&H5B&H2F&H00&HC0&H07&H03&H00&H2E&H0"
"&H00&H00&H00&H06&H02&H55&H8D&H5B&H9F&HCF&HC0&H08&H00&H00&H38&H0"
"&H00&HC1&HC0&H0C&H11&HA0&H30&H5B&H9F&HCF&HC0&H08&H00&H00&H30&H1"
"&H00&H00&H00&H00&H00&H00&H00&H00&H00&H00&HC0&H00&H00&H00&H20&H1"
And it is a nice game no if the sound worked if it worked for Tim Truman in 1997 on some machine then it should work now in 2011. Just have to find that OUT and INP number I so far have 262 and what 263 OR is it 26A OR is it 26B??? :?: Found 262 system device in right-click properties on My Computer and then Realtek audio properties in device manager. :wink:

User avatar
burger2227
Veteran
Posts: 2368
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Sat Dec 03, 2011 12:27 am

Where is DoShip and DoScore?
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

TRANERAECK
Coder
Posts: 29
Joined: Thu Mar 24, 2011 3:08 am

WELL the answer is simple

Post by TRANERAECK » Sat Dec 03, 2011 1:25 am

I have an answer to the problem I looked up my datasheet of REALTEK ALC262 found out by manager realtek is on my machine HDAUDIO and there is all the info you could ask for... have a lot to go over. Search out what realtek HDAUDIO you have and then look up the data sheet this game is an example of something but it should be able to play a sound from what I gather. How that sound is played is upto Realtek and there sound driver. I do not know where the Doship is or Do score I did not go over the game; found it, got it to run and that is nice seeing as how most stuff doesnot work on QB4.5. I like to know if it is all good apparently it is a little missing stuff but works. As for now I think I will start a new post when I figure out ALC262 like i said IT was system device 262. This will stop the confusion. If this is the entry to this thing something like 70F or whatever I saw you also need to turn it off and clean the speaker usage out of QB. don't want to blow my Labtech speakers with subwoofer or my JBL stereo speakers that came with my S4100NX compaq now that I am on a DC7700 Compaq with the old monitor and keyboard and mouse. Took out my CPU when I crashed on my S4100NX without removing battery not good. :roll:

User avatar
burger2227
Veteran
Posts: 2368
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Sat Dec 03, 2011 8:32 am

WHERE are those TWO SUB PROCEDURES? I will remove this thread if you don't supply the FULL CODE! Otherwise the code is USELESS!
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

TRANERAECK
Coder
Posts: 29
Joined: Thu Mar 24, 2011 3:08 am

FOUND the code OK

Post by TRANERAECK » Tue Dec 06, 2011 8:48 pm

Found this code do not know where the two subs are... There is interesting ideas on the stereo there. It requires the programmer to look up the datasheet on the stereo port to use anything close to what is resembled. If it can be done it would be great. :(

User avatar
burger2227
Veteran
Posts: 2368
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Tue Dec 06, 2011 9:00 pm

Well I did a Google Search of the author's name and got his download. Let me get back to you..
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

TRANERAECK
Coder
Posts: 29
Joined: Thu Mar 24, 2011 3:08 am

HAVE best ever

Post by TRANERAECK » Fri Dec 30, 2011 10:36 pm

With the help of a REALTEK AUDIO DATASHEET I have used the archive to find a nice code called SNDBLAST.BAS. I have come up with this code:

Code: Select all

DIM wav(9000) AS STRING * 1

INPUT "Path: ", Path$
Path$ = "C:\LANGUAJS\TEST.wav"

OPEN Path$ FOR BINARY AS #1
    GET #1, , WavFile
        t% = 1
            DO WHILE NOT EOF(1)
                 GET #1, , wav$(t%)
                 t% = t% + 1
            LOOP
    CLOSE #1

        OUT &H1, 1
        OUT &H705, 16
        OUT &H70F, 129 '<<<<<<<<<<
FOR x% = 1 TO t%
        OUT &H5, ASC(wav$(x%))
        FOR a% = 1 TO 2706
        NEXT
NEXT
        OUT &H1, 7


Now this is a suggestion it is for realtek hd audio. Mine is the 262 device.
My test wave is gamespy arcade that is installed on my machine and the file wave is buddy_online. IT seems that with a little work from other ideas that a long wave can be played without loading into memory, I think.
Anyway, it does work. :wink:
I am on a Processor: x86 Family 15 Model 6 Stepping 5 GenuineIntel
~3391 Mhz I suggest adjusting the nested loop for your machine. I still do not know if I set it correctly to slow down the processor. I am close it makes noise and is close to being correct. I forgot to add this had to edit.

TRANERAECK
Coder
Posts: 29
Joined: Thu Mar 24, 2011 3:08 am

FORGOT volume setting

Post by TRANERAECK » Fri Dec 30, 2011 11:19 pm

ADD in this:
OUT &H70F, 129

AFTER &H705 entry.

7 bits is equal to 128 (explanation: 2^7 power).
I am close to reproducing the sound with hardware volume setting just can't get the process speed to slow down. :(

User avatar
burger2227
Veteran
Posts: 2368
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Sat Dec 31, 2011 3:10 pm

You do know that you can edit old posts don't you?
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

TRANERAECK
Coder
Posts: 29
Joined: Thu Mar 24, 2011 3:08 am

Have finally done something

Post by TRANERAECK » Sun Jan 08, 2012 5:09 pm

I posted what I found on qbcafe it has dll's. Also a library it shiows how to use dll's with qbasic. It was made by Randall L Glass. I am pretty sure you don't want to open the port. The way to do it with windows xp is to use a dll. I am almost positive.
:o

Post Reply