![]() |
Forum Index : Microcontroller and PC projects : PicoMite Draft manual V6.00.02 - please review
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7933 |
Maybe or maybe not if your comments are on this thread. :) - matherp on the "PicoMite V6.00.02" thread. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1003 |
Manual Feedback Obsolete Commands and Functions MM.HPOS,MM.VPOS,MM.VER,MM.FONTHEIGHT,MM.FONTWIDTH are no longer obsolete and should be removed. Appendix H Special Keyboard Keys B(5) and 20 Hex is added for shift not B(6) and 40 Hex Teraterm VT100 seems only to send codes for Shift (F3-F8) (Peter should verify these before you change in case I am missing something) > list Print "Testing Inkey CNTRL+C to exit" Do a$=Inkey$ If a$<>"" Then Print Hex$(Asc(a$),2),Asc(a$) End If Loop Suggested addition of shifted codes to F1-F12 keys in table in Appendix H Keyboard Key Key Code Keycode (HEX) (Decimal) ------------- ------- --------- F1/Shift F1 91/B1 145/177 F2/Shift F2 92/B2 146/178 F3/Shift F3 ** 93/B3 147/179 F4/Shift F4 ** 94/B4 148/180 F5/Shift F5 ** 95/B5 149/181 F6/Shift F6 ** 96/B6 150/182 F7/Shift F7 ** 97/B7 151/183 F8/Shift F8 ** 98/B8 152/184 F9/Shift F9 91/B9 153/185 F10/Shift F10 91/BA 154/186 F11/Shift F11 91/BB 155/187 F12/Shift F12 91/BC 156/188 ** indicates also work for VT100 emulators Suggested replacement text at bottom For attached PS2 and USB keyboards, if the shift key is simultaneously pressed with the function keys F1 to F12 then 20 (hex) is added to the code (this is the equivalent of setting bit 5). For example Shift-F10 will generate BA (hex). The shift modifier works with the function keys F1 to F12; it is ignored for the other keys except TAB, DEL, DOWN_ARROW and RIGHT_ARROW as identified above. MMBasic will translate most VT100 escape codes generated by terminal emulators such as TeraTerm and Putty to these codes (the shift modifier only works for F3-F8). This means that a terminal emulator operating over a USB or a serial port opened as console will generate the same key codes as a directly attached keyboard. Latest F4 Latest H7 FotS |
||||
toml_12953 Guru ![]() Joined: 13/02/2015 Location: United StatesPosts: 440 |
Why remove them if they're no longer obsolete? |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1003 |
They are in the section Obsolete Commands and Functions! Latest F4 Latest H7 FotS |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1593 |
Since this was already overlooked in the last update: and I couldn't get it (PLAY LOAD SOUND) to work with MEMORY PACK, I found some more typos in the description of the sprite commands: p. 159 (Blit load?) p. 183 (missing closing bracket) p. 184 (Duplicate section) (so1 = s1) Kind regards Michael causality ≠ correlation ≠ coincidence |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5087 |
@Geoff, Peter, MM.INFO(FILESIZE filename$) returns 0 if the file does not exist, or the size. The -1 and -2 reponse does not show any more since the 2 new functions MM.INFO(EXISTS FILE filename$) MM.INFO(EXISTS DIR foldername$) Take over that role. Volhout PicomiteVGA PETSCII ROBOTS |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1593 |
Thanks Harm good to know! Michael causality ≠ correlation ≠ coincidence |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
I believe the manual should mention that PEEK and POKE are "aligned", e.g. PEEK(WORD address%) will "round" the address% down to the nearest WORD (32-bit) boundary. Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10305 |
Poke will error, peek will round - not sure how that happened |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
You are correct, I had mistakenly assumed they would be symmetric but I see that even MMB4L has this strange asymmetric behaviour. Is it even necessary to guard against unaligned memory access in the modern era ? This all came up when I was reading the 'width' and 'height' from a .bmp header that I had read into a string. These are 32-bit words starting at bytes 18 and 22 of the header (19 and 23 of the string). Note that I have resolved this by doing it long-hand so I don't need help there. Best wishes, Tom Edited 2025-06-29 02:11 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10305 |
Tom AFAIK Arm only support unaligned memory access on the Cortex-M7 and above (e.g. the STM32H743 in the CMM2). However, even on that chip it is painfully slow and is only supported for 32-bit operations - NOT double word |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Doesn't the compiler save you from this low-level "nonsense" ? In any case, if you were so inclined could the MMBasic interpreter not check if the PEEK/POKE was aligned and if not then do it byte by byte ? Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
I expect the compiler lets you suffer if you do the wrong access. I suppose MMBasic could do it along the lines you put. Feels to me a bit like those who insist on PEEK/POKE should take care! John |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Possibly though I don't think I'm doing anything unreasonable, reading data from a file into a string and then trying to PEEK a 32-bit value from that string ... it's just that 32-bit value isn't aligned in the string's memory ![]() Unless Peter is going to tell me he is going to do "something that would conflict" in the MMBasic mainline I'm going to do the following in MMB4L: a) Throw errors from both PEEK and POKE for unaligned access - no more mysteriously rounding down the address in PEEK. b) Record an issue (https://github.com/thwill1000/mmb4l/issues) to consider adding UPEEK and UPOKE for unaligned access in the future. Best wishes, Tom Edited 2025-07-03 03:32 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
I'm sure you can write some Basic code that can take an address (aligned or unaligned) and extract data via aligned addresses then combine the appropriate bytes to make a 32-bit value :) (It would be easier if the CPU allows a byte to be extracted from any address, then it's just a few shifts. But some CPUs are a bit evil and may not allow that...) In the case of reading from a file into a string it's particularly easy to use MID to extract each byte from the string, of course. John Edited 2025-07-03 08:08 by JohnS |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1593 |
Hi Geoff, In the meantime, I was able to get PLAY SOUND working for custom sounds. But I think the description of the frequency parameter on page 146: PLAY SOUND soundno, channelno, type [,frequency] [,volume] ‘frequency’ is the frequency from 1 to 20000 (Hz) and it must be specified except when type is O. is not correct for ustom sounds (Type: U). As far as I can tell, values from about 1 to 10 are actually meaningful. Here, 2 seems to represent the original frequency of the sound sample (PLAY LOAD SOUND). A value of 1 appears to halve the frequency, and values above 2 act as multipliers. I don't know if this is intended, it's a useful behavior if you know it, but without a description, it's simply confusing. Kind regards Michael causality ≠ correlation ≠ coincidence |
||||
phil99![]() Guru ![]() Joined: 11/02/2018 Location: AustraliaPosts: 2638 |
After Volhout found the problem with Type S I tried Type U and found it had the same problem. One channel works exactly as per the manual and the other is 3.3V. This confuses me as the packed array used for PLAY LOAD SOUND array%() doesn't have a frequency. It is just an arbitrary waveform, so that would appear to be another issue. The only error in the manual for PLAY LOAD SOUND is which should be 4096. Edited 2025-07-04 23:17 by phil99 |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1593 |
@Phil You're right. Of course, a waveform is dimensionless and dependent on sample rate and resolution. But at reasonable sample rates (8000 or 16000 S/sec and 12-bit resolution) for sound snippets, the described behavior occurs. I suspect this also explains the behavior of the multiplier. Edit Some results (for those concerned): At a sample rate of 4000, a frequency parameter of 1 will play back the waveform at its original pitch. At a sample rate of 8000, a frequency parameter of 2 will play back the waveform at its original pitch. At a sample rate of 16000, a frequency parameter of 4 will play back the waveform at its original pitch. That's not correct! If that were the only error and the description in the manual were correct, then you could set the frequency with the frequency parameter, but that doesn't make sense for user-defined sounds, since MMBasic doesn't analyze the waveform. Regards Michael @Geoff: It might be worth adding that, in Type U mode, the "frequency" parameter can also accept decimal values. This allows you to generate an unlimited number of different tones from a single waveform. The waveform should be changed by replacing the packed arrays directly, without using PLAY STOP beforehand! Edited 2025-07-05 02:25 by twofingers causality ≠ correlation ≠ coincidence |
||||
phil99![]() Guru ![]() Joined: 11/02/2018 Location: AustraliaPosts: 2638 |
Peter will be the final arbiter of course but my recollection of the introduction of Type U is the array is intended for a single cycle of arbitrary shape. Play Sound then sets the output frequency and amplitude, exactly the same as the other Types. If you put two or more cycles in the array the output frequency is multiplied by the number of cycles in it. This may cause aliasing if the frequency is set higher than 22000 / number of cycles. It works for you when you set a very low frequency. Edit. This shows the the result of arrays with 1 and 2 cycles. > Dim Integer n, a1(4095), a2(1023) > for n=0 to 4095 : a1(n)=cos(2*pi/4095 * n) * 2047 +2047 : next 'make 1 cycle > memory pack a1(), a2(), 4096, 16 > play load sound a2() : play sound 2,L,U,1000,25 : do : loop 'output 1kHz sinewave <ctrl-c> > > for n=0 to 4095 : a1(n)=cos(4*pi/4095 * n) * 2047 +2047 : next 'make 2 cycles > memory pack a1(), a2(), 4096, 16 > play load sound a2() : play sound 2,L,U,1000,25 : do : loop 'output 2kHz sinewave Creating a waveform with harmonics for Type U Edited 2025-07-05 14:34 by phil99 |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1593 |
Thanks Phil, very useful. ![]() I must have missed last year's post because I was in the hospital. But you also notice that in the second example you use a multiplier instead of a frequency? ![]() By the way, I used for your example "PLAY SOUND 1, "M", U, 1000, 25" I consider the function even more valuable if it allows me not only to play a single wave cycle, but also sequences of cycles with a decay characteristic or an envelope ... And there are simpler commands for sine waves. ![]() I mean, it's more useful to play complex waveforms, but I understand and acknowledge that you've only shown simple examples here! I would also be in favor of removing the 4096 bytes limit; then even longer sound effects would be possible. ![]() 80 Hz, 8000 sample rate. ![]() 445 hz Kind regards Michael causality ≠ correlation ≠ coincidence |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |