Interrupt time Z80 for work with sound effect in assembler MSX

Страница 1/3
| 2 | 3

By gasparrini

Champion (301)

Аватар пользователя gasparrini

23-07-2009, 16:25

Hello Guys,

I sent you, 2 source programm in assembler for make interrupt time Z80 for
work with sound effect in assembler MSX.
But it unfortunately doesn't work, it is not interrupt time, then is not good
for MSX BASIC!!

Can you help me? Please? Please? ^_^

I hope than you have free time for make this litte work for me, OK??

You remember, than I job with CHAOS ASSEMBLER for Windows.

See you to soon.....
Andrea Gasparrini from Italy

; [YOUR GROUP] MSX Z80 source file.
;
; Prog: 
; Code: [YOUR HANDLE]
; Date:
;
; cmnt:
;
; Coded in TeddyWareZ' Chaos Assembler 3
;
; (C) 2001 [YOUR GROUP]!



	.org $B000 - 7

	.db $fe
	.dw startProgram,endProgram,startProgram

startProgram:
;*************************************************************
;   List 2.4   How to use HOOK safety
;	       This routine uses TIMER INTERRUPT HOOK
;				   and turn on/off CAPS LOCK
;	       To start, do  DEF USR=&HB000 : A=USR(0)
;	       To end,	 do  DEF USR=&HB030 : 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 $B020   ; 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	$B050  ; 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: 
   ; silence

CAPON:
   ; 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 "bomba2.asm"
endProgram:

.end



start:

 LD A,7
 LD E,254
 CALL 147
 LD A,8
 LD E,15
 CALL 147
 LD E,40
CICLO:
 LD A,0
 CALL 147
 LD A,10
RITARDO:
 PUSH AF
 LD A,255
MENO:
 DEC A
 JP NZ,MENO
 POP AF
 DEC A
 JP NZ,RITARDO
 LD A,E
 SUB 150
 JP Z,NEXT
 ADD A,151
 LD E,A
 JP CICLO
NEXT:
 LD A,0
 LD E,0
 CALL 147
 LD A,7
 LD E,247
 CALL 147
 LD A,0
NEXT1: 
 PUSH AF   
 LD E,A
 CALL 147
 LD A,50
PIPPO:
 PUSH AF
 LD A,255
PLUTO: 
 DEC A
 JP NZ,PLUTO
 POP AF
 DEC A
 JP NZ,PIPPO
 POP AF
 SUB 31
 JP Z,RITA
 ADD A,32
 JP NEXT1
RITA:
 LD A,100
RITA1:
 PUSH AF
 LD A,255
RITA2:
 DEC A
 JP NZ,RITA2
 POP AF
 DEC A
 JP NZ,RITA1
 LD A,7
 LD E,255
 CALL 147
 RET
  
end:
Для того, чтобы оставить комментарий, необходимо регистрация или !login

By Sonic_aka_T

Enlighted (4130)

Аватар пользователя Sonic_aka_T

23-07-2009, 19:56

Hi,

I'd like to help, but I'm not really sure what you're trying to do. Do you want to create a routine which plays sound effects, or do you only need a routine which handles the interrupt service?

By ARTRAG

Enlighted (6280)

Аватар пользователя ARTRAG

23-07-2009, 22:03

Try to see if you can use the aySFX code ftom z80st
http://z80st-software.blogspot.com/

the code is here
http://www.lasekta.org/Z80ST/ayFX-replayer-1.2.rar

By RetroTechie

Paragon (1563)

Аватар пользователя RetroTechie

24-07-2009, 01:18

Have you checked a full listing for the assembled code, or loaded up in a debugger? That is, check what the assembler actually outputs as binary file, and where everything is located? I can see several problems with your code:

  • the BLOAD header says code goes from startProgram to endProgram, possibly BASIC loads just that, and "start" routine (behind endProgram) isn't loaded?
  • I get the feeling you're trying to use .ORG statements to make code start at specific addresses (and expect the assembler to fill up spaces in between). Don't! .ORG serves as reference for absolute addresses, but *you* should watch how much space everything takes up. One .ORG statement is enough, unless the code itself relocates pieces of code that contain absolute addresses. Also: doesn't the ".end" directive tell the assembler to stop assembling code? That means "start" routine shouldn't be included, even though you're calling it? Weird... Question
  • The CAPON section is always executed... perhaps you'd want to end CAPOFF section with a JR to FIN ?
  • Why not simply store the old hook contents directly behind your interrupt routine?
  • Btw: what does that "start" routine do?

Let me make some edits, see if this works for you?



; [YOUR GROUP] MSX Z80 source file.
;
; Prog: 
; Code: [YOUR HANDLE]
; Date:
;
; cmnt:
;
; Coded in TeddyWareZ' Chaos Assembler 3
;
; (C) 2001 [YOUR GROUP]!



;*************************************************************
;   List 2.4   How to use HOOK safely
;	       This routine uses TIMER INTERRUPT HOOK
;				   and turn on/off CAPS LOCK
;	       To start, do  DEF USR=&HB000 : A=USR(0)
;	       To end,	 do  DEF USR=&HB002 : 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



	.db $fe
	.dw startProgram,end-1,startProgram

	.org $B000

startProgram:

;----- interrupt on ----- Note:  restore the former hook
				 ;when changing the hook
	JR INTON

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

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


INTON:
	CALL START  ; load and initialize STAR MUSIC
	LD	HL,TIMI 	;OLD HOOK SAVE
	LD	DE,HKSAVE
	LD	BC,5
	LDIR

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


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

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

CAPOFF: 
   ; silence
	JR FIN

CAPON:
   ; play 1 quark
   
FIN:
 	POP	AF
HKSAVE:
	NOP			;old HOOK save area
	NOP
	NOP
	NOP
	RET

COUNT1:           
      .DB TIMER
COUNT2:
      .DB TIMER


start:

 LD A,7
 LD E,254
 CALL 147
 LD A,8
 LD E,15
 CALL 147
 LD E,40
CICLO:
 LD A,0
 CALL 147
 LD A,10
RITARDO:
 PUSH AF
 LD A,255
MENO:
 DEC A
 JP NZ,MENO
 POP AF
 DEC A
 JP NZ,RITARDO
 LD A,E
 SUB 150
 JP Z,NEXT
 ADD A,151
 LD E,A
 JP CICLO
NEXT:
 LD A,0
 LD E,0
 CALL 147
 LD A,7
 LD E,247
 CALL 147
 LD A,0
NEXT1: 
 PUSH AF   
 LD E,A
 CALL 147
 LD A,50
PIPPO:
 PUSH AF
 LD A,255
PLUTO: 
 DEC A
 JP NZ,PLUTO
 POP AF
 DEC A
 JP NZ,PIPPO
 POP AF
 SUB 31
 JP Z,RITA
 ADD A,32
 JP NEXT1
RITA:
 LD A,100
RITA1:
 PUSH AF
 LD A,255
RITA2:
 DEC A
 JP NZ,RITA2
 POP AF
 DEC A
 JP NZ,RITA1
 LD A,7
 LD E,255
 CALL 147
 RET
  
end:

By jltursan

Prophet (2193)

Аватар пользователя jltursan

24-07-2009, 17:46

The start routine is somekind of sfx playing routine; but not designed to be executed under an interrupt. Seems that it plays the full effect in a row...

What Andrea is looking for is a multi-purpose and BASIC compatible playing routine. The only one I can barely recall is the mbwave BASIC replayer; but of course it's designed for the Moonsound.

Anyone can point out a BASIC replayer routine (music, SFX or both)?. I think that I've never found one Sad

By RetroTechie

Paragon (1563)

Аватар пользователя RetroTechie

24-07-2009, 21:14

The start routine is somekind of sfx playing routine; but not designed to be executed under an interrupt.
... and isn't used that way (at least not in above code).

I have no idea about the exact PSG registers addressed and what they do Tongue, but: sequences of increasing/decreasing values written, delays in between... I suspect it serves as a "kill whatever PSG sound that may already be playing, gradually".

I hope than you have free time for make this litte work for me, OK??

You remember, than I job with CHAOS ASSEMBLER for Windows.
Gotta love those machine translations... only some of those Japanse/Korean/Chinese -> English manual translations are funnier LOL!Wink

By gasparrini

Champion (301)

Аватар пользователя gasparrini

25-07-2009, 02:22

Post for Retro Techie,

Thank you for your help for me,
But...Unfortunately your new routine doesn't work!!!
Because:
1) When I compile the source assembler with the CHAOS ASSEMBLER
, the compile it creates a file of 45 Kbyte, then it is not possible!!
Inside there is error bug.
2) When I to load the file binary and RUN with DEFUSR=&HB000:
A=USR(0) the sound is mute!!!

Then... now... Please.... Fix this your new routine, Ok???

See you to soon....
Good night
Andrea Gasparrini from Italy

Hannibal

By Edwin

Paragon (1182)

Аватар пользователя Edwin

25-07-2009, 15:08

If it's just about soundeffects (not music) then the SEE replayer is probably the easiest to modify for use in basic.

By RetroTechie

Paragon (1563)

Аватар пользователя RetroTechie

25-07-2009, 18:47

Then... now... Please.... Fix this your new routine, Ok???
Ehm sorry, I thought you were writing this program, not me... Besides you're not paying me LOL!

1) When I compile the source assembler with the CHAOS ASSEMBLER
, the compile it creates a file of 45 Kbyte, then it is not possible!!
Inside there is error bug.

'Error bug' inside CHAOS ASSEMBLER, obviously... the above code 'skeleton' is a few hundred bytes maximum (since as you can see, there's no actual player code, just placeholders "silence" and "play 1 quark" ). Perhaps it needs that '.end' directive (add on last line, after "end:" label) ? Perhaps you're including that "bomba2.asm", and it contains a shitload of code/data you're not using? Try copy/pasting just the stuff you need... and again: check what the assembler actually outputs as binary file, and where everything is located.

2) When I to load the file binary and RUN with DEFUSR=&HB000: A=USR(0) the sound is mute!!!
Ehm.. initialize PSG, install interrupt routine that does... nothing? Sounds like intended behaviour to me. There's a lot of variables here, and you should have a better handle on those: What sound data are you trying to play? Is it loaded? Where is it in memory? How do you tell player code where sound data is? Have you done that? Can you hear sound from other games and so on (monitor/external speakers on) ? It's sensitive to CAPS LOCK status? Try flipping that on and off? Etc. etc. etc.

What player code are you trying to use anyway? Perhaps a well documented, ready-made solution (that SEE replayer Edwin mentioned, for example) would be easier?

By gasparrini

Champion (301)

Аватар пользователя gasparrini

26-07-2009, 13:15

Hi retro Techie,

I had already make to putting (.end) at the end of the programm in
assembler, but it doesn't work nothing!!

But You have tried to do to work this programm in assembler??
Have you do of the try!! If no, you try to do of TEST, OK??
And send me please, the source right!! Without error bug, Ok??

I wait your good news
Bye
Andrea

By ARTRAG

Enlighted (6280)

Аватар пользователя ARTRAG

27-07-2009, 10:24

Andrea,
try to study this:

http://www.libreriauniversitaria.it/msx-linguaggio-macchina-burkinshaw-tecniche/libro/9788870812527

It was a nice textbook for beginners, and it is in Italian

Страница 1/3
| 2 | 3