Home | Contents | KwikPik |
Issue 19 | "Grid Bug" |
Issue 20 | "More Interruptions" |
J U S T A T I C K !
It may be rude to interrupt but it's certainly dead easy now, 'cos Toni Baker's back with a program that lets you have up to sixteen interrupt routines running at once. You'll wonder how you ever managed before! | ||
---|---|---|
You may have noticed just how many
routines there are these days that are
interrupt driven - that's to say, routines
that make use of the Spectrum's
interrupts. They're run automatically
once every TV frame (50 times per
second) and they make it quite possible
for the Spectrum to appear to be doing
two things at once. The big drawback is that they're all pretty exclusive. If you've got one running it's very difficult to get another one running at the same time. You can have, for instance, a real time clock or moving sprites or continuous music - all during the running of normal Basic, |
of course, but you can't have more than
one at once - or, at least, it's more than
a little tricky. MANAGEMENT TECHNIQUESThis program provides the solution - it's called an Interrupt Manager and with it you can have up to sixteen user- defined interrupt routines running together. One routine, say, runs a clock, another plays music and both could run together quite happily without disturbing normal Basic or machine code.The Interrupt Manager not only knots the separate interrupt routines |
together but it can also save space by
making each interrupt routine a little
simpler. For instance, it's normally
necessary in an interrupt routine to
preserve all the registers. The manager
looks after that for you so you can
corrupt the registers as much as you
like. You'll only need to take special
action if you want to make use of the
alternative registers as well. Another point that's often glossed over is that many interrupt routines need to take very special precautions when calling routines in the ROM. If you don't, and you have Interface 1 attached, then the Spectrum's very |
|
|
![]() | ||
likely to crash if an interrupt occurs whilst the Shadow ROM's paged in. The Interrupt Manager program avoids this trap - at each stage it'll determine which ROM is current, which ROM is needed, and it'll switch between the two as desired. In other words, the |
individual interrupt routines don't have
to concern themselves with worrying
about ROMs - the Manager will take
care of it all. Also, interrupt routines usually require a RST 38 instruction. This ensures that the keyboard is properly | scanned for Basic. Not so with the Manager though. RST 38 is automatic, and individual routines needn't concern themselves with it. Still, you can deactivate this facility if, for example, you want to modify the keyboard scan or do without it altogether. |
BRIEF ENCOUNTERSOK, so now you've got an Interrupt Manager, what are you going to do with it? Just to get you started here's a selection of simple routines that have been compiled to show you how easily the Manager can be used. If you want a demo, type them into your Assembler at memory location 61800. Once you've got the Manager and the demo program in memory you're ready to go. As you'll see the first routine randomly changes the border colour - to make it work, type:POKE TABLE+(INTNO*5)+1, LOW BYTE POKE TABLE+(INTNO*5)+2, HIGH BYTE This places the address of the routine on the Manager table - in this case the high byte is 241 (F1h) and the low byte is 104 (68h). Now type: POKE TABLE+(INTNO*5)+4, COUNTER POKE TABLE+(INTNO*5)+5, PRIORITY If the counter and the priority both hold 10, this |
means that the routine will be called every ten
50ths of a second - of course, you can change
this as you please. Now (finally) type:
POKE TABLE+(INTNO*5)+3, FLAGS The flags hold the info that tells the Manager which of the two ROMs to access if they're needed, or even if the routine's to be called at all. In this case the flags should be 1. In all these examples TABLE refers to the start location in memory of the Manager table which here is 61543. Now number your routine according to where on the table it's to appear - the number you assign it is, of course, INTNO. To use the other four routines, all you've got to do is change the values for the low and high bytes, the counter, the priority and the flag. The last demo routine is the only one where the choice of ROM is important as it uses the Spectrum's, so make sure you have the correct value in FLAGS when you're mucking about with it. Finally, if you still can't get the demo to work, change the value in the master Flag at 61543 to 2. | |||||||||||
|
|
Home | Contents | KwikPik |