🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #11288

Re: Help wanted on SetFunction in Multi-Forth

#11288
From: Bill W. Kelly
Date: Wed, 01 Feb 1989 06:16
67 lines
3548 bytes
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
Technical Details
Message-ID: <3798@crash.cts.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!nrl-cmf!ukma!gatech!hubcap!ncrcae!ncr-sd!crash!pnet01!billk

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!nrl-cmf!ukma!gatech!hubcap!ncrcae!ncr-sd!crash!pnet01!billk
From: billk@pnet01.cts.com (Bill W. Kelly)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Help wanted on SetFunction in Multi-Forth
Message-ID: <3798@crash.cts.com>
Date: 1 Feb 89 06:16:24 GMT
Sender: bblue@crash.cts.com
Organization: People-Net [pnet01], El Cajon CA
Lines: 67