I want to play good old normal 4 channel modules in my demo/intro.
In my first little "comeback" on the Amiga scene (http://www.pouet.net/prod.php?which=61596) I wrote everything in pure assembler (like I did back in the 90ies) and reused the same old Noistetracker replay code from Kaktus & Mahoney (C) 1990.
Worked fine, just call mt_init at startup and mt_music every frame and all is OK.
Now I have moved along to a bit more modern way of developing, so I have setup a VBCC+VASM based build system, where my main code is in C and then I call assembler functions where extra speed is needed.
It also works fine, at least until I added music.
The Noisetracker replayer simply does not get along with this new setup, at all.
Somehow just calling mt_init manages to mess up bitplane pointers, and while running mt_music every frame actually plays the music, I get some kind of system error on every exit and have to reboot my (emulated) Amiga.
I have tried looking at the replayer code and see if I can find what is going wrong, but no luck.
Is there any better and easier option to replay 4 channel modules (A500 OCS is my target)?
I looked into P61Play, but that was just way to hard to get going.
1) The code didn't even compile in VASM
2) Looking at page iupon page ofl the strange options I have to setup makes my eyes glaze over. I want to call init, play and that's it.
3) It requires converting the modules from mod to p61.
So, are there any small, quick and easy .mod replayers with source that I can drop in and see if it works better than the Noisetracker replayer?
Oh, for reference, here's the replay code I am trying to use that isn't working anymore:
;ญ NoisetrackerV2.0 FASTreplay ญ
;ญ Uses lev6irq - takes 8 rasterlines ญ
;ญ Do not disable Master irq in $dff09a ญ
;ญ Used registers: d0-d3/a0-a7| =INTENA ญ
;ญ Mahoney & Kaktus - (C) E.A.S. 1990 ญ
mt_lop: dbf d0,mt_lop2
mt_end: moveq #0,d0
mt_sub: sub.w d0,$10(a4)
mt_vib: move.b $3(a4),d0
mt_arp: moveq #0,d0
mt_com: move.w 2(a4),d0
mt_sv2: moveq #0,d0
mt_sp2: tst.w d0
mt_sp3: move.b d0,mt_speed-mt_playvoice(a6)
mt_speed: dc.b 6
mt_counter: dc.b 0
mt_pattpos: dc.w 0
mt_songpos: dc.b 0
mt_break: dc.b 0
mt_dmacon: dc.w 0
mt_voice1: blk.w 13,0
mt_voice2: blk.w 13,0
mt_voice3: blk.w 13,0
mt_voice4: blk.w 13,0
mt_oldirq: dc.l 0
Photon got a tutorial on youtube how to get set playing a mod with the P61 playroutine, the player tutorial
I would also recommend using The Player 6.1, and you can build it with vasm using the devpac compatibility mode, but if you want to get this replayer working then you need to preserve registers D2-D7/A2-A6 on all calls to the player, this is what the Amiga M68K ABI specifies and what VBCC expects from external functions.
You also have to fix mt_init, mt_music, mt_irq1, and mt_irq2 so they take the vector base into account when setting the level 6 interrupt vector.
Ambient: Yes, i saw that there was a tutorial, but that was using AsmOne and an Amiga.native mod-to-p61 converter, I'd like to keep my toolchain on Windows for cross-development.
I think I have the register-preservation correct, all functions are declared with stuff like this:
__regsused("d0/d1/d2/d3/d4/d5/d6/d7/a0/a1/a2/a3/a4/a5/a6") void mod_play();
(The mod-play then does the jsr to mt_music)
Perhaps it is the vector base stuff that you touch upon that is the problem, that bit goes a bit above my head.
But for now I'll do one more attempt to get P61 player compiled and working from VBCC/VASM, as it seems to be the preferred solution.
IIRC regsused is not enough for the compiler to satisfy the calling convention. I just always saved registers d2-d7 and a2-a6 in an ASM function that gets called from C and restored them before rts. That always worked.
noname: thanks for the tip, I did an attempt at that, but it made no difference. Also, I call a lot of my own asm-functions that uses all kind of registers from C, and everything works just fine, it's just that damn tracker-replayer that messes it up.
Well, other than that I have spent many, many hours now trying to get P61play to work. And I have made at least "some" progress.
If I just take the entire sample code from P61Play and put that into a single C function that I call, it works.
So my main program looks like this:
And then the entire assembler source from the P61 replayer example source is in an assembler subroutine that gets called, so it sets up the system, plays music, waits for mouseclick and the brings everything down again, and returns.
However, what I rally want to do is this:
Where setup initializes everything in the system, and bringdown restores the system, and between that I can run my demo code.
This works absolutely fine if I just do my own stuff, but as soon as I add the P61player stuff in the setup (I'm using the CIA-timer method), it doesn't work.
I've tried two methods:
1) Keep the working setup/bringdown code I already have, copy relevant parts to start playing P61 into startup.
2) Try to split the P61 example source code in two and use that as setup/bringdown.
Neither 1 nor 2 works, at all...
If I use method 1, the music doesn't play.
If I use method 2, the music plays but I can't get any graphics on screen, and the system isn't restored properly.
I think the problem is that I have absolutely no clue what is needed in the startup and bringdown parts, and which IRQ this and DMA that and what strange calls to -(somenumber)a6 is the right ones.
Yeah, I guess I really should learn all that, but I am much more interested in actually coding demos, not doing framework/system OS stuff.
I'll give it a few more days of trying, and if I don't have any luck I guess I'll head back to the 8-bit machines, where things generally seem a bit simpler! :)
Alright, some progress!
By modifying the code from P61 example to not use any stack related stuff at all, and remove some stuff from my main code that apparently was touching the IRQ/DMA setup my "split P61 example it into two"-method seems to *almost* work now. Music plays, graphics is shown, and most of the time you can quit to system OK. Sometimes it still seems to hang on exit though.
I wonder if people will be upset if my little demo/intro hangs their Amiga on exit occasionally..? ;)
Well, I take that back, it turns out that the code is completely and utterly fucked, adding and removing lines of code from the end of the program can affect whether the player works or not, eventhough the code is not even running. So it seems like whether things works or not at the moment depends on exactly where certain code happens to end up.
Something (either P61 player, or the code generated by VBCC) seems to be writing somewhere it shouldn't.
I give up.
Does this example work?
Thanks for the support ZEROblue! I couldn't get that to build (it was refering some P61Player.i that I didn't have, and when I removed that I had soem undefined varables).
HOWEVER!!! I *think* I actually have something that works now. By combining some of my "old" setup/bringdown code with the IRQ-setup stuff from the P61player example, it seems to work! Yay!
Here's the end result:
Unfortunately some notes didn't sound *quite* right in P61, but we suspect it's because Mr.Death did the tune in a "Protracker-compatible" mode in a PC-tracker and that in fact did not end up being 100% compatible.
|Angry Retired Bastard
I think it turned out nicely and the different bob patterns provided enough variation to keep it interesting while reading the text. :)
The music *did* sound a bit off, as you mentioned. I'd recommend testing the unpacked mod in protracker during development and then investigate further whenever P61 sounds different.
Confirming. Music sounded out of tune at times (especially at 0:08).
Without having seen the actual mod, it sounds like the 3-command isn't set properly. A higher value would probably fix it. I tried to gather more information in Mr. Death's compomod from Gubbdata, but the error isn't there, or at least not as obvious. A classic 0 command error is there however, when exceeding B-3 with the 00C command, but I digress. The tune(s) are great as well as the intro. Well done!