BASIC

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Gary

Pages: [1] 2 3 ... 5
1
GLBasic - en / setting up large arrays
« on: 2016-Jul-07 »
I have a program I am working on that requires a few very large arrays to be set up on start up as look up tables. The amount of data in each of them is anything up to 200,000 entries.

I have the entries in a text document ready to paste into a DIMDATA line but it looks like GLBasic can't handle really really long line in the editor and just locks up when I paste the data in

Is there any other solution to my problem without having to resort to reading in the data from a file at start up and also can GLB handle arrays of that size?

Thanks
Gary

2
For the project I am working on I need to set the version and copyright information on a windows EXE file so that when you right click, properties, and then detail (windows 10) it shows all the embedded information like the screen below. I need it to be like the one on the left but mine is the one on the right. I have tried setting it all up in project options but it does not seem to want to carry over to the exe. Is there a 3rd party tool I can use to add the info or can GLB do it directly?

Thanks
Gary


3
GLBasic - en / GLB crashing on startup
« on: 2016-Jan-22 »
Everything was fine yesterday, came to start coding today and getting a crash almost straight away on editor start up, the normal windows xp error "GLBasic has encountered a problem and needs to close"

Is there an ini file somewhere that stores what the last files opened were? Im wondering if that could have got corrupted. Don't want to do a clean install as I am using an old version which works fine for the project I'm working on

cheers

4
Ive noticed a strange quirk of my add in that when I run it in debug mode I do not hear a windows exclamation beep but if I turn off debug mode I am getting the sound which is a bit annoying.

Does anyone know where I could be going wrong? I am using version 10 (Yes I know, very old but I'm reluctant to upgrade until the project is finished as it could mess up the whole project) on a windows xp computer. Upgrading the main system is not an option before anyone says stick windows 10 on it :) I would have thought if there was an error (like missing file etc) causing the exclamation sound that the debug window would have shown the error

Thanks
Gary

5
GLBasic - en / DLL and HWND
« on: 2015-Aug-28 »
I have a DLL which I need to include in a program. I have got it all loading and opening properly but I am struggling with one of the commands I need to set up.

In the manual that came with the DLL is has visual studio examples and the one im struggling with at the moment is this one

Code: GLBasic [Select]
BP_StartDLL = (bp_bool_hwnd) GetProcAddress (DllModule, "BP_StartDLL");
 

and it says to call it you need to do the following

Code: GLBasic [Select]
RetVal = (*BP_StartDLL)(myhWnd);

Now I thought I had found out how to do it from the help and set things up like this

Code: GLBasic [Select]
DECLARE_ALIAS(BPStartDLL, "gamesocket.dll", "BP_StartDLL", (bool hwnd), int);

in the part where I load the DLL and declare all the functions

and

Code: GLBasic [Select]
FUNCTION StartDLL:
INLINE
if(BPStartDLL)
return BPStartDLL(GLBASIC_HWND);
else
return 255;
ENDINLINE
ENDFUNCTION

In the actual StartDLL function but it is refusing to talk to the other program it is supposed to. I think it is getting the wrong HWND value.

Anyone got any ideas where I am going wrong?

Thanks
Gary

6
I am wondering if there is an easy way for GLB to do the following

I have a display that is currently drawn as a single screen of 1024 wide and 1526 high to display over 2 screens within windows. I now need to draw it as a screen 2048 wide and 768 high with the screen that starts at 1024,0 being what was drawn as the top screen.

Can I use my existing draw routine and then create a sprite for each of the halves of the screens and then redraw in the new positions?

its something like this I'm after


current screen layout
----------
-        -
-    x   -
-        -
----------
-        -
-    y   -
-        -
----------

new screen layout
-------------------
-        --       -
-   y    --   x   -
-        --       -
-------------------


7
Off Topic / Any xbox insider members on here?
« on: 2015-Jun-22 »
Dont suppose there is anyone on here who is part of the xbox preview program is there? Would love to try out the backwards compatibility stuff but it seems to become a member you have to be invited by someone who is on the program. So just thought I would ask if there was anyone on here who is.

Cheers
Gary

8
Been a while since I did a build for release on the app store so wondered if there was any step by step instructions for making sure the app gets uploaded correctly with the correct certs etc as it looks like things have changed a lot in the last 4 years.

Cheers
Gary

9
Is there any automatic way of getting the build date of the program to display when it starts running? or do I have to manually change the date in a string with every new build?

10
Off Topic / php/java question
« on: 2012-Jul-06 »
I know this is way off topic but I am hoping that someone may be able to help.

I have a list of 1000 url addresses that add free bonuses into a facebook game im playing and each url needs to be clicked in turn to add the bonus. Now I know you can get Java to use window.open to automatically open a new window/tab for each url but I cant think how to automate it in with php to open a text file, read in the first line, open the url, wait 5 seconds, close the window and then grab the next url and so on. Has anyone done anything similar or know how I can do it?

I did wonder if GLB could do it with its web commands but as you need to be logged onto facebook to get the bonus it needs to be opened in a proper browser window so I discounted a quick GLB project

Hope someone has some ideas that might work

Gary

11
music/sound / feature request: Mem2Wav
« on: 2012-Jun-22 »
Kitty,

Would it be possible to add a mem2wav option much like the mem2sprite function (and a loadwavmem command)? This would then allow basic sound manipulation (like speed up and slow down by altering the sample frequency) on the fly and give the option to generate tones without the use of wav files being prebuilt before hand. Also any music and sounds could be hidden in the source rather than being separate files that could be ripped out

Gary

12
I have found what I think is an issue with passing a variable to a subroutine.  Example code

Code: GLBasic [Select]
GLOBAL i

FOR i = 0 TO 10
        GOSUB printi
NEXT

END

SUB printi:
        DEBUG i+"\r\n"
ENDSUB
 

I would expect the output to be
0
1
2
3
4
5
6
7
8
9
10

but instead I get
0
0
0
0
0
0
0
0
0
0
0

if I make a copy of the variable used in the for loop it passes to the routine correctly.

It almost looks like a variable used in a for loop is not the same variable as the globally defined one. See the code below for a better explanation

Code: GLBasic [Select]
GLOBAL i=100

FOR i = 0 TO 10
        GOSUB printi
NEXT

END

SUB printi:
        DEBUG i+"\r\n"
        i=i+1
ENDSUB
 

this will display
100
101
102
103
104
105
106
107
108
109
110

in the debug window

Using a function also does the same thing

Gary

13
I am looking to write a simple converter from a sound eprom from a fruit machine which is encoded for an oki M6876 chip in 4 bit adpcm format into wav files.

I have found some source code that does the job apparently (funny enough the guy who wrote it bought an unknown board from an electrical shop and was curious to know what was on the sound proms on there. The board is the one I want to do the decoder for, so the code is written already :) ). The problem is I don't know what BASIC it is written in, it wont compile with any of the VB editions I have and thats about the only other one I know.

I'm wondering if any of the more knowledgeable members could have a look and let me know if they recognise what BASIC it is and also any pointers to converting it to GLB would be great. Everything looks fairly straight forward but if there are any particular commands that don't have a GLB equivalent it would be good to know before I start.

Cheers
Gary

Code: GLBasic [Select]


' ADPCM decoder. this code decompresses the contents of a speech chip sound ROM set that
' is 4 bit ADPCM encoded. A table of addresses at the start of the ROM is used to find
' the start of the individual samples, the end, and the sample length, is calculated from
' the sample block sizes. this version saves the decompressed samples as eight bit 16ksps
' mono .wav files with the hex start address of the sample as the file name

' 05/04/06

SCREEN 12                                                               ' 640 x 480 x 16
CLS                                                                     ' clear it

DEFINT A-Z                                                              ' all integers except where defined

DIM stepadj(7)                                                  ' step index adjust, 0 to 7
DIM steptable(48)                                                       ' step size table, 0 to 48
DIM wavaddr&(127)                                                       ' sample start addresses
adrcount% = 0                                                   ' number of sample addresses found

RESTORE stepadj                                                 ' read the step index adjust table
FOR i = 0 TO 7
  READ stepadj(i)
NEXT

RESTORE steptable                                                       ' read the step size table
FOR i = 0 TO 48
  READ steptable(i)
NEXT

OPEN "snd_2.rom" FOR BINARY AS #1                               ' open input file

i& = 3                                                          ' skip unknown start bytes

DO
  GOSUB GetLong                                                 ' get address longword
  wavaddr&(adrcount%) = llong&                          ' save address
  adrcount% = adrcount% + 1                                     ' increment address count
  PRINT RIGHT$("00000" + HEX$(llong&), 6); "  ";        ' display address
LOOP WHILE llong&

PRINT
PRINT  adrcount% - 1; "addresses found";
adrcount% = adrcount% - 2                                       ' correct for zero term and zero
                                                                        ' count start

FOR wavfiles% = 0 to adrcount%                          ' for each sample
  filename$ = RIGHT$("00000" + HEX$(wavaddr&(wavfiles%)), 6) + ".wav"
  OPEN filename$ FOR OUTPUT AS #2                               ' open output file
  PRINT
  PRINT "File "; filename$;                                     ' show file name
  GOSUB GetLength                                                       ' get the sample length
  GOSUB WriteRIFF                                                       ' write the header chunk
  GOSUB WriteFORMAT                                             ' write the format chunk
  GOSUB WriteDATA                                                       ' write the data chunk
  CLOSE #2                                                              ' close output file
NEXT

CLOSE #1                                                                ' close input file

PRINT
PRINT "Done. Any key to exit."                          ' show file name

DO
LOOP WHILE INKEY$=""                                            ' wait for a key

END


' get the sample size. the sample is arranged into blocks, the first byte of the block
' is the byte count for the remainder of the block + $80. the sample is terminated by
' a block count of zero

GetLength:
  sslength& = 0                                                 ' reset length
  i& = wavaddr&(wavfiles%)                                      ' sample start address
  DO
    GOSUB GetByte                                                       ' read block length
    byte% = byte% AND 127                                       ' mask block length
    sslength& = sslength& + byte%                               ' add this chunk length
    i& = i& + byte%                                             ' index to next chunk length
  LOOP WHILE byte%                                              ' zero length is end marker
RETURN


' write RIFF header chunk

WriteRIFF:
  PRINT #2, "RIFF";                                             ' always there
  samplength& = sslength& * 2                                   ' length of output in bytes
  llong& = samplength& + 36                                     ' length of rest of file
  GOSUB WriteLongword                                           ' write file length
  PRINT #2, "WAVE";                                             ' always there
RETURN


' write FORMAT chunk

WriteFORMAT:
  PRINT #2, "fmt ";                                             ' always there
  llong& = 16 : GOSUB WriteLongword                             ' length of chunk, always 16
  llong& = 1 : GOSUB WriteWord                          ' always 1
  llong& = 1 : GOSUB WriteWord                          ' mono
  llong& = 16000 : GOSUB WriteLongword                  ' sample rate
  llong& = 16000 : GOSUB WriteLongword                  ' bytes/second
  llong& = 1 : GOSUB WriteWord                          ' 1 byte/sample
  llong& = 8 : GOSUB WriteWord                          ' 8 bits/sample
RETURN


' write DATA chunk

WriteDATA:
  PRINT #2, "data";                                             ' always there
  llong& = samplength& : GOSUB WriteLongword            ' data chunk length
  sstart& = wavaddr&(wavfiles%)                         ' sample start address
  send& = wavaddr&(wavfiles% + 1)                               ' sample end address
  GOSUB Decompress                                              ' decompress the sample
RETURN


' write llong& as word to file, little endian format

WriteWord:
  PRINT #2, CHR$(llong& AND 255&);                              ' write low byte
  llong& = llong& \ 256&
  PRINT #2, CHR$(llong& AND 255&);                              ' write high byte
RETURN


' write llong& as longword to file, little endian format

WriteLongword:
  GOSUB WriteWord                                                       ' write low word
  llong& = llong& \ 256&
  GOSUB WriteWord                                                       ' write high word
RETURN


' decompress ADPCM sample data to .wav data. first get the blocksize, if it's zero then
' all done so exit else for each byte in the block umpack the high then the low nibbles
' into 12 bit samples

' This routine could be greatly simplified but is given in this form as it more closely
' represents how it would be implemented in assembly code or directly in hardware

Decompress:
  stepindex = 0                                                 ' reset decompression variables
  stepsize = 16                                                 ' initialise index
  sample& = 2048                                                        ' set 50% for unsigned value

  i& = sstart&                                                  ' set start of sample
  eflag% = 0                                                    ' clear end flag
  DO
    GOSUB GetByte                                                       ' get this sample blocklength
    blklength% = byte% AND 127                          ' mask and copy block length
    IF blklength% THEN                                          ' if there are samples
      DO
        GOSUB GetByte                                           ' get two compressed nibbles
        FOR nib% = 0 TO 1                                       ' for each nibble
          IF nib% THEN
            nibble% = byte% AND 15                              ' second sample is low nibble
          ELSE
            nibble% = byte% \ 16                                ' first sample is high nibble
          END IF

          newsample = nibble% AND 7                             ' compressed sample magnitude

          difference = stepsize \ 8                             ' effectively add 0.5 to difference

          IF newsample AND 4 THEN
            difference = difference + stepsize          ' + stepsize / 4 * 4
          END IF
          IF newsample AND 2 THEN
            difference = difference + stepsize \ 2      ' + stepsize / 4 * 2
          END IF
          IF newsample AND 1 THEN
            difference = difference + stepsize \ 4      ' + stepsize / 4 * 1
          END IF

          IF (nibble% AND 8) THEN                               ' if -ve compressed sample
            sample& = sample& - difference              '  subtract the difference
          ELSE                                                  ' else compressed sample was +ve
            sample& = sample& + difference              '  so add the difference
          END IF

          IF sample& > 4095 THEN                                ' if > than unsigned 12 bit max
            PRINT " +clip ";                                    '  print a warning
            sample& = 4095                                      '  clamp to 4095
          ELSEIF sample& < 0 THEN                               ' if < than unsigned 12 bit min
            PRINT " -clip ";                                    '  print a warning
            sample& = 0                                         '  clamp to 0
          END IF

          PRINT #2, CHR$(sample& \ 16&);                        ' scale and save decompressed sample
          stepindex = stepindex + stepadj(newsample)    ' new decompress step index
          IF stepindex > 48 THEN                                ' if > than step table max
            stepindex = 48                                      '  clamp to step table max
          ELSEIF stepindex < 0 THEN                             ' if < than step table min
            stepindex = 0                                       '  clamp to step table min
          END IF

          stepsize = steptable(stepindex)                       ' get step size for next sample

        NEXT nib%                                                       ' do other nibble
        blklength% = blklength% - 1%                    ' decrement count
      LOOP WHILE blklength%                                     ' loop if more to do
    ELSE
      eflag% = -1%                                              ' else set end flag
    END IF
  LOOP UNTIL eflag%                                             ' loop until end
RETURN


' get an indexed byte from the input stream. return the value as a string and a number

GetByte:
  byte$ = " "                                                   ' one byte long string
  i& = i& + 1&                                                  ' increment the index
  GET #1, (i&), byte$                                           ' get LEN(byte$) bytes
  byte% =  ASC(byte$)                                           ' get numeric byte value
RETURN


' get a big endian longword from the input stream. return the value in llong&

GetLong:
  GOSUB GetByte                                                 ' get MS byte
  llong& = byte%                                                        ' copy it
  GOSUB GetByte                                                 ' get next byte
  llong& = llong& * 256& + byte%                                ' convert and add it
  GOSUB GetByte                                                 ' get next byte
  llong& = llong& * 256& + byte%                                ' convert and add it
  GOSUB GetByte                                                 ' get next byte
  llong& = llong& * 256& + byte%                                ' convert and add it
RETURN


' dialogic modified IMA tables

steptable:
        DATA     16,  17,  19,  21,   23,   25,   28,   31,   34,  37
        DATA     41,  45,  50,  55,   60,   66,   73,   80,   88,  97
        DATA    107, 118, 130, 143,  157,  173,  190,  209,  230, 253
        DATA    279, 307, 337, 371,  408,  449,  494,  544,  598, 658
        DATA    724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552

stepadj:
        DATA    -1,-1,-1,-1,2,4,6,8
 

I have attached the source file as well as a sound prom file to decode

[attachment deleted by admin]

14
This has had me stumped for 2 days now so time to ask the gurus for help  :nw:

I am working on a project and have a routine for displaying text by loading in the individual letters as sprites and breaking the string down into individual characters and drawing the sprite for the letter, setting the xpos to the width of the char plus current print pos so its ready to print the next char. The widths are in a look up table as I figured it would be quicker than getting sprite size on the fly each time.

Code: GLBasic [Select]
FUNCTION stringprint: string$,stringxpos,stringypos,center = TRUE

        LOCAL numchars, ctr, charypos, nextchar$,strlen=0

        numchars = LEN(string$)

        IF center
                stringypos=stringypos + 11 // I moved the graphics on the screen by 11 pixels and this was easier than reentering all the ypos values on each draw command
                FOR ctr = 0 TO numchars-1
                 strlen = strlen + char_width[ASC(string$,ctr)]
                NEXT
                stringxpos = stringxpos - (strlen/2)
        ENDIF

        FOR ctr = 0 TO numchars-1
                DRAWSPRITE 500+ASC(string$,ctr),stringxpos,stringypos
                stringxpos=stringxpos+char_width[ASC(string$,ctr)]
        NEXT

ENDFUNCTION
 

On my dev computer it displays fine as per the first screen shot. On the computer it needs to be deployed on it is missing the text totally. I did also try Peejays/morus text drawing routine (but as its a commercial project I dont want to use it for production as its their code) and this does exactly the same.

I have tried removing some of the graphics to keep the overheads down but that doesn't change anything so I am stumped.

The graphics card in the deployment PC is an Intel 82845G/GL/GE/PE/GV which I know does not do everything in the 3d department but I'm not doing anything fancy. All other sprites display correctly and everything else works apart from this one aspect.

Anyone else have any ideas as to what I could try? I'm on the verge of going back to a standard font and using the PRINT routine :) Its not a difference between full screen and windowed as the issues stay regardless of the settings

Thanks
Gary



[attachment deleted by admin]

15
GLBasic - en / playmusic/playsound question
« on: 2011-Dec-20 »
Hopefully someone here can give me a simple solution to this problem

I have a sound that is loaded as a wav file at program start up that I want to play as a continuous loop at certain times. Currently I am using PLAYSOUND and checking if the channel is still playing and restarting if it isn't but my problem is if the music stops when it is out of the loop doing something else I get a pause. I see that PLAYMUSIC can be set to run and just play in the background as a looping tune but from the docs it looks like PLAYMUSIC requires the sample to be loaded at the time of playing rather than specifying a sound number that is already loaded. This would be difficult to use as I jump all over the place saving files.

I also notice that you can set a buffer value on LOADSOUND between 1 and 4 that states the number of times the sample can be played without interruption, I assume it just duplicates the sound x number of times. Setting this to 4 cures the problem a little bit but not totally.

Can PLAYMUSIC be used with a preloaded sample or is there any way that PLAYSOUND can be set to loop and forget until the sample is killed with a HUSH?

Thanks
Gary

Pages: [1] 2 3 ... 5