[comp.sys.acorn] Module is currently active

hughesmp@vax1.tcd.ie (05/24/91)

Months ago I wrote a silly version of Tetris for the Arc that mono-tasks...
Recently, in the midst of exams, I decided to make it Desktop-friendly, ie
when you quit, it returns to the Desktop fine. It has music, and hence some
voice modules, but instead of loading these into RMA, they are linked in
from RAM (OS_Module 10)... Before returning to the Desktop, I naturally
enough have to remove them from the module list (OS_Module 4). The problem
I found was that the last one won't die (Module is currently active).
After several sleepless nights, I worked out the problem...

If you *RUN a program, which consequently loads in a module off disk, over
the start of itself, and links the module into the chain of modules, leaving
it in RAM, the module can't be killed until the program has terminated, or
another program has been *RUN.

As an example:

1 DIM code 131072:FOR pass=0TO2STEP2:P%=&A000+(len 'mod' -4):[OPT pass
2 .program
3 ADR 0,loadmod:SWI "XOS_CLI"                          \Load module
  \ The module overwrites the first instruction.
4 MOV 0,#10:MOV 1,#&A000:ADD 1,1,#4:SWI "XOS_Module"   \Link in module
5 MOV 0,#4:ADR 1,name:SWI "OS_Module"                  \Kill module
  \ The module is currently active here.
6 MOVS15,14:.name:EQUS "Thunk":DCB 13:ALIGN            \Module name
7 .loadmod:EQUS "LOAD mod A000":DCB 13:ALIGN
8 ]NEXT
9 OSCLI"SAVE yoke "+STR$~program+" "+STR$~P%

The file 'mod' consists of one word, being the length of the module, and
then the module itself, a sound module as an example.

Typing in '*yoke' returns the error 'Module is currently active' - at
the * prompt however, after the program has terminated, it is possible
to kill the module by hand. The module obviously isn't in use.
Just a plain old *RMKILL Thunk put in an obey script, after *<program>
works, in that it kills the module when the program has terminated, but
this is useless for a semi-m'tasking program.

I don't know if the same effect is found by loading other than a voice
module, or loading it over the end, as opposed to the beginning, but
owing to memory restrictions, at least one module is going to overwrite
the code. Presumably the error occurs, because *file somehow says that
the word (or more?) at the execution (load?) address of the program, is
currently active... How? Why? How do I stop it? Is it an odd voice
module I have? (Generated by Armadeus if I recall correctly)...

The only way around it I have found, is to *RUN another file, after
adding the modules in, which is 0 length, but has an execution address
further on in my code, which is icky.

Any help / abuse greatly appreciated.

I'll probably post it to c.b.a. or the Newcastle info-server soon, but
I haven't yet received any reply from either of the <x>@acorn places,
presumable Alan's busy, and I don't want to post it over, if nothing's
getting through.

Thanx,
 Merlin.
--SICK--
You suffer... But why?