Home » CEEFAX disks » telesoftware14.adl » 12-03-89/T\TTX01

12-03-89/T\TTX01

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 » telesoftware14.adl
Filename: 12-03-89/T\TTX01
Read OK:
File size: 44DD bytes
Load address: 0000
Exec address: FFFFFFFF
File contents
Interfacing with the Acorn Teletext Adaptor - by - Gordon Horsington
--------------------------------------------------------------------

Module 1. Teletext generated interrupts
---------------------------------------

In the next six Teletext modules I will explain how to write software to
interface with the Acorn Teletext adaptor hardware without using either
the ATS or the TFS. In order to understand these modules you will need to
be familiar with the use of maskable interrupts on the BBC microcomputer.

The Acorn Teletext adaptor uses maskable interrupts to inform the BBC
computer that it has data ready for processing. Maskable interrupts can be
intercepted on the BBC computer and re-directed to an address specified by
the user. There are two interrupt request vectors which could be used to
make this interception. Interrupt Request Vector 1 (IRQ1V) at &204 and
&205 is used for high priority interrupts and you should avoid using this
vector. The low priority Interrupt Request Vector 2 (IRQ2V) at &206 and
&207 should be used to intercept the Teletext generated interrupts.

The BBC computer is connected to the Acorn Teletext adaptor using the 1
MHz bus. The Teletext hardware is mapped onto 4 bytes of page &FC in the
I/O processor memory. This page is usually known as FRED and it is
reserved for the 1 MHz bus. The four bytes reserved for the Teletext
adaptor, from &FC10 to &FC13, are used for all communication between the
BBC computer and the Teletext hardware. Using these four bytes is the only
direct way of reading from or writing to the adaptor and they are used by
all Acorn Teletext adaptor software including the ATS and the TFS.

Osbyte calls &92 and &93 can be used to communicate with page &FC. Osbyte
&92 is used to write to FRED and Osbyte &93 to read from FRED. Although
operating system calls have been provided for reading from and writing to
FRED, you should avoid using them in interrupt processing software
whenever possible. The reason for avoiding the operating system calls is
that if a foreground task is using an operating system routine which is
also used by an interrupt routine, and the operating system routine is not
re-entrant, your program will crash.

All Osbyte calls have a time penalty associated with their use and, for
reasons which will explained later in this module, it is necessary to use
programs which have been optimized for speed when processing the
interrupts generated by the Teletext adaptor. It is much quicker to peek
and poke the registers directly as well as much safer. This faster method
of using the Teletext registers directly does not cause any Tube
compatibility problems because interrupts generated by I/O processor
hardware, such as the Teletext adaptor, are not passed to a second
processor. Teletext generated interrupts must be dealt with by software
running in the I/O processor.

The Acorn Teletext adaptor contains 1k of memory arranged as 16 rows of 64
bytes. This memory can be accessed and controlled using the Teletext
registers. The five Teletext adaptor registers are mapped onto the four
bytes from &FC10 to &FC13. These registers are known as the status
register (&FC10), the control register (also at &FC10), the row register
(&FC11), the data register (&FC12) and the status clear register (&FC13).


Status Register (&FC10)
-----------------------

The eight bit status register at &FC10 is the read-only status register of
the Teletext adaptor. The bits of the status register have the following
interpretation:

D0-3 Link selectable options.
D4   Frame Sync. Set by the TV frame sync pulse and reset by writing to
     &FC13.
D5   Data Entry Window. High during TTX portion of TV signal. If D7 is low
     and TTX unit enabled the TTX unit locks out the CPU during this time.
D6   Data Overrun. Set High if status is not cleared before next data
     entry window.
D7   Interrupt. Set High by the trailing edge of the data entry window.


Control Register (&FC10)
------------------------

The eight bit control register at &FC10 is the write-only control register
of the Teletext adaptor. The bits of the control register have the
following functions:

D0-1 Channel number (0-3)
D2   TTX Enable. Set High to enable TTX reception. Set Low to allow use of
     1K by computer. (16*64 bytes)
D3   Interrupt Enable. Set High to enable interrupts. Set Low to disable
     interrupts. No effect on working of TTX unit.
D4   AFC Control. Set Low to disable AFC and allow tuning. Set High to
     enable automatic frequency control.
D5   Spare.
D6-7 Not used, not latched.


Row Register (&FC11)
--------------------

The four bit row register at &FC11 is the write-only row register of the
Teletext adaptor. The bits of the row register have the following
functions:

D0-3 This 4 bit register controls which of the 16 64 byte long rows of the
     adaptor's memory will be accessed by the data register. Setting this
     register resets the column count (internal) to zero.


Data Register (&FC12)
---------------------

The eight bit Data Register at &FC12 is the read and write data register
of the Teletext adaptor. The bits of the data register have the following
interpretation:

D0-7 This 8 bit register is used to read from and write to the 16*64 bytes
     in the TTX adaptor. When the Row register is written to, an internal
     column count is set to zero. Every time the data register is read or
     written to, the column count is incremented. Thus successive reads
     from the data register return successive bytes from the selected row.


Status Clear Register (&FC13)
-----------------------------

The eight bit status clear register at &FC13 is the read-and-write clear
status register of the Teletext adaptor. The bits of the clear status
register have the following interpretation:

D0-7 Reading or writing to this register clears the status flags. This
     must be done at the end of any data collection routine, otherwise the
     Data Overrun flag will be set (bit 6 of the status register).



When you design programs which bypass the ATS ROM and interface directly
with the Teletext hardware it is a good idea to consider using either a
BASIC or a machine code foreground task to update the screen and an
interrupt driven machine code background task to process the Teletext
interrupts. This type of design will be used in all the programs used to
illustrate the Teletext modules 1 to 7.

The example program associated with this module shows you how to re-direct
the IRQ2V vector to point to an interrupt handling routine and how that
routine can recognise and process Teletext generated interrupts. The
program COUNTER is perhaps the most simple type of interrupt processing
possible with the Teletext adaptor. The program recognises Teletext
interrupts and counts how many interrupts are generated while the program
is active. When the escape key is pressed the program calculates the rate
at which the interrupts have been generated.

The program COUNTER uses BASIC to assemble and call a machine code
program. The machine code can be divided into a foreground task (lines 500
to 660), which prints the contents of a four byte decimal counter, and a
background task (lines 780 to 1170), which processes the Teletext
generated interrupts. This program illustrates how the control register is
used to enable the Teletext adaptor and select a TV channel, and also how
the clear status register must be used after processing every Teletext
interrupt.

Bits 0 to 4 of the control register are used to enable the Teletext
adaptor and select the required channel. Bits 0 and 1 are used to select
the channel, bit 2 is set high to enable Teletext reception, bit 3 is set
high to enable Teletext generated interrupts and bit 4 is set high to
enable the automatic frequency control. When you use the control register
to enable the Teletext adaptor you will only normally write one of four
values to the register. These numbers are in the range from &1C to &1F.


  &1C %00011100 Enable AFC, enable interrupts, enable TTX, channel 0
  &1D %00011101 Enable AFC, enable interrupts, enable TTX, channel 1
  &1E %00011110 Enable AFC, enable interrupts, enable TTX, channel 2
  &1F %00011111 Enable AFC, enable interrupts, enable TTX, channel 3


One of these four values is selected in lines 80 to 120 and written to
the control register in lines 480 and 490 of COUNTER. The Teletext adaptor
is disabled by writing the value &00 to the control register (lines 690
and 700). All the demonstration programs in the Acorn Teletext modules
will prompt for a channel number in the range from 1 to 4 even though the
adaptor uses channel numbers 0 to 3. It seems to be sensible to use the
range 1 to 4 which corresponds with BBC1, BBC2 and Channel 4 better than
the range 0 to 3. For this reason the number &1B (not &1C) is added to the
channel number in line 100 to give the required range of values for the
control register.

An interrupt generated by the Teletext adaptor can be recognised by
polling the status register. Bit 7 of the status register is set when the
Teletext adaptor generates an interrupt. The program COUNTER intercepts
all unrecognised maskable interrupts offered to the IRQ2 vector and polls
the status register (line 790) to see if the Teletext adaptor was the
source of the unrecognised interrupt. If the adaptor was not the source of
the interrupt it is passed on to the original interrupt handling routine
(line 810). If the adaptor was the source of the interrupt it is processed
by the program and a return is made using an RTI instruction (line 1170).

Before returning from a Teletext generated interrupt it is essential to
clear all 16 rows in the Teletext adaptor by selecting each row and
writing the number zero to the adaptor (lines 1030 to 1090). A row is
selected by writing the row number into the row register and the row is
cleared by storing zero in the first available byte in the row. This byte
is called the framing code and will be explained in detail in module 2.
After clearing the adaptor memory, it is also necessary to either read
from or write to the status clear register to clear the status flags (line
1100). All Teletext processing routines must do this before returning from
an interrupt. Failure to do so will produce a data overrun error.

Before chaining the program COUNTER you can disable the ATS ROM by typing
the command *NOTTX. This should convince sceptics that the program is
completely independant of the ATS. It is not necessary to disable the ATS
in this way to use any of the demonstration programs with the Acorn
adaptor because the ATS should not interfere with them in any way but, if
you have a sideways RAM / shadow RAM board installed in a BBC B computer,
you may have to use *NOTTX and alter irq2v to irq1v to get the program to
work. If you have to modify this program you will have to modify all the
programs associated with Teletext modules 1 to 7.

Chain the program COUNTER, let it run for a little while and then press
the Escape key. When I used the program I found that the Teletext adaptor
produced 50.05 interrupts a second. This corresponds very well with the 50
Hz field flyback interval and the difference may be due to a slight
inaccuracy in the BBC computer's timer.

A Teletext generated interrupt indicates that data are available for
processing and it is up to you to ensure that all processing of the
Teletext interrupt is complete well before 20 milliseconds have elapsed
when another Teletext interrupt can be expected. If a program does not
clear the status flags and execute an RTI before the 20 millisecond
deadline then the least problem you can expect is a data overrun error. It
is much more likely that any interrupt handling routine which takes
anything like 20 milliseconds will hang up the computer completely and
very quickly.

You must always design your background tasks to deal with the interrupts
as quickly as possible. This is certainly not a problem with a simple
program like COUNTER but it something to keep in mind in the later modules
when the design of frame grabbers and keyword searching will be
considered.

If a foreground task needs more than 20 milliseconds to analyse a data
packet then you could consider either disabling the Teletext hardware or
"dumping" unwanted data after reading the data you want to process into
the computer memory. Although this is a possible method of controlling the
hardware you must use it with care. Any processing that takes more than 20
milliseconds will probably be written in BASIC or very inefficient machine
code and you must remember that disabling the hardware or dumping data can
result in losing the very data you want to process. You can only expect to
get away with very long data processing times when your program is looking
for single data packets, such as the Television Service Data Packet, which
arrive at infrequent intervals.


   10 REM> COUNTER
   20 MODE7
   30 DIM mcode &200 :REM: space for machine code
   40 PROCmcode :REM: assemble machine code
   50 ttx$=CHR$(141)+CHR$(132)+CHR$(157)+CHR$(131)
      +"TTX interrupt counter  "+CHR$(156)
   60 PRINTTAB(5,3)ttx$
   70 PRINTTAB(5,4)ttx$
   80 INPUTTAB(9,8)"TV channel (1-4) = "answer$
   90 VDU23,1,0;0;0;0;
  100 ?channel=EVAL("&"+LEFT$(answer$,1))+&1B
  110 IF ?channel < &1C THEN ?channel = &1C
  120 IF ?channel > &1F THEN ?channel = &1F
  130 TIME=0
  140 CALL mcode
  150 time=TIME/100
  160 count=EVAL(STR$~(!counter))
  170 at%=@%
  180 @%=&20205
  190 PRINTTAB(6,16);count/time;" interrupts per second"
  200 @%=at%
  210 VDU31,0,22,23,1,1;0;0;0;
  220 END
  230 DEFPROCmcode
  240 channel=&70 :REM: TV channel
  250 savereg=&FC :REM: interrupt accumulator save register
  260 escape=&FF :REM: escape flag
  270 irq2v=&206 :REM: IRQ2 vector
  280 ttxcontrol=&FC10 :REM: TTX control register, write only
  290 ttxstatus=&FC10 :REM: TTX status register, read only
  300 rowreg=&FC11 :REM: TTX row register, write only
  310 datareg=&FC12 :REM: TTX data register, read & write
  320 statclr=&FC13 :REM: TTX clear status register, read & write
  330 oswrch=&FFEE
  340 osbyte=&FFF4
  350 FOR pass=0 TO 2 STEP 2
  360 P%=mcode
  370 [       OPT pass
  380         LDX irq2v     \ load secondary interrupt vector
  390         LDY irq2v+1
  400         STX oldirq2v  \ save secondary interrupt vector
  410         STY oldirq2v+1
  420         LDX #interrupt MOD 256 \ install new interrupt routine
  430         LDY #interrupt DIV 256
  440         SEI           \ disable interrupts when altering vector
  450         STX irq2v
  460         STY irq2v+1
  470         CLI           \ re-enable interrupts
  480         LDA channel   \ load (channel number + #&1C)
  490         STA ttxcontrol \ enable TTX
  500 .mainloop
  510         LDA #&1F      \ decimal 31
  520         JSR oswrch
  530         LDA #&0F      \ decimal 15
  540         JSR oswrch
  550         LDA #&0C      \ decimal 12
  560         JSR oswrch    \ VDU 31,14,14
  570         LDA counter+3
  580         JSR printbcd  \ print 4 byte counter in hex.
  590         LDA counter+2
  600         JSR printbcd
  610         LDA counter+1
  620         JSR printbcd
  630         LDA counter
  640         JSR printbcd
  650         LDA escape    \ poll escape flag
  660         BPL mainloop  \ branch if escape not pressed
  670         LDA #&7E
  680         JSR osbyte    \ acknowledge escape
  690         LDA #&00
  700         STA ttxcontrol \ disable TTX
  710         LDX oldirq2v  \ load original vector
  720         LDY oldirq2v+1
  730         SEI           \ disable interrupts when altering vector
  740         STX irq2v     \ restore original vector
  750         STY irq2v+1
  760         CLI           \ re-enable interrupts
  770         RTS           \ return to BASIC
  780 .interrupt
  790         BIT ttxstatus \ poll TTX hardware
  800         BMI ttxinter  \ branch if TTX interrupt
  810         JMP (oldirq2v) \ not TTX interrupt
  820 .ttxinter
  830         LDA savereg   \ interrupt accumulator save register
  840         PHA           \ push interrupt accumulator save register
  850         TXA
  860         PHA           \ push X
  870         TYA
  880         PHA           \ push Y
  890         SED
  900         CLC
  910         LDA #&01
  920         ADC counter   \ add 1 for every TTX interrupt
  930         STA counter
  940         LDA #&00
  950         ADC counter+1
  960         STA counter+1
  970         LDA #&00
  980         ADC counter+2
  990         STA counter+2
 1000         LDA #&00
 1010         ADC counter+3
 1020         STA counter+3
 1030         LDA #&00
 1040         LDY #&0F      \ clear 16 rows in adaptor
 1050 .clearloop
 1060         STY rowreg
 1070         STA datareg
 1080         DEY
 1090         BPL clearloop
 1100         STA statclr   \ clear status flags before returning
 1110         PLA
 1120         TAY           \ restore Y
 1130         PLA
 1140         TAX           \ restore X
 1150         PLA
 1160         STA savereg   \ restore interrupt accumulator save register
 1170         RTI           \ return from interrupt
 1180 .printbcd
 1190         PHA
 1200         LSR A
 1210         LSR A
 1220         LSR A
 1230         LSR A
 1240         JSR nybble
 1250         PLA
 1260 .nybble
 1270         AND #&0F      \ decimal 15
 1280         SED
 1290         CLC
 1300         ADC #&90      \ decimal 144
 1310         ADC #&40      \ decimal 64
 1320         CLD
 1330         JMP oswrch
 1340 .counter
 1350         EQUD &00
 1360 .oldirq2v
 1370         EQUW &00
 1380 ]
 1390 NEXT
 1400 ENDPROC
00000000  49 6e 74 65 72 66 61 63  69 6e 67 20 77 69 74 68  |Interfacing with|
00000010  20 74 68 65 20 41 63 6f  72 6e 20 54 65 6c 65 74  | the Acorn Telet|
00000020  65 78 74 20 41 64 61 70  74 6f 72 20 2d 20 62 79  |ext Adaptor - by|
00000030  20 2d 20 47 6f 72 64 6f  6e 20 48 6f 72 73 69 6e  | - Gordon Horsin|
00000040  67 74 6f 6e 0d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |gton.-----------|
00000050  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
*
00000080  2d 2d 2d 2d 2d 2d 2d 2d  2d 0d 0d 4d 6f 64 75 6c  |---------..Modul|
00000090  65 20 31 2e 20 54 65 6c  65 74 65 78 74 20 67 65  |e 1. Teletext ge|
000000a0  6e 65 72 61 74 65 64 20  69 6e 74 65 72 72 75 70  |nerated interrup|
000000b0  74 73 0d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |ts.-------------|
000000c0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
000000d0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 0d 0d 49 6e 20 74  |----------..In t|
000000e0  68 65 20 6e 65 78 74 20  73 69 78 20 54 65 6c 65  |he next six Tele|
000000f0  74 65 78 74 20 6d 6f 64  75 6c 65 73 20 49 20 77  |text modules I w|
00000100  69 6c 6c 20 65 78 70 6c  61 69 6e 20 68 6f 77 20  |ill explain how |
00000110  74 6f 20 77 72 69 74 65  20 73 6f 66 74 77 61 72  |to write softwar|
00000120  65 20 74 6f 0d 69 6e 74  65 72 66 61 63 65 20 77  |e to.interface w|
00000130  69 74 68 20 74 68 65 20  41 63 6f 72 6e 20 54 65  |ith the Acorn Te|
00000140  6c 65 74 65 78 74 20 61  64 61 70 74 6f 72 20 68  |letext adaptor h|
00000150  61 72 64 77 61 72 65 20  77 69 74 68 6f 75 74 20  |ardware without |
00000160  75 73 69 6e 67 20 65 69  74 68 65 72 0d 74 68 65  |using either.the|
00000170  20 41 54 53 20 6f 72 20  74 68 65 20 54 46 53 2e  | ATS or the TFS.|
00000180  20 49 6e 20 6f 72 64 65  72 20 74 6f 20 75 6e 64  | In order to und|
00000190  65 72 73 74 61 6e 64 20  74 68 65 73 65 20 6d 6f  |erstand these mo|
000001a0  64 75 6c 65 73 20 79 6f  75 20 77 69 6c 6c 20 6e  |dules you will n|
000001b0  65 65 64 20 74 6f 0d 62  65 20 66 61 6d 69 6c 69  |eed to.be famili|
000001c0  61 72 20 77 69 74 68 20  74 68 65 20 75 73 65 20  |ar with the use |
000001d0  6f 66 20 6d 61 73 6b 61  62 6c 65 20 69 6e 74 65  |of maskable inte|
000001e0  72 72 75 70 74 73 20 6f  6e 20 74 68 65 20 42 42  |rrupts on the BB|
000001f0  43 20 6d 69 63 72 6f 63  6f 6d 70 75 74 65 72 2e  |C microcomputer.|
00000200  0d 0d 54 68 65 20 41 63  6f 72 6e 20 54 65 6c 65  |..The Acorn Tele|
00000210  74 65 78 74 20 61 64 61  70 74 6f 72 20 75 73 65  |text adaptor use|
00000220  73 20 6d 61 73 6b 61 62  6c 65 20 69 6e 74 65 72  |s maskable inter|
00000230  72 75 70 74 73 20 74 6f  20 69 6e 66 6f 72 6d 20  |rupts to inform |
00000240  74 68 65 20 42 42 43 0d  63 6f 6d 70 75 74 65 72  |the BBC.computer|
00000250  20 74 68 61 74 20 69 74  20 68 61 73 20 64 61 74  | that it has dat|
00000260  61 20 72 65 61 64 79 20  66 6f 72 20 70 72 6f 63  |a ready for proc|
00000270  65 73 73 69 6e 67 2e 20  4d 61 73 6b 61 62 6c 65  |essing. Maskable|
00000280  20 69 6e 74 65 72 72 75  70 74 73 20 63 61 6e 20  | interrupts can |
00000290  62 65 0d 69 6e 74 65 72  63 65 70 74 65 64 20 6f  |be.intercepted o|
000002a0  6e 20 74 68 65 20 42 42  43 20 63 6f 6d 70 75 74  |n the BBC comput|
000002b0  65 72 20 61 6e 64 20 72  65 2d 64 69 72 65 63 74  |er and re-direct|
000002c0  65 64 20 74 6f 20 61 6e  20 61 64 64 72 65 73 73  |ed to an address|
000002d0  20 73 70 65 63 69 66 69  65 64 20 62 79 0d 74 68  | specified by.th|
000002e0  65 20 75 73 65 72 2e 20  54 68 65 72 65 20 61 72  |e user. There ar|
000002f0  65 20 74 77 6f 20 69 6e  74 65 72 72 75 70 74 20  |e two interrupt |
00000300  72 65 71 75 65 73 74 20  76 65 63 74 6f 72 73 20  |request vectors |
00000310  77 68 69 63 68 20 63 6f  75 6c 64 20 62 65 20 75  |which could be u|
00000320  73 65 64 20 74 6f 0d 6d  61 6b 65 20 74 68 69 73  |sed to.make this|
00000330  20 69 6e 74 65 72 63 65  70 74 69 6f 6e 2e 20 49  | interception. I|
00000340  6e 74 65 72 72 75 70 74  20 52 65 71 75 65 73 74  |nterrupt Request|
00000350  20 56 65 63 74 6f 72 20  31 20 28 49 52 51 31 56  | Vector 1 (IRQ1V|
00000360  29 20 61 74 20 26 32 30  34 20 61 6e 64 0d 26 32  |) at &204 and.&2|
00000370  30 35 20 69 73 20 75 73  65 64 20 66 6f 72 20 68  |05 is used for h|
00000380  69 67 68 20 70 72 69 6f  72 69 74 79 20 69 6e 74  |igh priority int|
00000390  65 72 72 75 70 74 73 20  61 6e 64 20 79 6f 75 20  |errupts and you |
000003a0  73 68 6f 75 6c 64 20 61  76 6f 69 64 20 75 73 69  |should avoid usi|
000003b0  6e 67 20 74 68 69 73 0d  76 65 63 74 6f 72 2e 20  |ng this.vector. |
000003c0  54 68 65 20 6c 6f 77 20  70 72 69 6f 72 69 74 79  |The low priority|
000003d0  20 49 6e 74 65 72 72 75  70 74 20 52 65 71 75 65  | Interrupt Reque|
000003e0  73 74 20 56 65 63 74 6f  72 20 32 20 28 49 52 51  |st Vector 2 (IRQ|
000003f0  32 56 29 20 61 74 20 26  32 30 36 20 61 6e 64 0d  |2V) at &206 and.|
00000400  26 32 30 37 20 73 68 6f  75 6c 64 20 62 65 20 75  |&207 should be u|
00000410  73 65 64 20 74 6f 20 69  6e 74 65 72 63 65 70 74  |sed to intercept|
00000420  20 74 68 65 20 54 65 6c  65 74 65 78 74 20 67 65  | the Teletext ge|
00000430  6e 65 72 61 74 65 64 20  69 6e 74 65 72 72 75 70  |nerated interrup|
00000440  74 73 2e 0d 0d 54 68 65  20 42 42 43 20 63 6f 6d  |ts...The BBC com|
00000450  70 75 74 65 72 20 69 73  20 63 6f 6e 6e 65 63 74  |puter is connect|
00000460  65 64 20 74 6f 20 74 68  65 20 41 63 6f 72 6e 20  |ed to the Acorn |
00000470  54 65 6c 65 74 65 78 74  20 61 64 61 70 74 6f 72  |Teletext adaptor|
00000480  20 75 73 69 6e 67 20 74  68 65 20 31 0d 4d 48 7a  | using the 1.MHz|
00000490  20 62 75 73 2e 20 54 68  65 20 54 65 6c 65 74 65  | bus. The Telete|
000004a0  78 74 20 68 61 72 64 77  61 72 65 20 69 73 20 6d  |xt hardware is m|
000004b0  61 70 70 65 64 20 6f 6e  74 6f 20 34 20 62 79 74  |apped onto 4 byt|
000004c0  65 73 20 6f 66 20 70 61  67 65 20 26 46 43 20 69  |es of page &FC i|
000004d0  6e 20 74 68 65 0d 49 2f  4f 20 70 72 6f 63 65 73  |n the.I/O proces|
000004e0  73 6f 72 20 6d 65 6d 6f  72 79 2e 20 54 68 69 73  |sor memory. This|
000004f0  20 70 61 67 65 20 69 73  20 75 73 75 61 6c 6c 79  | page is usually|
00000500  20 6b 6e 6f 77 6e 20 61  73 20 46 52 45 44 20 61  | known as FRED a|
00000510  6e 64 20 69 74 20 69 73  0d 72 65 73 65 72 76 65  |nd it is.reserve|
00000520  64 20 66 6f 72 20 74 68  65 20 31 20 4d 48 7a 20  |d for the 1 MHz |
00000530  62 75 73 2e 20 54 68 65  20 66 6f 75 72 20 62 79  |bus. The four by|
00000540  74 65 73 20 72 65 73 65  72 76 65 64 20 66 6f 72  |tes reserved for|
00000550  20 74 68 65 20 54 65 6c  65 74 65 78 74 0d 61 64  | the Teletext.ad|
00000560  61 70 74 6f 72 2c 20 66  72 6f 6d 20 26 46 43 31  |aptor, from &FC1|
00000570  30 20 74 6f 20 26 46 43  31 33 2c 20 61 72 65 20  |0 to &FC13, are |
00000580  75 73 65 64 20 66 6f 72  20 61 6c 6c 20 63 6f 6d  |used for all com|
00000590  6d 75 6e 69 63 61 74 69  6f 6e 20 62 65 74 77 65  |munication betwe|
000005a0  65 6e 20 74 68 65 0d 42  42 43 20 63 6f 6d 70 75  |en the.BBC compu|
000005b0  74 65 72 20 61 6e 64 20  74 68 65 20 54 65 6c 65  |ter and the Tele|
000005c0  74 65 78 74 20 68 61 72  64 77 61 72 65 2e 20 55  |text hardware. U|
000005d0  73 69 6e 67 20 74 68 65  73 65 20 66 6f 75 72 20  |sing these four |
000005e0  62 79 74 65 73 20 69 73  20 74 68 65 20 6f 6e 6c  |bytes is the onl|
000005f0  79 0d 64 69 72 65 63 74  20 77 61 79 20 6f 66 20  |y.direct way of |
00000600  72 65 61 64 69 6e 67 20  66 72 6f 6d 20 6f 72 20  |reading from or |
00000610  77 72 69 74 69 6e 67 20  74 6f 20 74 68 65 20 61  |writing to the a|
00000620  64 61 70 74 6f 72 20 61  6e 64 20 74 68 65 79 20  |daptor and they |
00000630  61 72 65 20 75 73 65 64  20 62 79 0d 61 6c 6c 20  |are used by.all |
00000640  41 63 6f 72 6e 20 54 65  6c 65 74 65 78 74 20 61  |Acorn Teletext a|
00000650  64 61 70 74 6f 72 20 73  6f 66 74 77 61 72 65 20  |daptor software |
00000660  69 6e 63 6c 75 64 69 6e  67 20 74 68 65 20 41 54  |including the AT|
00000670  53 20 61 6e 64 20 74 68  65 20 54 46 53 2e 0d 0d  |S and the TFS...|
00000680  4f 73 62 79 74 65 20 63  61 6c 6c 73 20 26 39 32  |Osbyte calls &92|
00000690  20 61 6e 64 20 26 39 33  20 63 61 6e 20 62 65 20  | and &93 can be |
000006a0  75 73 65 64 20 74 6f 20  63 6f 6d 6d 75 6e 69 63  |used to communic|
000006b0  61 74 65 20 77 69 74 68  20 70 61 67 65 20 26 46  |ate with page &F|
000006c0  43 2e 20 4f 73 62 79 74  65 0d 26 39 32 20 69 73  |C. Osbyte.&92 is|
000006d0  20 75 73 65 64 20 74 6f  20 77 72 69 74 65 20 74  | used to write t|
000006e0  6f 20 46 52 45 44 20 61  6e 64 20 4f 73 62 79 74  |o FRED and Osbyt|
000006f0  65 20 26 39 33 20 74 6f  20 72 65 61 64 20 66 72  |e &93 to read fr|
00000700  6f 6d 20 46 52 45 44 2e  20 41 6c 74 68 6f 75 67  |om FRED. Althoug|
00000710  68 0d 6f 70 65 72 61 74  69 6e 67 20 73 79 73 74  |h.operating syst|
00000720  65 6d 20 63 61 6c 6c 73  20 68 61 76 65 20 62 65  |em calls have be|
00000730  65 6e 20 70 72 6f 76 69  64 65 64 20 66 6f 72 20  |en provided for |
00000740  72 65 61 64 69 6e 67 20  66 72 6f 6d 20 61 6e 64  |reading from and|
00000750  20 77 72 69 74 69 6e 67  20 74 6f 0d 46 52 45 44  | writing to.FRED|
00000760  2c 20 79 6f 75 20 73 68  6f 75 6c 64 20 61 76 6f  |, you should avo|
00000770  69 64 20 75 73 69 6e 67  20 74 68 65 6d 20 69 6e  |id using them in|
00000780  20 69 6e 74 65 72 72 75  70 74 20 70 72 6f 63 65  | interrupt proce|
00000790  73 73 69 6e 67 20 73 6f  66 74 77 61 72 65 0d 77  |ssing software.w|
000007a0  68 65 6e 65 76 65 72 20  70 6f 73 73 69 62 6c 65  |henever possible|
000007b0  2e 20 54 68 65 20 72 65  61 73 6f 6e 20 66 6f 72  |. The reason for|
000007c0  20 61 76 6f 69 64 69 6e  67 20 74 68 65 20 6f 70  | avoiding the op|
000007d0  65 72 61 74 69 6e 67 20  73 79 73 74 65 6d 20 63  |erating system c|
000007e0  61 6c 6c 73 20 69 73 0d  74 68 61 74 20 69 66 20  |alls is.that if |
000007f0  61 20 66 6f 72 65 67 72  6f 75 6e 64 20 74 61 73  |a foreground tas|
00000800  6b 20 69 73 20 75 73 69  6e 67 20 61 6e 20 6f 70  |k is using an op|
00000810  65 72 61 74 69 6e 67 20  73 79 73 74 65 6d 20 72  |erating system r|
00000820  6f 75 74 69 6e 65 20 77  68 69 63 68 20 69 73 0d  |outine which is.|
00000830  61 6c 73 6f 20 75 73 65  64 20 62 79 20 61 6e 20  |also used by an |
00000840  69 6e 74 65 72 72 75 70  74 20 72 6f 75 74 69 6e  |interrupt routin|
00000850  65 2c 20 61 6e 64 20 74  68 65 20 6f 70 65 72 61  |e, and the opera|
00000860  74 69 6e 67 20 73 79 73  74 65 6d 20 72 6f 75 74  |ting system rout|
00000870  69 6e 65 20 69 73 20 6e  6f 74 0d 72 65 2d 65 6e  |ine is not.re-en|
00000880  74 72 61 6e 74 2c 20 79  6f 75 72 20 70 72 6f 67  |trant, your prog|
00000890  72 61 6d 20 77 69 6c 6c  20 63 72 61 73 68 2e 0d  |ram will crash..|
000008a0  0d 41 6c 6c 20 4f 73 62  79 74 65 20 63 61 6c 6c  |.All Osbyte call|
000008b0  73 20 68 61 76 65 20 61  20 74 69 6d 65 20 70 65  |s have a time pe|
000008c0  6e 61 6c 74 79 20 61 73  73 6f 63 69 61 74 65 64  |nalty associated|
000008d0  20 77 69 74 68 20 74 68  65 69 72 20 75 73 65 20  | with their use |
000008e0  61 6e 64 2c 20 66 6f 72  0d 72 65 61 73 6f 6e 73  |and, for.reasons|
000008f0  20 77 68 69 63 68 20 77  69 6c 6c 20 65 78 70 6c  | which will expl|
00000900  61 69 6e 65 64 20 6c 61  74 65 72 20 69 6e 20 74  |ained later in t|
00000910  68 69 73 20 6d 6f 64 75  6c 65 2c 20 69 74 20 69  |his module, it i|
00000920  73 20 6e 65 63 65 73 73  61 72 79 20 74 6f 20 75  |s necessary to u|
00000930  73 65 0d 70 72 6f 67 72  61 6d 73 20 77 68 69 63  |se.programs whic|
00000940  68 20 68 61 76 65 20 62  65 65 6e 20 6f 70 74 69  |h have been opti|
00000950  6d 69 7a 65 64 20 66 6f  72 20 73 70 65 65 64 20  |mized for speed |
00000960  77 68 65 6e 20 70 72 6f  63 65 73 73 69 6e 67 20  |when processing |
00000970  74 68 65 0d 69 6e 74 65  72 72 75 70 74 73 20 67  |the.interrupts g|
00000980  65 6e 65 72 61 74 65 64  20 62 79 20 74 68 65 20  |enerated by the |
00000990  54 65 6c 65 74 65 78 74  20 61 64 61 70 74 6f 72  |Teletext adaptor|
000009a0  2e 20 49 74 20 69 73 20  6d 75 63 68 20 71 75 69  |. It is much qui|
000009b0  63 6b 65 72 20 74 6f 20  70 65 65 6b 0d 61 6e 64  |cker to peek.and|
000009c0  20 70 6f 6b 65 20 74 68  65 20 72 65 67 69 73 74  | poke the regist|
000009d0  65 72 73 20 64 69 72 65  63 74 6c 79 20 61 73 20  |ers directly as |
000009e0  77 65 6c 6c 20 61 73 20  6d 75 63 68 20 73 61 66  |well as much saf|
000009f0  65 72 2e 20 54 68 69 73  20 66 61 73 74 65 72 20  |er. This faster |
00000a00  6d 65 74 68 6f 64 0d 6f  66 20 75 73 69 6e 67 20  |method.of using |
00000a10  74 68 65 20 54 65 6c 65  74 65 78 74 20 72 65 67  |the Teletext reg|
00000a20  69 73 74 65 72 73 20 64  69 72 65 63 74 6c 79 20  |isters directly |
00000a30  64 6f 65 73 20 6e 6f 74  20 63 61 75 73 65 20 61  |does not cause a|
00000a40  6e 79 20 54 75 62 65 0d  63 6f 6d 70 61 74 69 62  |ny Tube.compatib|
00000a50  69 6c 69 74 79 20 70 72  6f 62 6c 65 6d 73 20 62  |ility problems b|
00000a60  65 63 61 75 73 65 20 69  6e 74 65 72 72 75 70 74  |ecause interrupt|
00000a70  73 20 67 65 6e 65 72 61  74 65 64 20 62 79 20 49  |s generated by I|
00000a80  2f 4f 20 70 72 6f 63 65  73 73 6f 72 0d 68 61 72  |/O processor.har|
00000a90  64 77 61 72 65 2c 20 73  75 63 68 20 61 73 20 74  |dware, such as t|
00000aa0  68 65 20 54 65 6c 65 74  65 78 74 20 61 64 61 70  |he Teletext adap|
00000ab0  74 6f 72 2c 20 61 72 65  20 6e 6f 74 20 70 61 73  |tor, are not pas|
00000ac0  73 65 64 20 74 6f 20 61  20 73 65 63 6f 6e 64 0d  |sed to a second.|
00000ad0  70 72 6f 63 65 73 73 6f  72 2e 20 54 65 6c 65 74  |processor. Telet|
00000ae0  65 78 74 20 67 65 6e 65  72 61 74 65 64 20 69 6e  |ext generated in|
00000af0  74 65 72 72 75 70 74 73  20 6d 75 73 74 20 62 65  |terrupts must be|
00000b00  20 64 65 61 6c 74 20 77  69 74 68 20 62 79 20 73  | dealt with by s|
00000b10  6f 66 74 77 61 72 65 0d  72 75 6e 6e 69 6e 67 20  |oftware.running |
00000b20  69 6e 20 74 68 65 20 49  2f 4f 20 70 72 6f 63 65  |in the I/O proce|
00000b30  73 73 6f 72 2e 0d 0d 54  68 65 20 41 63 6f 72 6e  |ssor...The Acorn|
00000b40  20 54 65 6c 65 74 65 78  74 20 61 64 61 70 74 6f  | Teletext adapto|
00000b50  72 20 63 6f 6e 74 61 69  6e 73 20 31 6b 20 6f 66  |r contains 1k of|
00000b60  20 6d 65 6d 6f 72 79 20  61 72 72 61 6e 67 65 64  | memory arranged|
00000b70  20 61 73 20 31 36 20 72  6f 77 73 20 6f 66 20 36  | as 16 rows of 6|
00000b80  34 0d 62 79 74 65 73 2e  20 54 68 69 73 20 6d 65  |4.bytes. This me|
00000b90  6d 6f 72 79 20 63 61 6e  20 62 65 20 61 63 63 65  |mory can be acce|
00000ba0  73 73 65 64 20 61 6e 64  20 63 6f 6e 74 72 6f 6c  |ssed and control|
00000bb0  6c 65 64 20 75 73 69 6e  67 20 74 68 65 20 54 65  |led using the Te|
00000bc0  6c 65 74 65 78 74 0d 72  65 67 69 73 74 65 72 73  |letext.registers|
00000bd0  2e 20 54 68 65 20 66 69  76 65 20 54 65 6c 65 74  |. The five Telet|
00000be0  65 78 74 20 61 64 61 70  74 6f 72 20 72 65 67 69  |ext adaptor regi|
00000bf0  73 74 65 72 73 20 61 72  65 20 6d 61 70 70 65 64  |sters are mapped|
00000c00  20 6f 6e 74 6f 20 74 68  65 20 66 6f 75 72 0d 62  | onto the four.b|
00000c10  79 74 65 73 20 66 72 6f  6d 20 26 46 43 31 30 20  |ytes from &FC10 |
00000c20  74 6f 20 26 46 43 31 33  2e 20 54 68 65 73 65 20  |to &FC13. These |
00000c30  72 65 67 69 73 74 65 72  73 20 61 72 65 20 6b 6e  |registers are kn|
00000c40  6f 77 6e 20 61 73 20 74  68 65 20 73 74 61 74 75  |own as the statu|
00000c50  73 0d 72 65 67 69 73 74  65 72 20 28 26 46 43 31  |s.register (&FC1|
00000c60  30 29 2c 20 74 68 65 20  63 6f 6e 74 72 6f 6c 20  |0), the control |
00000c70  72 65 67 69 73 74 65 72  20 28 61 6c 73 6f 20 61  |register (also a|
00000c80  74 20 26 46 43 31 30 29  2c 20 74 68 65 20 72 6f  |t &FC10), the ro|
00000c90  77 20 72 65 67 69 73 74  65 72 0d 28 26 46 43 31  |w register.(&FC1|
00000ca0  31 29 2c 20 74 68 65 20  64 61 74 61 20 72 65 67  |1), the data reg|
00000cb0  69 73 74 65 72 20 28 26  46 43 31 32 29 20 61 6e  |ister (&FC12) an|
00000cc0  64 20 74 68 65 20 73 74  61 74 75 73 20 63 6c 65  |d the status cle|
00000cd0  61 72 20 72 65 67 69 73  74 65 72 20 28 26 46 43  |ar register (&FC|
00000ce0  31 33 29 2e 0d 0d 0d 53  74 61 74 75 73 20 52 65  |13)....Status Re|
00000cf0  67 69 73 74 65 72 20 28  26 46 43 31 30 29 0d 2d  |gister (&FC10).-|
00000d00  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
00000d10  2d 2d 2d 2d 2d 2d 0d 0d  54 68 65 20 65 69 67 68  |------..The eigh|
00000d20  74 20 62 69 74 20 73 74  61 74 75 73 20 72 65 67  |t bit status reg|
00000d30  69 73 74 65 72 20 61 74  20 26 46 43 31 30 20 69  |ister at &FC10 i|
00000d40  73 20 74 68 65 20 72 65  61 64 2d 6f 6e 6c 79 20  |s the read-only |
00000d50  73 74 61 74 75 73 20 72  65 67 69 73 74 65 72 20  |status register |
00000d60  6f 66 0d 74 68 65 20 54  65 6c 65 74 65 78 74 20  |of.the Teletext |
00000d70  61 64 61 70 74 6f 72 2e  20 54 68 65 20 62 69 74  |adaptor. The bit|
00000d80  73 20 6f 66 20 74 68 65  20 73 74 61 74 75 73 20  |s of the status |
00000d90  72 65 67 69 73 74 65 72  20 68 61 76 65 20 74 68  |register have th|
00000da0  65 20 66 6f 6c 6c 6f 77  69 6e 67 0d 69 6e 74 65  |e following.inte|
00000db0  72 70 72 65 74 61 74 69  6f 6e 3a 0d 0d 44 30 2d  |rpretation:..D0-|
00000dc0  33 20 4c 69 6e 6b 20 73  65 6c 65 63 74 61 62 6c  |3 Link selectabl|
00000dd0  65 20 6f 70 74 69 6f 6e  73 2e 0d 44 34 20 20 20  |e options..D4   |
00000de0  46 72 61 6d 65 20 53 79  6e 63 2e 20 53 65 74 20  |Frame Sync. Set |
00000df0  62 79 20 74 68 65 20 54  56 20 66 72 61 6d 65 20  |by the TV frame |
00000e00  73 79 6e 63 20 70 75 6c  73 65 20 61 6e 64 20 72  |sync pulse and r|
00000e10  65 73 65 74 20 62 79 20  77 72 69 74 69 6e 67 20  |eset by writing |
00000e20  74 6f 0d 20 20 20 20 20  26 46 43 31 33 2e 0d 44  |to.     &FC13..D|
00000e30  35 20 20 20 44 61 74 61  20 45 6e 74 72 79 20 57  |5   Data Entry W|
00000e40  69 6e 64 6f 77 2e 20 48  69 67 68 20 64 75 72 69  |indow. High duri|
00000e50  6e 67 20 54 54 58 20 70  6f 72 74 69 6f 6e 20 6f  |ng TTX portion o|
00000e60  66 20 54 56 20 73 69 67  6e 61 6c 2e 20 49 66 20  |f TV signal. If |
00000e70  44 37 20 69 73 20 6c 6f  77 0d 20 20 20 20 20 61  |D7 is low.     a|
00000e80  6e 64 20 54 54 58 20 75  6e 69 74 20 65 6e 61 62  |nd TTX unit enab|
00000e90  6c 65 64 20 74 68 65 20  54 54 58 20 75 6e 69 74  |led the TTX unit|
00000ea0  20 6c 6f 63 6b 73 20 6f  75 74 20 74 68 65 20 43  | locks out the C|
00000eb0  50 55 20 64 75 72 69 6e  67 20 74 68 69 73 20 74  |PU during this t|
00000ec0  69 6d 65 2e 0d 44 36 20  20 20 44 61 74 61 20 4f  |ime..D6   Data O|
00000ed0  76 65 72 72 75 6e 2e 20  53 65 74 20 48 69 67 68  |verrun. Set High|
00000ee0  20 69 66 20 73 74 61 74  75 73 20 69 73 20 6e 6f  | if status is no|
00000ef0  74 20 63 6c 65 61 72 65  64 20 62 65 66 6f 72 65  |t cleared before|
00000f00  20 6e 65 78 74 20 64 61  74 61 0d 20 20 20 20 20  | next data.     |
00000f10  65 6e 74 72 79 20 77 69  6e 64 6f 77 2e 0d 44 37  |entry window..D7|
00000f20  20 20 20 49 6e 74 65 72  72 75 70 74 2e 20 53 65  |   Interrupt. Se|
00000f30  74 20 48 69 67 68 20 62  79 20 74 68 65 20 74 72  |t High by the tr|
00000f40  61 69 6c 69 6e 67 20 65  64 67 65 20 6f 66 20 74  |ailing edge of t|
00000f50  68 65 20 64 61 74 61 20  65 6e 74 72 79 20 77 69  |he data entry wi|
00000f60  6e 64 6f 77 2e 0d 0d 0d  43 6f 6e 74 72 6f 6c 20  |ndow....Control |
00000f70  52 65 67 69 73 74 65 72  20 28 26 46 43 31 30 29  |Register (&FC10)|
00000f80  0d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |.---------------|
00000f90  2d 2d 2d 2d 2d 2d 2d 2d  2d 0d 0d 54 68 65 20 65  |---------..The e|
00000fa0  69 67 68 74 20 62 69 74  20 63 6f 6e 74 72 6f 6c  |ight bit control|
00000fb0  20 72 65 67 69 73 74 65  72 20 61 74 20 26 46 43  | register at &FC|
00000fc0  31 30 20 69 73 20 74 68  65 20 77 72 69 74 65 2d  |10 is the write-|
00000fd0  6f 6e 6c 79 20 63 6f 6e  74 72 6f 6c 20 72 65 67  |only control reg|
00000fe0  69 73 74 65 72 0d 6f 66  20 74 68 65 20 54 65 6c  |ister.of the Tel|
00000ff0  65 74 65 78 74 20 61 64  61 70 74 6f 72 2e 20 54  |etext adaptor. T|
00001000  68 65 20 62 69 74 73 20  6f 66 20 74 68 65 20 63  |he bits of the c|
00001010  6f 6e 74 72 6f 6c 20 72  65 67 69 73 74 65 72 20  |ontrol register |
00001020  68 61 76 65 20 74 68 65  0d 66 6f 6c 6c 6f 77 69  |have the.followi|
00001030  6e 67 20 66 75 6e 63 74  69 6f 6e 73 3a 0d 0d 44  |ng functions:..D|
00001040  30 2d 31 20 43 68 61 6e  6e 65 6c 20 6e 75 6d 62  |0-1 Channel numb|
00001050  65 72 20 28 30 2d 33 29  0d 44 32 20 20 20 54 54  |er (0-3).D2   TT|
00001060  58 20 45 6e 61 62 6c 65  2e 20 53 65 74 20 48 69  |X Enable. Set Hi|
00001070  67 68 20 74 6f 20 65 6e  61 62 6c 65 20 54 54 58  |gh to enable TTX|
00001080  20 72 65 63 65 70 74 69  6f 6e 2e 20 53 65 74 20  | reception. Set |
00001090  4c 6f 77 20 74 6f 20 61  6c 6c 6f 77 20 75 73 65  |Low to allow use|
000010a0  20 6f 66 0d 20 20 20 20  20 31 4b 20 62 79 20 63  | of.     1K by c|
000010b0  6f 6d 70 75 74 65 72 2e  20 28 31 36 2a 36 34 20  |omputer. (16*64 |
000010c0  62 79 74 65 73 29 0d 44  33 20 20 20 49 6e 74 65  |bytes).D3   Inte|
000010d0  72 72 75 70 74 20 45 6e  61 62 6c 65 2e 20 53 65  |rrupt Enable. Se|
000010e0  74 20 48 69 67 68 20 74  6f 20 65 6e 61 62 6c 65  |t High to enable|
000010f0  20 69 6e 74 65 72 72 75  70 74 73 2e 20 53 65 74  | interrupts. Set|
00001100  20 4c 6f 77 20 74 6f 20  64 69 73 61 62 6c 65 0d  | Low to disable.|
00001110  20 20 20 20 20 69 6e 74  65 72 72 75 70 74 73 2e  |     interrupts.|
00001120  20 4e 6f 20 65 66 66 65  63 74 20 6f 6e 20 77 6f  | No effect on wo|
00001130  72 6b 69 6e 67 20 6f 66  20 54 54 58 20 75 6e 69  |rking of TTX uni|
00001140  74 2e 0d 44 34 20 20 20  41 46 43 20 43 6f 6e 74  |t..D4   AFC Cont|
00001150  72 6f 6c 2e 20 53 65 74  20 4c 6f 77 20 74 6f 20  |rol. Set Low to |
00001160  64 69 73 61 62 6c 65 20  41 46 43 20 61 6e 64 20  |disable AFC and |
00001170  61 6c 6c 6f 77 20 74 75  6e 69 6e 67 2e 20 53 65  |allow tuning. Se|
00001180  74 20 48 69 67 68 20 74  6f 0d 20 20 20 20 20 65  |t High to.     e|
00001190  6e 61 62 6c 65 20 61 75  74 6f 6d 61 74 69 63 20  |nable automatic |
000011a0  66 72 65 71 75 65 6e 63  79 20 63 6f 6e 74 72 6f  |frequency contro|
000011b0  6c 2e 0d 44 35 20 20 20  53 70 61 72 65 2e 0d 44  |l..D5   Spare..D|
000011c0  36 2d 37 20 4e 6f 74 20  75 73 65 64 2c 20 6e 6f  |6-7 Not used, no|
000011d0  74 20 6c 61 74 63 68 65  64 2e 0d 0d 0d 52 6f 77  |t latched....Row|
000011e0  20 52 65 67 69 73 74 65  72 20 28 26 46 43 31 31  | Register (&FC11|
000011f0  29 0d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |).--------------|
00001200  2d 2d 2d 2d 2d 2d 0d 0d  54 68 65 20 66 6f 75 72  |------..The four|
00001210  20 62 69 74 20 72 6f 77  20 72 65 67 69 73 74 65  | bit row registe|
00001220  72 20 61 74 20 26 46 43  31 31 20 69 73 20 74 68  |r at &FC11 is th|
00001230  65 20 77 72 69 74 65 2d  6f 6e 6c 79 20 72 6f 77  |e write-only row|
00001240  20 72 65 67 69 73 74 65  72 20 6f 66 20 74 68 65  | register of the|
00001250  0d 54 65 6c 65 74 65 78  74 20 61 64 61 70 74 6f  |.Teletext adapto|
00001260  72 2e 20 54 68 65 20 62  69 74 73 20 6f 66 20 74  |r. The bits of t|
00001270  68 65 20 72 6f 77 20 72  65 67 69 73 74 65 72 20  |he row register |
00001280  68 61 76 65 20 74 68 65  20 66 6f 6c 6c 6f 77 69  |have the followi|
00001290  6e 67 0d 66 75 6e 63 74  69 6f 6e 73 3a 0d 0d 44  |ng.functions:..D|
000012a0  30 2d 33 20 54 68 69 73  20 34 20 62 69 74 20 72  |0-3 This 4 bit r|
000012b0  65 67 69 73 74 65 72 20  63 6f 6e 74 72 6f 6c 73  |egister controls|
000012c0  20 77 68 69 63 68 20 6f  66 20 74 68 65 20 31 36  | which of the 16|
000012d0  20 36 34 20 62 79 74 65  20 6c 6f 6e 67 20 72 6f  | 64 byte long ro|
000012e0  77 73 20 6f 66 20 74 68  65 0d 20 20 20 20 20 61  |ws of the.     a|
000012f0  64 61 70 74 6f 72 27 73  20 6d 65 6d 6f 72 79 20  |daptor's memory |
00001300  77 69 6c 6c 20 62 65 20  61 63 63 65 73 73 65 64  |will be accessed|
00001310  20 62 79 20 74 68 65 20  64 61 74 61 20 72 65 67  | by the data reg|
00001320  69 73 74 65 72 2e 20 53  65 74 74 69 6e 67 20 74  |ister. Setting t|
00001330  68 69 73 0d 20 20 20 20  20 72 65 67 69 73 74 65  |his.     registe|
00001340  72 20 72 65 73 65 74 73  20 74 68 65 20 63 6f 6c  |r resets the col|
00001350  75 6d 6e 20 63 6f 75 6e  74 20 28 69 6e 74 65 72  |umn count (inter|
00001360  6e 61 6c 29 20 74 6f 20  7a 65 72 6f 2e 0d 0d 0d  |nal) to zero....|
00001370  44 61 74 61 20 52 65 67  69 73 74 65 72 20 28 26  |Data Register (&|
00001380  46 43 31 32 29 0d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |FC12).----------|
00001390  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 0d 0d 54 68 65  |-----------..The|
000013a0  20 65 69 67 68 74 20 62  69 74 20 44 61 74 61 20  | eight bit Data |
000013b0  52 65 67 69 73 74 65 72  20 61 74 20 26 46 43 31  |Register at &FC1|
000013c0  32 20 69 73 20 74 68 65  20 72 65 61 64 20 61 6e  |2 is the read an|
000013d0  64 20 77 72 69 74 65 20  64 61 74 61 20 72 65 67  |d write data reg|
000013e0  69 73 74 65 72 0d 6f 66  20 74 68 65 20 54 65 6c  |ister.of the Tel|
000013f0  65 74 65 78 74 20 61 64  61 70 74 6f 72 2e 20 54  |etext adaptor. T|
00001400  68 65 20 62 69 74 73 20  6f 66 20 74 68 65 20 64  |he bits of the d|
00001410  61 74 61 20 72 65 67 69  73 74 65 72 20 68 61 76  |ata register hav|
00001420  65 20 74 68 65 20 66 6f  6c 6c 6f 77 69 6e 67 0d  |e the following.|
00001430  69 6e 74 65 72 70 72 65  74 61 74 69 6f 6e 3a 0d  |interpretation:.|
00001440  0d 44 30 2d 37 20 54 68  69 73 20 38 20 62 69 74  |.D0-7 This 8 bit|
00001450  20 72 65 67 69 73 74 65  72 20 69 73 20 75 73 65  | register is use|
00001460  64 20 74 6f 20 72 65 61  64 20 66 72 6f 6d 20 61  |d to read from a|
00001470  6e 64 20 77 72 69 74 65  20 74 6f 20 74 68 65 20  |nd write to the |
00001480  31 36 2a 36 34 20 62 79  74 65 73 0d 20 20 20 20  |16*64 bytes.    |
00001490  20 69 6e 20 74 68 65 20  54 54 58 20 61 64 61 70  | in the TTX adap|
000014a0  74 6f 72 2e 20 57 68 65  6e 20 74 68 65 20 52 6f  |tor. When the Ro|
000014b0  77 20 72 65 67 69 73 74  65 72 20 69 73 20 77 72  |w register is wr|
000014c0  69 74 74 65 6e 20 74 6f  2c 20 61 6e 20 69 6e 74  |itten to, an int|
000014d0  65 72 6e 61 6c 0d 20 20  20 20 20 63 6f 6c 75 6d  |ernal.     colum|
000014e0  6e 20 63 6f 75 6e 74 20  69 73 20 73 65 74 20 74  |n count is set t|
000014f0  6f 20 7a 65 72 6f 2e 20  45 76 65 72 79 20 74 69  |o zero. Every ti|
00001500  6d 65 20 74 68 65 20 64  61 74 61 20 72 65 67 69  |me the data regi|
00001510  73 74 65 72 20 69 73 20  72 65 61 64 20 6f 72 0d  |ster is read or.|
00001520  20 20 20 20 20 77 72 69  74 74 65 6e 20 74 6f 2c  |     written to,|
00001530  20 74 68 65 20 63 6f 6c  75 6d 6e 20 63 6f 75 6e  | the column coun|
00001540  74 20 69 73 20 69 6e 63  72 65 6d 65 6e 74 65 64  |t is incremented|
00001550  2e 20 54 68 75 73 20 73  75 63 63 65 73 73 69 76  |. Thus successiv|
00001560  65 20 72 65 61 64 73 0d  20 20 20 20 20 66 72 6f  |e reads.     fro|
00001570  6d 20 74 68 65 20 64 61  74 61 20 72 65 67 69 73  |m the data regis|
00001580  74 65 72 20 72 65 74 75  72 6e 20 73 75 63 63 65  |ter return succe|
00001590  73 73 69 76 65 20 62 79  74 65 73 20 66 72 6f 6d  |ssive bytes from|
000015a0  20 74 68 65 20 73 65 6c  65 63 74 65 64 20 72 6f  | the selected ro|
000015b0  77 2e 0d 0d 0d 53 74 61  74 75 73 20 43 6c 65 61  |w....Status Clea|
000015c0  72 20 52 65 67 69 73 74  65 72 20 28 26 46 43 31  |r Register (&FC1|
000015d0  33 29 0d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |3).-------------|
000015e0  2d 2d 2d 2d 2d 2d 2d 2d  2d 2d 2d 2d 2d 2d 2d 2d  |----------------|
000015f0  0d 0d 54 68 65 20 65 69  67 68 74 20 62 69 74 20  |..The eight bit |
00001600  73 74 61 74 75 73 20 63  6c 65 61 72 20 72 65 67  |status clear reg|
00001610  69 73 74 65 72 20 61 74  20 26 46 43 31 33 20 69  |ister at &FC13 i|
00001620  73 20 74 68 65 20 72 65  61 64 2d 61 6e 64 2d 77  |s the read-and-w|
00001630  72 69 74 65 20 63 6c 65  61 72 0d 73 74 61 74 75  |rite clear.statu|
00001640  73 20 72 65 67 69 73 74  65 72 20 6f 66 20 74 68  |s register of th|
00001650  65 20 54 65 6c 65 74 65  78 74 20 61 64 61 70 74  |e Teletext adapt|
00001660  6f 72 2e 20 54 68 65 20  62 69 74 73 20 6f 66 20  |or. The bits of |
00001670  74 68 65 20 63 6c 65 61  72 20 73 74 61 74 75 73  |the clear status|
00001680  0d 72 65 67 69 73 74 65  72 20 68 61 76 65 20 74  |.register have t|
00001690  68 65 20 66 6f 6c 6c 6f  77 69 6e 67 20 69 6e 74  |he following int|
000016a0  65 72 70 72 65 74 61 74  69 6f 6e 3a 0d 0d 44 30  |erpretation:..D0|
000016b0  2d 37 20 52 65 61 64 69  6e 67 20 6f 72 20 77 72  |-7 Reading or wr|
000016c0  69 74 69 6e 67 20 74 6f  20 74 68 69 73 20 72 65  |iting to this re|
000016d0  67 69 73 74 65 72 20 63  6c 65 61 72 73 20 74 68  |gister clears th|
000016e0  65 20 73 74 61 74 75 73  20 66 6c 61 67 73 2e 20  |e status flags. |
000016f0  54 68 69 73 0d 20 20 20  20 20 6d 75 73 74 20 62  |This.     must b|
00001700  65 20 64 6f 6e 65 20 61  74 20 74 68 65 20 65 6e  |e done at the en|
00001710  64 20 6f 66 20 61 6e 79  20 64 61 74 61 20 63 6f  |d of any data co|
00001720  6c 6c 65 63 74 69 6f 6e  20 72 6f 75 74 69 6e 65  |llection routine|
00001730  2c 20 6f 74 68 65 72 77  69 73 65 20 74 68 65 0d  |, otherwise the.|
00001740  20 20 20 20 20 44 61 74  61 20 4f 76 65 72 72 75  |     Data Overru|
00001750  6e 20 66 6c 61 67 20 77  69 6c 6c 20 62 65 20 73  |n flag will be s|
00001760  65 74 20 28 62 69 74 20  36 20 6f 66 20 74 68 65  |et (bit 6 of the|
00001770  20 73 74 61 74 75 73 20  72 65 67 69 73 74 65 72  | status register|
00001780  29 2e 0d 0d 0d 0d 57 68  65 6e 20 79 6f 75 20 64  |).....When you d|
00001790  65 73 69 67 6e 20 70 72  6f 67 72 61 6d 73 20 77  |esign programs w|
000017a0  68 69 63 68 20 62 79 70  61 73 73 20 74 68 65 20  |hich bypass the |
000017b0  41 54 53 20 52 4f 4d 20  61 6e 64 20 69 6e 74 65  |ATS ROM and inte|
000017c0  72 66 61 63 65 20 64 69  72 65 63 74 6c 79 0d 77  |rface directly.w|
000017d0  69 74 68 20 74 68 65 20  54 65 6c 65 74 65 78 74  |ith the Teletext|
000017e0  20 68 61 72 64 77 61 72  65 20 69 74 20 69 73 20  | hardware it is |
000017f0  61 20 67 6f 6f 64 20 69  64 65 61 20 74 6f 20 63  |a good idea to c|
00001800  6f 6e 73 69 64 65 72 20  75 73 69 6e 67 20 65 69  |onsider using ei|
00001810  74 68 65 72 20 61 0d 42  41 53 49 43 20 6f 72 20  |ther a.BASIC or |
00001820  61 20 6d 61 63 68 69 6e  65 20 63 6f 64 65 20 66  |a machine code f|
00001830  6f 72 65 67 72 6f 75 6e  64 20 74 61 73 6b 20 74  |oreground task t|
00001840  6f 20 75 70 64 61 74 65  20 74 68 65 20 73 63 72  |o update the scr|
00001850  65 65 6e 20 61 6e 64 20  61 6e 0d 69 6e 74 65 72  |een and an.inter|
00001860  72 75 70 74 20 64 72 69  76 65 6e 20 6d 61 63 68  |rupt driven mach|
00001870  69 6e 65 20 63 6f 64 65  20 62 61 63 6b 67 72 6f  |ine code backgro|
00001880  75 6e 64 20 74 61 73 6b  20 74 6f 20 70 72 6f 63  |und task to proc|
00001890  65 73 73 20 74 68 65 20  54 65 6c 65 74 65 78 74  |ess the Teletext|
000018a0  0d 69 6e 74 65 72 72 75  70 74 73 2e 20 54 68 69  |.interrupts. Thi|
000018b0  73 20 74 79 70 65 20 6f  66 20 64 65 73 69 67 6e  |s type of design|
000018c0  20 77 69 6c 6c 20 62 65  20 75 73 65 64 20 69 6e  | will be used in|
000018d0  20 61 6c 6c 20 74 68 65  20 70 72 6f 67 72 61 6d  | all the program|
000018e0  73 20 75 73 65 64 20 74  6f 0d 69 6c 6c 75 73 74  |s used to.illust|
000018f0  72 61 74 65 20 74 68 65  20 54 65 6c 65 74 65 78  |rate the Teletex|
00001900  74 20 6d 6f 64 75 6c 65  73 20 31 20 74 6f 20 37  |t modules 1 to 7|
00001910  2e 0d 0d 54 68 65 20 65  78 61 6d 70 6c 65 20 70  |...The example p|
00001920  72 6f 67 72 61 6d 20 61  73 73 6f 63 69 61 74 65  |rogram associate|
00001930  64 20 77 69 74 68 20 74  68 69 73 20 6d 6f 64 75  |d with this modu|
00001940  6c 65 20 73 68 6f 77 73  20 79 6f 75 20 68 6f 77  |le shows you how|
00001950  20 74 6f 20 72 65 2d 64  69 72 65 63 74 0d 74 68  | to re-direct.th|
00001960  65 20 49 52 51 32 56 20  76 65 63 74 6f 72 20 74  |e IRQ2V vector t|
00001970  6f 20 70 6f 69 6e 74 20  74 6f 20 61 6e 20 69 6e  |o point to an in|
00001980  74 65 72 72 75 70 74 20  68 61 6e 64 6c 69 6e 67  |terrupt handling|
00001990  20 72 6f 75 74 69 6e 65  20 61 6e 64 20 68 6f 77  | routine and how|
000019a0  20 74 68 61 74 0d 72 6f  75 74 69 6e 65 20 63 61  | that.routine ca|
000019b0  6e 20 72 65 63 6f 67 6e  69 73 65 20 61 6e 64 20  |n recognise and |
000019c0  70 72 6f 63 65 73 73 20  54 65 6c 65 74 65 78 74  |process Teletext|
000019d0  20 67 65 6e 65 72 61 74  65 64 20 69 6e 74 65 72  | generated inter|
000019e0  72 75 70 74 73 2e 20 54  68 65 0d 70 72 6f 67 72  |rupts. The.progr|
000019f0  61 6d 20 43 4f 55 4e 54  45 52 20 69 73 20 70 65  |am COUNTER is pe|
00001a00  72 68 61 70 73 20 74 68  65 20 6d 6f 73 74 20 73  |rhaps the most s|
00001a10  69 6d 70 6c 65 20 74 79  70 65 20 6f 66 20 69 6e  |imple type of in|
00001a20  74 65 72 72 75 70 74 20  70 72 6f 63 65 73 73 69  |terrupt processi|
00001a30  6e 67 0d 70 6f 73 73 69  62 6c 65 20 77 69 74 68  |ng.possible with|
00001a40  20 74 68 65 20 54 65 6c  65 74 65 78 74 20 61 64  | the Teletext ad|
00001a50  61 70 74 6f 72 2e 20 54  68 65 20 70 72 6f 67 72  |aptor. The progr|
00001a60  61 6d 20 72 65 63 6f 67  6e 69 73 65 73 20 54 65  |am recognises Te|
00001a70  6c 65 74 65 78 74 0d 69  6e 74 65 72 72 75 70 74  |letext.interrupt|
00001a80  73 20 61 6e 64 20 63 6f  75 6e 74 73 20 68 6f 77  |s and counts how|
00001a90  20 6d 61 6e 79 20 69 6e  74 65 72 72 75 70 74 73  | many interrupts|
00001aa0  20 61 72 65 20 67 65 6e  65 72 61 74 65 64 20 77  | are generated w|
00001ab0  68 69 6c 65 20 74 68 65  20 70 72 6f 67 72 61 6d  |hile the program|
00001ac0  0d 69 73 20 61 63 74 69  76 65 2e 20 57 68 65 6e  |.is active. When|
00001ad0  20 74 68 65 20 65 73 63  61 70 65 20 6b 65 79 20  | the escape key |
00001ae0  69 73 20 70 72 65 73 73  65 64 20 74 68 65 20 70  |is pressed the p|
00001af0  72 6f 67 72 61 6d 20 63  61 6c 63 75 6c 61 74 65  |rogram calculate|
00001b00  73 20 74 68 65 20 72 61  74 65 0d 61 74 20 77 68  |s the rate.at wh|
00001b10  69 63 68 20 74 68 65 20  69 6e 74 65 72 72 75 70  |ich the interrup|
00001b20  74 73 20 68 61 76 65 20  62 65 65 6e 20 67 65 6e  |ts have been gen|
00001b30  65 72 61 74 65 64 2e 0d  0d 54 68 65 20 70 72 6f  |erated...The pro|
00001b40  67 72 61 6d 20 43 4f 55  4e 54 45 52 20 75 73 65  |gram COUNTER use|
00001b50  73 20 42 41 53 49 43 20  74 6f 20 61 73 73 65 6d  |s BASIC to assem|
00001b60  62 6c 65 20 61 6e 64 20  63 61 6c 6c 20 61 20 6d  |ble and call a m|
00001b70  61 63 68 69 6e 65 20 63  6f 64 65 0d 70 72 6f 67  |achine code.prog|
00001b80  72 61 6d 2e 20 54 68 65  20 6d 61 63 68 69 6e 65  |ram. The machine|
00001b90  20 63 6f 64 65 20 63 61  6e 20 62 65 20 64 69 76  | code can be div|
00001ba0  69 64 65 64 20 69 6e 74  6f 20 61 20 66 6f 72 65  |ided into a fore|
00001bb0  67 72 6f 75 6e 64 20 74  61 73 6b 20 28 6c 69 6e  |ground task (lin|
00001bc0  65 73 20 35 30 30 0d 74  6f 20 36 36 30 29 2c 20  |es 500.to 660), |
00001bd0  77 68 69 63 68 20 70 72  69 6e 74 73 20 74 68 65  |which prints the|
00001be0  20 63 6f 6e 74 65 6e 74  73 20 6f 66 20 61 20 66  | contents of a f|
00001bf0  6f 75 72 20 62 79 74 65  20 64 65 63 69 6d 61 6c  |our byte decimal|
00001c00  20 63 6f 75 6e 74 65 72  2c 20 61 6e 64 20 61 0d  | counter, and a.|
00001c10  62 61 63 6b 67 72 6f 75  6e 64 20 74 61 73 6b 20  |background task |
00001c20  28 6c 69 6e 65 73 20 37  38 30 20 74 6f 20 31 31  |(lines 780 to 11|
00001c30  37 30 29 2c 20 77 68 69  63 68 20 70 72 6f 63 65  |70), which proce|
00001c40  73 73 65 73 20 74 68 65  20 54 65 6c 65 74 65 78  |sses the Teletex|
00001c50  74 0d 67 65 6e 65 72 61  74 65 64 20 69 6e 74 65  |t.generated inte|
00001c60  72 72 75 70 74 73 2e 20  54 68 69 73 20 70 72 6f  |rrupts. This pro|
00001c70  67 72 61 6d 20 69 6c 6c  75 73 74 72 61 74 65 73  |gram illustrates|
00001c80  20 68 6f 77 20 74 68 65  20 63 6f 6e 74 72 6f 6c  | how the control|
00001c90  20 72 65 67 69 73 74 65  72 20 69 73 0d 75 73 65  | register is.use|
00001ca0  64 20 74 6f 20 65 6e 61  62 6c 65 20 74 68 65 20  |d to enable the |
00001cb0  54 65 6c 65 74 65 78 74  20 61 64 61 70 74 6f 72  |Teletext adaptor|
00001cc0  20 61 6e 64 20 73 65 6c  65 63 74 20 61 20 54 56  | and select a TV|
00001cd0  20 63 68 61 6e 6e 65 6c  2c 20 61 6e 64 20 61 6c  | channel, and al|
00001ce0  73 6f 20 68 6f 77 0d 74  68 65 20 63 6c 65 61 72  |so how.the clear|
00001cf0  20 73 74 61 74 75 73 20  72 65 67 69 73 74 65 72  | status register|
00001d00  20 6d 75 73 74 20 62 65  20 75 73 65 64 20 61 66  | must be used af|
00001d10  74 65 72 20 70 72 6f 63  65 73 73 69 6e 67 20 65  |ter processing e|
00001d20  76 65 72 79 20 54 65 6c  65 74 65 78 74 0d 69 6e  |very Teletext.in|
00001d30  74 65 72 72 75 70 74 2e  0d 0d 42 69 74 73 20 30  |terrupt...Bits 0|
00001d40  20 74 6f 20 34 20 6f 66  20 74 68 65 20 63 6f 6e  | to 4 of the con|
00001d50  74 72 6f 6c 20 72 65 67  69 73 74 65 72 20 61 72  |trol register ar|
00001d60  65 20 75 73 65 64 20 74  6f 20 65 6e 61 62 6c 65  |e used to enable|
00001d70  20 74 68 65 20 54 65 6c  65 74 65 78 74 0d 61 64  | the Teletext.ad|
00001d80  61 70 74 6f 72 20 61 6e  64 20 73 65 6c 65 63 74  |aptor and select|
00001d90  20 74 68 65 20 72 65 71  75 69 72 65 64 20 63 68  | the required ch|
00001da0  61 6e 6e 65 6c 2e 20 42  69 74 73 20 30 20 61 6e  |annel. Bits 0 an|
00001db0  64 20 31 20 61 72 65 20  75 73 65 64 20 74 6f 20  |d 1 are used to |
00001dc0  73 65 6c 65 63 74 0d 74  68 65 20 63 68 61 6e 6e  |select.the chann|
00001dd0  65 6c 2c 20 62 69 74 20  32 20 69 73 20 73 65 74  |el, bit 2 is set|
00001de0  20 68 69 67 68 20 74 6f  20 65 6e 61 62 6c 65 20  | high to enable |
00001df0  54 65 6c 65 74 65 78 74  20 72 65 63 65 70 74 69  |Teletext recepti|
00001e00  6f 6e 2c 20 62 69 74 20  33 20 69 73 20 73 65 74  |on, bit 3 is set|
00001e10  0d 68 69 67 68 20 74 6f  20 65 6e 61 62 6c 65 20  |.high to enable |
00001e20  54 65 6c 65 74 65 78 74  20 67 65 6e 65 72 61 74  |Teletext generat|
00001e30  65 64 20 69 6e 74 65 72  72 75 70 74 73 20 61 6e  |ed interrupts an|
00001e40  64 20 62 69 74 20 34 20  69 73 20 73 65 74 20 68  |d bit 4 is set h|
00001e50  69 67 68 20 74 6f 0d 65  6e 61 62 6c 65 20 74 68  |igh to.enable th|
00001e60  65 20 61 75 74 6f 6d 61  74 69 63 20 66 72 65 71  |e automatic freq|
00001e70  75 65 6e 63 79 20 63 6f  6e 74 72 6f 6c 2e 20 57  |uency control. W|
00001e80  68 65 6e 20 79 6f 75 20  75 73 65 20 74 68 65 20  |hen you use the |
00001e90  63 6f 6e 74 72 6f 6c 20  72 65 67 69 73 74 65 72  |control register|
00001ea0  0d 74 6f 20 65 6e 61 62  6c 65 20 74 68 65 20 54  |.to enable the T|
00001eb0  65 6c 65 74 65 78 74 20  61 64 61 70 74 6f 72 20  |eletext adaptor |
00001ec0  79 6f 75 20 77 69 6c 6c  20 6f 6e 6c 79 20 6e 6f  |you will only no|
00001ed0  72 6d 61 6c 6c 79 20 77  72 69 74 65 20 6f 6e 65  |rmally write one|
00001ee0  20 6f 66 20 66 6f 75 72  0d 76 61 6c 75 65 73 20  | of four.values |
00001ef0  74 6f 20 74 68 65 20 72  65 67 69 73 74 65 72 2e  |to the register.|
00001f00  20 54 68 65 73 65 20 6e  75 6d 62 65 72 73 20 61  | These numbers a|
00001f10  72 65 20 69 6e 20 74 68  65 20 72 61 6e 67 65 20  |re in the range |
00001f20  66 72 6f 6d 20 26 31 43  20 74 6f 20 26 31 46 2e  |from &1C to &1F.|
00001f30  0d 0d 0d 20 20 26 31 43  20 25 30 30 30 31 31 31  |...  &1C %000111|
00001f40  30 30 20 45 6e 61 62 6c  65 20 41 46 43 2c 20 65  |00 Enable AFC, e|
00001f50  6e 61 62 6c 65 20 69 6e  74 65 72 72 75 70 74 73  |nable interrupts|
00001f60  2c 20 65 6e 61 62 6c 65  20 54 54 58 2c 20 63 68  |, enable TTX, ch|
00001f70  61 6e 6e 65 6c 20 30 0d  20 20 26 31 44 20 25 30  |annel 0.  &1D %0|
00001f80  30 30 31 31 31 30 31 20  45 6e 61 62 6c 65 20 41  |0011101 Enable A|
00001f90  46 43 2c 20 65 6e 61 62  6c 65 20 69 6e 74 65 72  |FC, enable inter|
00001fa0  72 75 70 74 73 2c 20 65  6e 61 62 6c 65 20 54 54  |rupts, enable TT|
00001fb0  58 2c 20 63 68 61 6e 6e  65 6c 20 31 0d 20 20 26  |X, channel 1.  &|
00001fc0  31 45 20 25 30 30 30 31  31 31 31 30 20 45 6e 61  |1E %00011110 Ena|
00001fd0  62 6c 65 20 41 46 43 2c  20 65 6e 61 62 6c 65 20  |ble AFC, enable |
00001fe0  69 6e 74 65 72 72 75 70  74 73 2c 20 65 6e 61 62  |interrupts, enab|
00001ff0  6c 65 20 54 54 58 2c 20  63 68 61 6e 6e 65 6c 20  |le TTX, channel |
00002000  32 0d 20 20 26 31 46 20  25 30 30 30 31 31 31 31  |2.  &1F %0001111|
00002010  31 20 45 6e 61 62 6c 65  20 41 46 43 2c 20 65 6e  |1 Enable AFC, en|
00002020  61 62 6c 65 20 69 6e 74  65 72 72 75 70 74 73 2c  |able interrupts,|
00002030  20 65 6e 61 62 6c 65 20  54 54 58 2c 20 63 68 61  | enable TTX, cha|
00002040  6e 6e 65 6c 20 33 0d 0d  0d 4f 6e 65 20 6f 66 20  |nnel 3...One of |
00002050  74 68 65 73 65 20 66 6f  75 72 20 76 61 6c 75 65  |these four value|
00002060  73 20 69 73 20 73 65 6c  65 63 74 65 64 20 69 6e  |s is selected in|
00002070  20 6c 69 6e 65 73 20 38  30 20 74 6f 20 31 32 30  | lines 80 to 120|
00002080  20 61 6e 64 20 77 72 69  74 74 65 6e 20 74 6f 0d  | and written to.|
00002090  74 68 65 20 63 6f 6e 74  72 6f 6c 20 72 65 67 69  |the control regi|
000020a0  73 74 65 72 20 69 6e 20  6c 69 6e 65 73 20 34 38  |ster in lines 48|
000020b0  30 20 61 6e 64 20 34 39  30 20 6f 66 20 43 4f 55  |0 and 490 of COU|
000020c0  4e 54 45 52 2e 20 54 68  65 20 54 65 6c 65 74 65  |NTER. The Telete|
000020d0  78 74 20 61 64 61 70 74  6f 72 0d 69 73 20 64 69  |xt adaptor.is di|
000020e0  73 61 62 6c 65 64 20 62  79 20 77 72 69 74 69 6e  |sabled by writin|
000020f0  67 20 74 68 65 20 76 61  6c 75 65 20 26 30 30 20  |g the value &00 |
00002100  74 6f 20 74 68 65 20 63  6f 6e 74 72 6f 6c 20 72  |to the control r|
00002110  65 67 69 73 74 65 72 20  28 6c 69 6e 65 73 20 36  |egister (lines 6|
00002120  39 30 0d 61 6e 64 20 37  30 30 29 2e 20 41 6c 6c  |90.and 700). All|
00002130  20 74 68 65 20 64 65 6d  6f 6e 73 74 72 61 74 69  | the demonstrati|
00002140  6f 6e 20 70 72 6f 67 72  61 6d 73 20 69 6e 20 74  |on programs in t|
00002150  68 65 20 41 63 6f 72 6e  20 54 65 6c 65 74 65 78  |he Acorn Teletex|
00002160  74 20 6d 6f 64 75 6c 65  73 0d 77 69 6c 6c 20 70  |t modules.will p|
00002170  72 6f 6d 70 74 20 66 6f  72 20 61 20 63 68 61 6e  |rompt for a chan|
00002180  6e 65 6c 20 6e 75 6d 62  65 72 20 69 6e 20 74 68  |nel number in th|
00002190  65 20 72 61 6e 67 65 20  66 72 6f 6d 20 31 20 74  |e range from 1 t|
000021a0  6f 20 34 20 65 76 65 6e  20 74 68 6f 75 67 68 20  |o 4 even though |
000021b0  74 68 65 0d 61 64 61 70  74 6f 72 20 75 73 65 73  |the.adaptor uses|
000021c0  20 63 68 61 6e 6e 65 6c  20 6e 75 6d 62 65 72 73  | channel numbers|
000021d0  20 30 20 74 6f 20 33 2e  20 49 74 20 73 65 65 6d  | 0 to 3. It seem|
000021e0  73 20 74 6f 20 62 65 20  73 65 6e 73 69 62 6c 65  |s to be sensible|
000021f0  20 74 6f 20 75 73 65 20  74 68 65 0d 72 61 6e 67  | to use the.rang|
00002200  65 20 31 20 74 6f 20 34  20 77 68 69 63 68 20 63  |e 1 to 4 which c|
00002210  6f 72 72 65 73 70 6f 6e  64 73 20 77 69 74 68 20  |orresponds with |
00002220  42 42 43 31 2c 20 42 42  43 32 20 61 6e 64 20 43  |BBC1, BBC2 and C|
00002230  68 61 6e 6e 65 6c 20 34  20 62 65 74 74 65 72 20  |hannel 4 better |
00002240  74 68 61 6e 0d 74 68 65  20 72 61 6e 67 65 20 30  |than.the range 0|
00002250  20 74 6f 20 33 2e 20 46  6f 72 20 74 68 69 73 20  | to 3. For this |
00002260  72 65 61 73 6f 6e 20 74  68 65 20 6e 75 6d 62 65  |reason the numbe|
00002270  72 20 26 31 42 20 28 6e  6f 74 20 26 31 43 29 20  |r &1B (not &1C) |
00002280  69 73 20 61 64 64 65 64  20 74 6f 20 74 68 65 0d  |is added to the.|
00002290  63 68 61 6e 6e 65 6c 20  6e 75 6d 62 65 72 20 69  |channel number i|
000022a0  6e 20 6c 69 6e 65 20 31  30 30 20 74 6f 20 67 69  |n line 100 to gi|
000022b0  76 65 20 74 68 65 20 72  65 71 75 69 72 65 64 20  |ve the required |
000022c0  72 61 6e 67 65 20 6f 66  20 76 61 6c 75 65 73 20  |range of values |
000022d0  66 6f 72 20 74 68 65 0d  63 6f 6e 74 72 6f 6c 20  |for the.control |
000022e0  72 65 67 69 73 74 65 72  2e 0d 0d 41 6e 20 69 6e  |register...An in|
000022f0  74 65 72 72 75 70 74 20  67 65 6e 65 72 61 74 65  |terrupt generate|
00002300  64 20 62 79 20 74 68 65  20 54 65 6c 65 74 65 78  |d by the Teletex|
00002310  74 20 61 64 61 70 74 6f  72 20 63 61 6e 20 62 65  |t adaptor can be|
00002320  20 72 65 63 6f 67 6e 69  73 65 64 20 62 79 0d 70  | recognised by.p|
00002330  6f 6c 6c 69 6e 67 20 74  68 65 20 73 74 61 74 75  |olling the statu|
00002340  73 20 72 65 67 69 73 74  65 72 2e 20 42 69 74 20  |s register. Bit |
00002350  37 20 6f 66 20 74 68 65  20 73 74 61 74 75 73 20  |7 of the status |
00002360  72 65 67 69 73 74 65 72  20 69 73 20 73 65 74 20  |register is set |
00002370  77 68 65 6e 20 74 68 65  0d 54 65 6c 65 74 65 78  |when the.Teletex|
00002380  74 20 61 64 61 70 74 6f  72 20 67 65 6e 65 72 61  |t adaptor genera|
00002390  74 65 73 20 61 6e 20 69  6e 74 65 72 72 75 70 74  |tes an interrupt|
000023a0  2e 20 54 68 65 20 70 72  6f 67 72 61 6d 20 43 4f  |. The program CO|
000023b0  55 4e 54 45 52 20 69 6e  74 65 72 63 65 70 74 73  |UNTER intercepts|
000023c0  0d 61 6c 6c 20 75 6e 72  65 63 6f 67 6e 69 73 65  |.all unrecognise|
000023d0  64 20 6d 61 73 6b 61 62  6c 65 20 69 6e 74 65 72  |d maskable inter|
000023e0  72 75 70 74 73 20 6f 66  66 65 72 65 64 20 74 6f  |rupts offered to|
000023f0  20 74 68 65 20 49 52 51  32 20 76 65 63 74 6f 72  | the IRQ2 vector|
00002400  20 61 6e 64 20 70 6f 6c  6c 73 0d 74 68 65 20 73  | and polls.the s|
00002410  74 61 74 75 73 20 72 65  67 69 73 74 65 72 20 28  |tatus register (|
00002420  6c 69 6e 65 20 37 39 30  29 20 74 6f 20 73 65 65  |line 790) to see|
00002430  20 69 66 20 74 68 65 20  54 65 6c 65 74 65 78 74  | if the Teletext|
00002440  20 61 64 61 70 74 6f 72  20 77 61 73 20 74 68 65  | adaptor was the|
00002450  0d 73 6f 75 72 63 65 20  6f 66 20 74 68 65 20 75  |.source of the u|
00002460  6e 72 65 63 6f 67 6e 69  73 65 64 20 69 6e 74 65  |nrecognised inte|
00002470  72 72 75 70 74 2e 20 49  66 20 74 68 65 20 61 64  |rrupt. If the ad|
00002480  61 70 74 6f 72 20 77 61  73 20 6e 6f 74 20 74 68  |aptor was not th|
00002490  65 20 73 6f 75 72 63 65  20 6f 66 0d 74 68 65 20  |e source of.the |
000024a0  69 6e 74 65 72 72 75 70  74 20 69 74 20 69 73 20  |interrupt it is |
000024b0  70 61 73 73 65 64 20 6f  6e 20 74 6f 20 74 68 65  |passed on to the|
000024c0  20 6f 72 69 67 69 6e 61  6c 20 69 6e 74 65 72 72  | original interr|
000024d0  75 70 74 20 68 61 6e 64  6c 69 6e 67 20 72 6f 75  |upt handling rou|
000024e0  74 69 6e 65 0d 28 6c 69  6e 65 20 38 31 30 29 2e  |tine.(line 810).|
000024f0  20 49 66 20 74 68 65 20  61 64 61 70 74 6f 72 20  | If the adaptor |
00002500  77 61 73 20 74 68 65 20  73 6f 75 72 63 65 20 6f  |was the source o|
00002510  66 20 74 68 65 20 69 6e  74 65 72 72 75 70 74 20  |f the interrupt |
00002520  69 74 20 69 73 20 70 72  6f 63 65 73 73 65 64 0d  |it is processed.|
00002530  62 79 20 74 68 65 20 70  72 6f 67 72 61 6d 20 61  |by the program a|
00002540  6e 64 20 61 20 72 65 74  75 72 6e 20 69 73 20 6d  |nd a return is m|
00002550  61 64 65 20 75 73 69 6e  67 20 61 6e 20 52 54 49  |ade using an RTI|
00002560  20 69 6e 73 74 72 75 63  74 69 6f 6e 20 28 6c 69  | instruction (li|
00002570  6e 65 20 31 31 37 30 29  2e 0d 0d 42 65 66 6f 72  |ne 1170)...Befor|
00002580  65 20 72 65 74 75 72 6e  69 6e 67 20 66 72 6f 6d  |e returning from|
00002590  20 61 20 54 65 6c 65 74  65 78 74 20 67 65 6e 65  | a Teletext gene|
000025a0  72 61 74 65 64 20 69 6e  74 65 72 72 75 70 74 20  |rated interrupt |
000025b0  69 74 20 69 73 20 65 73  73 65 6e 74 69 61 6c 20  |it is essential |
000025c0  74 6f 0d 63 6c 65 61 72  20 61 6c 6c 20 31 36 20  |to.clear all 16 |
000025d0  72 6f 77 73 20 69 6e 20  74 68 65 20 54 65 6c 65  |rows in the Tele|
000025e0  74 65 78 74 20 61 64 61  70 74 6f 72 20 62 79 20  |text adaptor by |
000025f0  73 65 6c 65 63 74 69 6e  67 20 65 61 63 68 20 72  |selecting each r|
00002600  6f 77 20 61 6e 64 0d 77  72 69 74 69 6e 67 20 74  |ow and.writing t|
00002610  68 65 20 6e 75 6d 62 65  72 20 7a 65 72 6f 20 74  |he number zero t|
00002620  6f 20 74 68 65 20 61 64  61 70 74 6f 72 20 28 6c  |o the adaptor (l|
00002630  69 6e 65 73 20 31 30 33  30 20 74 6f 20 31 30 39  |ines 1030 to 109|
00002640  30 29 2e 20 41 20 72 6f  77 20 69 73 0d 73 65 6c  |0). A row is.sel|
00002650  65 63 74 65 64 20 62 79  20 77 72 69 74 69 6e 67  |ected by writing|
00002660  20 74 68 65 20 72 6f 77  20 6e 75 6d 62 65 72 20  | the row number |
00002670  69 6e 74 6f 20 74 68 65  20 72 6f 77 20 72 65 67  |into the row reg|
00002680  69 73 74 65 72 20 61 6e  64 20 74 68 65 20 72 6f  |ister and the ro|
00002690  77 20 69 73 0d 63 6c 65  61 72 65 64 20 62 79 20  |w is.cleared by |
000026a0  73 74 6f 72 69 6e 67 20  7a 65 72 6f 20 69 6e 20  |storing zero in |
000026b0  74 68 65 20 66 69 72 73  74 20 61 76 61 69 6c 61  |the first availa|
000026c0  62 6c 65 20 62 79 74 65  20 69 6e 20 74 68 65 20  |ble byte in the |
000026d0  72 6f 77 2e 20 54 68 69  73 20 62 79 74 65 0d 69  |row. This byte.i|
000026e0  73 20 63 61 6c 6c 65 64  20 74 68 65 20 66 72 61  |s called the fra|
000026f0  6d 69 6e 67 20 63 6f 64  65 20 61 6e 64 20 77 69  |ming code and wi|
00002700  6c 6c 20 62 65 20 65 78  70 6c 61 69 6e 65 64 20  |ll be explained |
00002710  69 6e 20 64 65 74 61 69  6c 20 69 6e 20 6d 6f 64  |in detail in mod|
00002720  75 6c 65 20 32 2e 0d 41  66 74 65 72 20 63 6c 65  |ule 2..After cle|
00002730  61 72 69 6e 67 20 74 68  65 20 61 64 61 70 74 6f  |aring the adapto|
00002740  72 20 6d 65 6d 6f 72 79  2c 20 69 74 20 69 73 20  |r memory, it is |
00002750  61 6c 73 6f 20 6e 65 63  65 73 73 61 72 79 20 74  |also necessary t|
00002760  6f 20 65 69 74 68 65 72  20 72 65 61 64 0d 66 72  |o either read.fr|
00002770  6f 6d 20 6f 72 20 77 72  69 74 65 20 74 6f 20 74  |om or write to t|
00002780  68 65 20 73 74 61 74 75  73 20 63 6c 65 61 72 20  |he status clear |
00002790  72 65 67 69 73 74 65 72  20 74 6f 20 63 6c 65 61  |register to clea|
000027a0  72 20 74 68 65 20 73 74  61 74 75 73 20 66 6c 61  |r the status fla|
000027b0  67 73 20 28 6c 69 6e 65  0d 31 31 30 30 29 2e 20  |gs (line.1100). |
000027c0  41 6c 6c 20 54 65 6c 65  74 65 78 74 20 70 72 6f  |All Teletext pro|
000027d0  63 65 73 73 69 6e 67 20  72 6f 75 74 69 6e 65 73  |cessing routines|
000027e0  20 6d 75 73 74 20 64 6f  20 74 68 69 73 20 62 65  | must do this be|
000027f0  66 6f 72 65 20 72 65 74  75 72 6e 69 6e 67 20 66  |fore returning f|
00002800  72 6f 6d 0d 61 6e 20 69  6e 74 65 72 72 75 70 74  |rom.an interrupt|
00002810  2e 20 46 61 69 6c 75 72  65 20 74 6f 20 64 6f 20  |. Failure to do |
00002820  73 6f 20 77 69 6c 6c 20  70 72 6f 64 75 63 65 20  |so will produce |
00002830  61 20 64 61 74 61 20 6f  76 65 72 72 75 6e 20 65  |a data overrun e|
00002840  72 72 6f 72 2e 0d 0d 42  65 66 6f 72 65 20 63 68  |rror...Before ch|
00002850  61 69 6e 69 6e 67 20 74  68 65 20 70 72 6f 67 72  |aining the progr|
00002860  61 6d 20 43 4f 55 4e 54  45 52 20 79 6f 75 20 63  |am COUNTER you c|
00002870  61 6e 20 64 69 73 61 62  6c 65 20 74 68 65 20 41  |an disable the A|
00002880  54 53 20 52 4f 4d 20 62  79 20 74 79 70 69 6e 67  |TS ROM by typing|
00002890  0d 74 68 65 20 63 6f 6d  6d 61 6e 64 20 2a 4e 4f  |.the command *NO|
000028a0  54 54 58 2e 20 54 68 69  73 20 73 68 6f 75 6c 64  |TTX. This should|
000028b0  20 63 6f 6e 76 69 6e 63  65 20 73 63 65 70 74 69  | convince scepti|
000028c0  63 73 20 74 68 61 74 20  74 68 65 20 70 72 6f 67  |cs that the prog|
000028d0  72 61 6d 20 69 73 0d 63  6f 6d 70 6c 65 74 65 6c  |ram is.completel|
000028e0  79 20 69 6e 64 65 70 65  6e 64 61 6e 74 20 6f 66  |y independant of|
000028f0  20 74 68 65 20 41 54 53  2e 20 49 74 20 69 73 20  | the ATS. It is |
00002900  6e 6f 74 20 6e 65 63 65  73 73 61 72 79 20 74 6f  |not necessary to|
00002910  20 64 69 73 61 62 6c 65  20 74 68 65 20 41 54 53  | disable the ATS|
00002920  0d 69 6e 20 74 68 69 73  20 77 61 79 20 74 6f 20  |.in this way to |
00002930  75 73 65 20 61 6e 79 20  6f 66 20 74 68 65 20 64  |use any of the d|
00002940  65 6d 6f 6e 73 74 72 61  74 69 6f 6e 20 70 72 6f  |emonstration pro|
00002950  67 72 61 6d 73 20 77 69  74 68 20 74 68 65 20 41  |grams with the A|
00002960  63 6f 72 6e 0d 61 64 61  70 74 6f 72 20 62 65 63  |corn.adaptor bec|
00002970  61 75 73 65 20 74 68 65  20 41 54 53 20 73 68 6f  |ause the ATS sho|
00002980  75 6c 64 20 6e 6f 74 20  69 6e 74 65 72 66 65 72  |uld not interfer|
00002990  65 20 77 69 74 68 20 74  68 65 6d 20 69 6e 20 61  |e with them in a|
000029a0  6e 79 20 77 61 79 20 62  75 74 2c 20 69 66 0d 79  |ny way but, if.y|
000029b0  6f 75 20 68 61 76 65 20  61 20 73 69 64 65 77 61  |ou have a sidewa|
000029c0  79 73 20 52 41 4d 20 2f  20 73 68 61 64 6f 77 20  |ys RAM / shadow |
000029d0  52 41 4d 20 62 6f 61 72  64 20 69 6e 73 74 61 6c  |RAM board instal|
000029e0  6c 65 64 20 69 6e 20 61  20 42 42 43 20 42 20 63  |led in a BBC B c|
000029f0  6f 6d 70 75 74 65 72 2c  0d 79 6f 75 20 6d 61 79  |omputer,.you may|
00002a00  20 68 61 76 65 20 74 6f  20 75 73 65 20 2a 4e 4f  | have to use *NO|
00002a10  54 54 58 20 61 6e 64 20  61 6c 74 65 72 20 69 72  |TTX and alter ir|
00002a20  71 32 76 20 74 6f 20 69  72 71 31 76 20 74 6f 20  |q2v to irq1v to |
00002a30  67 65 74 20 74 68 65 20  70 72 6f 67 72 61 6d 20  |get the program |
00002a40  74 6f 0d 77 6f 72 6b 2e  20 49 66 20 79 6f 75 20  |to.work. If you |
00002a50  68 61 76 65 20 74 6f 20  6d 6f 64 69 66 79 20 74  |have to modify t|
00002a60  68 69 73 20 70 72 6f 67  72 61 6d 20 79 6f 75 20  |his program you |
00002a70  77 69 6c 6c 20 68 61 76  65 20 74 6f 20 6d 6f 64  |will have to mod|
00002a80  69 66 79 20 61 6c 6c 20  74 68 65 0d 70 72 6f 67  |ify all the.prog|
00002a90  72 61 6d 73 20 61 73 73  6f 63 69 61 74 65 64 20  |rams associated |
00002aa0  77 69 74 68 20 54 65 6c  65 74 65 78 74 20 6d 6f  |with Teletext mo|
00002ab0  64 75 6c 65 73 20 31 20  74 6f 20 37 2e 0d 0d 43  |dules 1 to 7...C|
00002ac0  68 61 69 6e 20 74 68 65  20 70 72 6f 67 72 61 6d  |hain the program|
00002ad0  20 43 4f 55 4e 54 45 52  2c 20 6c 65 74 20 69 74  | COUNTER, let it|
00002ae0  20 72 75 6e 20 66 6f 72  20 61 20 6c 69 74 74 6c  | run for a littl|
00002af0  65 20 77 68 69 6c 65 20  61 6e 64 20 74 68 65 6e  |e while and then|
00002b00  20 70 72 65 73 73 0d 74  68 65 20 45 73 63 61 70  | press.the Escap|
00002b10  65 20 6b 65 79 2e 20 57  68 65 6e 20 49 20 75 73  |e key. When I us|
00002b20  65 64 20 74 68 65 20 70  72 6f 67 72 61 6d 20 49  |ed the program I|
00002b30  20 66 6f 75 6e 64 20 74  68 61 74 20 74 68 65 20  | found that the |
00002b40  54 65 6c 65 74 65 78 74  20 61 64 61 70 74 6f 72  |Teletext adaptor|
00002b50  0d 70 72 6f 64 75 63 65  64 20 35 30 2e 30 35 20  |.produced 50.05 |
00002b60  69 6e 74 65 72 72 75 70  74 73 20 61 20 73 65 63  |interrupts a sec|
00002b70  6f 6e 64 2e 20 54 68 69  73 20 63 6f 72 72 65 73  |ond. This corres|
00002b80  70 6f 6e 64 73 20 76 65  72 79 20 77 65 6c 6c 20  |ponds very well |
00002b90  77 69 74 68 20 74 68 65  20 35 30 0d 48 7a 20 66  |with the 50.Hz f|
00002ba0  69 65 6c 64 20 66 6c 79  62 61 63 6b 20 69 6e 74  |ield flyback int|
00002bb0  65 72 76 61 6c 20 61 6e  64 20 74 68 65 20 64 69  |erval and the di|
00002bc0  66 66 65 72 65 6e 63 65  20 6d 61 79 20 62 65 20  |fference may be |
00002bd0  64 75 65 20 74 6f 20 61  20 73 6c 69 67 68 74 0d  |due to a slight.|
00002be0  69 6e 61 63 63 75 72 61  63 79 20 69 6e 20 74 68  |inaccuracy in th|
00002bf0  65 20 42 42 43 20 63 6f  6d 70 75 74 65 72 27 73  |e BBC computer's|
00002c00  20 74 69 6d 65 72 2e 0d  0d 41 20 54 65 6c 65 74  | timer...A Telet|
00002c10  65 78 74 20 67 65 6e 65  72 61 74 65 64 20 69 6e  |ext generated in|
00002c20  74 65 72 72 75 70 74 20  69 6e 64 69 63 61 74 65  |terrupt indicate|
00002c30  73 20 74 68 61 74 20 64  61 74 61 20 61 72 65 20  |s that data are |
00002c40  61 76 61 69 6c 61 62 6c  65 20 66 6f 72 0d 70 72  |available for.pr|
00002c50  6f 63 65 73 73 69 6e 67  20 61 6e 64 20 69 74 20  |ocessing and it |
00002c60  69 73 20 75 70 20 74 6f  20 79 6f 75 20 74 6f 20  |is up to you to |
00002c70  65 6e 73 75 72 65 20 74  68 61 74 20 61 6c 6c 20  |ensure that all |
00002c80  70 72 6f 63 65 73 73 69  6e 67 20 6f 66 20 74 68  |processing of th|
00002c90  65 0d 54 65 6c 65 74 65  78 74 20 69 6e 74 65 72  |e.Teletext inter|
00002ca0  72 75 70 74 20 69 73 20  63 6f 6d 70 6c 65 74 65  |rupt is complete|
00002cb0  20 77 65 6c 6c 20 62 65  66 6f 72 65 20 32 30 20  | well before 20 |
00002cc0  6d 69 6c 6c 69 73 65 63  6f 6e 64 73 20 68 61 76  |milliseconds hav|
00002cd0  65 20 65 6c 61 70 73 65  64 0d 77 68 65 6e 20 61  |e elapsed.when a|
00002ce0  6e 6f 74 68 65 72 20 54  65 6c 65 74 65 78 74 20  |nother Teletext |
00002cf0  69 6e 74 65 72 72 75 70  74 20 63 61 6e 20 62 65  |interrupt can be|
00002d00  20 65 78 70 65 63 74 65  64 2e 20 49 66 20 61 20  | expected. If a |
00002d10  70 72 6f 67 72 61 6d 20  64 6f 65 73 20 6e 6f 74  |program does not|
00002d20  0d 63 6c 65 61 72 20 74  68 65 20 73 74 61 74 75  |.clear the statu|
00002d30  73 20 66 6c 61 67 73 20  61 6e 64 20 65 78 65 63  |s flags and exec|
00002d40  75 74 65 20 61 6e 20 52  54 49 20 62 65 66 6f 72  |ute an RTI befor|
00002d50  65 20 74 68 65 20 32 30  20 6d 69 6c 6c 69 73 65  |e the 20 millise|
00002d60  63 6f 6e 64 0d 64 65 61  64 6c 69 6e 65 20 74 68  |cond.deadline th|
00002d70  65 6e 20 74 68 65 20 6c  65 61 73 74 20 70 72 6f  |en the least pro|
00002d80  62 6c 65 6d 20 79 6f 75  20 63 61 6e 20 65 78 70  |blem you can exp|
00002d90  65 63 74 20 69 73 20 61  20 64 61 74 61 20 6f 76  |ect is a data ov|
00002da0  65 72 72 75 6e 20 65 72  72 6f 72 2e 20 49 74 0d  |errun error. It.|
00002db0  69 73 20 6d 75 63 68 20  6d 6f 72 65 20 6c 69 6b  |is much more lik|
00002dc0  65 6c 79 20 74 68 61 74  20 61 6e 79 20 69 6e 74  |ely that any int|
00002dd0  65 72 72 75 70 74 20 68  61 6e 64 6c 69 6e 67 20  |errupt handling |
00002de0  72 6f 75 74 69 6e 65 20  77 68 69 63 68 20 74 61  |routine which ta|
00002df0  6b 65 73 0d 61 6e 79 74  68 69 6e 67 20 6c 69 6b  |kes.anything lik|
00002e00  65 20 32 30 20 6d 69 6c  6c 69 73 65 63 6f 6e 64  |e 20 millisecond|
00002e10  73 20 77 69 6c 6c 20 68  61 6e 67 20 75 70 20 74  |s will hang up t|
00002e20  68 65 20 63 6f 6d 70 75  74 65 72 20 63 6f 6d 70  |he computer comp|
00002e30  6c 65 74 65 6c 79 20 61  6e 64 0d 76 65 72 79 20  |letely and.very |
00002e40  71 75 69 63 6b 6c 79 2e  0d 0d 59 6f 75 20 6d 75  |quickly...You mu|
00002e50  73 74 20 61 6c 77 61 79  73 20 64 65 73 69 67 6e  |st always design|
00002e60  20 79 6f 75 72 20 62 61  63 6b 67 72 6f 75 6e 64  | your background|
00002e70  20 74 61 73 6b 73 20 74  6f 20 64 65 61 6c 20 77  | tasks to deal w|
00002e80  69 74 68 20 74 68 65 20  69 6e 74 65 72 72 75 70  |ith the interrup|
00002e90  74 73 0d 61 73 20 71 75  69 63 6b 6c 79 20 61 73  |ts.as quickly as|
00002ea0  20 70 6f 73 73 69 62 6c  65 2e 20 54 68 69 73 20  | possible. This |
00002eb0  69 73 20 63 65 72 74 61  69 6e 6c 79 20 6e 6f 74  |is certainly not|
00002ec0  20 61 20 70 72 6f 62 6c  65 6d 20 77 69 74 68 20  | a problem with |
00002ed0  61 20 73 69 6d 70 6c 65  0d 70 72 6f 67 72 61 6d  |a simple.program|
00002ee0  20 6c 69 6b 65 20 43 4f  55 4e 54 45 52 20 62 75  | like COUNTER bu|
00002ef0  74 20 69 74 20 73 6f 6d  65 74 68 69 6e 67 20 74  |t it something t|
00002f00  6f 20 6b 65 65 70 20 69  6e 20 6d 69 6e 64 20 69  |o keep in mind i|
00002f10  6e 20 74 68 65 20 6c 61  74 65 72 20 6d 6f 64 75  |n the later modu|
00002f20  6c 65 73 0d 77 68 65 6e  20 74 68 65 20 64 65 73  |les.when the des|
00002f30  69 67 6e 20 6f 66 20 66  72 61 6d 65 20 67 72 61  |ign of frame gra|
00002f40  62 62 65 72 73 20 61 6e  64 20 6b 65 79 77 6f 72  |bbers and keywor|
00002f50  64 20 73 65 61 72 63 68  69 6e 67 20 77 69 6c 6c  |d searching will|
00002f60  20 62 65 0d 63 6f 6e 73  69 64 65 72 65 64 2e 0d  | be.considered..|
00002f70  0d 49 66 20 61 20 66 6f  72 65 67 72 6f 75 6e 64  |.If a foreground|
00002f80  20 74 61 73 6b 20 6e 65  65 64 73 20 6d 6f 72 65  | task needs more|
00002f90  20 74 68 61 6e 20 32 30  20 6d 69 6c 6c 69 73 65  | than 20 millise|
00002fa0  63 6f 6e 64 73 20 74 6f  20 61 6e 61 6c 79 73 65  |conds to analyse|
00002fb0  20 61 20 64 61 74 61 0d  70 61 63 6b 65 74 20 74  | a data.packet t|
00002fc0  68 65 6e 20 79 6f 75 20  63 6f 75 6c 64 20 63 6f  |hen you could co|
00002fd0  6e 73 69 64 65 72 20 65  69 74 68 65 72 20 64 69  |nsider either di|
00002fe0  73 61 62 6c 69 6e 67 20  74 68 65 20 54 65 6c 65  |sabling the Tele|
00002ff0  74 65 78 74 20 68 61 72  64 77 61 72 65 20 6f 72  |text hardware or|
00003000  0d 22 64 75 6d 70 69 6e  67 22 20 75 6e 77 61 6e  |."dumping" unwan|
00003010  74 65 64 20 64 61 74 61  20 61 66 74 65 72 20 72  |ted data after r|
00003020  65 61 64 69 6e 67 20 74  68 65 20 64 61 74 61 20  |eading the data |
00003030  79 6f 75 20 77 61 6e 74  20 74 6f 20 70 72 6f 63  |you want to proc|
00003040  65 73 73 20 69 6e 74 6f  0d 74 68 65 20 63 6f 6d  |ess into.the com|
00003050  70 75 74 65 72 20 6d 65  6d 6f 72 79 2e 20 41 6c  |puter memory. Al|
00003060  74 68 6f 75 67 68 20 74  68 69 73 20 69 73 20 61  |though this is a|
00003070  20 70 6f 73 73 69 62 6c  65 20 6d 65 74 68 6f 64  | possible method|
00003080  20 6f 66 20 63 6f 6e 74  72 6f 6c 6c 69 6e 67 20  | of controlling |
00003090  74 68 65 0d 68 61 72 64  77 61 72 65 20 79 6f 75  |the.hardware you|
000030a0  20 6d 75 73 74 20 75 73  65 20 69 74 20 77 69 74  | must use it wit|
000030b0  68 20 63 61 72 65 2e 20  41 6e 79 20 70 72 6f 63  |h care. Any proc|
000030c0  65 73 73 69 6e 67 20 74  68 61 74 20 74 61 6b 65  |essing that take|
000030d0  73 20 6d 6f 72 65 20 74  68 61 6e 20 32 30 0d 6d  |s more than 20.m|
000030e0  69 6c 6c 69 73 65 63 6f  6e 64 73 20 77 69 6c 6c  |illiseconds will|
000030f0  20 70 72 6f 62 61 62 6c  79 20 62 65 20 77 72 69  | probably be wri|
00003100  74 74 65 6e 20 69 6e 20  42 41 53 49 43 20 6f 72  |tten in BASIC or|
00003110  20 76 65 72 79 20 69 6e  65 66 66 69 63 69 65 6e  | very inefficien|
00003120  74 20 6d 61 63 68 69 6e  65 0d 63 6f 64 65 20 61  |t machine.code a|
00003130  6e 64 20 79 6f 75 20 6d  75 73 74 20 72 65 6d 65  |nd you must reme|
00003140  6d 62 65 72 20 74 68 61  74 20 64 69 73 61 62 6c  |mber that disabl|
00003150  69 6e 67 20 74 68 65 20  68 61 72 64 77 61 72 65  |ing the hardware|
00003160  20 6f 72 20 64 75 6d 70  69 6e 67 20 64 61 74 61  | or dumping data|
00003170  20 63 61 6e 0d 72 65 73  75 6c 74 20 69 6e 20 6c  | can.result in l|
00003180  6f 73 69 6e 67 20 74 68  65 20 76 65 72 79 20 64  |osing the very d|
00003190  61 74 61 20 79 6f 75 20  77 61 6e 74 20 74 6f 20  |ata you want to |
000031a0  70 72 6f 63 65 73 73 2e  20 59 6f 75 20 63 61 6e  |process. You can|
000031b0  20 6f 6e 6c 79 20 65 78  70 65 63 74 20 74 6f 0d  | only expect to.|
000031c0  67 65 74 20 61 77 61 79  20 77 69 74 68 20 76 65  |get away with ve|
000031d0  72 79 20 6c 6f 6e 67 20  64 61 74 61 20 70 72 6f  |ry long data pro|
000031e0  63 65 73 73 69 6e 67 20  74 69 6d 65 73 20 77 68  |cessing times wh|
000031f0  65 6e 20 79 6f 75 72 20  70 72 6f 67 72 61 6d 20  |en your program |
00003200  69 73 20 6c 6f 6f 6b 69  6e 67 0d 66 6f 72 20 73  |is looking.for s|
00003210  69 6e 67 6c 65 20 64 61  74 61 20 70 61 63 6b 65  |ingle data packe|
00003220  74 73 2c 20 73 75 63 68  20 61 73 20 74 68 65 20  |ts, such as the |
00003230  54 65 6c 65 76 69 73 69  6f 6e 20 53 65 72 76 69  |Television Servi|
00003240  63 65 20 44 61 74 61 20  50 61 63 6b 65 74 2c 20  |ce Data Packet, |
00003250  77 68 69 63 68 0d 61 72  72 69 76 65 20 61 74 20  |which.arrive at |
00003260  69 6e 66 72 65 71 75 65  6e 74 20 69 6e 74 65 72  |infrequent inter|
00003270  76 61 6c 73 2e 0d 0d 0d  20 20 20 31 30 20 52 45  |vals....   10 RE|
00003280  4d 3e 20 43 4f 55 4e 54  45 52 0d 20 20 20 32 30  |M> COUNTER.   20|
00003290  20 4d 4f 44 45 37 0d 20  20 20 33 30 20 44 49 4d  | MODE7.   30 DIM|
000032a0  20 6d 63 6f 64 65 20 26  32 30 30 20 3a 52 45 4d  | mcode &200 :REM|
000032b0  3a 20 73 70 61 63 65 20  66 6f 72 20 6d 61 63 68  |: space for mach|
000032c0  69 6e 65 20 63 6f 64 65  0d 20 20 20 34 30 20 50  |ine code.   40 P|
000032d0  52 4f 43 6d 63 6f 64 65  20 3a 52 45 4d 3a 20 61  |ROCmcode :REM: a|
000032e0  73 73 65 6d 62 6c 65 20  6d 61 63 68 69 6e 65 20  |ssemble machine |
000032f0  63 6f 64 65 0d 20 20 20  35 30 20 74 74 78 24 3d  |code.   50 ttx$=|
00003300  43 48 52 24 28 31 34 31  29 2b 43 48 52 24 28 31  |CHR$(141)+CHR$(1|
00003310  33 32 29 2b 43 48 52 24  28 31 35 37 29 2b 43 48  |32)+CHR$(157)+CH|
00003320  52 24 28 31 33 31 29 0d  20 20 20 20 20 20 2b 22  |R$(131).      +"|
00003330  54 54 58 20 69 6e 74 65  72 72 75 70 74 20 63 6f  |TTX interrupt co|
00003340  75 6e 74 65 72 20 20 22  2b 43 48 52 24 28 31 35  |unter  "+CHR$(15|
00003350  36 29 0d 20 20 20 36 30  20 50 52 49 4e 54 54 41  |6).   60 PRINTTA|
00003360  42 28 35 2c 33 29 74 74  78 24 0d 20 20 20 37 30  |B(5,3)ttx$.   70|
00003370  20 50 52 49 4e 54 54 41  42 28 35 2c 34 29 74 74  | PRINTTAB(5,4)tt|
00003380  78 24 0d 20 20 20 38 30  20 49 4e 50 55 54 54 41  |x$.   80 INPUTTA|
00003390  42 28 39 2c 38 29 22 54  56 20 63 68 61 6e 6e 65  |B(9,8)"TV channe|
000033a0  6c 20 28 31 2d 34 29 20  3d 20 22 61 6e 73 77 65  |l (1-4) = "answe|
000033b0  72 24 0d 20 20 20 39 30  20 56 44 55 32 33 2c 31  |r$.   90 VDU23,1|
000033c0  2c 30 3b 30 3b 30 3b 30  3b 0d 20 20 31 30 30 20  |,0;0;0;0;.  100 |
000033d0  3f 63 68 61 6e 6e 65 6c  3d 45 56 41 4c 28 22 26  |?channel=EVAL("&|
000033e0  22 2b 4c 45 46 54 24 28  61 6e 73 77 65 72 24 2c  |"+LEFT$(answer$,|
000033f0  31 29 29 2b 26 31 42 0d  20 20 31 31 30 20 49 46  |1))+&1B.  110 IF|
00003400  20 3f 63 68 61 6e 6e 65  6c 20 3c 20 26 31 43 20  | ?channel < &1C |
00003410  54 48 45 4e 20 3f 63 68  61 6e 6e 65 6c 20 3d 20  |THEN ?channel = |
00003420  26 31 43 0d 20 20 31 32  30 20 49 46 20 3f 63 68  |&1C.  120 IF ?ch|
00003430  61 6e 6e 65 6c 20 3e 20  26 31 46 20 54 48 45 4e  |annel > &1F THEN|
00003440  20 3f 63 68 61 6e 6e 65  6c 20 3d 20 26 31 46 0d  | ?channel = &1F.|
00003450  20 20 31 33 30 20 54 49  4d 45 3d 30 0d 20 20 31  |  130 TIME=0.  1|
00003460  34 30 20 43 41 4c 4c 20  6d 63 6f 64 65 0d 20 20  |40 CALL mcode.  |
00003470  31 35 30 20 74 69 6d 65  3d 54 49 4d 45 2f 31 30  |150 time=TIME/10|
00003480  30 0d 20 20 31 36 30 20  63 6f 75 6e 74 3d 45 56  |0.  160 count=EV|
00003490  41 4c 28 53 54 52 24 7e  28 21 63 6f 75 6e 74 65  |AL(STR$~(!counte|
000034a0  72 29 29 0d 20 20 31 37  30 20 61 74 25 3d 40 25  |r)).  170 at%=@%|
000034b0  0d 20 20 31 38 30 20 40  25 3d 26 32 30 32 30 35  |.  180 @%=&20205|
000034c0  0d 20 20 31 39 30 20 50  52 49 4e 54 54 41 42 28  |.  190 PRINTTAB(|
000034d0  36 2c 31 36 29 3b 63 6f  75 6e 74 2f 74 69 6d 65  |6,16);count/time|
000034e0  3b 22 20 69 6e 74 65 72  72 75 70 74 73 20 70 65  |;" interrupts pe|
000034f0  72 20 73 65 63 6f 6e 64  22 0d 20 20 32 30 30 20  |r second".  200 |
00003500  40 25 3d 61 74 25 0d 20  20 32 31 30 20 56 44 55  |@%=at%.  210 VDU|
00003510  33 31 2c 30 2c 32 32 2c  32 33 2c 31 2c 31 3b 30  |31,0,22,23,1,1;0|
00003520  3b 30 3b 30 3b 0d 20 20  32 32 30 20 45 4e 44 0d  |;0;0;.  220 END.|
00003530  20 20 32 33 30 20 44 45  46 50 52 4f 43 6d 63 6f  |  230 DEFPROCmco|
00003540  64 65 0d 20 20 32 34 30  20 63 68 61 6e 6e 65 6c  |de.  240 channel|
00003550  3d 26 37 30 20 3a 52 45  4d 3a 20 54 56 20 63 68  |=&70 :REM: TV ch|
00003560  61 6e 6e 65 6c 0d 20 20  32 35 30 20 73 61 76 65  |annel.  250 save|
00003570  72 65 67 3d 26 46 43 20  3a 52 45 4d 3a 20 69 6e  |reg=&FC :REM: in|
00003580  74 65 72 72 75 70 74 20  61 63 63 75 6d 75 6c 61  |terrupt accumula|
00003590  74 6f 72 20 73 61 76 65  20 72 65 67 69 73 74 65  |tor save registe|
000035a0  72 0d 20 20 32 36 30 20  65 73 63 61 70 65 3d 26  |r.  260 escape=&|
000035b0  46 46 20 3a 52 45 4d 3a  20 65 73 63 61 70 65 20  |FF :REM: escape |
000035c0  66 6c 61 67 0d 20 20 32  37 30 20 69 72 71 32 76  |flag.  270 irq2v|
000035d0  3d 26 32 30 36 20 3a 52  45 4d 3a 20 49 52 51 32  |=&206 :REM: IRQ2|
000035e0  20 76 65 63 74 6f 72 0d  20 20 32 38 30 20 74 74  | vector.  280 tt|
000035f0  78 63 6f 6e 74 72 6f 6c  3d 26 46 43 31 30 20 3a  |xcontrol=&FC10 :|
00003600  52 45 4d 3a 20 54 54 58  20 63 6f 6e 74 72 6f 6c  |REM: TTX control|
00003610  20 72 65 67 69 73 74 65  72 2c 20 77 72 69 74 65  | register, write|
00003620  20 6f 6e 6c 79 0d 20 20  32 39 30 20 74 74 78 73  | only.  290 ttxs|
00003630  74 61 74 75 73 3d 26 46  43 31 30 20 3a 52 45 4d  |tatus=&FC10 :REM|
00003640  3a 20 54 54 58 20 73 74  61 74 75 73 20 72 65 67  |: TTX status reg|
00003650  69 73 74 65 72 2c 20 72  65 61 64 20 6f 6e 6c 79  |ister, read only|
00003660  0d 20 20 33 30 30 20 72  6f 77 72 65 67 3d 26 46  |.  300 rowreg=&F|
00003670  43 31 31 20 3a 52 45 4d  3a 20 54 54 58 20 72 6f  |C11 :REM: TTX ro|
00003680  77 20 72 65 67 69 73 74  65 72 2c 20 77 72 69 74  |w register, writ|
00003690  65 20 6f 6e 6c 79 0d 20  20 33 31 30 20 64 61 74  |e only.  310 dat|
000036a0  61 72 65 67 3d 26 46 43  31 32 20 3a 52 45 4d 3a  |areg=&FC12 :REM:|
000036b0  20 54 54 58 20 64 61 74  61 20 72 65 67 69 73 74  | TTX data regist|
000036c0  65 72 2c 20 72 65 61 64  20 26 20 77 72 69 74 65  |er, read & write|
000036d0  0d 20 20 33 32 30 20 73  74 61 74 63 6c 72 3d 26  |.  320 statclr=&|
000036e0  46 43 31 33 20 3a 52 45  4d 3a 20 54 54 58 20 63  |FC13 :REM: TTX c|
000036f0  6c 65 61 72 20 73 74 61  74 75 73 20 72 65 67 69  |lear status regi|
00003700  73 74 65 72 2c 20 72 65  61 64 20 26 20 77 72 69  |ster, read & wri|
00003710  74 65 0d 20 20 33 33 30  20 6f 73 77 72 63 68 3d  |te.  330 oswrch=|
00003720  26 46 46 45 45 0d 20 20  33 34 30 20 6f 73 62 79  |&FFEE.  340 osby|
00003730  74 65 3d 26 46 46 46 34  0d 20 20 33 35 30 20 46  |te=&FFF4.  350 F|
00003740  4f 52 20 70 61 73 73 3d  30 20 54 4f 20 32 20 53  |OR pass=0 TO 2 S|
00003750  54 45 50 20 32 0d 20 20  33 36 30 20 50 25 3d 6d  |TEP 2.  360 P%=m|
00003760  63 6f 64 65 0d 20 20 33  37 30 20 5b 20 20 20 20  |code.  370 [    |
00003770  20 20 20 4f 50 54 20 70  61 73 73 0d 20 20 33 38  |   OPT pass.  38|
00003780  30 20 20 20 20 20 20 20  20 20 4c 44 58 20 69 72  |0         LDX ir|
00003790  71 32 76 20 20 20 20 20  5c 20 6c 6f 61 64 20 73  |q2v     \ load s|
000037a0  65 63 6f 6e 64 61 72 79  20 69 6e 74 65 72 72 75  |econdary interru|
000037b0  70 74 20 76 65 63 74 6f  72 0d 20 20 33 39 30 20  |pt vector.  390 |
000037c0  20 20 20 20 20 20 20 20  4c 44 59 20 69 72 71 32  |        LDY irq2|
000037d0  76 2b 31 0d 20 20 34 30  30 20 20 20 20 20 20 20  |v+1.  400       |
000037e0  20 20 53 54 58 20 6f 6c  64 69 72 71 32 76 20 20  |  STX oldirq2v  |
000037f0  5c 20 73 61 76 65 20 73  65 63 6f 6e 64 61 72 79  |\ save secondary|
00003800  20 69 6e 74 65 72 72 75  70 74 20 76 65 63 74 6f  | interrupt vecto|
00003810  72 0d 20 20 34 31 30 20  20 20 20 20 20 20 20 20  |r.  410         |
00003820  53 54 59 20 6f 6c 64 69  72 71 32 76 2b 31 0d 20  |STY oldirq2v+1. |
00003830  20 34 32 30 20 20 20 20  20 20 20 20 20 4c 44 58  | 420         LDX|
00003840  20 23 69 6e 74 65 72 72  75 70 74 20 4d 4f 44 20  | #interrupt MOD |
00003850  32 35 36 20 5c 20 69 6e  73 74 61 6c 6c 20 6e 65  |256 \ install ne|
00003860  77 20 69 6e 74 65 72 72  75 70 74 20 72 6f 75 74  |w interrupt rout|
00003870  69 6e 65 0d 20 20 34 33  30 20 20 20 20 20 20 20  |ine.  430       |
00003880  20 20 4c 44 59 20 23 69  6e 74 65 72 72 75 70 74  |  LDY #interrupt|
00003890  20 44 49 56 20 32 35 36  0d 20 20 34 34 30 20 20  | DIV 256.  440  |
000038a0  20 20 20 20 20 20 20 53  45 49 20 20 20 20 20 20  |       SEI      |
000038b0  20 20 20 20 20 5c 20 64  69 73 61 62 6c 65 20 69  |     \ disable i|
000038c0  6e 74 65 72 72 75 70 74  73 20 77 68 65 6e 20 61  |nterrupts when a|
000038d0  6c 74 65 72 69 6e 67 20  76 65 63 74 6f 72 0d 20  |ltering vector. |
000038e0  20 34 35 30 20 20 20 20  20 20 20 20 20 53 54 58  | 450         STX|
000038f0  20 69 72 71 32 76 0d 20  20 34 36 30 20 20 20 20  | irq2v.  460    |
00003900  20 20 20 20 20 53 54 59  20 69 72 71 32 76 2b 31  |     STY irq2v+1|
00003910  0d 20 20 34 37 30 20 20  20 20 20 20 20 20 20 43  |.  470         C|
00003920  4c 49 20 20 20 20 20 20  20 20 20 20 20 5c 20 72  |LI           \ r|
00003930  65 2d 65 6e 61 62 6c 65  20 69 6e 74 65 72 72 75  |e-enable interru|
00003940  70 74 73 0d 20 20 34 38  30 20 20 20 20 20 20 20  |pts.  480       |
00003950  20 20 4c 44 41 20 63 68  61 6e 6e 65 6c 20 20 20  |  LDA channel   |
00003960  5c 20 6c 6f 61 64 20 28  63 68 61 6e 6e 65 6c 20  |\ load (channel |
00003970  6e 75 6d 62 65 72 20 2b  20 23 26 31 43 29 0d 20  |number + #&1C). |
00003980  20 34 39 30 20 20 20 20  20 20 20 20 20 53 54 41  | 490         STA|
00003990  20 74 74 78 63 6f 6e 74  72 6f 6c 20 5c 20 65 6e  | ttxcontrol \ en|
000039a0  61 62 6c 65 20 54 54 58  0d 20 20 35 30 30 20 2e  |able TTX.  500 .|
000039b0  6d 61 69 6e 6c 6f 6f 70  0d 20 20 35 31 30 20 20  |mainloop.  510  |
000039c0  20 20 20 20 20 20 20 4c  44 41 20 23 26 31 46 20  |       LDA #&1F |
000039d0  20 20 20 20 20 5c 20 64  65 63 69 6d 61 6c 20 33  |     \ decimal 3|
000039e0  31 0d 20 20 35 32 30 20  20 20 20 20 20 20 20 20  |1.  520         |
000039f0  4a 53 52 20 6f 73 77 72  63 68 0d 20 20 35 33 30  |JSR oswrch.  530|
00003a00  20 20 20 20 20 20 20 20  20 4c 44 41 20 23 26 30  |         LDA #&0|
00003a10  46 20 20 20 20 20 20 5c  20 64 65 63 69 6d 61 6c  |F      \ decimal|
00003a20  20 31 35 0d 20 20 35 34  30 20 20 20 20 20 20 20  | 15.  540       |
00003a30  20 20 4a 53 52 20 6f 73  77 72 63 68 0d 20 20 35  |  JSR oswrch.  5|
00003a40  35 30 20 20 20 20 20 20  20 20 20 4c 44 41 20 23  |50         LDA #|
00003a50  26 30 43 20 20 20 20 20  20 5c 20 64 65 63 69 6d  |&0C      \ decim|
00003a60  61 6c 20 31 32 0d 20 20  35 36 30 20 20 20 20 20  |al 12.  560     |
00003a70  20 20 20 20 4a 53 52 20  6f 73 77 72 63 68 20 20  |    JSR oswrch  |
00003a80  20 20 5c 20 56 44 55 20  33 31 2c 31 34 2c 31 34  |  \ VDU 31,14,14|
00003a90  0d 20 20 35 37 30 20 20  20 20 20 20 20 20 20 4c  |.  570         L|
00003aa0  44 41 20 63 6f 75 6e 74  65 72 2b 33 0d 20 20 35  |DA counter+3.  5|
00003ab0  38 30 20 20 20 20 20 20  20 20 20 4a 53 52 20 70  |80         JSR p|
00003ac0  72 69 6e 74 62 63 64 20  20 5c 20 70 72 69 6e 74  |rintbcd  \ print|
00003ad0  20 34 20 62 79 74 65 20  63 6f 75 6e 74 65 72 20  | 4 byte counter |
00003ae0  69 6e 20 68 65 78 2e 0d  20 20 35 39 30 20 20 20  |in hex..  590   |
00003af0  20 20 20 20 20 20 4c 44  41 20 63 6f 75 6e 74 65  |      LDA counte|
00003b00  72 2b 32 0d 20 20 36 30  30 20 20 20 20 20 20 20  |r+2.  600       |
00003b10  20 20 4a 53 52 20 70 72  69 6e 74 62 63 64 0d 20  |  JSR printbcd. |
00003b20  20 36 31 30 20 20 20 20  20 20 20 20 20 4c 44 41  | 610         LDA|
00003b30  20 63 6f 75 6e 74 65 72  2b 31 0d 20 20 36 32 30  | counter+1.  620|
00003b40  20 20 20 20 20 20 20 20  20 4a 53 52 20 70 72 69  |         JSR pri|
00003b50  6e 74 62 63 64 0d 20 20  36 33 30 20 20 20 20 20  |ntbcd.  630     |
00003b60  20 20 20 20 4c 44 41 20  63 6f 75 6e 74 65 72 0d  |    LDA counter.|
00003b70  20 20 36 34 30 20 20 20  20 20 20 20 20 20 4a 53  |  640         JS|
00003b80  52 20 70 72 69 6e 74 62  63 64 0d 20 20 36 35 30  |R printbcd.  650|
00003b90  20 20 20 20 20 20 20 20  20 4c 44 41 20 65 73 63  |         LDA esc|
00003ba0  61 70 65 20 20 20 20 5c  20 70 6f 6c 6c 20 65 73  |ape    \ poll es|
00003bb0  63 61 70 65 20 66 6c 61  67 0d 20 20 36 36 30 20  |cape flag.  660 |
00003bc0  20 20 20 20 20 20 20 20  42 50 4c 20 6d 61 69 6e  |        BPL main|
00003bd0  6c 6f 6f 70 20 20 5c 20  62 72 61 6e 63 68 20 69  |loop  \ branch i|
00003be0  66 20 65 73 63 61 70 65  20 6e 6f 74 20 70 72 65  |f escape not pre|
00003bf0  73 73 65 64 0d 20 20 36  37 30 20 20 20 20 20 20  |ssed.  670      |
00003c00  20 20 20 4c 44 41 20 23  26 37 45 0d 20 20 36 38  |   LDA #&7E.  68|
00003c10  30 20 20 20 20 20 20 20  20 20 4a 53 52 20 6f 73  |0         JSR os|
00003c20  62 79 74 65 20 20 20 20  5c 20 61 63 6b 6e 6f 77  |byte    \ acknow|
00003c30  6c 65 64 67 65 20 65 73  63 61 70 65 0d 20 20 36  |ledge escape.  6|
00003c40  39 30 20 20 20 20 20 20  20 20 20 4c 44 41 20 23  |90         LDA #|
00003c50  26 30 30 0d 20 20 37 30  30 20 20 20 20 20 20 20  |&00.  700       |
00003c60  20 20 53 54 41 20 74 74  78 63 6f 6e 74 72 6f 6c  |  STA ttxcontrol|
00003c70  20 5c 20 64 69 73 61 62  6c 65 20 54 54 58 0d 20  | \ disable TTX. |
00003c80  20 37 31 30 20 20 20 20  20 20 20 20 20 4c 44 58  | 710         LDX|
00003c90  20 6f 6c 64 69 72 71 32  76 20 20 5c 20 6c 6f 61  | oldirq2v  \ loa|
00003ca0  64 20 6f 72 69 67 69 6e  61 6c 20 76 65 63 74 6f  |d original vecto|
00003cb0  72 0d 20 20 37 32 30 20  20 20 20 20 20 20 20 20  |r.  720         |
00003cc0  4c 44 59 20 6f 6c 64 69  72 71 32 76 2b 31 0d 20  |LDY oldirq2v+1. |
00003cd0  20 37 33 30 20 20 20 20  20 20 20 20 20 53 45 49  | 730         SEI|
00003ce0  20 20 20 20 20 20 20 20  20 20 20 5c 20 64 69 73  |           \ dis|
00003cf0  61 62 6c 65 20 69 6e 74  65 72 72 75 70 74 73 20  |able interrupts |
00003d00  77 68 65 6e 20 61 6c 74  65 72 69 6e 67 20 76 65  |when altering ve|
00003d10  63 74 6f 72 0d 20 20 37  34 30 20 20 20 20 20 20  |ctor.  740      |
00003d20  20 20 20 53 54 58 20 69  72 71 32 76 20 20 20 20  |   STX irq2v    |
00003d30  20 5c 20 72 65 73 74 6f  72 65 20 6f 72 69 67 69  | \ restore origi|
00003d40  6e 61 6c 20 76 65 63 74  6f 72 0d 20 20 37 35 30  |nal vector.  750|
00003d50  20 20 20 20 20 20 20 20  20 53 54 59 20 69 72 71  |         STY irq|
00003d60  32 76 2b 31 0d 20 20 37  36 30 20 20 20 20 20 20  |2v+1.  760      |
00003d70  20 20 20 43 4c 49 20 20  20 20 20 20 20 20 20 20  |   CLI          |
00003d80  20 5c 20 72 65 2d 65 6e  61 62 6c 65 20 69 6e 74  | \ re-enable int|
00003d90  65 72 72 75 70 74 73 0d  20 20 37 37 30 20 20 20  |errupts.  770   |
00003da0  20 20 20 20 20 20 52 54  53 20 20 20 20 20 20 20  |      RTS       |
00003db0  20 20 20 20 5c 20 72 65  74 75 72 6e 20 74 6f 20  |    \ return to |
00003dc0  42 41 53 49 43 0d 20 20  37 38 30 20 2e 69 6e 74  |BASIC.  780 .int|
00003dd0  65 72 72 75 70 74 0d 20  20 37 39 30 20 20 20 20  |errupt.  790    |
00003de0  20 20 20 20 20 42 49 54  20 74 74 78 73 74 61 74  |     BIT ttxstat|
00003df0  75 73 20 5c 20 70 6f 6c  6c 20 54 54 58 20 68 61  |us \ poll TTX ha|
00003e00  72 64 77 61 72 65 0d 20  20 38 30 30 20 20 20 20  |rdware.  800    |
00003e10  20 20 20 20 20 42 4d 49  20 74 74 78 69 6e 74 65  |     BMI ttxinte|
00003e20  72 20 20 5c 20 62 72 61  6e 63 68 20 69 66 20 54  |r  \ branch if T|
00003e30  54 58 20 69 6e 74 65 72  72 75 70 74 0d 20 20 38  |TX interrupt.  8|
00003e40  31 30 20 20 20 20 20 20  20 20 20 4a 4d 50 20 28  |10         JMP (|
00003e50  6f 6c 64 69 72 71 32 76  29 20 5c 20 6e 6f 74 20  |oldirq2v) \ not |
00003e60  54 54 58 20 69 6e 74 65  72 72 75 70 74 0d 20 20  |TTX interrupt.  |
00003e70  38 32 30 20 2e 74 74 78  69 6e 74 65 72 0d 20 20  |820 .ttxinter.  |
00003e80  38 33 30 20 20 20 20 20  20 20 20 20 4c 44 41 20  |830         LDA |
00003e90  73 61 76 65 72 65 67 20  20 20 5c 20 69 6e 74 65  |savereg   \ inte|
00003ea0  72 72 75 70 74 20 61 63  63 75 6d 75 6c 61 74 6f  |rrupt accumulato|
00003eb0  72 20 73 61 76 65 20 72  65 67 69 73 74 65 72 0d  |r save register.|
00003ec0  20 20 38 34 30 20 20 20  20 20 20 20 20 20 50 48  |  840         PH|
00003ed0  41 20 20 20 20 20 20 20  20 20 20 20 5c 20 70 75  |A           \ pu|
00003ee0  73 68 20 69 6e 74 65 72  72 75 70 74 20 61 63 63  |sh interrupt acc|
00003ef0  75 6d 75 6c 61 74 6f 72  20 73 61 76 65 20 72 65  |umulator save re|
00003f00  67 69 73 74 65 72 0d 20  20 38 35 30 20 20 20 20  |gister.  850    |
00003f10  20 20 20 20 20 54 58 41  0d 20 20 38 36 30 20 20  |     TXA.  860  |
00003f20  20 20 20 20 20 20 20 50  48 41 20 20 20 20 20 20  |       PHA      |
00003f30  20 20 20 20 20 5c 20 70  75 73 68 20 58 0d 20 20  |     \ push X.  |
00003f40  38 37 30 20 20 20 20 20  20 20 20 20 54 59 41 0d  |870         TYA.|
00003f50  20 20 38 38 30 20 20 20  20 20 20 20 20 20 50 48  |  880         PH|
00003f60  41 20 20 20 20 20 20 20  20 20 20 20 5c 20 70 75  |A           \ pu|
00003f70  73 68 20 59 0d 20 20 38  39 30 20 20 20 20 20 20  |sh Y.  890      |
00003f80  20 20 20 53 45 44 0d 20  20 39 30 30 20 20 20 20  |   SED.  900    |
00003f90  20 20 20 20 20 43 4c 43  0d 20 20 39 31 30 20 20  |     CLC.  910  |
00003fa0  20 20 20 20 20 20 20 4c  44 41 20 23 26 30 31 0d  |       LDA #&01.|
00003fb0  20 20 39 32 30 20 20 20  20 20 20 20 20 20 41 44  |  920         AD|
00003fc0  43 20 63 6f 75 6e 74 65  72 20 20 20 5c 20 61 64  |C counter   \ ad|
00003fd0  64 20 31 20 66 6f 72 20  65 76 65 72 79 20 54 54  |d 1 for every TT|
00003fe0  58 20 69 6e 74 65 72 72  75 70 74 0d 20 20 39 33  |X interrupt.  93|
00003ff0  30 20 20 20 20 20 20 20  20 20 53 54 41 20 63 6f  |0         STA co|
00004000  75 6e 74 65 72 0d 20 20  39 34 30 20 20 20 20 20  |unter.  940     |
00004010  20 20 20 20 4c 44 41 20  23 26 30 30 0d 20 20 39  |    LDA #&00.  9|
00004020  35 30 20 20 20 20 20 20  20 20 20 41 44 43 20 63  |50         ADC c|
00004030  6f 75 6e 74 65 72 2b 31  0d 20 20 39 36 30 20 20  |ounter+1.  960  |
00004040  20 20 20 20 20 20 20 53  54 41 20 63 6f 75 6e 74  |       STA count|
00004050  65 72 2b 31 0d 20 20 39  37 30 20 20 20 20 20 20  |er+1.  970      |
00004060  20 20 20 4c 44 41 20 23  26 30 30 0d 20 20 39 38  |   LDA #&00.  98|
00004070  30 20 20 20 20 20 20 20  20 20 41 44 43 20 63 6f  |0         ADC co|
00004080  75 6e 74 65 72 2b 32 0d  20 20 39 39 30 20 20 20  |unter+2.  990   |
00004090  20 20 20 20 20 20 53 54  41 20 63 6f 75 6e 74 65  |      STA counte|
000040a0  72 2b 32 0d 20 31 30 30  30 20 20 20 20 20 20 20  |r+2. 1000       |
000040b0  20 20 4c 44 41 20 23 26  30 30 0d 20 31 30 31 30  |  LDA #&00. 1010|
000040c0  20 20 20 20 20 20 20 20  20 41 44 43 20 63 6f 75  |         ADC cou|
000040d0  6e 74 65 72 2b 33 0d 20  31 30 32 30 20 20 20 20  |nter+3. 1020    |
000040e0  20 20 20 20 20 53 54 41  20 63 6f 75 6e 74 65 72  |     STA counter|
000040f0  2b 33 0d 20 31 30 33 30  20 20 20 20 20 20 20 20  |+3. 1030        |
00004100  20 4c 44 41 20 23 26 30  30 0d 20 31 30 34 30 20  | LDA #&00. 1040 |
00004110  20 20 20 20 20 20 20 20  4c 44 59 20 23 26 30 46  |        LDY #&0F|
00004120  20 20 20 20 20 20 5c 20  63 6c 65 61 72 20 31 36  |      \ clear 16|
00004130  20 72 6f 77 73 20 69 6e  20 61 64 61 70 74 6f 72  | rows in adaptor|
00004140  0d 20 31 30 35 30 20 2e  63 6c 65 61 72 6c 6f 6f  |. 1050 .clearloo|
00004150  70 0d 20 31 30 36 30 20  20 20 20 20 20 20 20 20  |p. 1060         |
00004160  53 54 59 20 72 6f 77 72  65 67 0d 20 31 30 37 30  |STY rowreg. 1070|
00004170  20 20 20 20 20 20 20 20  20 53 54 41 20 64 61 74  |         STA dat|
00004180  61 72 65 67 0d 20 31 30  38 30 20 20 20 20 20 20  |areg. 1080      |
00004190  20 20 20 44 45 59 0d 20  31 30 39 30 20 20 20 20  |   DEY. 1090    |
000041a0  20 20 20 20 20 42 50 4c  20 63 6c 65 61 72 6c 6f  |     BPL clearlo|
000041b0  6f 70 0d 20 31 31 30 30  20 20 20 20 20 20 20 20  |op. 1100        |
000041c0  20 53 54 41 20 73 74 61  74 63 6c 72 20 20 20 5c  | STA statclr   \|
000041d0  20 63 6c 65 61 72 20 73  74 61 74 75 73 20 66 6c  | clear status fl|
000041e0  61 67 73 20 62 65 66 6f  72 65 20 72 65 74 75 72  |ags before retur|
000041f0  6e 69 6e 67 0d 20 31 31  31 30 20 20 20 20 20 20  |ning. 1110      |
00004200  20 20 20 50 4c 41 0d 20  31 31 32 30 20 20 20 20  |   PLA. 1120    |
00004210  20 20 20 20 20 54 41 59  20 20 20 20 20 20 20 20  |     TAY        |
00004220  20 20 20 5c 20 72 65 73  74 6f 72 65 20 59 0d 20  |   \ restore Y. |
00004230  31 31 33 30 20 20 20 20  20 20 20 20 20 50 4c 41  |1130         PLA|
00004240  0d 20 31 31 34 30 20 20  20 20 20 20 20 20 20 54  |. 1140         T|
00004250  41 58 20 20 20 20 20 20  20 20 20 20 20 5c 20 72  |AX           \ r|
00004260  65 73 74 6f 72 65 20 58  0d 20 31 31 35 30 20 20  |estore X. 1150  |
00004270  20 20 20 20 20 20 20 50  4c 41 0d 20 31 31 36 30  |       PLA. 1160|
00004280  20 20 20 20 20 20 20 20  20 53 54 41 20 73 61 76  |         STA sav|
00004290  65 72 65 67 20 20 20 5c  20 72 65 73 74 6f 72 65  |ereg   \ restore|
000042a0  20 69 6e 74 65 72 72 75  70 74 20 61 63 63 75 6d  | interrupt accum|
000042b0  75 6c 61 74 6f 72 20 73  61 76 65 20 72 65 67 69  |ulator save regi|
000042c0  73 74 65 72 0d 20 31 31  37 30 20 20 20 20 20 20  |ster. 1170      |
000042d0  20 20 20 52 54 49 20 20  20 20 20 20 20 20 20 20  |   RTI          |
000042e0  20 5c 20 72 65 74 75 72  6e 20 66 72 6f 6d 20 69  | \ return from i|
000042f0  6e 74 65 72 72 75 70 74  0d 20 31 31 38 30 20 2e  |nterrupt. 1180 .|
00004300  70 72 69 6e 74 62 63 64  0d 20 31 31 39 30 20 20  |printbcd. 1190  |
00004310  20 20 20 20 20 20 20 50  48 41 0d 20 31 32 30 30  |       PHA. 1200|
00004320  20 20 20 20 20 20 20 20  20 4c 53 52 20 41 0d 20  |         LSR A. |
00004330  31 32 31 30 20 20 20 20  20 20 20 20 20 4c 53 52  |1210         LSR|
00004340  20 41 0d 20 31 32 32 30  20 20 20 20 20 20 20 20  | A. 1220        |
00004350  20 4c 53 52 20 41 0d 20  31 32 33 30 20 20 20 20  | LSR A. 1230    |
00004360  20 20 20 20 20 4c 53 52  20 41 0d 20 31 32 34 30  |     LSR A. 1240|
00004370  20 20 20 20 20 20 20 20  20 4a 53 52 20 6e 79 62  |         JSR nyb|
00004380  62 6c 65 0d 20 31 32 35  30 20 20 20 20 20 20 20  |ble. 1250       |
00004390  20 20 50 4c 41 0d 20 31  32 36 30 20 2e 6e 79 62  |  PLA. 1260 .nyb|
000043a0  62 6c 65 0d 20 31 32 37  30 20 20 20 20 20 20 20  |ble. 1270       |
000043b0  20 20 41 4e 44 20 23 26  30 46 20 20 20 20 20 20  |  AND #&0F      |
000043c0  5c 20 64 65 63 69 6d 61  6c 20 31 35 0d 20 31 32  |\ decimal 15. 12|
000043d0  38 30 20 20 20 20 20 20  20 20 20 53 45 44 0d 20  |80         SED. |
000043e0  31 32 39 30 20 20 20 20  20 20 20 20 20 43 4c 43  |1290         CLC|
000043f0  0d 20 31 33 30 30 20 20  20 20 20 20 20 20 20 41  |. 1300         A|
00004400  44 43 20 23 26 39 30 20  20 20 20 20 20 5c 20 64  |DC #&90      \ d|
00004410  65 63 69 6d 61 6c 20 31  34 34 0d 20 31 33 31 30  |ecimal 144. 1310|
00004420  20 20 20 20 20 20 20 20  20 41 44 43 20 23 26 34  |         ADC #&4|
00004430  30 20 20 20 20 20 20 5c  20 64 65 63 69 6d 61 6c  |0      \ decimal|
00004440  20 36 34 0d 20 31 33 32  30 20 20 20 20 20 20 20  | 64. 1320       |
00004450  20 20 43 4c 44 0d 20 31  33 33 30 20 20 20 20 20  |  CLD. 1330     |
00004460  20 20 20 20 4a 4d 50 20  6f 73 77 72 63 68 0d 20  |    JMP oswrch. |
00004470  31 33 34 30 20 2e 63 6f  75 6e 74 65 72 0d 20 31  |1340 .counter. 1|
00004480  33 35 30 20 20 20 20 20  20 20 20 20 45 51 55 44  |350         EQUD|
00004490  20 26 30 30 0d 20 31 33  36 30 20 2e 6f 6c 64 69  | &00. 1360 .oldi|
000044a0  72 71 32 76 0d 20 31 33  37 30 20 20 20 20 20 20  |rq2v. 1370      |
000044b0  20 20 20 45 51 55 57 20  26 30 30 0d 20 31 33 38  |   EQUW &00. 138|
000044c0  30 20 5d 0d 20 31 33 39  30 20 4e 45 58 54 0d 20  |0 ]. 1390 NEXT. |
000044d0  31 34 30 30 20 45 4e 44  50 52 4f 43 0d           |1400 ENDPROC.|
000044dd
12-03-89/T\TTX01.m0
12-03-89/T\TTX01.m1
12-03-89/T\TTX01.m2
12-03-89/T\TTX01.m4
12-03-89/T\TTX01.m5