FAQ  •  Register  •  Login

Sound effects?

<<

LCD

Posts: 596

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Fri Jul 15, 2011 7:13 am

Re: Sound effects?

LTee wrote:Hmm... or maybe not. Something's not *quite* right still. The music will play once, but it doesn't exit properly at the end of the tune (or if you press a key) - the Spectrum locks up rather than ending play gracefully.

I'll paste what I've been messing around with, maybe someone else can see what the issue is:

I would say, the issue is the ASM data and the RET from ASM, before PLAY_MUSIC label.
this is a procedure, so RET would not return back to BASIC but to nirvana, and the ASM datas at the end would prevent correct returning further. I faced the same problem. The solution looks so:
  Code:
Procedure
  ASM Routine (without RET), JP to [ASM Label Ending] replaces RET
  [ASM label data]:
    All Data
  [ASM Label Ending]:
    Again no RET! This is empty or ending code
END Procedure
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

boriel

Site Admin

Posts: 1463

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Fri Jul 15, 2011 7:54 am

Re: Sound effects?

LCD wrote:I would say, the issue is the ASM data and the RET from ASM, before PLAY_MUSIC label.
this is a procedure, so RET would not return back to BASIC but to nirvana, and the ASM datas at the end would prevent correct returning further. I faced the same problem. The solution looks so:

That's right :!: However, it's possible to use directly RET by telling the compiler this is a "non standard procedure nor function". Standard procedure and functions deals with the stack to take parameters (as many as the user wants) and local variables, and need to clean up the stack upon return or the program will crash.

If you want it to make completely "ASM compatible" use FASTCALL, but then you will need to deal yourself with parameters and return value. Since this is a procedure with NO parameters and NO return value, there's nothing to do, just pure ASM! :P

  Code:
Procedure FASTCALL ProcedureName
  ;;  ASM Routine (without RET), JP to [ASM Label Ending] replaces RET
  You can use RET here now
  [ASM label data]:
    All Data
  [ASM Label Ending]:
    You can use RET here, but it's needless since there is an implicit RET
    at the END Procedure
END Procedure
<<

LCD

Posts: 596

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Fri Jul 15, 2011 8:27 pm

Re: Sound effects?

Okay, thats true, but the posted code cannot use the implicit RET at the end of procedure in present form, because it has ASM Data before the end, and the real RET is only few bytes after start. It needs more modifications to use fastcall, but if the routines are written with fastcall in mind, it will work much better.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

LTee

Posts: 153

Joined: Tue Jul 07, 2009 2:54 pm

Post Thu Jul 21, 2011 8:30 am

Re: Sound effects?

oblo wrote:Hi all

LTee, How a song created with Beepola can be integrated in ZX Basic? I don't know how to handle the .bbsong format in Basic.

Thanks and regards

Hi oblo,

You don't have to handle the bbsong format yourself, you can get Beepola to export the song and a player as executable code. On Beepola's 'tools' menu, select 'Compile Song' and you can export in a variety of formats that you can use elsewhere. I compile to a code block only .tap file using an address high in memory (away from ZX Basic code) and then call it with RANDOMIZE USR xxxxx from within my game code (although there are a couple of quirks at the minute, see http://www.boriel.com/forum/help-support/calling-non-zxb-code-with-randomize-usr-t633.html).

Hope that helps!
<<

LTee

Posts: 153

Joined: Tue Jul 07, 2009 2:54 pm

Post Thu Jul 21, 2011 8:31 am

Re: Sound effects?

boriel/LCD - interesting stuff. Maybe I can make that way work after all? I think I'll go back to running a few experiments, as it's nicer to do it this way than having to hack .tap files together at the end. Thanks for the info!
<<

LCD

Posts: 596

Joined: Fri Feb 13, 2009 3:11 pm

Location: Vienna, Austria

Post Thu Jul 21, 2011 1:11 pm

Re: Sound effects?

LTee wrote:boriel/LCD - interesting stuff. Maybe I can make that way work after all? I think I'll go back to running a few experiments, as it's nicer to do it this way than having to hack .tap files together at the end. Thanks for the info!

Surely it can be done. The first version of ODINs proportional font routine was crashing too on return, so the solution was to rearrange add some JP and labels to jump to the end of procedure after all the data. Nothing is impossible.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
<<

oblo

Posts: 60

Joined: Tue Jul 12, 2011 5:23 pm

Post Sat Jul 23, 2011 12:56 pm

Re: Sound effects?

LTee wrote:
oblo wrote:Hi all

LTee, How a song created with Beepola can be integrated in ZX Basic? I don't know how to handle the .bbsong format in Basic.

Thanks and regards

Hi oblo,

You don't have to handle the bbsong format yourself, you can get Beepola to export the song and a player as executable code. On Beepola's 'tools' menu, select 'Compile Song' and you can export in a variety of formats that you can use elsewhere. I compile to a code block only .tap file using an address high in memory (away from ZX Basic code) and then call it with RANDOMIZE USR xxxxx from within my game code (although there are a couple of quirks at the minute, see http://www.boriel.com/forum/help-support/calling-non-zxb-code-with-randomize-usr-t633.html).

Hope that helps!



Thanks, good post about it :) I was thinking to define a bi-dimensional array, one for the pitch and the other for with the duration; then, put a BEEP x,y: x+1:y+1 in every game loop, but it looks like your solution is more elegant :)

Cheers
Previous

Return to How-To & Tutorials

Who is online

Users browsing this forum: No registered users and 0 guests

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO