Hi folks
For the sake of the musicians in my crew I wanted to implement the AHX replayer
to give a little more of a flexible environment.
So I fetched the AHX 2.3.3 version off the intarwebz and tried to make it fit with my
startup code - which of course didn't succeed because otherwise I wouldn't be writing this lines right now ;)
It pretty much seems to boil down to the "system killer" and level 6 interrupt matter, or at least that's what I
think it is.
I fitted the little replayer example that Dexter included to my working path and it ran just fine.
But this doesn't kill the system let alone resets the interrupt and DMA registers, 'n shit.
The replayer only comes as a binary and an include with a bunch of offsets to jump on, as you may all know.
I tried to adapt the CIA- interrupt for the system-killer-setting in the P61 replayer but it was not of any use.
The program just freezes.
I'm now at a point with the example, expanded with the startup/restore code I use, where I either just have
to set the right bits in the right registers or must establish an own interrupt which the AHX replayer can handle.
Dexter said something in the Documentation (which is rather slim) of "NO RTE !!".
So the situation looks as follows:
INTENASET = %1100000000000000
DMASET = %1000001111000000
incdir "sources:"
include "AHX/AHX-Offsets.I"
section Dexter\Abyss_rulez,Code
Start
movem.l d1-d7/a0-a6,-(sp)
; HERE MY STARTUP COMMENCES
move.l $4.w,a6
jsr -132(a6)
moveq #0,d0
moveq #0,d0
lea libname(pc),a1 ;name for gfx.lib
jsr -$228(a6) ;LVO_OpenLibrary()
beq.w error
move.l d0,a6
move.l a6,gfxbase
move.l 34(a6),Actiview ; Get active viewport
sub.l a1,a1 ; Find current task
jsr -222(a6) ; LoadView()
jsr -270(a6) ; WaitTOF()
jsr -270(a6) ; there must be at least 2 WaitTOFs
move.l $26(a6),OldCopper1 ; Store old CL 1
move.l $32(a6),OldCopper2 ; Store old CL 2
lea $dff000,a6
move.w $010(a6),adkbits ; Store old ADKCON
move.w $01c(a6),intbits ; Store old INTENA
move.w $002(a6),dmabits ; Store old DMA
; FROM HERE THE PROBLEMS SEEM TO START
; BECAUSE IN THE FOLLOWING LINES THE DMA & INTENA & INTREQ are being reset
move.w #$7fff,d0
move.w d0,$09a(a6)
move.w d0,$096(a6) ;clear dmacon
move.w d0,$09c(a6) ;clear interrupt req
;
;switch ON the DMA and Interrupt settings prepared above
;
move.w #INTENASET,$09a(a6)
move.w #DMASET,$096(a6)
; THIS IS PRETTY MUCH THE AHX EXAMPLE CODE SNIPPLET
.InitCIA
lea ahxCIAInterrupt,a0
moveq #0,d0
jsr ahxReplayer+ahxInitCIA
tst d0
bne .ahxInitFailed
.InitPlayer
sub.l a0,a0 ;auto-allocate public (fast)
sub.l a1,a1 ;auto-allocate chip
moveq #0,d0 ;load waves from hd if possible
moveq #0,d1
jsr ahxReplayer+ahxInitPlayer
;check d0=result normally here...
.InitModule
lea ahxMyModule,a0 ;module
jsr ahxReplayer+ahxInitModule
;check d0=result normally here...
.InitSubSong
moveq #0,d0 ;Subsong #0 = Mainsong
moveq #0,d1 ;Play immediately
jsr ahxReplayer+ahxInitSubSong
.ahxLetHimPlay
btst #6,$bfe001 ;not so system-friendly, i know!
bne.b .ahxLetHimPlay
.StopSong
jsr ahxReplayer+ahxStopSong
.KillPlayer
jsr ahxReplayer+ahxKillPlayer ;don't forget!
.RemoveCIA
jsr ahxReplayer+ahxKillCIA ;don't forget!
.ahxInitFailed
; AND HERE WE RESTORE THE WHOLE SH'BANG
move.w #$8000,d0 ;$8000 for the register switches
or.w d0,intbits ;set/clr bits in storef sysregs to 1
or.w d0,dmabits
or.w d0,adkbits
subq.w #1,d0 ;=$7fff
move.w d0,$09a(a6) ; Clear all INT bits
move.w d0,$096(a6) ;clear dma
move.w d0,$09c(a6) ;clear int-request
move.w #$0,$88(a6) ;touch the COPJMP1
move.w intbits(pc),$09a(a6) ; Restore INTENA
move.w dmabits(pc),$096(a6) ; Restore DMAcon
move.w adkbits(pc),$09e(a6) ; Restore ADKcon
move.l OldCopper1(pc),$80(a6) ; Restore old CL 1
move.l OldCopper2(pc),$84(a6) ; Restore old CL 2
move.l gfxbase(pc),a6
move.l Actiview(pc),a1 ; restore old viewport
jsr -222(a6) ; LoadView()
jsr -270(a6) ; WaitTOF
jsr -270(a6)
move.l $4.w,a6
move.l gfxbase(pc),a1
jsr -$19e(a6) ; LVO_CloseLibrary()
jsr -138(a6) ; LVO_Permit()
moveq #0,d0
; THIS TWO LINES WERE THE ORIGINAL EXAMPLE PROGRAM EXIT
movem.l (sp)+,d1-d7/a0-a6
RTS
error:
move.l $4.w,a6
jsr -138(a6)
moveq #0,d0
movem.l (sp)+,d1-d7/a0-a6
rts
cnop 0,4
;syspointers
spr dc.l 0
Actiview: dc.l 0
OldCopper1: dc.l 0
OldCopper2: dc.l 0
VBRSave: dc.l 0
memadr: dc.l 0
adkbits: dc.w 0
intbits: dc.w 0
dmabits: dc.w 0
storyboardCtrl: dc.b 0,0
gfxbase: dc.l 0
dosbase: dc.l 0
dosname: dc.b "dos.library",0,0
libname: dc.b "graphics.library",0
cnop 0,4
; THAT'S THE INTERRUPT HANDLER THAT CAME WITH THE EXAMPLE
ahxCIAInterrupt
move #0,$dff180
jsr ahxReplayer+ahxInterrupt
move #$aaa,$dff180
RTS
Section Pink\Abyss_rulez,Data
ahxReplayer IncBIN "AHX/Players/AHX-Replayer000.BIN"
ahxMyModule IncBIN "msx_arc/AHX.AgonyEnd"
The basic question is just this:
How the heck do I either set the right bits to make the out-of-the-box AHX calls work in a system killer
environment OR what do I need to do, to play a freakin' ultra neat sounding AHX chiptune in my intros
without the bitch dying on me when the replayer tries to initiate its CIA-interrupt ? >:(
Happy season and tasty Straf-Stollen :D