          OPT A+      ; use (PC)-relativ adressing
          OPT O3+     ; use short-word addressing
          OPT O4+     ; use MOVEQ
          OPT O5+     ; use ADDQ / SUBQ

;####################################################################
;#         Externes Programm fr ZX-SPECTRUM EMULATOR 2.0
;#
;#  Schaltet zwischen den Emulator-Sets 1..4 um.
;#  Einzubinden im Config-Dialog des Setup-Programmes (siehe Doku)
;####################################################################

sw_set:   move.l   4(a7),a5             ; BASEPAGE
          lea      128(a5),a5           ; Adresse der Kommandozeile
          cmpi.b   #'½',1(a5)           ; Aufruf vom Emulator?
          bne.s    sws_exi              ; Exit, wenn vom Desktop
          
          lea      2+4*8(a5),a0         ; Adresse fr Return-Wert
          bsr      asc2hex
          move.l   d0,a4                ; nach a4
          lea      2+5*8(a5),a0         ; Kommandozeile Nr. akt. Set
          bsr      asc2hex

          addq.w   #1,d0                ; nchstes Set
          andi.w   #3,d0                ; 0...3...0

          move.w   #10,(a4)             ; Return=Einstellen neues Set
          move.w   d0,2(a4)             ; Set.Nr

sws_exi: 
          clr.w    -(sp)                ; fertig
          trap     #1

asc2hex:  moveq     #0,d0
          moveq     #8-1,d1
a2h_05:   move.b    (a0)+,d2
          cmpi.b    #'9'+1,d2
          bcs.s     a2h_10
          subq.b    #7,d2
a2h_10:   subi.b    #'0',d2
          lsl.l     #4,d0
          or.b      d2,d0
          dbf       d1,a2h_05
          rts
