krell@xanth.cs.odu.edu (Mike Krell) (01/30/89)
I'm trying to write a simple program in Multi-Forth to replace the annoying flash generated by DisplayBeep with an audio bell instead. My idea is to use SetFunction to replace the DisplayBeep jump vector in the Intuition library with one to my own code. SetFunction requires the absolute address of the replacement routine. How do I get this address? Even if I use the FROM.HEAP word to request heap space for my routine, how do I tell Multi-Forth to compile my Forth code at the address returned by FROM.HEAP? Will this approach even work, or should I be thinking along different lines? Thanks in advance for any help. Mike Krell "I may be accused of being confused, krell@xanth.cs.odu.edu but I'm average weight for my height. My philosophy, like color TV, "I can't believe my life is all there in black and white." is happening to me." -- P. Norton M. Python
billk@pnet01.cts.com (Bill W. Kelly) (02/01/89)
krell@xanth.cs.odu.edu (Mike Krell) writes: > > I'm trying to write a simple program in Multi-Forth to replace the >annoying flash generated by DisplayBeep with an audio bell instead. My >idea is to use SetFunction to replace the DisplayBeep jump vector in the >Intuition library with one to my own code. > SetFunction requires the absolute address of the replacement routine. >How do I get this address? Even if I use the FROM.HEAP word to request heap >space for my routine, how do I tell Multi-Forth to compile my Forth code >at the address returned by FROM.HEAP? Will this approach even work, or >should I be thinking along different lines? Ok. First, you can't SetVector() directly to MultiForth code. It would be a real pain to attempt doing this at all, let alone making it reentrant. Here's what I suggest you do: Write a small assembly routine that you give to SetVector() which will simply Signal() your MultiForth task. Your MultiForth task can then worry about playing the sound. I haven't used MultiForth's backward assembler for a while, so here's some example code done in standard "Motorola-style" format: ASM MyBeep move.l _mytask(pc),a1 ;addr of your MultiForth task move.l _mysignal(pc),d0 ;signal your task will be waiting for move.l a6,-(sp) ;save a6 move.l $4,a6 ;get execbase (from abs. addr 4) jsr _LVOSignal(a6) ;signal your task move.l (sp)+,a6 ;restore a6 rts ;return to caller _mytask: ds.l 1 _mysignal:ds.l 1 ;storage space for task and signal END-CODE Basically, you will need to set the contents of _mytask to the address of your MultiForth task. (You can get the address with FindTask(0).) Then you need to call AllocSignal() to get a signal and place a copy of the signal you've allocated into _mysignal. Now you can use ['] MyBeep to get the address of your new DisplayBeep() routine and give it to SetFunction(). Having done this, your MultiForth task simply needs to Wait() for MyBeep to Signal() it. Then your MultiForth task can send a message to the audio.device requesting it to play a sound. Obviously, you will have to translate MyBeep into MultiForth's backward assembler format. Note: the values for _LVOSignal and _LVODisplayBeep (the latter is needed for the call to SetFunction()) can be found in the back of the Exec manual. In case your manuals don't have the offsets (my old manuals don't) I'll list them here: $ febc Constant _LVOSignal \ exec.library function $ ffa0 Constant _LVODisplayBeep \ intuition.library function This ought to do it. If you have any questions, feel free to send me email. Good Luck, Bill -- Bill W. Kelly billk@pnet01.cts.com {nosc ucsd hplabs!hp-sdd}!crash!pnet01!billk crash!pnet01!billk@nosc.mil