Blitz (9/218)

From:David McMinn
Date:3 Aug 2001 at 10:47:05
Subject:Re: Drawing a sample

Hi amorel

> Yeah me too. I tested it with dim and dim list of various sizes and types
> and it sure complained at >64k. That`s just very lame. I can`t imagine why
> the heck this can`t be limited by memory instead of 64k.

You're right, I just checked. If you Dim and array which is >=65536 items
(NB items, not bytes), you get an error saying "Array Dimension out of
Range". If you dim an array with 65535 and try to access the first item,
you get an "array subscript out of range".

I wrote a small test program and disassembled it. The way the Blitz
executables work, there does not need to be a limit to the size of arrays
because it uses a longword for the index (shifted left to get the correct
size for each item) and adds that to the address of the array (using an
ADD instruction, not an addressing mode).

Actually, I've just tested another exe, with a newtype, and it uses the
68k multiplication instructions to work out the position in the array.
And these only multiply a word by a word to get a longword result, so the
maximum index you can use with newtype arrays is 65535. However, it
should have been written a bit better than than (i.e. allow you large
arrays for 2^n sized types and only 65535 for strange sized arrays).

You could get around this by making up a big newtype. So that would give
you more range for your 65535 items, i.e.

NEWTYPE.sixteen
values.b[16]
END NEWTYPE

Dim mysample.sixteen(60000) ; <- can store 60000*16 bytes
CopyMem_ *mysound\_data,&mysample(0),*mysound\_length*2
for i=0 to *mysound\_length*2 ; OK, I couldn't remember your original
loop :)
idx2 = i mod sizeof.sixteen
idx1 = i / sizeof.sixteen
NPrint mysample(idx1)\values[idx2]
next

Alternatively you could allocate some memory and peeking from it to get
the sample values to draw. Or perhaps one of the 3rd party libraries that
have maths or matrix commands in it would be capable of doing this.

> I tried the dll and it did not complain but also drew an empty sample
> window. Don`t know if it`s related. But dll is so freaking slow(I`d say
> 100 times as slow as normal array), I gotta fill the array with the
> sounddata in a loop and cant use copymem_ afaik.

Yep, it's got to be slow because it's all written in basic. And you're
right about copying in a loop.



|) /\ \/ ][ |) |\/| c |\/| ][ |\| |\| | dave@blitz-2000.co.uk
http://members.nbci.com/david_mcminn | ICQ=16827694
It may be that your sole purpose in life is simply to serve as a warning
to others.

---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list-help@netsoc.ucd.ie