>> The point is that (a) the MIDI OUT interrupt is quite difficult to 
catch
>> if there are line and frame interrupts going on as well because you 
coul
>> easily miss one while the interrupts are disabled; and (b) you don't 
need
>> that flag because in(248) already contains one (bit 1).
>>
>> imc
>>
>
>Thanks Ian, you beat be to it there.
>
>My interrupt handler works like this at the minute...

Hmmm... personally, I'd do it like this:

int.handler:  PUSH AF
              IN A,(INTSTAT)
              BIT 2,A ; midi out bit? can't remember
              CALL NZ,midiout
              RRA
              CALL NC,lineint

              BIT 2,A ; now check for frame interrupt...
              EI
              JP NZ,exitint

              ; we've done all the short interrupts, so re-enable
frame:        ; this is more longwinded and complicated, so...
frameflag:    LD A,0x00 ; check if we're already in frame handler
              OR A ;if so, early abort
              JP NZ,exitallint
              CPL
              LD (frameflag:d),A
              ; push everything we need onto the stack, and do our
              ; frame interrupt stuff
              ;... and then clear frameint flag
              DI ;just in case... we don't want to nest, so make sure
                 ;that we have a clean stack - this way, interrupts
                 ;won't come back until AFTER the RET at the end of
                 ;the routine
              XOR A
              LD (frameflag:d),A
exitint:      POP AF
              EI ;inexpensive safety check
              RET

midiout:      PUSH AF
              XOR A
              LD (outmididata:d),A ;reset the "wait" flag.
exitmidi:     POP AF
              RET
              
line:         ; only do simple stuff here...
              PUSH AF
              ;blah
              POP AF
              RET

; Return NZ if not ready to output data version

outmididatanz: LD A,(outmididata:d)
               OR A
               RET NZ

               JR outmidi

; Spinlock version of midi out routine

outmididata:  LD A,0x00
              OR A
              JP NZ,outmididata ;data already queued, so spin round
              
outmidi:      CPL
              LD (outmididata:d),A  
              LD A,E
              OUT (MIDIOUT),A
              RET

I don't have my tech manual in the office, so I can't look up that flag; 
however, this routine could be easily modified to use it.

You could, of course, also build your own FIFO for the MIDI OUT 
interrupt to use. It's similar logic - you have to make sure that your 
starting conditions are correct though.

Also, the frame interrupt trick is very handy - that way you can do all 
your key checking every frame (which is necessary for good key response 
- 25Hz gives dropped keys, at least for me), and mouse checks, etc etc 
without dropping other interrupts. I used this in TERMITE, and it works 
decidedly well - even at 57,600KHz.

Simon

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

Reply via email to