SOUND Utility

Use this section to showcase your programming examples. Or to ask members for programming suggestions
Post Reply
User avatar
Zenerdiode
Posts: 44
Joined: Wed Jan 04, 2023 12:45 am
Location: Newcastle, England

SOUND Utility

Post by Zenerdiode »

I'm thinking about enhancing a few of the utilities in the UTILS menu. My bugbear with the native SOUND utility is that it doesn't tell you the existing setting; also I'm not keen on menu items with the same starting letter (On and Off in the native utility) - as I like to press the associated key.

Please, comments and criticisms on my coding style:

Code: Select all

SOUND:
LOCAL k% :REM Key Click flag
LOCAL s% :REM Sound flag
LOCAL m% :REM Menu Result
LOCAL kf$(2),sf$(2) :REM Strings for 'On or Off'

UDG 0,9,10,12,10,9,0,0,21   :REM K
UDG 1,14,8,12,8,14,0,0,21   :REM E
UDG 2,10,10,4,4,4,0,0,21    :REM Y
UDG 3,14,8,14,2,14,0,0,21   :REM S
UDG 4,14,10,10,10,14,0,0,21 :REM O
UDG 5,0,0,0,0,0,0,0,21      :REM <Space>
UDG 6,0,0,31,0,0,0,0,21     :REM -
REM 7,0,0,14,10,10,0,0,21   :REM n
REM 7,6,8,12,8,8,0,0,21     :REM f

k%=PEEKB($20C0) :REM 0-Off 1-On
s%=PEEKB($00A4) :REM 1-Off 0-On

IF k%
 UDG 7,0,0,14,10,10,0,0,21
 kf$=CHR$(7)+CHR$(5)
ELSE
 UDG 7,6,8,12,8,8,0,0,21
 kf$=CHR$(7)+CHR$(7)
ENDIF

IF s%
 sf$="ff"
ELSE
 sf$="n "
ENDIF

CLS
AT 4,1 :PRINT "SET THE SOUND"
AT 5,2 :PRINT "Sound - O"+sf$
AT 1,3 :PRINT REPT$(CHR$(5),5)+CHR$(0)+CHR$(1)+CHR$(2)+CHR$(3)+CHR$(5)+CHR$(6)+CHR$(5)+CHR$(4)+kf$+REPT$(CHR$(5),5)
AT 1,4 :m%=MENUN(1,"SOUND,KEYS,EXIT")

IF m%=1
 IF s% :REM Sound currently off
  POKEB $00A4,0
  PRINT CHR$(12)+CHR$(16)
 ELSE
  POKEB $00A4,1
 ENDIF

ELSEIF m%=2
 IF k% :REM Keys currently on
  POKEB $20C0,0
 ELSE
  POKEB $20C0,1
 ENDIF
ENDIF

REM **********************
REM *   SET THE SOUND    *
REM *    Sound - Off     *
REM *     Keys - Off     *
REM *Sound Keys Exit     *
REM **********************
Christopher. - Check out my TRAP message, it’s not difficult to decode and is sometimes uttered under the breath when said message appears… :|
User avatar
Martin
Global Admin
Posts: 220
Joined: Mon Jan 02, 2023 5:18 pm

SOUND Utility - Works

Post by Martin »

Hi Christopher

I've tried it and yes it works fine.. I like the redesigned characters....

If you have 'lots' of these 'utilities' you could group them together in an Apps module example (here)

Others have included sound switches in their programmes, here is an example from the Angular Pack..

Code: Select all

utnoise:
REM Utility Noise turns Sound ON or OFF
REM Taken from the Angular Pack - Martin Reid

CLS
PRINT "Sound Switched ";
IF PEEKB(164)=0
 POKEB 164,1
 PRINT " OFF"
ELSE
 PRINT " ON"
 POKEB 164,0
 BEEP 100,100
ENDIF
GET
These small utilities are also useful to CM/XP users who don't have access to a Utils Menu that as introduced with the LZ range.

Sincerely
Martin
Lostgallifreyan
Posts: 83
Joined: Thu Jan 12, 2023 8:25 pm

Re: SOUND Utility

Post by Lostgallifreyan »

Zenerdiode, I have an idea... (I hate having two entries in any menu with same letter too, for the same reason you do).

My idea (for which I have no programatic example) is that if you use the key TSR by Jaap Scherphuis, you have a possibility for many unique keyed shortcuts, using OPL KEY or GET, or a menu, to capture input. The TSR makes key sequences available for all ASCII values, including the ability to customise an array of one-key accesses to a specific character code. If you put one entry on the main menu, to call a small program to interpret your key codes, you could call arbitrary stuff, and even without the TSR, you can set up second-level menus so you can have a branching access to stuff with a minimal keystroke count for each destination.

If this TSR idea sounds useful to you, let me know, and I'll post a modified key TSR that I use, it takes a small subprocedure that sets up a user-defined array for the more commonly used keys. I did this to it because one person might want electronic symbols, and another might want more European accented characters, etc, so it's useful to make a custom array that loads when the TSR is loaded. Once it's in place, it stays there until the TSR is removed (or the Organiser breaks so badly it needs a reset).
Post Reply