Jump to content

Radio Buttons for the NTS-1 Patch Editor Part 03


k-Pack

234 views

I seem to remember that setting up radio buttons using Visual BASIC 4 was a point, click and fill in the properties table procedure.  Not so easy with Diamond GOS.  Programming Diamond is a lot like the early days of the Atari programing, when the only way to know if an algorithm would work was to try it, rather than searching the internet for an error free method.  Add up the frustration from (what I don't know about the (Atari hardware + MAC-65 + assembly language + Diamond GOS)) and you get the mountain I have to climb because it's there.   But it feels so good when you reach the top.   

 

The NTS-1 Patch Editor is going to need a radio button cluster using 26 icons; one for each of the MIDI controls.   Clicking on a button icon should change the image of the button to on, change the last button to the off image and store the icon number to memory.  

 

That's the easy part after the icon graphic has been designed. The process can be done using 2 Diamond functions.  INSTALLICON(#4) and SHAPEICON(#7).  The when-to-do-it is determined in the EVENT loop. If an icon event is detected the memory location EVENTTYPE should contain 1($01).  EVENTTYPE+1 will be equal to the Icon number.

 

This can all be done using the MAC-65 macros provided in the DMACRO.M65 library (my DMACRO01.M65 is the Diamond macro library with a couple of changes/corrections) But….. The macros were written using the immediate addressing mode and requires values be passed to the macro in the argument list.  Rewriting the macos as a subroutine using  absolute,X addressing, and data tables is far more memory efficient.

 

This short 3 radio button-do-nothing demo was used to test a routine that would change the on/off icon graphic and set the ACTIVEICON number.  It should be scalable to 26 icons. Failure is not an option. 

 

image.thumb.jpeg.3d44e25c93d0177796ae7a086f61976f.jpeg

The program RADIO.APP can be run from the desktop.  Click on the buttons to change the active icon or the Q icon to return to the desktop. The other files are source code in .M65.  The SYSPRT.MAS is a Macro And Subroutine that replaces the Diamond's SYSDRAW macro.

directory.thumb.jpg.0eaa6d7ca5191ec4a7d8820516302409.jpg

Radio 3 button demo.atr

 

I'm not sold on the use of multiple ON graphics for each icon.  Seems that if you change the icon shape and then change it back, the ON graphic could be used again for the next icon.  I tried this three times without success, but it always worked when using an ON and OFF graphic for each icon. Right now, it's just one more place where memory might be found if it gets scarce.

 

The MAC-65 source code:

 

10 ;RADIO BUTTON DEMO - DEMONSTRATES
20 ;USING ICONS TO CREATE A SERIES OF
30 ; BUTTONS WHERE ONLY ONE BUTTON CAN
40 ; BE ON/ACTIVE/PUSHED-IN.
50 ;
60 ;KEVIN PACKARD 3/2023
70 ;
80 ;
90 ;
0100     .OPT NO LIST
0110     *=  $2000
0120     .INCLUDE #D1:DMACRO01.M65
0130     .INCLUDE #D1:SYSPRT.MAS
0140 ;
0150 BUTOF1 .BYTE 0,60,102,66,66,102,60,0
0160 BUTON1 .BYTE 0,60,126,126,126,126,60,0
0170 BUTOF2 .BYTE 0,60,102,66,66,102,60,0
0180 BUTON2 .BYTE 0,60,126,126,126,126,60,0
0190 BUTOF3 .BYTE 0,60,102,66,66,102,60,0
0200 BUTON3 .BYTE 0,60,126,126,126,126,60,0
0220 BUTOFADRLO .BYTE 0, <BUTOF1, <BUTOF2, <BUTOF3
0230 BUTOFADRHI .BYTE 0, >BUTOF1, >BUTOF2, >BUTOF3
0240 BUTONADRLO .BYTE 0, <BUTON1, <BUTON2, <BUTON3
0250 BUTONADRHI .BYTE 0, >BUTON1, >BUTON2, >BUTON3
0260 ACTIVEICON .BYTE 1
0270 QICON .BYTE 0,60,102,102,102,108,54,0
0280 ;SYSPRT FORMAT X,Y,FONT,"TXT",255
0290 ASTR .BYTE 10,10,0,"A A",255
0300 BSTR .BYTE 10,20,0,"B B",255
0310 CSTR .BYTE 10,30,0,"C C",255
0320 ;
0330 START
0340      INIT  0
0350      SYSPRT  ASTR
0360      SYSPRT  BSTR
0370      SYSPRT  CSTR
0380      INSTALLICON  0,10,70,1,8,QICON
0390      INSTALLICON  1,10,10,1,8,BUTOF1
0400      INSTALLICON  2,10,20,1,8,BUTOF2
0410      INSTALLICON  3,10,30,1,8,BUTOF3
0420     LDX ACTIVEICON ;TURN ON INIT BUTTON
0430     STX B0
0440     JSR INITON
0450 ;
0460 LOOP  EVENT  
0470     LDA EVENTTYPE
0480     BEQ LOOP    ;NO EVENT
0490     CMP #1
0500     BNE LOOP    ;EVENT NOT ICON
0510     LDA EVENTTYPE+1
0520     BEQ ENDIT   ;IF ICON 0 END
0530     CMP #4
0540     BCS LOOP    ;IF <  NOT IN RANGE
0550     JSR CHANGEICON ;CHANGE BUTON
0560     JMP LOOP
0570 ENDIT  EXIT  
0580      EXECDESKTOP  
0600 ;
0610 CHANGEICON
0620     LDA ACTIVEICON ;ICON TO CHANGE
0630     STA B0
0640     TAX         ;ACTIVEICON OFFSET
0650     LDA BUTOFADRLO,X
0660     STA W0
0670     LDA BUTOFADRHI,X
0680     STA W0+1
0690     LDA #7      ;SHAPEICON
0700     JSR DIAMOND
0710     LDA EVENTTYPE+1 ;GET ICON #
0720     STA ACTIVEICON ;MAKE ACTIVE
0730     STA B0      ;OFF SET TO ADDRESS TABLE
0740     TAX 
0750 INITON LDA BUTONADRLO,X
0760     STA W0
0770     LDA BUTONADRHI,X
0780     STA W0+1
0790     LDA #7
0800     JSR DIAMOND
0810     RTS 
0820 ;
0830     *=  $02E0
0840     .WORD START

 

There is still the LOAD/SAVE and the change value routines to write before I start climbing Mt. Editor. Yup, just 3 more miles to base camp.

Raido three button demo.txt

  • Like 1

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...