Home » CEEFAX disks » telesoftware5.adl » 12-03-88/T\OSB17
12-03-88/T\OSB17
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » CEEFAX disks » telesoftware5.adl |
Filename: | 12-03-88/T\OSB17 |
Read OK: | ✔ |
File size: | 1CF7 bytes |
Load address: | 0000 |
Exec address: | 0000 |
File contents
OSBITS - An Exploration of the BBC Micro at Machine Level By Programmer .......................................................... Part 17: Events Here you, are reading a module of OSbits, when the telephone rings. You stop reading, answer the 'phone and talk to whoever is ringing. When you have finished you put the 'phone down and start reading again. Reading was your main, or foreground task, but it was interrupted by the telephone. The ringing of the 'phone was an interrupt and by answering the 'phone you serviced that interrupt. When you had finished you returned to your foreground task. One of the strengths of the 6502 microprocessor is its speedy response to interrupts. Essentially pieces of hardware interrupt the 6502 and the OS has a built in pecking order for these devices so it knows in which order to respond. When you press a key you generate an interrupt, when the TV scan finishes a field and flies back to start another picture an interrupt is generated. The OS interrupts every 10 milliseconds to update system clocks. Although they are essentially the same, the BBC Micro OS distinguishes between Events and Interrupts. Events are interrupts that have been 'packaged' to make them a little easier to use, so we'll start there and go on interrupts next time. The vector intercept program in the last module would run alongside any program. Whenever a character was sent to the VDU drivers the intercept program would spring into action. Similarly when an event occurs the 6502 jumps down the event vector to find whatever code you might have put there. The 'event' that the intercept program responded to was caused by the software but the principle is the same. An event has to be enabled by using OSBYTE (*FX) 14 and can be disabled by using OSBYTE 13. These are the events and their numbers. 0 Output buffer becomes empty 1 Input buffer becomes full The buffer number (which is as selected by OSBYTE 21) will be in the X register. Event 1 is generated when the OS fails to put a character in a buffer and the Y register will hold that character. 2 A character enters the input buffer This is effectively caused by a key being pressed on the keyboard. 3 A to D conversion finished This is caused by a A to D conversion being finished on any channel that is enabled and the channel just converted will be represented by the number in the Y register. 4 Start of TV field blanking interval The beam of the TV picture generated by the micro scans the whole screen twice for each frame. Each frame is made up of two fields, each of 1/50th second duration. This event is generated whenever the beam leaves the bottom of the screen and flies back to the top, i.e. once per field, 50 times a second. OSBYTE 19 forces the micro to wait for the flyback to start. 5 Interval timer crosses zero This is a timer, not the TIME timer, read or set by OSWORD 3 and 4. As the timer increases by one 100 times a second you could use this event to print a background clock on the screen. 6 ESCAPE detected When this event is enabled, the ESCAPE key has no effect from BASIC or whatever language you are using. The ESCAPE could have come down the RS423 if that was enabled. 7 RS423 error detected The serial system has generated an error. 8 Network event Can only happen when Econet is attached to your machine. 9 User event Set aside for the user, who could also use Event 8 if no Econet was present. If one of these events is enabled with OSBYTE 14 (A=14 X=event number) then when the event itself occurs the micro will JMP (evntv), i.e. it will jump to the address held in the event vector &220 (and &221). Unless you wish to chain on down the event vector after your interception (and this should not be neccessary) you must exit from your code with an RTS, since before execution jumped down the vector the OS set up the stack and memory in a way that expects this. In effect this means that the OS expects a subroutine at the address in the event vector. There is a 'ReTurn from Interrupt' mnemonic that might at first sight seem appropriate, since events are actually a form of interrupt. However the OS has set up the event in a special way and you must RTS from an event, not RTI. The address in the vector should be pointing to your event routine. As it enters your routine the accumulator is holding the event number. Your routine must save all the registers (P A X and Y) to the stack, and when you have finished you should restore the registers before you exit. The interrupt disable flag will be set by the OS automatically before the micro reaches your code and you should not enable interrupts. By the same token you should not use any OS routine that enables interrupts. This means you can use OSBYTE and some OSWORD calls during an event routine but not others like OSCLI, OSRDCH and OSWRCH. If you are absolutely certain that yours is the only event routine then you should RTS rather than going down the original vector. Your event routine will probably be expecting only one event, so you should check the value in A to see if the event that has caused the jump to your routine is the one you expect. If it is not then you should jump to the original contents of the vector. The program in this module uses the keyboard event (number 2) to make a click when a key is pressed. The code is assembled in the I/O processor only at &A00 as before. Let's go through the program. The setting up routine is from line 210 to line 420. In it the vectors are changed (if they haven't been changed already) with the old vector contents being stored in 'old_evntv'. OSWORD 8 is then used to set up a suitable envelope from the parameter list in lines 760 to 890. The setting up procedure for OSWORD was given in module 5. The actual event code is very simple. It lies between lines 440 and 690. First we check that this is event 2 and if not we jump out straight away down the old vector. (If you are feeling devious you could remove this trap and see what happens when you enable other events with *FX 14.) All registers are saved onto the stack, including the status register (very important). The decimal flag is cleared just in case the foreground routine was in decimal mode. (It would return to decimal mode since the status register will be restored at the end of the routine.) Then OSWORD 7 is called which makes the sound using the envelope (number 1) set in the set-up code. The registers are restored and the code jumps down the old vector. You can not assume that no one else would use event 2 just because you have. If you want to save the routine to disk then copy the *SAVE line across. This has to run in the I/O processor so you will not be allowed to run this assembly in a second processor and the disc saving command puts the address as &FFFF0A00. No OS calls are allowed inside events in the second processor but, as with the vector program, this will run in the I/O processor no-matter where your foreground program is. The BASIC program shell enables the event so you should hear the key clicks. To disable them enter *FX13,2. If you later want to run in the routine from disc then typing *kclick followed by *FX 14,2 will do it. In the next module we progress onto interrupts proper and I'll show you how to write a mouse driver.
00000000 4f 53 42 49 54 53 20 2d 20 41 6e 20 45 78 70 6c |OSBITS - An Expl| 00000010 6f 72 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 42 |oration of the B| 00000020 42 43 20 4d 69 63 72 6f 20 61 74 20 4d 61 63 68 |BC Micro at Mach| 00000030 69 6e 65 20 4c 65 76 65 6c 0d 0d 42 79 20 50 72 |ine Level..By Pr| 00000040 6f 67 72 61 6d 6d 65 72 0d 0d 2e 2e 2e 2e 2e 2e |ogrammer........| 00000050 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e 2e |................| * 00000080 2e 2e 2e 2e 0d 0d 0d 50 61 72 74 20 31 37 3a 20 |.......Part 17: | 00000090 45 76 65 6e 74 73 0d 0d 0d 48 65 72 65 20 79 6f |Events...Here yo| 000000a0 75 2c 20 61 72 65 20 72 65 61 64 69 6e 67 20 61 |u, are reading a| 000000b0 20 6d 6f 64 75 6c 65 20 6f 66 20 4f 53 62 69 74 | module of OSbit| 000000c0 73 2c 20 77 68 65 6e 20 74 68 65 20 74 65 6c 65 |s, when the tele| 000000d0 70 68 6f 6e 65 0d 72 69 6e 67 73 2e 20 20 59 6f |phone.rings. Yo| 000000e0 75 20 73 74 6f 70 20 72 65 61 64 69 6e 67 2c 20 |u stop reading, | 000000f0 61 6e 73 77 65 72 20 74 68 65 20 27 70 68 6f 6e |answer the 'phon| 00000100 65 20 61 6e 64 20 74 61 6c 6b 20 74 6f 0d 77 68 |e and talk to.wh| 00000110 6f 65 76 65 72 20 69 73 20 72 69 6e 67 69 6e 67 |oever is ringing| 00000120 2e 20 20 57 68 65 6e 20 79 6f 75 20 68 61 76 65 |. When you have| 00000130 20 66 69 6e 69 73 68 65 64 20 79 6f 75 20 70 75 | finished you pu| 00000140 74 20 74 68 65 0d 27 70 68 6f 6e 65 20 64 6f 77 |t the.'phone dow| 00000150 6e 20 61 6e 64 20 73 74 61 72 74 20 72 65 61 64 |n and start read| 00000160 69 6e 67 20 61 67 61 69 6e 2e 0d 0d 52 65 61 64 |ing again...Read| 00000170 69 6e 67 20 77 61 73 20 79 6f 75 72 20 6d 61 69 |ing was your mai| 00000180 6e 2c 20 6f 72 20 66 6f 72 65 67 72 6f 75 6e 64 |n, or foreground| 00000190 20 74 61 73 6b 2c 20 62 75 74 20 69 74 20 77 61 | task, but it wa| 000001a0 73 0d 69 6e 74 65 72 72 75 70 74 65 64 20 62 79 |s.interrupted by| 000001b0 20 74 68 65 20 74 65 6c 65 70 68 6f 6e 65 2e 20 | the telephone. | 000001c0 20 54 68 65 20 72 69 6e 67 69 6e 67 20 6f 66 20 | The ringing of | 000001d0 74 68 65 20 27 70 68 6f 6e 65 20 77 61 73 0d 61 |the 'phone was.a| 000001e0 6e 20 69 6e 74 65 72 72 75 70 74 20 61 6e 64 20 |n interrupt and | 000001f0 62 79 20 61 6e 73 77 65 72 69 6e 67 20 74 68 65 |by answering the| 00000200 20 27 70 68 6f 6e 65 20 79 6f 75 20 73 65 72 76 | 'phone you serv| 00000210 69 63 65 64 20 74 68 61 74 0d 69 6e 74 65 72 72 |iced that.interr| 00000220 75 70 74 2e 20 20 57 68 65 6e 20 79 6f 75 20 68 |upt. When you h| 00000230 61 64 20 66 69 6e 69 73 68 65 64 20 79 6f 75 20 |ad finished you | 00000240 72 65 74 75 72 6e 65 64 20 74 6f 20 79 6f 75 72 |returned to your| 00000250 0d 66 6f 72 65 67 72 6f 75 6e 64 20 74 61 73 6b |.foreground task| 00000260 2e 0d 0d 4f 6e 65 20 6f 66 20 74 68 65 20 73 74 |...One of the st| 00000270 72 65 6e 67 74 68 73 20 6f 66 20 74 68 65 20 36 |rengths of the 6| 00000280 35 30 32 20 6d 69 63 72 6f 70 72 6f 63 65 73 73 |502 microprocess| 00000290 6f 72 20 69 73 20 69 74 73 0d 73 70 65 65 64 79 |or is its.speedy| 000002a0 20 72 65 73 70 6f 6e 73 65 20 74 6f 20 69 6e 74 | response to int| 000002b0 65 72 72 75 70 74 73 2e 20 20 45 73 73 65 6e 74 |errupts. Essent| 000002c0 69 61 6c 6c 79 20 70 69 65 63 65 73 20 6f 66 0d |ially pieces of.| 000002d0 68 61 72 64 77 61 72 65 20 69 6e 74 65 72 72 75 |hardware interru| 000002e0 70 74 20 74 68 65 20 36 35 30 32 20 61 6e 64 20 |pt the 6502 and | 000002f0 74 68 65 20 4f 53 20 68 61 73 20 61 20 62 75 69 |the OS has a bui| 00000300 6c 74 20 69 6e 0d 70 65 63 6b 69 6e 67 20 6f 72 |lt in.pecking or| 00000310 64 65 72 20 66 6f 72 20 74 68 65 73 65 20 64 65 |der for these de| 00000320 76 69 63 65 73 20 73 6f 20 69 74 20 6b 6e 6f 77 |vices so it know| 00000330 73 20 69 6e 20 77 68 69 63 68 20 6f 72 64 65 72 |s in which order| 00000340 0d 74 6f 20 72 65 73 70 6f 6e 64 2e 20 20 57 68 |.to respond. Wh| 00000350 65 6e 20 79 6f 75 20 70 72 65 73 73 20 61 20 6b |en you press a k| 00000360 65 79 20 79 6f 75 20 67 65 6e 65 72 61 74 65 20 |ey you generate | 00000370 61 6e 20 69 6e 74 65 72 72 75 70 74 2c 0d 77 68 |an interrupt,.wh| 00000380 65 6e 20 74 68 65 20 54 56 20 73 63 61 6e 20 66 |en the TV scan f| 00000390 69 6e 69 73 68 65 73 20 61 20 66 69 65 6c 64 20 |inishes a field | 000003a0 61 6e 64 20 66 6c 69 65 73 20 62 61 63 6b 20 74 |and flies back t| 000003b0 6f 20 73 74 61 72 74 0d 61 6e 6f 74 68 65 72 20 |o start.another | 000003c0 70 69 63 74 75 72 65 20 61 6e 20 69 6e 74 65 72 |picture an inter| 000003d0 72 75 70 74 20 69 73 20 67 65 6e 65 72 61 74 65 |rupt is generate| 000003e0 64 2e 20 20 54 68 65 20 4f 53 0d 69 6e 74 65 72 |d. The OS.inter| 000003f0 72 75 70 74 73 20 65 76 65 72 79 20 31 30 20 6d |rupts every 10 m| 00000400 69 6c 6c 69 73 65 63 6f 6e 64 73 20 74 6f 20 75 |illiseconds to u| 00000410 70 64 61 74 65 20 73 79 73 74 65 6d 20 63 6c 6f |pdate system clo| 00000420 63 6b 73 2e 0d 0d 41 6c 74 68 6f 75 67 68 20 74 |cks...Although t| 00000430 68 65 79 20 61 72 65 20 65 73 73 65 6e 74 69 61 |hey are essentia| 00000440 6c 6c 79 20 74 68 65 20 73 61 6d 65 2c 20 74 68 |lly the same, th| 00000450 65 20 42 42 43 20 4d 69 63 72 6f 20 4f 53 0d 64 |e BBC Micro OS.d| 00000460 69 73 74 69 6e 67 75 69 73 68 65 73 20 62 65 74 |istinguishes bet| 00000470 77 65 65 6e 20 45 76 65 6e 74 73 20 61 6e 64 20 |ween Events and | 00000480 49 6e 74 65 72 72 75 70 74 73 2e 20 20 45 76 65 |Interrupts. Eve| 00000490 6e 74 73 20 61 72 65 0d 69 6e 74 65 72 72 75 70 |nts are.interrup| 000004a0 74 73 20 74 68 61 74 20 68 61 76 65 20 62 65 65 |ts that have bee| 000004b0 6e 20 27 70 61 63 6b 61 67 65 64 27 20 74 6f 20 |n 'packaged' to | 000004c0 6d 61 6b 65 20 74 68 65 6d 20 61 20 6c 69 74 74 |make them a litt| 000004d0 6c 65 0d 65 61 73 69 65 72 20 74 6f 20 75 73 65 |le.easier to use| 000004e0 2c 20 73 6f 20 77 65 27 6c 6c 20 73 74 61 72 74 |, so we'll start| 000004f0 20 74 68 65 72 65 20 61 6e 64 20 67 6f 20 6f 6e | there and go on| 00000500 20 69 6e 74 65 72 72 75 70 74 73 0d 6e 65 78 74 | interrupts.next| 00000510 20 74 69 6d 65 2e 0d 0d 54 68 65 20 76 65 63 74 | time...The vect| 00000520 6f 72 20 69 6e 74 65 72 63 65 70 74 20 70 72 6f |or intercept pro| 00000530 67 72 61 6d 20 69 6e 20 74 68 65 20 6c 61 73 74 |gram in the last| 00000540 20 6d 6f 64 75 6c 65 20 77 6f 75 6c 64 20 72 75 | module would ru| 00000550 6e 0d 61 6c 6f 6e 67 73 69 64 65 20 61 6e 79 20 |n.alongside any | 00000560 70 72 6f 67 72 61 6d 2e 20 20 57 68 65 6e 65 76 |program. Whenev| 00000570 65 72 20 61 20 63 68 61 72 61 63 74 65 72 20 77 |er a character w| 00000580 61 73 20 73 65 6e 74 20 74 6f 20 74 68 65 0d 56 |as sent to the.V| 00000590 44 55 20 64 72 69 76 65 72 73 20 74 68 65 20 69 |DU drivers the i| 000005a0 6e 74 65 72 63 65 70 74 20 70 72 6f 67 72 61 6d |ntercept program| 000005b0 20 77 6f 75 6c 64 20 73 70 72 69 6e 67 20 69 6e | would spring in| 000005c0 74 6f 20 61 63 74 69 6f 6e 2e 20 0d 53 69 6d 69 |to action. .Simi| 000005d0 6c 61 72 6c 79 20 77 68 65 6e 20 61 6e 20 65 76 |larly when an ev| 000005e0 65 6e 74 20 6f 63 63 75 72 73 20 74 68 65 20 36 |ent occurs the 6| 000005f0 35 30 32 20 6a 75 6d 70 73 20 64 6f 77 6e 20 74 |502 jumps down t| 00000600 68 65 20 65 76 65 6e 74 0d 76 65 63 74 6f 72 20 |he event.vector | 00000610 74 6f 20 66 69 6e 64 20 77 68 61 74 65 76 65 72 |to find whatever| 00000620 20 63 6f 64 65 20 79 6f 75 20 6d 69 67 68 74 20 | code you might | 00000630 68 61 76 65 20 70 75 74 20 74 68 65 72 65 2e 20 |have put there. | 00000640 20 54 68 65 0d 27 65 76 65 6e 74 27 20 74 68 61 | The.'event' tha| 00000650 74 20 74 68 65 20 69 6e 74 65 72 63 65 70 74 20 |t the intercept | 00000660 70 72 6f 67 72 61 6d 20 72 65 73 70 6f 6e 64 65 |program responde| 00000670 64 20 74 6f 20 77 61 73 20 63 61 75 73 65 64 0d |d to was caused.| 00000680 62 79 20 74 68 65 20 73 6f 66 74 77 61 72 65 20 |by the software | 00000690 62 75 74 20 74 68 65 20 70 72 69 6e 63 69 70 6c |but the principl| 000006a0 65 20 69 73 20 74 68 65 20 73 61 6d 65 2e 20 20 |e is the same. | 000006b0 41 6e 20 65 76 65 6e 74 20 68 61 73 0d 74 6f 20 |An event has.to | 000006c0 62 65 20 65 6e 61 62 6c 65 64 20 62 79 20 75 73 |be enabled by us| 000006d0 69 6e 67 20 4f 53 42 59 54 45 20 28 2a 46 58 29 |ing OSBYTE (*FX)| 000006e0 20 31 34 20 61 6e 64 20 63 61 6e 20 62 65 20 64 | 14 and can be d| 000006f0 69 73 61 62 6c 65 64 0d 62 79 20 75 73 69 6e 67 |isabled.by using| 00000700 20 4f 53 42 59 54 45 20 31 33 2e 0d 0d 54 68 65 | OSBYTE 13...The| 00000710 73 65 20 61 72 65 20 74 68 65 20 65 76 65 6e 74 |se are the event| 00000720 73 20 61 6e 64 20 74 68 65 69 72 20 6e 75 6d 62 |s and their numb| 00000730 65 72 73 2e 0d 0d 20 20 20 20 30 20 20 20 4f 75 |ers... 0 Ou| 00000740 74 70 75 74 20 62 75 66 66 65 72 20 62 65 63 6f |tput buffer beco| 00000750 6d 65 73 20 65 6d 70 74 79 0d 20 20 20 20 31 20 |mes empty. 1 | 00000760 20 20 49 6e 70 75 74 20 62 75 66 66 65 72 20 62 | Input buffer b| 00000770 65 63 6f 6d 65 73 20 66 75 6c 6c 0d 0d 54 68 65 |ecomes full..The| 00000780 20 62 75 66 66 65 72 20 6e 75 6d 62 65 72 20 28 | buffer number (| 00000790 77 68 69 63 68 20 69 73 20 61 73 20 73 65 6c 65 |which is as sele| 000007a0 63 74 65 64 20 62 79 20 4f 53 42 59 54 45 20 32 |cted by OSBYTE 2| 000007b0 31 29 20 77 69 6c 6c 0d 62 65 20 69 6e 20 74 68 |1) will.be in th| 000007c0 65 20 58 20 72 65 67 69 73 74 65 72 2e 20 20 45 |e X register. E| 000007d0 76 65 6e 74 20 31 20 69 73 20 67 65 6e 65 72 61 |vent 1 is genera| 000007e0 74 65 64 20 77 68 65 6e 20 74 68 65 20 4f 53 0d |ted when the OS.| 000007f0 66 61 69 6c 73 20 74 6f 20 70 75 74 20 61 20 63 |fails to put a c| 00000800 68 61 72 61 63 74 65 72 20 69 6e 20 61 20 62 75 |haracter in a bu| 00000810 66 66 65 72 20 61 6e 64 20 74 68 65 20 59 20 72 |ffer and the Y r| 00000820 65 67 69 73 74 65 72 20 77 69 6c 6c 0d 68 6f 6c |egister will.hol| 00000830 64 20 74 68 61 74 20 63 68 61 72 61 63 74 65 72 |d that character| 00000840 2e 0d 0d 20 20 20 20 32 20 20 20 41 20 63 68 61 |... 2 A cha| 00000850 72 61 63 74 65 72 20 65 6e 74 65 72 73 20 74 68 |racter enters th| 00000860 65 20 69 6e 70 75 74 20 62 75 66 66 65 72 0d 0d |e input buffer..| 00000870 54 68 69 73 20 69 73 20 65 66 66 65 63 74 69 76 |This is effectiv| 00000880 65 6c 79 20 63 61 75 73 65 64 20 62 79 20 61 20 |ely caused by a | 00000890 6b 65 79 20 62 65 69 6e 67 20 70 72 65 73 73 65 |key being presse| 000008a0 64 20 6f 6e 20 74 68 65 0d 6b 65 79 62 6f 61 72 |d on the.keyboar| 000008b0 64 2e 0d 0d 20 20 20 20 33 20 20 20 41 20 74 6f |d... 3 A to| 000008c0 20 44 20 63 6f 6e 76 65 72 73 69 6f 6e 20 66 69 | D conversion fi| 000008d0 6e 69 73 68 65 64 0d 0d 54 68 69 73 20 69 73 20 |nished..This is | 000008e0 63 61 75 73 65 64 20 62 79 20 61 20 41 20 74 6f |caused by a A to| 000008f0 20 44 20 63 6f 6e 76 65 72 73 69 6f 6e 20 62 65 | D conversion be| 00000900 69 6e 67 20 66 69 6e 69 73 68 65 64 20 6f 6e 20 |ing finished on | 00000910 61 6e 79 0d 63 68 61 6e 6e 65 6c 20 74 68 61 74 |any.channel that| 00000920 20 69 73 20 65 6e 61 62 6c 65 64 20 61 6e 64 20 | is enabled and | 00000930 74 68 65 20 63 68 61 6e 6e 65 6c 20 6a 75 73 74 |the channel just| 00000940 20 63 6f 6e 76 65 72 74 65 64 20 77 69 6c 6c 0d | converted will.| 00000950 62 65 20 72 65 70 72 65 73 65 6e 74 65 64 20 62 |be represented b| 00000960 79 20 74 68 65 20 6e 75 6d 62 65 72 20 69 6e 20 |y the number in | 00000970 74 68 65 20 59 20 72 65 67 69 73 74 65 72 2e 0d |the Y register..| 00000980 0d 20 20 20 20 34 20 20 20 53 74 61 72 74 20 6f |. 4 Start o| 00000990 66 20 54 56 20 66 69 65 6c 64 20 62 6c 61 6e 6b |f TV field blank| 000009a0 69 6e 67 20 69 6e 74 65 72 76 61 6c 0d 0d 54 68 |ing interval..Th| 000009b0 65 20 62 65 61 6d 20 6f 66 20 74 68 65 20 54 56 |e beam of the TV| 000009c0 20 70 69 63 74 75 72 65 20 67 65 6e 65 72 61 74 | picture generat| 000009d0 65 64 20 62 79 20 74 68 65 20 6d 69 63 72 6f 20 |ed by the micro | 000009e0 73 63 61 6e 73 20 74 68 65 0d 77 68 6f 6c 65 20 |scans the.whole | 000009f0 73 63 72 65 65 6e 20 74 77 69 63 65 20 66 6f 72 |screen twice for| 00000a00 20 65 61 63 68 20 66 72 61 6d 65 2e 20 20 45 61 | each frame. Ea| 00000a10 63 68 20 66 72 61 6d 65 20 69 73 20 6d 61 64 65 |ch frame is made| 00000a20 20 75 70 20 6f 66 0d 74 77 6f 20 66 69 65 6c 64 | up of.two field| 00000a30 73 2c 20 65 61 63 68 20 6f 66 20 31 2f 35 30 74 |s, each of 1/50t| 00000a40 68 20 73 65 63 6f 6e 64 20 64 75 72 61 74 69 6f |h second duratio| 00000a50 6e 2e 20 20 54 68 69 73 20 65 76 65 6e 74 20 69 |n. This event i| 00000a60 73 0d 67 65 6e 65 72 61 74 65 64 20 77 68 65 6e |s.generated when| 00000a70 65 76 65 72 20 74 68 65 20 62 65 61 6d 20 6c 65 |ever the beam le| 00000a80 61 76 65 73 20 74 68 65 20 62 6f 74 74 6f 6d 20 |aves the bottom | 00000a90 6f 66 20 74 68 65 20 73 63 72 65 65 6e 0d 61 6e |of the screen.an| 00000aa0 64 20 66 6c 69 65 73 20 62 61 63 6b 20 74 6f 20 |d flies back to | 00000ab0 74 68 65 20 74 6f 70 2c 20 69 2e 65 2e 20 6f 6e |the top, i.e. on| 00000ac0 63 65 20 70 65 72 20 66 69 65 6c 64 2c 20 35 30 |ce per field, 50| 00000ad0 20 74 69 6d 65 73 20 61 0d 73 65 63 6f 6e 64 2e | times a.second.| 00000ae0 20 20 4f 53 42 59 54 45 20 31 39 20 66 6f 72 63 | OSBYTE 19 forc| 00000af0 65 73 20 74 68 65 20 6d 69 63 72 6f 20 74 6f 20 |es the micro to | 00000b00 77 61 69 74 20 66 6f 72 20 74 68 65 20 66 6c 79 |wait for the fly| 00000b10 62 61 63 6b 0d 74 6f 20 73 74 61 72 74 2e 0d 0d |back.to start...| 00000b20 20 20 20 20 35 20 20 20 49 6e 74 65 72 76 61 6c | 5 Interval| 00000b30 20 74 69 6d 65 72 20 63 72 6f 73 73 65 73 20 7a | timer crosses z| 00000b40 65 72 6f 0d 0d 54 68 69 73 20 69 73 20 61 20 74 |ero..This is a t| 00000b50 69 6d 65 72 2c 20 6e 6f 74 20 74 68 65 20 54 49 |imer, not the TI| 00000b60 4d 45 20 74 69 6d 65 72 2c 20 72 65 61 64 20 6f |ME timer, read o| 00000b70 72 20 73 65 74 20 62 79 20 4f 53 57 4f 52 44 0d |r set by OSWORD.| 00000b80 33 20 61 6e 64 20 34 2e 20 20 41 73 20 74 68 65 |3 and 4. As the| 00000b90 20 74 69 6d 65 72 20 69 6e 63 72 65 61 73 65 73 | timer increases| 00000ba0 20 62 79 20 6f 6e 65 20 31 30 30 20 74 69 6d 65 | by one 100 time| 00000bb0 73 20 61 20 73 65 63 6f 6e 64 0d 79 6f 75 20 63 |s a second.you c| 00000bc0 6f 75 6c 64 20 75 73 65 20 74 68 69 73 20 65 76 |ould use this ev| 00000bd0 65 6e 74 20 74 6f 20 70 72 69 6e 74 20 61 20 62 |ent to print a b| 00000be0 61 63 6b 67 72 6f 75 6e 64 20 63 6c 6f 63 6b 20 |ackground clock | 00000bf0 6f 6e 20 74 68 65 0d 73 63 72 65 65 6e 2e 0d 0d |on the.screen...| 00000c00 20 20 20 20 36 20 20 20 45 53 43 41 50 45 20 64 | 6 ESCAPE d| 00000c10 65 74 65 63 74 65 64 0d 0d 57 68 65 6e 20 74 68 |etected..When th| 00000c20 69 73 20 65 76 65 6e 74 20 69 73 20 65 6e 61 62 |is event is enab| 00000c30 6c 65 64 2c 20 74 68 65 20 45 53 43 41 50 45 20 |led, the ESCAPE | 00000c40 6b 65 79 20 68 61 73 20 6e 6f 20 65 66 66 65 63 |key has no effec| 00000c50 74 0d 66 72 6f 6d 20 42 41 53 49 43 20 6f 72 20 |t.from BASIC or | 00000c60 77 68 61 74 65 76 65 72 20 6c 61 6e 67 75 61 67 |whatever languag| 00000c70 65 20 79 6f 75 20 61 72 65 20 75 73 69 6e 67 2e |e you are using.| 00000c80 20 20 54 68 65 20 45 53 43 41 50 45 0d 63 6f 75 | The ESCAPE.cou| 00000c90 6c 64 20 68 61 76 65 20 63 6f 6d 65 20 64 6f 77 |ld have come dow| 00000ca0 6e 20 74 68 65 20 52 53 34 32 33 20 69 66 20 74 |n the RS423 if t| 00000cb0 68 61 74 20 77 61 73 20 65 6e 61 62 6c 65 64 2e |hat was enabled.| 00000cc0 0d 0d 20 20 20 20 37 20 20 20 52 53 34 32 33 20 |.. 7 RS423 | 00000cd0 65 72 72 6f 72 20 64 65 74 65 63 74 65 64 0d 0d |error detected..| 00000ce0 54 68 65 20 73 65 72 69 61 6c 20 73 79 73 74 65 |The serial syste| 00000cf0 6d 20 68 61 73 20 67 65 6e 65 72 61 74 65 64 20 |m has generated | 00000d00 61 6e 20 65 72 72 6f 72 2e 0d 0d 20 20 20 20 38 |an error... 8| 00000d10 20 20 20 4e 65 74 77 6f 72 6b 20 65 76 65 6e 74 | Network event| 00000d20 0d 0d 43 61 6e 20 6f 6e 6c 79 20 68 61 70 70 65 |..Can only happe| 00000d30 6e 20 77 68 65 6e 20 45 63 6f 6e 65 74 20 69 73 |n when Econet is| 00000d40 20 61 74 74 61 63 68 65 64 20 74 6f 20 79 6f 75 | attached to you| 00000d50 72 20 6d 61 63 68 69 6e 65 2e 0d 0d 20 20 20 20 |r machine... | 00000d60 39 20 20 20 55 73 65 72 20 65 76 65 6e 74 0d 0d |9 User event..| 00000d70 53 65 74 20 61 73 69 64 65 20 66 6f 72 20 74 68 |Set aside for th| 00000d80 65 20 75 73 65 72 2c 20 77 68 6f 20 63 6f 75 6c |e user, who coul| 00000d90 64 20 61 6c 73 6f 20 75 73 65 20 45 76 65 6e 74 |d also use Event| 00000da0 20 38 20 69 66 20 6e 6f 0d 45 63 6f 6e 65 74 20 | 8 if no.Econet | 00000db0 77 61 73 20 70 72 65 73 65 6e 74 2e 0d 0d 49 66 |was present...If| 00000dc0 20 6f 6e 65 20 6f 66 20 74 68 65 73 65 20 65 76 | one of these ev| 00000dd0 65 6e 74 73 20 69 73 20 65 6e 61 62 6c 65 64 20 |ents is enabled | 00000de0 77 69 74 68 20 4f 53 42 59 54 45 20 31 34 20 28 |with OSBYTE 14 (| 00000df0 41 3d 31 34 0d 58 3d 65 76 65 6e 74 20 6e 75 6d |A=14.X=event num| 00000e00 62 65 72 29 20 74 68 65 6e 20 77 68 65 6e 20 74 |ber) then when t| 00000e10 68 65 20 65 76 65 6e 74 20 69 74 73 65 6c 66 20 |he event itself | 00000e20 6f 63 63 75 72 73 20 74 68 65 20 6d 69 63 72 6f |occurs the micro| 00000e30 0d 77 69 6c 6c 20 4a 4d 50 20 28 65 76 6e 74 76 |.will JMP (evntv| 00000e40 29 2c 20 69 2e 65 2e 20 69 74 20 77 69 6c 6c 20 |), i.e. it will | 00000e50 6a 75 6d 70 20 74 6f 20 74 68 65 20 61 64 64 72 |jump to the addr| 00000e60 65 73 73 20 68 65 6c 64 20 69 6e 0d 74 68 65 20 |ess held in.the | 00000e70 65 76 65 6e 74 20 76 65 63 74 6f 72 20 26 32 32 |event vector &22| 00000e80 30 20 28 61 6e 64 20 26 32 32 31 29 2e 20 20 55 |0 (and &221). U| 00000e90 6e 6c 65 73 73 20 79 6f 75 20 77 69 73 68 20 74 |nless you wish t| 00000ea0 6f 20 63 68 61 69 6e 0d 6f 6e 20 64 6f 77 6e 20 |o chain.on down | 00000eb0 74 68 65 20 65 76 65 6e 74 20 76 65 63 74 6f 72 |the event vector| 00000ec0 20 61 66 74 65 72 20 79 6f 75 72 20 69 6e 74 65 | after your inte| 00000ed0 72 63 65 70 74 69 6f 6e 20 28 61 6e 64 20 74 68 |rception (and th| 00000ee0 69 73 0d 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65 |is.should not be| 00000ef0 20 6e 65 63 63 65 73 73 61 72 79 29 20 79 6f 75 | neccessary) you| 00000f00 20 6d 75 73 74 20 65 78 69 74 20 66 72 6f 6d 20 | must exit from | 00000f10 79 6f 75 72 20 63 6f 64 65 20 77 69 74 68 0d 61 |your code with.a| 00000f20 6e 20 52 54 53 2c 20 73 69 6e 63 65 20 62 65 66 |n RTS, since bef| 00000f30 6f 72 65 20 65 78 65 63 75 74 69 6f 6e 20 6a 75 |ore execution ju| 00000f40 6d 70 65 64 20 64 6f 77 6e 20 74 68 65 20 76 65 |mped down the ve| 00000f50 63 74 6f 72 20 74 68 65 20 4f 53 0d 73 65 74 20 |ctor the OS.set | 00000f60 75 70 20 74 68 65 20 73 74 61 63 6b 20 61 6e 64 |up the stack and| 00000f70 20 6d 65 6d 6f 72 79 20 69 6e 20 61 20 77 61 79 | memory in a way| 00000f80 20 74 68 61 74 20 65 78 70 65 63 74 73 20 74 68 | that expects th| 00000f90 69 73 2e 20 49 6e 0d 65 66 66 65 63 74 20 74 68 |is. In.effect th| 00000fa0 69 73 20 6d 65 61 6e 73 20 74 68 61 74 20 74 68 |is means that th| 00000fb0 65 20 4f 53 20 65 78 70 65 63 74 73 20 61 20 73 |e OS expects a s| 00000fc0 75 62 72 6f 75 74 69 6e 65 20 61 74 20 74 68 65 |ubroutine at the| 00000fd0 0d 61 64 64 72 65 73 73 20 69 6e 20 74 68 65 20 |.address in the | 00000fe0 65 76 65 6e 74 20 76 65 63 74 6f 72 2e 0d 0d 54 |event vector...T| 00000ff0 68 65 72 65 20 69 73 20 61 20 27 52 65 54 75 72 |here is a 'ReTur| 00001000 6e 20 66 72 6f 6d 20 49 6e 74 65 72 72 75 70 74 |n from Interrupt| 00001010 27 20 6d 6e 65 6d 6f 6e 69 63 20 74 68 61 74 20 |' mnemonic that | 00001020 6d 69 67 68 74 20 61 74 0d 66 69 72 73 74 20 73 |might at.first s| 00001030 69 67 68 74 20 73 65 65 6d 20 61 70 70 72 6f 70 |ight seem approp| 00001040 72 69 61 74 65 2c 20 73 69 6e 63 65 20 65 76 65 |riate, since eve| 00001050 6e 74 73 20 61 72 65 20 61 63 74 75 61 6c 6c 79 |nts are actually| 00001060 20 61 0d 66 6f 72 6d 20 6f 66 20 69 6e 74 65 72 | a.form of inter| 00001070 72 75 70 74 2e 20 20 48 6f 77 65 76 65 72 20 74 |rupt. However t| 00001080 68 65 20 4f 53 20 68 61 73 20 73 65 74 20 75 70 |he OS has set up| 00001090 20 74 68 65 20 65 76 65 6e 74 20 69 6e 20 61 0d | the event in a.| 000010a0 73 70 65 63 69 61 6c 20 77 61 79 20 61 6e 64 20 |special way and | 000010b0 79 6f 75 20 6d 75 73 74 20 52 54 53 20 66 72 6f |you must RTS fro| 000010c0 6d 20 61 6e 20 65 76 65 6e 74 2c 20 6e 6f 74 20 |m an event, not | 000010d0 52 54 49 2e 0d 0d 54 68 65 20 61 64 64 72 65 73 |RTI...The addres| 000010e0 73 20 69 6e 20 74 68 65 20 76 65 63 74 6f 72 20 |s in the vector | 000010f0 73 68 6f 75 6c 64 20 62 65 20 70 6f 69 6e 74 69 |should be pointi| 00001100 6e 67 20 74 6f 20 79 6f 75 72 20 65 76 65 6e 74 |ng to your event| 00001110 0d 72 6f 75 74 69 6e 65 2e 20 20 41 73 20 69 74 |.routine. As it| 00001120 20 65 6e 74 65 72 73 20 79 6f 75 72 20 72 6f 75 | enters your rou| 00001130 74 69 6e 65 20 74 68 65 20 61 63 63 75 6d 75 6c |tine the accumul| 00001140 61 74 6f 72 20 69 73 0d 68 6f 6c 64 69 6e 67 20 |ator is.holding | 00001150 74 68 65 20 65 76 65 6e 74 20 6e 75 6d 62 65 72 |the event number| 00001160 2e 20 20 59 6f 75 72 20 72 6f 75 74 69 6e 65 20 |. Your routine | 00001170 6d 75 73 74 20 73 61 76 65 20 61 6c 6c 20 74 68 |must save all th| 00001180 65 0d 72 65 67 69 73 74 65 72 73 20 28 50 20 41 |e.registers (P A| 00001190 20 58 20 20 61 6e 64 20 59 29 20 74 6f 20 74 68 | X and Y) to th| 000011a0 65 20 73 74 61 63 6b 2c 20 61 6e 64 20 77 68 65 |e stack, and whe| 000011b0 6e 20 79 6f 75 20 68 61 76 65 0d 66 69 6e 69 73 |n you have.finis| 000011c0 68 65 64 20 79 6f 75 20 73 68 6f 75 6c 64 20 72 |hed you should r| 000011d0 65 73 74 6f 72 65 20 74 68 65 20 72 65 67 69 73 |estore the regis| 000011e0 74 65 72 73 20 62 65 66 6f 72 65 20 79 6f 75 20 |ters before you | 000011f0 65 78 69 74 2e 0d 0d 54 68 65 20 69 6e 74 65 72 |exit...The inter| 00001200 72 75 70 74 20 64 69 73 61 62 6c 65 20 66 6c 61 |rupt disable fla| 00001210 67 20 77 69 6c 6c 20 62 65 20 73 65 74 20 62 79 |g will be set by| 00001220 20 74 68 65 20 4f 53 0d 61 75 74 6f 6d 61 74 69 | the OS.automati| 00001230 63 61 6c 6c 79 20 62 65 66 6f 72 65 20 74 68 65 |cally before the| 00001240 20 6d 69 63 72 6f 20 72 65 61 63 68 65 73 20 79 | micro reaches y| 00001250 6f 75 72 20 63 6f 64 65 20 61 6e 64 20 79 6f 75 |our code and you| 00001260 0d 73 68 6f 75 6c 64 20 6e 6f 74 20 65 6e 61 62 |.should not enab| 00001270 6c 65 20 69 6e 74 65 72 72 75 70 74 73 2e 20 20 |le interrupts. | 00001280 42 79 20 74 68 65 20 73 61 6d 65 20 74 6f 6b 65 |By the same toke| 00001290 6e 20 79 6f 75 20 73 68 6f 75 6c 64 0d 6e 6f 74 |n you should.not| 000012a0 20 75 73 65 20 61 6e 79 20 4f 53 20 72 6f 75 74 | use any OS rout| 000012b0 69 6e 65 20 74 68 61 74 20 65 6e 61 62 6c 65 73 |ine that enables| 000012c0 20 69 6e 74 65 72 72 75 70 74 73 2e 20 20 54 68 | interrupts. Th| 000012d0 69 73 20 6d 65 61 6e 73 0d 79 6f 75 20 63 61 6e |is means.you can| 000012e0 20 75 73 65 20 4f 53 42 59 54 45 20 61 6e 64 20 | use OSBYTE and | 000012f0 73 6f 6d 65 20 4f 53 57 4f 52 44 20 63 61 6c 6c |some OSWORD call| 00001300 73 20 64 75 72 69 6e 67 20 61 6e 20 65 76 65 6e |s during an even| 00001310 74 0d 72 6f 75 74 69 6e 65 20 62 75 74 20 6e 6f |t.routine but no| 00001320 74 20 6f 74 68 65 72 73 20 6c 69 6b 65 20 4f 53 |t others like OS| 00001330 43 4c 49 2c 20 4f 53 52 44 43 48 20 61 6e 64 20 |CLI, OSRDCH and | 00001340 4f 53 57 52 43 48 2e 0d 0d 49 66 20 79 6f 75 20 |OSWRCH...If you | 00001350 61 72 65 20 61 62 73 6f 6c 75 74 65 6c 79 20 63 |are absolutely c| 00001360 65 72 74 61 69 6e 20 74 68 61 74 20 79 6f 75 72 |ertain that your| 00001370 73 20 69 73 20 74 68 65 20 6f 6e 6c 79 20 65 76 |s is the only ev| 00001380 65 6e 74 0d 72 6f 75 74 69 6e 65 20 74 68 65 6e |ent.routine then| 00001390 20 79 6f 75 20 73 68 6f 75 6c 64 20 52 54 53 20 | you should RTS | 000013a0 72 61 74 68 65 72 20 74 68 61 6e 20 67 6f 69 6e |rather than goin| 000013b0 67 20 64 6f 77 6e 20 74 68 65 0d 6f 72 69 67 69 |g down the.origi| 000013c0 6e 61 6c 20 76 65 63 74 6f 72 2e 0d 0d 59 6f 75 |nal vector...You| 000013d0 72 20 65 76 65 6e 74 20 72 6f 75 74 69 6e 65 20 |r event routine | 000013e0 77 69 6c 6c 20 70 72 6f 62 61 62 6c 79 20 62 65 |will probably be| 000013f0 20 65 78 70 65 63 74 69 6e 67 20 6f 6e 6c 79 20 | expecting only | 00001400 6f 6e 65 0d 65 76 65 6e 74 2c 20 73 6f 20 79 6f |one.event, so yo| 00001410 75 20 73 68 6f 75 6c 64 20 63 68 65 63 6b 20 74 |u should check t| 00001420 68 65 20 76 61 6c 75 65 20 69 6e 20 41 20 74 6f |he value in A to| 00001430 20 73 65 65 20 69 66 20 74 68 65 0d 65 76 65 6e | see if the.even| 00001440 74 20 74 68 61 74 20 68 61 73 20 63 61 75 73 65 |t that has cause| 00001450 64 20 74 68 65 20 6a 75 6d 70 20 74 6f 20 79 6f |d the jump to yo| 00001460 75 72 20 72 6f 75 74 69 6e 65 20 69 73 20 74 68 |ur routine is th| 00001470 65 20 6f 6e 65 0d 79 6f 75 20 65 78 70 65 63 74 |e one.you expect| 00001480 2e 20 20 49 66 20 69 74 20 69 73 20 6e 6f 74 20 |. If it is not | 00001490 74 68 65 6e 20 79 6f 75 20 73 68 6f 75 6c 64 20 |then you should | 000014a0 6a 75 6d 70 20 74 6f 20 74 68 65 0d 6f 72 69 67 |jump to the.orig| 000014b0 69 6e 61 6c 20 63 6f 6e 74 65 6e 74 73 20 6f 66 |inal contents of| 000014c0 20 74 68 65 20 76 65 63 74 6f 72 2e 0d 0d 54 68 | the vector...Th| 000014d0 65 20 70 72 6f 67 72 61 6d 20 69 6e 20 74 68 69 |e program in thi| 000014e0 73 20 6d 6f 64 75 6c 65 20 75 73 65 73 20 74 68 |s module uses th| 000014f0 65 20 6b 65 79 62 6f 61 72 64 20 65 76 65 6e 74 |e keyboard event| 00001500 20 28 6e 75 6d 62 65 72 0d 32 29 20 74 6f 20 6d | (number.2) to m| 00001510 61 6b 65 20 61 20 63 6c 69 63 6b 20 77 68 65 6e |ake a click when| 00001520 20 61 20 6b 65 79 20 69 73 20 70 72 65 73 73 65 | a key is presse| 00001530 64 2e 20 20 54 68 65 20 63 6f 64 65 20 69 73 0d |d. The code is.| 00001540 61 73 73 65 6d 62 6c 65 64 20 69 6e 20 74 68 65 |assembled in the| 00001550 20 49 2f 4f 20 70 72 6f 63 65 73 73 6f 72 20 6f | I/O processor o| 00001560 6e 6c 79 20 61 74 20 26 41 30 30 20 61 73 20 62 |nly at &A00 as b| 00001570 65 66 6f 72 65 2e 20 0d 4c 65 74 27 73 20 67 6f |efore. .Let's go| 00001580 20 74 68 72 6f 75 67 68 20 74 68 65 20 70 72 6f | through the pro| 00001590 67 72 61 6d 2e 0d 0d 54 68 65 20 73 65 74 74 69 |gram...The setti| 000015a0 6e 67 20 75 70 20 72 6f 75 74 69 6e 65 20 69 73 |ng up routine is| 000015b0 20 66 72 6f 6d 20 6c 69 6e 65 20 32 31 30 20 74 | from line 210 t| 000015c0 6f 20 6c 69 6e 65 20 34 32 30 2e 20 20 49 6e 20 |o line 420. In | 000015d0 69 74 0d 74 68 65 20 76 65 63 74 6f 72 73 20 61 |it.the vectors a| 000015e0 72 65 20 63 68 61 6e 67 65 64 20 28 69 66 20 74 |re changed (if t| 000015f0 68 65 79 20 68 61 76 65 6e 27 74 20 62 65 65 6e |hey haven't been| 00001600 20 63 68 61 6e 67 65 64 0d 61 6c 72 65 61 64 79 | changed.already| 00001610 29 20 77 69 74 68 20 74 68 65 20 6f 6c 64 20 76 |) with the old v| 00001620 65 63 74 6f 72 20 63 6f 6e 74 65 6e 74 73 20 62 |ector contents b| 00001630 65 69 6e 67 20 73 74 6f 72 65 64 20 69 6e 0d 27 |eing stored in.'| 00001640 6f 6c 64 5f 65 76 6e 74 76 27 2e 20 20 4f 53 57 |old_evntv'. OSW| 00001650 4f 52 44 20 38 20 69 73 20 74 68 65 6e 20 75 73 |ORD 8 is then us| 00001660 65 64 20 74 6f 20 73 65 74 20 75 70 20 61 20 73 |ed to set up a s| 00001670 75 69 74 61 62 6c 65 0d 65 6e 76 65 6c 6f 70 65 |uitable.envelope| 00001680 20 66 72 6f 6d 20 74 68 65 20 70 61 72 61 6d 65 | from the parame| 00001690 74 65 72 20 6c 69 73 74 20 69 6e 20 6c 69 6e 65 |ter list in line| 000016a0 73 20 37 36 30 20 74 6f 20 38 39 30 2e 20 20 54 |s 760 to 890. T| 000016b0 68 65 0d 73 65 74 74 69 6e 67 20 75 70 20 70 72 |he.setting up pr| 000016c0 6f 63 65 64 75 72 65 20 66 6f 72 20 4f 53 57 4f |ocedure for OSWO| 000016d0 52 44 20 77 61 73 20 67 69 76 65 6e 20 69 6e 20 |RD was given in | 000016e0 6d 6f 64 75 6c 65 20 35 2e 0d 0d 54 68 65 20 61 |module 5...The a| 000016f0 63 74 75 61 6c 20 65 76 65 6e 74 20 63 6f 64 65 |ctual event code| 00001700 20 69 73 20 76 65 72 79 20 73 69 6d 70 6c 65 2e | is very simple.| 00001710 20 20 49 74 20 6c 69 65 73 20 62 65 74 77 65 65 | It lies betwee| 00001720 6e 20 6c 69 6e 65 73 0d 34 34 30 20 61 6e 64 20 |n lines.440 and | 00001730 36 39 30 2e 20 20 46 69 72 73 74 20 77 65 20 63 |690. First we c| 00001740 68 65 63 6b 20 74 68 61 74 20 74 68 69 73 20 69 |heck that this i| 00001750 73 20 65 76 65 6e 74 20 32 20 61 6e 64 20 69 66 |s event 2 and if| 00001760 20 6e 6f 74 0d 77 65 20 6a 75 6d 70 20 6f 75 74 | not.we jump out| 00001770 20 73 74 72 61 69 67 68 74 20 61 77 61 79 20 64 | straight away d| 00001780 6f 77 6e 20 74 68 65 20 6f 6c 64 20 76 65 63 74 |own the old vect| 00001790 6f 72 2e 20 20 28 49 66 20 79 6f 75 20 61 72 65 |or. (If you are| 000017a0 0d 66 65 65 6c 69 6e 67 20 64 65 76 69 6f 75 73 |.feeling devious| 000017b0 20 79 6f 75 20 63 6f 75 6c 64 20 72 65 6d 6f 76 | you could remov| 000017c0 65 20 74 68 69 73 20 74 72 61 70 20 61 6e 64 20 |e this trap and | 000017d0 73 65 65 20 77 68 61 74 0d 68 61 70 70 65 6e 73 |see what.happens| 000017e0 20 77 68 65 6e 20 79 6f 75 20 65 6e 61 62 6c 65 | when you enable| 000017f0 20 6f 74 68 65 72 20 65 76 65 6e 74 73 20 77 69 | other events wi| 00001800 74 68 20 2a 46 58 20 31 34 2e 29 0d 0d 41 6c 6c |th *FX 14.)..All| 00001810 20 72 65 67 69 73 74 65 72 73 20 61 72 65 20 73 | registers are s| 00001820 61 76 65 64 20 6f 6e 74 6f 20 74 68 65 20 73 74 |aved onto the st| 00001830 61 63 6b 2c 20 69 6e 63 6c 75 64 69 6e 67 20 74 |ack, including t| 00001840 68 65 20 73 74 61 74 75 73 0d 72 65 67 69 73 74 |he status.regist| 00001850 65 72 20 28 76 65 72 79 20 69 6d 70 6f 72 74 61 |er (very importa| 00001860 6e 74 29 2e 20 20 54 68 65 20 64 65 63 69 6d 61 |nt). The decima| 00001870 6c 20 66 6c 61 67 20 69 73 20 63 6c 65 61 72 65 |l flag is cleare| 00001880 64 20 6a 75 73 74 0d 69 6e 20 63 61 73 65 20 74 |d just.in case t| 00001890 68 65 20 66 6f 72 65 67 72 6f 75 6e 64 20 72 6f |he foreground ro| 000018a0 75 74 69 6e 65 20 77 61 73 20 69 6e 20 64 65 63 |utine was in dec| 000018b0 69 6d 61 6c 20 6d 6f 64 65 2e 20 20 28 49 74 0d |imal mode. (It.| 000018c0 77 6f 75 6c 64 20 72 65 74 75 72 6e 20 74 6f 20 |would return to | 000018d0 64 65 63 69 6d 61 6c 20 6d 6f 64 65 20 73 69 6e |decimal mode sin| 000018e0 63 65 20 74 68 65 20 73 74 61 74 75 73 20 72 65 |ce the status re| 000018f0 67 69 73 74 65 72 20 77 69 6c 6c 0d 62 65 20 72 |gister will.be r| 00001900 65 73 74 6f 72 65 64 20 61 74 20 74 68 65 20 65 |estored at the e| 00001910 6e 64 20 6f 66 20 74 68 65 20 72 6f 75 74 69 6e |nd of the routin| 00001920 65 2e 29 0d 0d 54 68 65 6e 20 4f 53 57 4f 52 44 |e.)..Then OSWORD| 00001930 20 37 20 69 73 20 63 61 6c 6c 65 64 20 77 68 69 | 7 is called whi| 00001940 63 68 20 6d 61 6b 65 73 20 74 68 65 20 73 6f 75 |ch makes the sou| 00001950 6e 64 20 75 73 69 6e 67 20 74 68 65 0d 65 6e 76 |nd using the.env| 00001960 65 6c 6f 70 65 20 28 6e 75 6d 62 65 72 20 31 29 |elope (number 1)| 00001970 20 73 65 74 20 69 6e 20 74 68 65 20 73 65 74 2d | set in the set-| 00001980 75 70 20 63 6f 64 65 2e 20 20 54 68 65 20 72 65 |up code. The re| 00001990 67 69 73 74 65 72 73 0d 61 72 65 20 72 65 73 74 |gisters.are rest| 000019a0 6f 72 65 64 20 61 6e 64 20 74 68 65 20 63 6f 64 |ored and the cod| 000019b0 65 20 6a 75 6d 70 73 20 64 6f 77 6e 20 74 68 65 |e jumps down the| 000019c0 20 6f 6c 64 20 76 65 63 74 6f 72 2e 20 20 59 6f | old vector. Yo| 000019d0 75 0d 63 61 6e 20 6e 6f 74 20 61 73 73 75 6d 65 |u.can not assume| 000019e0 20 74 68 61 74 20 6e 6f 20 6f 6e 65 20 65 6c 73 | that no one els| 000019f0 65 20 77 6f 75 6c 64 20 75 73 65 20 65 76 65 6e |e would use even| 00001a00 74 20 32 20 6a 75 73 74 0d 62 65 63 61 75 73 65 |t 2 just.because| 00001a10 20 79 6f 75 20 68 61 76 65 2e 0d 0d 49 66 20 79 | you have...If y| 00001a20 6f 75 20 77 61 6e 74 20 74 6f 20 73 61 76 65 20 |ou want to save | 00001a30 74 68 65 20 72 6f 75 74 69 6e 65 20 74 6f 20 64 |the routine to d| 00001a40 69 73 6b 20 74 68 65 6e 20 63 6f 70 79 20 74 68 |isk then copy th| 00001a50 65 20 2a 53 41 56 45 0d 6c 69 6e 65 20 61 63 72 |e *SAVE.line acr| 00001a60 6f 73 73 2e 20 20 54 68 69 73 20 68 61 73 20 74 |oss. This has t| 00001a70 6f 20 72 75 6e 20 69 6e 20 74 68 65 20 49 2f 4f |o run in the I/O| 00001a80 20 70 72 6f 63 65 73 73 6f 72 20 73 6f 20 79 6f | processor so yo| 00001a90 75 0d 77 69 6c 6c 20 6e 6f 74 20 62 65 20 61 6c |u.will not be al| 00001aa0 6c 6f 77 65 64 20 74 6f 20 72 75 6e 20 74 68 69 |lowed to run thi| 00001ab0 73 20 61 73 73 65 6d 62 6c 79 20 69 6e 20 61 20 |s assembly in a | 00001ac0 73 65 63 6f 6e 64 0d 70 72 6f 63 65 73 73 6f 72 |second.processor| 00001ad0 20 61 6e 64 20 74 68 65 20 64 69 73 63 20 73 61 | and the disc sa| 00001ae0 76 69 6e 67 20 63 6f 6d 6d 61 6e 64 20 70 75 74 |ving command put| 00001af0 73 20 74 68 65 20 61 64 64 72 65 73 73 20 61 73 |s the address as| 00001b00 0d 26 46 46 46 46 30 41 30 30 2e 20 20 4e 6f 20 |.&FFFF0A00. No | 00001b10 4f 53 20 63 61 6c 6c 73 20 61 72 65 20 61 6c 6c |OS calls are all| 00001b20 6f 77 65 64 20 69 6e 73 69 64 65 20 65 76 65 6e |owed inside even| 00001b30 74 73 20 69 6e 20 74 68 65 0d 73 65 63 6f 6e 64 |ts in the.second| 00001b40 20 70 72 6f 63 65 73 73 6f 72 20 62 75 74 2c 20 | processor but, | 00001b50 61 73 20 77 69 74 68 20 74 68 65 20 76 65 63 74 |as with the vect| 00001b60 6f 72 20 70 72 6f 67 72 61 6d 2c 20 74 68 69 73 |or program, this| 00001b70 20 77 69 6c 6c 0d 72 75 6e 20 69 6e 20 74 68 65 | will.run in the| 00001b80 20 49 2f 4f 20 70 72 6f 63 65 73 73 6f 72 20 6e | I/O processor n| 00001b90 6f 2d 6d 61 74 74 65 72 20 77 68 65 72 65 20 79 |o-matter where y| 00001ba0 6f 75 72 20 66 6f 72 65 67 72 6f 75 6e 64 0d 70 |our foreground.p| 00001bb0 72 6f 67 72 61 6d 20 69 73 2e 0d 0d 54 68 65 20 |rogram is...The | 00001bc0 42 41 53 49 43 20 70 72 6f 67 72 61 6d 20 73 68 |BASIC program sh| 00001bd0 65 6c 6c 20 65 6e 61 62 6c 65 73 20 74 68 65 20 |ell enables the | 00001be0 65 76 65 6e 74 20 73 6f 20 79 6f 75 20 73 68 6f |event so you sho| 00001bf0 75 6c 64 20 68 65 61 72 0d 74 68 65 20 6b 65 79 |uld hear.the key| 00001c00 20 63 6c 69 63 6b 73 2e 20 20 54 6f 20 64 69 73 | clicks. To dis| 00001c10 61 62 6c 65 20 74 68 65 6d 20 65 6e 74 65 72 20 |able them enter | 00001c20 2a 46 58 31 33 2c 32 2e 20 20 49 66 20 79 6f 75 |*FX13,2. If you| 00001c30 0d 6c 61 74 65 72 20 77 61 6e 74 20 74 6f 20 72 |.later want to r| 00001c40 75 6e 20 69 6e 20 74 68 65 20 72 6f 75 74 69 6e |un in the routin| 00001c50 65 20 66 72 6f 6d 20 64 69 73 63 20 74 68 65 6e |e from disc then| 00001c60 20 74 79 70 69 6e 67 0d 2a 6b 63 6c 69 63 6b 20 | typing.*kclick | 00001c70 66 6f 6c 6c 6f 77 65 64 20 62 79 20 2a 46 58 20 |followed by *FX | 00001c80 31 34 2c 32 20 77 69 6c 6c 20 64 6f 20 69 74 2e |14,2 will do it.| 00001c90 0d 0d 49 6e 20 74 68 65 20 6e 65 78 74 20 6d 6f |..In the next mo| 00001ca0 64 75 6c 65 20 77 65 20 70 72 6f 67 72 65 73 73 |dule we progress| 00001cb0 20 6f 6e 74 6f 20 69 6e 74 65 72 72 75 70 74 73 | onto interrupts| 00001cc0 20 70 72 6f 70 65 72 20 61 6e 64 0d 49 27 6c 6c | proper and.I'll| 00001cd0 20 73 68 6f 77 20 79 6f 75 20 68 6f 77 20 74 6f | show you how to| 00001ce0 20 77 72 69 74 65 20 61 20 6d 6f 75 73 65 20 64 | write a mouse d| 00001cf0 72 69 76 65 72 2e 0d |river..| 00001cf7