home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / amiga / programm / 11692 < prev    next >
Encoding:
Text File  |  1992-07-27  |  3.8 KB  |  79 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!destroyer!ubc-cs!unixg.ubc.ca!kakwa.ucs.ualberta.ca!news
  3. From: charro@ee.ualberta.ca (Dan Charrois)
  4. Subject: ProTracker player problems/C->ASM interfacing
  5. Message-ID: <1992Jul27.162310.23614@kakwa.ucs.ualberta.ca>
  6. Sender: news@kakwa.ucs.ualberta.ca
  7. Nntp-Posting-Host: bode.ee.ualberta.ca
  8. Reply-To: charro@ee.ualberta.ca (Dan Charrois)
  9. Organization: University of Alberta Electrical Engineering
  10. Date: Mon, 27 Jul 1992 16:23:10 GMT
  11. Lines: 66
  12.  
  13. I am appealing to anyone who has used the ProTracker player routine
  14. pt-ciaplay.s contained in the PT2.1 archive (and specifically if you have
  15. interfaced it to C code..)  I am having a rather difficult problem.
  16.  
  17. First of all, the assembler I am using is A68k.  The player routine needed to
  18. be modified a bit here and ther to make A68K but after some tweaking and
  19. stuff, I managed to get the code generated by simply compiling and linking
  20. the player routine to be identical to that produced by saving modules as an
  21. executable using that capability in PT2.2a (after having added the same code
  22. to display the song info, etc...).  So I suspect A68K isn't totally to blame.
  23.  
  24. Anyway, I can run the programs created this way and they work just fine.  The
  25. problem comes in my attempts to interface the player to some C code I have.
  26. Since I have never before tried to interface assembly to C on the Amiga before,
  27. I could be missing some crucial step here or there...Basically I put in two
  28. labels in the assembly - _StartSong & _EndSong.  Near the beginning of the code,
  29. I also put a     xdef _StartSong,_EndSong.  I got rid of the routines to check
  30. for a mouse press in the assembly and instead inserted an RTS where they would
  31. normally be.  _EndSong went in to reference the couple lines of code to
  32. cancel the player.  (As far as I can understand it, nothing could be simpler...)
  33.  
  34. My C code has
  35. void __asm far StartSong(void);
  36. void __asm far EndSong(void);
  37.  
  38. up near the top..  I figure I had to use far since the assembly player routine
  39. loads into Chip ram.  (And besides, that was the only way I could appease
  40. Blink... :-)
  41.  
  42. Now, simple C code such as:
  43. void main(void)
  44. {
  45.   StartSong();
  46.   Delay(1000);
  47.   EndSong();
  48. }
  49.  
  50. works just fine - playing the song for a short time and then stopping.
  51. However, if I go and insert a "char a" or something near the top so that
  52. the compiler warns against an unreferenced variable (which shouldn't matter
  53. anyway), the code executes fine - and even executes code after the EndSong()
  54. if there is any, but immediately upon exiting, gurus the Amiga.  Suspecting
  55. there was a stack problem somewhere, I changed the interrupt server to save
  56. D0-D7/A0-A6 on the stack instead of D0-D4/A0-A6 as is in the code (and
  57. retrieved the same too of course once it was complete).  Same problem.
  58. Of course, there could be some data left on the stack or removed from the stack
  59. that shouldn't be (a mistake in the code), but every +(A6) seems to have
  60. a corresponding (A6)-... and besides, when checking the memory situation before
  61. and after running the program, I find it to be identical.
  62. It doesn't seem to be related to EndSong() either.  When I put the code in
  63. an introduction sequence I am writing, it goes fine for awhile, then 
  64. gurus (always at the same place) before getting to the EndSong().  Again, I
  65. don't expect it to be the fault of the C code, since it works just fine without
  66. using the ProTracker player.
  67.  
  68. I'm pulling my hair out with this one!  If anybody can give me some hints on
  69. what may be going wrong, I'd love to hear them.  Who knows - you just may get
  70. mentioned in the credits to my program...:-)
  71.  
  72. Please address all replies to dcharroi@sol.drao.nrc.ca - I don't read the
  73. nets as often as I should.  Thanks a lot!
  74.  
  75. Dan
  76. -- 
  77. Dan Charrois - University of Alberta
  78. INTERNET:= dcharroi@sol.drao.nrc.ca       charro@bode.ee.ualberta.ca 
  79.