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.

Messages - Gary

Pages: 1 2 3 [4] 5 6 ... 21
Off Topic / Re: php/java question
« on: 2012-Jul-06 »
the code I have tried so far that should work is

Code: (glbasic) [Select]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<script type="text/javascript">
function open_win()


function closeWin()

function pausecomp(ms) {
ms += new Date().getTime();
while (new Date() < ms){}
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>

<input type="button" value="Open Windows" onclick="open_win()">

Which creates a button, you click on it and then it opens a new window/tab but doesnt seem to actually load the content :([/code]

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 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


explicit is set in the build options, toggling it off makes no difference.

Or is there another setting elsewhere that sets it?

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

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


just ran another test and found its not related to subroutines

Code: (glbasic) [Select]
GLOBAL i=100

FOR i = 0 TO 10
DEBUG i+"\r\n"

will output i being = 100 (the default value) after the for loop is run when it should be 10

For anyone that is interested I have attached the converted program. The outputted files are not totally identical to the QBASIC output (seems to go slightly off track half way through decoding a sample) but the outputted wav file sounds exactly the same.

Its not pretty and is slower than the QB original (partly because I have to load the rom into an array before I start to do the conversion and partly because I have to check the rom size first so its loaded twice) but it does work :)

Thanks to everyone for the help. And for the that are curious, the sound roms that can be converted are from Barcrest MPU4 fruit machines


[attachment deleted by admin]

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

Code: (glbasic) [Select]

FOR i = 0 TO 10
GOSUB printi


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

I would expect the output to be

but instead I get

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


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

this will display

in the debug window

Using a function also does the same thing


got the majority converted to GLB but couple of sticking points

this section wont compile

Code: (glbasic) [Select]
//' get a big endian longword from the INPUT stream. RETURN the value IN llong&

SUB GetLong:
READLONG 0,llong

it gives the error

Code: (glbasic) [Select]
C:\Users\Gary\AppData\Local\Temp\glbasic\gpc_temp0.cpp: In function `DGInt __GLBASIC__::GetLong()':
C:\Users\Gary\AppData\Local\Temp\glbasic\gpc_temp0.cpp:1194: error: invalid initialization of reference of type 'DGNat&' from expression of type 'DGInt'
C:/Program Files (x86)/GLBasic/Compiler/platform/Include/glb.h:1124: error: in passing argument 2 of `void __GLBASIC__::READLONG(DGNat, DGNat&)'

and is there any way of jumping bytes in  file so you can go straight to the 4th byte in the file and skip reading the first 3? the only way I can see to do it is to load the whole file into an array and interrogate it from the array but that seems long winded

apologies for the questions but do you know if a variable has an & at the end of it does it signify anything special? Im just removing them for now

btw is you put snd_2.rom in your mail QB64 folder, or move the exe file generated to the same folder as the rom it will decrypt it

Thanks for the quick reply Okee, I can at least run in that and see how good the conversion is then compare the output to the GLB version when done

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.


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)

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

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

i& = 3 ' skip unknown start bytes

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

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 "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

CLOSE #1 ' close input file

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

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


' 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

  sslength& = 0 ' reset length
  i& = wavaddr&(wavfiles%) ' sample start address
    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

' write RIFF header chunk

  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

' write FORMAT chunk

  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

' write DATA chunk

  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

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

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

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

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

' 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

  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
    GOSUB GetByte ' get this sample blocklength
    blklength% = byte% AND 127 ' mask and copy block length
    IF blklength% THEN ' if there are samples
        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
            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
      eflag% = -1% ' else set end flag
    END IF
  LOOP UNTIL eflag% ' loop until end

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

  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

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

  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

' dialogic modified IMA tables

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

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]

curious, the android version is free yet the IOS version costs £2.99 wonder what the thinking is behind that considering its a one off run program and android has a larger amount of devices to make it run on

Off Topic / Re: GameGadget handheld
« on: 2012-May-31 »
Well as you may know I *had* one of these consoles, I say had as I have returned it for a refund as they are just not delivering on their promises.

I sent a lengthy but nicely worded to their MD who, by his own words, always replies to emails, saying what I felt was good, what was bad and how to improve the console and the dev process, I heard nothing.

There was then the blatant lies on the FaceBook page, new update coming tomorrow then a post saying it had been delayed, then a list of new games was coming, that never showed. The new items in the store were all freeware with no emulated games being added except for the ones that Blaze already had licences for for their other consoles. All the freeware seems to be stuff that others had written and got running in the sandbox so they did nothing new themselves.

Mame has been ported but no information about how to use it was given and more importantly any requests for the source code were met with silence so therefore it is not a legal port of MAME.

They send Alan Sugar a tweet asking how they could licence Amstrad and Spectrum ZX (yes thats what they called it) games. A quick search on World of Spectrum would have given them email addresses of hundreds of ex developers and answer their questions.

Then there is the abusive message on the forum from GameGadget to someone asking a fairly civil question and then the drastic removal of posts to try to hide the damage done.

They shut down the facebook page but then seem to have abandoned the forums as well. Xploder seem to be handling everything now.

I would advise anyone thinking of getting one to get a Dingoo instead, they are cheaper and you dont have to boot it in sandbox to be able to do anything.

The product is a great idea but they have seriously messed it up by rushing the console out before it was ready, 2 weeks of not even being able to activate the console was a joke.

The amount of bad press that the GameGadget has got on the various gaming sites has already killed it in my view, they cannot recover from this and should just abandon the project

Off Topic / Re: GameGadget handheld
« on: 2012-May-01 »
Blaze could save the day by managing to get the device into high street stores where parents of the kids that buy the games for the 3ds, xbox etc will see it on the shelf and think I used to play that and buy one.

The problem is though I cannot see how any of the Grade A retro games can appear on it. Nintendo want everything decent from the back catalogue for the Wii and 3ds, so no GB, Nes or Snes top titles, Sega will want too much for Sonic titles, Rare wont allow any of Ultimates Spectrum games on there. And arcade emulation is a minefield. You will be left with a few MSX, spectrum, amstrad and c64 games but even then there is the issue of kernal roms for the emulators.

So it will be play a few poor titles or look to see how you can get more on there and its nothing more than copying a few files to an SD card, hold down A at boot up and job done

Pages: 1 2 3 [4] 5 6 ... 21