Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 09:25 24 Sep 2020 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : CMM2: V5.05.05 beta

     Page 1 of 7    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 3869
Posted: 12:05pm 30 Jul 2020
Copy link to clipboard 
Print this post

5.05.05b2 available for download

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Bug fixes
Fixed bug in DIR$, MM.INFO(MODIFIED and MM.INFO(FILESIZE when pathname contains ../

New functionality
Addition optional parameter for DAC start
DAC START frequency, left%() [,right%()] [,DACint]
If the optional Basic interrupt routine DACint is specified then the the DAC just plays the contents of the arrays once and triggers the interrupt on completion.
Option to use FRAMEBUFFER as the read page for IMAGE commands

Below is an example program for playing a WAV file from a MMbasic array

blue.zip


option explicit
option default integer
dim s$
dim i,j,cksize, chunksize, formatcode, nChannels, SamplesPerSec, BitsPerSample, datasize, multiply
open "blue.wav" for input as #1
s$=input$(4,1)
print s$
s$=input$(4,1)
cksize=STR2BIN(uint32, s$)
print "file size is: " cksize
s$=input$(4,1)
print s$
s$=input$(4,1)
print s$
s$=input$(4,1)
chunksize=str2bin(uint32,s$)
print "chunk size is: " chunksize
s$=input$(2,1)
formatcode=str2bin(uint16,s$)
print "format code is: " formatcode
s$=input$(2,1)
nChannels=str2bin(uint16,s$)
print "Number of Channels is: " nChannels
s$=input$(4,1)
SamplesPerSec=str2bin(uint32,s$)
print "Sample rate is: " SamplesPerSec
s$=input$(6,1)
s$=input$(2,1)
BitsPerSample=str2bin(uint16,s$)
print "BitsPerSample is: " BitsPerSample
do
 s$=input$(2,1)
loop until s$="da"
s$=input$(2,1)
s$=input$(4,1)
datasize=str2bin(uint32,s$)
print "datasize is: " datasize
multiply=1
if BitsPerSample>8 then multiply=2
if nChannels=2 then
 DIM left(datasize\2\multiply), right(datasize\2\multiply)
 j=datasize\2\multiply
else
 dim left(datasize\multiply) right(datasize\multiply)
 j=datasize\multiply
endif
i=0
do
if nChannels=2 then
 if BitsPerSample=8 then ' assume 8-bit samples are unsigned
   s$=input$(1,1)
   left(i)=str2bin(uint8,s$)*16
   s$=input$(1,1)
   right(i)=str2bin(uint8,s$)*16
   i=i+1
 else 'assume 16 bit samples are signed
   s$=input$(2,1)
   left(i)=str2bin(int16,s$)\16+2048
   s$=input$(2,1)
   right(i)=str2bin(int16,s$)\16+2048
   i=i+1
 endif
else
 if BitsPerSample=8 then
   s$=input$(1,1)
   left(i)=str2bin(uint8,s$)*16
   right(i)=str2bin(uint8,s$)*16
   i=i+1
 else
   s$=input$(2,1)
   left(i)=str2bin(int16,s$)\16+2048
   right(i)=str2bin(int16,s$)\16+2048
   i=i+1
 endif
endif
loop until eof(1) or i=j+1
close 1
dac start SamplesPerSec*nChannels, left(), right(), myint
do:loop
sub myint
 dac stop
 end
end sub

Edited 2020-07-30 22:10 by matherp
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 3869
Posted: 01:41pm 30 Jul 2020
Copy link to clipboard 
Print this post

5.05.05b3 posted

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Bug fix:
DAC START command generated a frequency half of that requested.

In above example, Change line:

dac start SamplesPerSec*nChannels, left(), right(), myint


for

dac start SamplesPerSec, left(), right(), myint


if using V5.05.05b3 or above
Edited 2020-07-30 23:44 by matherp
 
realmnm

Newbie

Joined: 07/07/2020
Location: Australia
Posts: 34
Posted: 09:42am 31 Jul 2020
Copy link to clipboard 
Print this post

  matherp said  5.05.05b3 posted

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Bug fix:
DAC START command generated a frequency half of that requested.


Thanks, I did notice that when I tried your code above.  Thanks for the code as well, I guess reading the file in smaller chunks is less of a slowdown than what I imagined and non destructive, as opposed to what the long string code was doing to it.

Martin
Edited 2020-07-31 19:43 by realmnm
This signature intentionally left blank.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 3869
Posted: 10:38am 03 Aug 2020
Copy link to clipboard 
Print this post

5.05.05b4 posted

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Fixed bug in using Mode 1,16 when using sprites and running the program from the editor or filmanager
Fixed bug in SPRITE LOAD that restricted maximum sprites to 63 rather than 64

New mode 6, 256x240 for easier porting of NES games

Floats for Turtle turns and any angle for turns and heading
Negative numbers for Tirtle forward and backward and range increased to +/- SQRT(MM.HRES^2 + MM.VRES^2)
Edited 2020-08-04 02:08 by matherp
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 3869
Posted: 09:13am 04 Aug 2020
Copy link to clipboard 
Print this post

5.05.05b5 posted

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Fixed bug in turtle graphics fill algorithm
Allow negative values for turtle forward and backward
All turtle graphics now converted to use double precision to reduce loss of accuracy
 
JoOngle
Regular Member

Joined: 25/07/2020
Location: Sweden
Posts: 43
Posted: 02:09pm 04 Aug 2020
Copy link to clipboard 
Print this post

Just want to say thanks to you Mather, for being so quick to update the Firmware and so enthusiastic about the Maximite.  
 
goc30

Guru

Joined: 12/04/2017
Location: France
Posts: 337
Posted: 11:51pm 07 Aug 2020
Copy link to clipboard 
Print this post

hi

I have a small problem

I want to use "constant" type for font number define. but it create an error msg

my prog


Option EXPLICIT
option base 0
Const TRUE = 1
Const FALSE = 0
const vpol1 = 8


DefineFont #vpol1  'with "DefineFont vpol1" same error
5F200808 00000000 00000000 08080808 00080008 00001414 00000000 247E2400
 00247E24 7C507C10 00107C14 08646200 00462610 10281000 003A442A 00100800
 00000000 10100800 00081010 08081000 00100808 10280000 0028107C 10100000
 0010107C 00000000 10080800 00000000 0000007C 00000000 00181800 08040000
 00402010 948C7800 0078C4A4 20A06000 00F82020 04847800 00FC8078 18847800
 00788404 50301000 0010FC90 F880FC00 00788404 F8807800 00788484 0804FC00
 00202010 78847800 00788484 84847800 0078047C 10000000 00100000 00100000
 20101000 10080000 00081020 7C000000 00007C00 10200000 00201008 04423C00
 00080008 564A3C00 003C405E 84847800 008484FC F884F800 00F88484 80847800
 00788480 8488F000 00F08884 F880FC00 00FC8080 F880FC00 00808080 80847800
 0078849C FC848400 00848484 10107C00 007C1010 04040400 00788484 E0908800
 00848890 80808000 00FC8080 B4CC8400 00848484 A4C48400 00848C94 84847800
 00788484 8484F800 008080F8 84847800 007894A4 8484F800 008488F8 78807800
 00788404 1010FE00 00101010 84848400 00788484 84848400 00304884 84848400
 0048B484 30488400 00844830 28448200 00101010 1008FC00 00FC4020 20203800
 00382020 20400000 00040810 08083800 00380808 54381000 00101010 00000000
 FE000000 A199423C 3C4299A1 04380000 003C443C 78404000 00784444 201C0000
 001C2020 3C040400 003C4444 44380000 003C4078 18100C00 00101010 423E0000
 3C023E42 78404000 00444444 18000800 001C0808 04000400 18240404 60504000
 00485060 10101000 000C1010 54680000 00545454 44780000 00444444 44380000
 00384444 44780000 40407844 443C0000 06043C44 201C0000 00202020 40380000
 00780438 10381000 000C1010 44440000 00384444 44440000 00102828 54440000
 00285454 28440000 00442810 44440000 38043C44 087C0000 007C2010 60101C00
 001C1010 10101000 00101010 0C107000 00701010 00281400 00000000
End DefineFont


it seem that I can't use "Constant" for font number define, but const is equ as value
I don't understand why it is not possible to use that

another problem. In this case, after error msg, I must execute "cls" or "option flash" if i want to execute my prog (with corrct value), in other case i receive "Error Memory write adress". It seem that after my font "error", memroy is not correctly initialise
Edited 2020-08-08 09:54 by goc30
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 3709
Posted: 12:37am 08 Aug 2020
Copy link to clipboard 
Print this post

  Quote  it seem that I can't use "Constant" for font number define, but const is equ as value
I don't understand why it is not possible to use that


The font is created when your program is saved, not when the program runs.
This means that the CONST definition is not available for MMBasic to use when it's needed.

Jim
It all started with the ZX81....
VK7JH
http://www.c-com.com.au/MMedit.htm
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 2743
Posted: 12:57am 08 Aug 2020
Copy link to clipboard 
Print this post

The font defined in DefineFont is processed when the program is loaded into memory from the SD card.  This is before the program has started running and before any Const declarations have been processed.  So no, you cannot do that.

Geoff

EDIT: Jim beat me to the answer.
Edited 2020-08-08 10:59 by Geoffg
Geoff Graham - http://geoffg.net
 
goc30

Guru

Joined: 12/04/2017
Location: France
Posts: 337
Posted: 10:35am 08 Aug 2020
Copy link to clipboard 
Print this post

I am sorry but "definefont" is processed when programm is loaded in same time as "constant" as others functions/commands/dim, not after. For that I don't undestand why it is not possible to interpret constant values.
Problem is that in Micormite for MM+, font #7 is loadable, and in CMM2, it is not possible. For that, when i load an old program, I must change every where Font number is 7.

another point, is that "constant value" can be use in programs, when it is load but also when it run, as any index value or any calculate value
Edited 2020-08-08 20:40 by goc30
 
Atomizer_Zero
Senior Member

Joined: 04/07/2020
Location: United Kingdom
Posts: 134
Posted: 10:56am 08 Aug 2020
Copy link to clipboard 
Print this post

"DefineFont", just like "#include" get processed before anything else in the code. This is just how it is on the CMM2. When you say "load "myprogramwithfontin.bas" ", the MMBasic will scan through the code and see "Definefont", load it in, and find "#include" and essentially paste the code from the include file, then it sets up the variables, etc. Then when you type "run", it executes the code (it doesn't touch the "#include" or "DefineFont" code anymore as it's already been worked on when you loaded).

CONST and DIM and OPTION get setup after "#include" and "Definefont".

Using the file browser and hitting Enter on the .BAS file, it performs all of the above in at once, so "load into memory", "include "#include"s", define "DefineFont", "run".
Edited 2020-08-08 20:59 by Atomizer_Zero
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 2743
Posted: 12:05pm 08 Aug 2020
Copy link to clipboard 
Print this post

  goc30 said  Problem is that in Micormite for MM+, font #7 is loadable, and in CMM2, it is not possible.

So why not use font #8 or #9 or #10 and so on?
The font numbers do not have to be sequential.

  goc30 said  I am sorry but "definefont" is processed when programm is loaded in same time as "constant" as others functions/commands/dim, not after. For that I don't undestand why it is not possible to interpret constant values.

The value of a CONST can be an expression (eg, CONST foo = SIN(1.23)) and for that to be evaluated the interpreter needs to be running.

Geoff
Geoff Graham - http://geoffg.net
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 3869
Posted: 04:48pm 10 Aug 2020
Copy link to clipboard 
Print this post

5.05.05b6 posted

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Fixed bug when FILES command is used on blank SDcard
Fixed bug in PLAY SOUND command that requires a frequency even when the mode is O
 
goc30

Guru

Joined: 12/04/2017
Location: France
Posts: 337
Posted: 05:41pm 10 Aug 2020
Copy link to clipboard 
Print this post

  Geoffg said  
So why not use font #8 or #9 or #10 and so on?
The font numbers do not have to be sequential.
Geoff

Because when I wrote my program, CMM2 do not exist, and Micromit accept loading font #7

  Geoffg said  

The value of a CONST can be an expression (eg, CONST foo = SIN(1.23)) and for that to be evaluated the interpreter needs to be running.

Geoff

If I undestand, I can't use const to load font, but I can use const in "Text" command


const internal_pol=6
const pol1=internal_pol+1

text posx,posy,"hello",CM,pol1,1

 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 3869
Posted: 05:44pm 10 Aug 2020
Copy link to clipboard 
Print this post

You can use a const in any command that is "interpreted". DEFINE FONT is not interpreted it is converted to binary when the program is loaded to flash or ram. This common to all versions of MMBasic. It cannot and isn't going to change.
Edited 2020-08-11 03:45 by matherp
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 3709
Posted: 07:03am 12 Aug 2020
Copy link to clipboard 
Print this post

I'll raise the issue here but it is also in micromite code so not specific to the CMM2

I was using STATIC in a function and had " Error: Conflicting variable type"

The function returns a string so I tried:
function ow_search$(PinNbr as integer)
 static integer LastDeviceFlag


That didn't work so I changed it to:
function ow_search(PinNbr as integer) as string
 static integer LastDeviceFlag


The second version works.

You can't have a STATIC integer or float if the function/sub name has the string identifier.

I assume that the STATIC name includes the full function name appended, causing the error.

I doubt if it is easy to fix so a note in the manual might be the best solution.

Jim
It all started with the ZX81....
VK7JH
http://www.c-com.com.au/MMedit.htm
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 710
Posted: 11:00am 13 Aug 2020
Copy link to clipboard 
Print this post

Sorry Peter, I think all the file-handling functions need inspecting for how they handle relative paths - I'm guessing it all needs to be going through the same code to create an absolute path before operating upon it.

Here are a couple more specific issues for you, consider the following:


> Print Cwd$
A:/SUB-DIR-1/SUB-DIR-2
> ls
A:/SUB-DIR-1/SUB-DIR-2
0 directories, 0 files

> ls "../"
A:/SUB-DIR-1
  <DIR>  sub-dir-2
11:50 13-08-2020         21  foo.bas
1 directory, 1 file


1. Trying
edit "../foo.bas"
does not show the current contents of "../foo.bas" in the editor, but will overwrite it when you exit the editor.

2. Typing
kill "../foo.bas"
reports "Error: Could not find the file"

3. Typing
mkdir "../sub-dir-3"
creates "sub-dir-3" in the current directory instead of its parent.

Regards,

Tom
CMM2 Welcome Tape, Z-MIM: Zork on the CMM2
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 2743
Posted: 11:48am 13 Aug 2020
Copy link to clipboard 
Print this post

  TassyJim said  I'll raise the issue here but it is also in micromite code so not specific to the CMM2.  I was using STATIC in a function and had " Error: Conflicting variable type"

Thanks Jim, you are right, it is in the core MMBasic code.  The fix for this turned out to be simple and it will be in the next Micromite release and Peter's next beta for the CMM2.

The workaround is, as you suggested, to always declare the function type using AS.  For example:  FUN MYFun() AS STRING.

Geoff
Geoff Graham - http://geoffg.net
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 369
Posted: 10:42pm 13 Aug 2020
Copy link to clipboard 
Print this post

Please see my posting in Oidzone video (4th post) about a BLIT bug. BLITs drawn partially off-screen with mirroring are not drawn correctly.
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 369
Posted: 10:55pm 13 Aug 2020
Copy link to clipboard 
Print this post

Atomizer_Zero's neat polygon test shows that the 'drawing stuff off or partly off the screen' bug is not completely squished.

Run his program, press right arrow a bit to skew the image to the left somewhat, then down arrow until part of the image slides off the top of the screen. Note the resulting horizontal line on the top of the screen. In contrast, the left, right and bottom edges appear to behave correctly.
 
     Page 1 of 7    
Print this page
© JAQ Software 2020