|
Post by Packobilly on Jun 29, 2020 8:06:16 GMT
Hi all! I have this asm call routine for a .pt3 music with its player to play in a BASIC loader:
START SET 60000 LD (START+10), A CALL START EI
LOOP HALT CALL START+5 LD A, (START+10) RLA JR NC, LOOP
RET When I run it, the music starts playing, but none of the IF INKEY$ options works. It seems that until the music ends you cannot press any key. I compiled the song with VT Player. Is there a way to solve this, so that at the same time as the music is running the menu in BASIC works? Thank you so much!!
|
|
|
Post by alessandro on Jun 29, 2020 17:29:39 GMT
Hi Packobilly,
in that code you posted there are no instructions reading the keyboard. Moreover, INKEY$ is a BASIC instruction, and the Spectrum won't return to BASIC until the last LOOP cycle has been performed and the RET instruction has been executed. That means you cannot play the music, or better said, run any machine code program, and run a BASIC instruction at the same time.
This code plays the music until a key is pressed. Assemble it and try it by entering PAUSE 1: RANDOMIZE USR YYYYY (where YYYYY is the address where you assembled it).
PLAYER EQU XXXXX ; XXXXX = address of the music player program
ORG YYYYY ; YYYYY = address where this code will be assembled, length 31 bytes
LD A,1 LD (PLAYER+10),A CALL PLAYER EI LOOP: HALT CALL PLAYER+5 XOR A IN A,(254) CPL AND 31 JR NZ,FINE LD A,(PLAYER+10) RLA JR NC,LOOP FINE: CALL PLAYER+8 RET
|
|
|
Post by Packobilly on Jun 29, 2020 18:42:29 GMT
Thanks, Alessandro. As you can see, I am trying a little more complicated things and thanks to advice like yours I am learning little by little. I will try this routine that surely works perfectly. Cheers!
|
|