Hello to all you User's MSX World,
I need of an INTERRUPT TIME hook for a sound SFX in assembler,
PLEASE....... (^_^)
Here under there is the source in assembler code Z80 MSX for compiler
CHAOS ASSEMBLER 3.
.org $E000 - 7 .db $fe .dw startProgram,endProgram,startProgram startProgram: START_SOUND_SFX: ; --------------------------- ; SET SOUND SFX LD A,$01 LD E,$02 CALL $93 ;sound LD A,$08 LD E,$0F CALL $93 ; -------------------------- LOOP1: INC E LD A,E CP $00 JR Z,SOUND LD A,$00 CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 ;; NOP CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 NOP CALL $93 JR LOOP1 ;LOOP to LOOP1 SOUND: LD E,$16 LOOP2: LD A,E CP $00 RET Z ;exit if A=0 LD A,$08 CALL $93 LD A,$00 CALL $93 DEC E ;E=E-1 CALL $93 NOP JR LOOP2 ;LOOP to LOOP2 endProgram: .end
Instead here uder there is the BASIC programm in code machine:
100 REM 110 REM ** LOADER L/M SOUND SFX BONUS ** 120 REM 130 CLEAR300,57343:RESTORE 200 140 FOR X=57344 TO 57470 150 READ A$:Y=VAL("&H"+A$) 160 POKE X,Y:CK=CK+Y 170 NEXT X 180 READ X:IF X<>CK THEN BEEP:PRINT"ERRORE NEI DATA: RICONTROLLA!":LIST 200-360:END 190 DEFUSR=&HE000:END 200 DATA 3E,01,1E,02,CD,93,00,3E 210 DATA 08,1E,0F,CD,93,00,1C,7B 220 DATA FE,00,28,53,3E,00,CD,93 230 DATA 00,00,CD,93,00,00,CD,93 240 DATA 00,00,CD,93,00,00,CD,93 250 DATA 00,00,CD,93,00,00,CD,93 260 DATA 00,00,CD,93,00,00,CD,93 270 DATA 00,00,CD,93,00,00,CD,93 280 DATA 00,00,CD,93,00,00,CD,93 290 DATA 00,00,CD,93,00,00,CD,93 300 DATA 00,00,CD,93,00,00,CD,93 310 DATA 00,00,CD,93,00,00,CD,93 320 DATA 00,00,CD,93,00,18,A7,1E 330 DATA 16,7B,FE,00,C8,3E,08,CD 340 DATA 93,00,3E,00,CD,93,00,1D 350 DATA CD,93,00,00,18,EB,FF 360 DATA 11095
The effect are is allocated to the address E00h
so to hear it simply type
A=USR(0): REM PLAY SOUND SFX BONUS!
As a sound effect, it might be fine when the player
1UP, collides with a bonus score item.
When starting this bonus sound effect, the BASIC remains frozen for a short time,
while the sound effect with A = USR (0) is heard, and therefore it is necessary to put
a time interrupt on the Z80, so that while the 'sound effect starts, BASIC remains free,
this is because if a program of a small videogames in BASIC, without the TIME INTERRUPT
to the Z80 the videogame would slow down a lot, and this should not happen.
Below is a small example of using the HOOK interrupt time:
.org $C000 - $C07 .db $fe .dw startProgram,endProgram,startProgram startProgram: ;************************************************************* ; How to use HOOK safety ; This routine uses TIMER INTERRUPT HOOK ; ; To start play SOUND SFX, do DEFUSR=&HC000 :A=USR(0) ; To continue sound SFX , do DEFUSR=&HC030:A=USR(0) ; To pause sound SFX, do DEFUSR=&HC050: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 START: ; load and initialize START SOUND SFX .ORG $C020 - $C00 ; CONTINUE SOUND SFX 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 - $C00 ; PAUSE SOUND ;----- 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 $90 ;CALL MUTE ; silence RET CAPON: CALL START_SOUND_SFX ; 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 "SOUND.ASM" ; routine sound.asm endProgram: .end
What I would like to ask you and what I want to achieve is that the sound effect
works with the interrupt time at the Z80, I repeat, so that BASIC remains free,
without any BASIC program slowing down when it is running.
That's all for now, I'm waiting for one
your positive answer.
Best Regards
(^_^)
Andrea Italy