Interrupting a Play command

Door mcavalcanti

Rookie (20)

afbeelding van mcavalcanti

30-03-2013, 22:22

Hello, guys.

I know the Play command plays a sequence of notes, but is there a way (in BASIC) to interrupt a Play command when, for example, I press the space bar? Something like the code below:

  10 PLAY "CDEFGABCDEFGAB"
  20 A$=INKEY$
  30 IFA$=CHR$(32)THEN PLAY"V0":END
  40 GOTO 20

Thanks. Best.

Aangemeld of registreer om reacties te plaatsen

Van o.geerdink

Hero (569)

afbeelding van o.geerdink

30-03-2013, 22:33

On Key Gosub??

Van theNestruo

Master (246)

afbeelding van theNestruo

31-03-2013, 09:23

Try DEFUSR=&H90:A=USR(0) instead of PLAY"V0"

Van mcavalcanti

Rookie (20)

afbeelding van mcavalcanti

31-03-2013, 15:15

Hey! It works very good. Until 25 notes, the music stops immediately, but if your music has more than 25 notes, there's a delay. Thanks, theNestruo! Smile

Van sd_snatcher

Prophet (3401)

afbeelding van sd_snatcher

01-04-2013, 01:52

The BEEP command interrupts any playing notes and flushes the queue.

Van gasparrini

Champion (309)

afbeelding van gasparrini

01-04-2013, 11:13

Hello Guys, Hello mcavalcanti,

listen: I understand that you would like to play some basic molodie in the MSX-BASIC using the PLAY function, but in my experience, and means specially in our day today, and I think that it is so! That use the basic to make music is a waste of time, and also useless! Because even if you should do to turn your music into basic, and at the same time a game program, the whole program should be in slow motion!

Therefore: what I suggest, is to program in assembly, using an assembler such as CHAOS ASSEMBLY 3 for Windows, but the compiled binary works fine on MSX/MSX2 ect ....

Example:

; GAMECAST Entertainment MSX Z80 source file.
;
; Prog: MUSIC SONG 1 for MINER BANK
; Code: Gasparrini Andrea 
; Date: 27 Marzo 2013
;
; cmnt:
;
; Coded in TeddyWareZ' Chaos Assembler 3
;
; (C) 2013 GameCast Entertainment

	.org $C000 - 7

	.db $fe
	.dw startProgram,endProgram,startProgram

startProgram:
;*************************************************************
;   List 2.4   How to use HOOK safety
;	       This routine uses TIMER INTERRUPT HOOK
;				   
;	       To start, do  DEF USR=&HC000 : A=USR(0)
;	       To end,	 do  DEF USR=&HC030 : A=USR(0)
;*************************************************************
;
CHGCAP     .EQU	0132H		;CAPS LAMP on/off
CAPST	 .EQU	0FCABH		;CAPS LOCK status
TIMI	         .EQU	0FD9FH		;timer interrupt hook
JPCODE      .EQU	0C3H
TIMER	 .EQU	020H


;----- interrupt on ----- Note:  restore the former hook
				 ;when changing the hook
      
 CALL START  ; load and initialize STAR MUSIC

 .ORG $C020   ; CONTINUE MUSIC

INTON:	
      DI
	LD	HL,TIMI 	;OLD HOOK SAVE
	LD	DE,HKSAVE
	LD	BC,5
	LDIR

	LD	A,JPCODE	;NEW HOOK SET
	LD	(TIMI),A
	LD	HL,INT
	LD	(TIMI+1),HL
	EI
	RET

	.ORG	$C050  ; PAUSE MUSIC

;----- interrupt off ----- Note:  restore the reserved hook and exit

INTOFF:
      DI
	LD	HL,HKSAVE
	LD	DE,TIMI
	LD	BC,5
	LDIR
	EI  
	CALL $90 ; resetta canale audio
	RET

;----- interrupt routine -----

INT:	PUSH	AF
	LD	A,(CAPST)
	OR	A
	JR	Z,CAPON

CAPOFF: 
   CALL MUTE  ; silence

CAPON:
   CALL PLAY  ; play 1 quark
   
FIN:
 	POP	AF
	CALL	HKSAVE		;old HOOK call

	RET

COUNT1:
      .DB TIMER
COUNT2:
      .DB TIMER

HKSAVE: 
        NOP			;old HOOK save area
	NOP
	NOP
	NOP
	RET   

;----- interrupt routine -----

#INCLUDE "pt3.asm"                             ; library for PT3 files music
#INCLUDE "minerbankmusic1pt3.asm"   ; Song FACTOR.PT3 converted to HEX values
endProgram:

.end

to listen to music from basic, proceed as follows:

   
DEFUSR1=&HC000:A=USR1(0):REM  PLAY MUSIC!
DEFUSR2=&HC020:A=USR2(0):REM  CONTINUE MUSIC!
DEFUSR3=&HC050:A=USR3(0):REM  PAUSE MUSIC!

I repeat, do not stand to spend some time making music in basic.
I hope that in some way of signing been help .....
Good luck and Happy MSX !! (^_^)
Best Regards
(O_*)
AG.