STARGO ====== Assembly listing generated by TurboMASM from the modified Acorn source. Source: https://www.4corn.co.uk/articles/65hostandmos/ Source: http://regregex.bbcmicro.net/#prog.os126 Source: https://github.com/regregex/OS126 Branch slack calculated by Greg Cook with slack.pl (attached), 20 September 2023 Columns, left to right: (1) Filename, (2) line number and (3) hex address of limiting branch instruction (4) Direction of limiting branch: ^=backwards, v=forwards, Space=N/A (5) Hex number of bytes that may be inserted at this address, or between the branch instruction and the target SYMBOL at this address (NB: a more generous limit than shown may apply on the far side of the symbol.) --=no limit. (6) Current source filename, (7) line of assembly listing which typically starts with source line number, hex address and optional hex equate. *emulateturbo Acorn 6502 Tube 6502 Emulator OS 0.64 (19 Oct 1988) HIBASIC >*turmasm TURBOMASM Acorn Macro assembler 1.15 Action : width 127 Action : length 127 Action : stop on Action : print on Action : asm SgoHdr Macro library : Acorn macro assembler Page 1 Pass 1 Pass 2 0001 0000 ; > SgoHdr 0002 0000 0003 0000 GBLL $Tutu 0004 0000 $Tutu SETL 1=0 0005 0000 0006 0000 ; conditional assembly flags 0007 0000 007F MOS125 * &7F 0008 0000 0000 STARGO * &00 0009 0000 00FF NOSP * &FF 0010 0000 ; ($00 => TRUE, $FF => FALSE) 0011 0000 0012 0000 ; special labels for STARGO 0013 0000 00DC SEAL * &DC 0014 0000 ;The value to be returned in A by OSARGS A=1, Y=0 0015 0000 ;when trapped by MOS/CFS/RFS. 0016 0000 ;MSRM says to preserve A (p. H.3-5), i.e. A=1 0017 0000 ;however MOS 3.20 breaks the spec and returns A=&DC, mainly. 0018 0000 ;This is just a copy of the 3MSB of the pointer at X+1. 0019 0000 ;NAUG says A is undefined (p.253); other unofficial sources 0020 0000 ;suggest that implemented OSARGS calls *should not* 0021 0000 ;preserve A. 0022 0000 0023 0000 02D0 TAILLO * &02D0 0024 0000 02D1 TAILHI * &02D1 0025 0000 ;Locations to store the command line tail pointer from *GO 0026 0000 ;and *RUN. Need not be adjacent. Formerly buffer activity 0027 0000 ;flags that are free in OS 1.26. 0028 0000 0029 0000 LNK MOS00 0001 0000 0002 0000 TTL VDU File -> MOS00 0003 0000 OPT &01 0004 0000 0005 0000 ; 0006 0000 ; MASM options 0007 0000 ; 0008 0000 0004 OPNEWP * &04 ;new page 0009 0000 0001 OPPON * &01 ;print on 0010 0000 0002 OPPOFF * &02 ;print off 0011 0000 ; 0012 0000 ; module print selections 0013 0000 ; 0014 0000 0005 DEFOPT * OPPON:OR:OPNEWP ;default option for MOS code 0015 0000 0005 MOS00 * DEFOPT 0016 0000 0005 MOS01 * DEFOPT 0017 0000 0005 MOS02 * DEFOPT 0018 0000 0005 MOS03 * DEFOPT 0019 0000 0005 MOS04 * DEFOPT 0020 0000 0005 MOS05 * DEFOPT 0021 0000 0005 MOS06 * DEFOPT 0022 0000 0005 MOS07 * DEFOPT 0023 0000 0005 MOS08 * DEFOPT 0024 0000 0025 0000 0005 MOS10 * DEFOPT 0026 0000 0005 MOS11 * DEFOPT 0027 0000 0028 0000 OPT MOS00 Acorn macro assembler Page 2 VDU File -> MOS00 0029 0000 0030 0000 00F0 WARGS * &00F0 0031 0000 00FA SEIWKA * &00FA 0032 0000 00FB SEIWKB * &00FB 0033 0000 0034 0000 ;Last updated 01/08/82 0035 0000 0036 0000 ;01/08/82 Intro of SEIWKA and SEIWKB to fix palette IRQ problem 0037 0000 ;01/05/82 Order of variables changed. Pseudo op # used. 0038 0000 ;21/04/82 QPOSN removed completely 0039 0000 ;25/03/82 Low byte of BEGSCN replaced with BYTCH (it was always zero) 0040 0000 ;04/02/82 QPOSN moved to MOS 0041 0000 ;07/01/82 VDUVEC removed (to $222 in MOS) 0042 0000 ;14/11/81 DOTS removed 0043 0000 0044 0000 ;VARIABLES, NOT ZERO PAGE 0045 0000 0046 0000 ;CHARACTER FONTS 0047 0000 0048 0000 BF00 HFONT * &BF00 0049 0000 00BF HFMSB * /(HFONT ) ;MSB of HFONT 0050 0000 0051 0000 ;VARIABLES PROPER 0052 0000 0053 0000 0054 0000 0300 VARBLE * &0300 0055 0000 0300 V * VARBLE ;An abbreviation 0056 0000 0057 0000 0058 0000 ^ VARBLE 0059 0000 0060 0000 0300 GWLCOL # &02 ;Row no. of LH margin of graphics window (internal repn.) 0061 0000 0302 GWBROW # &02 ;Row no. of bottom margin of graphics window (internal repn.) 0062 0000 0304 GWRCOL # &02 ;Col no. of RH margin of graphics window (internal repn.) 0063 0000 0306 GWTROW # &02 ;Row no. of top margin of graphics window (internal repn.) 0064 0000 0308 TWLCOL # &01 ;Column number of left margin of text window 0065 0000 0309 TWBROW # &01 ;Row number of bottom margin of text window 0066 0000 030A TWRCOL # &01 ;Column number of right margin of text window 0067 0000 030B TWTROW # &01 ;Row number of top margin of text window 0068 0000 030C ORGX # &02 ;Screen origin (external represntation) 0069 0000 030E ORGY # &02 0070 0000 0310 GCSX # &02 ;Graphics cursor (external representation) 0071 0000 0312 GCSY # &02 0072 0000 0314 OLDCS # &04 ;Old graphics cursor 0073 0000 0318 CSX # &01 ;Text cursor posn (screen relative) 0074 0000 0319 CSY # &01 0075 0000 031A YLINE # &01 ;Offset from ZMEMG for current graphics point 0076 0000 031B QQ # &08 ;Queue 0077 0000 0323 QEND # &01 ;Last byte in queue 0078 0000 0324 GCSIX # &02 ;Graphics cursor (internal representation) 0079 0000 0326 GCSIY # &02 0080 0000 0328 VDUWS # &22 ;Workspace for VDU 0081 0000 034A CSPOSN # &02 ;Memory of top byte of character at cursor 0082 0000 034C PWWDTH # &02 ;Text window width in bytes 0083 0000 034E BEGSCN # &01 ;MSByte of Lowest byte address displayed 0084 0000 034F BYTCH # &01 ;No bytes per character displayed 0085 0000 0350 TOPSCN # &02 ;Address of top left byte on screen 0086 0000 0352 BYTROW # &02 ;Bytes per row 0087 0000 0354 BYTSCN # &01 ;Bytes used for screen display 0088 0000 0355 MODE # &01 ;Current VDU mode (0..7) 0089 0000 0356 MEMODE # &01 ;Memory map type (0..4) 0090 0000 ;STATS # $01 ;Individual bits used for various things - see docn. for details 0091 0000 0357 FTCOLF # &01 ;Next four must be in this order Foreground text colour 0092 0000 0358 BTCOLF # &01 ;Background text colour 0093 0000 0359 FGCOLF # &01 ;Foreground graphics colour 0094 0000 035A BGCOLF # &01 ;Background graphics colour 0095 0000 035B GPLFMD # &01 ;Current graphics foreground plot colour 0096 0000 035C GPLBMD # &01 ;Current graphics background plot colour 0097 0000 035D JVEC # &02 ;Jump vector for JMIs 0098 0000 035F CSTEMP # &01 ;Cursor start register of 6845 0099 0000 0360 NCOLOR # &01 ;No. colours available (=0 for TTX) 0100 0000 0361 NPIX # &01 ;No. pixels per byte (=0 for non-graphics mode) 0101 0000 0362 MASKL # &01 ;Mask for left most pixel in byte 0102 0000 0363 MASKR # &01 ;Mask for right most pixel in byte 0103 0000 0364 PCSX # &01 ;Print cursor x position 0104 0000 0365 PCSY # &01 ;Print cursor y position 0105 0000 0366 CHCSR # &01 ;Character which is the displayed cursor on print line 0106 0000 0367 FNTFLG # &01 ;Default font flags, 0 for hard font, p.1=b6 .. p.7=b0 0107 0000 0368 PGSFNT # &07 ;Page addresses for the soft font $20 - $3F & etc. 0108 0000 036F PARROT # &10 ;Storage of 16 physical colours 0109 0000 037F VEND # &00 ;End of the variables 0110 0000 0111 0000 ; ************************** MANIFESTS **************************** 0112 0000 0113 0000 0114 0000 ^ VDUWS 0115 0000 0328 DLEWS # &08 ;Workspace for DLE 0116 0000 0330 DLENLN # &01 0117 0000 0118 0000 ^ VDUWS 0119 0000 0328 CANWS # &04 ;Workspace for CAN 0120 0000 032C CDELTA # &04 0121 0000 0122 0000 ^ VDUWS 0123 0000 0328 USWS # &02 ;Workspace for US 0124 0000 0125 0000 ^ VDUWS 0126 0000 0328 SSWS # &02 ;Workspace for soft scrolling 0127 0000 0128 0000 ^ VDUWS 0129 0000 0328 APCS1 # &04 ;Workspace for anomalous printing 0130 0000 0131 0000 ^ VDUWS 0132 0000 0328 READWS # &08 ;Intermediate bit pattern formed during READCH 0133 0000 0134 0000 ^ VDUWS 0135 0000 0328 RPXLWS # &04 ;Workspace for read pixel 0136 0000 0137 0000 ;For graphics in general 0138 0000 0139 0000 030C ORG * ORGX ;Graphics origin 0140 0000 0310 GCSR * GCSX ;Graphics external cursor 0141 0000 0324 GCSIR * GCSIX ;Graphics internal cursor 0142 0000 0320 NEWPT * QEND-&03 ;New point introduced by call to routine. Multiple of 8 ! 0143 0000 031F PLMODE * QEND-&04 ;Plot mode 0144 0000 0145 0000 ;Plotting lines 0146 0000 0147 0000 ^ VDUWS 0148 0000 0328 LDELTA # &04 ;DeltaX & DeltaY 0149 0000 032C LSTART # &04 ;Start point for line Acorn macro assembler Page 3 VDU File -> MOS00 0150 0000 0330 HEND # &02 ;Horizontal end point 0151 0000 0332 D2JVEC # &02 ;Jump vector for D2 0152 0000 0334 DOTFLG # &01 ;Dotted line flag 0153 0000 0335 LPARMS # &06 ;Parameters for line drawing 0154 0000 0155 0000 ;Plotting triangles 0156 0000 0157 0000 ^ VDUWS 0158 0000 0328 HPARMS # &06 0159 0000 032E HSTART # &04 0160 0000 0332 HDIREC # &01 0161 0000 0333 SPARMS # &06 0162 0000 0339 SSTART # &04 0163 0000 033D SDIREC # &01 0164 0000 033E GCSTMP # &08 0165 0000 0166 0000 032A HDELTA * HPARMS+&02 0167 0000 0335 SDELTA * SPARMS+&02 0168 0000 031B TRINLN * QQ 0169 0000 0170 0000 ;Teletext temp variable for byte hidden by input cursor 0171 0000 0172 0000 0338 TTXTMP * VDUWS+&10 ;as nothing available in TTX uses this much storage 0173 0000 0174 0000 LNK MOS01 0001 0000 0002 0000 TTL VDU File - MOS01 0003 0000 OPT MOS01 Acorn macro assembler Page 4 VDU File - MOS01 0004 0000 0005 0000 < &0001 0006 0000 > &0002 0007 0000 0008 0000 ;Last revision 02/06/82 0009 0000 0010 0000 ;02/06/82 Remove HWMOFS 0011 0000 ;26/05/82 Concatenate TBZGOE & FCOLTB 0012 0000 ;05/05/82 Reverse bytes of multiplication tables TXTTB & HRGTB 0013 0000 ; Delete LRGTB 0014 0000 ;02/05/82 Concatenate TBZGxx tables 0015 0000 ; Change order of D1 & D2 jump tables & EWTBA 0016 0000 ;21/04/82 Colour mode #5 (which gives no change) included in TBZGxx. 0017 0000 ; External entry points provided 0018 0000 ;15/04/82 NPCOL declared 0019 0000 ;24/03/82 Delete DFSFPG as these are calculated at run time 0020 0000 ;22/01/82 Delete PDIVTB, it wasn't referenced 0021 0000 ; Delete READVP entry point & asssociated jump table 0022 0000 ; Change VDUVEC to VDUVEC, prefix all MOS names with m 0023 0000 ; TRMCH fixed as $0D 0024 0000 ; Soft font default now the exploded default 0025 0000 ;07/01/82 Change MODEL & VDUVEC 0026 0000 ;09/11/81 Change to one entry point for read VDU parameters 0027 0000 ;28/10/81 ETB msb changed from $49 to $59 0028 0000 ; Chars $C0-$DF taken from $10 (was $0C) 0029 0000 ; Chars $E0-$FF taken from $0C (was $10) 0030 0000 0031 0000 ; conditional assembly flags 0032 0000 00FF STARTP * &FF ;assume end points plotted twice 0033 0000 0000 PAGEFX * &00 ;Fix bug in page mode (I hope) 0034 0000 ; ($00 => TRUE, $FF => FALSE) 0035 0000 0036 0000 ;ZERO PAGE VARIABLES 0037 0000 0038 0000 ^ &00D0 0039 0000 00D0 STATS # &01 0040 0000 0041 0000 ; 0042 0000 00D1 ZMASK # &01 0043 0000 00D2 ZORA # &01 ;Next four must be in this order 0044 0000 00D3 ZEOR # &01 0045 0000 00D4 ZGORA # &01 0046 0000 00D5 ZGEOR # &01 0047 0000 ; 0048 0000 00D6 ZMEMG # &02 0049 0000 00D8 ZMEMT # &02 ;Immediately before ZTEMP (SSCRS) 0050 0000 00DA ZTEMP # &02 0051 0000 00DC ZTEMPB # &02 0052 0000 00DE ZTEMPC # &02 0053 0000 00E0 ZTBL # &02 0054 0000 0055 0000 ;EQUATE TABLE 0056 0000 0057 0000 0006 ACKASC * &06 ;Ascii value of acknowledge 0058 0000 00FE INBYTE * &FE ;Dummy colour to indicate invert (illegal colour) 0059 0000 0060 0000 0020 TTXBCL * &20 ;Byte to clear screen with in TTX 0061 0000 000D TRMCH * &0D ;Byte to terminate edit mode 0062 0000 000C SFPAGE * &0C ;Page of first definable set of characters 0063 0000 003F INVSXT * &3F ;Used to invert logical colour of mode 2 without touching flash 0064 0000 000F NPCOL * &0F ;number of physical colours - 1 0065 0000 0066 0000 ;MACHINE CONSTANTS 0067 0000 0068 0000 FE00 CRTCA * &FE00 ;6845 address reg. 0069 0000 FE01 CRTCD * &FE01 ;6845 data register 0070 0000 0071 0000 ;ENTRY POINTS 0072 0000 0073 0000 C300 CODE * &C300 0074 0000 00C3 CODORG * /CODE 0075 0000 0076 0000 ORG CODE 0077 C300 0078 C300 4C FA CA JMP RESET ;Reset VDU to mode (A) 0079 C303 ; JMP GADDR 0080 C303 ; JMP WIND 0081 C303 ; JMP EIGABS 0082 C303 ; JMP IEG 0083 C303 ; JMP PLOT 0084 C303 ; JMP HPLOT 0085 C303 ; JMP SETZG 0086 C303 ; JMP RPXLD 0087 C303 0088 C303 ; MOS messages to be written by WRSTR 0089 C303 MSG 0090 C303 MSGBBC ;BBC Computer 0091 C303 0D 42 42 = MCR,"BBC Computer ",0 0092 C312 0093 C312 MSG16K ;16K 0094 C312 31 36 4B = "16K",BEL,0 0095 C317 0096 C317 MSG32K ;32K 0097 C317 33 32 4B = "32K",BEL,0 0098 C31C 0099 C31C MSG2CR 0100 C31C 08 = &08 0101 C31D 0D = &0D 0102 C31E 0D = &0D ;uses the next $00 0103 C31F 0104 C31F ;EXPANDED BIT PATTERN TABLES - must be contiguous 0105 C31F 0106 C31F ;FOUR COLOUR MODE 0107 C31F 0108 C31F 00 BPFTB = &00 0109 C320 11 = &11 0110 C321 22 = &22 0111 C322 33 = &33 0112 C323 44 = &44 0113 C324 55 = &55 0114 C325 66 = &66 0115 C326 77 = &77 0116 C327 88 = &88 0117 C328 99 = &99 0118 C329 AA = &AA 0119 C32A BB = &BB 0120 C32B CC = &CC 0121 C32C DD = &DD 0122 C32D EE = &EE 0123 C32E FF = &FF 0124 C32F Acorn macro assembler Page 5 VDU File - MOS01 0125 C32F ;SIXTEEN COLOUR MODE 0126 C32F 0127 C32F 00 BPSTB = &00 0128 C330 55 = &55 0129 C331 AA = &AA 0130 C332 FF = &FF 0131 C333 0132 C333 0133 C333 ;JUMP TABLES Lower byte 0134 C333 0135 C333 12 JTBLO = ACK ;Points to an RTS 0136 C334 3C = SOH 0137 C335 95 = STX 0138 C336 A0 = ETX 0139 C337 AC = EOT 0140 C338 B8 = ENQ 0141 C339 12 = ACK 0142 C33A 77 = BELL 0143 C33B C4 = BS 0144 C33C 63 = HT 0145 C33D EF = LF 0146 C33E 5A = VT 0147 C33F 47 = FF 0148 C340 B9 = CR 0149 C341 8C = SO 0150 C342 A5 = SI 0151 C343 C7 = DLE 0152 C344 00 = DCA 0153 C345 04 = DCB 0154 C346 82 = DCC 0155 C347 3F = DCD 0156 C348 9A = NAK 0157 C349 D0 = SYN 0158 C34A D6 = ETB 0159 C34B 0D = CAN 0160 C34C 62 = EM 0161 C34D 93 = SUB 0162 C34E 12 = ACK ;Points to an RTS 0163 C34F F9 = FS 0164 C350 76 = GS 0165 C351 64 = RS 0166 C352 91 = US 0167 C353 D8 = DEL 0168 C354 0169 C354 ;Higher byte unless bytes to be queued, in which case, lower nibble 0170 C354 ;gives number of bytes to be queued, upper offset of higher byte 0171 C354 ;of routine address from code origin as specified by CODORG. Note 0172 C354 ;that this must be <8, i.e. biy 7 of whole byte is clear. 0173 C354 0174 C354 C5 JTBHI = /(ACK ) ;Points to an RTS 0175 C355 2F = SOH:SHR:&8-CODORG:SHL:&4+&10-&1 ;Queue 1 byte (SOH) 0176 C356 C5 = /(STX ) 0177 C357 C5 = /(ETX ) 0178 C358 C5 = /(EOT ) 0179 C359 C5 = /(ENQ ) 0180 C35A C5 = /(ACK ) 0181 C35B E8 = /(BELL ) 0182 C35C C5 = /(BS ) 0183 C35D C6 = /(HT ) 0184 C35E C6 = /(LF ) 0185 C35F C6 = /(VT ) 0186 C360 C7 = /(FF ) 0187 C361 C7 = /(CR ) 0188 C362 C5 = /(SO ) 0189 C363 C5 = /(SI ) 0190 C364 C7 = /(DLE ) 0191 C365 5F = DCA:SHR:&8-CODORG:SHL:&4+&10-&1 ;Queue 1 byte (DCA) 0192 C366 5E = DCB:SHR:&8-CODORG:SHL:&4+&10-&2 ;Queue 2 bytes (DCB) 0193 C367 5B = DCC:SHR:&8-CODORG:SHL:&4+&10-&5 ;Queue 5 bytes (DCC) 0194 C368 C8 = /(DCD ) 0195 C369 C5 = /(NAK ) 0196 C36A 5F = SYN:SHR:&8-CODORG:SHL:&4+&10-&1 ;Queue 1 byte (SYN) 0197 C36B 57 = ETB:SHR:&8-CODORG:SHL:&4+&10-&9 ;Queue 9 bytes (ETB) 0198 C36C 78 = CAN:SHR:&8-CODORG:SHL:&4+&10-&8 ;Queue 8 bytes (CAN) 0199 C36D 6B = EM:SHR:&8-CODORG:SHL:&4+&10-&5 ;Queue 5 bytes (EM) 0200 C36E C9 = /(SUB ) 0201 C36F C5 = /(ACK ) ;Points to an RTS 0202 C370 3C = FS:SHR:&8-CODORG:SHL:&4+&10-&4 ;Queue 4 bytes (FS) 0203 C371 7C = GS:SHR:&8-CODORG:SHL:&4+&10-&4 ;Queue 4 bytes (GS) 0204 C372 C7 = /(RS ) 0205 C373 4E = US:SHR:&8-CODORG:SHL:&4+&10-&2 ;Queue 2 bytes (US) 0206 C374 CF = /(DEL ) 0207 C375 0208 C375 ;ROW OFFSETS FOR H.R.G. 0209 C375 0210 C375 00 HRGTB = &00 0211 C376 00 = &00 0212 C377 02 = &02 0213 C378 80 = &80 0214 C379 05 = &05 0215 C37A 00 = &00 0216 C37B 07 = &07 0217 C37C 80 = &80 0218 C37D 0A = &0A 0219 C37E 00 = &00 0220 C37F 0C = &0C 0221 C380 80 = &80 0222 C381 0F = &0F 0223 C382 00 = &00 0224 C383 11 = &11 0225 C384 80 = &80 0226 C385 14 = &14 0227 C386 00 = &00 0228 C387 16 = &16 0229 C388 80 = &80 0230 C389 19 = &19 0231 C38A 00 = &00 0232 C38B 1B = &1B 0233 C38C 80 = &80 0234 C38D 1E = &1E 0235 C38E 00 = &00 0236 C38F 20 = &20 0237 C390 80 = &80 0238 C391 23 = &23 0239 C392 00 = &00 0240 C393 25 = &25 0241 C394 80 = &80 0242 C395 28 = &28 0243 C396 00 = &00 0244 C397 2A = &2A 0245 C398 80 = &80 Acorn macro assembler Page 6 VDU File - MOS01 0246 C399 2D = &2D 0247 C39A 00 = &00 0248 C39B 2F = &2F 0249 C39C 80 = &80 0250 C39D 32 = &32 0251 C39E 00 = &00 0252 C39F 34 = &34 0253 C3A0 80 = &80 0254 C3A1 37 = &37 0255 C3A2 00 = &00 0256 C3A3 39 = &39 0257 C3A4 80 = &80 0258 C3A5 3C = &3C 0259 C3A6 00 = &00 0260 C3A7 3E = &3E 0261 C3A8 80 = &80 0262 C3A9 41 = &41 0263 C3AA 00 = &00 0264 C3AB 43 = &43 0265 C3AC 80 = &80 0266 C3AD 46 = &46 0267 C3AE 00 = &00 0268 C3AF 48 = &48 0269 C3B0 80 = &80 0270 C3B1 4B = &4B 0271 C3B2 00 = &00 0272 C3B3 4D = &4D 0273 C3B4 80 = &80 0274 C3B5 0275 C3B5 ;ROW OFFSET TABLE FOR TELETEXT 0276 C3B5 0277 C3B5 00 TXTTB = &00 0278 C3B6 00 = &00 0279 C3B7 00 = &00 0280 C3B8 28 = &28 0281 C3B9 00 = &00 0282 C3BA 50 = &50 0283 C3BB 00 = &00 0284 C3BC 78 = &78 0285 C3BD 00 = &00 0286 C3BE A0 = &A0 0287 C3BF 00 = &00 0288 C3C0 C8 = &C8 0289 C3C1 00 = &00 0290 C3C2 F0 = &F0 0291 C3C3 01 = &01 0292 C3C4 18 = &18 0293 C3C5 01 = &01 0294 C3C6 40 = &40 0295 C3C7 01 = &01 0296 C3C8 68 = &68 0297 C3C9 01 = &01 0298 C3CA 90 = &90 0299 C3CB 01 = &01 0300 C3CC B8 = &B8 0301 C3CD 01 = &01 0302 C3CE E0 = &E0 0303 C3CF 02 = &02 0304 C3D0 08 = &08 0305 C3D1 02 = &02 0306 C3D2 30 = &30 0307 C3D3 02 = &02 0308 C3D4 58 = &58 0309 C3D5 02 = &02 0310 C3D6 80 = &80 0311 C3D7 02 = &02 0312 C3D8 A8 = &A8 0313 C3D9 02 = &02 0314 C3DA D0 = &D0 0315 C3DB 02 = &02 0316 C3DC F8 = &F8 0317 C3DD 03 = &03 0318 C3DE 20 = &20 0319 C3DF 03 = &03 0320 C3E0 48 = &48 0321 C3E1 03 = &03 0322 C3E2 70 = &70 0323 C3E3 03 = &03 0324 C3E4 98 = &98 0325 C3E5 03 = &03 0326 C3E6 C0 = &C0 0327 C3E7 0328 C3E7 ;NO. ROWS IN EACH MEMORY MODE 0329 C3E7 0330 C3E7 1F PROWS = &1F 0331 C3E8 1F = &1F 0332 C3E9 1F = &1F 0333 C3EA 18 = &18 0334 C3EB 1F = &1F 0335 C3EC 1F = &1F 0336 C3ED 18 = &18 0337 C3EE 18 = &18 0338 C3EF 0339 C3EF ;NO. COLS. IN EACH MEMORY MODE 0340 C3EF 0341 C3EF 4F PCOLS = &4F 0342 C3F0 27 = &27 0343 C3F1 13 = &13 0344 C3F2 4F = &4F 0345 C3F3 27 = &27 0346 C3F4 13 = &13 0347 C3F5 27 = &27 0348 C3F6 27 = &27 0349 C3F7 0350 C3F7 ;BYTES TO BE LOADED INTO mMODREG FOR DIFFERENT MODES 0351 C3F7 0352 C3F7 9C INDMOD = &9C 0353 C3F8 D8 = &D8 0354 C3F9 F4 = &F4 0355 C3FA 9C = &9C 0356 C3FB 88 = &88 0357 C3FC C4 = &C4 0358 C3FD 88 = &88 0359 C3FE 4B = &4B 0360 C3FF 0361 C3FF ;BYTES PER CHARACTER 0362 C3FF ;IN EACH MODE 0363 C3FF 0364 C3FF 08 BYTCHT = &08 0365 C400 10 = &10 0366 C401 20 = &20 Acorn macro assembler Page 7 VDU File - MOS01 0367 C402 08 = &08 0368 C403 08 = &08 0369 C404 10 = &10 0370 C405 08 = &08 0371 C406 01 = &01 0372 C407 0373 C407 ;MASK TABLES - must be contiguous 0374 C407 0375 C407 ;For each mode, the masks of each pixel, MS first 0376 C407 ;Note that it is now assumed that adjacent masks may be generated 0377 C407 ;by either ASL or LSR. 0378 C407 0379 C407 ;SIXTEEN colour mode 0380 C407 0381 C407 AA MASKTB = &AA 0382 C408 55 = &55 0383 C409 0384 C409 ;FOUR colour mode 0385 C409 88 = &88 0386 C40A 44 = &44 0387 C40B 22 = &22 0388 C40C 11 = &11 0389 C40D 0390 C40D ;TWO colour mode 0391 C40D 0392 C40D 80 BITTBL = &80 0393 C40E 40 = &40 0394 C40F 20 = &20 0395 C410 10 = &10 0396 C411 08 = &08 0397 C412 04 = &04 0398 C413 0399 C413 02 = &02 ;**** NEXT 3 BYTES USED BY CFS **** 0400 C414 ;Uses $01 of next table 0401 C414 0402 C414 ;COLOURS AVAILABLE FOR MODES 0403 C414 0404 C414 01 COLMOD = &01 0405 C415 03 = &03 0406 C416 0F = &0F 0407 C417 0408 C417 01 = &01 ;**** NEXT 3 BYTES USED BY CFS **** 0409 C418 01 = &01 0410 C419 03 = &03 0411 C41A 01 = &01 0412 C41B ;TTX - must be 0 - uses 1st byte of next table 0413 C41B 0414 C41B ;Bytes for forming ZGORA & ZGEOR 0415 C41B ;Tables have been run into each other to save bytes. 0416 C41B ;They should be as follows 0417 C41B 0418 C41B ;TBZGOO OR the OR :- $FF,$00,$00,$FF,$FF,$FF 0419 C41B ;TBZGEO EOR the OR :- $00,$00,$FF,$FF,$FF,$FF 0420 C41B ;TBZGOE OR the EOR :- $00,$FF,$00,$00,$FF,$FF 0421 C41B ;TBZGEE EOR the EOR :- $FF,$FF,$FF,$00,$00,$FF 0422 C41B 0423 C41B ;These are for the colour modes 0 to 5, being 0424 C41B ;0=Store,1=OR,2=AND,3=EOR,4=Invert,5=No change 0425 C41B 0426 C41B 00 TBZGOE = &00 0427 C41C FF TBZGOO = &FF 0428 C41D 00 TBZGEO = &00 0429 C41E 00 = &00 0430 C41F FF = &FF 0431 C420 FF TBZGEE = &FF 0432 C421 FF = &FF 0433 C422 FF = &FF 0434 C423 00 = &00 ;Uses next $00, $FF 0435 C424 0436 C424 ;~~~ COLOUR TABLES ~~~ 0437 C424 0438 C424 ;FULL COLOUR TABLES 0439 C424 ;Tables of 'full colours', 0440 C424 ;i.e. of bytes with all bits 0441 C424 ;set to 1 colour, in ascending 0442 C424 ;colour order 0443 C424 0444 C424 00 FCOLTB = &00 ;Two colour table 0445 C425 FF = &FF 0446 C426 0447 C426 ;Four colour table 0448 C426 0449 C426 00 = &00 0450 C427 0F = &0F 0451 C428 F0 = &F0 0452 C429 FF = &FF 0453 C42A 0454 C42A ;Sixteen colour table 0455 C42A 0456 C42A 00 = &00 0457 C42B 03 = &03 0458 C42C 0C = &0C 0459 C42D 0F = &0F 0460 C42E 30 = &30 0461 C42F 33 = &33 0462 C430 3C = &3C 0463 C431 3F = &3F ;INVSXT This byte used to invert graphics pixels 0464 C432 C0 = &C0 0465 C433 C3 = &C3 0466 C434 CC = &CC 0467 C435 CF = &CF 0468 C436 F0 = &F0 0469 C437 F3 = &F3 0470 C438 FC = &FC 0471 C439 FF = &FF 0472 C43A 0473 C43A ;TABLE FOR NPIX 0474 C43A 0475 C43A ;No. pixles per byte in each graphics mode 0476 C43A ;(0 if not graphics) 0477 C43A 0478 C43A 07 NPIXTB = &07 0479 C43B 03 = &03 0480 C43C 01 = &01 0481 C43D 00 = &00 ;(Non graphics) 0482 C43E 07 = &07 0483 C43F 03 = &03 0484 C440 ;Non-graphics modes - use next 2 $00s 0485 C440 0486 C440 ;MEMORY MAP TYPES 0487 C440 ;Index from MODE (0..7), to Acorn macro assembler Page 8 VDU File - MOS01 0488 C440 ;the following 5 element tables 0489 C440 0490 C440 MODETB 0491 C440 00 = &00 0492 C441 SOUNDV ;channel dependent period offset 0493 C441 C43D SCHOFF * SOUNDV -&04 0494 C441 0495 C441 00 = &00 0496 C442 00 = &00 0497 C443 01 = &01 0498 C444 02 = &02 0499 C445 02 = &02 0500 C446 03 = &03 0501 C447 ;Uses $04 of next table 0502 C447 0503 C447 0504 C447 ;EXIT WINDOW OFFSET TABLE 0505 C447 0506 C447 04 EWTBA = &04 0507 C448 00 = &00 0508 C449 06 = &06 0509 C44A 02 = &02 0510 C44B 0511 C44B 0512 C44B ;C0 control table 0513 C44B ;C1 control table 0514 C44B 0515 C44B 0D CONE = &0D 0516 C44C 05 = &05 0517 C44D 0D = &0D 0518 C44E 05 = &05 ;Uses next $04 0519 C44F 04 CZERO = &04 0520 C450 04 = &04 0521 C451 0C = &0C 0522 C452 0C = &0C 0523 C453 04 = &04 0524 C454 0525 C454 ;TABLES OF JUMP VECTORS 0526 C454 ;FOR CLEAR SCREEN 0527 C454 0528 C454 07 CLSCTA = CLASCA ;(LSB) 0529 C455 37 = CLASCB 0530 C456 7F = CLASCC 0531 C457 97 = CLASCD 0532 C458 EB = CLASCE 0533 C459 0534 C459 ;CLSCTB = CLASCA / ;(MSB) 0535 C459 ; = CLASCB / 0536 C459 ; = CLASCC / 0537 C459 ; = CLASCD / 0538 C459 ; = CLASCE / 0539 C459 0540 C459 ;NO. BYTES PER SCREEN (MSB) 0541 C459 0542 C459 50 BYTSTA = &50 0543 C45A 40 = &40 0544 C45B 28 = &28 0545 C45C 20 = &20 0546 C45D 04 = &04 0547 C45E 0548 C45E ;MSB OF SCREEN START 0549 C45E 0550 C45E 30 STSCTB = &30 0551 C45F 40 = &40 0552 C460 58 = &58 0553 C461 60 = &60 0554 C462 7C = &7C 0555 C463 0556 C463 ;BYTE WIDTH TYPES 0557 C463 ;Index from MEMODE (0..4), to 0558 C463 ;the following 3 element tables 0559 C463 0560 C463 ;Now replaced with LSRA 0561 C463 0562 C463 ;LSB OF NO. BYTES PER ROW 0563 C463 0564 C463 28 BYTRTA = &28 0565 C464 40 = &40 0566 C465 80 = &80 0567 C466 0568 C466 ;LSB OF SCREEN OFFSET TABLES 0569 C466 0570 C466 B5 TBZTBA = TXTTB 0571 C467 75 = HRGTB 0572 C468 75 = HRGTB 0573 C469 0574 C469 0575 C469 ;CRTC TABLES 0576 C469 0577 C469 ;INDEX FOR CRTC TABLES 0578 C469 0579 C469 0B CRTCX = &0B 0580 C46A 17 = &17 0581 C46B 23 = &23 0582 C46C 2F = &2F 0583 C46D 3B = &3B 0584 C46E 0585 C46E ;CRTC TABLE FOR MODES 0-2 0586 C46E 0587 C46E 7F CRTCTB = &7F 0588 C46F 50 = &50 0589 C470 62 = &62 0590 C471 28 = &28 ;VS=2 0591 C472 26 = &26 0592 C473 00 = &00 0593 C474 20 = &20 0594 C475 22 = &22 ;was $22 & then it was $23 0595 C476 01 = &01 0596 C477 07 = &07 0597 C478 67 = &67 0598 C479 08 = &08 0599 C47A 0600 C47A ;CRTC TABLE FOR MODE 3 0601 C47A 0602 C47A 7F = &7F 0603 C47B 50 = &50 0604 C47C 62 = &62 0605 C47D 28 = &28 ;VS=2 0606 C47E 1E = &1E 0607 C47F 02 = &02 0608 C480 19 = &19 Acorn macro assembler Page 9 VDU File - MOS01 0609 C481 1B = &1B ;was $1B & then it was $1C 0610 C482 01 = &01 0611 C483 09 = &09 0612 C484 67 = &67 0613 C485 09 = &09 0614 C486 0615 C486 ;CRTC TABLE FOR MODES 4-5 0616 C486 0617 C486 3F = &3F 0618 C487 28 = &28 0619 C488 31 = &31 0620 C489 24 = &24 ;VS=2 0621 C48A 26 = &26 0622 C48B 00 = &00 0623 C48C 20 = &20 0624 C48D 22 = &22 ;was $22 & then it was $23 0625 C48E 01 = &01 0626 C48F 07 = &07 0627 C490 67 = &67 0628 C491 08 = &08 0629 C492 0630 C492 ;CRTC TABLE FOR MODE 6 0631 C492 0632 C492 3F = &3F 0633 C493 28 = &28 0634 C494 31 = &31 0635 C495 24 = &24 ;VS=2 0636 C496 1E = &1E 0637 C497 02 = &02 0638 C498 19 = &19 0639 C499 1B = &1B ;was $1B & then it was $1C 0640 C49A 01 = &01 0641 C49B 09 = &09 0642 C49C 67 = &67 0643 C49D 09 = &09 0644 C49E 0645 C49E ;CRTC TABLE FOR MODE 7 0646 C49E 0647 C49E 3F = &3F 0648 C49F 28 = &28 0649 C4A0 33 = &33 0650 C4A1 24 = &24 ;VS=2 0651 C4A2 1E = &1E 0652 C4A3 02 = &02 0653 C4A4 19 = &19 0654 C4A5 1B = &1B ;was $1B & then it was $1C 0655 C4A6 93 = &93 0656 C4A7 12 = &12 0657 C4A8 72 = &72 0658 C4A9 13 = &13 0659 C4AA 0660 C4AA ;JUMP TABLES FOR PLOTTING ROUTINES 0661 C4AA 0662 C4AA 57 D1JTB = EA 0663 C4AB D3 = /(EA ) 0664 C4AC 4F = NA 0665 C4AD D3 = /(NA ) 0666 C4AE 0667 C4AE 3B D2JTBL = EB 0668 C4AF 45 = WB 0669 C4B0 13 = NB 0670 C4B1 1C = SB 0671 C4B2 0672 C4B2 D3 D2JTBH = /(EB ) 0673 C4B3 D3 = /(WB ) 0674 C4B4 D3 = /(NB ) 0675 C4B5 D3 = /(SB ) 0676 C4B6 0677 C4B6 0678 C4B6 ;TELETEXT CONVERSION TABLE 0679 C4B6 0680 C4B6 23 TTXTB = &23 0681 C4B7 5F = &5F 0682 C4B8 60 = &60 0683 C4B9 23 = &23 0684 C4BA 0685 C4BA 0686 C4BA ; font table 0687 C4BA 0688 C4BA FFSZOT ;Four,Five,Six,Zero,One,Two 0689 C4BA 04 = &04 0690 C4BB 05 = &05 0691 C4BC 06 = &06 0692 C4BD 00 = &00 0693 C4BE 01 = &01 0694 C4BF 02 = &02 0695 C4C0 0696 C4C0 0697 C4C0 LNK MOS02 0001 C4C0 0002 C4C0 TTL VDU File - MOS02 0003 C4C0 OPT MOS02 Acorn macro assembler Page 10 VDU File - MOS02 0004 C4C0 0005 C4C0 ;Last revision 30/04/82 0006 C4C0 0007 C4C0 ;30/04/82 Recoded to allow for reverse queueing 0008 C4C0 ;19/04/82 To put ASCIQ in line, and various other byte savings 0009 C4C0 ;19/11/81 No longer include bell in printer range check 0010 C4C0 0011 C4C0 0012 C4C0 ;ENTRY POINT - SELECT ROUTINE 0013 C4C0 0014 C4C0 0015 C4C0 VDU 0016 C4C0 AE 6A 02 LDX QPOSN ;Are we Qing ? 0017 C4C3 D0 4E BNE QING ;Yes?, then queue this byte 0018 C4C5 24 D0 BIT STATS 0019 C4C7 50 0F BVC NOTCEA ;In C.E. mode? 0020 C4C9 20 67 C5 JSR CSWAP ;Yes?, then swap cursors 0021 C4CC 20 60 CD JSR OCSRDL ;Delete the output cursor 0022 C4CF 30 07 BMI NOTCEA ;Are we disabled ? then skip 0023 C4D1 C9 0D CMPIM TRMCH ;No?, then is this TRMCH ? 0024 C4D3 D0 03 BNE NOTCEA 0025 C4D5 20 AA D8 JSR CSEDEX ;Yes?, then exit C.E. mode 0026 C4D8 C9 7F NOTCEA CMPIM &7F ;No?, then form vector 0027 C4DA F0 13 BEQ ISDEL 0028 C4DC C9 20 CMPIM &20 0029 C4DE 90 11 BCC NOTDEL ; Branch if unprintable 0030 C4E0 24 D0 BIT STATS ;Printable - are we disabled ? 0031 C4E2 30 06 BMI NOTC20 ;Yes, then print it if print module on 0032 C4E4 20 A7 CF JSR VDUPR ;No?, then print to VDU 0033 C4E7 20 63 C6 JSR HT 0034 C4EA [ MOS125 = &FF 0036 C4EA | 0037 C4EA NOTC20 ;A dead 0038 C4EA A5 D0 LDA STATS 0039 C4EC 4A LSRA ;C=1 if printer module on 0040 C4ED 10 71 BPL CSWDEX ;& ditto 0041 C4EF ] 0042 C4EF 0043 C4EF A9 20 ISDEL LDAIM &20 ;(Form correct index for DEL) 0044 C4F1 0045 C4F1 A8 NOTDEL TAY 0046 C4F2 B9 33 C3 LDAAY JTBLO ;Get LSByte of jump vector 0047 C4F5 8D 5D 03 STA JVEC 0048 C4F8 B9 54 C3 LDAAY JTBHI ;Get MSByte 0049 C4FB 30 4A BMI REXEC ;No Qing required, so execute routine 0050 C4FD AA TAX ;b7=0, so Q needed - set it up 0051 C4FE 09 F0 ORAIM &F0 ;2's comp. of no. of bytes to Q 0052 C500 8D 6A 02 STA QPOSN 0053 C503 8A TXA ;Generate MSByte of address - MSNybble, plus CODORG 0054 C504 4A LSRA 0055 C505 4A LSRA 0056 C506 4A LSRA 0057 C507 4A LSRA 0058 C508 18 CLC 0059 C509 69 C3 ADCIM CODORG ;Forms the high byte of the vector 0060 C50B 8D 5E 03 STA JVEC +&01 0061 C50E 24 D0 BIT STATS ;Swap back again if C.E. 0062 C510 70 1E BVS NOTC10 0063 C512 [ MOS125 = &FF 0065 C512 | 0066 C512 ;adcim codorg never overflows (here...), C=0 0067 C512 ] 0068 C512 60 ACK RTS ;NUL points at this to save a byte 0069 C513 0070 C513 0071 C513 9D 24 02 QING STAAX QEND-&FF ;Q the byte 0072 C516 E8 INX 0073 C517 8E 6A 02 STX QPOSN ;(z preserved from INX) 0074 C51A D0 17 BNE CLCEX ;More to do?, then exit 0075 C51C 24 D0 BIT STATS ;Disabled?, then go away 0076 C51E 30 15 BMI DISABL 0077 C520 70 05 BVS NOTCEB ;C.E. mode, then do swapping 0078 C522 20 FA CC JSR RUNNER 0079 C525 18 CLC 0080 C526 60 RTS 0081 C527 0082 C527 20 67 C5 NOTCEB JSR CSWAP 0083 C52A 20 60 CD JSR OCSRDL 0084 C52D 20 FA CC JSR RUNNER 0085 C530 20 64 C5 NOTC10 JSR REXE10 0086 C533 18 CLCEX CLC 0087 C534 60 RTS 0088 C535 0089 C535 AC 5E 03 DISABL LDY JVEC +&01 ;Was this an SOH ? 0090 C538 C0 C5 CPYIM /(SOH ) 0091 C53A D0 F7 BNE CLCEX ;No?, then go home 0092 C53C 0093 C53C AA SOH TAX ;Yes, then (A)=Byte to be printed 0094 C53D A5 D0 LDA STATS ;Is printing enabled ? 0095 C53F 4A LSRA 0096 C540 90 D0 BCC ACK 0097 C542 8A TXA 0098 C543 [ MOS125 = &FF 0099 C543 | 0100 C543 18 CLC ;C=0, prevent second printing; PRINT preserves flags 0101 C544 ] 0102 C544 4C 70 E1 JMP PRINT ;print character and return, setting c=0 (done by MOS) 0103 C547 0104 C547 [ MOS125 = &FF 0127 C547 | 0128 C547 REXEC ;starting +2 from NOTC20; 1 spare byte 0129 C547 8D 5E 03 STA JVEC +&01 0130 C54A A5 D0 LDA STATS 0131 C54C 6A RORA ;Is printer module on? 0132 C54D 98 TYA ;AND Is it range $08 to $0D ? (no longer include bell) 0133 C54E 6A RORA ;+4 = +6 0134 C54F C9 84 CMPIM &84 0135 C551 49 FF EORIM &FF 0136 C553 6A RORA 0137 C554 69 43 ADCIM &43 0138 C556 98 TYA ;-2 = +4 0139 C557 ; 0140 C557 24 D0 BIT STATS ;Execute routine - are we disabled ? 0141 C559 30 24 BMI ACKQ ;Was it an ACK? (can't be an SOH cos she queues) 0142 C55B ; 0143 C55B 08 PHP ;and push c 0144 C55C 20 FA CC JSR RUNNER ;Do the routine 0145 C55F 28 PLP 0146 C560 CSWDEX ;enter with C=printer module on ;-5 = -1; 4 spare bytes 0147 C560 24 D0 BIT STATS ;Following preserves c 0148 C562 50 AE BVC ACK ;Not C.E. so exit Acorn macro assembler Page 11 VDU File - MOS02 0149 C564 20 70 CD REXE10 JSR OCSRWR ;Write output cursor 0150 C567 ] 0151 C567 0152 C567 ;CSWAP - swap input and output text cursors 0153 C567 ; invert b1 of STATS 0154 C567 0155 C567 08 CSWAP PHP ;Preserve carry 0156 C568 48 PHA 0157 C569 A2 18 LDXIM CSX-V 0158 C56B A0 64 LDYIM PCSX-V 0159 C56D 20 CC CD JSR SWAP2 0160 C570 20 09 CF JSR TADDRY ;Address this point 0161 C573 20 D8 C9 JSR CSDSP 0162 C576 A5 D0 LDA STATS 0163 C578 49 02 EORIM &02 ;Invert bit 1 of STATS 0164 C57A 85 D0 STA STATS 0165 C57C 68 PLA 0166 C57D 28 PLP ;Restore c 0167 C57E 60 RTS 0168 C57F 0169 C57F ACKQ 0170 C57F ; C=0 => character not printable, C=1 => printable 0171 C57F 49 06 EORIM ACKASC ;Was it an ACK ? 0172 C581 D0 08 BNE VDURTS ;[not ACK] 0173 C583 ; 0174 C583 ; C=0 cos ACK not printable 0175 C583 A9 7F LDAIM &7F ;Yes?, then clear b7 of STATS 0176 C585 90 20 BCC STTAND ;always jump 0177 C587 0178 C587 0179 C587 0180 C587 ;Test to see if printable ($20-$7E or $80-$FF) 0181 C587 ;Returns c=1 iff printable, c=0 otherwise 0182 C587 0183 C587 0184 C587 ;ANOMQ Returns z=0 iff cursors joined 0185 C587 0186 C587 A5 D0 ANOMQ LDA STATS 0187 C589 29 20 ANDIM &20 ;Is b5 set ? (Answer to z) 0188 C58B VDURTS 0189 C58B 60 RTS ;Returns(A)=0 if b5 clear 0190 C58C 0191 C58C ;INDIVIDUAL ROUTINES 0192 C58C 0193 C58C ;NUL ($00) - do nothing 0194 C58C 0195 C58C ;Jump table points to ACK, an RTS, to save a byte 0196 C58C 0197 C58C ;SOH ($01) - Next char to printer 0198 C58C 0199 C58C ;This is taken care of above 0200 C58C 0201 C58C 0202 C58C ;SO ($0E) - Page mode on 0203 C58C 0204 C58C A0 00 SO LDYIM &00 ;Initialise LINES 0205 C58E 8C 69 02 STY LINES 0206 C591 A9 04 LDAIM &04 ;Set b2 of STATS 0207 C593 D0 07 BNE STTOR 0208 C595 0209 C595 ;SI ($0F) - Page mode OFF 0210 C595 ; This is frigged below 0211 C595 0212 C595 ;STX ($02) - Start printer 0213 C595 0214 C595 20 F2 E1 STX JSR mUPT ;inform network (A assumed to contain $02) 0215 C598 A9 94 LDAIM &94 ;Set bit 0 of STATS. This maps to $01 0216 C59A 0217 C59A ;NAK ($15) - Turn VDU off 0218 C59A 0219 C59A 49 95 NAK EORIM &95 ;Set b7 of STATS. Map $15 to $80 0220 C59C 0221 C59C 05 D0 STTOR ORA STATS 0222 C59E D0 09 BNE STTEXT ;(branch always taken unless ORed with 0) 0223 C5A0 0224 C5A0 0225 C5A0 ;ETX ($03) - Stop printer 0226 C5A0 0227 C5A0 20 F2 E1 ETX JSR mUPT ;inform network (A assumed to contain $03) 0228 C5A3 A9 0A LDAIM &0A ;clear bit 0 of STATS. Maps $0A on to $FE 0229 C5A5 0230 C5A5 49 F4 SI EORIM &F4 ;Clears b2 of STATS. Maps $0F on to $FB 0231 C5A7 0232 C5A7 25 D0 STTAND AND STATS 0233 C5A9 85 D0 STTEXT STA STATS 0234 C5AB 60 EOTEXT RTS 0235 C5AC 0236 C5AC 0237 C5AC ;EOT ($04) - Separate cursors 0238 C5AC 0239 C5AC AD 61 03 EOT LDA NPIX ;Is this a graphics mode ? 0240 C5AF F0 FA BEQ EOTEXT ;NO, then return 0241 C5B1 20 27 C9 JSR ETCA ;Redisplay old cursor 0242 C5B4 A9 DF LDAIM &DF ;Clear b5 of STATS 0243 C5B6 D0 EF BNE STTAND ;(branch always taken) 0244 C5B8 0245 C5B8 ;ENQ ($05) - Join cursors 0246 C5B8 ;Store & hide current cursor 0247 C5B8 ;Set bit 5 of STATS 0248 C5B8 0249 C5B8 AD 61 03 ENQ LDA NPIX ;Is this a graphics mode ? 0250 C5BB F0 EE BEQ EOTEXT ;NO, then return 0251 C5BD ;Access R10 OF 6845. NB cannot do this through CRTCP. 0252 C5BD A9 20 LDAIM &20 ;Hide cursor 0253 C5BF 20 2A C9 JSR ETCB ; Preserves flags 0254 C5C2 D0 D8 BNE STTOR ;Set bit 5 of STATS, (A) preserved by ETCB 0255 C5C4 0256 C5C4 ;ACK ($06) - Turn VDU drivers on again 0257 C5C4 ;Clear bit 7 of STATS 0258 C5C4 0259 C5C4 ;Taken care of above 0260 C5C4 0261 C5C4 ;BELL ($07) - Ring BELL 0262 C5C4 0263 C5C4 ;The routine BELL is externally declared in file UADE90 0264 C5C4 0265 C5C4 ;Cursor primitives 0266 C5C4 0267 C5C4 ;BS ($08) - Cursor left 1 character position 0268 C5C4 0269 C5C4 20 87 C5 BS JSR ANOMQ Acorn macro assembler Page 12 VDU File - MOS02 0270 C5C7 D0 55 BNE CSAL 0271 C5C9 0272 C5C9 ;Cursor left 0273 C5C9 0274 C5C9 CE 18 03 CSL DEC CSX 0275 C5CC AE 18 03 LDX CSX ;Over LH margin ? 0276 C5CF EC 08 03 CPX TWLCOL 0277 C5D2 30 19 BMI CSLC ;Yes, then up (see below) a line 0278 C5D4 AD 4A 03 LDA CSPOSN ;Move cursor left 0279 C5D7 38 SEC 0280 C5D8 ED 4F 03 SBC BYTCH 0281 C5DB AA TAX 0282 C5DC AD 4B 03 LDA CSPOSN +&01 0283 C5DF E9 00 SBCIM &00 0284 C5E1 CD 4E 03 CMP BEGSCN ;Wraparound ? 0285 C5E4 B0 03 BCS CSLA 0286 C5E6 6D 54 03 ADC BYTSCN ;Yes, then add screen 0287 C5E9 A8 CSLA TAY 0288 C5EA 4C CC C9 JMP CSDSPA 0289 C5ED 0290 C5ED AD 0A 03 CSLC LDA TWRCOL ;Put csr = RH edge 0291 C5F0 8D 18 03 STA CSX ;& fall through to ... 0292 C5F3 0293 C5F3 ;Cursor up 0294 C5F3 0295 C5F3 CE 69 02 CSU DEC LINES ;One more line to print before page mode occurs 0296 C5F6 10 03 BPL CSUC 0297 C5F8 EE 69 02 INC LINES ;At top of page, so don't go -ve! 0298 C5FB AE 19 03 CSUC LDX CSY ;Cursor on top row ? 0299 C5FE EC 0B 03 CPX TWTROW 0300 C601 F0 06 BEQ CSUA ;Yes, then scroll 0301 C603 CE 19 03 DEC CSY 0302 C606 4C AE C6 JMP CSDA 0303 C609 0304 C609 18 CSUA CLC 0305 C60A 20 35 CD JSR ENSCRL ;Account for scroll disable 0306 C60D A9 08 LDAIM &08 ;Test hard/soft flag 0307 C60F 24 D0 BIT STATS 0308 C611 D0 05 BNE CSUB ;S3 set, soft scroll 0309 C613 20 6A C9 JSR HSCRDN ;S3 clear, hard scroll 0310 C616 D0 03 BNE CSUD ; HSCRDN returns zero false 0311 C618 20 93 CD CSUB JSR SSCRDN 0312 C61B 4C AB C6 CSUD JMP CSDC 0313 C61E A2 00 CSAL LDXIM &00 0314 C620 ; And fall through to 0315 C620 0316 C620 ;Move graphics cursor 1 character - primitives. 0317 C620 ;(X) = 0 if X cursor to be moved 0318 C620 ; 2 if Y cursor to be moved 0319 C620 ;Iff (X)=0, then if off window, LF/VT occurs 0320 C620 ;If cursor crosses margin, then goes to opposite margin. 0321 C620 ;Go down 1 character location 0322 C620 0323 C620 86 DB GCSCHD STX ZTEMP +&01 ;Store offset 0324 C622 20 1F D1 JSR WINDCS ;Window current cursor (result to ZTEMP) 0325 C625 A6 DB LDX ZTEMP +&01 ;Subtract 8 from cursor 0326 C627 38 SEC 0327 C628 BD 24 03 LDAAX GCSIR 0328 C62B E9 08 SBCIM &08 0329 C62D 9D 24 03 STAAX GCSIR 0330 C630 B0 03 BCS GCSHDA 0331 C632 DE 25 03 DECAX GCSIR+&01 0332 C635 A5 DA GCSHDA LDA ZTEMP ;Get window 0333 C637 D0 1E BNE GCSHDB ;Out of window to begin with?, then skip 0334 C639 20 1F D1 JSR WINDCS ;Window current point 0335 C63C F0 19 BEQ GCSHDB ;Still inside? , then return 0336 C63E A6 DB LDX ZTEMP +&01 ;Gone outside?, then go to high margin 0337 C640 BD 04 03 LDAAX GWRCOL 0338 C643 E0 01 CPXIM &01 ;Plot by X?, then back up 1 character 0339 C645 B0 02 BCS GCSHDC 0340 C647 E9 06 SBCIM &06 ;c=0. so subt. 7 to get char. just on screen 0341 C649 9D 24 03 GCSHDC STAAX GCSIR 0342 C64C BD 05 03 LDAAX GWRCOL+&01 0343 C64F E9 00 SBCIM &00 0344 C651 9D 25 03 STAAX GCSIR+&01 0345 C654 8A TXA ;Plot by X?, then go up a line as well 0346 C655 F0 08 BEQ CSAU 0347 C657 4C 7D CA GCSHDB JMP IEG 0348 C65A 0349 C65A 0350 C65A ;VT ($0B) - Cursor up 1 character line 0351 C65A 0352 C65A 20 87 C5 VT JSR ANOMQ 0353 C65D F0 94 BEQ CSU 0354 C65F A2 02 CSAU LDXIM &02 0355 C661 D0 52 BNE GCSCHU ;(branch always taken) 0356 C663 0357 C663 ;HT ($09) - Cursor right 1 character position 0358 C663 0359 C663 A5 D0 HT LDA STATS ;Encode ANOMQ because this routine often referenced 0360 C665 29 20 ANDIM &20 0361 C667 D0 4A BNE CSAR 0362 C669 0363 C669 ;Cursor right 0364 C669 0365 C669 AE 18 03 CSR LDX CSX ;Cursor over RH col ? 0366 C66C EC 0A 03 CPX TWRCOL 0367 C66F B0 12 BCS CSRC 0368 C671 EE 18 03 INC CSX 0369 C674 AD 4A 03 LDA CSPOSN 0370 C677 6D 4F 03 ADC BYTCH ;Add no. bytes per char 0371 C67A AA TAX 0372 C67B AD 4B 03 LDA CSPOSN +&01 ;to posn. of csr. 0373 C67E 69 00 ADCIM &00 ;sets n for test in CSDSPA 0374 C680 4C CC C9 JMP CSDSPA 0375 C683 AD 08 03 CSRC LDA TWLCOL ;Put csr = LH edge 0376 C686 8D 18 03 STA CSX ;& fall through to ... 0377 C689 0378 C689 ;Cursor down 0379 C689 0380 C689 18 CSD CLC ;do not set LEDs on first test for page wait (MOS requirement) 0381 C68A 20 C0 CA JSR PAGE ;Account for page mode 0382 C68D AE 19 03 LDX CSY ;Is cursor off bottom? 0383 C690 EC 09 03 CPX TWBROW 0384 C693 B0 05 BCS CSDD ;Yes, then scroll 0385 C695 EE 19 03 INC CSY ;No, then move down line 0386 C698 90 14 BCC CSDA ;(branch always taken) 0387 C69A 0388 C69A 20 35 CD CSDD JSR ENSCRL ;Account for scroll disable 0389 C69D A9 08 LDAIM &08 ;Test hard/soft flag 0390 C69F 24 D0 BIT STATS Acorn macro assembler Page 13 VDU File - MOS02 0391 C6A1 D0 05 BNE CSDB 0392 C6A3 20 7A C9 JSR HSCRUP ;No windows set, so use hard scroll 0393 C6A6 D0 03 BNE CSDC ; HSCRUP unsets zero 0394 C6A8 20 00 CE CSDB JSR SSCRUP ;Windows set, so use soft scroll 0395 C6AB 20 AC CE CSDC JSR CLTLIN ;Clear the line on which CSY lies 0396 C6AE 20 09 CF CSDA JSR TADDRY ;address the cursor, point guaranteed in window 0397 C6B1 90 7E BCC FSD ;and display it (TADDRY returns carry clear) 0398 C6B3 A2 00 CSAR LDXIM &00 0399 C6B5 ; And fall through to 0400 C6B5 0401 C6B5 ;Move graphics cursor 1 character - primitives. 0402 C6B5 ;(X) = 0 if Y cursor to be moved 0403 C6B5 ; 2 if X cursor to be moved 0404 C6B5 ;Iff (X)=0, then if off window, LF/VT occurs 0405 C6B5 ;If cursor crosses margin, then goes to opposite margin. 0406 C6B5 0407 C6B5 86 DB GCSCHU STX ZTEMP +&01 ;Store offset 0408 C6B7 20 1F D1 JSR WINDCS ;Window current cursor (result to ZTEMP) 0409 C6BA A6 DB LDX ZTEMP +&01 ;Add 8 to cursor 0410 C6BC 18 CLC 0411 C6BD BD 24 03 LDAAX GCSIR 0412 C6C0 69 08 ADCIM &08 0413 C6C2 9D 24 03 STAAX GCSIR 0414 C6C5 90 03 BCC GCSHUA 0415 C6C7 FE 25 03 INCAX GCSIR+&01 0416 C6CA A5 DA GCSHUA LDA ZTEMP ;Get window 0417 C6CC D0 89 BNE GCSHDB ;Out of window to begin with?, then skip 0418 C6CE 20 1F D1 JSR WINDCS ;Window current point 0419 C6D1 F0 84 BEQ GCSHDB ;Still inside? , then return 0420 C6D3 A6 DB LDX ZTEMP +&01 ;Gone outside?, then go to low margin 0421 C6D5 BD 00 03 LDAAX GWLCOL 0422 C6D8 E0 01 CPXIM &01 ;Plot by Y?, then go up a line 0423 C6DA 90 02 BCC GCSHUC 0424 C6DC 69 06 ADCIM &06 ;c=1, so add 7 to get char. just on screen 0425 C6DE 9D 24 03 GCSHUC STAAX GCSIR 0426 C6E1 BD 01 03 LDAAX GWLCOL+&01 0427 C6E4 69 00 ADCIM &00 0428 C6E6 9D 25 03 STAAX GCSIR+&01 0429 C6E9 8A TXA ;Plot by X? 0430 C6EA F0 08 BEQ CSAD ;Yes?, then go down a line as well 0431 C6EC 4C 7D CA JMP IEG ;No?, then exit 0432 C6EF 0433 C6EF 0434 C6EF ;LF ($0A) - Cursor down 1 character line 0435 C6EF 0436 C6EF 20 87 C5 LF JSR ANOMQ 0437 C6F2 F0 95 BEQ CSD 0438 C6F4 A2 02 CSAD LDXIM &02 0439 C6F6 4C 20 C6 JMP GCSCHD 0440 C6F9 0441 C6F9 ;FS ($1C) Define text area 0442 C6F9 0443 C6F9 ;QEND-3 = L.H. margin = TWLCOL 0444 C6F9 ;QEND-2 = Bottom row = TWBROW 0445 C6F9 ;QEND-1 = R.H. margin = TWRCOL 0446 C6F9 ;QEND = Top row = TWTROW 0447 C6F9 0448 C6F9 [ MOS125 = &FF 0464 C6F9 | 0465 C6F9 AE 55 03 FS LDX MODE 0466 C6FC AD 21 03 LDA QEND-&02 ;Do y co-ordinates. Get bottom (higher numbered) row 0467 C6FF CD 23 03 CMP QEND ;Top row above bottom ? 0468 C702 90 16 BCC FSF ;No?, then fail 0469 C704 DD E7 C3 CMPAX PROWS ;Is > max. no. rows? 0470 C707 F0 02 BEQ FSC 0471 C709 B0 09 BCS FSE ;Yes, then fail 0472 C70B AD 22 03 FSC LDA QEND-&01 ;Do x co-ordinates. Get RH margin 0473 C70E A8 TAY 0474 C70F DD EF C3 CMPAX PCOLS ;Is > than max. cols? 0475 C712 F0 02 BEQ FSB 0476 C714 FSE 0477 C714 B0 74 BCS PRACX ;Yes, then fail 0478 C716 38 FSB SEC 0479 C717 ED 20 03 SBC QEND-&03 ;How many cols. wide ? 0480 C71A FSF 0481 C71A 90 6E BCC PRACX ;Fail if -ve no. cols. 0482 C71C ] 0483 C71C A8 TAY 0484 C71D 20 5C CA JSR SETPWW ;Set PWWDTH 0485 C720 A9 08 LDAIM &08 ;Set bit 3 for soft scrolling 0486 C722 20 9C C5 JSR STTOR 0487 C725 A2 20 LDXIM QEND-&03-V ;copy Q to TWxxxx 0488 C727 A0 08 LDYIM TWLCOL-V 0489 C729 20 41 D4 JSR COPYF 0490 C72C 20 EB CE JSR TADDR ;Is cursor still inside 0491 C72F B0 33 BCS RS ;No, then home cursor 0492 C731 4C D8 C9 FSD JMP CSDSP 0493 C734 0494 C734 RPXLXY 0495 C734 A0 03 LDYIM &03 ;~~~ Read pixel at (x,y) ~~~ 0496 C736 B1 F0 PRAAA LDAIY WARGS ;Copy (x,y) to RPXLWS ... 0497 C738 99 28 03 STAAY RPXLWS 0498 C73B 88 DEY 0499 C73C 10 F8 BPL PRAAA 0500 C73E A9 28 LDAIM RPXLWS-V ;Convert in internal co-ordinates 0501 C740 20 CE D7 JSR RPXLD ;Read pixel if extant 0502 C743 A0 04 LDYIM &04 ;Store in (XY) +4 0503 C745 D0 3B BNE PRACB ;(branch always taken) 0504 C747 0505 C747 [ MOS125 = &FF 0516 C747 ] 0517 C747 0518 C747 ;FF ($0C) Form feed 0519 C747 0520 C747 20 87 C5 FF JSR ANOMQ ;Cursors joined ? 0521 C74A D0 78 BNE FFANOM ;Yes, then clear graphics area 0522 C74C A5 D0 LDA STATS ;Window set ? 0523 C74E 29 08 ANDIM &08 ;Test bit 3 of STATS 0524 C750 [ MOS125 = &FF 0527 C750 | 0528 C750 F0 64 BEQ FFC ;Clear?, then fast clear 0529 C752 ] 0530 C752 AE 0B 03 FFA LDX TWTROW ;Initialise cursor to top row 0531 C755 8E 19 03 FFB STX CSY ;Clear this line 0532 C758 20 AC CE JSR CLTLIN 0533 C75B AE 19 03 LDX CSY ;Move down a line 0534 C75E EC 09 03 CPX TWBROW ;On the bottom ? 0535 C761 E8 INX 0536 C762 90 F1 BCC FFB ;(INX preserves c) 0537 C764 0538 C764 ;& fall through to Acorn macro assembler Page 14 VDU File - MOS02 0539 C764 0540 C764 0541 C764 ;RS ($1E) Home character cursor 0542 C764 0543 C764 20 87 C5 RS JSR ANOMQ 0544 C767 F0 22 BEQ RSA 0545 C769 [ MOS125 = &FF 0547 C769 | 0548 C769 ;RSAN Anomalous cursor home 0549 C769 0550 C769 A2 06 RSAN LDXIM GWTROW-V ;Copy GWLCOL to GCSIR 0551 C76B A0 26 LDYIM GCSIY-V 0552 C76D 20 39 D4 JSR COPY2 ;Copy 4 bytes of RAM saves 2 bytes of ROM 0553 C770 0554 C770 ;& fall through to ... 0555 C770 0556 C770 0557 C770 ;CRAN Anomalous carriage return 0558 C770 0559 C770 A2 00 CRAN LDXIM GWLCOL-V ;Copy GWLCOL to GCSIX 0560 C772 A0 24 LDYIM GCSIX-V 0561 C774 20 39 D4 JSR COPY2 0562 C777 4C 7D CA JMP IEG 0563 C77A 0564 C77A RPALET 0565 C77A 2D 60 03 AND NCOLOR ;Read parrot 0566 C77D AA TAX 0567 C77E BD 6F 03 LDAAX PARROT 0568 C781 C8 PRACA INY 0569 C782 91 F0 PRACB STAIY WARGS 0570 C784 A9 00 LDAIM &00 0571 C786 C0 04 CPYIM &04 0572 C788 D0 F7 BNE PRACA 0573 C78A 60 PRACX RTS 0574 C78B ] 0575 C78B 0576 C78B 8D 23 03 RSA STA QEND 0577 C78E 8D 22 03 STA QEND-&01 0578 C791 0579 C791 ;& fall through to .... 0580 C791 0581 C791 ;US ($1F) Move text csr to x,y 0582 C791 0583 C791 ;Put cursor to (x,y), where 0584 C791 ;x in QEND-1 & y in QEND 0585 C791 ;If illegal, leave cursor alone 0586 C791 0587 C791 20 87 C5 US JSR ANOMQ ;Cursors joined ? 0588 C794 D0 F4 BNE PRACX ;Yes, then skip 0589 C796 20 AF C7 JSR USAF ;Remember current cursor 0590 C799 18 CLC 0591 C79A AD 22 03 LDA QEND-&01 ;Add offset to x posn 0592 C79D 6D 08 03 ADC TWLCOL 0593 C7A0 8D 18 03 STA CSX 0594 C7A3 AD 23 03 LDA QEND ;Add offset to y posn 0595 C7A6 18 CLC 0596 C7A7 6D 0B 03 ADC TWTROW 0597 C7AA [ MOS125 = &FF 0600 C7AA | 0601 C7AA 20 E8 CE JSR SYTADD ;Attempt to posn. csr 0602 C7AD ] 0603 C7AD 90 82 BCC FSD ;to a JMP CSDSP 0604 C7AF 0605 C7AF A2 18 USAF LDXIM CSX-V 0606 C7B1 A0 28 LDYIM USWS-V 0607 C7B3 4C CC CD JMP SWAP2 0608 C7B6 0609 C7B6 [ MOS125 = &FF 0610 C7B6 | 0611 C7B6 FFC 0612 C7B6 4C 9D CB JMP CLATXT ;Clear?, then fast clear 0613 C7B9 ] 0614 C7B9 0615 C7B9 ;CR ($0D) Carriage return 0616 C7B9 0617 C7B9 20 87 C5 CR JSR ANOMQ 0618 C7BC [ MOS125 = &FF 0621 C7BC | 0622 C7BC D0 B2 BNE CRAN 0623 C7BE ] 0624 C7BE 20 6E CE CRA JSR SSCRIM ;Position cursor to LH edge of window 0625 C7C1 4C AE C6 JMP CSDA ;Display cursor & TADDR 0626 C7C4 0627 C7C4 LNK MOS03 0001 C7C4 0002 C7C4 TTL VDU File - MOS03 0003 C7C4 OPT MOS03 Acorn macro assembler Page 15 VDU File - MOS03 0004 C7C4 0005 C7C4 ;Last revision 15/06/82 0006 C7C4 0007 C7C4 ;15/06/82 Route ALL unknown plot commands thru VDUVEC, even in text modes 0008 C7C4 ;02/06/82 ETB mod to redef of ASCII 0009 C7C4 ;27/05/82 DCC (programme palette) recoded 0010 C7C4 ;05/05/82 Delete anomalous TAB 0011 C7C4 ; Move NAK to MOS02 0012 C7C4 ;01/05/82 Recoded to allow for forward queueing & change in variable order 0013 C7C4 ;24/04/82 ETB Function 1 (hide/display cursor) coded 0014 C7C4 ;19/04/82 DCC & DCCB moved for byte saving 0015 C7C4 ;15/04/82 NPCOL used to fix VDU 19,0,20,0,0,0 bug 0016 C7C4 ;24/03/82 DLE leaves graphics cursor alone 0017 C7C4 ; ETB to check if font exploded before reprogramming fonts 1-3 0018 C7C4 ;21/03/82 DLE to account for non-zero origins 0019 C7C4 ;22/01/82 EIG to EIGABS in graphics window definition 0020 C7C4 ;07/01/82 Catch illegal VDU 23,n,.... commands 0021 C7C4 ;15/11/81 Vertical sync user adjustment (Paul) 0022 C7C4 0023 C7C4 ;INDIVIDUAL ROUTINES 0024 C7C4 0025 C7C4 0026 C7C4 ;DLE ($10) Clear graphics area 0027 C7C4 0028 C7C4 20 69 C7 FFANOM JSR RSAN 0029 C7C7 AD 61 03 DLE LDA NPIX ;Non-graphics ? 0030 C7CA F0 33 BEQ DLEX 0031 C7CC AE 5A 03 LDX BGCOLF ;Clear to the background colour 0032 C7CF AC 5C 03 LDY GPLBMD ;Use the background colour mode 0033 C7D2 20 C5 D0 JSR SETZG ;Set this up 0034 C7D5 A2 00 LDXIM GWLCOL-V ;Copy window params from GWTROW ... 0035 C7D7 A0 28 LDYIM DLEWS-V ;Copy window parameters to DLEWS 0036 C7D9 20 33 D4 JSR COPY8 0037 C7DC 38 SEC ;How many lines to do ? 0038 C7DD AD 06 03 LDA GWTROW 0039 C7E0 ED 02 03 SBC GWBROW 0040 C7E3 A8 TAY 0041 C7E4 C8 INY ;Increment this to distinguish between 0 & 255 0042 C7E5 8C 30 03 STY DLENLN ;Line counter 0043 C7E8 A2 2C DLEA LDXIM DLEWS+&04-V ;Point to R.H. point, containing valid Y address 0044 C7EA A0 28 LDYIM DLEWS-V ;Point to L.H. point, with irrelevant Y address 0045 C7EC 20 43 D6 JSR HPLOTA ;Clear the current line 0046 C7EF AD 2E 03 LDA DLEWS+&06 ;Decrement the current line number 0047 C7F2 D0 03 BNE DLEB 0048 C7F4 CE 2F 03 DEC DLEWS+&07 0049 C7F7 CE 2E 03 DLEB DEC DLEWS+&06 0050 C7FA CE 30 03 DEC DLENLN 0051 C7FD D0 E9 BNE DLEA 0052 C7FF 60 DLEX RTS 0053 C800 0054 C800 ;DC1 ($11) Programme foreground 0055 C800 ;or background colours for text 0056 C800 0057 C800 A0 00 DCA LDYIM &00 ;Used for storing 0058 C802 F0 02 BEQ DCABA ;(branch always taken) 0059 C804 0060 C804 ;DC2 ($12) Programme foreground 0061 C804 ;or background colours for graphics 0062 C804 ;QEND-1=mode 0063 C804 ;QEND =logical colour 0064 C804 0065 C804 A0 02 DCB LDYIM &02 0066 C806 AD 23 03 DCABA LDA QEND ;Get logical colour 0067 C809 10 01 BPL DCABB ;Foreground ? 0068 C80B C8 INY ;No, then point to background locations 0069 C80C 2D 60 03 DCABB AND NCOLOR 0070 C80F 85 DA STA ZTEMP 0071 C811 AD 60 03 LDA NCOLOR ;Sneaky offset method 0072 C814 F0 1B BEQ DCABX ;Branch for TTX 0073 C816 29 07 ANDIM &07 ;to FCOLTB. A=table base 0074 C818 18 CLC 0075 C819 65 DA ADC ZTEMP ;(A) = offset +1 0076 C81B AA TAX 0077 C81C BD 23 C4 LDAAX FCOLTB -&01 0078 C81F 99 57 03 STAAY FTCOLF ;(Y) set above to 0..3 0079 C822 [ MOS125 = &FF 0084 C822 | 0085 C822 98 TYA 0086 C823 4A LSRA ;Graphics? 0087 C824 D0 0C BNE DCBAC ;Yes, then set up GPLMDE 0088 C826 18 CLC ;A=0, C=0; SBC takes one's complement 0089 C827 ED 57 03 SBC FTCOLF ;No, then set ZORA and ZEOR 0090 C82A ] 0091 C82A 85 D3 STA ZEOR ;ZEOR = NOT foreground 0092 C82C 4D 58 03 EOR BTCOLF ;ZORA = ZEOR EOR back 0093 C82F 85 D2 STA ZORA 0094 C831 60 DCABX RTS 0095 C832 AD 22 03 DCBAC LDA QEND-&01 0096 C835 99 59 03 STAAY GPLFMD -&02 ;Y=2 or 3 (for fore or background) mode 0097 C838 60 RTS 0098 C839 0099 C839 A9 20 DCTTX LDAIM TTXBCL ;TTX load with a particular byte ($20) 0100 C83B 8D 58 03 STA BTCOLF ;Used only for screen clears 0101 C83E 60 RTS 0102 C83F 0103 C83F ;DC3 ($13) is below this routine 0104 C83F 0105 C83F 0106 C83F ;DC4 ($14) Set default physical 0107 C83F ;- logical relations 0108 C83F ;Default back & foreground clrs 0109 C83F 0110 C83F A2 05 DCD LDXIM &05 ;Programme all full colours & modes to zero 0111 C841 A9 00 LDAIM &00 0112 C843 9D 57 03 DCDA STAAX FTCOLF 0113 C846 CA DEX 0114 C847 10 FA BPL DCDA 0115 C849 [ MOS125 = &FF 0119 C849 | 0120 C849 8A TXA ;A = &FF 0121 C84A AE 60 03 LDX NCOLOR ;Set foreground colours & ZORA & ZEOR 0122 C84D F0 EA BEQ DCTTX ;Branch for TTX 0123 C84F ] 0124 C84F E0 0F CPXIM &0F 0125 C851 D0 02 BNE DCDB 0126 C853 A9 3F LDAIM INVSXT ;Don't invert flashing bit 0127 C855 8D 57 03 DCDB STA FTCOLF 0128 C858 8D 59 03 STA FGCOLF 0129 C85B 49 FF EORIM &FF 0130 C85D 85 D2 STA ZORA 0131 C85F 85 D3 STA ZEOR Acorn macro assembler Page 16 VDU File - MOS03 0132 C861 8E 1F 03 STX QEND-&04 ;set logical colour := NCOLOR 0133 C864 [ MOS125 = &FF 0166 C864 | 0167 C864 A9 07 LDAIM &07 0168 C866 E0 03 CPXIM &03 ;How many colours? 0169 C868 90 0A BCC DCDLF 0170 C86A D0 0E BNE DCDLI 0171 C86C 0172 C86C ;4 colour, use shift right of $07 0173 C86C 0174 C86C 20 7F C8 JSR DCDLJ ;Programme log.=3, phys.=7 0175 C86F CE 1F 03 DEC QEND-&04 ;Programme log.=2, phys.=3 0176 C872 A9 03 LDAIM &03 ;then 1=1, 0=0 0177 C874 0178 C874 ;2 colour (TTX also executes this rouine) 0179 C874 0180 C874 20 7F C8 DCDLF JSR DCDLJ ;Programme log.=1, phys.=7 0181 C877 CE 1F 03 DEC QEND-&04 0182 C87A 0183 C87A ;16 colours - one to one 0184 C87A 0185 C87A DCDLI 0186 C87A 0187 C87A AD 1F 03 LDA QEND-&04 0188 C87D D0 F5 BNE DCDLF 0189 C87F 8D 20 03 DCDLJ STA QEND-&03 ;& fall through to .... 0190 C882 ] 0191 C882 0192 C882 ;DC3 ($13) - Programme logical/ 0193 C882 ;physical colour relation 0194 C882 0195 C882 ;Logical colour in QEND-4 0196 C882 ;Physical colour in QEND-3 0197 C882 0198 C882 08 DCC PHP 0199 C883 78 SEI 0200 C884 AD 1F 03 LDA QEND-&04 ;Determine logical colour 0201 C887 2D 60 03 AND NCOLOR 0202 C88A AA TAX 0203 C88B AD 20 03 LDA QEND-&03 ;Get physical colour 0204 C88E 29 0F DCC1 ANDIM NPCOL ;mask off confusing bits 0205 C890 9D 6F 03 STAAX PARROT ;Write to list 0206 C893 [ MOS125 = &FF 0223 C893 | 0224 C893 86 FA STX SEIWKA 0225 C895 AD 60 03 LDA NCOLOR 0226 C898 C9 03 CMPIM &03 0227 C89A 08 PHP ;Needed later 0228 C89B 4A LSRA 0229 C89C 46 FA DCCALA LSR SEIWKA ;determine start position =Logi*16/(ncolor+1)*16 0230 C89E 6A RORA 0231 C89F B0 FB BCS DCCALA 0232 C8A1 1D 6F 03 ORAAX PARROT ;Get physical colour 0233 C8A4 A0 F0 LDYIM &F0 ;Initialise loop counter 0234 C8A6 0235 C8A6 AA DCCALB TAX ;Byte to be given to VPROC1 0236 C8A7 28 PLP ;Does NCOLOR=3? 0237 C8A8 ] 0238 C8A8 08 PHP 0239 C8A9 D0 09 BNE DCCALC ;No?, then skip 0240 C8AB [ MOS125 = &FF 0249 C8AB | 0250 C8AB 0A ASLA ;b6,b5 to b7,b6; clear b0 0251 C8AC 69 40 ADCIM &40 ;carry doesn't matter (thanks Woz) 0252 C8AE 0A ASLA ;b6 EOR b5 to C 0253 C8AF 8A TXA ;restore byte 0254 C8B0 90 02 BCC DCCALC ;If b5 & b6 both set or clear, don't invert them 0255 C8B2 49 60 EORIM &60 0256 C8B4 ] 0257 C8B4 20 16 EA DCCALC JSR MVPRC1 ;Save (X) & (Y) 0258 C8B7 98 TYA ;Loop counter 0259 C8B8 [ MOS125 = &FF 0268 C8B8 | 0269 C8B8 18 CLC 0270 C8B9 6D 60 03 ADC NCOLOR 0271 C8BC A8 TAY 0272 C8BD 8A TXA ;Restore (A) 0273 C8BE 69 10 ADCIM &10 ;c=0 0274 C8C0 C8 INY 0275 C8C1 30 E3 BMI DCCALB 0276 C8C3 ] 0277 C8C3 28 PLP 0278 C8C4 28 PLP 0279 C8C5 60 RTS 0280 C8C6 0281 C8C6 0282 C8C6 ;OSWORD call to programme palette 0283 C8C6 0284 C8C6 PRPAL 0285 C8C6 08 PHP 0286 C8C7 2D 60 03 AND NCOLOR ;Get logical colour 0287 C8CA AA TAX 0288 C8CB C8 INY ;(Y):=1 0289 C8CC B1 F0 LDAIY WARGS ;Load physical colour 0290 C8CE [ MOS125 = &FF 0292 C8CE | 0293 C8CE 90 BE BCC DCC1 ;C=0 from WORD->BYTE2 0294 C8D0 ] 0295 C8D0 0296 C8D0 ;SYN ($16) Change mode 0297 C8D0 0298 C8D0 AD 23 03 SYN LDA QEND ;Get the mode 0299 C8D3 4C 10 CB JMP CHMODE 0300 C8D6 0301 C8D6 ;ETB ($17) Programme soft font 0302 C8D6 ;Programme character font to user definition 0303 C8D6 ;Character to be programmed in Q+08, top row in Q+07 0304 C8D6 ;through to bottom row in Q+00 0305 C8D6 0306 C8D6 AD 1B 03 ETB LDA QEND-&08 ;Is it the soft font ? 0307 C8D9 C9 20 CMPIM &20 ;Is it a printable character ? 0308 C8DB 90 38 BCC ETBD 0309 C8DD [ MOS125 = &FF 0347 C8DD | 0348 C8DD 20 50 D0 JSR CHADDR 0349 C8E0 ;returns X=font no., Y=(ZTEMPC+&01)=hard/soft page no. 0350 C8E0 ;A=font flag mask, (ZTEMPC)=hard/soft character address 0351 C8E0 2C 67 03 BIT FNTFLG ;flag set ? 0352 C8E3 D0 1E BNE ETBB ;Yes?, then just copy defn. 0353 C8E5 0D 67 03 ORA FNTFLG 0354 C8E8 8D 67 03 STA FNTFLG Acorn macro assembler Page 17 VDU File - MOS03 0355 C8EB 84 DD STY ZTEMPB +&01 ;point to hard font 0356 C8ED BC 67 03 LDYAX PGSFNT -&01 ;point to soft font 0357 C8F0 84 DF STY ZTEMPC +&01 0358 C8F2 A6 DE LDX ZTEMPC +&00 ;save character offset 0359 C8F4 A0 00 LDYIM &00 0360 C8F6 84 DC STY ZTEMPB +&00 ;align both pointers 0361 C8F8 84 DE STY ZTEMPC +&00 0362 C8FA B1 DC ETBC LDAIY ZTEMPB ;copy from hard font 0363 C8FC 91 DE STAIY ZTEMPC ;to soft font 0364 C8FE 88 DEY 0365 C8FF D0 F9 BNE ETBC 0366 C901 86 DE STX ZTEMPC +&00 ;restore character offset 0367 C903 ETBB 0368 C903 A0 07 LDYIM &07 ;& copy character into the font 0369 C905 B9 1C 03 ETBA LDAAY QEND-&07 0370 C908 91 DE STAIY ZTEMPC 0371 C90A 88 DEY 0372 C90B 10 F8 BPL ETBA 0373 C90D ] 0374 C90D 60 ETCX RTS 0375 C90E 0376 C90E JMIV25 0377 C90E AD 1F 03 LDA PLMODE 0378 C911 18 CLC 0379 C912 ; C=0 0380 C912 JMIV23 ;C=1 0381 C912 6C 26 02 JMI VDUVEC 0382 C915 ; 0383 C915 C9 01 ETBD CMPIM &01 ;Valid command ? 0384 C917 90 15 BCC ETD 0385 C919 ; C=1 0386 C919 D0 F7 BNE JMIV23 ;No?, then jump indirect to user vector with C=1 0387 C91B ; 0388 C91B 20 87 C5 JSR ANOMQ ;Anom. printing? ~~~ FUNCTION 1 Turn cursor on/off ~~~ 0389 C91E D0 ED BNE ETCX ;Yes?, then don't do it 0390 C920 A9 20 LDAIM &20 0391 C922 AC 1C 03 LDY QEND-&07 ;Hide(0) or display(1)? 0392 C925 F0 03 BEQ ETCB 0393 C927 AD 5F 03 ETCA LDA CSTEMP ;RESTORE CURSOR 0394 C92A A0 0A ETCB LDYIM &0A 0395 C92C D0 2D BNE CRTCPA ;Programme the 6845 without saving to CSTEMP 0396 C92E 0397 C92E AD 1D 03 ETD LDA QEND-&06 ;~~~ FUNCTION 0 Programme 6845 register #(Q+7) WITH (Q+6) ~~~ 0398 C931 AC 1C 03 LDY QEND-&07 0399 C934 0400 C934 C0 07 CRTCP CPYIM &07 0401 C936 90 23 BCC CRTCPA ;[register<7, so not register 7 or 10] 0402 C938 D0 03 BNE CRTCPC ;[not vertical sync position] 0403 C93A 0404 C93A 6D 90 02 ADC VERTIC ;apply user adjustment (c=1) 0405 C93D 0406 C93D C0 08 CRTCPC CPYIM &08 0407 C93F D0 07 BNE CRTCPD ;[not interlace mode register] 0408 C941 09 00 ORAIM &00 ; interlace mode register 0409 C943 30 03 BMI CRTCPD ;[do not alter interlace (probably teletext)] 0410 C945 ; 0411 C945 4D 91 02 EOR INTERL ;modify interlace 0412 C948 C0 0A CRTCPD CPYIM &0A ;Cursor start register ? 0413 C94A D0 0F BNE CRTCPA ;[not cursor start register] 0414 C94C 8D 5F 03 STA CSTEMP ;Yes?, then record this for separate cursors 0415 C94F A8 TAY 0416 C950 A5 D0 LDA STATS ;Are cursors joined ? 0417 C952 29 20 ANDIM &20 0418 C954 08 PHP ;(very nasty coding, but it is short) 0419 C955 98 TYA 0420 C956 A0 0A LDYIM &0A 0421 C958 28 PLP 0422 C959 D0 06 BNE CRTCPB ;Yes, then don't write to 6845 0423 C95B 8C 00 FE CRTCPA STY CRTCA ;Address said register 0424 C95E 8D 01 FE STA CRTCD ;and store data therein 0425 C961 60 CRTCPB RTS ;(Referenced from EM) 0426 C962 0427 C962 ;ESC ($1B) does bugger all 0428 C962 0429 C962 ;Jump table points to the RTS at ACK 0430 C962 0431 C962 ;EM ($19) - Plotting 0432 C962 0433 C962 AE 61 03 EM LDX NPIX ;Filter out non-graphics modes 0434 C965 F0 A7 BEQ JMIV25 ;[text mode] 0435 C967 4C 70 D0 JMP EMA ;Jump to graphics routines 0436 C96A 0437 C96A ;Hardware scroll down 0438 C96A ;Doesn't touch cursor 0439 C96A 0440 C96A ; These routines return z=0 0441 C96A 0442 C96A AE 50 03 HSCRDN LDX TOPSCN ;Subt. BYTROW from TOPSCN 0443 C96D AD 51 03 LDA TOPSCN+&01 0444 C970 20 DE CB JSR SUBROW 0445 C973 B0 14 BCS NEWTOP ;Wraparound? No?, then done 0446 C975 6D 54 03 ADC BYTSCN ;Yes?, then add screen length 0447 C978 90 0F BCC NEWTOP ;(branch always taken) 0448 C97A 0449 C97A AE 50 03 HSCRUP LDX TOPSCN ;Add BYTROW to TOPSCN 0450 C97D AD 51 03 LDA TOPSCN+&01 0451 C980 20 B1 CA JSR ADDROW 0452 C983 10 04 BPL NEWTOP ;Wraparound? 0453 C985 38 SEC 0454 C986 ED 54 03 SBC BYTSCN ;Yes?, then subtract off screen length 0455 C989 8D 51 03 NEWTOP STA TOPSCN +&01 0456 C98C 8E 50 03 STX TOPSCN 0457 C98F A0 0C LDYIM &0C ;Prog. START of 6845 0458 C991 D0 51 BNE AXCRTA ;(branch always taken) 0459 C993 0460 C993 ;SUB ($1A) - Sets default text 0461 C993 ;& graphics windows. 0462 C993 ;Homes both cursors 0463 C993 ;Sets graphics origin to (0,0) 0464 C993 0465 C993 ;Clear all window parameters, 0466 C993 ;Both cusors, & gr. origin 0467 C993 0468 C993 A9 00 SUB LDAIM &00 0469 C995 A2 2C LDXIM VDUWS+&04-GWLCOL ;THIS VALUE LIKELY TO CHANGE ! 0470 C997 9D 00 03 SUBA STAAX GWLCOL 0471 C99A CA DEX 0472 C99B 10 FA BPL SUBA 0473 C99D 0474 C99D ;Set other parameters 0475 C99D Acorn macro assembler Page 18 VDU File - MOS03 0476 C99D AE 55 03 LDX MODE ;Get no. of char. cols. 0477 C9A0 BC EF C3 LDYAX PCOLS ;How many columns ? 0478 C9A3 8C 0A 03 STY TWRCOL ;Default text window 0479 C9A6 20 5C CA JSR SETPWW ;Set the text width 0480 C9A9 BC E7 C3 LDYAX PROWS ;Get no. char. rows 0481 C9AC 8C 09 03 STY TWBROW ;Default text window 0482 C9AF A0 03 LDYIM &03 ;GRAPHICS WINDOW Top row 0483 C9B1 8C 23 03 STY QEND 0484 C9B4 C8 INY 0485 C9B5 8C 21 03 STY QEND-&02 ;right column 0486 C9B8 CE 22 03 DEC QEND-&01 ;now = $FF 0487 C9BB CE 20 03 DEC QEND-&03 ;now = $FF 0488 C9BE 20 0D CA JSR CAN ;Transfer to window & convert co-ords 0489 C9C1 A9 F7 LDAIM &F7 ;Clear bit 3 of STATS (default windows set) 0490 C9C3 20 A7 C5 JSR STTAND 0491 C9C6 AE 50 03 LDX TOPSCN ;Programme cursor 0492 C9C9 AD 51 03 LDA TOPSCN+&01 ;to top L.H. byte 0493 C9CC 8E 4A 03 CSDSPA STX CSPOSN 0494 C9CF 8D 4B 03 STA CSPOSN +&01 0495 C9D2 10 04 BPL CSDSP 0496 C9D4 38 SEC 0497 C9D5 ED 54 03 SBC BYTSCN 0498 C9D8 86 D8 CSDSP STX ZMEMT 0499 C9DA 85 D9 STA ZMEMT +&01 0500 C9DC AE 4A 03 LDX CSPOSN 0501 C9DF AD 4B 03 LDA CSPOSN +&01 0502 C9E2 A0 0E LDYIM &0E 0503 C9E4 48 AXCRTA PHA 0504 C9E5 AD 55 03 LDA MODE ;Is it teletext ? 0505 C9E8 C9 07 CMPIM &07 0506 C9EA 68 PLA 0507 C9EB B0 10 BCS AXCRTB 0508 C9ED 86 DA STX ZTEMP ;No?, then divide by 8 0509 C9EF 4A LSRA 0510 C9F0 66 DA ROR ZTEMP 0511 C9F2 4A LSRA 0512 C9F3 66 DA ROR ZTEMP 0513 C9F5 4A LSRA 0514 C9F6 66 DA ROR ZTEMP 0515 C9F8 A6 DA LDX ZTEMP 0516 C9FA 4C FF C9 JMP AXCRTC 0517 C9FD ;For TTX, fiddle the high address lines 0518 C9FD [ MOS125 = &FF 0521 C9FD | 0522 C9FD ;on entry C=1, A=&7C..83, normal/wrapped screen address high byte, we need: 0523 C9FD ;b5 = MA13 set, TTXVDU address mapping 0524 C9FD ;b4 = MA12 clear, no HIRES wraparound 0525 C9FD ;b3 = MA11 set, high RAM bank 0526 C9FD ;b2 = MA10 indicates TTX wraparound, needed on-chip for cursor display 0527 C9FD ;b7,6 unused 0528 C9FD E9 54 AXCRTB SBCIM &54 ;map to &28..2F 0529 C9FF ] 0530 C9FF ;Write (A) to reg. (Y) of 6845 0531 C9FF ;& (X) to reg. (Y)+1 0532 C9FF 0533 C9FF 8C 00 FE AXCRTC STY CRTCA ;Access reg. (Y) 0534 CA02 8D 01 FE STA CRTCD ;Store MSB 0535 CA05 C8 INY ;Access reg. (Y)+1 0536 CA06 8C 00 FE STY CRTCA 0537 CA09 8E 01 FE STX CRTCD ;Store LSB 0538 CA0C 60 RTS 0539 CA0D 0540 CA0D ;CAN ($18) Define graphics area 0541 CA0D 0542 CA0D ;QEND-7 = L.H. margin = GWLCOL Low byte 1st 0543 CA0D ;QEND-5 = Bottom row = GWBROW 0544 CA0D ;QEND-3 = R.H. margin = GWRCOL 0545 CA0D ;QEND-1 = Top row = GWTROW 0546 CA0D 0547 CA0D 20 55 CA CAN JSR CANB ;Swap graphics cursor with innocuous bytes in WS 0548 CA10 A2 1C LDXIM QEND-&07-V 0549 CA12 A0 2C LDYIM CDELTA-V 0550 CA14 20 C8 D3 JSR TRISA ;Calculate window differences to CDELTA 0551 CA17 0D 2D 03 ORA CDELTA+&01 ;(A) returns with CDELTA+3= DeltaY, so OR with DeltaX 0552 CA1A 30 39 BMI CANB ;If either is -ve, then illegal window 0553 CA1C A2 20 LDXIM QEND-&03-V ;Convert window to Ico-ords 0554 CA1E 20 5B D1 JSR EIGABS 0555 CA21 A2 1C LDXIM QEND-&07-V 0556 CA23 20 5B D1 JSR EIGABS 0557 CA26 AD 1F 03 LDA QEND-&04 ;Are both lower margins +ve ? 0558 CA29 0D 1D 03 ORA QEND-&06 0559 CA2C 30 27 BMI CANB ;No?, then illegal 0560 CA2E AD 23 03 LDA QEND ;Is Y valid ? 0561 CA31 D0 22 BNE CANB ;Only if MSB is zero 0562 CA33 AE 55 03 LDX MODE ;Is X valid ? 0563 CA36 AD 21 03 LDA QEND-&02 ;Divide by 8 & see if > no. of character cols 0564 CA39 85 DA STA ZTEMP 0565 CA3B AD 20 03 LDA QEND-&03 ;LSB of RH margin -1 0566 CA3E 46 DA LSR ZTEMP 0567 CA40 6A RORA 0568 CA41 46 DA LSR ZTEMP 0569 CA43 D0 10 BNE CANB 0570 CA45 6A RORA 0571 CA46 4A LSRA 0572 CA47 DD EF C3 CMPAX PCOLS 0573 CA4A F0 02 BEQ CANA 0574 CA4C 10 07 BPL CANB 0575 CA4E A0 00 CANA LDYIM GWLCOL-V ;Copy to window 0576 CA50 A2 1C LDXIM QEND-&07-V ;From Q 0577 CA52 20 33 D4 JSR COPY8 0578 CA55 A2 10 CANB LDXIM GCSR-V ;Swap GCSR with CANWS, as EIGABS corrupts this 0579 CA57 A0 28 LDYIM CANWS-V 0580 CA59 4C D4 CD JMP SWAPF 0581 CA5C 0582 CA5C ;Set printer window width 0583 CA5C ;Char. width in A 0584 CA5C ;Mode in X 0585 CA5C 0586 CA5C C8 SETPWW INY 0587 CA5D 98 TYA 0588 CA5E A0 00 LDYIM &00 0589 CA60 8C 4D 03 STY PWWDTH +&01 ;Clear MSB 0590 CA63 8D 4C 03 STA PWWDTH 0591 CA66 AD 4F 03 LDA BYTCH ;How many times to shift PWWDTH left ? 0592 CA69 4A LSRA 0593 CA6A F0 09 BEQ SETPWC ;TTX? 0594 CA6C 0E 4C 03 SETPWA ASL PWWDTH 0595 CA6F 2E 4D 03 ROL PWWDTH +&01 0596 CA72 4A LSRA 0597 CA73 90 F7 BCC SETPWA 0598 CA75 60 SETPWC RTS ;This used to be FSFAIL & ESCFL & ESCBB as well Acorn macro assembler Page 19 VDU File - MOS03 0599 CA76 0600 CA76 ;GS ($1D) Define graphics origin 0601 CA76 0602 CA76 ;GSA Define graphics origin 0603 CA76 ;The co-ordinates are in external 16 bit space. This does not 0604 CA76 ;move the windows, but does move the graphics cursors 0605 CA76 0606 CA76 A2 20 GS LDXIM QEND-&03-V 0607 CA78 A0 0C LDYIM ORG-V ;Copy the new origin (external co-ords) to ORGY.. 0608 CA7A 20 41 D4 JSR COPYF 0609 CA7D [ MOS125 = &FF 0630 CA7D | 0631 CA7D ;IEG Inverse of EIG. Converts Icursor to Ecursor 0632 CA7D 0633 CA7D A0 10 IEG LDYIM GCSR-V ;Copy GCSIY to GCSY 0634 CA7F 20 3F D4 JSR COPYFB 0635 CA82 A2 02 LDXIM &02 ;Convert y co-ordinates 0636 CA84 A0 02 LDYIM &02 ;by multiplying by 4 0637 CA86 20 99 CA JSR IEGC 0638 CA89 A2 00 LDXIM &00 ;Convert x co-ordinates 0639 CA8B A0 05 LDYIM &05 ;By multiplying by 2 0640 CA8D AD 61 03 LDA NPIX ;4, or 8, depending on (NPIX) 0641 CA90 88 IEGA DEY 0642 CA91 4A LSRA 0643 CA92 D0 FC BNE IEGA 0644 CA94 AD 56 03 LDA MEMODE ;Get memory map type 0645 CA97 F0 06 BEQ IEGE ;=0 if 20K mode in which case skip one multiplication 0646 CA99 0647 CA99 1E 10 03 IEGC ASLAX GCSR 0648 CA9C 3E 11 03 ROLAX GCSR+&01 0649 CA9F IEGE 0650 CA9F 88 DEY 0651 CAA0 D0 F7 BNE IEGC 0652 CAA2 38 SEC ;Now subtract off origin to give external co-ordinate 0653 CAA3 20 A7 CA JSR IEGD 0654 CAA6 E8 INX 0655 CAA7 BD 10 03 IEGD LDAAX GCSR 0656 CAAA FD 0C 03 SBCAX ORG 0657 CAAD 9D 10 03 STAAX GCSR 0658 CAB0 60 RTS 0659 CAB1 ] 0660 CAB1 LNK MOS04 0001 CAB1 0002 CAB1 TTL VDU File - MOS04 0003 CAB1 OPT MOS04 Acorn macro assembler Page 20 VDU File - MOS04 0004 CAB1 ;Last revision 02/06/82 0005 CAB1 0006 CAB1 ;02/06/82 Implode/Explode font change, RESET (fonts) changed 0007 CAB1 ;26/05/82 Replace table TBZTBX with LSRA 0008 CAB1 ;19/05/82 Compress PAGEE code 0009 CAB1 ;18/05/82 Conditional coding to remove bug from PAGE 0010 CAB1 ;01/05/82 Considerable recoding for new variable order & forward queueing 0011 CAB1 ;19/04/82 BYTE squashing 0012 CAB1 ;24/03/82 Add soft font implosion & explosion 0013 CAB1 ; Change refs. to BEGSCN+1 to BEGSCN 0014 CAB1 ;08/02/82 Remove initialisation of TRMCH 0015 CAB1 ;07/01/82 Remove initialisation of VDUVEC 0016 CAB1 ;16/11 Bug fix - page mode only at bottom line of window 0017 CAB1 ;14/11 Initialisation of DOTS removed 0018 CAB1 ;28/10 Initialisation of FNTFLG 0019 CAB1 0020 CAB1 ;Get address of line below 0021 CAB1 0022 CAB1 48 ADDROW PHA 0023 CAB2 8A TXA 0024 CAB3 18 CLC 0025 CAB4 6D 52 03 ADC BYTROW 0026 CAB7 AA TAX 0027 CAB8 68 PLA 0028 CAB9 6D 53 03 ADC BYTROW +&01 0029 CABC 60 RTS 0030 CABD 0031 CABD ;Is page mode on ? 0032 CABD 0033 CABD ;CTRL and SHIFT keys pressed (c=1) 0034 CABD 0035 CABD 20 F1 CA PAGEF JSR PAGED ;reset LINES, N.B. does not corrupt c 0036 CAC0 ; If c=1 => set both LEDs 0037 CAC0 20 DE E9 PAGE JSR MOSTST ;pause if CTRL and SHIFT keys pressed 0038 CAC3 90 02 BCC PAGEE ;[CTRL not pressed] 0039 CAC5 30 F6 BMI PAGEF ;[CTRL and SHIFT keys pressed ,c=1] 0040 CAC7 ; CTRL without SHIFT 0041 CAC7 0042 CAC7 [ PAGEFX =0 ;TRUE if bug in page to be fixed 0043 CAC7 A5 D0 PAGEE LDA STATS 0044 CAC9 49 04 EORIM &04 ;invert page mode bit 0045 CACB 29 46 ANDIM &46 ;Exit if C.E. or scroll disabled, or not in page mode 0046 CACD D0 2A BNE PAGEX 0047 CACF | 0052 CACF ] 0053 CACF 0054 CACF AD 69 02 LDA LINES ;Is a page printed yet ? 0055 CAD2 30 22 BMI PAGEA ;If -ve, then reset (more down scrolls than up) 0056 CAD4 ; ensure on bottom line of text window 0057 CAD4 AD 19 03 LDA CSY 0058 CAD7 CD 09 03 CMP TWBROW 0059 CADA 90 1A BCC PAGEA ;[not on bottom line of text window] 0060 CADC ; deal with overlap 0061 CADC 4A LSRA 0062 CADD 4A LSRA 0063 CADE 38 SEC 0064 CADF 6D 69 02 ADC LINES 0065 CAE2 6D 0B 03 ADC TWTROW ;(c=0) 0066 CAE5 CD 09 03 CMP TWBROW 0067 CAE8 90 0C BCC PAGEA ;No, then continue 0068 CAEA 18 CLC ;do not set LEDs on first scroll test 0069 CAEB ;wait for shift key 0070 CAEB 20 DE E9 PAGEC JSR MOSTST 0071 CAEE 38 SEC ;test LEDs on subsequent scroll tests 0072 CAEF 10 FA BPL PAGEC 0073 CAF1 A9 FF PAGED LDAIM &FF ;Reinitialise LINES 0074 CAF3 8D 69 02 STA LINES 0075 CAF6 EE 69 02 PAGEA INC LINES 0076 CAF9 60 PAGEX RTS 0077 CAFA 0078 CAFA ;INTIALISATION ROUTINE 0079 CAFA ;Initial mode in (A) 0080 CAFA 0081 CAFA 48 RESET PHA ;Push mode 0082 CAFB A2 7F LDXIM VEND-V ;Clear all variables 0083 CAFD A9 00 LDAIM &00 0084 CAFF 85 D0 STA STATS 0085 CB01 9D FF 02 RESETA STAAX V-&01 0086 CB04 CA DEX 0087 CB05 D0 FA BNE RESETA 0088 CB07 ; X=0 **** AND EQ status (used by FONT) **** 0089 CB07 20 FD CC JSR FONT ;Ensure font imploded 0090 CB0A 68 PLA ;Pull the mode back again 0091 CB0B A2 7F LDXIM &7F ;Initialise CHCSR to character for DEL 0092 CB0D 8E 66 03 STX CHCSR ;and fall through to ... 0093 CB10 0094 CB10 ;MODE CHANGE 0095 CB10 0096 CB10 2C 8E 02 CHMODE BIT MODEL ;adjust according to model 0097 CB13 30 02 BMI CHMOD1 ;[model B] 0098 CB15 09 04 ORAIM &04 ;model A 0099 CB17 29 07 CHMOD1 ANDIM &07 0100 CB19 AA TAX 0101 CB1A 8E 55 03 STX MODE ;Initialise MODE 0102 CB1D BD 14 C4 LDAAX COLMOD ;Get no. colours 0103 CB20 8D 60 03 STA NCOLOR ;=0 if TTX 0104 CB23 BD FF C3 LDAAX BYTCHT ;No. bytes / char. 0105 CB26 8D 4F 03 STA BYTCH 0106 CB29 BD 3A C4 LDAAX NPIXTB ;no. pixles per byte -1, =0 if non-graphics mode 0107 CB2C 8D 61 03 STA NPIX 0108 CB2F D0 02 BNE CHMODB 0109 CB31 A9 07 LDAIM &07 ;Initialise left and right masks for read character 0110 CB33 0A CHMODB ASLA ;Define left and right masks. PRESERVE c !!! 0111 CB34 A8 TAY 0112 CB35 B9 06 C4 LDAAY MASKTB -&01 ;Offset to right mask 0113 CB38 8D 63 03 STA MASKR 0114 CB3B 0A CHMODC ASLA 0115 CB3C 10 FD BPL CHMODC ;Generate left most mask 0116 CB3E 8D 62 03 STA MASKL ;c=0 - preserve until byte width type generated 0117 CB41 BC 40 C4 LDYAX MODETB ;Memory map type 0118 CB44 8C 56 03 STY MEMODE 0119 CB47 B9 4F C4 LDAAY CZERO ;Initialise C0 0120 CB4A 20 FD E9 JSR CREG ;must preserve c=0 0121 CB4D B9 4B C4 LDAAY CONE 0122 CB50 20 FD E9 JSR CREG 0123 CB53 B9 59 C4 LDAAY BYTSTA ;Total bytes dsp.'ed 0124 CB56 8D 54 03 STA BYTSCN 0125 CB59 B9 5E C4 LDAAY STSCTB ;Addr. 1st to disp'ed 0126 CB5C 8D 4E 03 STA BEGSCN 0127 CB5F [ MOS125 = &FF 0133 CB5F | Acorn macro assembler Page 21 VDU File - MOS04 0134 CB5F 98 TYA ;Get byte width type 0135 CB60 49 07 EORIM &07 0136 CB62 4A LSRA 0137 CB63 AA TAX 0138 CB64 CA DEX ;Map (0,1,2,3,4) to (2,2,1,1,0) 0139 CB65 ] 0140 CB65 BD 66 C4 LDAAX TBZTBA ;LSB of table addr. 0141 CB68 85 E0 STA ZTBL 0142 CB6A A9 C3 LDAIM /(HRGTB ) ;MSB of same (always the same) 0143 CB6C 85 E1 STA ZTBL +&01 0144 CB6E BD 63 C4 LDAAX BYTRTA ;Byte width of row 0145 CB71 8D 52 03 STA BYTROW 0146 CB74 8E 53 03 STX BYTROW +&01 0147 CB77 A9 43 LDAIM &43 ;Preserve b6, b1 & b0 of STATS only 0148 CB79 20 A7 C5 JSR STTAND ;Clear all others 0149 CB7C AE 55 03 LDX MODE ;Indirect mode to mMODREG 0150 CB7F BD F7 C3 LDAAX INDMOD ;from this table 0151 CB82 20 05 EA JSR MVPRC0 ;as close as possible to the reprogramming of the 6845 0152 CB85 0153 CB85 ;PROGRAMME THE 6845 0154 CB85 0155 CB85 08 PHP 0156 CB86 78 SEI 0157 CB87 BE 69 C4 LDXAY CRTCX ;Get the table to Xmt 0158 CB8A A0 0B LDYIM &0B ;No. bytes to feed it 0159 CB8C BD 6E C4 CRTCLP LDAAX CRTCTB ;Load byte to 0160 CB8F 20 34 C9 JSR CRTCP ;Programme the 6845 and save value of cursor start 0161 CB92 CA DEX 0162 CB93 88 DEY 0163 CB94 10 F6 BPL CRTCLP 0164 CB96 28 PLP 0165 CB97 0166 CB97 20 3F C8 JSR DCD ;Default log.phys. cols. 0167 CB9A 20 93 C9 JSR SUB ;Clear any windowing 0168 CB9D 0169 CB9D ;fall through to ..... 0170 CB9D 0171 CB9D A2 00 CLATXT LDXIM &00 ;TOPSCN:=BEGSCN 0172 CB9F AD 4E 03 LDA BEGSCN ;Load must be in this to ensure n=0, tested in CSDSPA 0173 CBA2 8E 50 03 STX TOPSCN 0174 CBA5 8D 51 03 STA TOPSCN +&01 0175 CBA8 20 CC C9 JSR CSDSPA ;Home cursor 0176 CBAB A0 0C LDYIM &0C ;Take divided address 0177 CBAD 20 FF C9 JSR AXCRTC 0178 CBB0 AD 58 03 LDA BTCOLF 0179 CBB3 AE 56 03 LDX MEMODE ;Get mem.map type 0180 CBB6 BC 54 C4 LDYAX CLSCTA ;Set up jump vector 0181 CBB9 8C 5D 03 STY JVEC 0182 CBBC A0 CC LDYIM /(CLASCA ) ;Used to be LDYAX CLSCTB 0183 CBBE 8C 5E 03 STY JVEC +&01 0184 CBC1 A2 00 LDXIM &00 0185 CBC3 8E 69 02 STX LINES ;Initialise the number of lines scrolled 0186 CBC6 8E 18 03 STX CSX 0187 CBC9 8E 19 03 STX CSY 0188 CBCC 6C 5D 03 JMI JVEC 0189 CBCF 0190 CBCF RCHDEF 0191 CBCF 20 50 D0 JSR CHADDR ;Read character definition 0192 CBD2 A0 00 LDYIM &00 ;Address character (start of defn. now in ZTEMPC) 0193 CBD4 B1 DE PRABA LDAIY ZTEMPC ;Copy definition 0194 CBD6 C8 INY 0195 CBD7 91 F0 STAIY WARGS 0196 CBD9 C0 08 CPYIM &08 0197 CBDB D0 F7 BNE PRABA 0198 CBDD 60 RTS 0199 CBDE 0200 CBDE [ MOS125 = &FF 0201 CBDE | 0202 CBDE ;Get the next line up, 0203 CBDE ;test if wraparound 0204 CBDE ;This is here as padding 0205 CBDE 0206 CBDE 48 SUBROW PHA 0207 CBDF 8A TXA 0208 CBE0 38 SEC 0209 CBE1 ED 52 03 SBC BYTROW 0210 CBE4 AA TAX 0211 CBE5 68 PLA 0212 CBE6 ED 53 03 SBC BYTROW +&01 0213 CBE9 CD 4E 03 CMP BEGSCN 0214 CBEC 60 RTS 0215 CBED 0216 CBED ;NORTH 0217 CBED 0218 CBED ; Returns zero false 0219 CBED 38 NBDY SEC 0220 CBEE A5 D6 LDA ZMEMG 0221 CBF0 ED 52 03 SBC BYTROW 0222 CBF3 85 D6 STA ZMEMG 0223 CBF5 A5 D7 LDA ZMEMG +&01 0224 CBF7 ED 53 03 SBC BYTROW +&01 0225 CBFA CD 4E 03 CMP BEGSCN ;Wraparound ? 0226 CBFD B0 03 BCS NBDYA 0227 CBFF 6D 54 03 ADC BYTSCN 0228 CC02 85 D7 NBDYA STA ZMEMG +&01 0229 CC04 A0 07 LDYIM &07 0230 CC06 60 RTS 0231 CC07 ] 0232 CC07 0233 CC07 9D 00 30 CLASCA STAAX &3000 ;Modes 1-3 (20K) 0234 CC0A 9D 00 31 STAAX &3100 0235 CC0D 9D 00 32 STAAX &3200 0236 CC10 9D 00 33 STAAX &3300 0237 CC13 9D 00 34 STAAX &3400 0238 CC16 9D 00 35 STAAX &3500 0239 CC19 9D 00 36 STAAX &3600 0240 CC1C 9D 00 37 STAAX &3700 0241 CC1F 9D 00 38 STAAX &3800 0242 CC22 9D 00 39 STAAX &3900 0243 CC25 9D 00 3A STAAX &3A00 0244 CC28 9D 00 3B STAAX &3B00 0245 CC2B 9D 00 3C STAAX &3C00 0246 CC2E 9D 00 3D STAAX &3D00 0247 CC31 9D 00 3E STAAX &3E00 0248 CC34 9D 00 3F STAAX &3F00 0249 CC37 9D 00 40 CLASCB STAAX &4000 ;Mode 3 (16k) 0250 CC3A 9D 00 41 STAAX &4100 0251 CC3D 9D 00 42 STAAX &4200 0252 CC40 9D 00 43 STAAX &4300 0253 CC43 9D 00 44 STAAX &4400 0254 CC46 9D 00 45 STAAX &4500 Acorn macro assembler Page 22 VDU File - MOS04 0255 CC49 9D 00 46 STAAX &4600 0256 CC4C 9D 00 47 STAAX &4700 0257 CC4F 9D 00 48 STAAX &4800 0258 CC52 9D 00 49 STAAX &4900 0259 CC55 9D 00 4A STAAX &4A00 0260 CC58 9D 00 4B STAAX &4B00 0261 CC5B 9D 00 4C STAAX &4C00 0262 CC5E 9D 00 4D STAAX &4D00 0263 CC61 9D 00 4E STAAX &4E00 0264 CC64 9D 00 4F STAAX &4F00 0265 CC67 9D 00 50 STAAX &5000 0266 CC6A 9D 00 51 STAAX &5100 0267 CC6D 9D 00 52 STAAX &5200 0268 CC70 9D 00 53 STAAX &5300 0269 CC73 9D 00 54 STAAX &5400 0270 CC76 9D 00 55 STAAX &5500 0271 CC79 9D 00 56 STAAX &5600 0272 CC7C 9D 00 57 STAAX &5700 0273 CC7F 9D 00 58 CLASCC STAAX &5800 ;Modes 4,5 (10K) 0274 CC82 9D 00 59 STAAX &5900 0275 CC85 9D 00 5A STAAX &5A00 0276 CC88 9D 00 5B STAAX &5B00 0277 CC8B 9D 00 5C STAAX &5C00 0278 CC8E 9D 00 5D STAAX &5D00 0279 CC91 9D 00 5E STAAX &5E00 0280 CC94 9D 00 5F STAAX &5F00 0281 CC97 9D 00 60 CLASCD STAAX &6000 ;Mode 6 (8k) 0282 CC9A 9D 00 61 STAAX &6100 0283 CC9D 9D 00 62 STAAX &6200 0284 CCA0 9D 00 63 STAAX &6300 0285 CCA3 9D 00 64 STAAX &6400 0286 CCA6 9D 00 65 STAAX &6500 0287 CCA9 9D 00 66 STAAX &6600 0288 CCAC 9D 00 67 STAAX &6700 0289 CCAF 9D 00 68 STAAX &6800 0290 CCB2 9D 00 69 STAAX &6900 0291 CCB5 9D 00 6A STAAX &6A00 0292 CCB8 9D 00 6B STAAX &6B00 0293 CCBB 9D 00 6C STAAX &6C00 0294 CCBE 9D 00 6D STAAX &6D00 0295 CCC1 9D 00 6E STAAX &6E00 0296 CCC4 9D 00 6F STAAX &6F00 0297 CCC7 9D 00 70 STAAX &7000 0298 CCCA 9D 00 71 STAAX &7100 0299 CCCD 9D 00 72 STAAX &7200 0300 CCD0 9D 00 73 STAAX &7300 0301 CCD3 9D 00 74 STAAX &7400 0302 CCD6 9D 00 75 STAAX &7500 0303 CCD9 9D 00 76 STAAX &7600 0304 CCDC 9D 00 77 STAAX &7700 0305 CCDF 9D 00 78 STAAX &7800 0306 CCE2 9D 00 79 STAAX &7900 0307 CCE5 9D 00 7A STAAX &7A00 0308 CCE8 9D 00 7B STAAX &7B00 0309 CCEB 9D 00 7C CLASCE STAAX &7C00 ;Mode 7 (1k = TTX) 0310 CCEE 9D 00 7D STAAX &7D00 0311 CCF1 9D 00 7E STAAX &7E00 0312 CCF4 9D 00 7F STAAX &7F00 0313 CCF7 E8 INX 0314 CCF8 F0 61 BEQ ENSCRX 0315 CCFA 6C 5D 03 RUNNER JMI JVEC 0316 CCFD 0317 CCFD [ MOS125 = &FF 0332 CCFD ] 0333 CCFD 0334 CCFD FONT 0335 CCFD ; 0336 CCFD ; implode font 0337 CCFD ; 0338 CCFD A9 0F LDAIM &0F ;Fonts 1,2,3 hard (set 0). MSb not used 0339 CCFF 8D 67 03 STA FNTFLG 0340 CD02 ; 0341 CD02 A9 0C LDAIM SFPAGE 0342 CD04 A0 06 LDYIM &06 ;Set Fonts 1 to 7 to page SFPAGE 0343 CD06 99 68 03 FIMPA STAAY PGSFNT 0344 CD09 88 DEY 0345 CD0A 10 FA BPL FIMPA 0346 CD0C ; 0347 CD0C ; test operation type 0348 CD0C ; 0349 CD0C ; force X in range 0350 CD0C E0 07 CPXIM &07 0351 CD0E 90 02 BCC FONTOK ;[X <= 6] 0352 CD10 A2 06 LDXIM &06 0353 CD12 FONTOK ;0 <= X <= 6 0354 CD12 8E 46 02 STX FONTSW ;record font state 0355 CD15 ; 0356 CD15 AD 43 02 LDA IHWM 0357 CD18 ; 0358 CD18 ; explode fonts that lie within extension pages 0359 CD18 ; 0360 CD18 A2 00 LDXIM &00 0361 CD1A FEXPA 0362 CD1A EC 46 02 CPX FONTSW 0363 CD1D B0 0B BCS FEXPA0 0364 CD1F ; C=0 0365 CD1F BC BA C4 LDYAX FFSZOT 0366 CD22 99 68 03 STAAY PGSFNT 0367 CD25 ; C=0 0368 CD25 69 01 ADCIM &01 0369 CD27 E8 INX 0370 CD28 D0 F0 BNE FEXPA ;[ALWAYS jump] 0371 CD2A FEXPA0 0372 CD2A ; 0373 CD2A ;X = FONTSW 0374 CD2A 8D 44 02 STA HWM 0375 CD2D ; 0376 CD2D A8 TAY 0377 CD2E F0 2B BEQ FONT0 0378 CD30 A2 11 LDXIM SVHWMC 0379 CD32 4C 74 F1 JMP SVOP 0380 CD35 0381 CD35 0382 CD35 LNK MOS05 0001 CD35 0002 CD35 TTL VDU File - MOS05 0003 CD35 OPT MOS05 Acorn macro assembler Page 23 VDU File - MOS05 0004 CD35 ; 0005 CD35 ;Last update 05/05/82 0006 CD35 0007 CD35 ;05/05/82 RSAN corrected 0008 CD35 ;05/05/82 TADDRY changed to allow for only 1 table 0009 CD35 ;01/05/82 Recoded using new variable order & manifests 0010 CD35 ;01/05/82 Recode for new order of variables 0011 CD35 ;22/04/82 Encode ADDSCN & SUBSCN 0012 CD35 ;19/04/82 Comments added plus small byte squash 0013 CD35 ;25/03/82 Change all refs. to BEGSCN+1 to BEGSCN 0014 CD35 0015 CD35 ;Account for scroll disabling if needs be 0016 CD35 ;Requires c=1 if scroll DOWN (cursor up) & vice versa 0017 CD35 ;If scroll enabled (b1 of STATS =0) adjusts PCSY unless on a margin 0018 CD35 ;If scroll disabled, wraps cursor, pulls return address from stack 0019 CD35 ;and jumps to CSDA. 0020 CD35 0021 CD35 A9 02 ENSCRL LDAIM &02 ;Is scroll disabled ? 0022 CD37 24 D0 BIT STATS 0023 CD39 D0 02 BNE ENSCRM ;Yes?, then skip 0024 CD3B 50 32 BVC ENSCRR ;Or is CE set ? 0025 CD3D AD 09 03 ENSCRM LDA TWBROW ;Assume scroll up (so go to bottom row) 0026 CD40 90 03 BCC ENSCRN ;Unless c=1 0027 CD42 AD 0B 03 LDA TWTROW ;Whence scroll DOWN (& go to top row) 0028 CD45 70 08 ENSCRN BVS ENSCRO ;If OUTPUT cursor, skip 0029 CD47 8D 19 03 STA CSY ;(this assumes windows are rectangular!) 0030 CD4A 68 PLA ;Cheat return stack 0031 CD4B 68 PLA 0032 CD4C 4C AE C6 JMP CSDA 0033 CD4F 08 ENSCRO PHP ;To preserve carry 0034 CD50 CD 65 03 CMP PCSY ;Would the input cursor like to go off screen ? 0035 CD53 F0 19 BEQ ENSCRP ;Yes?, then don't readdress it 0036 CD55 28 PLP ;Restore the carry, to see which way to go 0037 CD56 90 04 BCC ENSCRQ 0038 CD58 CE 65 03 DEC PCSY ;Scroll DOWN, so follow it down 0039 CD5B [ MOS125 = &FF 0040 CD5B | 0041 CD5B FONT0 0042 CD5B ] 0043 CD5B 60 ENSCRX RTS ;May be referenced from MOS04 0044 CD5C EE 65 03 ENSCRQ INC PCSY ;Scroll UP, so go up as well 0045 CD5F 60 RTS 0046 CD60 0047 CD60 ;OCSRDL Delete output cursor 0048 CD60 0049 CD60 08 OCSRDL PHP 0050 CD61 48 PHA 0051 CD62 AC 4F 03 LDY BYTCH 0052 CD65 88 DEY ;TTX? 0053 CD66 D0 0A BNE OCSRIV ;Not TTX?, then same as writing cursor, as it inverts 0054 CD68 AD 38 03 LDA TTXTMP ;TTX?, then write remebered byte 0055 CD6B 91 D8 STAIY ZMEMT ;(Y)=0 0056 CD6D 68 OCSREX PLA ;& exit 0057 CD6E 28 ENSCRP PLP ;Get the stack correct 0058 CD6F 60 ENSCRR RTS 0059 CD70 0060 CD70 ;OCSRWR Write output cursor 0061 CD70 0062 CD70 [ MOS125 = &FF 0084 CD70 | 0085 CD70 08 OCSRWR PHP 0086 CD71 48 PHA 0087 CD72 A9 3F OCSRIV LDAIM INVSXT 0088 CD74 AC 4F 03 LDY BYTCH 0089 CD77 C0 20 CPYIM &20 ;Mode 2 ? 0090 CD79 F0 13 BEQ OCSRIW ;Yes?, then don't invert the flashing bit 0091 CD7B A9 FF LDAIM &FF 0092 CD7D 88 DEY ;TTX? 0093 CD7E D0 08 BNE OCSRIU 0094 CD80 B1 D8 LDAIY ZMEMT ;(Y)=0 Yes?, then read byte directly from screen 0095 CD82 8D 38 03 STA TTXTMP ;and store it out of harm's way (no plotting in this mode) 0096 CD85 4D 66 03 EOR CHCSR ;Write the cursor 0097 CD88 48 OCSRIU PHA 0098 CD89 51 D8 EORIY ZMEMT ;Invert the character cell 0099 CD8B 91 D8 STAIY ZMEMT 0100 CD8D 68 PLA 0101 CD8E 88 OCSRIW DEY 0102 CD8F 10 F7 BPL OCSRIU 0103 CD91 30 DA BMI OCSREX ; Branch always 0104 CD93 ] 0105 CD93 0106 CD93 ;Soft scrolling (non-anom.) 0107 CD93 0108 CD93 ;Scroll DOWN 0109 CD93 0110 CD93 20 5B CE SSCRDN JSR SSCRIN ;Initialise 0111 CD96 AD 09 03 LDA TWBROW ;1st receive address is bottom LH point 0112 CD99 8D 19 03 STA CSY ;(CSX initialised in SSCRIN) 0113 CD9C 20 09 CF JSR TADDRY ;address bottom LH point (guaranteed in window) 0114 CD9F 20 DE CB SSCRDA JSR SUBROW ;Get the address of the LH point of the next line up 0115 CDA2 B0 03 BCS SSCRDB ;Wraparound between these two lines? NO, then continue 0116 CDA4 6D 54 03 ADC BYTSCN ;Yes,then add screen and note we must scroll slowly! 0117 CDA7 85 DB SSCRDB STA ZTEMP +&01 ;store transmit address 0118 CDA9 86 DA STX ZTEMP 0119 CDAB 85 DC STA ZTEMPB ;& MSB of next receive address (LSB is not changed) 0120 CDAD [ MOS125 = &FF 0127 CDAD | 0128 CDAD 90 0A BCC SSCRDC ;c unchanged since just after SSCRDA 0129 CDAF 20 DE CB SSCRDE JSR SUBROW ;Get next line up 0130 CDB2 90 05 BCC SSCRDC ;Wraparound occured ?, then slow scroll to be safe 0131 CDB4 20 38 CE JSR XMIT ;Scroll fast is possible 0132 CDB7 F0 03 BEQ SSCRDD ;xmit returns EQ 0133 CDB9 20 73 CE SSCRDC JSR SSCRS ;Scroll slowly ! 0134 CDBC ] 0135 CDBC A5 DC SSCRDD LDA ZTEMPB ;MSB of next receive address 0136 CDBE A6 DA LDX ZTEMP ;LSB of same 0137 CDC0 85 D9 STA ZMEMT +&01 ;Initialise next receive address 0138 CDC2 86 D8 STX ZMEMT 0139 CDC4 C6 DE DEC ZTEMPC ;Any more lines to copy ? 0140 CDC6 D0 D7 BNE SSCRDA ;Don't bother to copy last line 0141 CDC8 A2 28 SSCREX LDXIM SSWS-V ;Preserve or restore current text cursor 0142 CDCA A0 18 LDYIM CSX-V 0143 CDCC A9 02 SWAP2 LDAIM &02 0144 CDCE D0 06 BNE SWAP 0145 CDD0 A2 24 SWAPB LDXIM GCSIR-V ;SPLOTY requires c preserved 0146 CDD2 A0 14 SWAPC LDYIM OLDCS-V 0147 CDD4 0148 CDD4 ;SWAPF swaps 4 bytes between (V)+(X) & (V)+(Y) 0149 CDD4 0150 CDD4 A9 04 SWAPF LDAIM &04 ;by falling through to ... 0151 CDD6 Acorn macro assembler Page 24 VDU File - MOS05 0152 CDD6 ;SWAP swaps (A) bytes between (V)+(X) & (V)+(Y) 0153 CDD6 0154 CDD6 85 DA SWAP STA ZTEMP 0155 CDD8 BD 00 03 SWAPA LDAAX V 0156 CDDB 48 PHA 0157 CDDC B9 00 03 LDAAY V 0158 CDDF 9D 00 03 STAAX V 0159 CDE2 68 PLA 0160 CDE3 99 00 03 STAAY V 0161 CDE6 E8 INX 0162 CDE7 C8 INY 0163 CDE8 C6 DA DEC ZTEMP 0164 CDEA D0 EC BNE SWAPA 0165 CDEC 60 RTS 0166 CDED 0167 CDED 0168 CDED [ MOS125 = &FF 0169 CDED | 0170 CDED ;(SORTY exits with (X)<(Y)) 0171 CDED 0172 CDED A2 20 SORTA LDXIM NEWPT-V 0173 CDEF A0 14 LDYIM OLDCS-V 0174 CDF1 BD 02 03 SORTY LDAAX V+&02 0175 CDF4 D9 02 03 CMPAY V+&02 0176 CDF7 BD 03 03 LDAAX V+&03 0177 CDFA F9 03 03 SBCAY V+&03 0178 CDFD 10 D5 BPL SWAPF 0179 CDFF 60 RTS 0180 CE00 ] 0181 CE00 0182 CE00 ;Soft scroll UP 0183 CE00 0184 CE00 20 5B CE SSCRUP JSR SSCRIN ;Initialise 0185 CE03 AC 0B 03 LDY TWTROW ;Receive from top line, LH column 0186 CE06 8C 19 03 STY CSY 0187 CE09 20 09 CF JSR TADDRY ;Get 1st receive address (point guaranteed in window) 0188 CE0C 20 B1 CA SSCRUA JSR ADDROW ;Get line below 0189 CE0F 10 04 BPL SSCRUE ;Wraparound ? 0190 CE11 38 SEC ;Yes, then correct and scroll slowly 0191 CE12 ED 54 03 SBC BYTSCN 0192 CE15 85 DB SSCRUE STA ZTEMP +&01 ;Transmit address 0193 CE17 86 DA STX ZTEMP 0194 CE19 85 DC STA ZTEMPB ;MSB of next receive addr., LSB is preserved 0195 CE1B [ MOS125 = &FF 0202 CE1B | 0203 CE1B B0 0A BCS SSCRUC ;(c unchanged since just after SSCRUA) 0204 CE1D 20 B1 CA SSCRUB JSR ADDROW ;Get next line down 0205 CE20 30 05 BMI SSCRUC ;Wraparound ?, then scroll slowly to be safe 0206 CE22 20 38 CE JSR XMIT ;No?, then we can scroll fast 0207 CE25 F0 03 BEQ SSCRUD ;xmit returns EQ 0208 CE27 20 73 CE SSCRUC JSR SSCRS ;Scroll slowly 0209 CE2A ] 0210 CE2A A5 DC SSCRUD LDA ZTEMPB ;Load next receive address 0211 CE2C A6 DA LDX ZTEMP 0212 CE2E 85 D9 STA ZMEMT +&01 ;and store it 0213 CE30 86 D8 STX ZMEMT 0214 CE32 C6 DE DEC ZTEMPC ;any more lines to copy ? 0215 CE34 D0 D6 BNE SSCRUA ;don't bother with the last line 0216 CE36 F0 90 BEQ SSCREX ; Jump always 0217 CE38 0218 CE38 ;XMIT - Fast soft scroll 0219 CE38 ;Copy PWWDTH bytes from (ZTEMP) to (ZMEMT) 0220 CE38 0221 CE38 AE 4D 03 XMIT LDX PWWDTH +&01 ;How many pages? 0222 CE3B F0 10 BEQ XMITB ;None?, then attempt fractional 0223 CE3D A0 00 LDYIM &00 0224 CE3F B1 DA XMITA LDAIY ZTEMP ;Inner loop - copy complete page 0225 CE41 91 D8 STAIY ZMEMT 0226 CE43 C8 INY 0227 CE44 D0 F9 BNE XMITA 0228 CE46 E6 D9 INC ZMEMT +&01 ;Prepare to copy next page 0229 CE48 E6 DB INC ZTEMP +&01 0230 CE4A CA DEX ;Any more complete pages to copy ? 0231 CE4B D0 F2 BNE XMITA 0232 CE4D AC 4C 03 XMITB LDY PWWDTH ;Copy fractional page? 0233 CE50 F0 08 BEQ XMITD ;No?, then exit 0234 CE52 88 XMITC DEY 0235 CE53 B1 DA LDAIY ZTEMP ;Yes?, then do so 0236 CE55 91 D8 STAIY ZMEMT 0237 CE57 98 TYA 0238 CE58 D0 F8 BNE XMITC 0239 CE5A 60 XMITD RTS ;Referenced below 0240 CE5B 0241 CE5B ;SSCRIN Soft scroll initialisation 0242 CE5B 0243 CE5B ;(SSWS) := (CSX)(CSY) 0244 CE5B ;(CSX) := (TWLCOL) 0245 CE5B ;(ZTEMPC) := No. of rows to scroll, minus one 0246 CE5B 0247 CE5B 20 C8 CD SSCRIN JSR SSCREX ;Store current text cursor for future reference 0248 CE5E 38 SEC ;Determine no. of rows to scroll 0249 CE5F AD 09 03 LDA TWBROW ;i.e. no. rows in window minus 1 0250 CE62 ED 0B 03 SBC TWTROW 0251 CE65 85 DE STA ZTEMPC 0252 CE67 D0 05 BNE SSCRIM 0253 CE69 68 PLA ;If zero lines to scroll, then cheat stack 0254 CE6A 68 PLA 0255 CE6B 4C C8 CD JMP SSCREX ;& restore cursor 0256 CE6E 0257 CE6E AD 08 03 SSCRIM LDA TWLCOL ;Put x cursor on LH margin 0258 CE71 10 70 BPL CLTLND 0259 CE73 0260 CE73 0261 CE73 ;SSCRS Slow soft scroll 0262 CE73 ;Scrolls 1 row of characters, one by one from (ZTEMP) to (ZMEMT), 0263 CE73 ;preserving the LSB of ZTEMP. 0264 CE73 ;Requires that ZMEMT & ZTEMP be juxtaposed. 0265 CE73 ;Checks for wraparound after each character is copied 0266 CE73 0267 CE73 A5 DA SSCRS LDA ZTEMP ;Push LSB of ZTEMP 0268 CE75 48 PHA 0269 CE76 38 SEC ;Calc no. chars to copy -1 0270 CE77 AD 0A 03 LDA TWRCOL 0271 CE7A ED 08 03 SBC TWLCOL 0272 CE7D 85 DF STA ZTEMPC +&01 ;No. of columns to be scrolled (for loop) 0273 CE7F AC 4F 03 SSCRSA LDY BYTCH 0274 CE82 88 DEY 0275 CE83 B1 DA SSCRSB LDAIY ZTEMP ;~~~ Copy 1 character ~~~ 0276 CE85 91 D8 STAIY ZMEMT ;by copying (BYTCH) consecutive bytes 0277 CE87 88 DEY 0278 CE88 10 F9 BPL SSCRSB Acorn macro assembler Page 25 VDU File - MOS05 0279 CE8A A2 02 LDXIM &02 ;Now add BYTCH to ZMEMT & ZTEMP, 0280 CE8C 18 SSCRSC CLC ;checking for wraparound on both 0281 CE8D B5 D8 LDAZX ZMEMT ;uses ZX mode, hence need for ZMEMT to be next to ZTEMP 0282 CE8F 6D 4F 03 ADC BYTCH 0283 CE92 95 D8 STAZX ZMEMT 0284 CE94 B5 D9 LDAZX ZMEMT +&01 0285 CE96 69 00 ADCIM &00 0286 CE98 10 04 BPL SSCRSD ;Did wraparound occur? 0287 CE9A 38 SEC 0288 CE9B ED 54 03 SBC BYTSCN 0289 CE9E 95 D9 SSCRSD STAZX ZMEMT +&01 0290 CEA0 CA DEX 0291 CEA1 CA DEX 0292 CEA2 F0 E8 BEQ SSCRSC ;(Do ZMEMT) 0293 CEA4 C6 DF DEC ZTEMPC +&01 ;Any more characters? 0294 CEA6 10 D7 BPL SSCRSA 0295 CEA8 68 PLA ;Restore LSB of ZMEMT 0296 CEA9 85 DA STA ZTEMP 0297 CEAB 60 RTS 0298 CEAC 0299 CEAC ;Clear the line of text addressed by CSY 0300 CEAC ;Preserve CSY & CSX 0301 CEAC 0302 CEAC AD 18 03 CLTLIN LDA CSX ;Push the current X cursor position 0303 CEAF 48 PHA 0304 CEB0 20 6E CE JSR SSCRIM ;CSX = Left margin of window 0305 CEB3 20 09 CF JSR TADDRY ;Init. ZMEMT 0306 CEB6 38 SEC 0307 CEB7 AD 0A 03 LDA TWRCOL 0308 CEBA ED 08 03 SBC TWLCOL 0309 CEBD 85 DC STA ZTEMPB ;Column count 0310 CEBF AD 58 03 CLTLNA LDA BTCOLF ;get colour 0311 CEC2 AC 4F 03 LDY BYTCH ;Bytes / character 0312 CEC5 88 CLTNB DEY ;Inner loop - clear one character cell 0313 CEC6 91 D8 STAIY ZMEMT ;(preserves z from previous DEY) 0314 CEC8 D0 FB BNE CLTNB ;1 char cell 0315 CECA 8A TXA ;Update ZMEMT 0316 CECB 18 CLC 0317 CECC 6D 4F 03 ADC BYTCH 0318 CECF AA TAX 0319 CED0 A5 D9 LDA ZMEMT +&01 0320 CED2 69 00 ADCIM &00 0321 CED4 10 04 BPL CLNLC ;Wraparound ? 0322 CED6 38 SEC ;Yes, then subtract off the number of bytes per screen 0323 CED7 ED 54 03 SBC BYTSCN 0324 CEDA 86 D8 CLNLC STX ZMEMT 0325 CEDC 85 D9 STA ZMEMT +&01 0326 CEDE C6 DC DEC ZTEMPB ;One less character to clear 0327 CEE0 10 DD BPL CLTLNA ;Any more? 0328 CEE2 68 PLA 0329 CEE3 8D 18 03 CLTLND STA CSX 0330 CEE6 38 FAIL SEC 0331 CEE7 60 RTS 0332 CEE8 0333 CEE8 0334 CEE8 ;Addresses CSX,CSY to memory locn. on screen. 0335 CEE8 ;Checks that CSX & CSY are in window 0336 CEE8 ;Returns with no action and c=1 if outside. 0337 CEE8 ;If OK, initialises ZMEMT and CSPOSN 0338 CEE8 ;Exits with cursor address in (AX) 0339 CEE8 ;For cursor display, follow immediately with 0340 CEE8 ;JSR CSDSP 0341 CEE8 0342 CEE8 [ MOS125 = &FF 0355 CEE8 | 0356 CEE8 8D 19 03 SYTADD STA CSY 0357 CEEB AE 18 03 TADDR LDX CSX ;Check window of CSX 0358 CEEE EC 08 03 CPX TWLCOL ;Lower than LH margin ? 0359 CEF1 90 F3 BCC FAIL 0360 CEF3 EC 0A 03 CPX TWRCOL ;Higher than RH edge ? 0361 CEF6 F0 02 BEQ TADDRX 0362 CEF8 B0 EC BCS FAIL 0363 CEFA AE 19 03 TADDRX LDX CSY ;Check CSY 0364 CEFD EC 0B 03 CPX TWTROW 0365 CF00 90 E4 BCC FAIL 0366 CF02 EC 09 03 CPX TWBROW 0367 CF05 F0 02 BEQ TADDRY 0368 CF07 B0 DD BCS FAIL 0369 CF09 ] 0370 CF09 0371 CF09 ;End of windowing, now calc. memory posn. 0372 CF09 ;As TADDR with no bounds checking 0373 CF09 ;Returns carry clear 0374 CF09 0375 CF09 AD 19 03 TADDRY LDA CSY ;Twice row no. to Y 0376 CF0C 0A ASLA 0377 CF0D A8 TAY ;(c=0 at this point) 0378 CF0E B1 E0 LDAIY ZTBL ;MSB 0379 CF10 85 D9 STA ZMEMT+&01 0380 CF12 C8 INY 0381 CF13 A9 02 LDAIM &02 0382 CF15 2D 56 03 AND MEMODE ;Non-zero if table offset is to be halved 0383 CF18 08 PHP 0384 CF19 B1 E0 LDAIY ZTBL ;LSB 0385 CF1B 28 PLP 0386 CF1C F0 03 BEQ TADDRH 0387 CF1E 46 D9 LSR ZMEMT+&01 0388 CF20 6A RORA 0389 CF21 6D 50 03 TADDRH ADC TOPSCN ;c=0 Add LSB 0390 CF24 85 D8 STA ZMEMT 0391 CF26 A5 D9 LDA ZMEMT+&01 ;Add MSB 0392 CF28 6D 51 03 ADC TOPSCN+&01 0393 CF2B A8 TAY ;Xfr MSB to Y 0394 CF2C ;Mpy. CSX by BYTCH 0395 CF2C AD 18 03 LDA CSX 0396 CF2F AE 4F 03 LDX BYTCH ;Is it TTX ? 0397 CF32 CA DEX 0398 CF33 F0 12 BEQ TADDRE ;Skip mult. if TTX 0399 CF35 E0 0F CPXIM &0F ;4 colour (16 bytes) ? 0400 CF37 F0 03 BEQ TADDRF 0401 CF39 90 02 BCC TADDRG ;Less ? Then 2 colour 0402 CF3B 0A ASLA ;Must have been 16 colour 0403 CF3C 0A TADDRF ASLA ;4 colour 0404 CF3D 0A TADDRG ASLA ;2 colour 0405 CF3E 0A ASLA 0406 CF3F 90 02 BCC TADDRB 0407 CF41 C8 INY ;c=1?, then inc. MSB by 2 0408 CF42 C8 INY 0409 CF43 0A TADDRB ASLA 0410 CF44 90 02 BCC TADDRC 0411 CF46 C8 INY ;c=1, then inc. MSB by 1 Acorn macro assembler Page 26 VDU File - MOS05 0412 CF47 18 TADDRE CLC 0413 CF48 65 D8 TADDRC ADC ZMEMT ;(c=0), add LSB of row offset 0414 CF4A 85 D8 STA ZMEMT 0415 CF4C 8D 4A 03 STA CSPOSN 0416 CF4F AA TAX ;LSB is returned by this routine in X 0417 CF50 98 TYA ;MSB to A 0418 CF51 69 00 ADCIM &00 0419 CF53 8D 4B 03 STA CSPOSN +&01 ;Store to cursor before wraparound 0420 CF56 10 04 BPL TADDRD ;Wraparound ? 0421 CF58 38 SEC ;Yes, then subt. scn. 0422 CF59 ED 54 03 SBC BYTSCN 0423 CF5C 85 D9 TADDRD STA ZMEMT +&01 ;Store physical address to ZMEMT 0424 CF5E 18 CLC ;indicate successful addressing 0425 CF5F 60 RTS 0426 CF60 0427 CF60 ;PRINT CHARACTER TO VDU 0428 CF60 0429 CF60 0430 CF60 0431 CF60 0432 CF60 ;ANOMALOUS PRINTING 0433 CF60 0434 CF60 AE 59 03 PRANM LDX FGCOLF ;Printing to be in foreground graphics colour 0435 CF63 AC 5B 03 LDY GPLFMD ;In the current foreground colour mode 0436 CF66 20 C5 D0 PRANC JSR SETZG ;Initialise ZGORA & ZGEOR 0437 CF69 0438 CF69 ;The graphics cursor is copied to 2 locations, APCS1 0439 CF69 ;and APCS2 . The latter is left untouched until the end of the printing, 0440 CF69 ;when it is restored to the GCSIY. The former is copied to the GCSIY 0441 CF69 ;after every column of pixels is printed, with the X cursor incremented 0442 CF69 ;each time. 0443 CF69 0444 CF69 20 3D D4 JSR COPYFA ;Copy GCSIY to APCS2 ... 0445 CF6C A0 00 LDYIM &00 ;Initialise row counter 0446 CF6E 84 DC PRANMC STY ZTEMPB 0447 CF70 [ MOS125 = &FF 0449 CF70 ] 0450 CF70 B1 DE LDAIY ZTEMPC ;Anything to do ? 0451 CF72 F0 13 BEQ PRANMG ;No, then skip 0452 CF74 85 DD STA ZTEMPB +&01 0453 CF76 10 03 PRANMA BPL PRANMD 0454 CF78 20 F5 D0 JSR WPLOTA ;Yes, then plot if inside window 0455 CF7B EE 24 03 PRANMD INC GCSIX ;Increment X cursor 0456 CF7E D0 03 BNE PRANME 0457 CF80 EE 25 03 INC GCSIX +&01 0458 CF83 06 DD PRANME ASL ZTEMPB +&01 0459 CF85 D0 EF BNE PRANMA 0460 CF87 A2 28 PRANMG LDXIM APCS1-V ;Restore previous x cursor 0461 CF89 A0 24 LDYIM GCSIR-V 0462 CF8B 20 39 D4 JSR COPY2 0463 CF8E AC 26 03 LDY GCSIY ;Decrement Igraphics Y cursor 0464 CF91 D0 03 BNE PRANMF 0465 CF93 CE 27 03 DEC GCSIY +&01 0466 CF96 CE 26 03 PRANMF DEC GCSIY 0467 CF99 A4 DC LDY ZTEMPB ;Do next row 0468 CF9B C8 INY 0469 CF9C C0 08 CPYIM &08 0470 CF9E D0 CE BNE PRANMC 0471 CFA0 A2 28 LDXIM APCS1 ;Finished, so restore grpahics cursor 0472 CFA2 A0 24 LDYIM GCSIR-V 0473 CFA4 4C 41 D4 JMP COPYF ; (branch always taken) 0474 CFA7 0475 CFA7 [ MOS125 = &FF 0491 CFA7 ] 0492 CFA7 0493 CFA7 ;NON-ANOMALOUS 0494 CFA7 0495 CFA7 ;Character to be printed in (A) 0496 CFA7 0497 CFA7 ;Set up address of bytes to be 0498 CFA7 ;copied from soft font. Result 0499 CFA7 ;to ZTEMP 0500 CFA7 0501 CFA7 AE 60 03 VDUPR LDX NCOLOR ;TTX? 0502 CFAA F0 43 BEQ PTTX 0503 CFAC 20 50 D0 JSR CHADDR ;Point (ZTEMPC) to character in soft font 0504 CFAF AE 60 03 VDUPRB LDX NCOLOR ;Because CHADDR now destroys (X) 0505 CFB2 A5 D0 LDA STATS ;Is this anomalous printing ? 0506 CFB4 29 20 ANDIM &20 0507 CFB6 D0 A8 BNE PRANM ;Anom. printing 0508 CFB8 0509 CFB8 ;Now select the mode 0510 CFB8 0511 CFB8 A0 07 LDYIM &07 ;No. rows (except TTX) 0512 CFBA E0 03 CPXIM &03 0513 CFBC F0 45 BEQ PFOUR ;4 colour mode ? 0514 CFBE B0 71 BCS PSXTN ;16 colour mode ? 0515 CFC0 0516 CFC0 ;TWO colour mode 0517 CFC0 0518 CFC0 B1 DE PTWO LDAIY ZTEMPC 0519 CFC2 05 D2 ORA ZORA 0520 CFC4 45 D3 EOR ZEOR 0521 CFC6 91 D8 STAIY ZMEMT 0522 CFC8 88 DEY 0523 CFC9 10 F5 BPL PTWO 0524 CFCB 60 RTS 0525 CFCC 0526 CFCC ;TELETEXT mode 0527 CFCC 0528 CFCC [ MOS125 = &FF 0538 CFCC | 0539 CFCC A9 7F DELA LDAIM &7F ;Point to DEL, only unprintable char. in hard font =$FF...$FF 0540 CFCE 20 50 D0 JSR CHADDR 0541 CFD1 AE 5A 03 LDX BGCOLF ;Force this to be graphics background colour 0542 CFD4 A0 00 LDYIM &00 ;Mode is STORE 0543 CFD6 F0 8E BEQ PRANC 0544 CFD8 0545 CFD8 ;DEL ($7F) Delete previous char 0546 CFD8 0547 CFD8 20 C4 C5 DEL JSR BS ;Move back 1 character 0548 CFDB 20 87 C5 JSR ANOMQ 0549 CFDE D0 EC BNE DELA 0550 CFE0 AE 60 03 LDX NCOLOR 0551 CFE3 F0 08 BEQ PTTXSP ;TTX space 0552 CFE5 85 DE STA ZTEMPC ;(A)=0 from ANOMQ 0553 CFE7 A9 C0 LDAIM HFMSB +&01 ;Point to hard font version of space 0554 CFE9 85 DF STA ZTEMPC +&01 0555 CFEB D0 C2 BNE VDUPRB ;always branch 0556 CFED 0557 CFED A9 20 PTTXSP LDAIM &20 ;Print TTX space Acorn macro assembler Page 27 VDU File - MOS05 0558 CFEF 18 PTTX CLC ;write to screen 0559 CFF0 TTXFRM ;transform once for ASCII->Teletext, twice for Teletext->ASCII 0560 CFF0 49 23 EORIM &23 ;is character ASCII &23, hash? 0561 CFF2 F0 04 BEQ PTTX5F ;then replace with Teletext &5F 0562 CFF4 49 7C PTTX23 EORIM &23:EOR:&5F ;else is it ASCII &5F, underscore? 0563 CFF6 F0 04 BEQ PTTX60 ;then replace with Teletext &60 0564 CFF8 49 3F PTTX5F EORIM &5F:EOR:&60 ;else is it ASCII &60, sterling? 0565 CFFA F0 F8 BEQ PTTX23 ;then replace with Teletext &23 (won't loop!) 0566 CFFC 49 60 PTTX60 EORIM &60 ;else undo our fiddling 0567 CFFE B0 02 BCS PTTXC ;if C=1 then transform only else C=0, write to screen 0568 D000 81 D8 STAIX ZMEMT ;as (X)=0 0569 D002 PTTXC 0570 D002 60 RTS 0571 D003 ] 0572 D003 0573 D003 ;FOUR colour mode 0574 D003 0575 D003 B1 DE PFOUR LDAIY ZTEMPC ;Get bit pattern 0576 D005 48 PHA ;Push for L.S.Nybble 0577 D006 4A LSRA 0578 D007 4A LSRA 0579 D008 4A LSRA 0580 D009 4A LSRA 0581 D00A AA TAX 0582 D00B BD 1F C3 LDAAX BPFTB ;Get expanded patten 0583 D00E 05 D2 ORA ZORA ;of M.S.Nybble 0584 D010 45 D3 EOR ZEOR 0585 D012 91 D8 STAIY ZMEMT 0586 D014 [ MOS125 = &FF 0594 D014 | 0595 D014 ; same size, reduce stack load 0596 D014 68 PLA ;Get L.S.Nybble 0597 D015 29 0F ANDIM &0F 0598 D017 AA TAX 0599 D018 98 TYA 0600 D019 18 CLC 0601 D01A 69 08 ADCIM &08 ;Access next char. cell 0602 D01C A8 TAY 0603 D01D ] 0604 D01D BD 1F C3 LDAAX BPFTB 0605 D020 05 D2 ORA ZORA 0606 D022 45 D3 EOR ZEOR 0607 D024 91 D8 STAIY ZMEMT 0608 D026 98 TYA 0609 D027 E9 08 SBCIM &08 ;c=0, thus subt. 9 0610 D029 A8 TAY 0611 D02A 10 D7 BPL PFOUR 0612 D02C 60 PSXTC RTS ;Also used by PSXTN 0613 D02D 0614 D02D ;SIXTEEN colour mode 0615 D02D 0616 D02D [ MOS125 = &FF 0641 D02D | 0642 D02D PSXTB ;Ref.the 1st cell again 0643 D02D F0 FD BEQ PSXTC ;Finished ? 0644 D02F A8 TAY ;No, then carry on .. 0645 D030 88 DEY 0646 D031 0647 D031 B1 DE PSXTN LDAIY ZTEMPC ;Get bit pattern 0648 D033 0A PSXTA ASLA 0649 D034 2A ROLA 0650 D035 85 DC STA ZTEMPB 0651 D037 29 01 ANDIM &01 0652 D039 2A ROLA ;(A)=next 2 bits 0653 D03A AA TAX ;Get expanded bit pattern 0654 D03B BD 2F C3 LDAAX BPSTB 0655 D03E 05 D2 ORA ZORA 0656 D040 45 D3 EOR ZEOR 0657 D042 91 D8 STAIY ZMEMT 0658 D044 98 TYA ;Access next char. cell 0659 D045 E9 17 SBCIM &17 ;c=0, subtract $18 0660 D047 B0 E4 BCS PSXTB 0661 D049 29 1F ANDIM &1F ;c=0 before & after 0662 D04B A8 TAY 0663 D04C A5 DC LDA ZTEMPB 0664 D04E 90 E3 BCC PSXTA ;(branch always taken) 0665 D050 ] 0666 D050 0667 D050 ;Addresses character in soft font. 0668 D050 ;Takes (ascii) value in A, multiplies by 8, adds appropriate font address 0669 D050 ;(assumed to be on page boudary), and puts result to ZTEMPC. 0670 D050 ;This addresses top row of character, subsequent rows being in the 0671 D050 ;following 7 bytes. 0672 D050 0673 D050 [ MOS125 = &FF 0693 D050 | 0694 D050 0A CHADDR ASLA ;ZTEMPC:=8*CHAR. + MSB of font 0695 D051 2A ROLA 0696 D052 2A ROLA 0697 D053 AA TAX 0698 D054 29 F8 ANDIM &F8 0699 D056 85 DE STA ZTEMPC ;Store LSB of addr. 0700 D058 8A TXA 0701 D059 29 03 ANDIM &03 ;Get page number of character 0702 D05B 2A ROLA 0703 D05C AA TAX 0704 D05D 29 03 ANDIM &03 0705 D05F 69 BF ADCIM HFMSB ;MSB of hard font - overwrite if soft font (c=0 from last ROLA) 0706 D061 A8 TAY 0707 D062 BD 0D C4 LDAAX BITTBL ;Which bit in the flag byte is to be tested 0708 D065 2C 67 03 BIT FNTFLG ;Test to see if soft or hard font 0709 D068 F0 03 BEQ CHADDS ;Clear, thus hard font 0710 D06A BC 67 03 LDYAX PGSFNT -&01 ;Load soft font page number 0711 D06D 84 DF CHADDS STY ZTEMPC +&01 ;Store MSByte 0712 D06F 60 RTS 0713 D070 ] 0714 D070 LNK MOS06 0001 D070 0002 D070 TTL VDU File - MOS06 0003 D070 OPT MOS06 Acorn macro assembler Page 28 VDU File - MOS06 0004 D070 0005 D070 ;Last revision 15/05/82 0006 D070 0007 D070 ;15/06/82 Adjust bad plot mode indirection code 0008 D070 ;05/05/82 GADDR converted such that it takes only 1 table. 0009 D070 ; Moved to MOS11 0010 D070 ;01/05/82 Recode to allow for new order of variables 0011 D070 ;21/04/82 Conditional assembly of start/end point double plotting. 0012 D070 ;22/01/82 Provide EIGABS 0013 D070 ;07/01/82 Put X to LSB of pointer 0014 D070 0015 D070 ;******* PLOTTING ******* 0016 D070 0017 D070 ;Prologue - converts from external to internal 0018 D070 ;co-ords, and distinguishes between types of 0019 D070 ;line & triangles 0020 D070 0021 D070 A2 20 EMA LDXIM NEWPT-V ;Convert external to internal 0022 D072 [ MOS125 = &FF 0025 D072 | 0026 D072 AD 1F 03 LDA PLMODE ;Get plot mode 0027 D075 48 PHA 0028 D076 20 5D D1 JSR EIGC ;for the 4 bytes starting at Q 0029 D079 68 PLA 0030 D07A ] 0031 D07A C9 04 CMPIM &04 ;BASIC's MOVE command 0032 D07C F0 6D BEQ EMAEX 0033 D07E A0 05 LDYIM &05 ;Point to do damn' all mode (for plotting that produces no change) 0034 D080 29 03 ANDIM &03 0035 D082 F0 0E BEQ EMAA ;No change, then exit 0036 D084 4A LSRA ;Is it odd ? 0037 D085 B0 03 BCS EMAF ;No?, then invert 0038 D087 88 DEY ;(Y) = 4. Point to INVERT values of table 0039 D088 D0 08 BNE EMAA ;(Branch always taken) 0040 D08A AA EMAF TAX 0041 D08B BC 5B 03 LDYAX GPLFMD 0042 D08E BD 59 03 LDAAX FGCOLF 0043 D091 AA TAX 0044 D092 20 C5 D0 EMAA JSR SETZG 0045 D095 0046 D095 ;What's to be done ? 0047 D095 0048 D095 AD 1F 03 LDA PLMODE ;Get plot mode 0049 D098 ;* TAY 0050 D098 30 23 BMI EXGREF ;Negative, then reference external routine 0051 D09A 0A ASLA ;Get type of operation 0052 D09B 10 3B BPL EMAD ;Is it a line? 0053 D09D 29 F0 ANDIM &F0 ;Get rid of irrelevant data 0054 D09F 0A ASLA ;Is it point ($80, will be shifted out) ? 0055 D0A0 F0 46 BEQ EMAC 0056 D0A2 49 40 EORIM &40 ;Triangles? 0057 D0A4 F0 14 BEQ EMAG 0058 D0A6 48 PHA 0059 D0A7 20 EE D0 JSR EMAEY ;Copy newpoint to internal cursor 0060 D0AA 68 PLA 0061 D0AB 49 60 EORIM &60 ;SPLOT 0062 D0AD F0 11 BEQ EME ;($60=$20 EOR $40) 0063 D0AF C9 40 CMPIM &40 ;SPLOT looking for b/g ($60 = $40 EOR $60 EOR $40) 0064 D0B1 D0 0A BNE EXGREF 0065 D0B3 A9 02 LDAIM &02 ;This is what is EORed with the flag register 0066 D0B5 85 DC STA ZTEMPB 0067 D0B7 4C BC D4 JMP SCHEAT 0068 D0BA 0069 D0BA 4C 9C D5 EMAG JMP EMC ;Jump to triangles 0070 D0BD EXGREF 0071 D0BD ;* TYA ;Restore plot mode to A 0072 D0BD 4C 0E C9 JMP JMIV25 0073 D0C0 0074 D0C0 85 DC EME STA ZTEMPB ;(A)=0 .This is what is EORed with the flag register 0075 D0C2 4C 75 D4 JMP SPLOT ;Fill plot 0076 D0C5 0077 D0C5 ;Set up ZGORA & ZGEOR, using 0078 D0C5 ;(X)=Full colour byte 0079 D0C5 ;(Y)=Plot mode 0080 D0C5 0081 D0C5 8A SETZG TXA 0082 D0C6 19 1C C4 ORAAY TBZGOO 0083 D0C9 59 1D C4 EORAY TBZGEO 0084 D0CC 85 D4 STA ZGORA 0085 D0CE 8A TXA 0086 D0CF 19 1B C4 ORAAY TBZGOE 0087 D0D2 59 20 C4 EORAY TBZGEE 0088 D0D5 85 D5 STA ZGEOR 0089 D0D7 60 RTS 0090 D0D8 0091 D0D8 ;Plot a line or curve 0092 D0D8 0093 D0D8 0A EMAD ASLA ;Is it a line or curve ? 0094 D0D9 30 E2 BMI EXGREF ;Curve, so reference user routine 0095 D0DB 0A ASLA 0096 D0DC 0A ASLA ;It's a line, so is the first point to be plotted again? 0097 D0DD 10 03 BPL EMAB ;No, then skip this, as routine plots both anyway 0098 D0DF ; 0099 D0DF [ STARTP=0 0102 D0DF | 0103 D0DF ; plot end point twice 0104 D0DF 20 FD D0 JSR WPLOT 0105 D0E2 ] 0106 D0E2 ; 0107 D0E2 20 C5 D1 EMAB JSR LINE 0108 D0E5 4C EB D0 JMP EMAEX 0109 D0E8 0110 D0E8 ;Plot a point 0111 D0E8 0112 D0E8 20 FD D0 EMAC JSR WPLOT ;Plot only if it is in window 0113 D0EB ;SPLOTY requires that EMAEX preserves carry 0114 D0EB 20 D0 CD EMAEX JSR SWAPB ;Swap current cursor with last cursor 0115 D0EE A0 24 EMAEY LDYIM GCSIR-V ;Copy new point to Icursor 0116 D0F0 A2 20 EMAEZ LDXIM NEWPT-V 0117 D0F2 4C 41 D4 JMP COPYF 0118 D0F5 0119 D0F5 ;WPLOT windows point at NEWPT and plots it if inside 0120 D0F5 0121 D0F5 A2 24 WPLOTA LDXIM GCSIR-V ;WPLOTA does this to current graphics cursor 0122 D0F7 20 F1 D7 JSR GADDV ;WPLOTB does this for any point pointed to by X 0123 D0FA F0 06 BEQ PLOT 0124 D0FC 60 RTS 0125 D0FD 20 EF D7 WPLOT JSR GADDW ;Window & address NEWPT 0126 D100 D0 13 BNE PLOTEX ;Out of window, then exit 0127 D102 0128 D102 ;otherwise fall through to ..... Acorn macro assembler Page 29 VDU File - MOS06 0129 D102 0130 D102 ;PLOT plots a point 0131 D102 ;Requires LINEY, ZMEMG, ZGORA, ZGEOR 0132 D102 ;Uses ZTEMP as work byte 0133 D102 ;Alters 1 byte on screen 0134 D102 0135 D102 AC 1A 03 PLOT LDY YLINE 0136 D105 A5 D1 PLOTS LDA ZMASK 0137 D107 25 D4 AND ZGORA 0138 D109 11 D6 ORAIY ZMEMG 0139 D10B 85 DA STA ZTEMP 0140 D10D A5 D5 LDA ZGEOR 0141 D10F 25 D1 AND ZMASK 0142 D111 45 DA EOR ZTEMP 0143 D113 91 D6 STAIY ZMEMG 0144 D115 60 PLOTEX RTS 0145 D116 0146 D116 B1 D6 PLOTFF LDAIY ZMEMG ;Plots a full byte 0147 D118 05 D4 ORA ZGORA 0148 D11A 45 D5 EOR ZGEOR 0149 D11C [ MOS125 = &7F 0150 D11C WRSC 0151 D11C ] 0152 D11C 91 D6 STAIY ZMEMG 0153 D11E 60 RTS 0154 D11F 0155 D11F ;WIND windows the point at V+(X), as follows 0156 D11F ;If the point is below the lower limit, the window is 1 0157 D11F ;If the point is above the upper limit, the window is 2 0158 D11F ;If the point is within both limits, the window is 0 0159 D11F ;The total window, returned in A (with z set appropriately) 0160 D11F ;is 4 times the window in the Y direction, plus the window 0161 D11F ;in the X direction. 0162 D11F ;The routine uses ZTEMP as a work byte 0163 D11F ;All windows, as specified by GWxxxx are reckoned as inclusive, 0164 D11F ;with the high byte last. 0165 D11F ;The order of the windows in RAM is reckoned as follows 0166 D11F ;GWLCOL, GWBROW, GWRCOL, GWTROW 0167 D11F 0168 D11F A2 24 WINDCS LDXIM GCSIR-V ;Special entry point to window graphics cursor 0169 D121 0170 D121 A0 00 WIND LDYIM &00 ;Initialise result 0171 D123 84 DA STY ZTEMP 0172 D125 A0 02 LDYIM &02 ;Do the Y co-ords 0173 D127 20 3A D1 JSR WINDA 0174 D12A 06 DA ASL ZTEMP ;Mult. the Y window by 4 0175 D12C 06 DA ASL ZTEMP 0176 D12E CA DEX 0177 D12F CA DEX 0178 D130 A0 00 LDYIM &00 ;Do the X window 0179 D132 20 3A D1 JSR WINDA 0180 D135 E8 INX ;Restore X 0181 D136 E8 INX 0182 D137 A5 DA LDA ZTEMP 0183 D139 60 RTS 0184 D13A 0185 D13A ;Subtract margin from point to obtain sign of difference 0186 D13A 0187 D13A BD 02 03 WINDA LDAAX V+&02 ;(LSB) 0188 D13D D9 00 03 CMPAY GWLCOL ;(LSB of lower limit) 0189 D140 BD 03 03 LDAAX V+&03 ;(MSB) 0190 D143 F9 01 03 SBCAY GWLCOL+&01 ;(MSB of lower limit) 0191 D146 30 10 BMI WINDAA 0192 D148 B9 04 03 LDAAY GWRCOL ;(LSB of upper limit) 0193 D14B DD 02 03 CMPAX V+&02 ;(LSB) 0194 D14E B9 05 03 LDAAY GWRCOL+&01 ;(MSB of upper limit) 0195 D151 FD 03 03 SBCAX V+&03 ;(MSB) 0196 D154 10 04 BPL WINDAB ;Is this <= upper limit ? 0197 D156 E6 DA INC ZTEMP 0198 D158 E6 DA WINDAA INC ZTEMP 0199 D15A 60 WINDAB RTS ;No longer referenced from EIG, incidentally, saving TWO WHOLE BYTES !! 0200 D15B 0201 D15B ;EIGABS in some embarassment is to provide EIG in ABSOLUTE co-ords 0202 D15B 0203 D15B A9 FF EIGABS LDAIM &FF 0204 D15D [ MOS125 = &FF 0206 D15D ] 0207 D15D 0208 D15D ;Convert external to internal co-ordinates 0209 D15D 0210 D15D ;EIG converts from external co-ords (either relative or abs) 0211 D15D ;and produces internal ones in situ. No windowing is done. 0212 D15D ;Requires (X) = the offset from V of the points to be converted 0213 D15D ;b2 of PLMODE = 0 for relative co-ords (add the Ecursor) 0214 D15D ; 1 for absolute co-ords (add the origin) 0215 D15D ;GCSR, ORGX, ORGY as usual 0216 D15D ;Writes the transformed co-ordinates from whence they came 0217 D15D ;Also writes new point to external cursor (GCSX,GCSY) 0218 D15D ;hence in triangle relative mode, the points are relative 0219 D15D ;to the last specified, not the original cursor 0220 D15D 0221 D15D ;a) Add the cursor to current posn. if relative 0222 D15D ;& add origin in both cases 0223 D15D 0224 D15D [ MOS125 = &FF 0226 D15D ] 0227 D15D 85 DA EIGC STA ZTEMP 0228 D15F A0 02 LDYIM &02 ;Do this for Y co-ordinates 0229 D161 20 83 D1 JSR EIGS 0230 D164 20 BA D1 JSR DIVAXT ;1024 points vertically 0231 D167 A0 00 LDYIM &00 0232 D169 CA DEX 0233 D16A CA DEX 0234 D16B 20 83 D1 JSR EIGS ;Do this for X co-ordinates 0235 D16E 0236 D16E ;b) scale down by the necessary factor 0237 D16E ;(EIGS has already divided by 2) 0238 D16E 0239 D16E AC 61 03 LDY NPIX ;How many pixles ? 0240 D171 C0 03 CPYIM &03 0241 D173 F0 05 BEQ EIGA ;4?, then divide by 4 0242 D175 B0 06 BCS EIGB ;8?, then divide by 2 0243 D177 20 BA D1 JSR DIVAXT ;2?, then divide by 8 0244 D17A 20 BA D1 EIGA JSR DIVAXT 0245 D17D AD 56 03 EIGB LDA MEMODE ;Is it a 10K mode? 0246 D180 D0 38 BNE DIVAXT ;YES, then another divide by 2 0247 D182 60 RTS ; NO, then skip 0248 D183 0249 D183 18 EIGS CLC 0250 D184 A5 DA LDA ZTEMP ;Test b2 of plot mode, for rel./abs. 0251 D186 29 04 ANDIM &04 Acorn macro assembler Page 30 VDU File - MOS06 0252 D188 F0 09 BEQ EIGSA ;Clear, so relative ( & skip ) 0253 D18A BD 02 03 LDAAX V+&02 ;(LSB) ~~~ ABSOLUTE ~~~ 0254 D18D 48 PHA 0255 D18E BD 03 03 LDAAX V+&03 ;(MSB) 0256 D191 90 0E BCC EIGSB ;(branch always taken) 0257 D193 BD 02 03 EIGSA LDAAX V+&02 ;~~~ RELATIVE ~~~ 0258 D196 79 10 03 ADCAY GCSR ;so add prev. cursor (LSB) 0259 D199 48 PHA 0260 D19A BD 03 03 LDAAX V+&03 ;(MSB) 0261 D19D 79 11 03 ADCAY GCSR+&01 0262 D1A0 18 CLC 0263 D1A1 99 11 03 EIGSB STAAY GCSR+&01 ;Update MSB of cursor 0264 D1A4 79 0D 03 ADCAY ORG+&01 ;Now add origin for both addressing modes ! 0265 D1A7 9D 03 03 STAAX V+&03 ;(MSB) 0266 D1AA 68 PLA ;Pull LSByte 0267 D1AB 99 10 03 STAAY GCSR ;Update LSB of cursor 0268 D1AE 18 CLC 0269 D1AF 79 0C 03 ADCAY ORG ;(LSB) 0270 D1B2 9D 02 03 STAAX V+&02 0271 D1B5 90 03 BCC DIVAXT 0272 D1B7 FE 03 03 INCAX V+&03 ;Carry into MSB if needs be 0273 D1BA 0274 D1BA ;Divide this by 2 by falling through to ... 0275 D1BA 0276 D1BA BD 03 03 DIVAXT LDAAX V+&03 ;Signed division by 2 0277 D1BD 0A ASLA ;(Screen now 1280 by 1024) 0278 D1BE 7E 03 03 RORAX V+&03 0279 D1C1 7E 02 03 RORAX V+&02 0280 D1C4 [ MOS125 = &FF 0281 D1C4 | 0282 D1C4 LINEX1 0283 D1C4 ] 0284 D1C4 60 RTS 0285 D1C5 0286 D1C5 [ MOS125 = &FF 0315 D1C5 ] 0316 D1C5 0317 D1C5 LNK MOS07 0001 D1C5 TTL VDU File - MOS07 0002 D1C5 OPT MOS07 Acorn macro assembler Page 31 VDU File - MOS07 0003 D1C5 0004 D1C5 ;Last revision 01/05/82 0005 D1C5 0006 D1C5 ;01/05/82 Recoded to allow for new order of variables & manifests 0007 D1C5 ;21/04/82 LINE rewritten 0008 D1C5 ;19/04/82 One byte saved in SB 0009 D1C5 ;25/03/82 Change all refs. to BEGSCN+1 to BEGSCN 0010 D1C5 ;14/11/81 Variable mark space on DOTS removed 0011 D1C5 0012 D1C5 ;******* PLOTTING ******* 0013 D1C5 0014 D1C5 ;LINE plots straight line from cursor to new point 0015 D1C5 ;taking account windowing, & plotting partial lines 0016 D1C5 ;if necessary 0017 D1C5 0018 D1C5 ;Requires GCSIR = the current cursor position (I co-ords) 0019 D1C5 ;NEWPT = the point to plotted to (I co-ords) 0020 D1C5 ;Windowing is assumed of neither 0021 D1C5 0022 D1C5 0023 D1C5 ;Plot a straight line 0024 D1C5 0025 D1C5 20 C4 D3 LINE JSR LINSA ;Find DeltaX & DeltaY to LDELTA 0026 D1C8 ;LINSB Returns n=1 iff MOD DeltaX < MOD DeltaY 0027 D1C8 ;Encoded version of a previous routine 0028 D1C8 0029 D1C8 AD 2B 03 LDA LDELTA+&03 ;DY, MSB Are the deltas of the same sign? 0030 D1CB [ MOS125 = &FF 0043 D1CB | 0044 D1CB AA TAX 0045 D1CC 4D 29 03 EOR LDELTA+&01 ;DX, MSB 0046 D1CF 0A ASLA 0047 D1D0 AD 2A 03 LDA LDELTA+&02 0048 D1D3 B0 0A BCS LINSBA 0049 D1D5 CD 28 03 CMP LDELTA ;YES, then compare DeltaY - DeltaX 0050 D1D8 8A TXA 0051 D1D9 ED 29 03 SBC LDELTA+&01 0052 D1DC 4C E7 D1 JMP LINSBB 0053 D1DF 18 LINSBA CLC ;NO, then add 0054 D1E0 6D 28 03 ADC LDELTA 0055 D1E3 8A TXA 0056 D1E4 6D 29 03 ADC LDELTA+&01 0057 D1E7 ] 0058 D1E7 6A LINSBB RORA ;c to b7 of A 0059 D1E8 A2 00 LDXIM &00 0060 D1EA 4D 2B 03 EOR LDELTA+&03 ;If DY < 0, then invert b7 of A. Sets n as required 0061 D1ED ; 0062 D1ED 10 02 BPL LINEA 0063 D1EF A2 02 LDXIM &02 0064 D1F1 86 DE LINEA STX ZTEMPC ;0 if p.b.X, 2 if p.b.Y 0065 D1F3 BD AA C4 LDAAX D1JTB ;JVEC initialisation (D1 jump vector) 0066 D1F6 8D 5D 03 STA JVEC 0067 D1F9 BD AB C4 LDAAX D1JTB+&01 0068 D1FC 8D 5E 03 STA JVEC+&01 0069 D1FF [ MOS125 = &FF 0076 D1FF | 0077 D1FF A9 24 LDAIM GCSIR-V ;+ve, then LSTART from GCSIR... 0078 D201 BC 29 03 LDYAX LDELTA+&01 ;Sign of D1 0079 D204 30 02 BMI LINEC 0080 D206 A9 20 LDAIM NEWPT-V ;Copy LSTART from new point 0081 D208 85 DF LINEC STA ZTEMPC+&01 ;Offset of LSTART (=PStart of old) 0082 D20A AA TAX 0083 D20B ] 0084 D20B A0 2C LDYIM LSTART-V ;Copy to LSTART 0085 D20D 20 41 D4 JSR COPYF 0086 D210 A5 DF LDA ZTEMPC+&01 ;Get Horizontal co-ordinate of other (end) point 0087 D212 49 04 EORIM &04 ;This requires NEWPT to be multiple of 8 & GCSIR 4 above it 0088 D214 85 DD STA ZTEMPB+&01 0089 D216 05 DE ORA ZTEMPC ;Get Hend (horizontal co-ordinate of endpoint) 0090 D218 AA TAX 0091 D219 20 37 D4 JSR COPY2H 0092 D21C AD 1F 03 LDA PLMODE ;Initialise dotted line test 0093 D21F 29 10 ANDIM &10 ;Isolate b4 0094 D221 0A ASLA 0095 D222 0A ASLA 0096 D223 0A ASLA ;now $80 if plot dotted line, $00 if full line 0097 D224 85 DB STA ZTEMP+&01 0098 D226 A2 2C LDXIM LSTART-V ;Window start point LSTART 0099 D228 20 21 D1 JSR WIND 0100 D22B 85 DC STA ZTEMPB 0101 D22D F0 06 BEQ LINED 0102 D22F A9 40 LDAIM &40 ;Start point not inside, so slow plot 0103 D231 05 DB ORA ZTEMP+&01 0104 D233 85 DB STA ZTEMP+&01 0105 D235 A6 DD LINED LDX ZTEMPB+&01 ;Window other point 0106 D237 20 21 D1 JSR WIND 0107 D23A 24 DC BIT ZTEMPB ;Anything to do ? 0108 D23C [ MOS125 = &FF 0111 D23C | 0112 D23C D0 86 BNE LINEX1 ;No, then exit 0113 D23E ] 0114 D23E A6 DE LINEE LDX ZTEMPC ;Isolate 2nd horizontal window 0115 D240 F0 02 BEQ LINEF 0116 D242 4A LSRA 0117 D243 4A LSRA 0118 D244 29 02 LINEF ANDIM &02 0119 D246 F0 07 BEQ LINEG ;Zero, so Hend is in window 0120 D248 8A TXA ;Point X to upper margin! 0121 D249 09 04 ORAIM GWRCOL-V ;Assumes GWLCOL-V is a multiple of 4 0122 D24B AA TAX ;Endpoint outside horizontal window, 0123 D24C 20 37 D4 JSR COPY2H ;so alter Hend to high margin 0124 D24F 20 E3 D3 LINEG JSR LINSG ;Get L values & MOD deltas 0125 D252 A5 DE LDA ZTEMPC 0126 D254 49 02 EORIM &02 0127 D256 AA TAX ;Unsigned D2 0128 D257 A8 TAY 0129 D258 AD 29 03 LDA LDELTA+&01 ;Sign of D2 ? 0130 D25B 4D 2B 03 EOR LDELTA+&03 0131 D25E 10 01 BPL LINEH 0132 D260 E8 INX ;Signed D2 - E,W,N,S 0133 D261 BD AE C4 LINEH LDAAX D2JTBL ;Initialise D2 jump vector 0134 D264 8D 32 03 STA D2JVEC 0135 D267 BD B2 C4 LDAAX D2JTBH 0136 D26A 8D 33 03 STA D2JVEC+&01 0137 D26D A9 7F LDAIM &7F ;dotted line initialisation 0138 D26F 8D 34 03 STA DOTFLG 0139 D272 24 DB BIT ZTEMP+&01 0140 D274 70 29 BVS LINEI ;Slow plot , so set ZTEMPC strangely 0141 D276 BD 47 C4 LDAAX EWTBA ;(4,0,6,2) Calculate V points 0142 D279 AA TAX 0143 D27A 38 SEC Acorn macro assembler Page 32 VDU File - MOS07 0144 D27B BD 00 03 LDAAX GWLCOL 0145 D27E F9 2C 03 SBCAY LSTART 0146 D281 85 DA STA ZTEMP 0147 D283 BD 01 03 LDAAX GWLCOL+&01 0148 D286 F9 2D 03 SBCAY LSTART+&01 0149 D289 A4 DA LDY ZTEMP 0150 D28B AA TAX ;Ensure +ve 0151 D28C 10 03 BPL LINEH1 0152 D28E 20 52 D4 JSR NEGAY 0153 D291 AA LINEH1 TAX ;MSB of no. V points 0154 D292 C8 INY ;Increment this no. 0155 D293 D0 01 BNE LINEH2 0156 D295 E8 INX 0157 D296 8A LINEH2 TXA ;MSB non-zero ? 0158 D297 F0 02 BEQ LINEH3 0159 D299 A0 00 LDYIM &00 ;Yes, then no limit to no. of vertical points 0160 D29B 84 DF LINEH3 STY ZTEMPC+&01 ; Zero is always set here 0161 D29D F0 09 BEQ LINEJ1 0162 D29F 8A LINEI TXA ;b7 = sign of D2. b1=D2 0163 D2A0 4A LSRA 0164 D2A1 6A RORA 0165 D2A2 09 02 ORAIM &02 0166 D2A4 45 DE EOR ZTEMPC 0167 D2A6 85 DE STA ZTEMPC 0168 D2A8 A2 2C LINEJ1 LDXIM LSTART-V ;Address the first point 0169 D2AA 20 F6 D7 JSR GADDR ;Now loads YLINE to Y 0170 D2AD A6 DC LDX ZTEMPB 0171 D2AF D0 02 BNE LINEN 0172 D2B1 C6 DD DEC ZTEMPB+&01 0173 D2B3 CA LINEN DEX 0174 D2B4 ; 0175 D2B4 ; Fall through to main plot routine 0176 D2B4 ; 0177 D2B4 A5 DB LINEJ LDA ZTEMP +&01 ;Was midpoint or DOTS referenced ? 0178 D2B6 F0 1F BEQ DOTYES ;No?, then run along 0179 D2B8 10 10 BPL MPTEST ;No, then do midpoint test 0180 D2BA 2C 34 03 BIT DOTFLG ;b7 set, then dotted 0181 D2BD 10 05 BPL DOTY ;Branch if last was a space 0182 D2BF CE 34 03 DEC DOTFLG ;now to $7F 0183 D2C2 D0 23 BNE DOTNO ;(branch always taken) 0184 D2C4 EE 34 03 DOTY INC DOTFLG ;to $80 0185 D2C7 0A ASLA 0186 D2C8 10 0D BPL DOTYES ;No?, then plot the point 0187 D2CA 86 DC MPTEST STX ZTEMPB ;Store X temporarily 0188 D2CC A2 2C LDXIM LSTART-V ;Window the point at Q +0D (PStart) 0189 D2CE 20 F1 D7 JSR GADDV ;& address if window was successful 0190 D2D1 A6 DC LDX ZTEMPB ;Restore X 0191 D2D3 09 00 ORAIM &00 ;To TSTA (a la 6800) (result of window) 0192 D2D5 D0 10 BNE DOTNO ;Outside?, then skip the plot 0193 D2D7 A5 D1 DOTYES LDA ZMASK ;Plot the point 0194 D2D9 25 D4 AND ZGORA 0195 D2DB 11 D6 ORAIY ZMEMG 0196 D2DD 85 DA STA ZTEMP 0197 D2DF A5 D5 LDA ZGEOR 0198 D2E1 25 D1 AND ZMASK 0199 D2E3 45 DA EOR ZTEMP 0200 D2E5 91 D6 STAIY ZMEMG 0201 D2E7 0202 D2E7 ;L := L - DeltaV 0203 D2E7 0204 D2E7 38 DOTNO SEC 0205 D2E8 AD 35 03 LDA LPARMS ;L,LSB 0206 D2EB ED 37 03 SBC LPARMS+&02 ;DeltaV,LSB 0207 D2EE 8D 35 03 STA LPARMS 0208 D2F1 AD 36 03 LDA LPARMS+&01 ;L,MSB 0209 D2F4 ED 38 03 SBC LPARMS+&03 ;DeltaV,MSB 0210 D2F7 B0 11 BCS LINED1 ;Skip if D2 not to be taken ( L > 0 ) 0211 D2F9 85 DA STA ZTEMP ;D2 must be taken, thus 0212 D2FB AD 35 03 LDA LPARMS ;L := L + DeltaH 0213 D2FE 6D 39 03 ADC LPARMS+&04 ;LSB of DeltaH (c=0) 0214 D301 8D 35 03 STA LPARMS 0215 D304 A5 DA LDA ZTEMP 0216 D306 6D 3A 03 ADC LPARMS+&05 ;MSB of DeltaH 0217 D309 18 CLC ;Do do D2 0218 D30A 8D 36 03 LINED1 STA LPARMS+&01 ;Store MSB of L, preserving c 0219 D30D 08 PHP ;Needed for decrementing no. of V points 0220 D30E B0 09 BCS LINEE1 ;Don't do D2 if you're not meant to 0221 D310 6C 32 03 JMI D2JVEC ;Jump to D2, through JVEC2, to xB (below) 0222 D313 88 NB DEY 0223 D314 10 03 BPL LINEE1 ;~~~~~~~~~~~~~~ D2 KING MOVES ~~~~~~~~~~~~~~ 0224 D316 20 ED CB JSR NBDY 0225 D319 6C 5D 03 LINEE1 JMI JVEC 0226 D31C C8 SB INY 0227 D31D C0 08 CPYIM &08 0228 D31F D0 F8 BNE LINEE1 0229 D321 18 CLC ; encoded version of SBDY 0230 D322 A5 D6 LDA ZMEMG 0231 D324 6D 52 03 ADC BYTROW 0232 D327 85 D6 STA ZMEMG 0233 D329 A5 D7 LDA ZMEMG +&01 0234 D32B 6D 53 03 ADC BYTROW +&01 0235 D32E 10 04 BPL SBDYA 0236 D330 38 SEC 0237 D331 ED 54 03 SBC BYTSCN 0238 D334 85 D7 SBDYA STA ZMEMG +&01 0239 D336 A0 00 LDYIM &00 0240 D338 6C 5D 03 JMI JVEC 0241 D33B 46 D1 EB LSR ZMASK 0242 D33D 90 DA BCC LINEE1 0243 D33F 20 A4 D3 JSR EBDY 0244 D342 6C 5D 03 JMI JVEC 0245 D345 06 D1 WB ASL ZMASK 0246 D347 90 D0 BCC LINEE1 0247 D349 20 B4 D3 JSR WBDY 0248 D34C 6C 5D 03 JMI JVEC 0249 D34F 88 NA DEY 0250 D350 10 0C BPL LINEF1 ;~~~~~~~~~~~~~~ D1 KING MOVES ~~~~~~~~~~~~~~ 0251 D352 20 ED CB JSR NBDY 0252 D355 D0 07 BNE LINEF1 ; NBDY returns Zero false 0253 D357 46 D1 EA LSR ZMASK 0254 D359 90 03 BCC LINEF1 0255 D35B 20 A4 D3 JSR EBDY 0256 D35E 28 LINEF1 PLP ;Did D2 occur ? Result to c (c=0 if it did) 0257 D35F E8 INX ;Inc no. H points left to plot (following preserves c) 0258 D360 D0 04 BNE LINEG1 0259 D362 E6 DD INC ZTEMPB +&01 0260 D364 F0 0A BEQ LINEX ;Zero?, then exit 0261 D366 24 DB LINEG1 BIT ZTEMP +&01 ;Was midpoint referenced? (preserves c) 0262 D368 70 07 BVS FRIGA ;Yes, then go to the nasty bit 0263 D36A B0 35 BCS LINEK ;D2 ?, then test V window. c from last PLP 0264 D36C C6 DF DEC ZTEMPC +&01 ;Off V window ?, then exit Acorn macro assembler Page 33 VDU File - MOS07 0265 D36E D0 31 BNE LINEK 0266 D370 60 LINEX RTS 0267 D371 A5 DE FRIGA LDA ZTEMPC ;Which direction was D2 ? 0268 D373 86 DC STX ZTEMPB 0269 D375 29 02 ANDIM &02 0270 D377 AA TAX 0271 D378 B0 19 BCS FRIGC ;No D2?, then skip the adjustment of V 0272 D37A 24 DE BIT ZTEMPC ;Was D2 +ve ? 0273 D37C 30 0A BMI FRIGB 0274 D37E FE 2C 03 INCAX LSTART ;D2 +ve, so increment V co-ord 0275 D381 D0 10 BNE FRIGC 0276 D383 FE 2D 03 INCAX LSTART+&01 0277 D386 90 0B BCC FRIGC ;(branch always taken) 0278 D388 BD 2C 03 FRIGB LDAAX LSTART ;D2 -ve, so dec. the V co-ord. 0279 D38B D0 03 BNE FRIGF 0280 D38D DE 2D 03 DECAX LSTART+&01 0281 D390 DE 2C 03 FRIGF DECAX LSTART 0282 D393 8A FRIGC TXA ;Get offset of D1 0283 D394 49 02 EORIM &02 0284 D396 AA TAX 0285 D397 FE 2C 03 INCAX LSTART ;D1 +ve,so inc. H co-ord 0286 D39A D0 03 BNE FRIGD 0287 D39C FE 2D 03 INCAX LSTART+&01 0288 D39F A6 DC FRIGD LDX ZTEMPB 0289 D3A1 4C B4 D2 LINEK JMP LINEJ 0290 D3A4 0291 D3A4 ;BOUNDARY ROUTINES 0292 D3A4 0293 D3A4 [ MOS125 = &FF 0309 D3A4 ] 0310 D3A4 0311 D3A4 ;EAST 0312 D3A4 0313 D3A4 AD 62 03 EBDY LDA MASKL 0314 D3A7 85 D1 STA ZMASK 0315 D3A9 A5 D6 LDA ZMEMG 0316 D3AB 69 07 ADCIM &07 ;c=1 from branch not taken to call this 0317 D3AD 85 D6 STA ZMEMG 0318 D3AF 90 02 BCC EBDYA 0319 D3B1 E6 D7 INC ZMEMG +&01 0320 D3B3 60 EBDYA RTS 0321 D3B4 0322 D3B4 ;WEST 0323 D3B4 0324 D3B4 AD 63 03 WBDY LDA MASKR ;encoded version of WBDY 0325 D3B7 85 D1 STA ZMASK 0326 D3B9 A5 D6 LDA ZMEMG 0327 D3BB D0 02 BNE WBDYA 0328 D3BD C6 D7 DEC ZMEMG +&01 0329 D3BF E9 08 WBDYA SBCIM &08 ;c=1 from failure of BCC 0330 D3C1 85 D6 STA ZMEMG 0331 D3C3 60 RTS 0332 D3C4 0333 D3C4 LNK MOS08 0001 D3C4 0002 D3C4 TTL VDU File - MOS08 0003 D3C4 OPT MOS08 Acorn macro assembler Page 34 VDU File - MOS08 0004 D3C4 0005 D3C4 ;Last revision 18/05/82 0006 D3C4 ; 0007 D3C4 ;18/05/82 External graphics cursor now updated on exit of SPLOT 0008 D3C4 ;04/05/82 SPLOT routine entered 0009 D3C4 ;01/05/82 Recoded using new variable order & manifests 0010 D3C4 ;21/04/82 Most of this deleted ! LINSG modified for new LINE routine 0011 D3C4 ;19/04/82 Byte saving in LINSCE 0012 D3C4 0013 D3C4 ;LINSA calculates Delta X & Delta Y 0014 D3C4 ;(New point - cursor), where both are in Ico-ords 0015 D3C4 ;Max. I value always assumed to be $8000, as arithmetic 0016 D3C4 ;is performed in 2's comp., 16 bit 0017 D3C4 ;New point in NEWPT, results to LDELTA 0018 D3C4 0019 D3C4 A0 28 LINSA LDYIM LDELTA-V ;Offset of results from V 0020 D3C6 A2 20 LDXIM NEWPT-V ;Offset of operands, from V 0021 D3C8 0022 D3C8 ;fall through to ....... 0023 D3C8 0024 D3C8 ;TRISA calculates Delta X & Delta Y for operands starting 0025 D3C8 ;at V+(X), and results to V+(Y). Calculation from 0026 D3C8 ;(Point at (V+(X)+4)) - (Point at (V+(X))) 0027 D3C8 0028 D3C8 20 CF D3 TRISA JSR TRISAA 0029 D3CB E8 INX 0030 D3CC E8 INX 0031 D3CD C8 INY 0032 D3CE C8 INY 0033 D3CF 38 TRISAA SEC 0034 D3D0 BD 04 03 LDAAX V+&04 0035 D3D3 FD 00 03 SBCAX V 0036 D3D6 99 00 03 STAAY V 0037 D3D9 BD 05 03 LDAAX V+&05 0038 D3DC FD 01 03 SBCAX V+&01 0039 D3DF 99 01 03 STAAY V+&01 0040 D3E2 60 RTS 0041 D3E3 0042 D3E3 ;LINSG calculates no. H points before H exit 0043 D3E3 ;putting 2's comp. to ZTEMPB,ZTEMPB +01 (LSB 1st). 0044 D3E3 ;Initialises MOD DELTAs & L 0045 D3E3 ;Requires ZTEMPB as usual, destroying original data 0046 D3E3 0047 D3E3 A5 DE LINSG LDA ZTEMPC ;Calc. MOD DELTAs. 0048 D3E5 D0 07 BNE LINSGB ;Plot by Y, so straight copy 0049 D3E7 A2 28 LDXIM LDELTA-V ;Swap DeltaX & DeltaY 0050 D3E9 A0 2A LDYIM LDELTA+&02-V 0051 D3EB 20 CC CD JSR SWAP2 0052 D3EE A2 28 LINSGB LDXIM LDELTA-V ;Copy from modified DX & DY (now DH & DV) 0053 D3F0 A0 37 LDYIM LPARMS+&02-V ;to LPARMS+2=LDELTA 0054 D3F2 20 41 D4 JSR COPYF ;Copy 4 bytes 0055 D3F5 0056 D3F5 ;Initialise No. H points 0057 D3F5 0058 D3F5 38 SEC 0059 D3F6 A6 DE LDX ZTEMPC 0060 D3F8 AD 30 03 LDA HEND ;He, LSB 0061 D3FB FD 2C 03 SBCAX LSTART ;HSt, LSB 0062 D3FE A8 TAY 0063 D3FF AD 31 03 LDA HEND+&01 ;He, MSB 0064 D402 FD 2D 03 SBCAX LSTART+&01 ;HSt, MSB 0065 D405 30 03 BMI LINSGA ;Ensure in 2's comp. 0066 D407 20 52 D4 JSR NEGAY 0067 D40A 85 DD LINSGA STA ZTEMPB +&01 0068 D40C 84 DC STY ZTEMPB 0069 D40E 0070 D40E ;now initialise L & MODULO the DH & DV 0071 D40E 0072 D40E A2 35 LDXIM LPARMS-V ;Point to the deltas 0073 D410 0074 D410 ;& fall through to ... 0075 D410 0076 D410 ;TRISB Set up L & MODULO deltas. 0077 D410 ;Assumes V+(X) points to LL,LH,DVL,DVH,DHL,DHH 0078 D410 ;Sets all Dxy to ABS in situ. Sets L := DH/2 (2 byte arith) 0079 D410 0080 D410 20 1E D4 TRISB JSR TRISBA ;Do DH 0081 D413 4A LSRA 0082 D414 9D 01 03 STAAX V+&01 ;Initialise LH 0083 D417 98 TYA ;Now do LL 0084 D418 6A RORA 0085 D419 9D 00 03 STAAX V 0086 D41C CA DEX ;Now DV 0087 D41D CA DEX 0088 D41E BC 04 03 TRISBA LDYAX V+&04 ;LSB 0089 D421 BD 05 03 LDAAX V+&05 ;MSB 0090 D424 10 0C BPL TRISBB ;Find ABS value 0091 D426 20 52 D4 JSR NEGAY 0092 D429 9D 05 03 STAAX V+&05 ;PAIN - why the hell isn't there a STYAX on this wretched chip ?? 0093 D42C 48 PHA 0094 D42D 98 TYA 0095 D42E 9D 04 03 STAAX V+&04 0096 D431 68 PLA 0097 D432 60 TRISBB RTS 0098 D433 0099 D433 0100 D433 ;COPYF copies 4 bytes from (V)+(X) to (V)+(Y) 0101 D433 0102 D433 A9 08 COPY8 LDAIM &08 0103 D435 D0 0C BNE COPY 0104 D437 0105 D437 A0 30 COPY2H LDYIM HEND-V 0106 D439 A9 02 COPY2 LDAIM &02 0107 D43B D0 06 BNE COPY 0108 D43D 0109 D43D A0 28 COPYFA LDYIM APCS1-V 0110 D43F A2 24 COPYFB LDXIM GCSIR-V 0111 D441 A9 04 COPYF LDAIM &04 ;SPLOTY requires that c preserved 0112 D443 85 DA COPY STA ZTEMP 0113 D445 BD 00 03 COPYA LDAAX V 0114 D448 99 00 03 STAAY V 0115 D44B E8 INX 0116 D44C C8 INY 0117 D44D C6 DA DEC ZTEMP 0118 D44F D0 F4 BNE COPYA 0119 D451 60 RTS 0120 D452 0121 D452 48 NEGAY PHA ;Negate (AY) - push MSB 0122 D453 98 TYA 0123 D454 49 FF EORIM &FF 0124 D456 A8 TAY Acorn macro assembler Page 35 VDU File - MOS08 0125 D457 68 PLA 0126 D458 49 FF EORIM &FF 0127 D45A [ MOS125 = &FF 0133 D45A | 0134 D45A C0 FF CPYIM &FF 0135 D45C C8 INY 0136 D45D 69 00 ADCIM &00 0137 D45F 60 RTS 0138 D460 ] 0139 D460 0140 D460 20 EF D7 SPF JSR GADDW ;Address new point COMMON CODE 0141 D463 D0 08 BNE SPFA ;Off window?, then exit 0142 D465 B1 D6 LDAIY ZMEMG ;Get the current byte 0143 D467 4D 5A 03 EOR BGCOLF ;Set b/g pixels to zero 0144 D46A 85 DA STA ZTEMP 0145 D46C 60 RTS 0146 D46D 68 SPFA PLA 0147 D46E 68 PLA 0148 D46F 0149 D46F ; & fall through to 0150 D46F 0151 D46F EE 26 03 SPLOTY INC GCSIY ;Failed, so make the L.H. cursor > R.H. 0152 D472 4C FB D4 JMP SPLOTX 0153 D475 0154 D475 ;SPLOT plots from the new point left & right 0155 D475 ; until it finds a pixel which is NOT background colour 0156 D475 ; It scans a byte at a time if possible, taking a lot 0157 D475 ; of code. 0158 D475 0159 D475 0160 D475 20 60 D4 SPLOT JSR SPF 0161 D478 25 D1 AND ZMASK ;Is the new point in b/g? 0162 D47A D0 F3 BNE SPLOTY ;No?, then exit 0163 D47C A2 00 LDXIM &00 ;Set up for plotting to the left 0164 D47E 20 44 D5 JSR SPS ;Corrupts all registers 0165 D481 F0 2D BEQ SPLOTE ;Nothing to do 0166 D483 AC 1A 03 LDY YLINE 0167 D486 06 D1 ASL ZMASK ;Don't want to plot the midpoint again 0168 D488 B0 05 BCS SPLOTB ;So move left 0169 D48A 20 2E D5 JSR SPB ;Plot the LH fractional byte 0170 D48D 90 21 BCC SPLOTE ;No complete bytes to attempt? 0171 D48F 0172 D48F 20 B4 D3 SPLOTB JSR WBDY ;Do complete bytes left 0173 D492 B1 D6 LDAIY ZMEMG ;(NB WBDY assumes c=1) 0174 D494 4D 5A 03 EOR BGCOLF 0175 D497 85 DA STA ZTEMP 0176 D499 D0 12 BNE SPLOTD ;Not a complete byte of b/g? 0177 D49B 38 SEC ;Go for next byte - add to pixel counter 0178 D49C 8A TXA 0179 D49D 6D 61 03 ADC NPIX 0180 D4A0 90 04 BCC SPLOTC 0181 D4A2 E6 DB INC ZTEMP+&01 ;MSB of pixel counter 0182 D4A4 10 07 BPL SPLOTD ;Reached margin? Then skip 0183 D4A6 AA SPLOTC TAX ;Not reached margin - then 0184 D4A7 20 16 D1 JSR PLOTFF 0185 D4AA 38 SEC ;carry on 0186 D4AB B0 E2 BCS SPLOTB ;(branch always taken). Sorry about the last comment 0187 D4AD 0188 D4AD 20 2E D5 SPLOTD JSR SPB ;Do whatever is right of the line 0189 D4B0 A0 00 SPLOTE LDYIM &00 ;Translate back to Ico-ords 0190 D4B2 20 5E D5 JSR SPU 0191 D4B5 0192 D4B5 A0 20 LDYIM NEWPT-V ;Entry point for look for b/g colour 0193 D4B7 A2 24 LDXIM GCSIR-V ;Swap newpoint (in GCSIR) & calculated RH endpoint 0194 D4B9 20 D4 CD JSR SWAPF 0195 D4BC 0196 D4BC 20 60 D4 SCHEAT JSR SPF ;Address midpoint again held in NEWPT 0197 D4BF A2 04 LDXIM &04 ;Set up for plotting right 0198 D4C1 20 44 D5 JSR SPS ;Musn't corrupt ZTEMP 0199 D4C4 8A TXA ;Plot the midpoint 0200 D4C5 D0 02 BNE SPLOTA 0201 D4C7 C6 DB DEC ZTEMP+&01 0202 D4C9 CA SPLOTA DEX 0203 D4CA 0204 D4CA 20 01 D5 SPLOTL JSR SPA ;Do this RH fractional byte 0205 D4CD 90 27 BCC SPLOTK ;No full bytes to attempt? 0206 D4CF 0207 D4CF 20 A4 D3 SPLOTI JSR EBDY ;Full bytes right 0208 D4D2 B1 D6 LDAIY ZMEMG 0209 D4D4 4D 5A 03 EOR BGCOLF 0210 D4D7 85 DA STA ZTEMP 0211 D4D9 0212 D4D9 A5 DC LDA ZTEMPB 0213 D4DB D0 ED BNE SPLOTL 0214 D4DD 0215 D4DD A5 DA LDA ZTEMP 0216 D4DF D0 12 BNE SPLOTJ ;This isn't a full byte 0217 D4E1 38 SEC ;Add (NPIX)+1=no.pixels to counter 0218 D4E2 8A TXA 0219 D4E3 6D 61 03 ADC NPIX 0220 D4E6 90 04 BCC SPLOTF 0221 D4E8 E6 DB INC ZTEMP+&01 0222 D4EA 10 07 BPL SPLOTJ ;Skip if hit margin 0223 D4EC AA SPLOTF TAX 0224 D4ED 20 16 D1 JSR PLOTFF 0225 D4F0 38 SEC 0226 D4F1 B0 DC BCS SPLOTI ;(branch always taken) 0227 D4F3 0228 D4F3 20 01 D5 SPLOTJ JSR SPA 0229 D4F6 A0 04 SPLOTK LDYIM &04 ;Convert to address of LH endpoint 0230 D4F8 20 5E D5 JSR SPU 0231 D4FB 20 EB D0 SPLOTX JSR EMAEX ;Finished 0232 D4FE 4C 7D CA JMP IEG ;update external cursor 0233 D501 0234 D501 ;SPA Plots fractional LH byte on RH line end 0235 D501 0236 D501 A5 D1 SPA LDA ZMASK ;Push the initial combined mask 0237 D503 [ MOS125 = &FF 0239 D503 ] 0240 D503 18 CLC 0241 D504 90 0E BCC SPAF ;(branch always taken) 0242 D506 0243 D506 68 SPAA PLA ;Try next pixel - pull combined mask 0244 D507 E8 INX ;Increment the pixel counter 0245 D508 D0 04 BNE SPAB 0246 D50A E6 DB INC ZTEMP+&01 0247 D50C 10 16 BPL SPAE ;Exit if all pixels plotted 0248 D50E 46 D1 SPAB LSR ZMASK ;Shift mask 0249 D510 B0 12 BCS SPAE ;Exit if shifted out of character cell 0250 D512 05 D1 ORA ZMASK ;Continue forming combined mask 0251 D514 [ MOS125 = &FF Acorn macro assembler Page 36 VDU File - MOS08 0254 D514 | 0255 D514 48 SPAF PHA ;& push it again 0256 D515 A5 D1 LDA ZMASK ;START HERE 0257 D517 ] 0258 D517 24 DA BIT ZTEMP ;Is this pixel b/g colour ? 0259 D519 0260 D519 08 PHP ;Invert z flag if needs be 0261 D51A 68 PLA 0262 D51B 45 DC EOR ZTEMPB ;By inverting it with ZTEMPB (0 or 2) 0263 D51D [ MOS125 = &FF 0268 D51D | 0269 D51D 29 02 ANDIM &02 ;No shorter but saves 5 cycles and ZTEMPB can't corrupt PSR 0270 D51F 0271 D51F D0 E5 BNE SPAA ;Z now inverted, NE means NOT background, so loop 0272 D521 ] 0273 D521 68 PLA ;Found it?, then pull combined mask 0274 D522 45 D1 EOR ZMASK ;& delete this pixel from it 0275 D524 85 D1 SPAE STA ZMASK ;These must preserve c! 0276 D526 4C 02 D1 JMP PLOT 0277 D529 0278 D529 [ MOS125 = &FF 0301 D529 | 0302 D529 SPBD 0303 D529 45 D1 EOR ZMASK 0304 D52B 4A LSRA 0305 D52C 90 F6 BCC SPAE ;(branch always taken) 0306 D52E 0307 D52E ;SPB Plots fractional RH byte on LH line end 0308 D52E 0309 D52E A9 00 SPB LDAIM &00 0310 D530 0A SPBE ASLA ;CC preserved via SPAE->PLOT and seen by caller 0311 D531 05 D1 ORA ZMASK 0312 D533 24 DA BIT ZTEMP 0313 D535 D0 F2 BNE SPBD 0314 D537 E8 INX 0315 D538 D0 04 BNE SPBB 0316 D53A E6 DB INC ZTEMP+&01 0317 D53C 10 E6 BPL SPAE 0318 D53E C9 80 SPBB CMPIM &80 0319 D540 90 EE BCC SPBE 0320 D542 B0 E0 BCS SPAE ;(branch always taken) 0321 D544 ] 0322 D544 0323 D544 ;SPS Set up pixel counter 0324 D544 0325 D544 BD 00 03 SPS LDAAX GWLCOL 0326 D547 38 SEC 0327 D548 ED 20 03 SBC NEWPT 0328 D54B A8 TAY 0329 D54C BD 01 03 LDAAX GWLCOL+&01 0330 D54F ED 21 03 SBC NEWPT+&01 0331 D552 30 03 BMI SPSA ;Ensure this is -ve 0332 D554 20 52 D4 JSR NEGAY 0333 D557 85 DB SPSA STA ZTEMP+&01 ;Store MSB 0334 D559 98 TYA 0335 D55A AA TAX ;LSB to X 0336 D55B 05 DB ORA ZTEMP+&01 ;Set z=1 if nothing to do 0337 D55D 60 RTS 0338 D55E 0339 D55E ;SPU Work out the internal co-ordinates of where we are 0340 D55E 0341 D55E 84 DA SPU STY ZTEMP 0342 D560 8A TXA 0343 D561 A8 TAY 0344 D562 A5 DB LDA ZTEMP+&01 0345 D564 30 02 BMI SPUA ;This byte is $00 at most 0346 D566 A9 00 LDAIM &00 ;although it can get a $01 in it 0347 D568 A6 DA SPUA LDX ZTEMP 0348 D56A D0 03 BNE SPUB 0349 D56C 20 52 D4 JSR NEGAY 0350 D56F 48 SPUB PHA 0351 D570 18 CLC 0352 D571 98 TYA 0353 D572 7D 00 03 ADCAX GWLCOL 0354 D575 8D 20 03 STA NEWPT 0355 D578 68 PLA 0356 D579 7D 01 03 ADCAX GWLCOL+&01 0357 D57C 8D 21 03 STA NEWPT+&01 0358 D57F 60 RTS 0359 D580 0360 D580 CSREAD 0361 D580 A9 03 LDAIM &03 ;Convert internal co-ordiantes at OLDCS & GCSIR 0362 D582 20 87 D5 JSR SPCA 0363 D585 A9 07 LDAIM &07 0364 D587 48 SPCA PHA 0365 D588 20 D0 CD JSR SWAPB ;Swap old cursor with cursor 0366 D58B 20 7D CA JSR IEG ;Convert to external co-ordiantes 0367 D58E A2 03 LDXIM &03 ;& copy it 0368 D590 68 PLA 0369 D591 A8 TAY 0370 D592 BD 10 03 SPCB LDAAX GCSR 0371 D595 91 F0 STAIY WARGS 0372 D597 88 DEY 0373 D598 CA DEX 0374 D599 10 F7 BPL SPCB 0375 D59B 60 RTS 0376 D59C 0377 D59C LNK MOS10 0001 D59C 0002 D59C TTL VDU File - MOS10 0003 D59C OPT MOS10 Acorn macro assembler Page 37 VDU File - MOS10 0004 D59C 0005 D59C ;Last revision 10/05/82 0006 D59C 0007 D59C ;10/05/82 Save 1 byte by BCS HPLOT -> BCC TRSRTS 0008 D59C ;05/05/82 HPLOT uses PLOTFF 0009 D59C ;01/05/82 Recoded using manifests & new ordering of static variables 0010 D59C ;07/02/82 Zero height triangles not so disasterous (GPT) 0011 D59C 0012 D59C ;TRIANGLE PLOTTING 0013 D59C 0014 D59C ;INITIALISATION 0015 D59C 0016 D59C A2 20 EMC LDXIM NEWPT-V ;Copy new point & graphics cursor to a safe place 0017 D59E A0 3E LDYIM GCSTMP-V 0018 D5A0 20 33 D4 JSR COPY8 0019 D5A3 20 ED CD JSR SORTA ;Sort into Y co-ords, in order NEWPT=Lo, GCSIR=Hi, OLDCS=Med 0020 D5A6 A2 14 LDXIM OLDCS-V 0021 D5A8 A0 24 LDYIM GCSIR-V 0022 D5AA 20 F1 CD JSR SORTY 0023 D5AD 20 ED CD JSR SORTA 0024 D5B0 A2 20 LDXIM NEWPT-V ;Set paramters for hypotenuse ... 0025 D5B2 A0 2A LDYIM HDELTA-V ;Find Deltas 0026 D5B4 20 C8 D3 JSR TRISA 0027 D5B7 AD 2B 03 LDA HDELTA+&01 ;Copy sign of DeltaX to determine direction 0028 D5BA 8D 32 03 STA HDIREC 0029 D5BD A2 28 LDXIM HPARMS 0030 D5BF 20 10 D4 JSR TRISB ;complete definition of hypotenuse parameters 0031 D5C2 A0 2E LDYIM HSTART-V ;Copy NEWPT to PStart of hypotenuse 0032 D5C4 20 F0 D0 JSR EMAEZ 0033 D5C7 ;Swap Y co-ords 2 & 3, to give 1st side 0034 D5C7 20 D0 CD JSR SWAPB ;Y co-ords now in order Lo, Med, Hi 0035 D5CA 18 CLC ;Don't plot the last line 0036 D5CB 20 F5 D5 JSR TRSF ;Do the lower half of the triangle 0037 D5CE ;Swap points to enable set up of 2nd side 0038 D5CE 20 D0 CD JSR SWAPB ;Y co-ords now Lo, Hi, Med 0039 D5D1 A2 20 LDXIM NEWPT-V ;swap Y co-ords 1 & 3 to give 2nd side 0040 D5D3 20 D2 CD JSR SWAPC ;& now Med, Hi, Lo 0041 D5D6 38 SEC ;Do plot the last line 0042 D5D7 20 F5 D5 JSR TRSF ;& plot the top half 0043 D5DA A2 3E LDXIM GCSTMP-V ;Restore original graphics cursor & new point 0044 D5DC A0 20 LDYIM NEWPT-V 0045 D5DE 20 33 D4 JSR COPY8 0046 D5E1 4C EB D0 JMP EMAEX ;& do things to the cursors 0047 D5E4 0048 D5E4 [ MOS125 = &FF 0059 D5E4 ] 0060 D5E4 0061 D5E4 CSRPOS 0062 D5E4 AD 18 03 LDA CSX ;~~~ Read text cursor position ~~~ 0063 D5E7 38 SEC 0064 D5E8 ED 08 03 SBC TWLCOL 0065 D5EB AA TAX 0066 D5EC AD 19 03 LDA CSY 0067 D5EF 38 SEC 0068 D5F0 ED 0B 03 SBC TWTROW 0069 D5F3 A8 TAY 0070 D5F4 60 TRSRTS RTS ;No, then return 0071 D5F5 0072 D5F5 ;TRSF Initialises a parameter list for ULN 0073 D5F5 ;Sets up the "sides" (as opposed to the hypoteneuse) only. Skips if 0074 D5F5 ;the 2 Y values are equal, otherwise calls HPLOT & ULN the requisite 0075 D5F5 ;number of times 0076 D5F5 ;Assumes the points forming the side to be initialised are in 0077 D5F5 ;NEWPT & GCSIR 0078 D5F5 0079 D5F5 08 TRSF PHP ;Push carry - is set if last line is to be plotted 0080 D5F6 A2 20 LDXIM NEWPT-V ;Set up triangle parameters 0081 D5F8 A0 35 LDYIM SDELTA-V ;Find deltas (sides only) 0082 D5FA 20 C8 D3 JSR TRISA 0083 D5FD AD 36 03 LDA SDELTA+&01 ;Find direction by sign of DeltaX 0084 D600 8D 3D 03 STA SDIREC 0085 D603 A2 33 LDXIM SPARMS-V ;Find MOD Deltas, and initialise L 0086 D605 20 10 D4 JSR TRISB 0087 D608 A0 39 LDYIM SSTART-V ;Copy NEWPT to SSTART 0088 D60A 20 F0 D0 JSR EMAEZ 0089 D60D 38 SEC ;How many Y values are there to be done ? 0090 D60E AD 22 03 LDA NEWPT+&02 0091 D611 ED 26 03 SBC GCSIY 0092 D614 8D 1B 03 STA TRINLN ;Result (2's comp.) to TRINLN 0093 D617 AD 23 03 LDA NEWPT+&03 0094 D61A ED 27 03 SBC GCSIY+&01 0095 D61D 8D 1C 03 STA TRINLN+&01 ;(MSB) 0096 D620 0D 1B 03 ORA TRINLN ;Anything to do? 0097 D623 F0 17 BEQ TRSFA 0098 D625 20 3F D6 TRSFB JSR HPLOT ;Plot the line 0099 D628 A2 33 LDXIM SPARMS-V ;Move the side up 0100 D62A 20 0F D7 JSR ULN 0101 D62D A2 28 LDXIM HPARMS-V ;Move the hypoteneuse up 0102 D62F 20 0F D7 JSR ULN 0103 D632 EE 1B 03 INC TRINLN ;Any more lines ? 0104 D635 D0 EE BNE TRSFB ;Yes, then loop, otherwise 0105 D637 EE 1C 03 INC TRINLN+&01 0106 D63A D0 E9 BNE TRSFB 0107 D63C 0108 D63C 28 TRSFA PLP ;Plot the last line? 0109 D63D 90 B5 BCC TRSRTS ;No, if c=0 0110 D63F 0111 D63F ;HPLOT Fast plot of horizontal line 0112 D63F ;Plots horizontal line in current colour from points defined 0113 D63F ;at SSTART & HSTART, or, if entered at HPLOTA, from 0114 D63F ;GWTROW+(X) to GWTROW+(Y). 0115 D63F ;Y co-ordinate taken from point at (X) 0116 D63F 0117 D63F A2 39 HPLOT LDXIM SSTART-V ;Initialise point pointers 0118 D641 A0 2E LDYIM HSTART-V 0119 D643 86 DE HPLOTA STX ZTEMPC ;Store these point pointers 0120 D645 BD 00 03 LDAAX V ;Is x co-ord. of (X)<(Y) ? 0121 D648 D9 00 03 CMPAY V 0122 D64B BD 01 03 LDAAX V+&01 0123 D64E F9 01 03 SBCAY V+&01 0124 D651 30 06 BMI HPLOTB ;No, then swap (X) < = > (Y) 0125 D653 98 TYA 0126 D654 A4 DE LDY ZTEMPC 0127 D656 AA TAX 0128 D657 86 DE STX ZTEMPC 0129 D659 84 DF HPLOTB STY ZTEMPC +&01 0130 D65B 0131 D65B ;ZTEMPC & X now contain the offset from V to the L.H. point 0132 D65B ;& ZTEMPC +01 & Y the offset from V to the R.H. point 0133 D65B 0134 D65B B9 00 03 LDAAY V ;Push R.H. x co-ordinate Acorn macro assembler Page 38 VDU File - MOS10 0135 D65E 48 PHA 0136 D65F B9 01 03 LDAAY V+&01 0137 D662 48 PHA 0138 D663 A6 DF LDX ZTEMPC +&01 ;Window the R.H. point 0139 D665 20 21 D1 JSR WIND 0140 D668 F0 0D BEQ HPLOTC ;Within window?, then plot to this point 0141 D66A C9 02 CMPIM &02 ;Only other allowed value of this window is 2 0142 D66C D0 3D BNE HPLOTX ;Exit if this isn't =2 0143 D66E A2 04 LDXIM GWRCOL-V ;It was 2?, then copy R.H. margin to x co-ord of RH point 0144 D670 A4 DF LDY ZTEMPC+&01 0145 D672 20 39 D4 JSR COPY2 0146 D675 A6 DF LDX ZTEMPC+&01 0147 D677 20 F6 D7 HPLOTC JSR GADDR ;Address (modified) RH end point 0148 D67A A6 DE LDX ZTEMPC ;Window L.H. end point 0149 D67C 20 21 D1 JSR WIND 0150 D67F 4A LSRA ;Only allowed values of this window are 0 & 1 0151 D680 D0 29 BNE HPLOTX ;Neither of those?, then exit 0152 D682 90 02 BCC HPLOTD ;Window was zero, then don't modify L.H. end point 0153 D684 A2 00 LDXIM GWLCOL-V ;L.H. endpoint was to the left of L. margin, so plot to latter 0154 D686 A4 DF HPLOTD LDY ZTEMPC +&01 ;Point to R.H. end point 0155 D688 38 SEC ;to determine no. of points needed 0156 D689 B9 00 03 LDAAY V ;Generate no. of points to be plotted 0157 D68C FD 00 03 SBCAX V 0158 D68F 85 DC STA ZTEMPB 0159 D691 B9 01 03 LDAAY V+&01 0160 D694 FD 01 03 SBCAX V+&01 0161 D697 85 DD STA ZTEMPB +&01 0162 D699 A9 00 LDAIM &00 ;Generate the mask for the R.H. fractional byte 0163 D69B 0A HPLOTG ASLA 0164 D69C 05 D1 ORA ZMASK ;Generate R.H fractional mask 0165 D69E A4 DC LDY ZTEMPB 0166 D6A0 D0 14 BNE HPLOTE 0167 D6A2 C6 DD DEC ZTEMPB +&01 ;No more points to be plotted ? 0168 D6A4 10 10 BPL HPLOTE 0169 D6A6 85 D1 STA ZMASK ;No?, then plot this byte only 0170 D6A8 20 02 D1 JSR PLOT 0171 D6AB A6 DF HPLOTX LDX ZTEMPC+&01 ;Restore R.H. end point's x co-ordinate 0172 D6AD 68 PLA 0173 D6AE 9D 01 03 STAAX V+&01 0174 D6B1 68 PLA 0175 D6B2 9D 00 03 STAAX V 0176 D6B5 60 RTS 0177 D6B6 C6 DC HPLOTE DEC ZTEMPB 0178 D6B8 AA TAX ;Continue with generation of R.H. fractional byte mask 0179 D6B9 10 E0 BPL HPLOTG ;until b7 of this mask is set, whence is the mask complete 0180 D6BB 85 D1 STA ZMASK 0181 D6BD 20 02 D1 JSR PLOT ;Plot R.H. fractional byte 0182 D6C0 A6 DC LDX ZTEMPB ;LSB of no. points to be plotted, excl RH fractional byte 0183 D6C2 E8 INX ;Increment this, for no. points is inclusive 0184 D6C3 D0 02 BNE HPLOTL 0185 D6C5 E6 DD INC ZTEMPB +&01 0186 D6C7 8A HPLOTL TXA 0187 D6C8 48 PHA ;Needed for the determination of the LH fractional byte 0188 D6C9 46 DD LSR ZTEMPB +&01 ;Divide no. points by no.pixels to give no. bytes 0189 D6CB 6A RORA 0190 D6CC AC 61 03 LDY NPIX 0191 D6CF C0 03 CPYIM &03 0192 D6D1 F0 05 BEQ HPLOTP 0193 D6D3 90 04 BCC HPLOTQ 0194 D6D5 46 DD LSR ZTEMPB +&01 ;y>3, i.e 8 pixels per byte 0195 D6D7 6A RORA 0196 D6D8 [ MOS125 = &FF 0198 D6D8 | 0199 D6D8 HPLOTP ;y=3, i.e. 4 pixels per byte 0200 D6D8 ;ZTEMPB +&01 dead; C dead as A must not exceed &4F 0201 D6D8 ] 0202 D6D8 4A LSRA 0203 D6D9 AC 1A 03 HPLOTQ LDY YLINE ;Prepare ye the way of the loop 0204 D6DC AA TAX ;Contains the nuber of complete bytes to be filled in 0205 D6DD F0 0F BEQ HPLOTF ;None?, then skip to plotting of L.H. fractional byte 0206 D6DF 0207 D6DF 98 HPLOTI TYA ;MAIN FULL BYTE LOOP 0208 D6E0 38 SEC ;Move Y back 8 bytes 0209 D6E1 E9 08 SBCIM &08 0210 D6E3 A8 TAY 0211 D6E4 B0 02 BCS HPLOTH ;Carry generated? 0212 D6E6 C6 D7 DEC ZMEMG +&01 ;Yes?, then decrement MSB of IY vector 0213 D6E8 20 16 D1 HPLOTH JSR PLOTFF ;Plot the bugger ! 0214 D6EB CA DEX ;Any more ? 0215 D6EC D0 F1 BNE HPLOTI ;Yes, then loop again 0216 D6EE 0217 D6EE 68 HPLOTF PLA ;Pull the LSB of the number of points to plotted 0218 D6EF 2D 61 03 AND NPIX ;No. of points in L.H. fractional byte 0219 D6F2 F0 B7 BEQ HPLOTX ;Leave if nothing to do 0220 D6F4 AA TAX ;Generate the mask for the LH fractional byte 0221 D6F5 A9 00 LDAIM &00 0222 D6F7 0A HPLOTJ ASLA 0223 D6F8 0D 63 03 ORA MASKR 0224 D6FB CA DEX 0225 D6FC D0 F9 BNE HPLOTJ 0226 D6FE 85 D1 STA ZMASK 0227 D700 98 TYA 0228 D701 38 SEC ;Move Y back 8 bytes again 0229 D702 E9 08 SBCIM &08 0230 D704 A8 TAY 0231 D705 B0 02 BCS HPLOTK ;Carry generated 0232 D707 C6 D7 DEC ZMEMG +&01 ;Yes?, then decrement MSB of IY vector 0233 D709 20 05 D1 HPLOTK JSR PLOTS ;Plot the L.H. fractional byte 0234 D70C 4C AB D6 JMP HPLOTX 0235 D70F 0236 D70F ;ULN Increments the current graphics line which is drawing the triangle 0237 D70F ;It varies the X points according to the values of the MOD deltas, and 0238 D70F ;the direction byte. 0239 D70F ;As input, it requires in X the offset of the parameter list from V. 0240 D70F ;The parameter list is assumed to be in the following order : 0241 D70F ;Bytes 0-1 "L", the variable used in determining the steps left/right 0242 D70F ;Bytes 2-3 MOD Delta X 0243 D70F ;Bytes 4-5 MOD Delta Y 0244 D70F ;Bytes 6-9 Point from which the line is to be drawn (XL,XH,YL,YH) 0245 D70F ;Byte A Direction - +ve if x increasing as Y does, else -ve 0246 D70F 0247 D70F FE 08 03 ULN INCAX V+&08 ;Increment Y value of point to be drawn from/to 0248 D712 D0 03 BNE ULNA 0249 D714 FE 09 03 INCAX V+&09 0250 D717 38 ULNA SEC ;L := L - MOD(DeltaX) 0251 D718 BD 00 03 LDAAX V 0252 D71B FD 02 03 SBCAX V+&02 0253 D71E 9D 00 03 STAAX V 0254 D721 BD 01 03 LDAAX V+&01 0255 D724 FD 03 03 SBCAX V+&03 0256 D727 9D 01 03 STAAX V+&01 Acorn macro assembler Page 39 VDU File - MOS10 0257 D72A 10 2F BPL ULNB ;+ve?, then skip the move X part following 0258 D72C [ MOS125 = &FF 0270 D72C | 0271 D72C 18 ULNF CLC 0272 D72D BD 0A 03 LDAAX V+&0A ;Move X, which direction ? 0273 D730 30 0A BMI ULNC ;Skip if move left 0274 D732 FE 06 03 INCAX V+&06 ;Move right, therefore increment the X value 0275 D735 D0 10 BNE ULND 0276 D737 FE 07 03 INCAX V+&07 0277 D73A 90 0B BCC ULND ;always branch 0278 D73C BD 06 03 ULNC LDAAX V+&06 ;Move left, therefore decrement X value 0279 D73F D0 03 BNE ULNE 0280 D741 DE 07 03 DECAX V+&07 0281 D744 DE 06 03 ULNE DECAX V+&06 0282 D747 ULND ;L := L + MOD DeltaY 0283 D747 ] 0284 D747 BD 00 03 LDAAX V 0285 D74A 7D 04 03 ADCAX V+&04 0286 D74D 9D 00 03 STAAX V 0287 D750 BD 01 03 LDAAX V+&01 0288 D753 7D 05 03 ADCAX V+&05 0289 D756 9D 01 03 STAAX V+&01 0290 D759 30 D1 BMI ULNF ;Move left/right again ? TRAP HORIZONTAL LINES BEFORE !! 0291 D75B 60 ULNB RTS 0292 D75C LNK MOS11 0001 D75C 0002 D75C TTL VDU File - MOS11 0003 D75C OPT MOS11 Acorn macro assembler Page 40 VDU File - MOS11 0004 D75C 0005 D75C ;Last revision 05/05/82 0006 D75C 0007 D75C ;05/05/82 Move GADDR here. Change to tabke with 1 entry only 0008 D75C ;01/05/82 Recoded to account for new ordering of variables 0009 D75C ;24/04/82 READCH returns mode in Y, char. in X (AGAIN!) 0010 D75C ;19/04/82 Improved exit at RPXLC 0011 D75C ;16/04/82 improved READCH code 0012 D75C ;25/03/82 Change order of READCH character search 0013 D75C ;22/01/82 Change EIG to EIGABS for READPX 0014 D75C ;07/01/82 Rewrite READCH for non-TTX (GPT) 0015 D75C ;16/11/81 Fix to READCH change (15/11) 0016 D75C ;15/11/81 READCH returns mode in Y, char. in X 0017 D75C ;09/11/81 (Paul) Read start of VDU space coping with model A 0018 D75C 0019 D75C ;READCH Reads the character at the current cursor location, 0020 D75C ;returning the result in A. 0021 D75C ;If the character is not found, 0 is returned. 0022 D75C ;Assumes new font splitting, using FNTFLG & PGSFNT 0023 D75C 0024 D75C READCH 0025 D75C AC 60 03 LDY NCOLOR ;Is it TTX? 0026 D75F D0 0D BNE READCE 0027 D761 B1 D8 LDAIY ZMEMT ;Yes, then read character direct (Y=0) 0028 D763 [ MOS125 = &FF 0036 D763 | 0037 D763 ;CS from OSB or RDCHK->RDCHGY->COPYCH 0038 D763 ;(or RDCHGS->GKEY..RDCHGY->COPYCH after hacking) 0039 D763 ;SEC ;transform only 0040 D763 20 F0 CF JSR TTXFRM ;convert ASCII to Teletext 0041 D766 20 F0 CF JSR TTXFRM ;and again to convert Teletext to ASCII 0042 D769 ] 0043 D769 AC 55 03 READKE LDY MODE ;Only way of getting the mode 0044 D76C AA TAX 0045 D76D 60 RTS 0046 D76E 0047 D76E 0048 D76E [ MOS125 = &FF 0074 D76E | 0075 D76E 20 99 D7 READCE JSR PTCNV ;Get the bit pattern to READWS 0076 D771 A2 20 LDXIM &20 ;First character to be checked 0077 D773 8A READKF TXA ;Address charcter 0078 D774 F0 F3 BEQ READKE ;Finished search? 0079 D776 48 PHA 0080 D777 20 50 D0 JSR CHADDR ;Result to ZTEMPC 0081 D77A 68 PLA 0082 D77B AA TAX 0083 D77C A0 07 READKA LDYIM &07 ;Compare this character 0084 D77E B9 28 03 READKB LDAAY READWS ;Get bit pattern 0085 D781 D1 DE CMPIY ZTEMPC ;Compare with font 0086 D783 D0 08 BNE READKC ;Different?, then not this character 0087 D785 88 DEY ;Same?, then look at next row down 0088 D786 10 F6 BPL READKB 0089 D788 8A TXA 0090 D789 E0 7F CPXIM &7F ;Is it a DEL? 0091 D78B D0 DC BNE READKE ;No?, then you have found it 0092 D78D E8 READKC INX ;Next character up 0093 D78E A5 DE LDA ZTEMPC ;LSB of font pointer up by 8 0094 D790 18 CLC 0095 D791 69 08 ADCIM &08 0096 D793 85 DE STA ZTEMPC 0097 D795 D0 E5 BNE READKA ;More on this page? 0098 D797 F0 DA BEQ READKF ;(branch always taken) 0099 D799 ] 0100 D799 0101 D799 ;Converts the 8,16 or 32 byte character on the screen to an 8 byte 0102 D799 ;bit pattern in Q .. Q+07. Not very fast, in particular, the 8 byte 0103 D799 ;version could be speeded up. Background text colour is recognized 0104 D799 ;as 'background', even if cursors are joined. Anything else is 0105 D799 ;recognised as 'foreground' 0106 D799 0107 D799 ;ZTEMP is the row number (7..0) 0108 D799 ;ZTEMP +01 is he bit pattern being formed from this row 0109 D799 ;ZTEMPB is the mask being used to isolate the current pixel 0110 D799 0111 D799 A0 07 PTCNV LDYIM &07 ;The row to be converted 0112 D79B 84 DA PTCNVA STY ZTEMP ;Start of 'convert 1 row' loop 0113 D79D A9 01 LDAIM &01 ;The bit pattern to be formed 0114 D79F 85 DB STA ZTEMP +&01 ;Finshed when a carry shifted out 0115 D7A1 [ MOS125 = &FF 0128 D7A1 | 0129 D7A1 ;Adds 4 bytes but OS 1.25 gets them anyway 0130 D7A1 ;to avoid diverging from 1.26 before GADDR 0131 D7A1 CD 63 03 CMP MASKR ;C=0 if >1bpp 0132 D7A4 AD 62 03 PTCNVB LDA MASKL ;Isolates the pixel to be tested in the current byte 0133 D7A7 85 DC STA ZTEMPB ;Must move to next byte when carry shifted out left 0134 D7A9 B1 D8 LDAIY ZMEMT ;Get the byte to be tested 0135 D7AB 4D 58 03 EOR BTCOLF ;Isolate back from foreground 0136 D7AE B0 17 BCS PTCNVF ;Write byte directly if 1bpp 0137 D7B0 24 DC PTCNVC BIT ZTEMPB ;Are any of the bits in this pixel set ? 0138 D7B2 F0 01 BEQ PTCNVD ;No?, then this pixel was background 0139 D7B4 38 SEC ;Yes?, then it was foreground 0140 D7B5 26 DB PTCNVD ROL ZTEMP +&01 ;Shift this bit into the bit pattern 0141 D7B7 66 DC ROR ZTEMPB ;Isolate the next pixel 0142 D7B9 90 F5 BCC PTCNVC ;carry clear, then continue 0143 D7BB 30 06 BMI PTCNVE ;pattern overflow?, then this pattern is complete 0144 D7BD ] 0145 D7BD 98 TYA ;c=1, then examine the next byte in the row 0146 D7BE 69 07 ADCIM &07 ;(c=1), by adding 8 to Y 0147 D7C0 A8 TAY 0148 D7C1 90 E1 BCC PTCNVB ;and continue (branch always taken) 0149 D7C3 A4 DA PTCNVE LDY ZTEMP ;Restore Y 0150 D7C5 A5 DB LDA ZTEMP +&01 ;bit pattern finished, store it in the READWS 0151 D7C7 [ MOS125 = &FF 0152 D7C7 | 0153 D7C7 PTCNVF 0154 D7C7 ] 0155 D7C7 99 28 03 STAAY READWS 0156 D7CA 88 DEY ;& do the next row up 0157 D7CB 10 CE BPL PTCNVA 0158 D7CD 60 RTS ;or return 0159 D7CE 0160 D7CE ;RPXL Reads the pixel at V+(A), 0161 D7CE ;returning $FF if the cursor is out of the window, else the logical 0162 D7CE ;colour at the cursor. 0163 D7CE ;Assumes the current cursor in internal representation is GCSIY... 0164 D7CE 0165 D7CE 48 RPXLD PHA 0166 D7CF AA TAX ;Convert to Ico-ords 0167 D7D0 20 5B D1 JSR EIGABS 0168 D7D3 68 PLA Acorn macro assembler Page 41 VDU File - MOS11 0169 D7D4 AA TAX 0170 D7D5 20 F1 D7 JSR GADDV 0171 D7D8 D0 12 BNE RPXLC ;Out of window?, then return $FF. 0172 D7DA B1 D6 LDAIY ZMEMG 0173 D7DC [ MOS125 = &FF 0183 D7DC | 0184 D7DC 85 DA STA ZTEMP 0185 D7DE B0 01 RPXLA BCS RPXLB ;kick the bit out again if it wasn't relevant 0186 D7E0 4A LSRA 0187 D7E1 06 DA RPXLB ASL ZTEMP ;Shift out the leftmost bit 0188 D7E3 2A ROLA ;& shift into the byte to receive the pixel's logical colour 0189 D7E4 06 D1 ASL ZMASK ;unless the bit was irrelevant 0190 D7E6 D0 F6 BNE RPXLA ;Have we finished ? 0191 D7E8 ] 0192 D7E8 2D 60 03 AND NCOLOR 0193 D7EB 60 RTS ;& finish 0194 D7EC A9 FF RPXLC LDAIM &FF ;Return $FF if point was outside graphics window 0195 D7EE 60 RPXLX RTS ;& finish 0196 D7EF 0197 D7EF ;Window a point, & plot if in window 0198 D7EF 0199 D7EF A2 20 GADDW LDXIM NEWPT-V ;Do this for new point 0200 D7F1 20 21 D1 GADDV JSR WIND ;Do this for general point. Is it in window ? 0201 D7F4 D0 F8 BNE RPXLX ;No, then skip the windowing 0202 D7F6 0203 D7F6 ;otherwise fall through to ... 0204 D7F6 0205 D7F6 ;GADDR Addresses a single pixel on the graphics screen 0206 D7F6 ;Results are not guaranteed unless point is on screen 0207 D7F6 ;Requires :- 0208 D7F6 ;(X) = offset from V of point to be addressed. 0209 D7F6 ;Format of the pointed at point is INTERNAL co-ords, non-inverted Y axis 0210 D7F6 ;with 4 bytes of XL,XH,YL,YH. 0211 D7F6 ;ZTBL points to row offset table as per character writing 0212 D7F6 ;TOPSCN as usual. 0213 D7F6 ;NPIX = No. pixles per byte 0214 D7F6 ;Wraparound may occur on ends of lines only, thus hardware must display 0215 D7F6 ;ALL the characters in the display area (OK for modes as proposed). 0216 D7F6 ;Sets the following variables 0217 D7F6 ;YLINE = line offset within character cell (0..7) 0218 D7F6 ;ZMEMG = 1st byte of character cell 0219 D7F6 ;ZMASK = mask 0220 D7F6 0221 D7F6 BD 02 03 GADDR LDAAX V+&02 ;(Y,LSB) MSB assumed 0 0222 D7F9 49 FF EORIM &FF ;Invert Y axis 0223 D7FB A8 TAY 0224 D7FC 29 07 ANDIM &07 ;Get YLINE = 3 least significant bits of Y 0225 D7FE 8D 1A 03 STA YLINE 0226 D801 98 TYA 0227 D802 4A LSRA ;Get twice the character row (for 2 byte entry lookup table) 0228 D803 4A LSRA 0229 D804 4A LSRA 0230 D805 0A ASLA ;c=0 guaranteed (better than AND $FE : CLC) 0231 D806 A8 TAY ;Character row offset 0232 D807 B1 E0 LDAIY ZTBL ;Add row offset to TOPSCN 0233 D809 85 DA STA ZTEMP ;MSB 0234 D80B C8 INY 0235 D80C B1 E0 LDAIY ZTBL ;LSB 0236 D80E AC 56 03 LDY MEMODE 0237 D811 F0 03 BEQ GADDRD ; Divide by 2 if 10K mode (can only be 0 or 2) 0238 D813 46 DA LSR ZTEMP 0239 D815 6A RORA 0240 D816 6D 50 03 GADDRD ADC TOPSCN ;c=0 guaranteed before this add 0241 D819 85 D6 STA ZMEMG 0242 D81B A5 DA LDA ZTEMP 0243 D81D 6D 51 03 ADC TOPSCN+&01 0244 D820 85 D7 STA ZMEMG +&01 0245 D822 0246 D822 ;Now calculate the X offset 0247 D822 0248 D822 BD 01 03 LDAAX V+&01 ;(MSB,X) 0249 D825 85 DA STA ZTEMP 0250 D827 BD 00 03 LDAAX V ;(LSB,X) 0251 D82A 48 PHA ;Push the LSB of the X co-ordinate 0252 D82B 2D 61 03 AND NPIX ;Calc. ZMASK (NB, c=0 from prev. addition) 0253 D82E 6D 61 03 ADC NPIX ;This gives the correct starting position 0254 D831 A8 TAY ;within the table, plus 1 0255 D832 B9 06 C4 LDAAY MASKTB-&01 ;So compensate by subtracting one here 0256 D835 85 D1 STA ZMASK 0257 D837 68 PLA ;Retrieve the LSB of X co-ordinate 0258 D838 AC 61 03 LDY NPIX 0259 D83B C0 03 CPYIM &03 ;Divide by NPIX, and mult. by 8 0260 D83D F0 05 BEQ GADDRA ;4 pixles/byte - mult. by 2 0261 D83F B0 06 BCS GADDRB ;8 pixles/byte - don't do anything 0262 D841 0A ASLA ;2 pixles per byte - mult. by 4 0263 D842 26 DA ROL ZTEMP 0264 D844 0A GADDRA ASLA 0265 D845 26 DA ROL ZTEMP 0266 D847 29 F8 GADDRB ANDIM &F8 ;Ignore any low order bits 0267 D849 18 CLC ;Calculate the final address, LSB 1st 0268 D84A 65 D6 ADC ZMEMG 0269 D84C 85 D6 STA ZMEMG 0270 D84E A5 DA LDA ZTEMP 0271 D850 65 D7 ADC ZMEMG +&01 0272 D852 10 04 BPL GADDRC ;Skip wraparound if < $8000 0273 D854 38 SEC ;Correct by subtracting off screen if it is 0274 D855 ED 54 03 SBC BYTSCN 0275 D858 85 D7 GADDRC STA ZMEMG +&01 ;Store final address, MSB 0276 D85A AC 1A 03 LDY YLINE 0277 D85D A9 00 COPYZX LDAIM &00 ;Sets z=1 0278 D85F 60 RTS 0279 D860 0280 D860 ;VDUB for cursor control keys 0281 D860 0282 D860 VDUB 0283 D860 48 PHA 0284 D861 A9 A0 LDAIM &A0 ;To see if the cursors are joined or drivers disabled when BIT is done 0285 D863 AE 6A 02 LDX QPOSN ;Qing bytes ? 0286 D866 D0 40 BNE VDUBEX ;Yes?, then ignore this 0287 D868 24 D0 BIT STATS ;Are the drivers enabled ? 0288 D86A D0 3C BNE VDUBEX ;Leave if not, or cursors joined 0289 D86C 70 19 BVS VDUBA ;Are we in cursor edit mode ? Yes?, then skip 0290 D86E AD 5F 03 LDA CSTEMP ;Flash the cursor at twice the rate 0291 D871 29 9F ANDIM &9F ;Sets b5=0, b6=1 of r10 of 6845, giving fast flashing cursor 0292 D873 09 40 ORAIM &40 0293 D875 20 2A C9 JSR ETCB ;Store in r10 of 6845, don't save to CSTEMP 0294 D878 A2 18 LDXIM CSX-V ;Set b1 of STATS or store CSX to PCSX 0295 D87A A0 64 LDYIM PCSX-V 0296 D87C 20 39 D4 JSR COPY2 0297 D87F 20 70 CD JSR OCSRWR ;Print the output cursor 0298 D882 A9 02 LDAIM &02 ;Set b1 of STATS Acorn macro assembler Page 42 VDU File - MOS11 0299 D884 20 9C C5 JSR STTOR 0300 D887 A9 BF VDUBA LDAIM &BF ;Clear b6 of STATS 0301 D889 20 A7 C5 JSR STTAND 0302 D88C 68 PLA ;Restore input character to routine 0303 D88D 29 7F ANDIM &7F ;Kill the parity bit 0304 D88F 20 C0 C4 JSR VDU ;Execute cursor movement on input cursor 0305 D892 A9 40 LDAIM &40 ;Set b6 of STATS 0306 D894 4C 9C C5 JMP STTOR 0307 D897 0308 D897 ;Copy key in cursor editing 0309 D897 0310 D897 COPYCH 0311 D897 A9 20 LDAIM &20 ;Cursors joined ? 0312 D899 24 D0 BIT STATS 0313 D89B 50 C0 BVC COPYZX ;Not C.E. mode, then do nothing 0314 D89D D0 BE BNE COPYZX ;Cursors joined, so do nothing 0315 D89F 20 5C D7 JSR READCH ;Read character at cursor position 0316 D8A2 F0 05 BEQ COPYCX ;Not recognised?, then exit with no further action 0317 D8A4 48 PHA ;Move input cursor right 0318 D8A5 20 63 C6 JSR HT ;But with no scrolling 0319 D8A8 68 VDUBEX PLA 0320 D8A9 60 COPYCX RTS 0321 D8AA 0322 D8AA ;CSEDEX Finish cursor edit mode 0323 D8AA 0324 D8AA A9 BD CSEDEX LDAIM &BD ;Clear b1 & b6 from STATS 0325 D8AC 20 A7 C5 JSR STTAND 0326 D8AF 20 27 C9 JSR ETCA ;Restore cursor from CSTEMP to r10 of 6845 0327 D8B2 A9 0D LDAIM TRMCH ;Restore (A) 0328 D8B4 60 RTS 0329 D8B5 0330 D8B5 TOPCMD 0331 D8B5 AE 55 03 LDX MODE ;~~~ Beginning of screen memory ~~~ 0332 D8B8 0333 D8B8 ;& fall through to .... 0334 D8B8 0335 D8B8 TOPMDX 0336 D8B8 8A TXA ;Don't trust (X) anymore .... 0337 D8B9 29 07 ANDIM &07 0338 D8BB A8 TAY 0339 D8BC ; read VDU low water mark for mode Y 0340 D8BC BE 40 C4 LDXAY MODETB ;~~~ Read beginning of memory for mode (Y) ~~~ 0341 D8BF BD 5E C4 LDAAX STSCTB ;A := hi-byte of lwm address 0342 D8C2 A2 00 LDXIM &00 ;Used later 0343 D8C4 ; check model type 0344 D8C4 2C 8E 02 BIT MODEL 0345 D8C7 30 07 BMI PRBB1 ;[model B, all modes permissable] 0346 D8C9 ; model A 0347 D8C9 ; return HWM of zero for modes 0 to 3 0348 D8C9 ; (cos they require between 16K and 20K) 0349 D8C9 29 3F ANDIM &3F ;correct for 16K m/c (model A) 0350 D8CB C0 04 CPYIM &04 ;fault modes<=3 on model A 0351 D8CD B0 01 BCS PRBB1 ;[mode>=4] 0352 D8CF 8A TXA ;model A and mode<=3. Sets (A):=0 0353 D8D0 PRBB1 ;return low water mark 0354 D8D0 A8 TAY 0355 D8D1 60 RTS 0356 D8D2 0357 D8D2 ENDVDU ;end of VDU code 0358 D8D2 ; Now test code layout for correctness 0359 D8D2 0360 D8D2 0000 T1 * SOH:SHR:&8-CODORG:SHR:&3 0361 D8D2 0000 T2 * DCA:SHR:&8-CODORG:SHR:&3 0362 D8D2 0000 T3 * DCB:SHR:&8-CODORG:SHR:&3 0363 D8D2 0000 T4 * DCC:SHR:&8-CODORG:SHR:&3 0364 D8D2 0000 T5 * SYN:SHR:&8-CODORG:SHR:&3 0365 D8D2 0000 T6 * ETB:SHR:&8-CODORG:SHR:&3 0366 D8D2 0000 T7 * CAN:SHR:&8-CODORG:SHR:&3 0367 D8D2 0000 T8 * EM:SHR:&8-CODORG:SHR:&3 0368 D8D2 0000 T9 * FS:SHR:&8-CODORG:SHR:&3 0369 D8D2 0000 TA * GS:SHR:&8-CODORG:SHR:&3 0370 D8D2 0000 TB * US:SHR:&8-CODORG:SHR:&3 0371 D8D2 [ T1=0 0372 D8D2 | 0374 D8D2 ] 0375 D8D2 [ T2=0 0376 D8D2 | 0378 D8D2 ] 0379 D8D2 [ T3=0 0380 D8D2 | 0382 D8D2 ] 0383 D8D2 [ T4=0 0384 D8D2 | 0386 D8D2 ] 0387 D8D2 [ T5=0 0388 D8D2 | 0390 D8D2 ] 0391 D8D2 [ T6=0 0392 D8D2 | 0394 D8D2 ] 0395 D8D2 [ T7=0 0396 D8D2 | 0398 D8D2 ] 0399 D8D2 [ T8=0 0400 D8D2 | 0402 D8D2 ] 0403 D8D2 [ T9=0 0404 D8D2 | 0406 D8D2 ] 0407 D8D2 [ TA=0 0408 D8D2 | 0410 D8D2 ] 0411 D8D2 [ TB=0 0412 D8D2 | 0414 D8D2 ] 0415 D8D2 0416 D8D2 00C3 TC * HRGTB:SHR: 8 0417 D8D2 00C3 TD * TXTTB:SHR: 8 0418 D8D2 [ TC-TD=0 0419 D8D2 | 0421 D8D2 ] 0422 D8D2 0423 D8D2 00CC TE * CLASCA:SHR: 8 0424 D8D2 00CC TF * CLASCE:SHR: 8 0425 D8D2 0426 D8D2 [ TE-TF=0 0427 D8D2 | 0429 D8D2 ] 0430 D8D2 0431 D8D2 OPT OPPON 0432 D8D2 < 3 Acorn macro assembler Page 43 VDU File - MOS11 0433 D8D2 0434 D8D2 LNK MOS30 0001 D8D2 ; MOS30 0002 D8D2 OPT &01 0003 D8D2 TTL MOS30 Manifests 0004 D8D2 0005 D8D2 ;Change record: 0006 D8D2 0007 D8D2 0008 D8D2 < &0003 0009 D8D2 > &0002 0010 D8D2 0011 D8D2 0012 D8D2 0013 D8D2 0014 D8D2 ; module print selections 0015 D8D2 ; 0016 D8D2 0005 MOS30 * DEFOPT 0017 D8D2 0005 MOS32 * DEFOPT 0018 D8D2 0005 MOS34 * DEFOPT 0019 D8D2 0005 MOS36 * DEFOPT 0020 D8D2 0005 MOS38 * DEFOPT 0021 D8D2 0005 MOS39 * DEFOPT 0022 D8D2 0005 MOS40 * DEFOPT 0023 D8D2 0005 MOS42 * DEFOPT 0024 D8D2 0005 MOS44 * DEFOPT 0025 D8D2 0005 MOS46 * DEFOPT 0026 D8D2 0005 MOS48 * DEFOPT 0027 D8D2 0028 D8D2 0005 MOS52 * DEFOPT 0029 D8D2 0005 MOS54 * DEFOPT 0030 D8D2 0005 MOS56 * DEFOPT 0031 D8D2 0032 D8D2 0005 MOS99 * DEFOPT 0033 D8D2 0034 D8D2 0035 D8D2 OPT MOS30 Acorn macro assembler Page 44 MOS30 Manifests 0036 D8D2 ;(c) 1981 ACORN Computers Limited 0037 D8D2 ;BBC Microcomputer Machine Operating System (MOS) 0038 D8D2 ;Change record: 0039 D8D2 ;Author(s): 0040 D8D2 ;PB Paul Bond 0041 D8D2 ;MP Mike Prees 0042 D8D2 0043 D8D2 0044 D8D2 ; version number 0045 D8D2 ; 0046 D8D2 0001 MCVER * &01 ;OS binary version number 0047 D8D2 0031 VERA * "1" 0048 D8D2 0032 VERB * "2" 0049 D8D2 [ MOS125 = &FF 0051 D8D2 ] 0052 D8D2 [ MOS125 = &7F 0053 D8D2 0036 VERC * "6" 0054 D8D2 ] 0055 D8D2 [ MOS125 = &00 0057 D8D2 ] 0058 D8D2 0059 D8D2 0060 D8D2 ; composition 0061 D8D2 ; 0062 D8D2 0000 TRUE * &00 ;for conditional assembly 0063 D8D2 00FF FALSE * &FF ;for conditional assembly 0064 D8D2 0065 D8D2 0066 D8D2 ; options 0067 D8D2 ; 0068 D8D2 0000 INKYSW * TRUE 0069 D8D2 0070 D8D2 0071 D8D2 ; VDU software interface 0072 D8D2 ; 0073 D8D2 C300 VDUORG * &C300 ;VDU software module origin 0074 D8D2 C300 VDINIT * VDUORG +&00 ;initialise RAM and VDU 0075 D8D2 D8D2 ORIGIN * ENDVDU 0076 D8D2 0077 D8D2 0078 D8D2 ; tube interface 0079 D8D2 ; 0080 D8D2 ^ &0400 0081 D8D2 0400 TBLANG # &03 ;enter language 0082 D8D2 0403 TBESC # &03 ;alter escape condition 0083 D8D2 0406 TBADDR # &03 ;address translation 0084 D8D2 0085 D8D2 0086 D8D2 0087 D8D2 ; error codes 0088 D8D2 0089 D8D2 ; special reports 0090 D8D2 ; 0091 D8D2 0092 D8D2 0093 D8D2 0094 D8D2 ; infamous BASIC error number assignment boob 0095 D8D2 ; 0096 D8D2 0097 D8D2 0098 D8D2 0099 D8D2 ; MOS errors 0100 D8D2 ; 0101 D8D2 0102 D8D2 0103 D8D2 0104 D8D2 ; $FF is reserved for a non-trappable error in future systems 0105 D8D2 ; 0106 D8D2 00FE BADCMD * &FE ;'Bad command' 0107 D8D2 00FD BADST * &FD ;'Bad string' 0108 D8D2 00FC BADADR * &FC ;'Bad address' 0109 D8D2 00FB BADKY * &FB ;'Bad key' 0110 D8D2 00FA KEYUSE * &FA ;'Key in use' 0111 D8D2 00F9 NOLROM * &F9 ;'No language ROM' 0112 D8D2 00F8 NOFSYS * &F8 ;'No filing system' 0113 D8D2 00F7 FX0MSG * &F7 ;operating system version number 0114 D8D2 0115 D8D2 0116 D8D2 ; file system control operations 0117 D8D2 ; 0118 D8D2 0000 FSOPT * &00 ;*OPT x,y value assumed by FX code 0119 D8D2 0001 FSEOF * &01 ;EOF#chan value assumed by FX code 0120 D8D2 0002 FSNOTA * &02 ;*non-alpha 0121 D8D2 0003 FSNAME * &03 ;*name 0122 D8D2 0004 FSRUN * &04 ;*RUN name 0123 D8D2 0005 FSCAT * &05 ;*CAT name 0124 D8D2 0006 FSDIE * &06 ;kill filing system 0125 D8D2 0007 FSHRNG * &07 ;return handle range in X (lo) and Y (hi) 0126 D8D2 0127 D8D2 0008 FSCLI * &08 ;*command encountered 0128 D8D2 0129 D8D2 0130 D8D2 ; user print operations 0131 D8D2 ; 0132 D8D2 0000 UPTIME * &00 ;timer interrupt 0133 D8D2 0001 UPWRCH * &01 ;write character 0134 D8D2 ; return C=0 => printer busy, C=1 => printer free 0135 D8D2 0136 D8D2 0137 D8D2 0138 D8D2 0139 D8D2 ; NET operations 0140 D8D2 ; 0141 D8D2 ; hi-level 0142 D8D2 ; 0143 D8D2 ; VALUES $01-$03,$05 RESERVED FOR PRINTER INTERFACE 0144 D8D2 0004 NTWRCH * &04 ;WRCH 0145 D8D2 0006 NTRDCH * &06 ;RDCH 0146 D8D2 0147 D8D2 0008 NTWORD * &08 ;OSWORD call (c.f. SVWORD) 0148 D8D2 0149 D8D2 0150 D8D2 0151 D8D2 ; service ROM operations 0152 D8D2 ; 0153 D8D2 0010 NROM * &0010 ;number of paged ROMs 0154 D8D2 0155 D8D2 0000 SVNOP * &00 ;no operation 0156 D8D2 0001 SVSTAT * &01 ;offer static allocation 0157 D8D2 0002 SVDYN * &02 ;offer dynamic allocation 0158 D8D2 0003 SVBOOT * &03 ;offer bootstrap Acorn macro assembler Page 45 MOS30 Manifests 0159 D8D2 0004 SVNAME * &04 ;offer command 0160 D8D2 0005 SVINT * &05 ;unknown interrupt 0161 D8D2 0006 SVBRK * &06 ;offer BRK 0162 D8D2 0007 SVBYTE * &07 ;offer bad OSBYTE (N.B. also NTxxxx code) 0163 D8D2 0008 SVWORD * &08 ;offer bad OSWORD (N.B. also NTxxxx code) 0164 D8D2 ; 0165 D8D2 [ FALSE=0 0167 D8D2 | 0168 D8D2 0009 SVHELP * &09 ;*HELP facility 0169 D8D2 ] 0170 D8D2 ; 0171 D8D2 000A SVCSHR * &0A ;claim shared workspace 0172 D8D2 000B SVRNMI * &0B ;release NMI 0173 D8D2 000C SVCNMI * &0C ;claim NMI 0174 D8D2 000D SVISFS * &0D ;initialise speech filing system 0175 D8D2 000E SVRSFS * &0E ;read from speech filing system 0176 D8D2 000F SVFSIC * &0F ;changed filing system indirections 0177 D8D2 0178 D8D2 0010 SVSHES * &10 ;shut EXEC and SPOOL files 0179 D8D2 0011 SVHWMC * &11 ;change of HWM ******** DO NOT CHANGE ******** 0180 D8D2 0012 SVSTFS * &12 ;start filing system N 0181 D8D2 00FE SVTPIN * &FE ;tube post-initialisation **** VALUE ASSUMED BY RESET **** 0182 D8D2 00FF SVTUBE * &FF ;initialise tube software 0183 D8D2 0184 D8D2 0185 D8D2 ; language entry reasons 0186 D8D2 ; 0187 D8D2 0000 LGNONE * &00 ;no language ROM (tube entry reason) 0188 D8D2 0001 LGENTR * &01 ;enter language 0189 D8D2 0190 D8D2 0191 D8D2 ; RS423 transmitter control bits 0192 D8D2 ; 0193 D8D2 0000 RHITXD * &00 ;RTS hi, Tx interrupt disabled 0194 D8D2 0020 RHITXE * &20 ;RTS hi, Tx interrupt enabled 0195 D8D2 0040 RLOTXD * &40 ;RTS lo, Tx interrupt disabled 0196 D8D2 0060 RHITXB * &60 ;RTS hi, Tx break 0197 D8D2 0056 RSCDEF * &16+RLOTXD ;Rx interrupt disabled ... 0198 D8D2 ; ... RTS lo, Tx interrupt disabled, divide by 64, 8 data bits, 1 stop bit 0199 D8D2 0200 D8D2 0201 D8D2 ; speech processor opcodes 0202 D8D2 ; 0203 D8D2 0010 SPOPRB * &10 ;read byte 0204 D8D2 0060 SPOPSE * &60 ;speak external 0205 D8D2 0030 SPOPBR * &30 ;read and branch 0206 D8D2 0040 SPOPLA * &40 ;load address 0207 D8D2 0050 SPOPSP * &50 ;speak 0208 D8D2 00FF SPOPRT * &FF ;reset 0209 D8D2 0210 D8D2 0211 D8D2 ; memory map assignments 0212 D8D2 ; 0213 D8D2 FC00 FRED * &FC00 0214 D8D2 FCFF MEG1P * &FCFF ;1MHz bus page selector 0215 D8D2 FD00 JIM * &FD00 0216 D8D2 FE00 SHEIL * &FE00 0217 D8D2 FE08 ACIA * &FE08 0218 D8D2 FE10 SERPRC * &FE10 ;serial processor 0219 D8D2 0220 D8D2 FE20 VPROC0 * &FE20 ;video processor 0221 D8D2 FE21 VPROC1 * VPROC0 +&01 0222 D8D2 FE20 STNID * &FE20 ;ECONET station identifier 0223 D8D2 FE30 ROM * &FE30 ;ROM select latch 0224 D8D2 FE40 VIAA * &FE40 ;first 6522 0225 D8D2 FE60 VIAB * &FE60 ;second 6522 0226 D8D2 0227 D8D2 0228 D8D2 ; analog to digital converter 0229 D8D2 ; 0230 D8D2 FEC0 ADCONV * &FEC0 0231 D8D2 FEC0 ADCCTL * ADCONV +&00 0232 D8D2 FEC1 ADCHI * ADCONV +&01 0233 D8D2 FEC2 ADCLO * ADCONV +&02 0234 D8D2 0235 D8D2 0236 D8D2 ; tube register(s) 0237 D8D2 ; 0238 D8D2 FEE0 TREG0 * &FEE0 0239 D8D2 FEE5 TREG3 * &FEE5 0240 D8D2 0241 D8D2 0242 D8D2 0243 D8D2 ; test software indirection 0244 D8D2 ; 0245 D8D2 FDFE TSTSFT * &FDFE 0246 D8D2 0247 D8D2 0248 D8D2 ; language ROM address 0249 D8D2 ; 0250 D8D2 8000 LANG * &8000 0251 D8D2 8000 ROMHRD * LANG +&00 ;hard ROM entry point 0252 D8D2 8003 ROMSFT * LANG +&03 ;soft ROM entry point 0253 D8D2 0254 D8D2 8006 ROMTYP * LANG +&06 ;ROM type 0255 D8D2 8007 COPYRP * LANG +&07 ;relative offset (from LANG) to copyright string 0256 D8D2 8008 ROMVER * LANG +&08 ;version byte 0257 D8D2 8009 ROMMSG * LANG +&09 ;name 0258 D8D2 0259 D8D2 0260 D8D2 ; miscellaneous constants 0261 D8D2 ; 0262 D8D2 0000 ZERO * &00 0263 D8D2 0000 NULL * ZERO ;don't care value 0264 D8D2 0020 SPACE * &20 0265 D8D2 0040 AT * &40 0266 D8D2 0041 ALPHAA * "A" 0267 D8D2 0022 DQUOTE * """" 0268 D8D2 002A SPLAT * "*" 0269 D8D2 0060 POUND * &60 0270 D8D2 0271 D8D2 0272 D8D2 0273 D8D2 0007 BEL * &07 0274 D8D2 0275 D8D2 0009 MHT * &09 0276 D8D2 0009 TAB * MHT 0277 D8D2 000A MLF * &0A 0278 D8D2 000D MCR * &0D 0279 D8D2 0015 MNAK * &15 0280 D8D2 Acorn macro assembler Page 46 MOS30 Manifests 0281 D8D2 001B ESC * &1B 0282 D8D2 007F MDEL * &7F 0283 D8D2 0284 D8D2 0285 D8D2 ; real softkeys 0286 D8D2 ; 0287 D8D2 0080 SOFTK0 * &0080 ;f0 (value must NOT be altered) 0288 D8D2 0081 SOFTK1 * SOFTK0 +&01 ;f1 0289 D8D2 0082 SOFTK2 * SOFTK1 +&01 ;f2 0290 D8D2 0083 SOFTK3 * SOFTK2 +&01 ;f3 0291 D8D2 0084 SOFTK4 * SOFTK3 +&01 ;f4 0292 D8D2 0085 SOFTK5 * SOFTK4 +&01 ;f5 0293 D8D2 0086 SOFTK6 * SOFTK5 +&01 ;f6 0294 D8D2 0087 SOFTK7 * SOFTK6 +&01 ;f7 0295 D8D2 0088 SOFTK8 * SOFTK7 +&01 ;f8 0296 D8D2 0089 SOFTK9 * SOFTK8 +&01 ;f9 0297 D8D2 0298 D8D2 0299 D8D2 ; pseudo softkeys, including cursor controls 0300 D8D2 ; 0301 D8D2 008A SOFTKA * SOFTK9 +&01 0302 D8D2 008B SOFTKB * SOFTKA +&01 ;COPY 0303 D8D2 008B MCOPY * SOFTKB 0304 D8D2 008C SOFTKC * SOFTKB +&01 ;cursor left arrow 0305 D8D2 008C CURLFT * SOFTKC 0306 D8D2 008D SOFTKD * SOFTKC +&01 ;cursor right arrow 0307 D8D2 008D CURRHT * SOFTKD 0308 D8D2 008E SOFTKE * SOFTKD +&01 ;cursor down 0309 D8D2 008E CURDWN * SOFTKE 0310 D8D2 008F SOFTKF * SOFTKE +&01 ;cursor up 0311 D8D2 008F CURUP * SOFTKF 0312 D8D2 00BF MAXSK * &BF ;maximum value of SHIFT/CTRL softkey code 0313 D8D2 00CA BREKEY * &CA ;softkey 10 feature 0314 D8D2 0315 D8D2 0316 D8D2 ; default auto-repeat rates 0317 D8D2 ; 0318 D8D2 0032 DAUTOD * 50 ;delay (centiseconds) 0319 D8D2 0008 DAUTOP * 8 ;period (centiseconds) 0320 D8D2 0321 D8D2 0322 D8D2 ; default RS423 baud rates 0323 D8D2 ; 0324 D8D2 0064 B9600 * &64 ;Tx9600 and Rx9600 0325 D8D2 0326 D8D2 0327 D8D2 ; RS423 printer timeout period 0328 D8D2 ; 0329 D8D2 00E7 PTIMUT * &E7 ;(-) 25/50 second 0330 D8D2 0331 D8D2 0332 D8D2 ; OS constants 0333 D8D2 0E00 OSHWM * &0E00 ;default high water mark 0334 D8D2 0D00 NMI * &0D00 0335 D8D2 0336 D8D2 0337 D8D2 ; buffer indices 0338 D8D2 ; 0339 D8D2 0000 BRDCH * &0000 ;RDCH (keyboard) 0340 D8D2 0001 BRSI * &0001 ;RS423 input 0341 D8D2 0001 INPUT * BRSI 0342 D8D2 0002 BRSO * &0002 ;RS423 output 0343 D8D2 0002 OUTPUT * BRSO 0344 D8D2 0003 BPRNT * &0003 ;print 0345 D8D2 0004 BSND1 * &0004 ;sound channel 1 0346 D8D2 0005 BSND2 * BSND1+&1 ;sound channel 2 0347 D8D2 0006 BSND3 * BSND2+&1 ;sound channel 3 0348 D8D2 0007 BSND4 * BSND3+&1 ;sound channel 4 0349 D8D2 0008 BSPCH * BSND4+&1 ;speech 0350 D8D2 0008 BUPB * BSPCH 0351 D8D2 0352 D8D2 0353 D8D2 ; keyboard status bits 0354 D8D2 ; 0355 D8D2 0008 SHFT * &08 ;SHIFT active 0356 D8D2 0010 CAPSL * &10 ;not CAPITALS lock 0357 D8D2 0020 SHFTL * &20 ;not SHIFT lock 0358 D8D2 0040 CTRL * &40 ;CTRL active 0359 D8D2 0080 INVERT * &80 ;SHIFT enable 0360 D8D2 00B7 CTLSHI * &B7 ;inverted (CTRL and SHIFT status bits) 0361 D8D2 0362 D8D2 0363 D8D2 ; keyboard matrix element values 0364 D8D2 ; 0365 D8D2 00C0 CPLKKY * &C0 ;CAPITALS lock key 0366 D8D2 00D0 SHLKKY * &D0 ;SHIFT lock key 0367 D8D2 0368 D8D2 0369 D8D2 ; FX numbers 0370 D8D2 ; 0371 D8D2 0088 FXCODE * &88 0372 D8D2 0089 FXMOTR * &89 0373 D8D2 008B FXOPT * &8B 0374 D8D2 008C FXTAPE * &8C 0375 D8D2 008D FXSROM * &8D 0376 D8D2 0090 FXTV * &90 0377 D8D2 0378 D8D2 0379 D8D2 ; MC6850 addresses 0380 D8D2 ; 0381 D8D2 FE08 RSCTL * ACIA 0382 D8D2 FE08 RSTAT * ACIA 0383 D8D2 FE09 RSDATA * ACIA +&01 0384 D8D2 0385 D8D2 0386 D8D2 ; miscellaneous 0387 D8D2 ; 0388 D8D2 0004 NADC * &04 ;number of ADC channels 0389 D8D2 0390 D8D2 0391 D8D2 ; 6522 addresses 0392 D8D2 ; 0393 D8D2 FE40 PBQ * VIAA 0394 D8D2 FE41 PAQ * VIAA +&01 0395 D8D2 FE42 DDRBQ * VIAA +&02 0396 D8D2 FE43 DDRAQ * VIAA +&03 0397 D8D2 FE44 TQCLQ * VIAA +&04 0398 D8D2 FE45 TQCHQ * VIAA +&05 0399 D8D2 FE46 TQLLQ * VIAA +&06 0400 D8D2 FE47 TQLHQ * VIAA +&07 0401 D8D2 FE48 TRCLQ * VIAA +&08 Acorn macro assembler Page 47 MOS30 Manifests 0402 D8D2 FE49 TRCHQ * VIAA +&09 0403 D8D2 FE4A SRQ * VIAA +&0A 0404 D8D2 FE4B ACRQ * VIAA +&0B 0405 D8D2 FE4C PCRQ * VIAA +&0C 0406 D8D2 000A CAPULS * &0A 0407 D8D2 000C CA2LO * &0C 0408 D8D2 000E CA2HI * &0E 0409 D8D2 00A0 CBPULS * &A0 0410 D8D2 00C0 CB2LO * &C0 0411 D8D2 00E0 CB2HI * &E0 0412 D8D2 FE4D IFRQ * VIAA +&0D 0413 D8D2 FE4E IERQ * VIAA +&0E 0414 D8D2 FE4F PAPQ * VIAA +&0F 0415 D8D2 FE60 PBR * VIAB 0416 D8D2 FE61 PAR * VIAB +&01 0417 D8D2 FE62 DDRBR * VIAB +&02 0418 D8D2 FE63 DDRAR * VIAB +&03 0419 D8D2 FE64 TQCLR * VIAB +&04 0420 D8D2 FE65 TQCHR * VIAB +&05 0421 D8D2 FE66 TQLLR * VIAB +&06 0422 D8D2 FE67 TQLHR * VIAB +&07 0423 D8D2 FE68 TRCLR * VIAB +&08 0424 D8D2 FE69 TRCHR * VIAB +&09 0425 D8D2 FE6A SRR * VIAB +&0A 0426 D8D2 FE6B ACRR * VIAB +&0B 0427 D8D2 FE6C PCRR * VIAB +&0C 0428 D8D2 FE6D IFRR * VIAB +&0D 0429 D8D2 FE6E IERR * VIAB +&0E 0430 D8D2 FE6F PAPR * VIAB +&0F 0431 D8D2 0432 D8D2 0433 D8D2 ; interrupt flags in 6522 IER and IFR 0434 D8D2 ; 0435 D8D2 0002 CA1 * &0002 0436 D8D2 0001 CA2 * &0001 0437 D8D2 0010 CB1 * &0010 0438 D8D2 0008 CB2 * &0008 0439 D8D2 0040 TIMER1 * &0040 0440 D8D2 0020 TIMER2 * &0020 0441 D8D2 0442 D8D2 0443 D8D2 ; VIA pin assignments 0444 D8D2 ; 0445 D8D2 ; VIAA:- 0446 D8D2 ; PA7-PA0 keyboard 0447 D8D2 ; CA1 VSYNC interrupt 0448 D8D2 0002 VSYNC * CA1 0449 D8D2 ; CA2 keyboard interrupt ('any key down') 0450 D8D2 0001 KEYBD * CA2 0451 D8D2 ; PB7 VSP interrupt 0452 D8D2 ; PB6 VSP ready 0453 D8D2 ; PB5,PB4 paddle 0454 D8D2 ; PB3-PB0 addressable latch 0455 D8D2 ; PB3 data value 0456 D8D2 ; PB2-PB0 latch register 0457 D8D2 ; 0 sound enable 0458 D8D2 ; 1 speech RS 0459 D8D2 ; 2 speech WS 0460 D8D2 ; 3 keyboard disable 0461 D8D2 ; 4,5 hardware scroll 0462 D8D2 ; 6,7 ROM select 0463 D8D2 ; CB1 ADC 0464 D8D2 0010 ADC * CB1 0465 D8D2 ; CB2 light pen 0466 D8D2 0467 D8D2 ; VIAB:- 0468 D8D2 ; PA7-PA0 printer output 0469 D8D2 ; CA1 printer acknowledge 0470 D8D2 0002 PRNT * CA1 0471 D8D2 ; CA2 printer strobe 0472 D8D2 ; PB7-PB0 reserved for user 0473 D8D2 ; CB1 reserved for user 0474 D8D2 ; CB2 reserved for user 0475 D8D2 ; TIMER 1 = MAIN CLOCK 0476 D8D2 0040 CLOCK * TIMER1 0477 D8D2 0478 D8D2 0479 D8D2 ; page one is main system stack 0480 D8D2 ; 0481 D8D2 00FF STACK * &FF 0482 D8D2 0483 D8D2 0484 D8D2 0485 D8D2 ; BUFFERS 0486 D8D2 0487 D8D2 0488 D8D2 ; keyboard 0489 D8D2 ; 0490 D8D2 03E0 RDCHBF * &03E0 ;RDCH (keyboard) buffer 0491 D8D2 0020 RDCHSZ * &0020 0492 D8D2 0493 D8D2 0494 D8D2 ; sound 0495 D8D2 ; 0496 D8D2 0800 SNDWRK * &0800 ;sound workspace 0497 D8D2 0804 MACTIV * SNDWRK+&04 ;activation flags 0498 D8D2 0499 D8D2 0840 SNDBF1 * &0840 ;sound buffer channel 1 0500 D8D2 0010 SBSIZE * &0010 ;sound buffer size 0501 D8D2 0850 SNDBF2 * SNDBF1+SBSIZE ;sound buffer channel 2 0502 D8D2 0860 SNDBF3 * SNDBF2+SBSIZE ;sound buffer channel 3 0503 D8D2 0870 SNDBF4 * SNDBF3+SBSIZE ;sound buffer channel 4 0504 D8D2 0505 D8D2 0506 D8D2 ; printer 0507 D8D2 ; 0508 D8D2 0880 PRNBF * &0880 ;print buffer 0509 D8D2 0040 PRNSZ * &0040 0510 D8D2 0511 D8D2 0512 D8D2 ; envelopes 0513 D8D2 ; 0514 D8D2 08C0 ENVEL * &08C0 ;sound envelopes 0515 D8D2 0010 ENVSIZ * &0010 ;size of each envelope 0516 D8D2 0004 NENV * &0004 ;number of envelopes 0517 D8D2 0518 D8D2 0519 D8D2 ; RS423 output 0520 D8D2 ; 0521 D8D2 0900 RSROBF * &0900 ;RS423 output 0522 D8D2 00C0 RSROSZ * &00C0 Acorn macro assembler Page 48 MOS30 Manifests 0523 D8D2 0524 D8D2 0525 D8D2 ; speech 0526 D8D2 ; 0527 D8D2 09C0 SPCHBF * &09C0 ;speech buffer 0528 D8D2 0040 SPCHSZ * &0040 0529 D8D2 0530 D8D2 0531 D8D2 ; RS423 input 0532 D8D2 ; 0533 D8D2 0A00 RSRIBF * &0A00 ;RS423 input 0534 D8D2 0100 RSRISZ * &0100 0535 D8D2 0008 RSOVR * 8 ;handshake overflow allowance 0536 D8D2 0537 D8D2 0538 D8D2 ; soft key buffer 0539 D8D2 ; 0540 D8D2 0B00 SKPTR * &0B00 ;pointers to soft key strings 0541 D8D2 0010 NSOFTK * 16 0542 D8D2 0B01 SKBUF * SKPTR+&01 ;N.B. soft key pointers are relative to this origin 0543 D8D2 0B10 SKEND * SKPTR+NSOFTK ;logical end of string 0544 D8D2 00EF TOTSFT * SKPTR+&0100-SKEND-&01 ;soft key data byte size 0545 D8D2 0546 D8D2 0547 D8D2 LNK MOS32 0001 D8D2 0002 D8D2 ; -> MOS32 0003 D8D2 TTL MOS32 Initialisation and external interfaces 0004 D8D2 OPT MOS32 Acorn macro assembler Page 49 MOS32 Initialisation and external interfaces 0005 D8D2 ;(c) 1981 ACORN Computers Limited 0006 D8D2 ;BBC Microcomputer Machine Operating System (MOS) 0007 D8D2 ;Change record: 0008 D8D2 ;Author(s): 0009 D8D2 ;PB Paul Bond 0010 D8D2 ;MP Mike Prees 0011 D8D2 0012 D8D2 0013 D8D2 ; origin of real code 0014 D8D2 ORG ORIGIN ;MOS starts where VDU ends 0015 D8D2 0016 D8D2 0017 D8D2 IPAGE0 ;page zero values 0018 D8D2 ; externally accessed zero page values 0019 D8D2 ^ &00FF 0020 D8D2 ; 0021 D8D2 00FF ESCFLG # 0 ;Bit 7 of this is the escape flag 0022 D8D2 0023 D8D2 0024 D8D2 ; bit7 escape pending 0025 D8D2 ;= ZERO 0026 D8D2 0027 D8D2 00FF # -2 0028 D8D2 00FD REPTR # &00 ;pointer after BRK 0029 D8D2 ;= NULL /;hi-byte 0030 D8D2 ;= NULL ;lo-byte 0031 D8D2 0032 D8D2 00FD # -1 0033 D8D2 00FC TEMPA # &00 ;user IRQ routine save slot for register A 0034 D8D2 ;= NULL 0035 D8D2 0036 D8D2 00FC # -2 0037 D8D2 00FA SEIWK # &00 ;two work slots used whilst interrupts disabled 0038 D8D2 ; 0039 D8D2 00FA JMILO * SEIWK +&00 ;used by OSBYTE/OSWORD 0040 D8D2 00FB JMIHI * SEIWK +&01 ;used by OSBYTE/OSWORD 0041 D8D2 ; 0042 D8D2 00FA KEYSV * SEIWK +&00 ;work area for ... 0043 D8D2 00FB SKSZWK * SEIWK +&01 ; ... soft key compaction (also SKSIZE) 0044 D8D2 ; 0045 D8D2 00FA KTEMP * SEIWK +&00 ;work area for keyboard 0046 D8D2 ; 0047 D8D2 00FA BUFFLO * SEIWK +&00 ;work slots used by buffer management 0048 D8D2 00FB BUFFHI * SEIWK +&01 0049 D8D2 ; 0050 D8D2 00FA CRLO * SEIWK +&00 ;work slots used during ROM compare 0051 D8D2 00FB CRHI * SEIWK +&01 0052 D8D2 ; 0053 D8D2 00FA MASK * SEIWK +&00 ;work slots used by set Rx/Tx RS423 baud rates 0054 D8D2 00FB BAUD * SEIWK +&01 0055 D8D2 ; 0056 D8D2 00FA RSOP * SEIWK +&00 ;work slot used by RSUCTL 0057 D8D2 ; 0058 D8D2 00FA NOTEWK * SEIWK +&00 ;work slot used by NOTE 0059 D8D2 ; 0060 D8D2 00FA EVENTA * SEIWK +&00 ;work slot used by EVENT (hopefully no clashes) 0061 D8D2 ; 0062 D8D2 00FA PEEKLO * SEIWK +&00 ;work slot used by OSWORD read-byte/write-byte 0063 D8D2 00FB PEEKHI * SEIWK +&01 0064 D8D2 ; 0065 D8D2 00FA SPWK1 * SEIWK +&00 ;used by speech sprocessing 0066 D8D2 00FB SPWK2 * SEIWK +&01 ;used by TIMER2 (speech) interrupt routine 0067 D8D2 0068 D8D2 00FA # -1 0069 D8D2 00F9 SPARE0 # &00 ;**************** 0070 D8D2 ; = NULL 0071 D8D2 0072 D8D2 00F9 # -1 0073 D8D2 00F8 SPARE1 # &00 ;**************** 0074 D8D2 ;= NULL 0075 D8D2 0076 D8D2 00F8 # -2 0077 D8D2 00F6 ROMPTR # &00 ;pointer used by ROM filing system 0078 D8D2 ;= NULL 0079 D8D2 ;= NULL 0080 D8D2 0081 D8D2 00F6 # -1 0082 D8D2 00F5 SEROM # &00 ;serial ROM id 0083 D8D2 ;= NULL 0084 D8D2 0085 D8D2 00F5 # -1 0086 D8D2 00F4 ROMID # &00 ;currently selected ROM 0087 D8D2 0088 D8D2 ;= NULL 0089 D8D2 0090 D8D2 00F4 # -2 0091 D8D2 00F2 WORK # &00 ;miscellaneous pointer 0092 D8D2 ;= NULL 0093 D8D2 ;= NULL 0094 D8D2 0095 D8D2 00F2 # -2 0096 D8D2 ; WORD values may be shared with other sei-routines 0097 D8D2 00F0 WORDX # &00 0098 D8D2 00F0 BYTEX * WORDX 0099 D8D2 00F1 WORDY * WORDX +&01 0100 D8D2 00F1 BYTEY * WORDY 0101 D8D2 0102 D8D2 00F0 # -1 0103 D8D2 00EF WORDA # &00 0104 D8D2 00EF BYTEA * WORDA 0105 D8D2 ;= NULL 0106 D8D2 0107 D8D2 00EF # -1 0108 D8D2 00EE PAGE1M # &00 ;selected page for 1MHz bus 0109 D8D2 ;= ZERO 0110 D8D2 0111 D8D2 00EE # -1 0112 D8D2 00ED OKEY # &00 ;current key value 0113 D8D2 ;= ZERO 0114 D8D2 0115 D8D2 00ED # -1 0116 D8D2 00EC CKEY # &00 ;current key value 0117 D8D2 ;= ZERO 0118 D8D2 0119 D8D2 00EC # -1 0120 D8D2 00EB ESSEMA # &00 ;EXEC/SPOOL semaphore (used by CFS) 0121 D8D2 0122 D8D2 0123 D8D2 00EB # -1 0124 D8D2 00EA RSTUT # &00 ;RS423 printer timeouT 0125 D8D2 ;= ZERO Acorn macro assembler Page 50 MOS32 Initialisation and external interfaces 0126 D8D2 0127 D8D2 00EA # -2 0128 D8D2 00E8 RDLNBF # &00 ;buffer address used by OSWORD readline routine 0129 D8D2 0130 D8D2 00E8 # -1 0131 D8D2 00E7 ARCTR # &00 ;auto-repeat counter 0132 D8D2 ;= ZERO 0133 D8D2 0134 D8D2 00E7 # -1 0135 D8D2 00E6 WRKCLI # &00 ;shared work slot with interrupts enabled 0136 D8D2 ; 0137 D8D2 00E6 RDCTEM * WRKCLI ;used by RDCH 0138 D8D2 00E6 CLIRY * WRKCLI ;used by CLI decoder 0139 D8D2 ; 0140 D8D2 00E6 NUMBER * WRKCLI ;work slot for GETNUM 0141 D8D2 00E6 CSKEY * NUMBER ;current softkey number (must not share with KMASK or KQUOTE) 0142 D8D2 ; 0143 D8D2 00E6 FILEY * WRKCLI ;save area for register Y 0144 D8D2 00E6 EXECY * FILEY ;save area used by EXEC 0145 D8D2 0146 D8D2 00E6 SPOOLY * FILEY ;save area used by SPOOL 0147 D8D2 ;= NULL 0148 D8D2 0149 D8D2 00E6 # -1 0150 D8D2 00E5 FXREGX # &00 ;used by FX CLI command 0151 D8D2 00E5 KMASK # &00 ;used by GSREAD 0152 D8D2 ; must not be shared with CSKEY 0153 D8D2 ;= NULL 0154 D8D2 0155 D8D2 00E5 # -1 0156 D8D2 00E4 FXREGY # &00 ;used by FX CLI command 0157 D8D2 00E4 KQUOTE # &00 ;must not be shared with KMASK 0158 D8D2 ; must not be shared with CSKEY 0159 D8D2 ;= NULL 0160 D8D2 0161 D8D2 00E4 # -1 0162 D8D2 00E3 CFS1 # &00 ;reserved for CFS 0163 D8D2 0164 D8D2 00E3 # -1 0165 D8D2 ; 0166 D8D2 ; CFS workspace 0167 D8D2 ; ============= 0168 D8D2 ; 0169 D8D2 00E2 CFS0 # &00 ;reserved for CFS 0170 D8D2 00E2 CFSTAT * CFS0 0171 D8D2 ;PAGE ZERO 0172 D8D2 0173 D8D2 00B0 PZERO * &00B0 ;Start of p.0 workspace 0174 D8D2 0175 D8D2 00B0 BKADDR * PZERO ;4 BYTE BLOCK PTR. 0176 D8D2 00B4 HIADDR * BKADDR +&04 ;Top of data being saved, 0177 D8D2 ;Must be contiguous with BKADDR 0178 D8D2 0179 D8D2 00B4 BLOKNO * HIADDR 0180 D8D2 00B6 SRCHBK * BLOKNO +&02 ;Block numbers being searched for 0181 D8D2 ;Not used in SAVE, hence can overlap HIADDR 0182 D8D2 0183 D8D2 00B8 FTPTR * HIADDR +&04 ;Used in VSTRIN 0184 D8D2 00BA ERRSW * FTPTR +&02 ;In p.0 to save space 0185 D8D2 00BB USFLGS * ERRSW +&01 0186 D8D2 00BC TEMP * USFLGS +&01 0187 D8D2 00BD IBUF * TEMP +&01 0188 D8D2 00BE CHKSUM * IBUF +&01 0189 D8D2 00C0 IFLAG * CHKSUM +&02 0190 D8D2 00C1 HDRCRC * IFLAG +&01 0191 D8D2 00C2 ITYPE * HDRCRC +&01 0192 D8D2 00C3 CURDRV * ITYPE +&01 ;Currently selected cassette 0193 D8D2 00C4 IADDR * CURDRV +&01 0194 D8D2 00C6 SPEED * IADDR +&02 0195 D8D2 00C7 GAPTIM * SPEED +&01 0196 D8D2 00C8 GENPTR * GAPTIM +&01 ;Used in FILEGO/LOAD only 0197 D8D2 00CA TXFLAG * GENPTR +&02 ;"We are transmitting" flag 0198 D8D2 00CB CRCCNT * TXFLAG +&01 ;Used in CRC check 0199 D8D2 00CC FSIZE * CRCCNT + 1 ;File size to modify control block in LOAD 0200 D8D2 0201 D8D2 00E3 OPTS * CFS1 ;Retained over filing system change 0202 D8D2 ;************************************** 0203 D8D2 0204 D8D2 00E2 BPAGE0 # &00 0205 D8D2 0206 D8D2 0207 D8D2 0208 D8D2 IPAGE2 0209 D8D2 ; page two values 0210 D8D2 ^ &0200 0211 D8D2 0200 APAGE2 # &00 0212 D8D2 0200 USRVEC # &02 ;user vector 0213 D8D2 55 = BADFX 0214 D8D3 E3 = /(BADFX ) 0215 D8D4 0202 BRKVEC # &02 ;BRK handling 0216 D8D4 6A = DEFBRK 0217 D8D5 DB = /(DEFBRK ) 0218 D8D6 0204 IRQALL # &02 ;all IRQs indirect thru here 0219 D8D6 23 = DEFIRQ 0220 D8D7 DE = /(DEFIRQ ) 0221 D8D8 0206 IRQVEC # &02 ;unrecognised IRQ 0222 D8D8 35 = IRQTWO 0223 D8D9 DE = /(IRQTWO ) 0224 D8DA 0208 COMVEC # &02 ;command line intepreter 0225 D8DA C4 = CLINT 0226 D8DB DF = /(CLINT ) 0227 D8DC 020A BYTVEC # &02 ;MOS routine, 0 1 or 2 arguments 0228 D8DC B3 = BYTE 0229 D8DD E7 = /(BYTE ) 0230 D8DE 020C WORVEC # &02 ;MOS routine, >2 arguments 0231 D8DE 1D = WORD 0232 D8DF E8 = /(WORD ) 0233 D8E0 020E WRCVEC # &02 ;write character 0234 D8E0 F6 = WRCH 0235 D8E1 E0 = /(WRCH ) 0236 D8E2 0210 RDCVEC # &02 ;read character 0237 D8E2 71 = RDCH 0238 D8E3 DE = /(RDCH ) 0239 D8E4 CFSTAB 0240 D8E4 0212 FILVEC # &02 ;load/save memory image 0241 D8E4 E2 = FILEGO 0242 D8E5 F1 = /(FILEGO ) 0243 D8E6 0214 ARGVEC # &02 ;read/set file attributes 0244 D8E6 98 = ARGGO 0245 D8E7 F1 = /(ARGGO ) 0246 D8E8 0216 BGTVEC # &02 ;get byte from random file Acorn macro assembler Page 51 MOS32 Initialisation and external interfaces 0247 D8E8 CF = GETBYT 0248 D8E9 F4 = /(GETBYT ) 0249 D8EA 0218 BPTVEC # &02 ;put byte to random file 0250 D8EA 32 = PUTBYT 0251 D8EB F5 = /(PUTBYT ) 0252 D8EC 021A GPBVEC # &02 ;get/put bytes 0253 D8EC B2 = RTS 0254 D8ED FF = /(RTS ) 0255 D8EE 021C FNDVEC # &02 ;open/close random file 0256 D8EE D0 = FIND 0257 D8EF F3 = /(FIND ) 0258 D8F0 021E FSCVEC # &02 ;file system control entry 0259 D8F0 AD = FSFUNC 0260 D8F1 F1 = /(FSFUNC ) 0261 D8F2 0220 EVTVEC # &02 ;event interrupt 0262 D8F2 B2 = DEFEVT 0263 D8F3 FF = /(DEFEVT ) 0264 D8F4 0222 UPTVEC # &02 ;user print routine 0265 D8F4 ; default hangs printer 0266 D8F4 B2 = DEFUPT 0267 D8F5 FF = /(DEFUPT ) 0268 D8F6 0224 NETVEC # &02 ;ECONET effects 0269 D8F6 ; default hangs printer 0270 D8F6 B2 = DEFNET 0271 D8F7 FF = /(DEFNET ) 0272 D8F8 0226 VDUVEC # &02 ;VDU command indirection 0273 D8F8 0274 D8F8 B2 = RTS 0275 D8F9 FF = /(RTS ) 0276 D8FA 0228 KEYVEC # &02 ;keyboard control indirection 0277 D8FA 1B = DEFKEY 0278 D8FB EF = /(DEFKEY ) 0279 D8FC 022A INSVEC # &02 ;buffer insert indirection 0280 D8FC F7 = INS 0281 D8FD E4 = /(INS ) 0282 D8FE 022C REMVEC # &02 ;buffer remove indirection 0283 D8FE A8 = REM 0284 D8FF E4 = /(REM ) 0285 D900 022E CNPVEC # &02 ;buffer count / purge buffer indirection 0286 D900 22 = CNP 0287 D901 E2 = /(CNP ) 0288 D902 0230 INDONE # &02 0289 D902 B2 = RTS 0290 D903 FF = /(RTS ) 0291 D904 0232 INDTWO # &02 0292 D904 B2 = RTS 0293 D905 FF = /(RTS ) 0294 D906 0234 INDTRH # &02 0295 D906 B2 = RTS 0296 D907 FF = /(RTS ) 0297 D908 0036 VLEN * @-APAGE2 0298 D908 ; 0299 D908 001B NP2IND * VLEN:SHR: 1 ;number of page 2 indirections 0300 D908 0051 ROMIVS * NP2IND* 3 ;page ROM indirection vector size 0301 D908 0D9F ROMVEC * &0DF0-ROMIVS ;paged ROM routine vectors 0302 D908 0303 D908 0304 D908 0236 VARS # &00 0305 D908 ; 0306 D908 0236 # &02 ;variables origin 0307 D908 90 = VBASE ;166 0308 D909 01 = /(VBASE ) 0309 D90A 0310 D90A 0238 # &02 ;origin of 3-byte ROM indirection vectors 0311 D90A 9F = ROMVEC ;168 0312 D90B 0D = /(ROMVEC ) 0313 D90C 0314 D90C 023A # &02 ;paged ROM info 0315 D90C A1 = ROMS ;170 0316 D90D 02 = /(ROMS ) 0317 D90E 0318 D90E 023C # &02 ;keyboard matrix info 0319 D90E 3A = KTBL ;172 0320 D90F F0 = /(KTBL ) 0321 D910 0322 D910 023E # &02 ;VDU module origin of variables 0323 D910 00 = VARBLE ;174 0324 D911 03 = /(VARBLE ) 0325 D912 0326 D912 0240 CYCLE # &01 ;filing system timeout byte 0327 D912 0328 D912 00 = NULL 0329 D913 0330 D913 0241 RDCHSW # &01 ;RDCH source switch (assumed not in page zero, see KTBL) 0331 D913 00 = ZERO ;177 BRDCH (zero) 0332 D914 0333 D914 0242 KSEMA # &01 ;keyboard semaphore 0334 D914 FF = &FF ;178 0335 D915 0336 D915 0243 IHWM # &01 0337 D915 0338 D915 00 = ZERO ;179 0339 D916 0340 D916 0244 HWM # &01 0341 D916 0342 D916 00 = NULL ;180 0343 D917 0344 D917 0245 RS8BIT # &01 0345 D917 01 = &01 ;181 1 => 8 bits, 0 => soft key processing 0346 D918 0347 D918 0348 D918 0246 FONTSW # &01 ;current state of font explosion/implosion 0349 D918 0350 D918 00 = ZERO ;182 0351 D919 ; 0352 D919 0247 SROMSW # &01 ;SEROM/cassette switch 0353 D919 0354 D919 00 = ZERO ;183 cassette by default 0355 D91A 0356 D91A 0357 D91A 0248 VPREGA # &01 ;video ULA control register 0 0358 D91A 00 = NULL ;184 0359 D91B ; 0360 D91B 0249 VPREGB # &01 ;video ULA control register 1 0361 D91B 00 = NULL ;185 0362 D91C 0363 D91C 0364 D91C 024A REPROM # &01 ;ROM id after BRK 0365 D91C 00 = NULL ;186 0366 D91D ; 0367 D91D 024B BROMID # &01 ;BASIC ROM id Acorn macro assembler Page 52 MOS32 Initialisation and external interfaces 0368 D91D FF = &FF ;187 0369 D91E 0370 D91E 0371 D91E 024C ADCHAN # &01 ;ADC channel number 0372 D91E 04 = NADC ;188 0373 D91F ; 0374 D91F 024D MAXADC # &01 ;maximum ADC channel in use 0375 D91F 04 = NADC ;189 0376 D920 ; 0377 D920 024E ADCCNV # &01 0378 D920 00 = ZERO ;190 ADC conversion type (12 bits) 0379 D921 0380 D921 0381 D921 024F RSFLAG # &01 ;RS423 use flag 0382 D921 0383 D921 ; 1xxx xxxx => dormant 0384 D921 ; 0xxx xxxx => busy 0385 D921 FF = &FF ;191 0386 D922 ; 0387 D922 0250 RSCTFL # &01 0388 D922 0389 D922 56 = RSCDEF ;192 0390 D923 0391 D923 0392 D923 ; 0393 D923 0251 FLCNT # &01 ;flash period counter 0394 D923 19 = &19 ;193 1/2 SECOND 0395 D924 ; 0396 D924 0252 FLASHB # &00 ;used by flash FX calls 0397 D924 0252 FLSPC # &01 ;flash space period 0398 D924 19 = &19 ;194 1/2 SECOND 0399 D925 0253 FLMRK # &01 ;flash mark period 0400 D925 19 = &19 ;195 1/2 SECOND 0401 D926 ; 0402 D926 0403 D926 0404 D926 ;**** FOLLOWING MUST BE CONTIGUOUS (c.f. *FX11 and *FX12) **** 0405 D926 0254 FARSET # &01 ;first auto-repeat reset 0406 D926 32 = DAUTOD ;196 0407 D927 0255 ARSET # &01 ;reset for above 0408 D927 08 = DAUTOP ;197 0409 D928 0410 D928 0411 D928 0256 EXECH # &01 ;*EXEC handle 0412 D928 0413 D928 00 = ZERO ;198 0414 D929 ; 0415 D929 0257 SPOOLH # &01 ;*SPOOL handle 0416 D929 0417 D929 00 = ZERO ;199 0418 D92A ; 0419 D92A 0258 CRIT # &01 ;critical region indicator 0420 D92A 0421 D92A 00 = &00 ;200 not within critical region 0422 D92B ; 0423 D92B 0259 NETKDS # &01 ;net keyboard disable 0424 D92B 00 = ZERO ;201 default: not disabled 0425 D92C ; 0426 D92C 025A KSTAT # &01 ;keyboard status (see MOS56) 0427 D92C 20 = SHFTL ;202 0428 D92D ; 0429 D92D 025B RSHLVL # &01 ;RS423 handshake level 0430 D92D 09 = RSOVR+&01 ;203 0431 D92E ; 0432 D92E 025C RSSHUT # &01 ;suppress RS423 input 0433 D92E 00 = ZERO ;204 default: enable RS423 input 0434 D92F ; 0435 D92F 025D RSCASS # &01 ;cassette/RS423 serial processor select 0436 D92F 00 = ZERO ;205 $00 => select RS423, $40 => select cassette 0437 D930 ; 0438 D930 025E NETIOC # &01 ;net interception of OS calls 0439 D930 00 = ZERO ;206 default: not intercepted 0440 D931 ; 0441 D931 025F NETRDC # &01 ;net interception of RDCH 0442 D931 00 = ZERO ;207 default: not intercepted 0443 D932 ; 0444 D932 0260 NETWRC # &01 ;net interception of WRCH 0445 D932 00 = ZERO ;208 default: not intercepted 0446 D933 ; 0447 D933 0261 SHUTSP # &01 ;speech suppressor 0448 D933 50 = SPOPSP ;209 0449 D934 ; 0450 D934 0262 SHUTUP # &01 ;sound suppressor 0451 D934 00 = ZERO ;210 allow sound by default 0452 D935 ; 0453 D935 0263 BELLC # &01 ;bell channel 0454 D935 03 = &03 ;211 0455 D936 ; 0456 D936 0264 BELLI # &01 ;bell envelope and chord information 0457 D936 90 = &90 ;212 0458 D937 ; 0459 D937 0265 BELLN # &01 ;bell frequency 0460 D937 64 = &64 ;213 0461 D938 ; 0462 D938 0266 BELLD # &01 ;bell duration 0463 D938 06 = &06 ;214 0464 D939 ; 0465 D939 0267 QUIET # &01 0466 D939 81 = &81 ;215 suppress start-up message / !BOOT option 0467 D93A ; 0468 D93A 0268 SOFKL # &01 ;soft key string length 0469 D93A 00 = ZERO ;216 0470 D93B ; 0471 D93B 0269 LINES # &01 ;used by VDU software 0472 D93B 0473 D93B 00 = ZERO ;217 used by VDU software in page mode 0474 D93C ; 0475 D93C 026A QPOSN # &01 ;VDU queue count 0476 D93C 0477 D93C 00 = ZERO ;218 0478 D93D ; 0479 D93D 026B TABCOD # &01 ;TAB key code 0480 D93D 09 = TAB ;219 0481 D93E ; 0482 D93E 026C INTCH # &01 0483 D93E 1B = ESC ;220 interrupt character (normally ESC) 0484 D93F ; 0485 D93F 026D SOFTLO # &00 0486 D93F ;221 softkey 10 feature 0487 D93F 026D EXBREK # &01 0488 D93F 01 = &01 ;expand softkey Acorn macro assembler Page 53 MOS32 Initialisation and external interfaces 0489 D940 ;222 reserved 0490 D940 026E # &01 0491 D940 D0 = &D0 0492 D941 ;223 reserved 0493 D941 026F # &01 0494 D941 E0 = &E0 0495 D942 ;224 reserved 0496 D942 0270 # &01 0497 D942 F0 = &F0 0498 D943 ;225 0499 D943 ; 0 => enable softkey expansion on fnkey 0500 D943 ; N => return code N+i for fnkey(i), i=0..9 0501 D943 0271 # &01 0502 D943 01 = &01 ;return soft strings by default 0503 D944 ;226 0504 D944 ; 0 => enable softkey expansion on SHIFT/fnkey 0505 D944 ; N => return code N+i for SHIFT/fnkey(i), i=0..9 0506 D944 0272 # &01 0507 D944 80 = &80 ;return codes $80..$89 by default (user definable characters) 0508 D945 ;227 0509 D945 ; 0 => enable softkey expansion on CTRL/fnkey 0510 D945 ; N => return code N+i for CTRL/fnkey(i), i=0..9 0511 D945 0273 # &01 0512 D945 90 = &90 ;return codes $90..$99 by default (user definable characters) 0513 D946 ;228 0514 D946 ; 0 => enable softkey expansion on SHIFT/CTRL/fnkey 0515 D946 ; N => return code N+i for SHIFT/CTRL/fnkey(i), i=0..9 0516 D946 0274 # &01 0517 D946 00 = ZERO ;ingnore key combination by default 0518 D947 0519 D947 0275 ESCHAR # &01 ;make INTERRUPT CHARACTER return normal value 0520 D947 00 = ZERO ;229 <>0 => return normal value 0521 D948 0522 D948 0276 EAOPT # &01 ;suppress normal escape acknowledge actions 0523 D948 00 = ZERO ;230 suppress if <> 0 0524 D949 0525 D949 0277 B6522 # &01 ;$00 => no, $FF => second 6522 present 0526 D949 FFBYT 0527 D949 FF = &FF ;231 assume 6522B present 0528 D94A 0529 D94A 0278 C6850 # &01 ;$00 => no, $FF => 6850 present 0530 D94A FF = &FF ;232 assume 6850 present 0531 D94B 0532 D94B 0279 A6522 # &01 ;$00 => no, $FF => primary 6522 present 0533 D94B FF = &FF ;233 assume 6522A present 0534 D94C 0535 D94C 027A TUBEM # &01 ;$FF if tube present 0536 D94C 027A TUBE * TUBEM 0537 D94C 00 = ZERO ;234 assume tube not present 0538 D94D 0539 D94D 027B SPFLAG # &01 ;$FF if speech chip present 0540 D94D 00 = ZERO ;235 0541 D94E 0542 D94E 027C WRCHSW # &01 ;OSWRCH destinations flag 0543 D94E 0001 WRRS * &01 ;WRCH is RS423 0544 D94E 0002 WRVDU * &02 ;WRCH is ***NOT*** VDU 0545 D94E 0004 WRPREN * &04 ;0 => ENABLE PRINT 0546 D94E 0008 WRPRNT * &08 ;WRCH is ***NOT*** print 0547 D94E 0010 WRSPL * &10 ;WRCH is ***NOT*** spool 0548 D94E 0040 WRVDU1 * &40 ;WRCH to printer only by VDU1 0549 D94E 00 = ZERO ;236 WRCH is VDU/print/spool 0550 D94F ; ******** DO NOT ALTER ******** 0551 D94F 0552 D94F 027D CURSED # &01 0553 D94F 00 = ZERO ;237 0554 D950 0555 D950 007E MPAGE2 * @-APAGE2 0556 D950 0557 D950 027E SPARE8 # &03 0558 D950 00 = ZERO 0559 D951 00 = ZERO 0560 D952 00 = ZERO 0561 D953 ; 238, 239, 240 0562 D953 0563 D953 0281 UFX1 # &01 ;FX 1 value 0564 D953 00 = ZERO ;241 0565 D954 ; ******** DO NOT ALTER ******** 0566 D954 0567 D954 0282 SPREGA # &01 ;serial processor register contents 0568 D954 0569 D954 64 = B9600 ;242 0570 D955 0571 D955 0283 TIMESW # &01 ;TIME pointer, either 5 or 10 0572 D955 05 = &05 ;243 0573 D956 0574 D956 0284 USKFLG # &01 ;soft key consistency flag 0575 D956 FF = &FF ;244 =0 => soft keys consistent 0576 D957 0577 D957 0285 PRNTSW # &01 ;PRINT destination flag 0578 D957 0001 PCEN * &01 ;print is (C)ENTRONICS 0579 D957 0002 PRS * &02 ;print is (RS)232 0580 D957 0003 PUSE * &03 ;print is (user) routine 0581 D957 0004 PNET * &04 ;print is ECO(NET) 0582 D957 01 = PCEN ;245 0583 D958 ; ******** DO NOT ALTER ******** 0584 D958 0585 D958 0286 PIGNOR # &01 ;printer ignore character 0586 D958 0A = MLF ;246 support auto-linefeed printers by default 0587 D959 ; ******** DO NOT ALTER ******** 0588 D959 0589 D959 0087 PPAGE2 * @-APAGE2 0590 D959 0591 D959 0287 BREAKI # &03 ;used for interception of BREAK 0592 D959 00 = ZERO ;247 change to $4C to intercept BREAK 0593 D95A 00 = ZERO ;248 0594 D95B 00 = ZERO ;249 0595 D95C 0596 D95C 028A SPARE9 # &02 ;spare 0597 D95C 00 = ZERO ;250 0598 D95D 00 = ZERO ;251 0599 D95E 0600 D95E 028C LROMID # &01 ;current language ROM id 0601 D95E FF = &FF ;252 0602 D95F 0603 D95F 008D NPAGE2 * @-APAGE2 0604 D95F 0605 D95F 028D TYPE # &01 ;restart type 0606 D95F ;= ZERO ;253 0607 D95F 0608 D95F 028E MODELB # &01 0609 D95F 028E MODEL * MODELB Acorn macro assembler Page 54 MOS32 Initialisation and external interfaces 0610 D95F ;= ZERO ;254 0611 D95F 0612 D95F 028F OPTION # &01 ;start up options 0613 D95F ;= ZERO ;255 0614 D95F 0615 D95F 0190 VBASE * @-&100 0616 D95F 00A6 VORG * VARS-VBASE 0617 D95F [ VARS-VBASE- 166=0 0618 D95F | 0620 D95F ] 0621 D95F ; 0622 D95F 0623 D95F 0290 DPAGE2 # &00 0624 D95F 0625 D95F 0290 VERTIC # &01 ;VDU vertical adjust 0626 D95F 0627 D95F ;= ZERO 0628 D95F 0629 D95F 0291 INTERL # &01 ;interlace invert 0630 D95F 0631 D95F ;= ZERO 0632 D95F 0633 D95F ; time 0634 D95F 0292 TIME1 # &05 ;first absolute time counter 0635 D95F 0292 TIME * TIME1 0636 D95F ;= ZERO 0637 D95F ;= ZERO 0638 D95F ;= ZERO 0639 D95F ;= ZERO 0640 D95F ;= ZERO 0641 D95F 0297 TIME2 # &05 ;second absolute time counter 0642 D95F ;= ZERO 0643 D95F ;= ZERO 0644 D95F ;= ZERO 0645 D95F ;= ZERO 0646 D95F ;= ZERO 0647 D95F ; N.B. soft restart zeroes from here onwards 0648 D95F 029C STPW # &05 ;stopwatch counter 0649 D95F 029C CPAGE2 * STPW 0650 D95F ;= ZERO 0651 D95F ;= ZERO 0652 D95F ;= ZERO 0653 D95F ;= ZERO 0654 D95F ;= ZERO 0655 D95F 0656 D95F 02A1 ROMS # NROM 0657 D95F 0658 D95F ;= ZERO (NROM times) 0659 D95F 0660 D95F ; work slots used by CLI 0661 D95F 02B1 RDCTLO # &01 ;INKEY wait counter 1 0662 D95F ;= ZERO 0663 D95F 02B2 RDCTHI # &01 ;INKEY wait counter 2 0664 D95F ;= ZERO 0665 D95F 0666 D95F ; work slots used by RDLN 0667 D95F ; values must not be altered by any sei-routine 0668 D95F 02B3 RDLNN # &01 0669 D95F ;= NULL 0670 D95F 02B4 RDLNLC # &01 0671 D95F ;= NULL 0672 D95F 02B5 RDLNHC # &01 0673 D95F ;= NULL 0674 D95F 0675 D95F ; ADC control 0676 D95F ; may not be shared 0677 D95F 02B6 ADCLOV # NADC ;ADC lo byte values (0 to 3) 0678 D95F ;= ZERO 0679 D95F ;= ZERO 0680 D95F ;= ZERO 0681 D95F ;= ZERO 0682 D95F 02BA ADCHIV # NADC ;ADC hi byte values (0 to 3) 0683 D95F ;= ZERO 0684 D95F ;= ZERO 0685 D95F ;= ZERO 0686 D95F ;= ZERO 0687 D95F 02BE ADCFLG # &01 0688 D95F ;= ZERO 0689 D95F 0690 D95F ; event interrupt vectors 0691 D95F 000A NEVENT * &000A ;total number of events 0692 D95F 02BF EVENTS # NEVENT ;event flags 0693 D95F 0000 EVMPTY * &00 ;output buffer empty 0694 D95F ;= ZERO 0695 D95F 0001 EVFULL * &01 ;input buffer full 0696 D95F ;= ZERO 0697 D95F 0002 EVKYBD * &02 ;keyboard interrupt 0698 D95F ;= ZERO 0699 D95F 0003 EVADC * &03 ;ADC conversion complete 0700 D95F ;= ZERO 0701 D95F 0004 EVVSYN * &04 ;VSYNC 0702 D95F ;= ZERO 0703 D95F 0005 EVSWCH * &05 ;(timer) stopwatch 0704 D95F ;= ZERO 0705 D95F 0006 EVESC * &06 ;escape detected 0706 D95F ;= ZERO 0707 D95F 0007 EVRS * &07 ;RS423 Rx error 0708 D95F ;= ZERO 0709 D95F 0008 EVUSER * &08 ;user allocated event 0710 D95F ;= ZERO 0711 D95F 0712 D95F ; miscellaneous 0713 D95F 02C9 SOFKP # &01 ;pointer to soft key string 0714 D95F ;= NULL 0715 D95F ; 0716 D95F 02CA FARCTR # &01 ;first auto-repeat count 0717 D95F ;= NULL 0718 D95F 0719 D95F 02CB KSCSTA # &03 ;keyboard scan start address work vector 0720 D95F ;= NULL 0721 D95F 0722 D95F ; values to be initialised to $FF 0723 D95F 02CE FFBYTE # &00 0724 D95F ; 0725 D95F 02CE SSEMA # &01 ;sound semaphore 0726 D95F ; 0727 D95F ; buffer activity flags 0728 D95F 02CF BACTIV # &00 0729 D95F 02CF DUMMY # 3 ;Not used - necessary for padding (see PURGE) 0730 D95F 02D2 PFLAG # &01 ;print flag 0731 D95F ; 1xxx xxxx => dormant Acorn macro assembler Page 55 MOS32 Initialisation and external interfaces 0732 D95F ; 0xxx xxxx => busy 0733 D95F 02D3 SFLUSH # &04 ;sound flush flags 0734 D95F 02D7 SPSTAT # &01 ;speech processor status 0735 D95F ; 0736 D95F ; buffer control 0737 D95F ; buffer start page offsets 0738 D95F 02D8 BFSTRT # BUPB+&01 0739 D95F ; buffer end page offsets 0740 D95F 02E1 BFEND # BUPB+&01 0741 D95F ; 0742 D95F 02EA CFSA # &03 0743 D95F 0744 D95F ; 0745 D95F 02ED CFSD # &01 0746 D95F 0747 D95F 02EE FBLOCK # &12 ;load/save control block 0748 D95F 0000 FSTR * &0000 ;pointer to filename (2 bytes) 0749 D95F 0002 FLOAD * &0002 ;load address (4 bytes) 0750 D95F 0006 FEXEC * &0006 ;execute address (4 bytes) 0751 D95F 000A FFROM * &000A ;from address (4 bytes) 0752 D95F 000E FTO * &000E ;to address (4 bytes) 0753 D95F ;= 18*NULL 0754 D95F 0755 D95F 0300 ZPAGE2 # &00 0756 D95F 0757 D95F LNK MOS34 0001 D95F 0002 D95F ; MOS34 0003 D95F TTL MOS34 Initialisation 0004 D95F OPT MOS34 Acorn macro assembler Page 56 MOS34 Initialisation 0005 D95F 0006 D95F ;(c) 1981 ACORN Computers Limited 0007 D95F ;BBC Microcomputer MOS 0008 D95F 0009 D95F ;Change record: 0010 D95F ;100 15-Apr-82 PB Use PCEN=1 0011 D95F ;039 15-Aug-81 PB Start of change to PROTON interface 0012 D95F ;004 29-Jul-81 MP Prototype version 0013 D95F 0014 D95F ;Author(s): 0015 D95F ;PB Paul Bond 0016 D95F ;MP Mike Prees 0017 D95F TTL Entry point after hardware break/reset 0018 D95F OPT OPNEWP Acorn macro assembler Page 57 Entry point after hardware break/reset 0019 D95F 0020 D95F 0021 D95F MRESET ;entered here after reset 0022 D95F 0023 D95F ; ensure NMIs are ignored as sson as possible 0024 D95F ; 0025 D95F A9 40 LDAIM &40 ;A := RTI opcode 0026 D961 8D 00 0D STA NMI 0027 D964 0028 D964 ; ensure interrupts disabled (useful for JMP -4 freaks) 0029 D964 ; 0030 D964 78 SEI 0031 D965 0032 D965 ; clear decimal mode 0033 D965 ; 0034 D965 D8 CLD 0035 D966 0036 D966 ; reset stack 0037 D966 ; 0038 D966 A2 FF LDXIM &FF 0039 D968 9A TXS 0040 D969 0041 D969 ; push hard reset status 0042 D969 ; 0043 D969 AD 4E FE LDA IERQ 0044 D96C 0A ASLA 0045 D96D 48 PHA ;A=0 => hard, A<>0 => soft 0046 D96E F0 09 BEQ HRDRST ;[hard reset, A=0] 0047 D970 ; 0048 D970 ; prepare for possible soft reset 0049 D970 ; 0050 D970 ; check for critical region 0051 D970 ; 0052 D970 AD 58 02 LDA CRIT 0053 D973 4A LSRA 0054 D974 C9 01 CMPIM &01 0055 D976 D0 38 BNE SFTRST ;[not within a critical region] 0056 D978 ; A=1 0057 D978 4A LSRA 0058 D979 ; A=0 0059 D979 ; 0060 D979 ; within a critical region - clear store 0061 D979 ; 0062 D979 HRDRST ;hard reset 0063 D979 ; A=0 0064 D979 ; hard reset 0065 D979 ; clear store 0066 D979 [ MOS125 = &FF 0092 D979 ] 0093 D979 0094 D979 [ MOS125 = &7F 0095 D979 A2 04 LDXIM &04 ;start clearing at page 4 0096 D97B A8 TAY ;Y := 0 0097 D97C 85 00 STA &0000 0098 D97E CLRPG 0099 D97E 86 01 STX &0001 0100 D980 C8 INY 0101 D981 91 00 STAIY &0000 ;saves 163 ms 0102 D983 E4 01 CPX &0001 0103 D985 D0 23 BNE CLEAR0 ;[16K RAM] 0104 D987 E8 INX 0105 D988 E0 0D CPXIM /(NMI ) 0106 D98A 85 F2 STA WORK 0107 D98C 86 F3 STX WORK+1 0108 D98E F0 06 BEQ CLEARA ;leave RTI in place 0109 D990 88 DEY ;otherwise Y=0 0110 D991 0111 D991 ; clear store to $00 (no blobs on screen) 0112 D991 ; done: 0000 even . 0 . . 0113 D991 ; X WORK odd x . . . 0114 D991 ; Y 0115 D991 CLEAR 0116 D991 91 F2 STAIY WORK ;saves 4 ms 0117 D993 C8 INY ;1 0118 D994 91 00 STAIY &0000 0119 D996 CLEARA 0120 D996 91 F2 STAIY WORK ;saves 4 ms 0121 D998 C8 INY ;2 0122 D999 91 00 STAIY &0000 ;saves 24 ms 0123 D99B 91 F2 STAIY WORK ;saves 4 ms 0124 D99D C8 INY ;3 0125 D99E 91 00 STAIY &0000 ;saves 8 ms 0126 D9A0 91 F2 STAIY WORK ;saves 4 ms 0127 D9A2 C8 INY ;0 0128 D9A3 91 00 STAIY &0000 ;saves 4 ms 0129 D9A5 D0 EA BNE CLEAR 0130 D9A7 E8 INX 0131 D9A8 10 D4 BPL CLRPG 0132 D9AA ; 32K RAM 0133 D9AA ; 0134 D9AA CLEAR0 0135 D9AA ; $0001 = $80 (model B) or $40 (model A) 0136 D9AA 8E 8E 02 STX MODELB 0137 D9AD ; 0138 D9AD ; force soft keys reset 0139 D9AD 8E 84 02 STX USKFLG ;USKFLG := non-zero 0140 D9B0 ] 0141 D9B0 0142 D9B0 [ MOS125 = &00 0169 D9B0 ] 0170 D9B0 0171 D9B0 ; 0172 D9B0 SFTRST 0173 D9B0 ; 0174 D9B0 ; initialise addressable latch outputs hi 0175 D9B0 ; 0176 D9B0 A2 0F LDXIM &0F ;for latch driving 0177 D9B2 8E 42 FE STX DDRBQ ;set PB3-PB0 as outputs to drive addressable latch 0178 D9B5 ; 0179 D9B5 IALTCH 0180 D9B5 CA DEX 0181 D9B6 8E 40 FE STX PBQ ;first store value = $0E, last store value = $08 0182 D9B9 E0 09 CPXIM &09 0183 D9BB B0 F8 BCS IALTCH 0184 D9BD ; fall thru when X=$08 0185 D9BD 0186 D9BD 0187 D9BD ; check for hard restart 0188 D9BD ; 0189 D9BD ; read start-up options 0190 D9BD ; Acorn macro assembler Page 58 Entry point after hardware break/reset 0191 D9BD E8 INX ;X := $09, scan down from last start-up option 0192 D9BE ; 0193 D9BE RDOPT1 0194 D9BE 8A TXA ;save X in A 0195 D9BF 20 39 F0 JSR KC ;read state of matrix element addressed by X (A maintained) 0196 D9C2 ; 0197 D9C2 ; N.B. does not corrupt A 0198 D9C2 ; 0199 D9C2 E0 80 CPXIM &80 ;C=0 => option open, C=1 => option closed 0200 D9C4 66 FC ROR TEMPA ;rotate state of start-up option into TEMPA byte 0201 D9C6 AA TAX ;restore X 0202 D9C7 CA DEX 0203 D9C8 D0 F4 BNE RDOPT1 ;execute loop 9 times 0204 D9CA ; 0205 D9CA ; N.B. exits with X=0, SHIFT key has not been scanned 0206 D9CA ; state of CTRL key has been rotated into TEMPA 0207 D9CA ; 0208 D9CA 8E 8D 02 STX TYPE ;restart type := 0 0209 D9CD 26 FC ROL TEMPA ;C = state of CTRL key, TEMPA = start-up options 0210 D9CF 20 04 EF JSR KBDIS ;disable keyboard (and resume hardware scan) 0211 D9D2 ; 0212 D9D2 6A RORA ;C=1 => CTRL pressed (KBDIS does PHP ... PLA) 0213 D9D3 ; 0214 D9D3 A2 9C LDXIM CPAGE2 ;(do not set to reset timer if soft restart) 0215 D9D5 A0 8D LDYIM NPAGE2 ;reset BREAKI if power up 0216 D9D7 68 PLA ;pull hard restart status 0217 D9D8 F0 09 BEQ POWER ;[power up] 0218 D9DA ; 0219 D9DA A0 7E LDYIM MPAGE2 ;prepare for BREAK 0220 D9DC 90 11 BCC SOFT ;[CTRL not pressed - force soft reset, b1b0(TYPE) := 0] 0221 D9DE ; 0222 D9DE ; b1b0(TYPE) := 2 0223 D9DE ; 0224 D9DE A0 87 LDYIM PPAGE2 ;CTRL/BREAK 0225 D9E0 EE 8D 02 INC TYPE 0226 D9E3 ; 0227 D9E3 POWER ;power up, b1b0(TYPE) := 1 0228 D9E3 ;HARD ;hard restart 0229 D9E3 EE 8D 02 INC TYPE 0230 D9E6 ; 0231 D9E6 ; initialise OPTION 0232 D9E6 ; 0233 D9E6 A5 FC LDA TEMPA 0234 D9E8 49 FF EORIM &FF ;invert VDU mode selection 0235 D9EA 8D 8F 02 STA OPTION 0236 D9ED ; 0237 D9ED A2 90 LDXIM DPAGE2 ;set to reset timer 0238 D9EF 0239 D9EF 0240 D9EF SOFT 0241 D9EF ; initialise other page two locations to zero/$FF 0242 D9EF ; N.B. X has been set to an appropriate value 0243 D9EF A9 00 LDAIM ZERO 0244 D9F1 IP0SX 0245 D9F1 E0 CE CPXIM FFBYTE 0246 D9F3 [ MOS125 = &FF 0249 D9F3 | 0250 D9F3 D0 07 BNE Z0BYTE 0251 D9F5 A9 FF LDAIM &FF 0252 D9F7 8D CE 02 STA SSEMA 0253 D9FA A2 D2 LDXIM PFLAG 0254 D9FC ] 0255 D9FC Z0BYTE 0256 D9FC 9D 00 02 STAAX &0200 0257 D9FF E8 INX 0258 DA00 D0 EF BNE IP0SX 0259 DA02 ; N.B. A=$FF, X=0 0260 DA02 8D 63 FE STA DDRAR ;set all outputs on printer data direction register (6522B) 0261 DA05 0262 DA05 0263 DA05 ; initialise page zero locations to zero 0264 DA05 ; 0265 DA05 8A TXA ;A := 0 0266 DA06 A2 E2 LDXIM BPAGE0 0267 DA08 IP0SW 0268 DA08 95 00 STAAX ZERO 0269 DA0A E8 INX 0270 DA0B D0 FB BNE IP0SW 0271 DA0D ; X=0 0272 DA0D 0273 DA0D 0274 DA0D ; initialise page two specific values 0275 DA0D ; 0276 DA0D IP2SV 0277 DA0D B9 D1 D8 LDAAY IPAGE2 -&01 0278 DA10 99 FF 01 STAAY APAGE2 -&01 0279 DA13 88 DEY 0280 DA14 D0 F7 BNE IP2SV 0281 DA16 ; Y=0 0282 DA16 0283 DA16 0284 DA16 ; make old key space in case CFS auto-boot selected 0285 DA16 ; 0286 DA16 A9 62 LDAIM &62 0287 DA18 85 ED STA OKEY 0288 DA1A ; X=0, Y=0 0289 DA1A 0290 DA1A 0291 DA1A ; setup MC6850 0292 DA1A ; 0293 DA1A 20 FD FA JSR MC6850 ;N.B. does not corrupt X or Y 0294 DA1D ; X=0, Y=0 0295 DA1D 0296 DA1D 0297 DA1D ; clear any 6522 interrupt status 0298 DA1D ; 0299 DA1D A9 7F LDAIM &7F 0300 DA1F E8 INX ;X=1 0301 DA20 IFRIER ;X=1 initialises IERQ&IERR, X=0 initialises IFRQ&IFRR 0302 DA20 9D 4D FE STAAX IFRQ 0303 DA23 9D 6D FE STAAX IFRR 0304 DA26 CA DEX 0305 DA27 10 F7 BPL IFRIER ;[execute loop once more with X=0] 0306 DA29 ; X=$FF 0307 DA29 ; 0308 DA29 [ FALSE=0 0311 DA29 ] 0312 DA29 0313 DA29 ; TEMPA is now 0 0314 DA29 ; if an interrupt occurs it will adopt the value $7F 0315 DA29 ; Acorn macro assembler Page 59 Entry point after hardware break/reset 0316 DA29 ; allow test equipment to interrupt if present 0317 DA29 ; 0318 DA29 58 CLI 0319 DA2A ; ** TEST EQUIPMENT INTERRUPT MAY OCCUR HERE ** 0320 DA2A 78 SEI 0321 DA2B ; 0322 DA2B 24 FC BIT TEMPA 0323 DA2D 50 03 BVC NOTST1 0324 DA2F ; C=0 0325 DA2F 20 64 F0 JSR JMITST ;enter test routine (first call) 0326 DA32 NOTST1 0327 DA32 0328 DA32 0329 DA32 [ FALSE=0 0348 DA32 ] 0349 DA32 0350 DA32 0351 DA32 ; initialise 6522s 0352 DA32 ; 0353 DA32 A2 F2 LDXIM &F2 ;enable TIMER1(clock,40), TIMER2(speech,20) 0354 DA34 ; CB1(ADC,10), CA1(VSYNC,02) and NOT[CA2(keyboard,01)] 0355 DA34 8E 4E FE STX IERQ 0356 DA37 0357 DA37 0358 DA37 ; initialise peripheral control register 0359 DA37 ; 0360 DA37 A2 04 LDXIM &04 0361 DA39 8E 4C FE STX PCRQ ;select CA2 positive active edge 0362 DA3C 0363 DA3C 0364 DA3C ; setup centisecond timer 0365 DA3C ; 0366 DA3C A9 60 LDAIM &60 ;TIMER1 continuous, TIMER2 count pulses on PB6 0367 DA3E 8D 4B FE STA ACRQ 0368 DA41 0369 DA41 0370 DA41 ; N.B. ACRR zeroed by reset 0371 DA41 ; 0372 DA41 ; set timer hi-byte 0373 DA41 ; 0374 DA41 A9 0E LDAIM &0E ;timer 1 period = 998 usec 0375 DA43 8D 46 FE STA TQLLQ 0376 DA46 8D 6C FE STA PCRR ;set CA2 hi (for printer) 0377 DA49 ; 0378 DA49 ; start conversion on analog/digital chip 0379 DA49 ; 0380 DA49 8D C0 FE STA ADCCTL ;12 bits from chip channel 2 0381 DA4C 0382 DA4C 0383 DA4C ; check whether 6522B present 0384 DA4C ; 0385 DA4C CD 6C FE CMP PCRR 0386 DA4F F0 03 BEQ B6522E ;[6522B exists] 0387 DA51 ; 0388 DA51 ; 6522B does not exist 0389 DA51 ; 0390 DA51 EE 77 02 INC B6522 ;B6522 := $00 0391 DA54 B6522E 0392 DA54 ; 0393 DA54 ; set timer lo-byte 0394 DA54 ; 0395 DA54 A9 27 LDAIM &27 0396 DA56 8D 47 FE STA TQLHQ 0397 DA59 8D 45 FE STA TQCHQ 0398 DA5C 0399 DA5C 0400 DA5C ; kill sound 0401 DA5C ; 0402 DA5C 20 86 EC JSR SNDRST 0403 DA5F 0404 DA5F 0405 DA5F ; ensure motor off 0406 DA5F ; reinitialise serproc 0407 DA5F ; 0408 DA5F AD 82 02 LDA SPREGA 0409 DA62 29 7F ANDIM &7F 0410 DA64 20 E9 E6 JSR STASP ;STA SPREGA, STA SERPRC 0411 DA67 ; X, Y corrupted 0412 DA67 0413 DA67 0414 DA67 ; conditionally reset soft keys 0415 DA67 ; soft keys are reset 0416 DA67 ; (a) after a hard reset 0417 DA67 ; (b) if reset occurred during a critical update of the soft keys 0418 DA67 ; 0419 DA67 AE 84 02 LDX USKFLG 0420 DA6A F0 03 BEQ SKOK 0421 DA6C 20 CD E9 JSR RSOFT ;reset soft keys, sets X=0 0422 DA6F SKOK 0423 DA6F ; X=0 0424 DA6F 0425 DA6F 0426 DA6F ; compare ROMs 0427 DA6F ; 0428 DA6F CRX 0429 DA6F 20 DB DB JSR STXROM ;select ROM 0430 DA72 ; 0431 DA72 ; check for copyright string 0432 DA72 ; 0433 DA72 A2 03 LDXIM &03 0434 DA74 AC 07 80 LDY COPYRP 0435 DA77 CRCPYR 0436 DA77 B9 00 80 LDAAY LANG 0437 DA7A DD 29 F5 CMPAX COPYR 0438 DA7D D0 2E BNE CRBAD 0439 DA7F C8 INY 0440 DA80 CA DEX 0441 DA81 10 F4 BPL CRCPYR 0442 DA83 ; 0443 DA83 ; ROM has copyright string 0444 DA83 ; 0445 DA83 A6 F4 LDX ROMID 0446 DA85 A4 F4 LDY ROMID 0447 DA87 CRY 0448 DA87 C8 INY 0449 DA88 C0 10 CPYIM NROM 0450 DA8A B0 25 BCS CRNX ;[Y > number of ROMs] 0451 DA8C 98 TYA 0452 DA8D 49 FF EORIM &FF 0453 DA8F 85 FA STA CRLO 0454 DA91 A9 7F LDAIM &7F ;N.B. this is LANG / - 1 Acorn macro assembler Page 60 Entry point after hardware break/reset 0455 DA93 85 FB STA CRHI 0456 DA95 CRLOOP 0457 DA95 8C 30 FE STY ROM ;select second (Y) ROM 0458 DA98 B1 FA LDAIY CRLO 0459 DA9A 8E 30 FE STX ROM ;select first (X) ROM 0460 DA9D D1 FA CMPIY CRLO 0461 DA9F D0 E6 BNE CRY ;[ROMs do not match] 0462 DAA1 E6 FA INC CRLO 0463 DAA3 D0 F0 BNE CRLOOP 0464 DAA5 E6 FB INC CRHI 0465 DAA7 A5 FB LDA CRHI 0466 DAA9 C9 84 CMPIM &84 ;compare only first 1K of ROMs 0467 DAAB 90 E8 BCC CRLOOP 0468 DAAD ; ROMs match 0469 DAAD CRBAD 0470 DAAD A6 F4 LDX ROMID 0471 DAAF 10 0D BPL CRNX1 ;[ALWAYS jump] 0472 DAB1 ; NEVER fall thru 0473 DAB1 ; 0474 DAB1 CRNX 0475 DAB1 AD 06 80 LDA ROMTYP 0476 DAB4 9D A1 02 STAAX ROMS ;store type of recognised ROM 0477 DAB7 ; check for BASIC ROM 0478 DAB7 ;***** N.B. WHITE BASIC MAY NEED 'ANDIM $FE' ***** 0479 DAB7 29 8F ANDIM &8F 0480 DAB9 D0 03 BNE CRNX1 ;[not a BASIC ROM] 0481 DABB ; BASIC ROM - remember ROM id for *BASIC command 0482 DABB 8E 4B 02 STX BROMID 0483 DABE CRNX1 0484 DABE E8 INX 0485 DABF E0 10 CPXIM NROM 0486 DAC1 90 AC BCC CRX ;[X a valid ROM number] 0487 DAC3 0488 DAC3 [ NOSP = &00 0490 DAC3 | 0491 DAC3 ; X=NROM 0492 DAC3 ; 0493 DAC3 ; if speech chip ready is still high then the chip has not been fitted 0494 DAC3 ; 0495 DAC3 2C 40 FE BIT PBQ 0496 DAC6 30 11 BMI START1 ;[chip does not exist] 0497 DAC8 ; X=NROM 0498 DAC8 ; speech chip present 0499 DAC8 ; 0500 DAC8 CE 7B 02 DEC SPFLAG ;SPFLAG := $FF 0501 DACB ; X=NROM 0502 DACB ; reset speech processor 0503 DACB ; 0504 DACB ; write NROM * $FF (reset) to speech processor 0505 DACB SPRST1 0506 DACB A0 FF LDYIM SPOPRT 0507 DACD 20 9B EE JSR WSPECH ;N.B. corrupts A and Y 0508 DAD0 CA DEX 0509 DAD1 D0 F8 BNE SPRST1 0510 DAD3 ; X=0 0511 DAD3 ; 0512 DAD3 8E 48 FE STX TRCLQ 0513 DAD6 8E 49 FE STX TRCHQ ;enable interrupt after one negative pulse on PB6 (speech int) 0514 DAD9 ] 0515 DAD9 0516 DAD9 START1 0517 DAD9 0518 DAD9 0519 DAD9 AD 8F 02 LDA OPTION ;initialise graphics mode from start-up options 0520 DADC 20 00 C3 JSR VDINIT ;initialise VDU module 0521 DADF 0522 DADF 0523 DADF ; set up reset soft key (fA) 0524 DADF ; 0525 DADF A0 CA LDYIM BREKEY 0526 DAE1 20 34 E5 JSR RDCHS ;set to expand softkeyA immediately 0527 DAE4 ; C=0 cos buffer empty 0528 DAE4 ; 0529 DAE4 ; let user intercept BREAK 0530 DAE4 ; 0531 DAE4 ; C=0 0532 DAE4 20 25 EB JSR BREAK 0533 DAE7 ; 0534 DAE7 ; initialise CFS state 0535 DAE7 ; 0536 DAE7 20 4C F1 JSR INIT 0537 DAEA ; 0538 DAEA ; check for tube 0539 DAEA ; 0540 DAEA A9 81 LDAIM &81 0541 DAEC 8D E0 FE STA TREG0 0542 DAEF AD E0 FE LDA TREG0 0543 DAF2 6A RORA 0544 DAF3 90 0A BCC NOTUBE ;[tube not present] 0545 DAF5 ; 0546 DAF5 ; tube present 0547 DAF5 ; 0548 DAF5 A2 FF LDXIM SVTUBE 0549 DAF7 20 74 F1 JSR SVOP ;initialise tube 0550 DAFA D0 03 BNE NOTUBE ;[tube software not present] 0551 DAFC CE 7A 02 DEC TUBEM ;TUBEM := $FF 0552 DAFF NOTUBE 0553 DAFF ; 0554 DAFF ; initialise service ROMs before writing to screen 0555 DAFF ; 0556 DAFF A0 0E LDYIM /(OSHWM ) ;Y := default high water mark 0557 DB01 ; 0558 DB01 A2 01 LDXIM SVSTAT ;offer static area 0559 DB03 20 74 F1 JSR SVOP 0560 DB06 ; 0561 DB06 A2 02 LDXIM SVDYN ;offer dynamic area 0562 DB08 20 74 F1 JSR SVOP 0563 DB0B ; 0564 DB0B 8C 43 02 STY IHWM ;save adjusted high water mark 0565 DB0E 8C 44 02 STY HWM ;save adjusted high water mark 0566 DB11 ; 0567 DB11 ; allow tube post-initialisation (e.g. exploding font) 0568 DB11 ; 0569 DB11 A2 FE LDXIM SVTPIN ;******** ASSUMED = $FE ******** 0570 DB13 AC 7A 02 LDY TUBEM ;pass tube flag as argument 0571 DB16 20 74 F1 JSR SVOP 0572 DB19 ; A=$00 (tube present) 0573 DB19 ; A=$FF (tube not present) 0574 DB19 ; 0575 DB19 ; conditionally output start-up message 0576 DB19 ; 'BBC Computer' Acorn macro assembler Page 61 Entry point after hardware break/reset 0577 DB19 ; 0578 DB19 2D 67 02 AND QUIET ;may be set by paged ROM 0579 DB1C 10 1B BPL ENTER ;[shshh ... you know who] 0580 DB1E ; 0581 DB1E ; output start up message 0582 DB1E ; 0583 DB1E A0 02 LDYIM MSGBBC-&01 0584 DB20 20 55 DE JSR WRSTR 0585 DB23 ; 0586 DB23 ; indicate model type 0587 DB23 ; 0588 DB23 AD 8D 02 LDA TYPE 0589 DB26 F0 0C BEQ Z ;[soft restart] 0590 DB28 ; 0591 DB28 ; hard restart 0592 DB28 ; complete message 0593 DB28 ; 0594 DB28 A0 16 LDYIM MSG32K-&01 0595 DB2A 2C 8E 02 BIT MODELB 0596 DB2D 30 02 BMI B ;[model B] 0597 DB2F ; 0598 DB2F ; model A 0599 DB2F ; 0600 DB2F A0 11 LDYIM MSG16K-&01 0601 DB31 B 0602 DB31 20 55 DE JSR WRSTR 0603 DB34 Z 0604 DB34 A0 1B LDYIM MSG2CR-&01 0605 DB36 20 55 DE JSR WRSTR 0606 DB39 ; 0607 DB39 ENTER ;initialise TAPE/DISC 0608 DB39 ; 0609 DB39 ; let user intercept BREAK after filing system initialisation 0610 DB39 ; 0611 DB39 38 SEC 0612 DB3A 20 25 EB JSR BREAK 0613 DB3D ; 0614 DB3D ; service ROMs again 0615 DB3D ; test for auto-boot condition (SHIFT and startup option bit3) 0616 DB3D ; 0617 DB3D 20 DE E9 JSR MOSTST ;test shift 0618 DB40 [ MOS125 = &FF 0621 DB40 | 0622 DB40 ;Slightly iffy using A directly as no other callers of MOSTST do 0623 DB40 ;however MOSTST always returns SHIFT state in both N and A b7 0624 DB40 ] 0625 DB40 4A LSRA 0626 DB41 4A LSRA 0627 DB42 4A LSRA 0628 DB43 4A LSRA 0629 DB44 4D 8F 02 EOR OPTION 0630 DB47 29 08 ANDIM &08 ;use bit3 0631 DB49 A8 TAY ;Y=0 => auto-boot, Y<>0 => do not auto-boot 0632 DB4A A2 03 LDXIM SVBOOT ;offer bootstrap 0633 DB4C 20 74 F1 JSR SVOP 0634 DB4F F0 30 BEQ SLANG ;[file system booted] 0635 DB51 ; 0636 DB51 ; file system not booted - try to auto-boot from SEROM 0637 DB51 ; 0638 DB51 98 TYA 0639 DB52 D0 27 BNE NOAUTO ;[do not auto boot] 0640 DB54 ; 0641 DB54 ; auto-boot from SEROM 0642 DB54 ; 0643 DB54 A9 8D LDAIM FXSROM 0644 DB56 20 41 F1 JSR CROM ;'*ROM' 0645 DB59 A2 1E LDXIM SLBOOT 0646 DB5B A0 EB LDYIM /(SLBOOT ) 0647 DB5D CE 67 02 DEC QUIET ;flag as loading auto-boot program 0648 DB60 20 F7 FF JSR OSCLI ;'/!BOOT' 0649 DB63 EE 67 02 INC QUIET ;flag as not loading auto-boot program 0650 DB66 ; if an error occurs whilst running the !BOOT program 0651 DB66 ; then the MOS jumps to EBRK (early BRK) 0652 DB66 D0 19 BNE DNRFS ;[ALWAYS jump, do not reset filing system] 0653 DB68 ; 0654 DB68 [ MOS125 = &FF 0655 DB68 | 0656 DB68 ;Restoring OS 1.20 behaviour: 0657 DB68 ;*FX215,0 by early birds (or *FX215,255 by RFS !BOOT) 0658 DB68 ;forces *TAPE12 on successful completion of RFS !BOOT 0659 DB68 ;with no error message printed 0660 DB68 F0 11 BEQ NOAUTO 0661 DB6A ;NEVER fall through 0662 DB6A 0663 DB6A DEFBRK ;default BRK routine outputs error message 0664 DB6A ; assume still decimal mode 0665 DB6A A0 00 LDYIM ZERO 0666 DB6C 20 5D DE JSR WRSTR1 ;output error message 0667 DB6F ; check whether within auto-boot program 0668 DB6F AD 67 02 LDA QUIET 0669 DB72 6A RORA 0670 DB73 STOP 0671 DB73 B0 FE BCS STOP ;hang if not within auto-boot program 0672 DB75 20 E7 FF JSR OSNEWL 0673 DB78 20 E7 FF JSR OSNEWL ;place 2*CR/LF after error message 0674 DB7B ;fall through 0675 DB7B ] 0676 DB7B 0677 DB7B NOAUTO 0678 DB7B EBRK ;unexpected (early) BRK (e.g. 'File not found') 0679 DB7B ; 0680 DB7B ; initialise cassette filing system (CFS) 0681 DB7B ; 0682 DB7B A9 00 LDAIM ZERO ;select CFS 0683 DB7D AA TAX ;X:=0, select default baudrate (1200 baud) 0684 DB7E 20 43 F1 JSR TAPE12 ;initialise CFS 0685 DB81 ; 0686 DB81 DNRFS ;do not reset filing system 0687 DB81 ; 0688 DB81 SLANG ;select a language ROM to enter 0689 DB81 AD 8D 02 LDA TYPE 0690 DB84 D0 05 BNE SLANG1 ;[hard restart - use same language as last time] 0691 DB86 ; 0692 DB86 ; soft restart - ensure language exists 0693 DB86 ; A b0=0 used by ILR2 enter ROM with C=0 0694 DB86 ; 0695 DB86 AE 8C 02 LDX LROMID 0696 DB89 10 1E BPL ILR2 ;[language does exist] 0697 DB8B ; 0698 DB8B SLANG1 ;find first language ROM 0699 DB8B ; Acorn macro assembler Page 62 Entry point after hardware break/reset 0700 DB8B A2 0F LDXIM NROM-&1 0701 DB8D ILR1 0702 DB8D BD A1 02 LDAAX ROMS 0703 DB90 [ MOS125 = &FF 0705 DB90 | 0706 DB90 0A ASLA ;b0=0 used by ILR2 enter ROM with C=0 0707 DB91 ] 0708 DB91 30 16 BMI ILR2 ;[found language ROM] 0709 DB93 ; 0710 DB93 CA DEX 0711 DB94 10 F7 BPL ILR1 ;[continue search for language ROM] 0712 DB96 ; 0713 DB96 A9 00 LDAIM LGNONE 0714 DB98 2C 7A 02 BIT TUBEM 0715 DB9B 30 30 BMI TLANG ;[tube active] 0716 DB9D ; neither language nor tube present 0717 DB9D 00 BRK 0718 DB9E F9 = NOLROM 0719 DB9F 4C 61 6E = "Language?" 0720 DBA8 00 = ZERO 0721 DBA9 ; 0722 DBA9 [ MOS125 = &FF 0725 DBA9 | 0726 DBA9 ILR2 ;*BASIC enters with A b0=1 indicate manual entry 0727 DBA9 4A LSRA ;C=0 indicate to tube that this is a restart 0728 DBAA ] 0729 DBAA SELANG ;FX entry point, entered with C=1 (for tube) 0730 DBAA ; found language ROM 0731 DBAA ; select language ROM 0732 DBAA 08 PHP ;save entry type (present in C) 0733 DBAB [ MOS125 = &FF 0735 DBAB ] 0736 DBAB 20 DB DB JSR STXROM 0737 DBAE ; output ROM message 0738 DBAE A9 80 LDAIM /(LANG ) 0739 DBB0 A0 08 LDYIM ROMMSG-&1 0740 DBB2 20 57 DE JSR WRSTRA 0741 DBB5 ; N.B. Y offset left pointing to copyright message 0742 DBB5 84 FD STY REPTR +&00 0743 DBB7 20 E7 FF JSR OSNEWL 0744 DBBA 20 E7 FF JSR OSNEWL 0745 DBBD ; 0746 DBBD ; enter language 0747 DBBD ; 0748 DBBD 28 PLP ;restore entry type into C 0749 DBBE [ MOS125 = &FF 0750 DBBE | 0751 DBBE ;preserve BRK handler until all printing done 0752 DBBE A5 F4 LDA ROMID 0753 DBC0 8D 8C 02 STA LROMID 0754 DBC3 ] 0755 DBC3 A9 01 LDAIM LGENTR ;entry reason 0756 DBC5 2C 7A 02 BIT TUBEM 0757 DBC8 30 03 BMI TLANG ;[tube active] 0758 DBCA 4C 00 80 JMP ROMHRD ;ROM entry 0759 DBCD TLANG 0760 DBCD 4C 00 04 JMP TBLANG ;tube entry 0761 DBD0 0762 DBD0 0763 DBD0 LNK MOS36 0001 DBD0 ; > MOS36 0002 DBD0 TTL MOS36 Int servicing 0003 DBD0 OPT MOS36 Acorn macro assembler Page 63 MOS36 Int servicing 0004 DBD0 0005 DBD0 ;(c) 1981 ACORN Computers Limited 0006 DBD0 ;BBC MOS 0007 DBD0 ;Change record: 0008 DBD0 0009 DBD0 ;Author(s): 0010 DBD0 ;PB Paul Bond 0011 DBD0 0012 DBD0 ; interrupt service mainline 0013 DBD0 ; priority sequence:- 0014 DBD0 ; [6850] 0015 DBD0 ; 1. RS423 0016 DBD0 ; [6522a] 0017 DBD0 ; 2. VSYNC 0018 DBD0 ; 3. centisecond timer 0019 DBD0 ; 4. ADC 0020 DBD0 ; 5. keyboard 0021 DBD0 ; [6522b] 0022 DBD0 ; 6. printer (parallel interface) 0023 DBD0 0024 DBD0 0025 DBD0 RPROM ;read byte from paged ROM 0026 DBD0 ; read byte at ROMPTR in ROM Y into A 0027 DBD0 A6 F4 LDX ROMID 0028 DBD2 84 F4 STY ROMID 0029 DBD4 8C 30 FE STY ROM 0030 DBD7 A0 00 LDYIM ZERO 0031 DBD9 B1 F6 LDAIY ROMPTR 0032 DBDB STXROM 0033 DBDB 86 F4 STX ROMID 0034 DBDD 8E 30 FE STX ROM 0035 DBE0 60 RTS 0036 DBE1 0037 DBE1 0038 DBE1 0039 DBE1 IRQ ;entered at IRQ or BRK 0040 DBE1 85 FC STA TEMPA 0041 DBE3 68 PLA 0042 DBE4 48 PHA ;A := processor status 0043 DBE5 29 10 ANDIM &10 0044 DBE7 D0 03 BNE BRK 0045 DBE9 6C 04 02 JMI IRQALL ;indirect thru 'all IRQs' routine 0046 DBEC ; (defaults to DEFIRQ) 0047 DBEC ; 0048 DBEC BRK 0049 DBEC 8A TXA 0050 DBED 48 PHA ;save X 0051 DBEE BA TSX 0052 DBEF BD 03 01 LDAAX &0100+&03 ;get address low 0053 DBF2 D8 CLD 0054 DBF3 38 SEC 0055 DBF4 E9 01 SBCIM &01 0056 DBF6 85 FD STA REPTR +&00 0057 DBF8 BD 04 01 LDAAX &0100+&04 ;get address high 0058 DBFB E9 00 SBCIM ZERO 0059 DBFD 85 FE STA REPTR +&01 0060 DBFF ; record ROM source of BRK 0061 DBFF A5 F4 LDA ROMID 0062 DC01 8D 4A 02 STA REPROM 0063 DC04 ; offer BRK to service ROMs 0064 DC04 86 F0 STX BYTEX ;provide clean way for service ROM to access relevant stack area 0065 DC06 A2 06 LDXIM SVBRK 0066 DC08 20 74 F1 JSR SVOP 0067 DC0B ; force language ROM (may be BASIC in pre-interface days) 0068 DC0B AE 8C 02 LDX LROMID 0069 DC0E 20 DB DB JSR STXROM ;reset to language ROM 0070 DC11 ; 0071 DC11 ; restore X 0072 DC11 ; 0073 DC11 68 PLA 0074 DC12 AA TAX 0075 DC13 ; 0076 DC13 ; restore A 0077 DC13 ; 0078 DC13 A5 FC LDA TEMPA 0079 DC15 ; 0080 DC15 ; enable interrupts and let user process BRK 0081 DC15 ; 0082 DC15 58 CLI 0083 DC16 6C 02 02 JMI BRKVEC ;process BRK, N.B. default is DEFBRK 0084 DC19 ; 0085 DC19 [ MOS125 = &FF 0098 DC19 ] 0099 DC19 0100 DC19 0101 DC19 TTL IRQ processing 0102 DC19 OPT OPNEWP Acorn macro assembler Page 64 IRQ processing 0103 DC19 0104 DC19 0105 DC19 TXDINT ;disable Tx interrupt 0106 DC19 ; 0107 DC19 ; RS423 printer selected but printer buffer empty 0108 DC19 ; 0109 DC19 38 SEC 0110 DC1A 6E 4F 02 ROR RSFLAG ;flag RS423 available 0111 DC1D ; 0112 DC1D ; no more characters to print 0113 DC1D ; 0114 DC1D ; disable RS423 Tx 0115 DC1D ; find whether to set RTS hi or lo 0116 DC1D ; 0117 DC1D ; check whether RS423 Rx enabled 0118 DC1D ; 0119 DC1D 2C 50 02 BIT RSCTFL 0120 DC20 10 07 BPL RLO ;[Rx disabled] 0121 DC22 ; 0122 DC22 ; Rx enabled 0123 DC22 ; 0124 DC22 ; check bytes in RS423 input buffer 0125 DC22 ; 0126 DC22 20 83 E7 JSR CNTRS 0127 DC25 ; 0128 DC25 ; C=0 => overflow, C=1 => no overflow 0129 DC25 ; check whether within overflow region 0130 DC25 ; 0131 DC25 A2 00 LDXIM RHITXD 0132 DC27 B0 02 BCS RSOK ;[not overflowing] 0133 DC29 ; 0134 DC29 ; within overflow region 0135 DC29 ; 0136 DC29 RLO ;set RTS lo, Tx interrupt disabled (unfortunately) 0137 DC29 A2 40 LDXIM RLOTXD 0138 DC2B ; 0139 DC2B RSOK ;set RTS hi/lo, Tx interrupt disabled 0140 DC2B 4C CA E1 JMP RSED ;disable Tx interrupts AND return from interrupt 0141 DC2E 0142 DC2E 0143 DC2E RX68 ;RS423 Rx interrupt 0144 DC2E ; 0145 DC2E ; A = 0|0|PE|OVRN|FE|CTS|DCD|TDRE 0146 DC2E ; 0147 DC2E AC 09 FE LDY RSDATA ;read data byte to clear interrupt 0148 DC31 29 3A ANDIM &3A ;CTS & TDRE are not relevant to Rx 0149 DC33 D0 26 BNE RX68BD ;[bad Rx, PE|OVRN|FE|DCD] 0150 DC35 ; 0151 DC35 ; good reception - move byte into RS423 input buffer 0152 DC35 ; 0153 DC35 AE 5C 02 LDX RSSHUT 0154 DC38 D0 09 BNE NRSI ;[suppress RS423 input] 0155 DC3A ; 0156 DC3A ; X=0 0157 DC3A ; 0158 DC3A E8 INX ;X = BRSI = $01 0159 DC3B 20 36 E5 JSR RNSRT ;insert character into RS423 buffer 0160 DC3E ; 0161 DC3E ; check number of characters in buffer 0162 DC3E ; 0163 DC3E 20 83 E7 JSR CNTRS 0164 DC41 ; 0165 DC41 ; check whether running into overflow area 0166 DC41 ; 0167 DC41 90 E6 BCC RLO ;[running into overflow area, set RTS lo, Tx interrupt disabled] 0168 DC43 NRSI ;suppress RS423 input 0169 DC43 60 RTS 0170 DC44 0171 DC44 0172 DC44 [ MOS125 = &FF 0188 DC44 | 0189 DC44 VAT 0190 DC44 ] 0191 DC44 ; 0192 DC44 ; indicate in DEFIRQ 0193 DC44 ; 0194 DC44 B8 CLV 0195 DC45 ; 0196 DC45 IRQ68 ;check for interrupt from 6850 0197 DC45 ; 0198 DC45 [ $Tutu 0201 DC45 | 0202 DC45 AD 08 FE LDA RSTAT 0203 DC48 ] 0204 DC48 70 02 BVS RSTIME ;[timer interrupt] 0205 DC4A ; 0206 DC4A 10 5D BPL IRQA ;[not a 6850 interrupt, N.B. possibly timer interrupt entry] 0207 DC4C ; 0208 DC4C RSTIME ;timer interrupt 0209 DC4C ; 0210 DC4C ; 6850 interrupt 0211 DC4C ; 0212 DC4C ; use RSTUT to decide where to route the interrupt 0213 DC4C ; 0214 DC4C A6 EA LDX RSTUT 0215 DC4E CA DEX 0216 DC4F 30 30 BMI NOTCFS ;[RS423 not managed by CFS] 0217 DC51 ; 0218 DC51 ; inform CFS of the interrupt 0219 DC51 ; 0220 DC51 70 2D BVS RTS68 ;[ignore timer interrupt entry] 0221 DC53 4C B6 F5 JMP IRUPT ;let CFS handle interrupt AND return from interrupt 0222 DC56 0223 DC56 0224 DC56 MDCD ;neither Rx not Tx interrupt => DCD interrupt 0225 DC56 ; 0226 DC56 AC 09 FE LDY RSDATA ;clear DCD interrupt 0227 DC59 2A ROLA ;DCD -> lo-bit 0228 DC5A 0A ASLA ;restore status byte 0229 DC5B ; 0230 DC5B RX68BD ;bad RS423 Rx 0231 DC5B ; 0232 DC5B ; A = 0|0|PE|OVRN|FE|0|DCD|0 0233 DC5B ; C=1 0234 DC5B ; 0235 DC5B ; signal RS423 error 0236 DC5B ; 0237 DC5B AA TAX ;X := status 0238 DC5C 98 TYA ;A := character 0239 DC5D A0 07 LDYIM EVRS ;RS423 error event 0240 DC5F 4C D8 E4 JMP EVENT ;signal event AND return from interrupt Acorn macro assembler Page 65 IRQ processing 0241 DC62 0242 DC62 0243 DC62 TDRE ;Tx interrupt 0244 DC62 ; 0245 DC62 ; RS423 is not claimed by CFS, so we are either 0246 DC62 ; writing or printing to RS423 0247 DC62 ; 0248 DC62 ; extract character from RS423 Tx buffer 0249 DC62 ; 0250 DC62 A2 02 LDXIM BRSO 0251 DC64 20 A4 E4 JSR REMOV 0252 DC67 90 10 BCC TXCH ;[character to transmit] 0253 DC69 ; X=BRSO 0254 DC69 ; 0255 DC69 ; check for print to RS423 0256 DC69 ; 0257 DC69 AD 85 02 LDA PRNTSW 0258 DC6C C9 02 CMPIM PRS 0259 DC6E D0 A9 BNE TXDINT ;[RS423 printer not selected] 0260 DC70 ; X=BRSO 0261 DC70 ; 0262 DC70 ; remove possible character from print buffer 0263 DC70 ; 0264 DC70 E8 INX ;X = BRSO+1 = BPRNT 0265 DC71 20 A4 E4 JSR REMOV ;remove character from printer buffer 0266 DC74 6E D2 02 ROR PFLAG ;update printer flag 0267 DC77 30 A0 BMI TXDINT ;[no character to print] 0268 DC79 ; 0269 DC79 TXCH ;transmit character in A 0270 DC79 ; 0271 DC79 8D 09 FE STA RSDATA ;transmit character 0272 DC7C ; 0273 DC7C ; set RS423 printer timeout active 0274 DC7C ; 0275 DC7C A9 E7 LDAIM PTIMUT 0276 DC7E 85 EA STA RSTUT 0277 DC80 ; 0278 DC80 0279 DC80 RTS68 0280 DC80 UNK0 0281 DC80 60 RTS ;return from interrupt 0282 DC81 0283 DC81 0284 DC81 NOTCFS ;RS423 not managed by CFS 0285 DC81 ; 0286 DC81 2D 78 02 AND C6850 ;suppress bits according to user tastes 0287 DC84 4A LSRA ;C=Rx 0288 DC85 90 07 BCC NOTRX ;[not Rx int] 0289 DC87 70 05 BVS NOTRX ;[do not allow Rx by polling] 0290 DC89 ; 0291 DC89 AC 50 02 LDY RSCTFL 0292 DC8C 30 A0 BMI RX68 ;[recieve interrupts enabled] 0293 DC8E ; 0294 DC8E NOTRX 0295 DC8E 4A LSRA ;C=Tx, N=Rx 0296 DC8F 6A RORA ;C=DCD, N=Tx 0297 DC90 B0 C4 BCS MDCD ;[DCD interrupt] 0298 DC92 ; 0299 DC92 30 CE BMI TDRE ;[TDRE] 0300 DC94 ; 0301 DC94 70 EA BVS RTS68 ;[timer interrupt entry] 0302 DC96 ; 0303 DC96 ; not timer interrupt entry 0304 DC96 ; 0305 DC96 UNKIRQ ;unknown interrupt 0306 DC96 ; 0307 DC96 A2 05 LDXIM SVINT 0308 DC98 20 74 F1 JSR SVOP ;allow FS ROMs to process interrupt 0309 DC9B F0 E3 BEQ UNK0 ;[service ROM dealt with interrupt] 0310 DC9D ; 0311 DC9D ; pull return address 0312 DC9D ; 0313 DC9D 68 PLA 0314 DC9E 68 PLA 0315 DC9F ; 0316 DC9F ; restore X and Y for user interrupt routine 0317 DC9F ; 0318 DC9F 68 PLA 0319 DCA0 A8 TAY 0320 DCA1 68 PLA 0321 DCA2 AA TAX 0322 DCA3 68 PLA 0323 DCA4 85 FC STA TEMPA 0324 DCA6 6C 06 02 JMI IRQVEC ;assume that user will clear the interrupt 0325 DCA9 ; (defaults to IRQTWO) 0326 DCA9 0327 DCA9 0328 DCA9 0329 DCA9 IRQA ;check for interrupt from primary 6522 0330 DCA9 ; 0331 DCA9 AD 4D FE LDA IFRQ ;A = IFR [IRQ,TIMER1,TIMER2,CB1,CB2,SHIFTREG,CA1,CA2] 0332 DCAC 10 3A BPL IRQB ;[not a VIAA interrupt] 0333 DCAE ; 0334 DCAE ; 0335 DCAE 2D 79 02 AND A6522 ;suppress bits according to user tastes 0336 DCB1 2D 4E FE AND IERQ ;N.B. only look at enabled interrupts 0337 DCB4 ; 0338 DCB4 ; 0339 DCB4 6A RORA ;A = IFR >> 1 0340 DCB5 6A RORA ;A = IFR >> 2, C = CA1, N = CA2 0341 DCB6 90 52 BCC ITIME2 ;[not VSYNC interrupt] 0342 DCB8 ; 0343 DCB8 ; VSYNC interrupt 0344 DCB8 ; N.B. C=1 0345 DCB8 ; 0346 DCB8 CE 40 02 DEC CYCLE ;update CFS timeout byte 0347 DCBB A5 EA LDA RSTUT ;decrement RS423 printer timeout 0348 DCBD 10 02 BPL NPRST 0349 DCBF E6 EA INC RSTUT 0350 DCC1 ; 0351 DCC1 NPRST ;no RS423 printer timeout 0352 DCC1 ; 0353 DCC1 AD 51 02 LDA FLCNT 0354 DCC4 F0 18 BEQ IVS1 ;[flash disabled] 0355 DCC6 CE 51 02 DEC FLCNT 0356 DCC9 D0 13 BNE IVS1 ;[flash count not exhausted] 0357 DCCB ; 0358 DCCB ; flash count exhausted 0359 DCCB ; reset FLCNT 0360 DCCB ; 0361 DCCB [ MOS125 = &FF Acorn macro assembler Page 66 IRQ processing 0372 DCCB | 0373 DCCB ; A=1 0374 DCCB AE 52 02 LDX FLSPC 0375 DCCE 4D 48 02 EOR VPREGA ;invert flash bit 0376 DCD1 4A LSRA ;C = new flash bit 0377 DCD2 B0 03 BCS FLASH1 ;[old flash bit = 0] 0378 DCD4 ; old flash bit = 1 0379 DCD4 AE 53 02 LDX FLMRK 0380 DCD7 FLASH1 0381 DCD7 ; 0382 DCD7 2A ROLA ;A = VPREGA 0383 DCD8 ] 0384 DCD8 20 05 EA JSR MVPRC0 ;update video processor and register image 0385 DCDB 8E 51 02 STX FLCNT ;update flash count 0386 DCDE ; 0387 DCDE IVS1 0388 DCDE A0 04 LDYIM EVVSYN 0389 DCE0 20 D8 E4 JSR EVENT 0390 DCE3 ; 0391 DCE3 A9 02 LDAIM VSYNC 0392 DCE5 4C 0F DE JMP IVIAA0 ;clear interrupt and return 0393 DCE8 0394 DCE8 0395 DCE8 0396 DCE8 IRQB ;check for interrupt from secondary 6522 0397 DCE8 ; 0398 DCE8 AD 6D FE LDA IFRR ;A = IFR, C = ?, N = IRQ 0399 DCEB 10 A9 BPL UNKIRQ ;[not a VIAB interrupt] 0400 DCED ; 0401 DCED ; 0402 DCED 2D 77 02 AND B6522 ;suppress bits if secondary 6522 not present 0403 DCF0 2D 6E FE AND IERR ;only look at enabled interrupts 0404 DCF3 6A RORA ;A = IFR >> 1 0405 DCF4 6A RORA ;A = IFR >> 2, C = CA1 0406 DCF5 90 9F BCC UNKIRQ ;[not a printer interrupt] 0407 DCF7 ; 0408 DCF7 IPRNT ;printer interrupt 0409 DCF7 ; 0410 DCF7 ; acknowledge interrupt 0411 DCF7 ; N.B. clear before sending next character since printer 0412 DCF7 ; may acknowledge quickly and we could miss the interrupt 0413 DCF7 AC 85 02 LDY PRNTSW 0414 DCFA 88 DEY ;******** ASSUMES PCEN = 1 ******** 0415 DCFB D0 99 BNE UNKIRQ ;[ignore printer interrupt cos centronics not selected] 0416 DCFD ; 0417 DCFD A9 02 LDAIM PRNT 0418 DCFF 8D 6D FE STA IFRR ;acknowledge interrupt 0419 DD02 8D 6E FE STA IERR ;disable printer interrupt 0420 DD05 ; (will be enabled again by STROBE if another character is sent 0421 DD05 ; using the parallel port) 0422 DD05 ; 0423 DD05 A2 03 LDXIM BPRNT ;X := print bufferid 0424 DD07 4C 8C E1 JMP STROBE ;if character read then print it AND return from interrupt 0425 DD0A 0426 DD0A 0427 DD0A ITIME2 ;check for TIMER2 interrupt 0428 DD0A ; 0429 DD0A 2A ROLA ;A = IFR >> 1 0430 DD0B 2A ROLA ;A = IFR 0431 DD0C 2A ROLA ;:A = IFR << 1, N = TIMER1 0432 DD0D 2A ROLA ;A = IFR << 2, N = TIMER2, C = TIMER1 0433 DD0E 10 5B BPL ITIME1 ;[not TIMER2, check for TIMER1 interrupt] 0434 DD10 [ NOSP = &00 0437 DD10 | 0438 DD10 ; 0439 DD10 ; timer 2 interrupt 0440 DD10 ; acknowledge interrupt 0441 DD10 ; 0442 DD10 ; and 0443 DD10 ; 0444 DD10 ; set speech RDY to interrupt again 0445 DD10 ; 0446 DD10 A9 20 LDAIM TIMER2 0447 DD12 A2 00 LDXIM ZERO 0448 DD14 ; N.B. minimise time between next two instructions 0449 DD14 8D 4D FE STA IFRQ ;clear interrupt 0450 DD17 8E 49 FE STX TRCHQ ;set to interrupt on speech chip INT 0451 DD1A ; 0452 DD1A ; process speech request 0453 DD1A ; 0454 DD1A PRSPRQ ;process speech request 0455 DD1A ; 0456 DD1A ; set speak external repeat counter to 4 0457 DD1A ; 0458 DD1A A2 08 LDXIM BSPCH 0459 DD1C 86 FB STX SPWK2 ;**** ASSUMES BSPCH=8 **** 0460 DD1E ; 0461 DD1E SPEREP ;repeat poke of speak external data 0462 DD1E ; 0463 DD1E ; inspect speech buffer 0464 DD1E ; 0465 DD1E 20 9F E4 JSR EXAM 0466 DD21 ; 0467 DD21 ; record buffer status - MI => dormant, PL => busy 0468 DD21 ; 0469 DD21 6E D7 02 ROR SPSTAT 0470 DD24 30 44 BMI NSPECH ;[buffer empty] 0471 DD26 ; 0472 DD26 A8 TAY 0473 DD27 F0 05 BEQ SPOK ;[speak external data] 0474 DD29 ; 0475 DD29 ; new command - ensure not talking 0476 DD29 ; 0477 DD29 20 89 EE JSR RSPECH 0478 DD2C 30 3C BMI NSPECH ;[talking active] 0479 DD2E ; 0480 DD2E ; new command and not talking 0481 DD2E ; 0482 DD2E SPOK ;speak external data 0483 DD2E ; 0484 DD2E ; get command byte from speech buffer 0485 DD2E ; 0486 DD2E 20 A4 E4 JSR REMOV 0487 DD31 ; 0488 DD31 ; codeword in A 0489 DD31 ; 0490 DD31 85 F5 STA SEROM 0491 DD33 ; 0492 DD33 ; pull data 0493 DD33 ; 0494 DD33 20 A4 E4 JSR REMOV Acorn macro assembler Page 67 IRQ processing 0495 DD36 85 F7 STA ROMPTR+&01 ;hi-address / hi-data 0496 DD38 20 A4 E4 JSR REMOV 0497 DD3B 85 F6 STA ROMPTR+&00 ;lo-address / lo-data 0498 DD3D ; 0499 DD3D ; switch on codeword 0500 DD3D ; 0501 DD3D A4 F5 LDY SEROM 0502 DD3F F0 1B BEQ ISP2 ;[command=0, do not treat codeword as a command] 0503 DD41 10 16 BPL ISP3 ;[command>0, speech command without address] 0504 DD43 ; 0505 DD43 ; command with address 0506 DD43 ; command either speak(address) OR read-and-branch(address) 0507 DD43 ; 0508 DD43 ; check for read and branch request 0509 DD43 ; 0510 DD43 24 F5 BIT SEROM 0511 DD45 70 05 BVS RAB ;[read and branch] 0512 DD47 ; 0513 DD47 ; speak(address) 0514 DD47 ; load address into speech processor 0515 DD47 ; 0516 DD47 ; V=0 0517 DD47 20 D7 EE JSR SPLOAD ;N.B. does PHP...PLP 0518 DD4A 50 07 BVC ISPX ;[ALWAYS jump] 0519 DD4C ; 0520 DD4C RAB ;read and branch (speak indirect) 0521 DD4C ; 0522 DD4C ; multiply offset by two 0523 DD4C ; 0524 DD4C 06 F6 ASL ROMPTR+&00 0525 DD4E 26 F7 ROL ROMPTR+&01 0526 DD50 ; 0527 DD50 ; reselect address 0528 DD50 ; 0529 DD50 20 58 EE JSR SPLIND ;load address indirect 0530 DD53 ; 0531 DD53 ISPX 0532 DD53 AC 61 02 LDY SHUTSP ;command defaults to speech 0533 DD56 4C 9B EE JMP WSPECH ;send command AND return 0534 DD59 ; 0535 DD59 ; 0536 DD59 ISP3 ;treat codeword as a command 0537 DD59 ; 0538 DD59 20 9B EE JSR WSPECH ;issue codeword command 0539 DD5C ; 0540 DD5C ISP2 ;write argument data bytes 0541 DD5C ; 0542 DD5C A4 F6 LDY ROMPTR+&00 0543 DD5E 20 9B EE JSR WSPECH 0544 DD61 A4 F7 LDY ROMPTR+&01 0545 DD63 20 9B EE JSR WSPECH 0546 DD66 ; 0547 DD66 ; repeat poke of speak external data up to 4 times (8 bytes) 0548 DD66 ; 0549 DD66 46 FB LSR SPWK2 0550 DD68 D0 B4 BNE SPEREP ;[try poking more speak external data] 0551 DD6A ; 0552 DD6A NSPECH 0553 DD6A 60 RTS 0554 DD6B ] 0555 DD6B 0556 DD6B 0557 DD6B 0558 DD6B ITIME1 ;check for TIMER1 interrupt 0559 DD6B ; 0560 DD6B 90 7B BCC IADC ;[not TIMER1, check for ADC interrupt] 0561 DD6D ; C=1 0562 DD6D ; 0563 DD6D ; main clock interrupt 0564 DD6D ; 0565 DD6D ; clear interrupt 0566 DD6D ; 0567 DD6D A9 40 LDAIM CLOCK 0568 DD6F 8D 4D FE STA IFRQ ;acknowledge clock interrupt 0569 DD72 ; C=1 0570 DD72 ; 0571 DD72 ; increment absolute time 0572 DD72 ; 0573 DD72 AD 83 02 LDA TIMESW 0574 DD75 AA TAX ;X -> current timer 0575 DD76 49 0F EORIM &0F 0576 DD78 48 PHA 0577 DD79 A8 TAY ;Y -> other timer 0578 DD7A ; C=1 0579 DD7A ;****SEC ;N.B. add 1 to timer 0580 DD7A ; 0581 DD7A IT1 0582 DD7A BD 91 02 LDAAX TIME -&01 0583 DD7D 69 00 ADCIM ZERO 0584 DD7F 99 91 02 STAAY TIME -&01 0585 DD82 CA DEX 0586 DD83 F0 03 BEQ IT2 0587 DD85 88 DEY 0588 DD86 D0 F2 BNE IT1 0589 DD88 IT2 0590 DD88 ; 0591 DD88 68 PLA 0592 DD89 8D 83 02 STA TIMESW ;switch timers 0593 DD8C ; 0594 DD8C ; 0595 DD8C A2 05 LDXIM &05 0596 DD8E IVIAA5 0597 DD8E FE 9B 02 INCAX STPW -&01 0598 DD91 D0 08 BNE IINKEY 0599 DD93 CA DEX 0600 DD94 D0 F8 BNE IVIAA5 0601 DD96 ; 0602 DD96 ; stopwatch timeout 0603 DD96 ; 0604 DD96 A0 05 LDYIM EVSWCH 0605 DD98 20 D8 E4 JSR EVENT 0606 DD9B ; 0607 DD9B IINKEY ;decrement INKEY counter 0608 DD9B ; 0609 DD9B AD B1 02 LDA RDCTLO 0610 DD9E D0 08 BNE IIN1 ;[just decrement lo] 0611 DDA0 ; lo zero 0612 DDA0 AD B2 02 LDA RDCTHI 0613 DDA3 F0 06 BEQ IIN0 ;[counter zero] 0614 DDA5 ; decrement lo and hi 0615 DDA5 CE B2 02 DEC RDCTHI Acorn macro assembler Page 68 IRQ processing 0616 DDA8 IIN1 ;just decrement lo 0617 DDA8 CE B1 02 DEC RDCTLO 0618 DDAB IIN0 ;counter zero 0619 DDAB 0620 DDAB [ $Tutu ; no sound, no speech shit wanted - nothing from this point on 0624 DDAB | 0625 DDAB ; 0626 DDAB ; 0627 DDAB ; check sound sema to ensure exclusive access to sound code 0628 DDAB ; 0629 DDAB 2C CE 02 BIT SSEMA 0630 DDAE ] 0631 DDAE 10 0B BPL SINUSE ;[sound software in use] 0632 DDB0 ; 0633 DDB0 ; sound software available 0634 DDB0 ; 0635 DDB0 EE CE 02 INC SSEMA ;claim sound sema 0636 DDB3 58 CLI ;enable interrupts during sound processing 0637 DDB4 20 81 EB JSR SNDIRQ 0638 DDB7 78 SEI ;disable interrupts after sound processing 0639 DDB8 CE CE 02 DEC SSEMA ;release sound sema 0640 DDBB SINUSE 0641 DDBB [ NOSP = &00 0643 DDBB | 0644 DDBB ; 0645 DDBB ; give speech a chance 0646 DDBB ; 0647 DDBB ; check buffer 0648 DDBB ; 0649 DDBB 2C D7 02 BIT SPSTAT 0650 DDBE 30 0C BMI SPBUSY ;[speech buffer empty] 0651 DDC0 ; 0652 DDC0 ; read speech chip status 0653 DDC0 ; 0654 DDC0 20 89 EE JSR RSPECH ;N.B. does not alter A if speech chip not present 0655 DDC3 ; 0656 DDC3 ; A>=$80 => busy 0657 DDC3 ; 0658 DDC3 ; N.B. if speech chip does not exist then 25% chance that PRSPRQ will 0659 DDC3 ; be called, this will just result in a no-operation effect 0660 DDC3 ; 0661 DDC3 49 A0 EORIM &A0 0662 DDC5 C9 60 CMPIM &60 0663 DDC7 90 03 BCC SPBUSY ;[100, 101 or 111] 0664 DDC9 ; 0665 DDC9 20 1A DD JSR PRSPRQ ;process speech request 0666 DDCC ] 0667 DDCC ; 0668 DDCC SPBUSY ;speech chip busy 0669 DDCC ; 0670 DDCC ; check RS423 for possible Tx 0671 DDCC ; 0672 DDCC 2C 49 D9 BIT FFBYT ;indicate timer interrupt call 0673 DDCF 20 45 DC JSR IRQ68 0674 DDD2 ; 0675 DDD2 ; check keyboard if keys active 0676 DDD2 ; 0677 DDD2 A5 EC LDA CKEY 0678 DDD4 05 ED ORA OKEY 0679 DDD6 2D 42 02 AND KSEMA ;check for keyboard critical region 0680 DDD9 F0 04 BEQ ICLK0 ;[no keys active, clear timer interrupt] 0681 DDDB 38 SEC 0682 DDDC 20 74 F0 JSR JMIKYV ;key(s) active, process timer interrupt 0683 DDDF ; ******** MAY ENABLE INTERRUPTS (EXITS DISABLED) ******** 0684 DDDF ; 0685 DDDF ICLK0 0686 DDDF ; give user print routine a chance 0687 DDDF 20 EB E1 JSR UPTINT 0688 DDE2 ; 0689 DDE2 ; the ADC is connected on CB1 0690 DDE2 ; when port B is read (by keyboard routines) any 0691 DDE2 ; interrupt is lost, and the ADC must be restarted 0692 DDE2 ; 0693 DDE2 2C C0 FE BIT ADCCTL 0694 DDE5 70 04 BVS IADCB ;[ADC not busy] 0695 DDE7 60 RTS ;return from interrupt 0696 DDE8 0697 DDE8 0698 DDE8 IADC ;check for ADC interrupt 0699 DDE8 ; 0700 DDE8 2A ROLA ;A = IFR << 3, N = CB1 0701 DDE9 10 28 BPL IKEYBD ;[not an ADC intterupt] 0702 DDEB ; 0703 DDEB ; ADC interrupt 0704 DDEB ; check ADC enabled 0705 DDEB ; 0706 DDEB IADCB 0707 DDEB AE 4C 02 LDX ADCHAN 0708 DDEE F0 1D BEQ IADC0 ;[ADC disabled] 0709 DDF0 ; 0710 DDF0 ; read conversion lo byte 0711 DDF0 ; 0712 DDF0 AD C2 FE LDA ADCLO 0713 DDF3 9D B5 02 STAAX ADCLOV -&01 0714 DDF6 ; 0715 DDF6 ; read conversion hi byte 0716 DDF6 ; 0717 DDF6 AD C1 FE LDA ADCHI 0718 DDF9 9D B9 02 STAAX ADCHIV -&01 0719 DDFC ; 0720 DDFC ; set latest conversion number 0721 DDFC ; 0722 DDFC 8E BE 02 STX ADCFLG 0723 DDFF ; 0724 DDFF ; signal ADC conversion event, X = channel number 0725 DDFF ; 0726 DDFF A0 03 LDYIM EVADC 0727 DE01 20 D8 E4 JSR EVENT 0728 DE04 ; 0729 DE04 ; step to next channel 0730 DE04 ; 0731 DE04 CA DEX 0732 DE05 D0 03 BNE IADC2 ;[channel >= 1] 0733 DE07 ; 0734 DE07 ; channel counter underflow 0735 DE07 ; reload channel counter 0736 DE07 ; 0737 DE07 AE 4D 02 LDX MAXADC 0738 DE0A IADC2 0739 DE0A ; 0740 DE0A ; initiate next conversion Acorn macro assembler Page 69 IRQ processing 0741 DE0A ; X = channel number 0742 DE0A ; 0743 DE0A 20 3B DE JSR ADCBGX ;begin conversion, sets ADCHAN=X 0744 DE0D IADC0 0745 DE0D A9 10 LDAIM ADC 0746 DE0F IVIAA0 ;return from VIAA interrupt 0747 DE0F 8D 4D FE STA IFRQ ;clear interrupt state 0748 DE12 60 RTS ;return from interrupt 0749 DE13 0750 DE13 0751 DE13 IKEYBD ;keyboard interrupt check 0752 DE13 ; 0753 DE13 2A ROLA ;A = IFR << 4 0754 DE14 2A ROLA ;A = IFR << 5 0755 DE15 2A ROLA ;A = IFR << 6 0756 DE16 2A ROLA ;A = IFR << 7, N = CA2 0757 DE17 10 07 BPL JUNKIRQ ;[not keyboard interrupt] 0758 DE19 ; 0759 DE19 ; C=0 because no VSYNC 0760 DE19 ; 0761 DE19 20 74 F0 JSR JMIKYV ;find and set up new current key (enter with C=0) 0762 DE1C ; ******** MAY ENABLE INTERRUPTS (EXITS DISABLED) ******** 0763 DE1C A9 01 LDAIM KEYBD 0764 DE1E D0 EF BNE IVIAA0 ;[ALWAYS jump] 0765 DE20 ; 0766 DE20 4C 96 DC JUNKIRQ JMP UNKIRQ ;IRQ not identified 0767 DE23 0768 DE23 0769 DE23 0770 DE23 [ MOS125 = &FF 0771 DE23 | 0772 DE23 DEFIRQ ;default IRQ routine 0773 DE23 D8 CLD 0774 DE24 A5 FC LDA TEMPA 0775 DE26 48 PHA 0776 DE27 8A TXA 0777 DE28 48 PHA 0778 DE29 98 TYA 0779 DE2A 48 PHA 0780 DE2B ; 0781 DE2B ; schedule return from interrupt 0782 DE2B ; 0783 DE2B 20 44 DC JSR VAT 0784 DE2E ] 0785 DE2E IRQ0 ;return from interrupt restoring registers 0786 DE2E 68 PLA 0787 DE2F A8 TAY 0788 DE30 68 PLA 0789 DE31 AA TAX 0790 DE32 68 PLA 0791 DE33 85 FC STA TEMPA 0792 DE35 ; 0793 DE35 IRQTWO 0794 DE35 A5 FC LDA TEMPA 0795 DE37 40 RTI 0796 DE38 0797 DE38 0798 DE38 ADCBEG ;begin forced ADC conversion 0799 DE38 ; 0800 DE38 ; X = external channel number 0801 DE38 ; Y = 0 0802 DE38 ; 0803 DE38 8C BE 02 STY ADCFLG ;clear conversion number 0804 DE3B ; 0805 DE3B ADCBGX ;begin ADC conversion 0806 DE3B ; 0807 DE3B ; X = external channel number 0808 DE3B ; Y corrupted 0809 DE3B ; 0810 DE3B E0 05 CPXIM NADC +&01 0811 DE3D 90 02 BCC ADCBG1 ;[valid channel number] 0812 DE3F A2 04 LDXIM NADC ;force valid channel number 0813 DE41 ADCBG1 ;channel number now valid (but possibly 0) 0814 DE41 ; 0815 DE41 8E 4C 02 STX ADCHAN 0816 DE44 AC 4E 02 LDY ADCCNV ;normally 0, 8 or 12 (0 has same effect as 12) 0817 DE47 88 DEY 0818 DE48 98 TYA 0819 DE49 29 08 ANDIM &08 ;extract conversion type 0820 DE4B 18 CLC 0821 DE4C 6D 4C 02 ADC ADCHAN 0822 DE4F ; C=0 0823 DE4F E9 00 SBCIM ZERO ;subtract 1, add in INTERNAL channel number (1->0 ... 4->3) 0824 DE51 8D C0 FE STA ADCCTL ;start conversion 0825 DE54 ; 0826 DE54 ; if X was 0 on entry then a conversion is initiated on channel 3 0827 DE54 ; of the opposite conversion type to that expected, but the result 0828 DE54 ; of this conversion will be ignored 0829 DE54 ; 0830 DE54 60 RTS 0831 DE55 0832 DE55 0833 DE55 WRSTR ;write string 0834 DE55 ; 0835 DE55 A9 C3 LDAIM /MSG 0836 DE57 WRSTRA 0837 DE57 85 FE STA REPTR +&01 0838 DE59 A9 00 LDAIM ZERO 0839 DE5B 85 FD STA REPTR +&00 0840 DE5D WRSTR1 0841 DE5D C8 INY 0842 DE5E B1 FD LDAIY REPTR 0843 DE60 20 E3 FF JSR OSASCI ;write message character 0844 DE63 AA TAX 0845 DE64 D0 F7 BNE WRSTR1 ;[ALWAYS jump, step to next message character] 0846 DE66 ; terminator found 0847 DE66 60 RTS 0848 DE67 0849 DE67 0850 DE67 LNK MOS38 0001 DE67 ; > MOS38 0002 DE67 TTL MOS38 CLI 0003 DE67 OPT MOS38 Acorn macro assembler Page 70 MOS38 CLI 0004 DE67 ;(c) 1981 ACORN 0005 DE67 ;BBC MOS 0006 DE67 ;Change record: 0007 DE67 ;004 29-Jul-81 MP Prototype version 0008 DE67 ;Author(s): 0009 DE67 ;PB Paul Bond 0010 DE67 ;MP Mike Prees 0011 DE67 0012 DE67 0013 DE67 ; RDCH 0014 DE67 INKEY 0015 DE67 8E B1 02 STX RDCTLO ;set INKEY counter 0016 DE6A 8C B2 02 STY RDCTHI 0017 DE6D A9 FF LDAIM &FF ;indicate INKEY operational 0018 DE6F D0 02 BNE RDCH5 ;[ALWAYS JUMP] 0019 DE71 RDCH ;default OSRDCH 0020 DE71 A9 00 LDAIM ZERO ;indicate not INKEY 0021 DE73 RDCH5 0022 DE73 85 E6 STA RDCTEM 0023 DE75 ; save X and Y 0024 DE75 8A TXA 0025 DE76 48 PHA 0026 DE77 98 TYA 0027 DE78 48 PHA 0028 DE79 ; check for exec file 0029 DE79 AC 56 02 LDY EXECH 0030 DE7C F0 14 BEQ RDCHQ ;[no exec file] 0031 DE7E ; 0032 DE7E 38 SEC 0033 DE7F 66 EB ROR ESSEMA ;enter critical region 0034 DE81 20 D7 FF JSR OSBGET ;get a byte from exec file 0035 DE84 08 PHP 0036 DE85 46 EB LSR ESSEMA ;exit critical region 0037 DE87 28 PLP 0038 DE88 90 25 BCC RDCH3 ;[return character] 0039 DE8A ; 0040 DE8A ; end of exec file: close exec file 0041 DE8A ; Y = handle 0042 DE8A A9 00 LDAIM ZERO 0043 DE8C 8D 56 02 STA EXECH ;cancel exec file handle 0044 DE8F 20 CE FF JSR OSFIND ;close exec file 0045 DE92 RDCHQ ;read character 0046 DE92 24 FF BIT ESCFLG 0047 DE94 30 16 BMI RDCH1 ;[ESCAPE detected] 0048 DE96 ; 0049 DE96 AE 41 02 LDX RDCHSW ;set to read ch from selected buffer 0050 DE99 20 BA E5 JSR RDCHG ;get ch from kybd input buffer 0051 DE9C 90 11 BCC RDCHN ;[character available] 0052 DE9E ; 0053 DE9E ; C=1 0054 DE9E ; 0055 DE9E 24 E6 BIT RDCTEM 0056 DEA0 50 F0 BVC RDCHQ ;[INKEY not operational] 0057 DEA2 ; 0058 DEA2 AD B1 02 LDA RDCTLO 0059 DEA5 0D B2 02 ORA RDCTHI 0060 DEA8 D0 E8 BNE RDCHQ ;[INKEY counter <> 0] 0061 DEAA ; 0062 DEAA ;INKEY count exhausted 0063 DEAA ; 0064 DEAA B0 05 BCS RDCH2 ;[ALWAYS jump, return A=$FF, C=1] 0065 DEAC ; 0066 DEAC RDCH1 ;ESCAPE detected 0067 DEAC 38 SEC ;indicate escape detected 0068 DEAD A9 1B LDAIM ESC 0069 DEAF RDCHN ;C=0 => 'real' character 0070 DEAF RDCH3 ;C=1 => escape detected OR INKEY count expired 0071 DEAF 85 E6 STA RDCTEM ;save character read 0072 DEB1 RDCH2 ;entry point used when INKEY count exhausted (N.B. RDCTEM=$FF) 0073 DEB1 68 PLA ;restore X and Y 0074 DEB2 A8 TAY 0075 DEB3 68 PLA 0076 DEB4 AA TAX 0077 DEB5 A5 E6 LDA RDCTEM ;A := character 0078 DEB7 60 RTS 0079 DEB8 [ MOS125 = &FF 0355 DEB8 ] 0356 DEB8 0357 DEB8 [ MOS125 = &FF 0358 DEB8 | 0359 DEB8 ;START OF MOS 1.25 0360 DEB8 ; COPYR had been anchored here for fear that CLISKP 0361 DEB8 ; would be entered with X<2; this is now ruled out 0362 DEB8 ; but instead end-of-table marker must be within 0363 DEB8 ; 253 bytes of COMTAB 0364 DEB8 ; command level interpreter 0365 DEB8 COMTAB ;table of MOS commands 0366 DEB8 ; this table uses the fact that all routine address hi-bytes 0367 DEB8 ; will have the top bit set 0368 DEB8 ; N.B. addresses are stored hi-byte followed by lo-byte 0369 DEB8 ; hi-byte is assumed to be >=$80 0370 DEB8 ; code following address is A reg on entry to address 0371 DEB8 ; A+ => enter with XY -> line 0372 DEB8 ; A- => enter with Y = offset 0373 DEB8 0374 DEB8 ; CAT 0375 DEB8 ;must come first to trap *. 0376 DEB8 43 41 54 = "CAT" 0377 DEBB E0 8A & /JMIFSC 0378 DEBD 05 = FSCAT ;enter with XY -> line 0379 DEBE 0380 DEBE ; FX 0381 DEBE ;second entry in OS 1.20. 0382 DEBE ;some naughty code might rely on the same quick response 0383 DEBE ;but we also want to give fast access to USERV (*FX136) 0384 DEBE ;and match early due to the sheer volume of calls 0385 DEBE 46 58 = "FX" 0386 DEC0 E3 6C & /FX 0387 DEC2 FF = &FF ;enter with Y = offset 0388 DEC3 0389 DEC3 ; CODE 0390 DEC3 ;match after FX to take less time than *FX136 0391 DEC3 43 4F 44 = "CODE" 0392 DEC7 E3 72 & /FXN 0393 DEC9 88 = FXCODE ;enter with Y = offset 0394 DECA 0395 DECA ; LOAD 0396 DECA ;must come before LINE to trap *L. 0397 DECA 4C 4F 41 = "LOAD" 0398 DECE E2 98 & /LOAD 0399 DED0 Acorn macro assembler Page 71 MOS38 CLI 0400 DED0 00 = &00 ;enter with XY -> line 0401 DED1 0402 DED1 ; LINE 0403 DED1 ;needs fast service the most as user code may be time critical 0404 DED1 ;the only (trivial) way to pass a string from parasite to USERV 0405 DED1 4C 49 4E = "LINE" 0406 DED5 E6 9C & /JMIUSR 0407 DED7 01 = &01 ;enter with A=$01, XY -> line, C=0 0408 DED8 0409 DED8 ; default if first character is not alpha, |, . or / 0410 DED8 ;filter the wordless *commands off early 0411 DED8 ;a substitute for testing the first char in code 0412 DED8 [ MOS125 = &7F 0413 DED8 [ STARGO = &00 0414 DED8 E0 83 & /JMICMD 0415 DEDA | 0417 DEDA ] 0418 DEDA | 0420 DEDA ] 0421 DEDA 03 = FSNAME ;enter with XY -> line 0422 DEDB 0423 DEDB ; RUN 0424 DEDB ;must come before ROM to trap *R. 0425 DEDB ;should be as fast as *wordless to avoid disadvantage 0426 DEDB 52 55 4E = "RUN" 0427 DEDE [ MOS125 = &7F 0428 DEDE [ STARGO = &00 0429 DEDE E0 83 & /JMICMD 0430 DEE0 | 0432 DEE0 ] 0433 DEE0 | 0435 DEE0 ] 0436 DEE0 0437 DEE0 04 = FSRUN ;enter with XY -> line 0438 DEE1 0439 DEE1 ; OPT 0440 DEE1 ;part of a program's operation, has high priority 0441 DEE1 4F 50 54 = "OPT" 0442 DEE4 E3 72 & /FXN 0443 DEE6 0444 DEE6 8B = FXOPT ;enter with Y = offset 0445 DEE7 0446 DEE7 ; EXEC 0447 DEE7 ;slow but provides the computer with work, should not hold it up 0448 DEE7 45 58 45 = "EXEC" 0449 DEEB F6 BD & /EXEC 0450 DEED 0451 DEED 00 = ZERO ;enter with XY -> line 0452 DEEE 0453 DEEE ; MOTOR 0454 DEEE ;a quick command but not urgent coming through OSCLI 0455 DEEE 4D 4F 54 = "MOTOR" 0456 DEF3 E3 72 & /FXN 0457 DEF5 0458 DEF5 89 = FXMOTR ;enter with Y = offset 0459 DEF6 0460 DEF6 ; SAVE 0461 DEF6 ;must come before SPOOL to trap *S. 0462 DEF6 ;a slow command and rarer than loading 0463 DEF6 53 41 56 = "SAVE" 0464 DEFA E2 9A & /SAVE 0465 DEFC 0466 DEFC 00 = ZERO ;enter with XY -> line 0467 DEFD 0468 DEFD ; SPOOL 0469 DEFD ;also slow and rarer than saving 0470 DEFD 53 50 4F = "SPOOL" 0471 DF02 E2 DD & /SPOOL 0472 DF04 0473 DF04 00 = ZERO ;enter with XY -> line 0474 DF05 0475 DF05 ; KEY 0476 DF05 ;low volume, called by programs at setup 0477 DF05 4B 45 59 = "KEY" 0478 DF08 E3 A1 & /KEY 0479 DF0A 0480 DF0A FF = &FF ;enter with Y = offset 0481 DF0B 0482 DF0B ; TAPE 0483 DF0B ;must come before TV to trap *T. 0484 DF0B ;slightly more complex, called by programs at setup 0485 DF0B 54 41 50 = "TAPE" 0486 DF0F E3 72 & /FXN 0487 DF11 0488 DF11 8C = FXTAPE ;enter with Y = offset 0489 DF12 0490 DF12 ; TV 0491 DF12 ;cosmetic, called by programs at setup 0492 DF12 54 56 = "TV" 0493 DF14 E3 72 & /FXN 0494 DF16 0495 DF16 90 = FXTV ;enter with Y = offset 0496 DF17 0497 DF17 ; HELP 0498 DF17 ;user command 0499 DF17 48 45 4C = "HELP" 0500 DF1B F0 C5 & /HELP 0501 DF1D 0502 DF1D FF = &FF ;enter with Y = offset 0503 DF1E 0504 DF1E ; ROM 0505 DF1E ;rarely used. as RFS installations are site-specific 0506 DF1E ;this is essentially a user command 0507 DF1E 52 4F 4D = "ROM" 0508 DF21 E3 72 & /FXN 0509 DF23 0510 DF23 8D = FXSROM ;don't care 0511 DF24 0512 DF24 ; BASIC 0513 DF24 ;invokes the language (i.e. non-transient) 0514 DF24 ;called either by the user or in a slow *EXEC file 0515 DF24 42 41 53 = "BASIC" 0516 DF29 E0 68 & /BASIC 0517 DF2B 01 = &01 ;bit 0 set for ILR2 to enter ROM with C=1 0518 DF2C ] 0519 DF2C 0520 DF2C [ MOS125 = &7F 0521 DF2C [ STARGO = &00 0522 DF2C ; GOIO 0523 DF2C ;comes before GO to trap *G. 0524 DF2C 47 4F 49 = "GOIO" Acorn macro assembler Page 72 MOS38 CLI 0525 DF30 DF 6F & /GOIO 0526 DF32 0527 DF32 80 = /LANG ;assumed -ve; stored as default jump address 0528 DF33 0529 DF33 ; GO 0530 DF33 47 4F = "GO" 0531 DF35 DF 70 & /GO 0532 DF37 0533 DF37 80 = /LANG ;assumed -ve; stored as default jump address 0534 DF38 0535 DF38 = "" ;terminating keyword [duplicate, NEVER matches] 0536 DF38 80 = &80 ;end of table 0537 DF39 0538 DF39 00 00 00 % 54 ;padding 0539 DF6F 0540 DF6F [ NOSP = &00 0542 DF6F ] 0543 DF6F 0544 DF6F GOIO 0545 DF6F 38 SEC 0546 DF70 GO 0547 DF70 08 PHP 0548 DF71 A2 D4 LDXIM INFO +BKEXEC -FBLOCK ;stretch! 0549 DF73 20 5F E2 JSR CLRFB 0550 DF76 8D C3 03 STA INFO +BKEXEC +&01 ;default address = &00008000 0551 DF79 20 70 E2 JSR LSA ;replace with user address if present 0552 DF7C 28 PLP 0553 DF7D 90 08 BCC GETENV ;if *GO then use whole address 0554 DF7F A9 FF LDAIM &FF 0555 DF81 8D C4 03 STA INFO +BKEXEC +&02 0556 DF84 8D C5 03 STA INFO +BKEXEC +&03 ;else force an I/O processor address 0557 DF87 GETENV 0558 DF87 20 93 E0 JSR SKIPSP ;get next argument 0559 DF8A F0 07 BEQ GOTO ;if CR then point tail at it 0560 DF8C C9 3B CMPIM ";" 0561 DF8E D0 03 BNE GOTO ;if not semicolon then point tail at it 0562 DF90 20 92 E0 JSR SKIPSN ;else absorb semicolon once 0563 DF93 GOTO 0564 DF93 4C 0A F3 JMP RUNGO ;set up tail from Y and enter user code 0565 DF96 0566 DF96 RETAIL ;return command line tail to OSARGS control block 0567 DF96 ;Y=high byte 0568 DF96 94 01 STYZX &01 ;store in 3MSB 0569 DF98 AC D0 02 LDY TAILLO 0570 DF9B 94 00 STYZX &00 ;store low byte in MSB 0571 DF9D A0 FF LDYIM &FF ;command line tail is always in I/O processor 0572 DF9F 94 02 STYZX &02 ;set high word to &FFFF 0573 DFA1 94 03 STYZX &03 0574 DFA3 C8 INY ;Y=0 for return 0575 DFA4 [ TRUE = &00 0576 DFA4 A9 DC LDAIM SEAL ;set conventional return value (conflicting documentation) 0577 DFA6 ] 0578 DFA6 60 RTS 0579 DFA7 0580 DFA7 COLHEX 0581 DFA7 [ FALSE = &00 0584 DFA7 ] 0585 DFA7 AE C2 03 LDX INFO +BKEXEC ;get selected slot to X 0586 DFAA E0 10 CPXIM NROM ;does the slot have a table entry? 0587 DFAC [ TRUE = &00 0588 DFAC B0 70 BCS FRIEZE ;[not in table] 0589 DFAE | 0591 DFAE ] 0592 DFAE BD A1 02 LDAAX ROMS 0593 DFB1 10 6B BPL FRIEZE ;[not a service ROM] 0594 DFB3 ABACUS 0595 DFB3 A5 F4 LDA ROMID ;save current ROM 0596 DFB5 48 PHA 0597 DFB6 20 DB DB JSR STXROM 0598 DFB9 A9 04 LDAIM SVNAME 0599 DFBB 20 03 80 JSR ROMSFT ;call service ROM 0600 DFBE AA TAX ;if ROM did not claim the call 0601 DFBF D0 5D BNE FRIEZE ;then raise "Bad command" 0602 DFC1 4C 90 F1 JMP SVOP3 ;[service claimed, do not offer to other ROMs] 0603 DFC4 | 0612 DFC4 ] 0613 DFC4 ] 0614 DFC4 0615 DFC4 [ MOS125 = &00 0624 DFC4 ] 0625 DFC4 0626 DFC4 [ MOS125 = &FF 0627 DFC4 | 0628 DFC4 CLINT 0629 DFC4 86 F2 STX WORK +&00 0630 DFC6 84 F3 STY WORK +&01 0631 DFC8 ; report *command to filing system 0632 DFC8 A9 08 LDAIM FSCLI 0633 DFCA 20 8A E0 JSR JMIFSC 0634 DFCD ; check line is terminated by CR 0635 DFCD A0 00 LDYIM ZERO 0636 DFCF A9 0D LDAIM MCR 0637 DFD1 D1 F2 CLICHK CMPIY WORK 0638 DFD3 F0 04 BEQ CLILOK ;[terminator present] 0639 DFD5 C8 INY 0640 DFD6 D0 F9 BNE CLICHK 0641 DFD8 ; no terminator within 256 bytes so ignore line 0642 DFD8 CLIRTS 0643 DFD8 60 RTS 0644 DFD9 ; 0645 DFD9 A0 FF CLILOK LDYIM &FF ;start scan from beginning of input buffer 0646 DFDB ; N.B. Y will now be incremented to ZERO by SKIPSN 0647 DFDB CLIR ;skip leading spaces and asterisks 0648 DFDB 20 92 E0 JSR SKIPSN ;skip spaces/asterisk and spaces 0649 DFDE F0 F8 BEQ CLIRTS ;[reached end-of-line, ignore line] 0650 DFE0 C9 2A CMPIM SPLAT 0651 DFE2 F0 F7 BEQ CLIR ;[asterisk, ignore] 0652 DFE4 [ FALSE=0 0656 DFE4 ] 0657 DFE4 ; ignore comment line 0658 DFE4 C9 7C CMPIM "|" 0659 DFE6 F0 F0 BEQ CLIRTS ;[*| command] 0660 DFE8 ; check for override 0661 DFE8 C9 2F CMPIM "/" 0662 DFEA D0 09 BNE NOTSL ;[not /] 0663 DFEC ; */name 0664 DFEC C8 INY ;skip past / 0665 DFED 20 59 E0 JSR CLIXY ;make XY -> after / 0666 DFF0 A9 02 LDAIM FSNOTA 0667 DFF2 [ MOS125 = &7F 0668 DFF2 [ STARGO = &00 Acorn macro assembler Page 73 MOS38 CLI 0669 DFF2 4C 83 E0 JMP JMICMD ;[ALWAYS JUMP] 0670 DFF5 NOTSL 0671 DFF5 ; save pointer to rest of line 0672 DFF5 84 E6 STY CLIRY 0673 DFF7 C9 3A CMPIM ":" 0674 DFF9 D0 26 BNE NOTCO 0675 DFFB C8 INY ;skip past colon 0676 DFFC [ TRUE = &00 0677 DFFC D1 F2 CMPIY WORK ;is there a second colon? 0678 DFFE D0 21 BNE NOTCO ;reject if not 0679 E000 C8 INY ;skip past colon 0680 E001 ] 0681 E001 D1 F2 CMPIY WORK ;three colons? 0682 E003 D0 06 BNE COLON ;if not then get hex 0683 E005 20 92 E0 JSR SKIPSN ;else skip colon and spaces 0684 E008 98 TYA ;command line offset to A 0685 E009 D0 73 BNE CLIFS ;pass rest of line via FSC 3 (always) 0686 E00B COLON 0687 E00B A2 D4 LDXIM INFO +BKEXEC -FBLOCK ;hopefully out of the way 0688 E00D 20 70 E2 JSR LSA ;hex to scratch space 0689 E010 08 PHP ;save result 0690 E011 20 93 E0 JSR SKIPSP 0691 E014 28 PLP 0692 E015 B0 90 BCS COLHEX ;if hex present, call specific ROM 0693 E017 A2 04 LDXIM SVNAME ;else pass to service ROMs only 0694 E019 20 74 F1 JSR SVOP 0695 E01C F0 49 BEQ SVACK 0696 E01E FRIEZE 0697 E01E 4C 55 E3 JMP MBDCMD 0698 E021 NOTCO 0699 E021 | 0704 E021 ] 0705 E021 | 0710 E021 ] 0711 E021 ; X=&FF going to 0, point to start of table 0712 E021 A2 FF LDXIM &FF 0713 E023 CLIRST ; restart search at next keyword 0714 E023 A4 E6 LDY CLIRY ; reset pointer to start of user word 0715 E025 88 DEY ;cancel first INY 0716 E026 CLIADV ; compare characters 0717 E026 C8 INY ; advance user word pointer 0718 E027 B1 F2 LDAIY WORK ; fetch user character 0719 E029 20 27 E5 JSR CAPS ; set C=1 iff alpha [not iff caps] 0720 E02C 29 5F ANDIM &5F ; equate cases and also clear bit 7 0721 E02E E8 INX ; advance table pointer or skip aux byte 0722 E02F 5D B8 DE EORAX COMTAB ; set b7 from table and compare b6..0 0723 E032 ;N Z C meaning action may test/absorb "." 0724 E032 ;0 0 0 mismatch skip y (won't find ".") 0725 E032 ;0 0 1 end of user word/abbr. skip/accept y 0726 E032 ;0 1 0 characters match advance n 0727 E032 ;0 1 1 impossible - - 0728 E032 ;1 0 0 end of keyword skip n 0729 E032 ;1 0 1 end of both words accept n 0730 E032 F0 F2 BEQ CLIADV ; if Z=1 then characters match, advance 0731 E034 ;x 0 x 0732 E034 CLIFIN 0733 E034 30 07 BMI CLISKP ; if N=1 then skip or set up X and accept 0734 E036 ;0 0 x 0735 E036 B1 F2 LDAIY WORK ; restore user character 0736 E038 C8 INY ; advance pointer past dot 0737 E039 49 D1 EORIM ".":EOR:&FF ; if it was ".", now A=&FF 0738 E03B C9 FF CMPIM &FF ; C=0 if mismatch, skip; C=1 if abbreviation, accept 0739 E03D CLISKP 0740 E03D ;x 0 x 0741 E03D E8 INX ; skip high byte of action address 0742 E03E CLIALI ; align to keyword terminator 0743 E03E E8 INX ; advance table pointer or skip low byte of action address 0744 E03F BD B6 DE LDAAX COMTAB -&02 ; test table byte at original offset 0745 E042 10 FA BPL CLIALI ;[not reached address hi-byte] 0746 E044 90 2A BCC CLITMN ;if C=0, command rejected; test high byte 0747 E046 ;must go to CLITMN at the terminator! 0748 E046 ;terminator's keyword must NEVER match [i.e. it must be a duplicate] 0749 E046 ;CLIMFN ;full name match 0750 E046 ; found CLI command match 0751 E046 ; construct JMI hi-byte value to command processing code 0752 E046 48 PHA 0753 E047 ; construct JMI lo-byte value to command processing code 0754 E047 BD B7 DE LDAAX COMTAB -&01 0755 E04A 48 PHA 0756 E04B ; skip spaces after command name 0757 E04B 20 93 E0 JSR SKIPSP 0758 E04E 18 CLC ;C=0 used by FXN entry 0759 E04F 08 PHP ;status used by EXEC and SPOOL 0760 E050 ; (optionally) make XY -> rest of line 0761 E050 20 54 E0 JSR CLIXYA 0762 E053 40 RTI ;enter command processing routine 0763 E054 0764 E054 0765 E054 CLIXYA ;conditionally make XY -> rest of line 0766 E054 BD B8 DE LDAAX COMTAB 0767 E057 30 0E BMI CLIXY0 ;[keep Y = offset of rest of line from WORK] 0768 E059 CLIXY ;make XY -> rest of command line 0769 E059 98 TYA ;A = offset of rest of line 0770 E05A BC B8 DE LDYAX COMTAB ;Y := function code 0771 E05D CLIXY2 0772 E05D 18 CLC 0773 E05E 65 F2 ADC WORK ;N.B. C=1 => carry 0774 E060 AA TAX ;X = lo-byte of pointer to rest of line 0775 E061 98 TYA ;A = function code 0776 E062 A4 F3 LDY WORK +&01 0777 E064 90 01 BCC CLIXY1 ;[no carry] 0778 E066 ; carry 0779 E066 C8 INY 0780 E067 CLIXY1 ;N.B. Y = hi-byte of pointer to rest of line 0781 E067 CLIXY0 0782 E067 SVACK ;command accepted by service ROM 0783 E067 60 RTS 0784 E068 0785 E068 0786 E068 BASIC ;select BASIC language ROM 0787 E068 AE 4B 02 LDX BROMID 0788 E06B 30 06 BMI NBASIC ;[no BASIC ROM] 0789 E06D 4C A9 DB JMP ILR2 ;enter BASIC ROM (N.B. A b0=1, enter with C=1) 0790 E070 0791 E070 CLITMN ;keyword rejected, action address reached 0792 E070 0A ASLA ;test bits 14..8 0793 E071 D0 B0 BNE CLIRST ;if high byte was >&80, compare with next keyword 0794 E073 ;else &80 = command table terminator, fall through to CLIEND 0795 E073 0796 E073 ;END OF MOS 1.25 0797 E073 ] Acorn macro assembler Page 74 MOS38 CLI 0798 E073 0799 E073 LNK MOS39 0001 E073 ; > MOS39 0002 E073 TTL MOS39 CLI 0003 E073 OPT MOS39 Acorn macro assembler Page 75 MOS39 CLI 0004 E073 ;(c) 1981 ACORN 0005 E073 ;BBC MOS 0006 E073 ;Change record: 0007 E073 ;004 29-Jul-81 MP Prototype version 0008 E073 ;Author(s): 0009 E073 ;PB Paul Bond 0010 E073 ;MP Mike Prees 0011 E073 0012 E073 0013 E073 NBASIC ;BASIC ROM not present so offer to service ROMs 0014 E073 CLIEND ;entered here if command not recognised or does not exist 0015 E073 ; offer command to service ROMs 0016 E073 A4 E6 LDY CLIRY ;restore Y offset to point to command name 0017 E075 A2 04 LDXIM SVNAME 0018 E077 20 74 F1 JSR SVOP 0019 E07A F0 EB BEQ SVACK ;[accepted by service ROM] 0020 E07C ; command not accepted by a service ROM 0021 E07C ; so pass command to filing system 0022 E07C A5 E6 LDA CLIRY ;A = offset to command name 0023 E07E [ MOS125 = &7F 0024 E07E [ STARGO = &00 0025 E07E CLIFS 0026 E07E ] 0027 E07E ] 0028 E07E 20 5D E0 JSR CLIXY2 ;make XY -> rest of line 0029 E081 A9 03 LDAIM FSNAME 0030 E083 [ MOS125 = &7F 0031 E083 [ STARGO = &00 0032 E083 JMICMD 0033 E083 ;entry for FSC calls 2,3,4,(11) 0034 E083 ;cancel OSARGS 1 intercept, FS provides the tail pointer itself 0035 E083 48 PHA 0036 E084 A9 00 LDAIM &00 0037 E086 8D D1 02 STA TAILHI 0038 E089 68 PLA 0039 E08A ] 0040 E08A ] 0041 E08A 0042 E08A JMIFSC 0043 E08A 0044 E08A 6C 1E 02 JMI FSCVEC 0045 E08D ; 0046 E08D ; 0047 E08D OPT 0048 E08D 0A ASLA ;lsb(A) := 0 0049 E08E ;* LDAIM $00 0050 E08E EOF 0051 E08E 29 01 ANDIM &01 ;$00 => OPT, $01 => EOF 0052 E090 10 F8 BPL JMIFSC ;[ALWAYS JUMP, present option to file system AND return] 0053 E092 0054 E092 0055 E092 ; ignore space characters 0056 E092 C8 SKIPSN INY ;skip current character 0057 E093 B1 F2 SKIPSP LDAIY WORK 0058 E095 C9 20 CMPIM SPACE 0059 E097 F0 F9 BEQ SKIPSN ;[character is space, ignore] 0060 E099 C9 0D SKPSP1 CMPIM MCR 0061 E09B ; Z=1 next character is CR 0062 E09B ; Z=0 next character is not CR 0063 E09B 60 RTS 0064 E09C SKPCM ;C=0 => check for line end 0065 E09C ;C=1 => skip optional comma and check for line end 0066 E09C 90 F5 BCC SKIPSP 0067 E09E SKPCOM 0068 E09E ; skip spaces and an optional comma 0069 E09E 20 93 E0 JSR SKIPSP 0070 E0A1 C9 2C CMPIM "," 0071 E0A3 D0 F4 BNE SKPSP1 0072 E0A5 C8 INY ;N.B. force Z=0 (i.e. non-zero result) 0073 E0A6 60 RTS 0074 E0A7 ; get decimal number 0075 E0A7 [ MOS125 = &FF 0108 E0A7 | 0109 E0A7 GETNUM 0110 E0A7 20 93 E0 JSR SKIPSP ;skip leading spaces, A := delimiter 0111 E0AA 20 CF E0 JSR TSTNUM 0112 E0AD B0 13 BCS GN0 0113 E0AF 60 RTS ;C=0 [not a digit] 0114 E0B0 0115 E0B0 GNT 0116 E0B0 E0 1A CPXIM &1A ;if 26 or more 0117 E0B2 B0 2B BCS TSTNR ;then overflow 0118 E0B4 AA TAX ;save last digit read 0119 E0B5 A5 E6 LDA NUMBER 0120 E0B7 0A ASLA ;times 2 0121 E0B8 0A ASLA ;times 4 0122 E0B9 65 E6 ADC NUMBER ;times 5; C=0 0123 E0BB 0A ASLA ;times 10; C=0 0124 E0BC 86 E6 STX NUMBER ;NUMBER := most recently read digit 0125 E0BE ; N.B. C=0 0126 E0BE 65 E6 ADC NUMBER ;A := accumulated value 0127 E0C0 B0 1D BCS TSTNR ;[overflow] 0128 E0C2 GN0 0129 E0C2 85 E6 STA NUMBER ;NUMBER := accumulated number so far (must save for KEY) 0130 E0C4 AA TAX 0131 E0C5 20 CE E0 JSR TSTNUX ;read digit skipping current character 0132 E0C8 B0 E6 BCS GNT ;process digit [non-digit serves as terminator] 0133 E0CA C9 0D CMPIM MCR 0134 E0CC 38 SEC 0135 E0CD ; return with: 0136 E0CD ; C=1 => valid number, Z=1/0 => delimiter is/is_not CR, number in X 0137 E0CD 60 RTS 0138 E0CE ] 0139 E0CE 0140 E0CE ; check character is a digit 0141 E0CE TSTNUX 0142 E0CE C8 INY ;skip current character 0143 E0CF TSTNUM 0144 E0CF B1 F2 LDAIY WORK ;get next character 0145 E0D1 C9 3A CMPIM &3A ;N.B. $3A = '9' + 1 0146 E0D3 B0 0A BCS TSTNR ;[bad digit, > '9'] 0147 E0D5 C9 30 CMPIM "0" 0148 E0D7 90 06 BCC TSTNR ;[bad digit, < '0'] 0149 E0D9 29 0F ANDIM &0F ;convert to number (do not corrupt V) 0150 E0DB ; N.B. C=1 0151 E0DB 60 RTS 0152 E0DC 0153 E0DC TSTNRX 0154 E0DC 20 9E E0 JSR SKPCOM 0155 E0DF TSTNR 0156 E0DF 18 CLC Acorn macro assembler Page 76 MOS39 CLI 0157 E0E0 ; C=0 bad number, A = delimiting character 0158 E0E0 60 RTS 0159 E0E1 0160 E0E1 TSTHEX ;test for, and convert, hex digit 0161 E0E1 20 CF E0 JSR TSTNUM 0162 E0E4 B0 0E BCS TSTH0 ;[is a number, therefore a valid hex digit] 0163 E0E6 29 DF ANDIM &DF ;force upper case 0164 E0E8 C9 47 CMPIM "G" 0165 E0EA B0 F0 BCS TSTNRX ;[>'F' so fail] 0166 E0EC C9 41 CMPIM "A" 0167 E0EE 90 EC BCC TSTNRX ;[<'A' so fail] 0168 E0F0 08 PHP ;save V 0169 E0F1 E9 37 SBCIM ALPHAA -&0A ;convert to hex 0170 E0F3 28 PLP ;restore V 0171 E0F4 ; C=1 0172 E0F4 TSTH0 ;C=1 0173 E0F4 C8 INY 0174 E0F5 60 RTS 0175 E0F6 0176 E0F6 0177 E0F6 WRCH ;system write character 0178 E0F6 48 PHA ;save character on stack 0179 E0F7 8A TXA ;save registers 0180 E0F8 48 PHA 0181 E0F9 98 TYA 0182 E0FA 48 PHA 0183 E0FB BA TSX 0184 E0FC BD 03 01 LDAAX &0103 ;restore character 0185 E0FF 48 PHA 0186 E100 ; A = character 0187 E100 0188 E100 ; examine WRCH selection(s) 0189 E100 ; 0190 E100 2C 60 02 BIT NETWRC 0191 E103 10 08 BPL WRCNTN ;[WRCH not to net] 0192 E105 ; WRCH to net 0193 E105 ; A = character 0194 E105 A8 TAY ;send character in Y 0195 E106 A9 04 LDAIM NTWRCH 0196 E108 20 C1 E5 JSR JMINET ;WRCH thru net 0197 E10B B0 52 BCS WRCHNN ;[immediate return to caller] 0198 E10D ; 0199 E10D ; continue within WRCH 0200 E10D ; 0201 E10D WRCNTN 0202 E10D 0203 E10D 18 CLC ;in case VDU not selected 0204 E10E A9 02 LDAIM WRVDU 0205 E110 2C 7C 02 BIT WRCHSW 0206 E113 D0 05 BNE WRCHNV ;[WRCH not to VDU] 0207 E115 ; WRCH to VDU 0208 E115 68 PLA 0209 E116 48 PHA ;A := character 0210 E117 20 C0 C4 JSR VDU 0211 E11A ; C=0 => VDU says do not print character 0212 E11A WRCHNV ;WRCH not to VDU 0213 E11A 0214 E11A ; C=0 => VDU (if selected) says do not print character 0215 E11A ; check who controls printing 0216 E11A A9 08 LDAIM WRPRNT 0217 E11C 2C 7C 02 BIT WRCHSW 0218 E11F D0 02 BNE WRCHNC ;[printing not controlled by VDU] 0219 E121 ; printing controlled by VDU 0220 E121 90 05 BCC WRCHNP ;[VDU says do not print character] 0221 E123 WRCHNC ;conditionally print character 0222 E123 68 PLA 0223 E124 48 PHA ;A := character 0224 E125 20 66 E1 JSR MPRINT ;conditionally print character 0225 E128 WRCHNP ;do not print character 0226 E128 0227 E128 ; check for output to RS423 0228 E128 ; 0229 E128 [ FALSE=0 0233 E128 | 0234 E128 AD 7C 02 LDA WRCHSW 0235 E12B 6A RORA ;**************** ASSUME WRRS = 1 **************** 0236 E12C 90 1B BCC WRCHNR ;[RS423 disabled] 0237 E12E ] 0238 E12E 0239 E12E ; WRCH via RS423 0240 E12E A4 EA LDY RSTUT 0241 E130 88 DEY 0242 E131 10 16 BPL WRCHNR ;[RS423 managed by CFS, ignore WRCH request] 0243 E133 68 PLA 0244 E134 48 PHA ;A := character 0245 E135 ; 0246 E135 08 PHP 0247 E136 78 SEI 0248 E137 A2 02 LDXIM BRSO 0249 E139 48 PHA 0250 E13A 20 9F E4 JSR EXAM 0251 E13D 90 03 BCC WRCNP1 ;[buffer not empty] 0252 E13F ; RS423 output buffer empty 0253 E13F 20 C0 E1 JSR RSBUSY ;enable RS423 Tx interrupts 0254 E142 WRCNP1 0255 E142 68 PLA 0256 E143 A2 02 LDXIM BRSO 0257 E145 20 49 E2 JSR WRITE ;insert character into RS423 output buffer, waiting if necessary 0258 E148 ; N.B. WRITE disables interrupts 0259 E148 ; character not inserted if ESCAPE detected 0260 E148 28 PLP 0261 E149 ; 0262 E149 WRCHNR ;not via RS423 0263 E149 0264 E149 ; check for spooling enabled 0265 E149 ; check whether spooling active 0266 E149 A9 10 LDAIM WRSPL 0267 E14B 2C 7C 02 BIT WRCHSW 0268 E14E D0 0F BNE WRCHNS ;[spooling disabled] 0269 E150 ; spool character 0270 E150 AC 57 02 LDY SPOOLH 0271 E153 F0 0A BEQ WRCHNS ;[spooling not active] 0272 E155 ; spooling active 0273 E155 ; write byte to spool file 0274 E155 68 PLA 0275 E156 48 PHA ;A := character 0276 E157 ; 0277 E157 38 SEC 0278 E158 66 EB ROR ESSEMA ;enter critical region 0279 E15A 20 D4 FF JSR OSBPUT 0280 E15D 46 EB LSR ESSEMA ;exit critical region Acorn macro assembler Page 77 MOS39 CLI 0281 E15F WRCHNS ;no spooling 0282 E15F 0283 E15F WRCHNN 0284 E15F ; exit restoring registers 0285 E15F 68 PLA ;pull redundant byte 0286 E160 [ MOS125 = &FF 0287 E160 | 0288 E160 PLYXAR 0289 E160 ] 0290 E160 68 PLA 0291 E161 A8 TAY 0292 E162 68 PLA 0293 E163 AA TAX 0294 E164 68 PLA ;restore character 0295 E165 60 RTS 0296 E166 0297 E166 MPRINT ;conditionally print character in A 0298 E166 ; N.B. character should never be NUL 0299 E166 ; decide whether to ignore character 0300 E166 2C 7C 02 BIT WRCHSW 0301 E169 70 20 BVS PRINT0 ;[only print thru VDU1] 0302 E16B CD 86 02 CMP PIGNOR 0303 E16E F0 1B BEQ PRINT0 ;[match on printer ignore character] 0304 E170 ; 0305 E170 ; 0306 E170 ; ====== 0307 E170 ; PRINT 0308 E170 ; ====== 0309 E170 ; 0310 E170 ; Print a character via VDU 1 0311 E170 ; 0312 E170 ; ENTRY:- A = Character 0313 E170 ; 0314 E170 ; EXIT:- A,X,Y corrupt 0315 E170 ; Flags preserved 0316 E170 ; 0317 E170 PRINT ;used by VDU (SOH), uses fact of exit with C=0 0318 E170 08 PHP 0319 E171 78 SEI 0320 E172 ; N.B. if print sink is 0 then character will 0321 E172 ; eventually be ignored by STROBE 0322 E172 ; 0323 E172 AA TAX ;save print character 0324 E173 ; 0325 E173 ; test whether printer enabled 0326 E173 ; 0327 E173 A9 04 LDAIM WRPREN 0328 E175 2C 7C 02 BIT WRCHSW 0329 E178 D0 10 BNE PRINT4 ;[printer disabled] 0330 E17A ; 0331 E17A 8A TXA ;restore print character 0332 E17B A2 03 LDXIM BPRNT ;X := print bufferid 0333 E17D 20 49 E2 JSR WRITE ;write character to buffer, waiting if necessary 0334 E180 B0 08 BCS PRINT3 ;[ESCAPE detected] 0335 E182 ; 0336 E182 ; test printer status; interrupts disabled 0337 E182 ; 0338 E182 2C D2 02 BIT PFLAG 0339 E185 10 03 BPL PRINT3 ;[printer busy] 0340 E187 ; 0341 E187 ; printer dormant 0342 E187 ; send the first character 0343 E187 ; 0344 E187 20 8C E1 JSR STROBE ;send character to selected printer 0345 E18A ; 0346 E18A PRINT3 ;printer busy 0347 E18A PRINT4 ;return enabling interrupts 0348 E18A 28 PLP ;restore interrupt state, set C=0 (fact used by VDU) 0349 E18B ; 0350 E18B PRINT0 0351 E18B 60 RTS 0352 E18C 0353 E18C 0354 E18C STROBE ;send character to selected printer 0355 E18C ; **************************************** 0356 E18C ; MUST BE ENTERED WITH INTERRUPTS DISABLED 0357 E18C ; ********************************** 0358 E18C ; determine print sink 0359 E18C AD 85 02 LDA PRNTSW 0360 E18F F0 6C BEQ PURGE ;[ignore print request] 0361 E191 ; print sink determined by PRNTSW 0362 E191 ; 0: infinite print sink 0363 E191 ; 1: centronics 0364 E191 ; 2: RS423 output 0365 E191 ; 3: user print routine 0366 E191 ; 4: net printer server 0367 E191 [ MOS125 = &FF 0370 E191 | 0371 E191 C9 02 CMPIM PRS 0372 E193 B0 21 BCS STROB1 ;[not centronics] 0373 E195 ] 0374 E195 ; centronics interface 0375 E195 ; this code must be executed with interrupts disabled 0376 E195 ; otherwise a CA1 interrupt coinciding with the STA PAR 0377 E195 ; would result in a spurious interrupt which would not 0378 E195 ; be recognised, resulting in a 'Bad IRQ' state 0379 E195 20 A4 E4 JSR REMOV ;remove character from print buffer 0380 E198 6E D2 02 ROR PFLAG 0381 E19B 30 43 BMI STROB0 ;[no more characters to print] 0382 E19D A0 82 LDYIM &82 0383 E19F 8C 6E FE STY IERR ;enable parallel port printer interrupt 0384 E1A2 ; write character 0385 E1A2 8D 61 FE STA PAR 0386 E1A5 ; pulse strobe line 0387 E1A5 AD 6C FE LDA PCRR 0388 E1A8 29 F1 ANDIM &F1 ;********** DO NOT CHANGE 0389 E1AA 09 0C ORAIM CA2LO ;********** DO NOT CHANGE 0390 E1AC 8D 6C FE STA PCRR ;CA2 strobe lo (signal inverted by h/w) 0391 E1AF 09 0E ORAIM CA2HI ;********** DO NOT CHANGE 0392 E1B1 8D 6C FE STA PCRR ;CA2 strobe hi (signal inverted by h/w) 0393 E1B4 ; N.B. leave signal hi 0394 E1B4 D0 2A BNE STROB0 ;[ALWAYS jump, exit] 0395 E1B6 0396 E1B6 STROB1 ;not centronics 0397 E1B6 ; X = bufferid 0398 E1B6 [ MOS125 = &FF 0400 E1B6 ] 0401 E1B6 D0 29 BNE STROB3 ;[not RS423] 0402 E1B8 ; printer is RS423 0403 E1B8 A4 EA LDY RSTUT 0404 E1BA 88 DEY Acorn macro assembler Page 78 MOS39 CLI 0405 E1BB 10 40 BPL STCRS ;[RS423 printer managed by CFS, ignore print request] 0406 E1BD ; print to RS423 0407 E1BD 4E D2 02 LSR PFLAG ;flag printer busy 0408 E1C0 ; 0409 E1C0 RSBUSY 0410 E1C0 4E 4F 02 LSR RSFLAG ;flag RS423 busy 0411 E1C3 ; 0412 E1C3 RSETX ;enable RS423 Tx interrupts 0413 E1C3 20 83 E7 JSR CNTRS 0414 E1C6 90 18 BCC RSOVF ;[RS423 input buffer overflow] 0415 E1C8 ; 0416 E1C8 A2 20 LDXIM RHITXE ;set RTS hi, Tx interrupt enabled 0417 E1CA ; 0418 E1CA RSED ;alter Tx control register to X 0419 E1CA A0 9F LDYIM &9F ;field is b6-b5 0420 E1CC ; 0421 E1CC RS423 0422 E1CC 08 PHP 0423 E1CD 78 SEI 0424 E1CE 98 TYA ;A := mask 0425 E1CF ; ***************************************** 0426 E1CF ; MUST BE EXECUTED WITH INTERRUPTS DISABLED 0427 E1CF ; ***************************************** 0428 E1CF ; A = mask (altered) 0429 E1CF ; X = new value 0430 E1CF 86 FA STX RSOP ;save new value of field 0431 E1D1 2D 50 02 AND RSCTFL ;copy status and clear field for new status 0432 E1D4 45 FA EOR RSOP ;add in new status 0433 E1D6 AE 50 02 LDX RSCTFL ;X := old value 0434 E1D9 STARSC ;used by MC6850 N.B. does PLP RTS 0435 E1D9 0436 E1D9 8D 50 02 STA RSCTFL ;update record of status 0437 E1DC 8D 08 FE STA RSCTL ;update 6850 0438 E1DF 28 PLP 0439 E1E0 RSOVF ;RS423 input buffer overflow 0440 E1E0 STROB0 0441 E1E0 60 RTS 0442 E1E1 0443 E1E1 STROB3 ;not RS423 0444 E1E1 0445 E1E1 18 CLC 0446 E1E2 0447 E1E2 ; C=0 0448 E1E2 ; user or net print 0449 E1E2 ; X=print_bufferid 0450 E1E2 ; character in printer buffer 0451 E1E2 A9 01 LDAIM UPWRCH 0452 E1E4 20 F2 E1 JSR mUPT ;call print routine (returns with carry meaningful) 0453 E1E7 PFREE ;indicate printer dormant (OSBYTE call used by UPT routine) 0454 E1E7 6E D2 02 ROR PFLAG ;set printer status according to user print routine 0455 E1EA ; C=0 => printer busy 0456 E1EA ; C=1 => printer free 0457 E1EA ; (default user print routine is DEFUPT) 0458 E1EA UPTRTS 0459 E1EA 60 RTS 0460 E1EB 0461 E1EB 0462 E1EB UPTINT ;timer interrupt 0463 E1EB 2C D2 02 BIT PFLAG 0464 E1EE 30 FA BMI UPTRTS ;[printer dormant] 0465 E1F0 ; 0466 E1F0 ; give a hand to polled printers 0467 E1F0 A9 00 LDAIM UPTIME 0468 E1F2 ; 0469 E1F2 MUPT ;call user print routine (also used by VDU software) 0470 E1F2 ; A = reason code ($02/$03) 0471 E1F2 A2 03 LDXIM BPRNT ;X := print buffer id 0472 E1F4 ; 0473 E1F4 UPTX ;entered by *FX5 0474 E1F4 AC 85 02 LDY PRNTSW ;Y := current print selection 0475 E1F7 20 C1 E5 JSR JMINET ;call net print routine 0476 E1FA 6C 22 02 JMI UPTVEC ;call user print routine AND return 0477 E1FD 0478 E1FD 0479 E1FD STROB4 ;not user print 0480 E1FD STCRS ;RS423 managed by cassette 0481 E1FD ; ignore print request by purging buffer AND return 0482 E1FD PURGE 0483 E1FD ; purge buffer given by index in X 0484 E1FD ; this routine does not corrupt A or X 0485 E1FD 18 CLC 0486 E1FE ; 0487 E1FE PURGEX ;entered by OSWORD sound routine with C=1 0488 E1FE 48 PHA ;save A 0489 E1FF 08 PHP ;save interrupt state 0490 E200 78 SEI 0491 E201 ; 0492 E201 ; kill sound channel if sound buffer 0493 E201 B0 08 BCS PURNSB ;[OSWORD call so do not kill sound] 0494 E203 BD B2 E9 LDAAX BUFTYP 0495 E206 10 03 BPL PURNSB ;[not a sound buffer] 0496 E208 ; kill sound on channel X 0497 E208 20 C5 EC JSR SCRST 0498 E20B PURNSB 0499 E20B [ MOS125 = &FF 0514 E20B | 0515 E20B ; 0516 E20B ; check for input buffer 0517 E20B E0 02 CPXIM OUTPUT 0518 E20D B0 08 BCS VAULT ;[output buffer] 0519 E20F ; 0520 E20F ; input buffer, kill soft key expansion and VDU queueing 0521 E20F ; 0522 E20F A9 00 LDAIM ZERO 0523 E211 8D 68 02 STA SOFKL ;kill soft key expansion 0524 E214 8D 6A 02 STA QPOSN ;kill VDU queueing 0525 E217 ; 0526 E217 ;if input buffer OR first output buffer i.e. RS423 0527 E217 ;then Z=1; buffer flag unused, preserve 0528 E217 F0 03 VAULT BEQ PURGE3 0529 E219 ;otherwise C=1 0530 E219 ; flag buffer dormant 0531 E219 7E CF 02 RORAX BACTIV 0532 E21C ;CNPV routine ignores C when V=1 0533 E21C ] 0534 E21C ; 0535 E21C PURGE3 0536 E21C ; 0537 E21C 20 7D E7 JSR JMIPUR ;use indirection with V=1 (defaults to CNP) 0538 E21F ; 0539 E21F 28 PLP ;restore interrupt state Acorn macro assembler Page 79 MOS39 CLI 0540 E220 68 PLA ;restore A 0541 E221 60 RTS 0542 E222 ; 0543 E222 ; 0544 E222 CNP ;count buffer entries / purge buffer 0545 E222 [ $Tutu 0548 E222 | 0549 E222 50 07 BVC COUNT ;[count buffer entries] 0550 E224 ] 0551 E224 ; 0552 E224 ; purge buffer 0553 E224 ; 0554 E224 ; reset buffer pointers 0555 E224 ; set buffer start = buffer end 0556 E224 BD D8 02 LDAAX BFSTRT 0557 E227 9D E1 02 STAAX BFEND 0558 E22A 60 RTS 0559 E22B ; 0560 E22B ; 0561 E22B COUNT 0562 E22B 08 PHP 0563 E22C 78 SEI 0564 E22D ; 0565 E22D 08 PHP ;save count type 0566 E22E ; 0567 E22E 38 SEC 0568 E22F BD E1 02 LDAAX BFEND 0569 E232 FD D8 02 SBCAX BFSTRT 0570 E235 B0 04 BCS BUFNX1 0571 E237 ; adjust for overflow 0572 E237 38 SEC 0573 E238 FD 8B E4 SBCAX BFORG 0574 E23B BUFNX1 0575 E23B ; 0576 E23B 28 PLP ;restore count type 0577 E23C ; 0578 E23C 90 06 BCC BFCNT0 ;[input buffer] 0579 E23E ; 0580 E23E ; output buffer 0581 E23E ; adjust to give remaining entries 0582 E23E 18 CLC 0583 E23F 7D 8B E4 ADCAX BFORG 0584 E242 49 FF EORIM &FF 0585 E244 ; 0586 E244 BFCNT0 0587 E244 A0 00 LDYIM ZERO 0588 E246 AA TAX 0589 E247 ; 0590 E247 28 PLP 0591 E248 60 RTS 0592 E249 0593 E249 0594 E249 LNK MOS40 0001 E249 0002 E249 ; MOS40 0003 E249 TTL MOS40 Machine operating system internal commands 0004 E249 OPT MOS40 Acorn macro assembler Page 80 MOS40 Machine operating system internal commands 0005 E249 ;(c) 1981 ACORN Computers Limited 0006 E249 ;BBC Microcomputer Machine Operating System (MOS) 0007 E249 ;Change record: 0008 E249 ;033 12-Aug-81 PB Reset SKNEND code, check KEY line termination 0009 E249 ;032 12-Aug-81 PB Extracted from CLI code 0010 E249 ;Author(s): 0011 E249 ;PB Paul Bond 0012 E249 ;MP Mike Prees 0013 E249 0014 E249 0015 E249 WRITE 0016 E249 WRITE1 0017 E249 78 SEI ;another critical region 0018 E24A 20 F4 E4 JSR INSRT ;attempt to add character to print queue 0019 E24D 90 0F BCC WRITE0 ;[character inserted into printer buffer] 0020 E24F ; printer buffer full 0021 E24F ; C=1 0022 E24F 20 EF E9 JSR LEDSON ;conditionally set LEDs and test escape condition 0023 E252 ; N.B. does not corrupt C or X 0024 E252 ; C=1 0025 E252 ; reset LEDs 0026 E252 08 PHP 0027 E253 48 PHA 0028 E254 20 04 EF JSR KBDIS 0029 E257 68 PLA 0030 E258 28 PLP 0031 E259 ; 0032 E259 30 03 BMI WRITE0 ;[escape detected] 0033 E25B 58 CLI ;enable interrupts to allow printer buffer to purge. 0034 E25C ; Interrupts are enabled at this part of the loop, 0035 E25C ; rather than at the begining (which would save 2 bytes of code) 0036 E25C ; in order to ensure that if the print routine is called with 0037 E25C ; interrupts disabled, then interrupts are not enabled if there is 0038 E25C ; room in the print buffer. 0039 E25C B0 EB BCS WRITE1 ;[ALWAYS jump, wait for room in printer buffer, C=1] 0040 E25E WRITE0 0041 E25E 60 RTS 0042 E25F 0043 E25F 0044 E25F CLRFB ;clear file control block 0045 E25F 48 PHA 0046 E260 A9 00 LDAIM ZERO 0047 E262 9D EE 02 STAAX FBLOCK 0048 E265 9D EF 02 STAAX FBLOCK +&01 0049 E268 9D F0 02 STAAX FBLOCK +&02 0050 E26B 9D F1 02 STAAX FBLOCK +&03 0051 E26E 68 PLA 0052 E26F 60 RTS 0053 E270 [ MOS125 = &FF 0076 E270 | 0077 E270 20 93 E0 LSA JSR SKIPSP 0078 E273 20 E1 E0 JSR TSTHEX 0079 E276 90 1F BCC LSA0 ;[hex not present, return V=1] 0080 E278 ; 0081 E278 ; clear field 0082 E278 ; 0083 E278 20 5F E2 JSR CLRFB 0084 E27B ; 0085 E27B ; read address 0086 E27B ; 0087 E27B LSA1 ;rotate hex digit into 4-byte address 0088 E27B ; move nibble into high nibble 0089 E27B ;set b3, clear b2..0 0090 E27B ;SEC ;C=1 from BCC LSA0 (CLRFB preserves) or BCS LSA1 0091 E27B 2A ROLA 0092 E27C 0A ASLA 0093 E27D 0A ASLA 0094 E27E 0A ASLA 0095 E27F ;shift once more. C=hex b3, A b4=1, b3..0=0 0096 E27F 0A ASLA 0097 E280 ROL4A ;rotate bit into address 0098 E280 3E EE 02 ROLAX FBLOCK 0099 E283 3E EF 02 ROLAX FBLOCK +&01 0100 E286 3E F0 02 ROLAX FBLOCK +&02 0101 E289 3E F1 02 ROLAX FBLOCK +&03 0102 E28C B0 35 BCS MBADHX ;[overflow] 0103 E28E ; C=0 0104 E28E 0A ASLA 0105 E28F D0 EF BNE ROL4A ;execute loop four times 0106 E291 ; C=1 which TSTHEX ignores 0107 E291 20 E1 E0 JSR TSTHEX 0108 E294 B0 E5 BCS LSA1 0109 E296 38 SEC ;return C=1 0110 E297 LSA0 ;Z=1 => CR terminator 0111 E297 60 RTS 0112 E298 ] 0113 E298 0114 E298 0115 E298 LOAD ;LOAD [load address] 0116 E298 A9 FF LDAIM &FF 0117 E29A SAVE ;(A=$00) SAVE [exechex] [loadhex] 0118 E29A 86 F2 STX WORK 0119 E29C 84 F3 STY WORK +&01 0120 E29E 8E EE 02 STX FBLOCK+FSTR+&0 0121 E2A1 8C EF 02 STY FBLOCK+FSTR+&1 0122 E2A4 48 PHA 0123 E2A5 ; clear load address 0124 E2A5 A2 02 LDXIM FLOAD 0125 E2A7 20 5F E2 JSR CLRFB 0126 E2AA ; set lsb exec address = $FF (preparing for possible LOAD) 0127 E2AA A0 FF LDYIM &FF 0128 E2AC 8C F4 02 STY FBLOCK+FEXEC ;'use file load address' 0129 E2AF ; set to read characters from WORK buffer 0130 E2AF C8 INY ;Y:=0 0131 E2B0 ; skip filename 0132 E2B0 20 78 EA JSR GSINTC 0133 E2B3 20 8A EA LS2 JSR GSREAD 0134 E2B6 90 FB BCC LS2 ;[string character] 0135 E2B8 ; determine command type 0136 E2B8 68 PLA 0137 E2B9 48 PHA 0138 E2BA F0 4D BEQ SAVEX ;[SAVE command] 0139 E2BC ; LOAD command 0140 E2BC ; 0141 E2BC ; read load address 0142 E2BC ; N.B. X=FLOAD 0143 E2BC 20 70 E2 JSR LSA 0144 E2BF B0 3B BCS LOADX1 ;hex present 0145 E2C1 F0 3E BEQ LS0 ;[just CR terminator] 0146 E2C3 MBADHX ;report error 'Bad address' 0147 E2C3 00 BRK Acorn macro assembler Page 81 MOS40 Machine operating system internal commands 0148 E2C4 FC = BADADR 0149 E2C5 42 61 64 = "Bad address" 0150 E2D0 00 = ZERO ;message terminator 0151 E2D1 0152 E2D1 0153 E2D1 SHUTES ;shut EXEC and SPOOL files 0154 E2D1 0155 E2D1 ; 0156 E2D1 ; inform paged ROMs of intentions 0157 E2D1 ; 0158 E2D1 A2 10 LDXIM SVSHES 0159 E2D3 20 74 F1 JSR SVOP 0160 E2D6 F0 23 BEQ SPOOL0 ;[claimed, do not close files] 0161 E2D8 ; 0162 E2D8 ; deal with EXEC file 0163 E2D8 ; 0164 E2D8 20 BB F6 JSR ECLOSE ;Close EXEC file 0165 E2DB ; 0166 E2DB ; close SPOOL file AND return 0167 E2DB ; 0168 E2DB A9 00 LDAIM ZERO ;Z=1, A=$00 0169 E2DD ; 0170 E2DD SPOOL ;SPOOL 0171 E2DD ; XY -> filename 0172 E2DD ; A = $00 0173 E2DD ; EQ -> spool off 0174 E2DD ;remember whether to just turn spooling off 0175 E2DD 08 PHP 0176 E2DE ; close old spool file 0177 E2DE 84 E6 STY SPOOLY ;save Y 0178 E2E0 AC 57 02 LDY SPOOLH 0179 E2E3 8D 57 02 STA SPOOLH ;clear spooling 0180 E2E6 F0 03 BEQ SPOOL2 ;[not currently spooling] 0181 E2E8 ; A=0 0182 E2E8 20 CE FF JSR OSFIND ;close spool file 0183 E2EB SPOOL2 0184 E2EB A4 E6 LDY SPOOLY ;restore Y 0185 E2ED 28 PLP 0186 E2EE F0 0B BEQ SPOOL0 ;[just close spool file] 0187 E2F0 ; open given spool file 0188 E2F0 A9 80 LDAIM &80 ;open file for output 0189 E2F2 20 CE FF JSR OSFIND 0190 E2F5 A8 TAY 0191 E2F6 F0 5D BEQ BADFX ;[open failure] 0192 E2F8 8D 57 02 STA SPOOLH 0193 E2FB SPOOL0 ;Z=1 0194 E2FB 60 RTS 0195 E2FC 0196 E2FC 0197 E2FC LOADX1 ;explicit load address given 0198 E2FC D0 57 BNE BADFX ;[no CR terminator] 0199 E2FE EE F4 02 INC FBLOCK+FEXEC ;use explicit load address 0200 E301 LS0 ;load file 0201 E301 A2 EE LDXIM FBLOCK 0202 E303 A0 02 LDYIM /(FBLOCK ) 0203 E305 68 PLA 0204 E306 4C DD FF JMP OSFILE 0205 E309 ; 0206 E309 [ MOS125 = &FF 0223 E309 ] 0224 E309 ; 0225 E309 ; 0226 E309 SAVEX ;SAVE command 0227 E309 ; 0228 E309 ; read FROM address 0229 E309 ; 0230 E309 A2 0A LDXIM FFROM 0231 E30B 20 70 E2 JSR LSA 0232 E30E 90 45 BCC BADFX 0233 E310 ; 0234 E310 ; read TO address 0235 E310 ; check if preceeded by '+' 0236 E310 ; 0237 E310 [ MOS125 = &FF 0243 E310 | 0244 E310 B1 F2 LDAIY WORK 0245 E312 49 AB EORIM "+":EOR:&80 0246 E314 69 FE ADCIM &FE ;c=1, set V iff symbol='+' 0247 E316 50 01 BVC SAVEX3 ;['+' not present] 0248 E318 ] 0249 E318 C8 INY ;skip '+' symbol 0250 E319 SAVEX3 0251 E319 A2 0E LDXIM FTO 0252 E31B 20 70 E2 JSR LSA ;N.B. does not corrupt V 0253 E31E 90 35 BCC BADFX ;[to address not given] 0254 E320 ; C=1 0255 E320 08 PHP ;Z => no exec address 0256 E321 ; if '+' was specified then the TO address was really 0257 E321 ; a length specification 0258 E321 50 0F BVC SAVEX4 ;['+' not specified] 0259 E323 ; convert length to end address 0260 E323 ; N.B. C=1 0261 E323 00FC MINUS4 * &00FC 0262 E323 A2 FC LDXIM MINUS4 0263 E325 18 CLC 0264 E326 SAVEX5 0265 E326 BD FC 01 LDAAX FBLOCK+FFROM-MINUS4 0266 E329 7D 00 02 ADCAX FBLOCK+FTO-MINUS4 0267 E32C 9D 00 02 STAAX FBLOCK+FTO-MINUS4 0268 E32F E8 INX 0269 E330 D0 F4 BNE SAVEX5 ;[execute loop four times] 0270 E332 SAVEX4 ;copy 'from' address to execute and load fields 0271 E332 A2 03 LDXIM &03 0272 E334 SAVEX1 0273 E334 BD F8 02 LDAAX FBLOCK+FFROM 0274 E337 9D F4 02 STAAX FBLOCK+FEXEC 0275 E33A 9D F0 02 STAAX FBLOCK+FLOAD 0276 E33D CA DEX 0277 E33E 10 F4 BPL SAVEX1 0278 E340 ; check if exec address present 0279 E340 28 PLP 0280 E341 F0 BE BEQ LS0 ;[no exec address] 0281 E343 ; read exec address 0282 E343 A2 06 LDXIM FEXEC 0283 E345 20 70 E2 JSR LSA 0284 E348 90 0B BCC BADFX ;[expected exec address not found] 0285 E34A F0 B5 BEQ LS0 ;[no following load address] 0286 E34C ; read load address 0287 E34C A2 02 LDXIM FLOAD 0288 E34E 20 70 E2 JSR LSA 0289 E351 90 02 BCC BADFX ;[expected load address not found] Acorn macro assembler Page 82 MOS40 Machine operating system internal commands 0290 E353 F0 AC BEQ LS0 ;[good line termination] 0291 E355 BADFX 0292 E355 MBDCMD 0293 E355 00 BRK ;report error 'Bad command' 0294 E356 FE = BADCMD 0295 E357 42 61 64 = "Bad command" 0296 E362 00 BADKEY BRK ;report error 'Bad KEY' / end of preceeding error message 0297 E363 FB = BADKY 0298 E364 42 61 64 = "Bad key" 0299 E36B 00 = ZERO ;message terminator 0300 E36C 0301 E36C [ MOS125 = &FF 0333 E36C ] 0334 E36C 0335 E36C 0336 E36C 0337 E36C FX ;*FX x,y 0338 E36C 20 A7 E0 JSR GETNUM ;read FX function code 0339 E36F 90 E4 BCC BADFX ;[bad FX number] 0340 E371 ; 0341 E371 ; N.B. C=1 0342 E371 ; push function code 0343 E371 ; 0344 E371 8A TXA 0345 E372 FXN ;entry point used by CLI, C=0 0346 E372 48 PHA 0347 E373 A9 00 LDAIM ZERO ;set default argument values 0348 E375 85 E5 STA FXREGX 0349 E377 85 E4 STA FXREGY 0350 E379 ; 0351 E379 ; check for line end 0352 E379 ; 0353 E379 20 9C E0 JSR SKPCM ;N.B. C=0 => just check for line end 0354 E37C ; 0355 E37C ; C=1 => skip an optional comma and check for line end 0356 E37C ; 0357 E37C F0 18 BEQ FX1 ;[line end, just a function code] 0358 E37E ; 0359 E37E ; try reading another argument 0360 E37E ; 0361 E37E 20 A7 E0 JSR GETNUM 0362 E381 90 D2 BCC BADFX ;[bad FX number] 0363 E383 ; 0364 E383 ; N.B. C=1 0365 E383 ; 0366 E383 86 E5 STX FXREGX 0367 E385 ; 0368 E385 ; check for line end 0369 E385 ; 0370 E385 20 9E E0 JSR SKPCOM 0371 E388 F0 0C BEQ FX1 0372 E38A ; 0373 E38A ; try reading another argument 0374 E38A ; 0375 E38A 20 A7 E0 JSR GETNUM 0376 E38D 90 C6 BCC BADFX ;[bad FX number] 0377 E38F 86 E4 STX FXREGY 0378 E391 ; 0379 E391 ; ensure line end 0380 E391 ; 0381 E391 20 93 E0 JSR SKIPSP 0382 E394 D0 BF BNE BADFX ;[bad command termination] 0383 E396 ; 0384 E396 FX1 0385 E396 A4 E4 LDY FXREGY ;load OSBYTE arguments 0386 E398 A6 E5 LDX FXREGX 0387 E39A 68 PLA 0388 E39B 20 F4 FF JSR OSBYTE 0389 E39E 70 B5 BVS BADFX ;[unrecognised FX code] 0390 E3A0 [ MOS125 = &FF 0391 E3A0 | 0392 E3A0 KEYZAP 0393 E3A0 ] 0394 E3A0 60 RTS 0395 E3A1 0396 E3A1 0397 E3A1 [ MOS125 = &FF 0398 E3A1 | 0399 E3A1 KEY ;KEY 0400 E3A1 20 A7 E0 JSR GETNUM 0401 E3A4 90 BC BCC BADKEY ;[bad soft key number (>255)] 0402 E3A6 ; A = character delimiting number 0403 E3A6 ; X = NUMBER = CSKEY = key number 0404 E3A6 ; Y = soft key number argument 0405 E3A6 ; check soft key number range 0406 E3A6 E0 10 CPXIM NSOFTK 0407 E3A8 B0 B8 BCS BADKEY ;[soft_key_number > number of soft keys - 1] 0408 E3AA ; key number in range 0 to NSOFTK-1 0409 E3AA ; 0410 E3AA [ FALSE=0 0413 E3AA ] 0414 E3AA ; 0415 E3AA 20 9E E0 JSR SKPCOM ;skip optional spaces and an optional comma 0416 E3AD 08 PHP ;save line end status 0417 E3AE AE 10 0B LDX SKEND ;Y points to unused portion of soft key buffer area 0418 E3B1 ; (set to reset SKNEND as it might have been set as a result 0419 E3B1 ; of a 'KEY in use' error) 0420 E3B1 98 TYA 0421 E3B2 48 PHA 0422 E3B3 20 15 E4 JSR SKGCR ;delete soft key (uses value in X) 0423 E3B6 ; on exit X = SKEND 0424 E3B6 68 PLA 0425 E3B7 A8 TAY 0426 E3B8 28 PLP ;restore line end status 0427 E3B9 F0 E5 BEQ KEYZAP ; end of line - specified soft key value value has been deleted so return 0428 E3BB ] 0429 E3BB CLI1 0430 E3BB 38 SEC 0431 E3BC 20 79 EA JSR GSINTS ;initialise for reading quoted string 0432 E3BF CLIWP 0433 E3BF 20 8A EA JSR GSREAD ;read string character 0434 E3C2 B0 08 BCS CLIY ;end of string 0435 E3C4 E8 INX 0436 E3C5 F0 9B BEQ BADKEY ;[buffer full, (N.B. buffer assumed to be 256 bytes long)] 0437 E3C7 ; buffer not full 0438 E3C7 9D 00 0B STAAX SKBUF -&01 ;store character in soft key buffer 0439 E3CA ;(N.B. note offset of -1) 0440 E3CA 90 F3 BCC CLIWP ;[ALWAYS jump, go process next character] 0441 E3CC ; SOFT KEY FINAL CHECK TO SEE IF ANY OTHER KEY SHARES SAME 0442 E3CC ; VALUE POINTER - IF IT DOES THEN SET IT EQUAL TO SKEND 0443 E3CC CLIY Acorn macro assembler Page 83 MOS40 Machine operating system internal commands 0444 E3CC D0 94 BNE BADKEY ;[string not terminated by CR] 0445 E3CE ; N.B. new buffer end in X 0446 E3CE 08 PHP 0447 E3CF 78 SEI ;** DISABLE INTERRUPTS ** 0448 E3D0 20 15 E4 JSR SKGCR ;delete old soft key and replace with new value (uses value in X) 0449 E3D3 ;N.B. sets Y to specified soft key number 0450 E3D3 A2 10 LDXIM NSOFTK ;X to be roving soft key number 0451 E3D5 CLIYP 0452 E3D5 E4 E6 CPX CSKEY 0453 E3D7 F0 0E BEQ CLIYQ ;[do not process specified soft key] 0454 E3D9 BD 00 0B LDAAX SKPTR 0455 E3DC D9 00 0B CMPAY SKPTR ;compare soft key buffer pointers 0456 E3DF D0 06 BNE CLIYQ ;[pointers differ] 0457 E3E1 AD 10 0B LDA SKEND 0458 E3E4 9D 00 0B STAAX SKPTR ;update soft key buffer pointer 0459 E3E7 CLIYQ 0460 E3E7 CA DEX 0461 E3E8 10 EB BPL CLIYP ;[go process next soft key] 0462 E3EA 28 PLP ;** ENABLE INTERRUPTS ** 0463 E3EB 60 RTS 0464 E3EC 0465 E3EC 0466 E3EC SKSIZE ;A := size of soft key given by Y 0467 E3EC ; ** THIS MODULE DISABLES INTERRUPTS ** 0468 E3EC ; this routine is called by soft key set (via *KEY command) 0469 E3EC ; and soft key read (via RDCH processing). 0470 E3EC ; the choice is to duplicate the code, using a distinct work slot, 0471 E3EC ; or share the code within a critical region in order that SKSZWK 0472 E3EC ; may be shared 0473 E3EC 08 PHP ;save interrupt state 0474 E3ED 78 SEI ;** DISABLE INTERRUPTS ** 0475 E3EE AD 10 0B LDA SKEND 0476 E3F1 38 SEC 0477 E3F2 F9 00 0B SBCAY SKPTR 0478 E3F5 85 FB STA SKSZWK ;SKSZWK := number of bytes to end of buffer 0479 E3F7 8A TXA 0480 E3F8 48 PHA ;push X 0481 E3F9 A2 10 LDXIM NSOFTK ;X is roving soft key number 0482 E3FB SKS1 0483 E3FB BD 00 0B LDAAX SKPTR 0484 E3FE 38 SEC 0485 E3FF F9 00 0B SBCAY SKPTR ;A := length of soft key w.r.t. specified soft key 0486 E402 90 08 BCC SKS2 ;[ignore negative length] 0487 E404 F0 06 BEQ SKS2 ;[ignore zero length] 0488 E406 C5 FB CMP SKSZWK 0489 E408 B0 02 BCS SKS2 ;[this length >= past lengths] 0490 E40A 85 FB STA SKSZWK ;remember new minimum length 0491 E40C CA SKS2 DEX 0492 E40D 10 EC BPL SKS1 ;[go process next soft key] 0493 E40F 68 PLA 0494 E410 AA TAX ;restore X 0495 E411 A5 FB LDA SKSZWK 0496 E413 28 PLP ;** RESTORE INTERRUPT STATE ** 0497 E414 ; A := length of soft key string 0498 E414 ; Y := soft key number given on entry 0499 E414 60 RTS 0500 E415 0501 E415 0502 E415 ; SOFT KEY BUFFER GARBAGE COLLECTION ROUTINE.STRING 0503 E415 ; FOR KEY NUMBER GIVEN IN 'CSKEY' IS DELETED & ALL 0504 E415 ; POINTERS ADJUSTED ACC 0505 E415 SKGCR ;delete (and insert) key value(s) 0506 E415 ;** THIS MODULE DISABLES INTERRUPTS ** 0507 E415 08 PHP ;** SAVE INTERRUPT STATE OF CALLER ** 0508 E416 78 SEI ;** DISABLE INTERRUPTS ** 0509 E417 ; save new end address 0510 E417 8A TXA 0511 E418 48 PHA 0512 E419 A4 E6 LDY CSKEY ;Y is specified soft key number 0513 E41B 20 EC E3 JSR SKSIZE ;A := length of soft key string 0514 E41E ; NOW SKSZWK = LENGTH OF CURRENT SK STRING 0515 E41E ; SO SETUP FOR DELETING THIS STRING. 0516 E41E B9 00 0B LDAAY SKPTR 0517 E421 A8 TAY ;Y points to specified soft key string 0518 E422 18 CLC 0519 E423 65 FB ADC SKSZWK 0520 E425 AA TAX ;X points to start of byte area to be moved down 0521 E426 85 FA STA KEYSV 0522 E428 ; TO AVOID MASHING POINTER STRUCTURE IF 0523 E428 ; MACHINE CRASHES ELSEWHERE,IT IS ESSENTIAL 0524 E428 ; THAT INTERRUPTS ARE *OFF* FOR THIS NEXT BIT 0525 E428 ; before altering the data structure, check that a soft key 0526 E428 ; is not being used by RDCH 0527 E428 AD 68 02 LDA SOFKL ;A := length of soft key in use by RDCH 0528 E42B F0 0D BEQ SK3 ;[no soft key in use] 0529 E42D ; soft key being 'unwound' by RDCH 0530 E42D ; N.B. altering the data structure would confuse RDCH 0531 E42D 00 BRK ;report error 'KEY in use' 0532 E42E FA = KEYUSE 0533 E42F 4B 65 79 = "Key in use" 0534 E439 00 = ZERO ;end of error message 0535 E43A 0536 E43A SK3 0537 E43A CE 84 02 DEC USKFLG ;indicate update of soft keys in progress (USKFLG<>0) 0538 E43D 68 PLA ;A := new end of buffer 0539 E43E 38 SEC 0540 E43F E5 FA SBC KEYSV 0541 E441 85 FA STA KEYSV ;KEYSV := number of bytes to copy 0542 E443 F0 0C BEQ SKGCV ;[zero bytes to copy] 0543 E445 SKGCS 0544 E445 BD 01 0B LDAAX SKBUF ;*MOVE 0545 E448 99 01 0B STAAY SKBUF ;*CHARACTERS 0546 E44B C8 INY 0547 E44C E8 INX 0548 E44D C6 FA DEC KEYSV 0549 E44F D0 F4 BNE SKGCS ;[more bytes to copy] 0550 E451 ; NOW ADJUST ALL POINTERS WHICH ARE GREATER 0551 E451 ; THAN THE ONE AT CSKEY. 0552 E451 SKGCV 0553 E451 ; save new end address 0554 E451 98 TYA 0555 E452 48 PHA 0556 E453 A4 E6 LDY CSKEY ;Y is specified soft key number 0557 E455 A2 10 LDXIM NSOFTK ;X is roving soft key number, including end pointer 0558 E457 SKGCT 0559 E457 BD 00 0B LDAAX SKPTR 0560 E45A D9 00 0B CMPAY SKPTR 0561 E45D 90 07 BCC SKGCU ;[current pointer precedes specified pointer] 0562 E45F [ TRUE=0 0563 E45F F0 05 BEQ SKGCU ;[current pointer equals specified pointer] 0564 E461 ] Acorn macro assembler Page 84 MOS40 Machine operating system internal commands 0565 E461 ; current pointer is beyond specified pointer 0566 E461 ; if pointers are equal then specified soft key was null ... 0567 E461 ; ... therefore its size was zero and a drop thru is a no-operation 0568 E461 ; C=1 0569 E461 E5 FB SBC SKSZWK ;C already 1 0570 E463 9D 00 0B STAAX SKPTR ;adjust current buffer pointer 0571 E466 SKGCU 0572 E466 CA DEX 0573 E467 10 EE BPL SKGCT ;[go process next soft key] 0574 E469 ; NOW UPDATE CURRENT KEY POINTER 0575 E469 AD 10 0B LDA SKEND 0576 E46C 99 00 0B STAAY SKPTR ;adjust specified soft key pointer to point to end of buffer 0577 E46F 68 PLA ;A := new end address 0578 E470 8D 10 0B STA SKEND ;make end buffer pointers equal 0579 E473 AA TAX ;X := new end of buffer pointer 0580 E474 EE 84 02 INC USKFLG ;indicate update of soft keys over (USKFLG=0) 0581 E477 28 PLP ;** RESTORE INTERRUPT STATE OF CALLER ** 0582 E478 ; X = SKEND 0583 E478 ; Y = specified soft key number 0584 E478 60 RTS 0585 E479 LNK MOS42 0001 E479 0002 E479 ; > MOS42 0003 E479 TTL MOS42 Buffer management 0004 E479 OPT MOS42 Acorn macro assembler Page 85 MOS42 Buffer management 0005 E479 ;(c) 1981 ACORN Computers Limited 0006 E479 ;BBC Microcomputer Machine Operating System (MOS) 0007 E479 ;Change record: 0008 E479 ;201 01-May-82 PB EVENT restores A 0009 E479 ;004 29-Jul-81 MP Prototype version 0010 E479 ;Author(s): 0011 E479 ;PB Paul Bond 0012 E479 ;MP Mike Prees 0013 E479 ; buffer address table (hi byte) 0014 E479 BFADHI 0015 E479 03 = /(RDCHBF+RDCHSZ-&0100 ) 0016 E47A 0A = /(RSRIBF+RSRISZ-&0100 ) 0017 E47B 08 = /(RSROBF+RSROSZ-&0100 ) 0018 E47C 07 = /(PRNBF+PRNSZ-&0100 ) 0019 E47D 07 = /(SNDBF1+SBSIZE-&0100 ) 0020 E47E 07 = /(SNDBF2+SBSIZE-&0100 ) 0021 E47F 07 = /(SNDBF3+SBSIZE-&0100 ) 0022 E480 07 = /(SNDBF4+SBSIZE-&0100 ) 0023 E481 09 = /(SPCHBF+SPCHSZ-&0100 ) 0024 E482 ; buffer address table (lo byte) 0025 E482 BFADLO 0026 E482 00 = RDCHBF+RDCHSZ-&0100 ;RDCH (keyboard) buffer 0027 E483 00 = RSRIBF+RSRISZ-&0100 ;RS423 input 0028 E484 C0 = RSROBF+RSROSZ-&0100 ;RS423 output 0029 E485 C0 = PRNBF+PRNSZ-&0100 ;print 0030 E486 50 = SNDBF1+SBSIZE-&0100 ;sound channel 1 0031 E487 60 = SNDBF2+SBSIZE-&0100 ;sound channel 2 0032 E488 70 = SNDBF3+SBSIZE-&0100 ;sound channel 3 0033 E489 80 = SNDBF4+SBSIZE-&0100 ;sound channel 4 0034 E48A 00 = SPCHBF+SPCHSZ-&0100 ;speech 0035 E48B ; buffer origin offsets within page 0036 E48B BFORG 0037 E48B E0 = &0100-RDCHSZ 0038 E48C 00 = &0100-RSRISZ 0039 E48D 40 = &0100-RSROSZ 0040 E48E C0 = &0100-PRNSZ 0041 E48F F0 = &0100-SBSIZE 0042 E490 F0 = &0100-SBSIZE 0043 E491 F0 = &0100-SBSIZE 0044 E492 F0 = &0100-SBSIZE 0045 E493 C0 = &0100-SPCHSZ 0046 E494 ; general buffer manipulation routines 0047 E494 SETBUF 0048 E494 ; set buffer pointer 0049 E494 BD 82 E4 LDAAX BFADLO 0050 E497 85 FA STA BUFFLO 0051 E499 BD 79 E4 LDAAX BFADHI 0052 E49C 85 FB STA BUFFHI 0053 E49E 60 RTS 0054 E49F 0055 E49F 0056 E49F EXAM ;examine character in buffer 0057 E49F 2C 49 D9 BIT FFBYT ;V=1 => examine option 0058 E4A2 70 01 BVS EXAM1 ;[ALWAYS jump] 0059 E4A4 ; NEVER fall thru 0060 E4A4 REMOV ;remove character from buffer 0061 E4A4 B8 CLV ;V=0 => indicate remove option 0062 E4A5 ; X = buffer index 0063 E4A5 ; V=0 => remove, V=1 => examine 0064 E4A5 EXAM1 ;entered with V=1 0065 E4A5 ; 0066 E4A5 6C 2C 02 JMI REMVEC ;use indirection (defaults to REM) 0067 E4A8 ; 0068 E4A8 REM 0069 E4A8 [ $Tutu 0072 E4A8 | 0073 E4A8 ; disable interrupts 0074 E4A8 08 PHP 0075 E4A9 78 SEI 0076 E4AA ] 0077 E4AA ; get buffer start pointer 0078 E4AA BD D8 02 LDAAX BFSTRT 0079 E4AD DD E1 02 CMPAX BFEND 0080 E4B0 F0 72 BEQ REMOV1 0081 E4B2 A8 TAY ;Y := buffer start pointer 0082 E4B3 ; set buffer pointer 0083 E4B3 20 94 E4 JSR SETBUF 0084 E4B6 ; remove character from buffer 0085 E4B6 B1 FA LDAIY BUFFLO 0086 E4B8 70 1B BVS REMOV3 ;[examine option, exit with character] 0087 E4BA 48 PHA ;push character 0088 E4BB ; update buffer start pointer 0089 E4BB C8 INY 0090 E4BC 98 TYA 0091 E4BD D0 03 BNE REMOV2 0092 E4BF ; wraparound 0093 E4BF BD 8B E4 LDAAX BFORG 0094 E4C2 REMOV2 0095 E4C2 9D D8 02 STAAX BFSTRT 0096 E4C5 ; check for removal of last character in buffer 0097 E4C5 ; N.B. this code is only executed for the remove option 0098 E4C5 E0 02 CPXIM OUTPUT 0099 E4C7 90 0A BCC REMOV4 ;[input buffer, buffer empty event not applicable] 0100 E4C9 DD E1 02 CMPAX BFEND 0101 E4CC D0 05 BNE REMOV4 ;[not last character] 0102 E4CE ; signal buffer empty event 0103 E4CE A0 00 LDYIM EVMPTY 0104 E4D0 20 D8 E4 JSR EVENT 0105 E4D3 REMOV4 0106 E4D3 68 PLA ;restore character read 0107 E4D4 A8 TAY ;Y := character 0108 E4D5 REMOV3 ;return with C=0 indicating removal successful 0109 E4D5 28 PLP ;restore interrupt state 0110 E4D6 18 CLC 0111 E4D7 60 RTS 0112 E4D8 0113 E4D8 0114 E4D8 EVENT ;signal event given by Y, optional arguments given in A & X 0115 E4D8 ; this routine must not corrupt A 0116 E4D8 08 PHP 0117 E4D9 78 SEI 0118 E4DA 48 PHA ;save A 0119 E4DB 85 FA STA EVENTA ;save A 0120 E4DD B9 BF 02 LDAAY EVENTS 0121 E4E0 F0 41 BEQ EVENT0 ;[event disabled] 0122 E4E2 ; event enabled, call event routine 0123 E4E2 98 TYA ;A = event code 0124 E4E3 A4 FA LDY EVENTA ;Y := argument passed originally in A 0125 E4E5 20 67 F0 JSR JMIEVT ;A = event code, must not corrupt X 0126 E4E8 68 PLA ;restore A 0127 E4E9 28 PLP Acorn macro assembler Page 86 MOS42 Buffer management 0128 E4EA 18 CLC ;indicate event was enabled 0129 E4EB 60 RTS 0130 E4EC 0131 E4EC CKESCY ;insert character in Y into buffer 0132 E4EC ; 0133 E4EC ; signal input event 0134 E4EC ; 0135 E4EC 98 TYA ;A := character 0136 E4ED A0 02 LDYIM EVKYBD 0137 E4EF 20 D8 E4 JSR EVENT ;assumes A and X not corrupted 0138 E4F2 A8 TAY 0139 E4F3 INSERT ;FX call to insert character into buffer 0140 E4F3 98 TYA 0141 E4F4 INSRT ;insert character into buffer 0142 E4F4 ; 0143 E4F4 6C 2A 02 JMI INSVEC ;use indirection (defaults to INS) 0144 E4F7 ; 0145 E4F7 INS 0146 E4F7 ; A = character 0147 E4F7 ; X = buffer index 0148 E4F7 [ $Tutu 0151 E4F7 | 0152 E4F7 ; disable interrupts 0153 E4F7 08 PHP 0154 E4F8 78 SEI 0155 E4F9 ] 0156 E4F9 ; save character 0157 E4F9 48 PHA 0158 E4FA ; construct buffer end offset in Y 0159 E4FA BC E1 02 LDYAX BFEND 0160 E4FD C8 INY 0161 E4FE D0 03 BNE INSRT2 0162 E500 ; buffer wraparound 0163 E500 BC 8B E4 LDYAX BFORG 0164 E503 INSRT2 0165 E503 98 TYA 0166 E504 DD D8 02 CMPAX BFSTRT 0167 E507 F0 0F BEQ INSRT1 ;[buffer full] 0168 E509 ; update buffer end pointer 0169 E509 BC E1 02 LDYAX BFEND 0170 E50C 9D E1 02 STAAX BFEND 0171 E50F ; construct buffer pointer 0172 E50F 20 94 E4 JSR SETBUF 0173 E512 ; store character in buffer 0174 E512 68 PLA ;A := character 0175 E513 91 FA STAIY BUFFLO 0176 E515 ; return with C=0 => insert successful 0177 E515 28 PLP ;restore interrupt state 0178 E516 18 CLC 0179 E517 60 RTS 0180 E518 0181 E518 INSRT1 ;signal buffer full event 0182 E518 68 PLA ;restore character 0183 E519 E0 02 CPXIM OUTPUT 0184 E51B B0 07 BCS INOBUF ;[output buffer, buffer full event not applicable] 0185 E51D ; signal input buffer full event 0186 E51D A0 01 LDYIM EVFULL 0187 E51F 20 D8 E4 JSR EVENT ;A=character, X=bufferid 0188 E522 ; (N.B. does not corrupt A, should not corrupt X) 0189 E522 48 PHA ;compensate for following PLA 0190 E523 EVENT0 ;indicate event was disabled 0191 E523 68 PLA 0192 E524 INOBUF ;output buffer, buffer full event not applicable 0193 E524 REMOV1 ;return with C=1 => insert/remove failed due to buffer full/empty 0194 E524 28 PLP ;restore interrupt state 0195 E525 38 SEC 0196 E526 60 RTS 0197 E527 0198 E527 0199 E527 CAPS ;test for an uppercase letter 0200 E527 0201 E527 [ MOS125 = &FF 0214 E527 | 0215 E527 48 PHA 0216 E528 ;Must preserve V during LOADGO->SRCH0->LOOK->CMPFT->CAPS 0217 E528 ;ANDIM &DF;CMPIM "A";EORIM &FF;RORA;ADCIM "Z":SHR:1 0218 E528 ;ORAIM &20;CMPIM "z"+&01;EORIM &FF;RORA;ADCIM ("a":SHR:1):OR:&80 0219 E528 29 DF ANDIM &DF 0220 E52A C9 5B CMPIM "Z"+&01 0221 E52C B0 04 BCS CAPSX 0222 E52E 49 FF EORIM &FF 0223 E530 C9 BF CMPIM "A"-&01:EOR:&FF 0224 E532 CAPSX 0225 E532 68 PLA 0226 E533 ; C=0 => Pass, C=1 => Fail 0227 E533 60 RTS 0228 E534 ] 0229 E534 0230 E534 0231 E534 RDCHS ;insert character into RDCH (keyboard) buffer 0232 E534 A2 00 LDXIM BRDCH 0233 E536 RNSRT 0234 E536 ; insert character Y into buffer whose index is X, 0235 E536 ; checking for the interrupt character (default ASCII escape) 0236 E536 ; 0237 E536 ; RS423 8 bit does not detect interrupt character 0238 E536 8A TXA 0239 E537 2D 45 02 AND RS8BIT 0240 E53A D0 B7 BNE INSERT ;[RSI & RS423-8-bit, no input event] 0241 E53C ; 0242 E53C 98 TYA 0243 E53D 4D 6C 02 EOR INTCH ;default INTCH is ESC 0244 E540 0D 75 02 ORA ESCHAR ;treat as character? 0245 E543 D0 A7 BNE CKESCY ;[not escape character or let escape thru, take no action] 0246 E545 ; 0247 E545 ; ESC detected - ignore ? 0248 E545 AD 58 02 LDA CRIT 0249 E548 6A RORA 0250 E549 98 TYA ;A := character 0251 E54A B0 0A BCS CLCRTS ;[ignore escape] 0252 E54C ; 0253 E54C A0 06 LDYIM EVESC 0254 E54E 20 D8 E4 JSR EVENT ;N.B. does not corrupt A 0255 E551 90 03 BCC CKESC1 ;[event was enabled, no need to take default action] 0256 E553 ; 0257 E553 ; event was disabled, so take default action 0258 E553 ; default escape routine 0259 E553 ; C=1 0260 E553 20 B7 E6 JSR CESCPS ;set escape flag **** MUST USE ROUTINE CESCPS **** 0261 E556 CKESC1 ;character 'inserted' successfully 0262 E556 CLCRTS Acorn macro assembler Page 87 MOS42 Buffer management 0263 E556 18 CLC 0264 E557 ; C=0 => character inserted OK, C=1 => character not inserted 0265 E557 60 RTS ;RETURN - do not insert ESC into buffer 0266 E558 0267 E558 RDCHGX ;check for cursor option 1 0268 E558 6A RORA 0269 E559 68 PLA 0270 E55A B0 79 BCS RDCHGCLC ;[option 1 active, return &87..&8B] 0271 E55C ; treat as cursor option 2 0272 E55C RDCHGS ;process character as real softkey 0273 E55C 98 TYA ;A := character 0274 E55D ; 0275 E55D 48 PHA 0276 E55E 4A LSRA 0277 E55F 4A LSRA 0278 E560 4A LSRA 0279 E561 4A LSRA 0280 E562 ; 0281 E562 49 04 EORIM &04 ;fudge to tie in with frozen documentation 0282 E564 A8 TAY 0283 E565 ; character on stack 0284 E565 ; 0285 E565 B9 65 02 LDAAY SOFTLO-&08 0286 E568 C9 01 CMPIM &01 ;test softkey range option 0287 E56A F0 6B BEQ GKEY ;[expand softkey] 0288 E56C 68 PLA ;restore character 0289 E56D 90 0D BCC RDCHG1 ;[ignore key] 0290 E56F ; return byte code 0291 E56F ; C=1 0292 E56F 29 0F ANDIM &0F ;A := offset of soft key 0293 E571 18 CLC 0294 E572 79 65 02 ADCAY SOFTLO-&08 0295 E575 0296 E575 18 CLC 0297 E576 60 RTS ;read successful, character in A 0298 E577 0299 E577 0300 E577 RDCHGB 0301 E577 ; invalid character at cursor position 0302 E577 ; complain by transmitting BEL 0303 E577 20 77 E8 JSR BELL ;**** N.B. NOT THRU OSWRCH **** must restore X 0304 E57A 68 PLA 0305 E57B AA TAX ;restore X 0306 E57C ; get next character 0307 E57C ; 0308 E57C RDCHG1 ;process character from currently selected input buffer 0309 E57C 20 A4 E4 JSR REMOV ;get character from buffer 0310 E57F B0 55 BCS RDCHG0 ;[buffer empty, C=1] 0311 E581 ; 0312 E581 ; C=0 0313 E581 ; 0314 E581 ; character is in A 0315 E581 ; 0316 E581 ; check whether to set RTS hi for RS423 input 0317 E581 ; save A 0318 E581 48 PHA 0319 E582 ; 0320 E582 ; check for RS423 input buffer 0321 E582 E0 01 CPXIM BRSI 0322 E584 D0 06 BNE RDCHL ;[keyboard buffer, C=0] 0323 E586 ; 0324 E586 20 C3 E1 JSR RSETX ;set RHITXE if applicable 0325 E589 ; 0326 E589 A2 01 LDXIM BRSI ;restore bufferid 0327 E58B 38 SEC 0328 E58C ; 0329 E58C RDCHL ;do not alter RTS 0330 E58C ; C=0 => keyboard, C=1 => RS423 0331 E58C ; 0332 E58C ; restore A 0333 E58C 68 PLA 0334 E58D ; 0335 E58D 90 05 BCC RDCHK ;[keyboard] 0336 E58F ; 0337 E58F ; RS423 0338 E58F ; 0339 E58F AC 45 02 LDY RS8BIT 0340 E592 D0 41 BNE RDCHGCLC ;[let RS423 deliver 8 bit codes] 0341 E594 RDCHK 0342 E594 ; 0343 E594 ; test to see if it is a softkey (real or pseudo) 0344 E594 A8 TAY ;Y := character 0345 E595 10 3E BPL RDCHGCLC ;[not a soft key (top bit zero), C=0] 0346 E597 0347 E597 [ FALSE=0 0350 E597 ] 0351 E597 0352 E597 ; character is a softkey 0353 E597 ; check for cursor control key 0354 E597 29 0F ANDIM &0F 0355 E599 C9 0B CMPIM MCOPY-SOFTK0 0356 E59B 90 BF BCC RDCHGS ;[not a cursor control, therefore a real softkey] 0357 E59D ; cursor control key 0358 E59D ; C=1 0359 E59D ; convert character to codes &87..&8B 0360 E59D 69 7B ADCIM &87-MCOPY+SOFTK0-&1 0361 E59F 48 PHA ;save converted code, real character still in Y 0362 E5A0 ; there are 3 cursor options (selected by *FX4) 0363 E5A0 ; 0 cursor edit VDU 0364 E5A0 ; 1 return codes &87..&8B 0365 E5A0 ; 2 treat as softkey 0366 E5A0 AD 7D 02 LDA CURSED 0367 E5A3 D0 B3 BNE RDCHGX ;[not option 0] 0368 E5A5 ; option 0 0369 E5A5 ; check if output to VDU 0370 E5A5 AD 7C 02 LDA WRCHSW 0371 E5A8 6A RORA 0372 E5A9 6A RORA 0373 E5AA 68 PLA ;restore converted code 0374 E5AB B0 CF BCS RDCHG1 ;[ignore character, output not to VDU] 0375 E5AD ; let VDU process code 0376 E5AD C9 87 CMPIM &87 0377 E5AF F0 38 BEQ RDCHGY ;[COPY key] 0378 E5B1 ; cursor direction key 0379 E5B1 A8 TAY ;save X 0380 E5B2 8A TXA 0381 E5B3 48 PHA 0382 E5B4 98 TYA 0383 E5B5 20 60 D8 JSR VDUB ;N.B. cursor control entry point 0384 E5B8 68 PLA 0385 E5B9 AA TAX ;restore X Acorn macro assembler Page 88 MOS42 Buffer management 0386 E5BA ; falling thru will transfer control to RDCHG1 0387 E5BA RDCHG 0388 E5BA ; FETCH CHAR FROM RDCH BUFFER 0389 E5BA ; EXPAND SOFT KEYS AS NECESSARY 0390 E5BA ; PASS CURSOR CONTROL KEYS 0391 E5BA ; STRAIGHT TO VDU DRIVER 0392 E5BA ; RETURN CARRY SET IF CHARACTER 0393 E5BA ; AVAILABLE 0394 E5BA ; 0395 E5BA ; check for ECONET interception 0396 E5BA ; 0397 E5BA 2C 5F 02 BIT NETRDC 0398 E5BD 10 05 BPL RDCHNM ;[normal RDCH] 0399 E5BF ; 0400 E5BF ; let network supply character 0401 E5BF ; 0402 E5BF A9 06 LDAIM NTRDCH 0403 E5C1 6C 24 02 JMINET JMI NETVEC ;network operation call, results returned in A and C 0404 E5C4 0405 E5C4 0406 E5C4 RDCHNM ;not reading from network 0407 E5C4 AD 68 02 LDA SOFKL 0408 E5C7 F0 B3 BEQ RDCHG1 ;[no pending soft key expansion] 0409 E5C9 AC C9 02 LDY SOFKP 0410 E5CC B9 01 0B LDAAY SKBUF ;GET EXPANSION CHAR 0411 E5CF EE C9 02 INC SOFKP ;increment pointer into soft key buffer 0412 E5D2 CE 68 02 DEC SOFKL ;decrement remaining count of soft key characters 0413 E5D5 RDCHGCLC 0414 E5D5 18 CLC ;C=0 => character read successfully 0415 E5D6 RDCHG0 0416 E5D6 60 RTS 0417 E5D7 0418 E5D7 GKEY ;soft key detected AND soft keys enabled 0419 E5D7 68 PLA ;restore softkey code 0420 E5D8 29 0F ANDIM &0F ;convert to soft key number in range 0-15 (assumes SFTKY0=$x0)) 0421 E5DA A8 TAY ;Y := soft key number 0422 E5DB 20 EC E3 JSR SKSIZE ;A := length of soft key string given by Y 0423 E5DE 8D 68 02 STA SOFKL ;SOFKL := length of soft key string 0424 E5E1 ; N.B. X = soft key number 0425 E5E1 B9 00 0B LDAAY SKPTR 0426 E5E4 8D C9 02 STA SOFKP ;SOFKP points to key string (N.B. pointer always <> 0) 0427 E5E7 D0 D1 BNE RDCHG ;[ALWAYS JUMP] 0428 E5E9 0429 E5E9 RDCHGY ;copy character at text cursor position 0430 E5E9 8A TXA 0431 E5EA 48 PHA ;save X 0432 E5EB 20 97 D8 JSR COPYCH ;N.B. VDU sets Z bit, but this is not used 0433 E5EE A8 TAY ;save character 0434 E5EF F0 86 BEQ RDCHGB ;[invalid character at text cursor] 0435 E5F1 ; valid character at cursor position 0436 E5F1 68 PLA 0437 E5F2 AA TAX ;restore X 0438 E5F3 98 TYA ;restore character 0439 E5F4 ; C=0, character in A 0440 E5F4 18 CLC 0441 E5F5 60 RTS 0442 E5F6 0443 E5F6 0444 E5F6 LNK MOS44 0001 E5F6 ; > MOS44 0002 E5F6 TTL MOS44 OSBYTE routines 0003 E5F6 OPT MOS44 Acorn macro assembler Page 89 MOS44 OSBYTE routines 0004 E5F6 ;(c) 1981 ACORN Computers Limited 0005 E5F6 ;BBC Microcomputer Machine Operating System (MOS) 0006 E5F6 ;Change record: 0007 E5F6 ;01-Mar-82 PB PEEK and POKE introduced 0008 E5F6 ;Author(s): 0009 E5F6 ;PB Paul Bond 0010 E5F6 0011 E5F6 0012 E5F6 BYTET ;table for OSBYTE. N.B. lo-byte followed by hi-byte 0013 E5F6 ; 0014 E5F6 ; 0 indicate version number 0015 E5F6 ; X=0 => BRK message 0016 E5F6 ; X<>0 => return version number in X 0017 E5F6 59 EA & VER 0018 E5F8 0019 E5F8 ; 0020 E5F8 ; 1 set value 0021 E5F8 8D E9 & V2B156 0022 E5FA 0023 E5FA ; 0024 E5FA ; 2 select input stream 0025 E5FA ; X=0 => select keyboard, disable RS423 0026 E5FA ; X=1 => select RS423, enable RS423 0027 E5FA ; X=2 => select keyboard, enable RS423 0028 E5FA 15 E7 & SELIN 0029 E5FC 0030 E5FC ; 0031 E5FC ; 3 select output stream(s) 0032 E5FC ; X=rrrrspvl 0033 E5FC ; r (reserved) 0034 E5FC ; s=0 => spooling enabled 0035 E5FC ; p=0 => printing enabled 0036 E5FC ; v=0 => output to VDU enabled 0037 E5FC ; l=1 => output to RS423 enabled 0038 E5FC 9C E9 & V2B34 0039 E5FE 0040 E5FE ; 0041 E5FE ; 4 enable/disable cursor edit 0042 E5FE ; X=0 => cursor editing enabled 0043 E5FE ; X=1 => COPY/LEFT/RIGHT/DOWN/UP return $87/$88/$89/$8A/$8B 0044 E5FE ; X=2 => COPY/LEFT/RIGHT/DOWN/UP at as soft keys 11 thru 15 0045 E5FE 9C E9 & V2B34 0046 E600 0047 E600 ; 0048 E600 ; 5 select print destination 0049 E600 ; X=0 => infinite sink 0050 E600 ; X=1 => centronics 0051 E600 ; X=2 => RS423 0052 E600 7B E9 & SPRINT 0053 E602 0054 E602 ; 0055 E602 ; 6 set printer ignore character 0056 E602 ; X=0 => ignore no characters 0057 E602 ; X<>0 => ignore character 0058 E602 8D E9 & V2B156 0059 E604 0060 E604 ; 0061 E604 ; 7 set RS423 receive baud rate 0062 E604 ; X=0 => set default (9600) 0063 E604 ; X=1/2/3/4/5/6/7/8 => 75/150/300/1200/2400/4800/9600/19200 0064 E604 CD E6 & RXBAUD 0065 E606 0066 E606 ; 0067 E606 ; 8 set RS423 trasmit baud rate 0068 E606 ; [values as for OSBYTE(7)] 0069 E606 CB E6 & TXBAUD 0070 E608 0071 E608 ; 0072 E608 ; 9 set flash mark period 0073 E608 ; X=0 => infinite 0074 E608 ; X<>0 => * 20 milliseconds 0075 E608 F2 E6 & FMRK 0076 E60A 0077 E60A ; 0078 E60A ; 10 set flash space period 0079 E60A ; 9 set flash mark period 0080 E60A ; X=0 => infinite 0081 E60A ; X<>0 => * 20 milliseconds 0082 E60A F4 E6 & FSPC 0083 E60C 0084 E60C ; 0085 E60C ; 11 set auto-repeat delay period 0086 E60C ; X=0 => suppress auto-repeat 0087 E60C ; X<>0 => set delay between first and second character to centiseconds 0088 E60C 9A E9 & ARDLY 0089 E60E 0090 E60E ; 0091 E60E ; 12 set auto-repeat repeat period 0092 E60E ; X=0 => set delay and period to values on power-up 0093 E60E ; X<>0 => set period between subsequent characters to centiseconds 0094 E60E 91 E9 & ARRPT 0095 E610 0096 E610 ; 0097 E610 ; 13 disable event 0098 E610 ; X=event_code 0099 E610 ; 0: output buffer empty 0100 E610 ; 1: input buffer full 0101 E610 ; 2: character entering input buffer 0102 E610 ; 3: ADC conversion complete 0103 E610 ; 4: vertical SYNC 0104 E610 ; 5: interval timer crossing zero 0105 E610 ; 6: ESCAPE detected 0106 E610 ; 7: RS423 error 0107 E610 3B E7 & MDSABL 0108 E612 0109 E612 ; 0110 E612 ; 14 enable event 0111 E612 ; [values as for OSBYTE(13)] 0112 E612 3C E7 & ENABLE 0113 E614 0114 E614 ; 0115 E614 ; 15 flush buffer class 0116 E614 ; X=0 => flush all buffers 0117 E614 ; X=1 => flush currently selected input buffer 0118 E614 B4 F0 & FLUSHC 0119 E616 0120 E616 ; 0121 E616 ; 16 select number of ADC channels 0122 E616 ; X=0 => stop scanning ADC channels 0123 E616 ; X=1/2/3/4 => only scan channels 1 thru 0124 E616 48 E7 & SETADC Acorn macro assembler Page 90 MOS44 OSBYTE routines 0125 E618 0126 E618 ; 0127 E618 ; 17 start ADC conversion on channel X 0128 E618 ; X=1/2/3/4 => start conversion on channel 0129 E618 38 DE & ADCBEG 0130 E61A 0131 E61A ; 0132 E61A ; 18 reset soft keys 0133 E61A CD E9 & RSOFT 0134 E61C 0135 E61C ; 0136 E61C ; 19 wait for vertical sync 0137 E61C BB E9 & WFVS 0138 E61E 0139 E61E ; 0140 E61E ; 20 implode/explode soft font 0141 E61E FD CC & FONT 0142 E620 0143 E620 ; 0144 E620 ; 21 flush specific buffer 0145 E620 C0 F0 & FLUSHS 0146 E622 0147 E622 ; 0148 E622 0016 BYTEL * .-BYTET:SHR: 1 ;next entry in BYTETL table (lo component) 0149 E622 ; 0150 E622 BYTET2 0151 E622 0075 BYTEM * &0075 0152 E622 ; 0153 E622 ; 0154 E622 74 E8 & VDUST ;read VDU status; $75 0155 E624 0156 E624 ; 0157 E624 DE E9 & MOSTST ;reflect state of KSTAT; $76 0158 E626 0159 E626 ; 0160 E626 D1 E2 & SHUTES ;close EXEC and SPOOL files; $77 0161 E628 0162 E628 ; 0163 E628 5D F2 & OLDKEY ;set keyboard old key; $78 0164 E62A 0165 E62A ; 0166 E62A DB F0 & XSCANB ;scan keyboard at specific address; $79 0167 E62C 0168 E62C ; 0169 E62C D9 F0 & XSCANA ;scan keyboard from matrix entry $10; $7A 0170 E62E 0171 E62E ; 0172 E62E E7 E1 & PFREE ;indicate printer dormant; $7B 0173 E630 0174 E630 ; 0175 E630 B6 E6 & CESCPC ;clear escape flag; $7C 0176 E632 0177 E632 ; 0178 E632 B7 E6 & CESCPS ;set escape flag; $7D 0179 E634 0180 E634 ; 0181 E634 9F E6 & CESCP ;clear escape flag and purge selected input buffer; $7E 0182 E636 0183 E636 ; 0184 E636 8E E0 & EOF ;end of file; $7F 0185 E638 0186 E638 ; 0187 E638 ; $80 0188 E638 ;; read data on ADC channel 0189 E638 ; in: Y>=0 => X=0 => read control information 0190 E638 ; X<>0 => read last conversion on channel X 0191 E638 ; Y<0 => read info for buffer NOT(X) 0192 E638 ; out: Y>=0 => X=0 => X=fire-buttons, Y=last-channel-to-convert 0193 E638 ; X<>0 => X=lo-data, Y=hi-data 0194 E638 ; Y<0 => X=buffer-count (input: bytes ready, output: bytes left) 0195 E638 91 E7 & RADCX 0196 E63A 0197 E63A ; 0198 E63A ; $81 0199 E63A ; read key with time limit 0200 E63A ; in: Y>=0 => X=lo-count, Y=hi-count (centiseconds) 0201 E63A ; Y<0 => X=NOT(key-matrix-address) 0202 E63A ; out: Y>=0 => Y=$00 => X=character 0203 E63A ; Y=$1B => escape condition detected 0204 E63A ; Y=$FF => timeout 0205 E63A ; Y<0 => X=0 => key not pressed 0206 E63A ; X<>0 => key pressed 0207 E63A 55 E7 & INKY 0208 E63C 0209 E63C ; 0210 E63C ; $82 0211 E63C ; read machine high order address 0212 E63C ; out: X = lo-component, Y = hi-component 0213 E63C 6B E7 & RMHA 0214 E63E 0215 E63E ; 0216 E63E ; $83 0217 E63E ; read operating system high water mark 0218 E63E ; out: X = lo-address, Y = hi-address 0219 E63E 94 F0 & RMLA 0220 E640 0221 E640 ; 0222 E640 ; $84 0223 E640 ; read address of start of current screen mode 0224 E640 ; out: X = lo-address, Y = hi-address 0225 E640 B5 D8 & TOPCMD 0226 E642 0227 E642 ; 0228 E642 ; $85 0229 E642 ; read address of start of screen for mode X 0230 E642 ; in: X = mode 0231 E642 ; out: X = lo-address, Y = hi-address 0232 E642 B8 D8 & TOPMDX 0233 E644 0234 E644 ; 0235 E644 ; $86 0236 E644 ;; read text cursor position 0237 E644 ; out: X = x-text-coord, Y = y-text-coord 0238 E644 E4 D5 & CSRPOS 0239 E646 0240 E646 ; 0241 E646 ; $87 0242 E646 ;; read character at text cursor 0243 E646 ; out: X=0 => no character at cursor position 0244 E646 ; X<>0 => X=character 0245 E646 ; Y = current screen mode Acorn macro assembler Page 91 MOS44 OSBYTE routines 0246 E646 5C D7 & READCH 0247 E648 0248 E648 ; 0249 E648 ; $88 0250 E648 ; *CODE X, Y 0251 E648 ; in: X = arg, Y = arg 0252 E648 ; out: C = return code 0253 E648 ; X = return code 0254 E648 ; Y = return code 0255 E648 9A E6 & MCODE 0256 E64A 0257 E64A ; 0258 E64A ; $89 0259 E64A ; *MOTOR X, Y 0260 E64A ; in: X=0 => turn motor off 0261 E64A ; X=1 => turn motor on 0262 E64A ; Y => motor selection 0263 E64A C1 E6 & MOTOR ;MOTOR command; $89 0264 E64C 0265 E64C ; 0266 E64C ; $8A 0267 E64C ; insert character into buffer 0268 E64C ; in: X = bufferid, Y = character 0269 E64C F3 E4 & INSERT 0270 E64E 0271 E64E ; 0272 E64E ; $8B 0273 E64E ; *OPT X, Y 0274 E64E ; in: X = arg, Y = arg (effect is filing system dependent) 0275 E64E 8D E0 & OPT 0276 E650 0277 E650 ; 0278 E650 ; $8C 0279 E650 ; *TAPE X, Y 0280 E650 ; in: X=0 => tape filing system at default baud rate (1200 baud) 0281 E650 ; X=3 => tape filing system at 300 baud 0282 E650 ; X=12 => tape filing system at 1200 baud 0283 E650 ; Y=$00 => tape filing system is cassette 0284 E650 ; Y=$FF => tape filing system is ROMs 0285 E650 41 F1 & TAPE 0286 E652 0287 E652 ; 0288 E652 ; $8D 0289 E652 ; *ROM X, Y 0290 E652 ; X and Y ignored 0291 E652 41 F1 & CROM 0292 E654 0293 E654 ; 0294 E654 ; $8E 0295 E654 ; enter language 0296 E654 ; in: X = ROMid of language, Y = arg 0297 E654 AA DB & SELANG 0298 E656 0299 E656 ; 0300 E656 ; $8F 0301 E656 ; call paged ROM function 0302 E656 ; in: X = reason code, Y = arg 0303 E656 ; out: C = return code 0304 E656 ; Y = return code 0305 E656 74 F1 & SVOP 0306 E658 0307 E658 ; 0308 E658 ; $90 0309 E658 ; alter TV characteristics 0310 E658 ; in: X = vertical sync adjust, Y = interlace adjust 0311 E658 2F EB & TV 0312 E65A 0313 E65A ; 0314 E65A ; $91 0315 E65A ; remove character from buffer 0316 E65A ; in: X = bufferid 0317 E65A ; out: C=0 => Y=character 0318 E65A ; C=1 => buffer empty 0319 E65A A4 E4 & REMOV 0320 E65C 0321 E65C [ MOS125 = &FF 0360 E65C | 0361 E65C ; 0362 E65C ; $92 0363 E65C ; read from FRED 0364 E65C ; in: X = offset 0365 E65C ; out: Y = value 0366 E65C 22 EA & CHEQUE 0367 E65E 0368 E65E ; 0369 E65E ; $93 0370 E65E ; write to FRED 0371 E65E ; in: X = offset, Y = value 0372 E65E 22 EA & CHEQUE 0373 E660 0374 E660 ; 0375 E660 ; $94 0376 E660 ; read from JIM 0377 E660 ; in: X = offset 0378 E660 ; out: Y = value 0379 E660 22 EA & CHEQUE 0380 E662 0381 E662 ; 0382 E662 ; $95 0383 E662 ; write to JIM 0384 E662 ; in: X = offset, Y = value 0385 E662 22 EA & CHEQUE 0386 E664 0387 E664 ; 0388 E664 ; $96 0389 E664 ; read from SHEILA 0390 E664 ; in: X = offset 0391 E664 ; out: Y = value 0392 E664 22 EA & CHEQUE 0393 E666 0394 E666 ; 0395 E666 ; $97 0396 E666 ; write to SHEILA 0397 E666 ; in: X = offset, Y = value 0398 E666 22 EA & CHEQUE 0399 E668 ] 0400 E668 0401 E668 ; 0402 E668 ; $98 0403 E668 ; examine character in buffer 0404 E668 ; in: X = bufferid Acorn macro assembler Page 92 MOS44 OSBYTE routines 0405 E668 ; out: C=0 => Y=character 0406 E668 ; C=1 => buffer empty 0407 E668 9F E4 & EXAM 0408 E66A 0409 E66A ; 0410 E66A ; $99 0411 E66A ; insert character into buffer dealing with ESC code 0412 E66A ; in: X = bufferid, Y = character 0413 E66A 36 E5 & RNSRT 0414 E66C 0415 E66C ; 0416 E66C ;; $9A 0417 E66C ; update vidproc control register 0418 E66C ; in: X = value 0419 E66C 04 EA & VP0 0420 E66E 0421 E66E ; 0422 E66E ; $9B 0423 E66E ; update vidproc palette register 0424 E66E ; in: X = value EOR $07 0425 E66E 15 EA & VP1 0426 E670 0427 E670 ; 0428 E670 ; $9C 0429 E670 ; update 6850 ACIA 0430 E670 ; in: X = value, Y = mask 0431 E670 CC E1 & RS423 0432 E672 0433 E672 ; 0434 E672 ; $9D 0435 E672 ; fast tube BPUT 0436 E672 ; in: X = byte, Y = handle 0437 E672 66 FF & FXBPUT 0438 E674 0439 E674 ; 0440 E674 ; $9E 0441 E674 ; read from speech chip 0442 E674 ; in: Y = command 0443 E674 ; out: Y = result 0444 E674 89 EE & RSPECH 0445 E676 0446 E676 ; 0447 E676 ; $9F 0448 E676 ; write to speech chip 0449 E676 ; in: Y = command 0450 E676 9B EE & WSPECH 0451 E678 0452 E678 ; 0453 E678 ; $A0 0454 E678 ; read VDU variables 0455 E678 ; in: X = index 0456 E678 ; out: X = variable0, Y = variable1 0457 E678 C5 E9 & VDUVAR 0458 E67A 0459 E67A ; 0460 E67A 00A1 BYTEH * .-BYTET2:SHR: 1+BYTEM ;next entry in BYTET table (hi component) 0461 E67A ; 0462 E67A A1 E9 & SETV ;set variable 0463 E67C 0464 E67C ; 0465 E67C 9C E6 & JMIUSR ;OSWORD calls >=$E0 0466 E67E 0467 E67E 0468 E67E 0469 E67E WORDT ;table for OSWORD. N.B. lo-byte followed by hi-byte 0470 E67E ; 0471 E67E 03 E9 & RDLN ;read line; $00 0472 E680 0473 E680 ; 0474 E680 D9 E8 & RATM ;read absolute time; $01 0475 E682 0476 E682 ; 0477 E682 E8 E8 & WATM ;write absolute time; $02 0478 E684 0479 E684 ; 0480 E684 D5 E8 & RITM ;read interval time; $03 0481 E686 0482 E686 ; 0483 E686 EC E8 & WITM ;write interval time; $04 0484 E688 0485 E688 ; 0486 E688 46 EA & PEEK ;PEEK; $05 0487 E68A 0488 E68A ; 0489 E68A 47 EA & POKE ;POKE; $06 0490 E68C 0491 E68C ; 0492 E68C 0007 OSWSND * .-WORDT:SHR: 1 0493 E68C ; 0494 E68C 35 E8 & NOTE ;sound; $07 0495 E68E 0496 E68E ; 0497 E68E B6 E8 & NVLP ;define envelope; $08 0498 E690 0499 E690 ; 0500 E690 34 C7 & RPXLXY ;read pixel at given coordinate to X; $09 0501 E692 0502 E692 ; 0503 E692 CF CB & RCHDEF ;read character definition of XY to XY+1..8; $0A 0504 E694 0505 E694 ; 0506 E694 7A C7 & RPALET ;read palette for XY to XY+1..4; $0B 0507 E696 0508 E696 ; 0509 E696 C6 C8 & PRPAL ;programme palette; $0C 0510 E698 0511 E698 ; 0512 E698 80 D5 & CSREAD ;cursor read; $0D 0513 E69A 0514 E69A ; 0515 E69A 000E WORDN * .-WORDT:SHR: 1 ;number of entries in WORDT table 0516 E69A 0517 E69A 0518 E69A [ NOSP = &00 0520 E69A | 0521 E69A MCODE ;call user code 0522 E69A A9 00 LDAIM ZERO 0523 E69C 6C 00 02 JMIUSR JMI USRVEC ;user OSBYTE call/OSWORD calls 0524 E69F ] 0525 E69F 0526 E69F Acorn macro assembler Page 93 MOS44 OSBYTE routines 0527 E69F ; OSBYTE specific routines 0528 E69F ; N.B. routines must exit with PLP to restore 0529 E69F ; caller's interrupt state 0530 E69F CESCP ;clear escape flag ad purge selected input buffer 0531 E69F A2 00 LDXIM ZERO ;indicate escape not cleared 0532 E6A1 24 FF BIT ESCFLG 0533 E6A3 10 11 BPL CESCPC ;[no escape to clear] 0534 E6A5 ; bypass procedure ? 0535 E6A5 AD 76 02 LDA EAOPT 0536 E6A8 D0 0A BNE CESCX ;[bypass normal acknowledge procedure] 0537 E6AA ; Z=1, A=$00 0538 E6AA ; close exec file 0539 E6AA 58 CLI ;********** (close may be a long operation) 0540 E6AB 8D 69 02 STA LINES ;reset page mode page origin 0541 E6AE 20 BD F6 JSR EXEC ;just close exec file, N.B. needs Z=1, A=$00 0542 E6B1 ; flush all buffers and clear soft key expansion 0543 E6B1 20 B6 F0 JSR FLSHAL ;N.B. also kills sound AND cancels VDU queueing 0544 E6B4 CESCX 0545 E6B4 A2 FF LDXIM &FF ;indicate escape cleared 0546 E6B6 CESCPC ;clear system escape flag 0547 E6B6 18 CLC 0548 E6B7 CESCPS ;set system escape flag (N.B. C=1) 0549 E6B7 66 FF ROR ESCFLG 0550 E6B9 2C 7A 02 BIT TUBEM 0551 E6BC [ MOS125 = &FF 0554 E6BC | 0555 E6BC 10 33 BPL TESCO ;[tube inactive] 0556 E6BE ] 0557 E6BE ; 0558 E6BE TESC 0559 E6BE 4C 03 04 JMP TBESC ;tube escape 0560 E6C1 0561 E6C1 0562 E6C1 MOTOR ;control cassette motor 0563 E6C1 ; on entry: X=0 => motor off 0564 E6C1 ; X<>0 => motor on 0565 E6C1 ; N.B. previous instruction was LDX 0566 E6C1 AD 82 02 LDA SPREGA 0567 E6C4 A8 TAY ;Y := old value 0568 E6C5 ; 0569 E6C5 2A ROLA 0570 E6C6 E0 01 CPXIM &01 ;C=0 => X=0, C=1 => X<>0 0571 E6C8 6A RORA 0572 E6C9 50 1E BVC STASP ;[ALWAYS jump] 0573 E6CB 0574 E6CB 0575 E6CB TXBAUD ;set RS423 transmit baudrate (N.B. A=$08) 0576 E6CB A9 38 LDAIM &38 0577 E6CD RXBAUD ;set RS423 receive baudrate (N.B. A=$07) 0578 E6CD 49 3F EORIM &3F ;Rx: A=$38, Tx: A=$07 0579 E6CF 85 FA STA MASK 0580 E6D1 AC 82 02 LDY SPREGA 0581 E6D4 E0 09 CPXIM &09 0582 E6D6 B0 17 BCS BAUD1 ;[bad baud selection] 0583 E6D8 3D B2 E9 ANDAX BAUDS ;extract serproc baud bits 0584 E6DB 85 FB STA BAUD 0585 E6DD 98 TYA 0586 E6DE 05 FA ORA MASK 0587 E6E0 45 FA EOR MASK ;clear slot for baudrate 0588 E6E2 05 FB ORA BAUD 0589 E6E4 09 40 ORAIM &40 ;set cassette/RS423 bit 0590 E6E6 4D 5D 02 EOR RSCASS ;select cassette/RS423 0591 E6E9 ; 0592 E6E9 STASP ;used by MOTOR and RESET 0593 E6E9 8D 82 02 STA SPREGA 0594 E6EC 8D 10 FE STA SERPRC 0595 E6EF ; 0596 E6EF BAUD1 0597 E6EF TYATAX ;used by TXBAUD, RXBAUD, FSPC, FMRK 0598 E6EF 98 TYA 0599 E6F0 BADEVT 0600 E6F0 AA TAX ;X := old value (bad events appear disabled) 0601 E6F1 [ MOS125 = &FF 0602 E6F1 | 0603 E6F1 TESCO 0604 E6F1 ] 0605 E6F1 60 RTS 0606 E6F2 0607 E6F2 0608 E6F2 FMRK ;set flash mark, Y=0, C=1 0609 E6F2 C8 INY 0610 E6F3 18 CLC 0611 E6F4 ; 0612 E6F4 ; Y=1, C=0 0613 E6F4 ; 0614 E6F4 FSPC ;set flash space, Y=0, C=1 0615 E6F4 B9 52 02 LDAAY FLASHB 0616 E6F7 ; 0617 E6F7 48 PHA 0618 E6F8 8A TXA 0619 E6F9 99 52 02 STAAY FLASHB 0620 E6FC 68 PLA 0621 E6FD ; 0622 E6FD A8 TAY 0623 E6FE ; 0624 E6FE ; C=0 => mark, C=1 => space 0625 E6FE ; FMS0 exit used, despite X not being corrupted 0626 E6FE ; (makes code clearer) 0627 E6FE AD 51 02 LDA FLCNT 0628 E701 D0 10 BNE FMS1 ;[flash enabled] 0629 E703 ; 'kick' flash count 0630 E703 8E 51 02 STX FLCNT 0631 E706 ; force mark/space (lsb VPREGA := C) 0632 E706 AD 48 02 LDA VPREGA 0633 E709 [ MOS125 = &FF 0638 E709 | 0639 E709 ;same size, faster, reduce stack load 0640 E709 29 FE ANDIM &FE 0641 E70B 69 00 ADCIM &00 ;V=0 0642 E70D ] 0643 E70D 8D 48 02 STA VPREGA 0644 E710 8D 20 FE STA VPROC0 0645 E713 FMS1 ; chain from clear escape condition routine 0646 E713 50 DA BVC TYATAX ;[ALWAYS jump] 0647 E715 0648 E715 0649 E715 SELIN ;select input 0650 E715 8A TXA 0651 E716 29 01 ANDIM &01 ;force legal bufferid 0652 E718 48 PHA ;save change 0653 E719 AD 50 02 LDA RSCTFL ;A := old state of controller status Acorn macro assembler Page 94 MOS44 OSBYTE routines 0654 E71C 2A ROLA 0655 E71D E0 01 CPXIM &01 ;C=0 => disable RS423, C=1 => enable RS423 0656 E71F 6A RORA ;A := new state of controller status 0657 E720 ; *FX 2,0 disables RS423, *FX 2,(1,2) enables RS423 0658 E720 ; if RS423 then enable RS423 Rx interrupt 0659 E720 CD 50 02 CMP RSCTFL 0660 E723 08 PHP 0661 E724 8D 50 02 STA RSCTFL 0662 E727 8D 08 FE STA RSCTL ;update RS423 control register 0663 E72A 20 C3 E1 JSR RSETX ;set RHITXE if possible 0664 E72D 28 PLP 0665 E72E F0 03 BEQ SELIN1 ;branch if no change 0666 E730 2C 09 FE BIT RSDATA ;purge character in controller 0667 E733 ; this purges data register if: disabled state -> enabled state 0668 E733 ; this does not matter if: enabled state -> disabled state 0669 E733 SELIN1 0670 E733 AE 41 02 LDX RDCHSW ;X := old value 0671 E736 68 PLA 0672 E737 8D 41 02 STA RDCHSW ;update value 0673 E73A 60 RTS 0674 E73B 0675 E73B 0676 E73B MDSABL ;disable event X 0677 E73B ; N.B. Y=0 0678 E73B 98 TYA ;A := 0 0679 E73C ;* LDAIM ZERO 0680 E73C ENABLE ;enable event X (N.B. A<>$00) 0681 E73C E0 0A CPXIM NEVENT 0682 E73E B0 B0 BCS BADEVT 0683 E740 BC BF 02 LDYAX EVENTS 0684 E743 9D BF 02 STAAX EVENTS 0685 E746 ; 0686 E746 50 A7 BVC TYATAX ;[ALWAYS jump] 0687 E748 0688 E748 0689 E748 SETADC ;set number of ADC channels to scan 0690 E748 ; N.B. preceeding instruction was LDX 0691 E748 ; Y=0 0692 E748 F0 03 BEQ SETAD1 ;[kill ADC (eventually)] 0693 E74A 20 38 DE JSR ADCBEG ;initiate conversion on channel X, uses Y=0 0694 E74D ; N.B. X not corrupted 0695 E74D SETAD1 0696 E74D ; a value of X=0 stops the ADC after the next (external) channel 1 0697 E74D ; conversion 0698 E74D AD 4D 02 LDA MAXADC 0699 E750 8E 4D 02 STX MAXADC 0700 E753 AA TAX ;X := old value 0701 E754 60 RTS 0702 E755 0703 E755 0704 E755 INKY ;read key with time limit 0705 E755 98 TYA 0706 E756 30 0B BMI RDKY 0707 E758 58 CLI ;**** ENABLE INTERRUPTS 0708 E759 20 67 DE JSR INKEY 0709 E75C B0 03 BCS INKY1 ;[escape detected or count exhausted] 0710 E75E ; 0711 E75E ; character read 0712 E75E ; 0713 E75E AA TAX ;X := character (INKEY) or lo-count (BUFN) 0714 E75F A9 00 LDAIM ZERO ;Y = 0 => success 0715 E761 ; 0716 E761 INKY1 ;escape detected or count exhausted, C=1 0717 E761 A8 TAY ;Y < $80 => escape, Y >= $80 => count exhausted 0718 E762 60 RTS 0719 E763 0720 E763 0721 E763 RDKY ;C=1, V=0, read key addressed by X 0722 E763 ; N.B. interrupts disabled 0723 E763 ; 0724 E763 ; test key at matrix address 0725 E763 ; 0726 E763 [ $Tutu 0734 E763 | 0735 E763 8A TXA 0736 E764 49 7F EORIM &7F 0737 E766 AA TAX 0738 E767 20 77 F0 JSR JMIKEY 0739 E76A 2A ROLA ;result into C 0740 E76B ] 0741 E76B ; 0742 E76B BADADC ;entered with C=1 0743 E76B RMHA ;entered with C=1 0744 E76B ; C=0 => return 0, C=1 => return -1 0745 E76B A2 FF LDXIM &FF ;N.B. I/O processor is notionally located at address $FFFFxxxx 0746 E76D A0 FF LDYIM &FF 0747 E76F B0 02 BCS RDKY0 0748 E771 ; INKEY entry (key open) 0749 E771 E8 INX ;X=0 0750 E772 ; invalid soft key read, return Y<>0 0751 E772 C8 INY ;Y=0 (except for soft key read entry) 0752 E773 RDKY0 0753 E773 60 RTS 0754 E774 0755 E774 0756 E774 BUFN ;count entries in buffer, called by FX ADVAL with negative argument 0757 E774 ; -N gives count for buffer with external id N 0758 E774 ; C=1 (by FX conventions) 0759 E774 8A TXA 0760 E775 49 FF EORIM &FF 0761 E777 AA TAX ;X := bufferid 0762 E778 ; 0763 E778 ; count entries (in)/(remaining in) buffer given by X 0764 E778 ; returns: 0765 E778 ; number of entries present for input buffers 0766 E778 ; number of entries remaining for output buffers 0767 E778 ; 0768 E778 E0 02 CPXIM OUTPUT 0769 E77A ; C=0 => count used entries 0770 E77A ; C=1 => count free slots 0771 E77A ; 0772 E77A JMICNT 0773 E77A B8 CLV ;V=0 => count buffer entry 0774 E77B 50 03 BVC JMICNP ;[ALWAYS jump] 0775 E77D ; 0776 E77D 2C 49 D9 JMIPUR BIT FFBYT ;V=1 0777 E780 6C 2E 02 JMICNP JMI CNPVEC ;use indirection (defaults to CNP) 0778 E783 ; return count in X (lo) and Y (hi) 0779 E783 0780 E783 0781 E783 CNTRS ;count bytes left in RS423 input buffer Acorn macro assembler Page 95 MOS44 OSBYTE routines 0782 E783 38 SEC ;count empty slots left ... 0783 E784 A2 01 LDXIM BRSI ;... in RS423 input buffer 0784 E786 20 7A E7 JSR JMICNT 0785 E789 ; count in Y (hi) and X (lo) 0786 E789 C0 01 CPYIM &01 0787 E78B B0 03 BCS CNTRS0 ;[more than RSOVER bytes left] 0788 E78D ; 0789 E78D EC 5B 02 CPX RSHLVL 0790 E790 ; 0791 E790 CNTRS0 0792 E790 ; C=0 => overflow 0793 E790 ; C=1 => no overflow 0794 E790 60 RTS 0795 E791 0796 E791 0797 E791 RADCX ;read ADC channel X 0798 E791 [ MOS125 = &FF 0803 E791 | 0804 E791 30 E1 BMI BUFN ;[count entries in buffer] 0805 E793 E0 05 CPXIM &05 0806 E795 B0 D4 BCS BADADC 0807 E797 8A TXA 0808 E798 F0 08 BEQ FIRE ;[get status of fire buttons] 0809 E79A ] 0810 E79A ; return latest conversion 0811 E79A BC B9 02 LDYAX ADCHIV -&01 0812 E79D BD B5 02 LDAAX ADCLOV -&01 0813 E7A0 AA TAX ;X := lo-byte 0814 E7A1 60 RTS 0815 E7A2 0816 E7A2 0817 E7A2 FIRE ;get status of fire buttons 0818 E7A2 [ MOS125 = &FF 0826 E7A2 | 0827 E7A2 ; X=0, A=0, C=0 0828 E7A2 ED 40 FE SBC PBQ ;take one's complement of system VIA port B 0829 E7A5 6A RORA 0830 E7A6 6A RORA 0831 E7A7 6A RORA 0832 E7A8 6A RORA 0833 E7A9 ] 0834 E7A9 29 03 ANDIM &03 ;A := fire buttons 0835 E7AB AC BE 02 LDY ADCFLG ;return latest conversion number 0836 E7AE ; clear latest conversion number 0837 E7AE 8E BE 02 STX ADCFLG 0838 E7B1 AA TAX ;return status of fire buttons in b0 and b1 0839 E7B2 60 RTS 0840 E7B3 0841 E7B3 0842 E7B3 LNK MOS46 0001 E7B3 ; > MOS46 0002 E7B3 TTL MOS46 OSWORD routines 0003 E7B3 OPT MOS46 Acorn macro assembler Page 96 MOS46 OSWORD routines 0004 E7B3 ;(c) 1981 ACORN Computers Limited 0005 E7B3 ;BBC MOS 0006 E7B3 ;Change record: 0007 E7B3 ;203 01-May-82 PB Fix EXTSND bug 0008 E7B3 ;041 15-Aug-81 PB First edition 0009 E7B3 ;Author(s): 0010 E7B3 ;PB Paul Bond 0011 E7B3 0012 E7B3 0013 E7B3 BYTE ;OSBYTE call 0014 E7B3 ; 0015 E7B3 ; uses: 0016 E7B3 ; BYTEX, BYTEY (may be shared by sei-routines) 0017 E7B3 ; JMILO, JMIHI 0018 E7B3 ; 0019 E7B3 48 PHA 0020 E7B4 08 PHP 0021 E7B5 78 SEI ;**** DISABLE INTERRUPTS **** 0022 E7B6 ; 0023 E7B6 ; save A and X 0024 E7B6 ; 0025 E7B6 85 EF STA BYTEA 0026 E7B8 86 F0 STX BYTEX 0027 E7BA 84 F1 STY BYTEY 0028 E7BC ; 0029 E7BC A2 07 LDXIM SVBYTE ;illegal codes are referred to paged ROM 0030 E7BE ; 0031 E7BE ; check for legal code 0032 E7BE ; 0033 E7BE C9 75 CMPIM BYTEM 0034 E7C0 90 41 BCC BYTELO ;[interactive code] 0035 E7C2 ; 0036 E7C2 ; code >= BYTEM 0037 E7C2 ; 0038 E7C2 C9 A1 CMPIM BYTEH 0039 E7C4 90 09 BCC BYTEHI ;[code < BYTEH] 0040 E7C6 ; 0041 E7C6 ; check for variable setting 0042 E7C6 ; 0043 E7C6 C9 A6 CMPIM VORG 0044 E7C8 90 3F BCC BYTE0 ;[not a variable setting] 0045 E7CA ; 0046 E7CA ; set variable 0047 E7CA ; 0048 E7CA 18 CLC ;force A=BYTEH 0049 E7CB ; 0050 E7CB WORDU ;user OSWORD call, C=1, force A=BYTEH+$01 0051 E7CB ; 0052 E7CB A9 A1 LDAIM BYTEH 0053 E7CD 69 00 ADCIM ZERO ;add in carry (C=0 => variable, C=1 => user OSWORD) 0054 E7CF ; 0055 E7CF BYTEHI 0056 E7CF ; 0057 E7CF 38 SEC 0058 E7D0 E9 5F SBCIM BYTEM-BYTEL 0059 E7D2 ; 0060 E7D2 BYTE1 ;construct address of specific OSBYTE routine 0061 E7D2 ; 0062 E7D2 0A ASLA ;prepare for Y := 2*code 0063 E7D3 ; 0064 E7D3 38 SEC ;indicate OSBYTE call 0065 E7D4 ; 0066 E7D4 BYTE2 ;C=0 => OSWORD call 0067 E7D4 ; 0068 E7D4 84 F1 STY BYTEY ;save Y 0069 E7D6 ; 0070 E7D6 A8 TAY ;Y := 2*code 0071 E7D7 ; 0072 E7D7 ; allow net to indirect OS call 0073 E7D7 ; 0074 E7D7 [ MOS125 = &FF 0082 E7D7 | 0083 E7D7 AD 5E 02 LDA NETIOC 0084 E7DA B8 CLV 0085 E7DB 10 06 BPL NET1 ;[net not indirecting OS calls] 0086 E7DD ; 0087 E7DD ; indirect OS call thru net 0088 E7DD ; 0089 E7DD 8A TXA ;A := reason code 0090 E7DE ] 0091 E7DE 20 C1 E5 JSR JMINET ;args in BYTEA, BYTEX, BYTEY (call type in A) 0092 E7E1 70 1A BVS OSRET ;[net substituted result] 0093 E7E3 ; 0094 E7E3 ; construct specific OSBYTE routine address 0095 E7E3 ; 0096 E7E3 NET1 ;call internal routine 0097 E7E3 B9 F7 E5 LDAAY BYTET+&01 ;hi-byte 0098 E7E6 85 FB STA JMIHI 0099 E7E8 B9 F6 E5 LDAAY BYTET+&00 ;lo-byte 0100 E7EB 85 FA STA JMILO 0101 E7ED ; 0102 E7ED ; enter specific OSBYTE routine 0103 E7ED ; 0104 E7ED ; X = SVBYTE or SVWORD 0105 E7ED ; 0106 E7ED ; 0107 E7ED A5 EF LDA BYTEA ;in case OSBYTE call 0108 E7EF A4 F1 LDY BYTEY ;restore Y 0109 E7F1 ; 0110 E7F1 ; determine type of call 0111 E7F1 ; 0112 E7F1 B0 04 BCS OSB ;[OSBYTE call] 0113 E7F3 ; 0114 E7F3 ; OSWORD call 0115 E7F3 ; 0116 E7F3 A0 00 LDYIM ZERO 0117 E7F5 B1 F0 LDAIY WORDX 0118 E7F7 ; 0119 E7F7 OSB 0120 E7F7 ; 0121 E7F7 ; ********** V=0 USED BY OSBYTE ROUTINES ********** 0122 E7F7 38 SEC ;used by several routines 0123 E7F8 A6 F0 LDX BYTEX ;restore X (N.B. N, Z status used by several routines) 0124 E7FA 20 60 EA JSR JMI ;enter specific routine 0125 E7FD ; 0126 E7FD OSRET 0127 E7FD ; 0128 E7FD 6A RORA ;save C 0129 E7FE 28 PLP 0130 E7FF 2A ROLA ;restore C (needed by readline routine - BASIC expects it) 0131 E800 68 PLA ;restore A Acorn macro assembler Page 97 MOS46 OSWORD routines 0132 E801 B8 CLV ;indicate call recognised 0133 E802 60 RTS 0134 E803 0135 E803 0136 E803 [ NOSP = &00 0141 E803 ] 0142 E803 0143 E803 BYTELO ;code has top bit clear - use table lo component 0144 E803 A0 00 LDYIM ZERO ;only one argument, set Y=0 for variable settings and ADC ops 0145 E805 C9 16 CMPIM BYTEL 0146 E807 90 C9 BCC BYTE1 ;[recognised code] 0147 E809 ; 0148 E809 ; unrecognised code 0149 E809 ; 0150 E809 BYTE0 ;unrecognised OSBYTE code 0151 E809 WORD0 ;unrecognised OSWORD code (C=1) 0152 E809 ; force 4 bytes on stack (making 4 before Preg, simulating a return link) 0153 E809 08 PHP ;N.B. non-zero byte (SEI mode) 0154 E80A 08 PHP 0155 E80B ; 0156 E80B EXTSND ;entry point used by SOUND (return link still on stack) 0157 E80B 68 PLA 0158 E80C 68 PLA 0159 E80D ; 0160 E80D 20 74 F1 JSR SVOP ;offer to paged ROMs (N.B. X=SVBYTE or X=SVWORD) 0161 E810 D0 05 BNE BADOSC ;[unrecognised OS call] 0162 E812 ; 0163 E812 ; recognised OS call 0164 E812 ; 0165 E812 A6 F0 LDX BYTEX ;replace X (corrupted by SVOP) 0166 E814 ; 0167 E814 4C FD E7 JMP OSRET 0168 E817 0169 E817 0170 E817 BADOSC ;bad OS call 0171 E817 28 PLP ;restore interrupt status 0172 E818 68 PLA ;restore code to return with 0173 E819 2C 49 D9 BIT FFBYT ;indicate call not recognised 0174 E81C 60 RTS 0175 E81D 0176 E81D 0177 E81D [ MOS125 = &FF 0193 E81D ] 0194 E81D 0195 E81D 0196 E81D WORD ;OSWORD call 0197 E81D ; uses: 0198 E81D ; WORDX, WORDY (may be shared by sei-routines) 0199 E81D ; JMILO, JMIHI (may be shared by sei-routines) 0200 E81D ; 0201 E81D 48 PHA 0202 E81E 08 PHP ;save interrupt state 0203 E81F 78 SEI ;**** DISABLE INTERRUPTS **** 0204 E820 ; 0205 E820 ; save A, X and Y 0206 E820 ; 0207 E820 85 EF STA WORDA 0208 E822 86 F0 STX WORDX 0209 E824 84 F1 STY WORDY 0210 E826 ; 0211 E826 A2 08 LDXIM SVWORD ;code used if indirection taken 0212 E828 ; 0213 E828 ; check for user OSWORD call 0214 E828 ; 0215 E828 C9 E0 CMPIM &E0 0216 E82A B0 9F BCS WORDU ;[user OSWORD call - route thru USRVEC, C=1] 0217 E82C ; 0218 E82C ; not a user OSWORD call 0219 E82C ; 0220 E82C ; check for legal code 0221 E82C ; 0222 E82C C9 0E CMPIM WORDN 0223 E82E B0 D9 BCS WORD0 ;[unrecognised code] 0224 E830 ; C=0 0225 E830 ; 0226 E830 ; recognised OSWORD call 0227 E830 ; construct address of specific OSWORD routine 0228 E830 ; 0229 E830 ; C=0 0230 E830 69 44 ADCIM WORDT-BYTET:SHR: 1 0231 E832 ; C=0 0232 E832 ; 0233 E832 ; enter specific OSWORD routine 0234 E832 ; 0235 E832 0A ASLA ;prepare for Y := 2*code 0236 E833 ; C=0 0237 E833 90 9F BCC BYTE2 ;[ALWAYS jump, C=0 => OSWORD call] 0238 E835 0239 E835 [ MOS125 = &FF 0277 E835 ] 0278 E835 0279 E835 NOTE ;add note to note buffer 0280 E835 ; ********************* 0281 E835 ; MAY ENABLE INTERRUPTS 0282 E835 ; ********************* 0283 E835 ; XY -> 8 bytes of info 0284 E835 ; C=1 0285 E835 ; X=SVWORD 0286 E835 ; Y=0 0287 E835 ; 0288 E835 [ NOSP = &00 0300 E835 | 0301 E835 [ $Tutu 0306 E835 | 0307 E835 C8 INY 0308 E836 B1 F0 LDAIY WORDX ;A := command type indicator (hi-byte of 1st argument) 0309 E838 C9 FF CMPIM &FF 0310 E83A ] 0311 E83A F0 59 BEQ SPEECH ;[speech command] 0312 E83C C9 20 CMPIM &20 0313 E83E ] 0314 E83E 0315 E83E A2 08 LDXIM SVWORD ;in case EXTSND called 0316 E840 B0 C9 BCS EXTSND ;[route command to paged ROM] 0317 E842 ; 0318 E842 ; sound command 0319 E842 ; 0320 E842 88 DEY ;Y := 0 0321 E843 20 CD E8 JSR NOTEX ;C => flush, A = channel, Y := 1 0322 E846 09 04 ORAIM &04 ;********** N.B. assumes BSND1=4 0323 E848 AA TAX ;X := (internal) sound bufferid Acorn macro assembler Page 98 MOS46 OSWORD routines 0324 E849 90 05 BCC NOTENF ;[do not flush channel] 0325 E84B ; C=1 0326 E84B ; flush channel 0327 E84B ; 0328 E84B ; C=1 0329 E84B 20 FE E1 JSR PURGEX ;purge buffer 0330 E84E A0 01 LDYIM &01 ;restore Y 0331 E850 ; 0332 E850 NOTENF 0333 E850 20 CD E8 JSR NOTEX ;C => release continue, A = chordcount-1 0334 E853 85 FA STA NOTEWK 0335 E855 ; 0336 E855 08 PHP ;needed in order to share code with BELL 0337 E856 A0 06 LDYIM &06 ;A := duration-lo 0338 E858 B1 F0 LDAIY WORDX 0339 E85A 48 PHA 0340 E85B ; 0341 E85B A0 04 LDYIM &04 ;A := note-lo 0342 E85D B1 F0 LDAIY WORDX 0343 E85F 48 PHA 0344 E860 ; 0345 E860 ; C => release continue 0346 E860 ; 0347 E860 A0 02 LDYIM &02 0348 E862 B1 F0 LDAIY WORDX ;A = envelope-lo 0349 E864 2A ROLA ;rotate in release continue bit 0350 E865 38 SEC 0351 E866 E9 02 SBCIM &02 ;envelope numbers start at 1 0352 E868 0A ASLA 0353 E869 0A ASLA ;rotate in 2 zero bits 0354 E86A 05 FA ORA NOTEWK ;A := AEEE ERHH 0355 E86C ; 0356 E86C ; insert byte into buffer, waiting if necessary 0357 E86C ; 0358 E86C 20 49 E2 JSR WRITE 0359 E86F 90 1E BCC NOTE2 ;[byte inserted] 0360 E871 ; 0361 E871 SPESC ;ESCAPE detected 0362 E871 68 PLA 0363 E872 68 PLA 0364 E873 28 PLP 0365 E874 ; 0366 E874 VDUST ;FX call to return VDU status 0367 E874 A6 D0 LDX STATS 0368 E876 ; 0369 E876 60 RTS 0370 E877 0371 E877 0372 E877 ; 0373 E877 ;; ===== 0374 E877 ; BELL 0375 E877 ; ===== 0376 E877 ; 0377 E877 ; Add BELL to sound queue 0378 E877 ; 0379 E877 ; ENTRY:- No conditions 0380 E877 ; 0381 E877 ; EXIT:- A,X,Y Corrupted 0382 E877 ; Flags preserved 0383 E877 ; 0384 E877 BELL 0385 E877 08 PHP 0386 E878 78 SEI 0387 E879 ; 0388 E879 ; try to add bell to sound channel queue 0389 E879 ; 0390 E879 AD 63 02 LDA BELLC 0391 E87C 29 07 ANDIM &07 0392 E87E 09 04 ORAIM &04 0393 E880 AA TAX ;force valid sound channel 0394 E881 ; 0395 E881 ; insert envelope/chord info 0396 E881 ; 0397 E881 AD 64 02 LDA BELLI 0398 E884 20 F4 E4 JSR INSRT 0399 E887 ; 0400 E887 ; N.B. ignore return code 0401 E887 ; C=0 => inserted, C=1 => not inserted 0402 E887 ; if first INSRT failed then so will the following INSRTs 0403 E887 ; set to insert duration 0404 E887 ; 0405 E887 AD 66 02 LDA BELLD 0406 E88A 48 PHA 0407 E88B ; 0408 E88B ; set to insert note 0409 E88B ; 0410 E88B AD 65 02 LDA BELLN 0411 E88E 48 PHA 0412 E88F ; 0413 E88F NOTE2 ;buffer slot available 0414 E88F ; C=0 => inserted, C=1 => not inserted 0415 E88F ; 0416 E88F 38 SEC 0417 E890 7E 00 08 RORAX MACTIV-BSND1 0418 E893 [ NOSP = &00 0420 E893 | 0421 E893 30 17 BMI NOTE3 ;[ALWAYS JUMP] 0422 E895 ; 0423 E895 SPEECH ;SOUND -1,x,y,z command 0424 E895 ; Y=1 0425 E895 08 PHP ;needed to share code with BELL 0426 E896 C8 INY ;Y := $02 0427 E897 B1 F0 LDAIY WORDX 0428 E899 48 PHA 0429 E89A ; 0430 E89A C8 INY ;Y := $03 0431 E89B B1 F0 LDAIY WORDX 0432 E89D 48 PHA 0433 E89E ; 0434 E89E A0 00 LDYIM ZERO 0435 E8A0 B1 F0 LDAIY WORDX 0436 E8A2 A2 08 LDXIM BSPCH 0437 E8A4 20 49 E2 JSR WRITE ;insert first byte into buffer 0438 E8A7 B0 C8 BCS SPESC ;[escape detected] 0439 E8A9 ; 0440 E8A9 ; C=0 0441 E8A9 ; 0442 E8A9 6E D7 02 ROR SPSTAT ;indicate speech buffer non-empty 0443 E8AC ] 0444 E8AC ; 0445 E8AC NOTE3 ;add note and duration (ignored if first byte not inserted) Acorn macro assembler Page 99 MOS46 OSWORD routines 0446 E8AC 68 PLA 0447 E8AD 20 F4 E4 JSR INSRT ;add note data to queue 0448 E8B0 68 PLA 0449 E8B1 20 F4 E4 JSR INSRT ;add duration info to queue 0450 E8B4 28 PLP 0451 E8B5 60 RTS 0452 E8B6 0453 E8B6 0454 E8B6 NVLP ;define envelope shape 0455 E8B6 ; A := envelope number 0456 E8B6 ; C=1 0457 E8B6 ; 0458 E8B6 [ MOS125 = &FF 0470 E8B6 | 0471 E8B6 ; 0472 E8B6 ; envelope number forced into range 0 to 15 (1->0, 2->1 ... 16->15) 0473 E8B6 ; (0 forced to 255, which will have the same effect as 15) 0474 E8B6 ; 0475 E8B6 0A ASLA 0476 E8B7 0A ASLA 0477 E8B8 0A ASLA 0478 E8B9 0A ASLA ;envelope number := envelope number * 16 0479 E8BA AA TAX ;N.B. ENVSIZ must be 16! 0480 E8BB ] 0481 E8BB ; 0482 E8BB ; copy envelope definition to envelope slot 0483 E8BB ; padding to 16 bytes with zeroes 0484 E8BB ; 0485 E8BB A9 00 LDAIM ZERO ;padding value 0486 E8BD A0 10 LDYIM ENVSIZ 0487 E8BF ; 0488 E8BF NVLP1 0489 E8BF C0 0E CPYIM ENVSIZ-&02 0490 E8C1 B0 02 BCS NVLP2 ;[still padding] 0491 E8C3 ; 0492 E8C3 B1 F0 LDAIY WORDX 0493 E8C5 NVLP2 0494 E8C5 [ MOS125 = &FF 0497 E8C5 | 0498 E8C5 CA DEX 0499 E8C6 9D C0 08 STAAX ENVEL 0500 E8C9 ] 0501 E8C9 88 DEY 0502 E8CA D0 F3 BNE NVLP1 0503 E8CC ; 0504 E8CC 60 RTS 0505 E8CD 0506 E8CD NOTEX ;extract byte info from offset Y of vector 0507 E8CD B1 F0 LDAIY WORDX 0508 E8CF C9 10 CMPIM &10 ;C => flag (flush or release continue) 0509 E8D1 29 03 ANDIM &03 0510 E8D3 C8 INY ;step Y to next slot 0511 E8D4 60 RTS 0512 E8D5 0513 E8D5 RITM ;read interval time 0514 E8D5 A2 0F LDXIM STPW+&5-TIME 0515 E8D7 D0 03 BNE RTM ;[ALWAYS jump] 0516 E8D9 ; NEVER fall thru 0517 E8D9 RATM ;read absolute time 0518 E8D9 AE 83 02 LDX TIMESW 0519 E8DC RTM 0520 E8DC A0 04 LDYIM &04 0521 E8DE RTM1 0522 E8DE BD 8D 02 LDAAX TIME -&05 0523 E8E1 91 F0 STAIY WORDX 0524 E8E3 E8 INX 0525 E8E4 88 DEY 0526 E8E5 10 F7 BPL RTM1 0527 E8E7 WTM0 0528 E8E7 60 RTS 0529 E8E8 0530 E8E8 [ MOS125 = &FF 0539 E8E8 | 0540 E8E8 WATM ;write absolute time 0541 E8E8 AC 83 02 LDY TIMESW 0542 E8EB 18 CLC ;indicate WATM entry 0543 E8EC WITM ;write interval time, C=1, Y=0 0544 E8EC 98 TYA 0545 E8ED 49 0F EORIM &0F ;assumes STPW-TIME = &A 0546 E8EF ] 0547 E8EF WTM 0548 E8EF 48 PHA ;save TIMESW for WATM entry 0549 E8F0 AA TAX 0550 E8F1 A0 04 LDYIM &04 0551 E8F3 WTM1 0552 E8F3 B1 F0 LDAIY WORDX 0553 E8F5 9D 8D 02 STAAX TIME -&05 0554 E8F8 E8 INX 0555 E8F9 88 DEY 0556 E8FA 10 F7 BPL WTM1 0557 E8FC 68 PLA 0558 E8FD B0 E8 BCS WTM0 ;[not WATM entry, do not reset TIMESW] 0559 E8FF ; WATM entry, reset TIMESW 0560 E8FF 8D 83 02 STA TIMESW 0561 E902 60 RTS 0562 E903 0563 E903 RDLN ;read input buffer 0564 E903 ; ****************** 0565 E903 ; ENABLES INTERRUPTS 0566 E903 ; ****************** 0567 E903 ;**************** 0568 E903 ;variables: 0569 E903 ;zero page: RDLNX, RDLNY (contiguous) 0570 E903 ;other page: RDLNN, RDLNLC, RDLNHC (contiguous) 0571 E903 ;**************** 0572 E903 ;Called with Y and X the high and low addresses of the information 0573 E903 ;describing what is to be done. The bytes in order are: 0574 E903 ;lsb address of buffer 0575 E903 ;msb address of buffer 0576 E903 ;maximum length allowed 0577 E903 ;minimum character value to be stored in buffer 0578 E903 ;maximum character value to be stored in buffer 0579 E903 ;Return when escape is pressed or seen with CARRY SET 0580 E903 ;Return after CR (which is always stored) with CARRY CLEAR 0581 E903 ;Always returns with Y the number of characters in the buffer 0582 E903 ;DEL,ESC and NAK are always processed 0583 E903 ;**** NOTE **** 0584 E903 ; if the 'other page' variables are put into page zero 0585 E903 ; this routine can be made ~10 bytes shorter. 0586 E903 ; however, an extra pointer variable in page zero would 0587 E903 ; then be required. Acorn macro assembler Page 100 MOS46 OSWORD routines 0588 E903 ; this routine enables interrupts 0589 E903 ; ********** 0590 E903 ; copy 'other page' values 0591 E903 0592 E903 A0 04 LDYIM &04 0593 E905 BUFFPR 0594 E905 B1 F0 LDAIY WORDX 0595 E907 99 B1 02 STAAY RDLNN -&02 ;N.B. offset of -02 0596 E90A 88 DEY 0597 E90B C0 02 CPYIM &02 0598 E90D B0 F6 BCS BUFFPR ;[more arguments to copy] 0599 E90F ; 0600 E90F ; C=0, Y=1 0601 E90F ; copy buffer pointer 0602 E90F ; 0603 E90F B1 F0 LDAIY WORDX ;hi-byte 0604 E911 85 E9 STA RDLNBF +&01 0605 E913 88 DEY ;Y := 0 0606 E914 8C 69 02 STY LINES ;reset page mode page origin 0607 E917 B1 F0 LDAIY WORDX ;lo-byte 0608 E919 85 E8 STA RDLNBF +&00 0609 E91B ; 0610 E91B ; C=0, Y=0 0611 E91B ; 0612 E91B 58 CLI ;**** ENABLE INTERRUPTS **** 0613 E91C 90 1F BCC BUFFIN ;[ALWAYS JUMP] 0614 E91E ; 0615 E91E ; NEVER fall thru 0616 E91E 0617 E91E 0618 E91E [ MOS125 = &FF 0622 E91E | 0623 E91E A9 07 BUFEXH LDAIM BEL ;reflect bell to indicate error 0624 E920 D0 18 BNE BUFIGN ;ALWAYS jump 0625 E922 0626 E922 BUFNXB ;check for ESC explicitly in case machine in non ESC mode 0627 E922 ;CMPIM ESC 0628 E922 ;BEQ BUFESC ;[ESC, N.B. C = 1] 0629 E922 ; not DEL, NAK or ESC 0630 E922 91 E8 STAIY RDLNBF ;store character in buffer 0631 E924 C9 0D CMPIM MCR 0632 E926 F0 3F BEQ BUFEND ;[CR detected, exit indicating CR received] 0633 E928 CC B3 02 CPY RDLNN 0634 E92B B0 F1 BCS BUFEXH ;[buffer exhausted, do not echo character] 0635 E92D ; 0636 E92D ; buffer not exhausted 0637 E92D ; 0638 E92D CD B4 02 CMP RDLNLC 0639 E930 90 08 BCC BUFIGN ;[character < lo-character] 0640 E932 CD B5 02 CMP RDLNHC 0641 E935 90 02 BCC BUFECH ;[character < hi-character, so accept] 0642 E937 D0 01 BNE BUFIGN ;[character > hi-character, so ignore] 0643 E939 C8 BUFECH INY ;increment count of characters in buffer 0644 E93A BUFIGN 0645 E93A ] 0646 E93A ; echo character 0647 E93A BFWRCH 0648 E93A 20 EE FF JSR OSWRCH 0649 E93D ; 0650 E93D BUFFIN ;main loop 0651 E93D 20 E0 FF JSR OSRDCH ;read a character 0652 E940 B0 2B BCS BUFESC ;[escape detected] 0653 E942 AA TAX 0654 E943 AD 7C 02 LDA WRCHSW 0655 E946 6A RORA 0656 E947 6A RORA 0657 E948 8A TXA 0658 E949 B0 05 BCS BUFNQ ;[output does not include VDU] 0659 E94B ; 0660 E94B ; output includes VDU 0661 E94B ; 0662 E94B ; 0663 E94B AE 6A 02 LDX QPOSN 0664 E94E D0 EA BNE BFWRCH ;[VDU queueing, reflect character] 0665 E950 ; 0666 E950 ; output does not include VDU 0667 E950 ; 0668 E950 BUFNQ ;VDU not queueing 0669 E950 [ MOS125 = &FF 0698 E950 | 0699 E950 C9 7F CMPIM MDEL 0700 E952 F0 05 BEQ BUFCNL ;[DEL received] 0701 E954 C9 15 CMPIM MNAK 0702 E956 D0 CA BNE BUFNXB ;[not DEL or NAK] 0703 E958 18 CLC 0704 E959 BUFCNL ;output DEL once (CC) or for each character in the buffer 0705 E959 98 TYA 0706 E95A F0 E1 BEQ BUFFIN ;[reached start of line] 0707 E95C 88 DEY 0708 E95D A9 7F LDAIM MDEL 0709 E95F B0 D9 BCS BFWRCH ;[if DEL, reflect DEL and get next char] 0710 E961 20 EE FF JSR OSWRCH 0711 E964 18 CLC 0712 E965 90 F2 BCC BUFCNL ;[ALWAYS jump, more characters to delete] 0713 E967 ] 0714 E967 ; NEVER fall thru 0715 E967 ; 0716 E967 [ MOS125 = &FF 0736 E967 ] 0737 E967 0738 E967 BUFEND ;read line successful 0739 E967 ; echo LF CR 0740 E967 20 E7 FF JSR OSNEWL 0741 E96A 20 C1 E5 JSR JMINET ;N.B. assumes NTCR has value $0D 0742 E96D ; 0743 E96D BUFESC ;escape exit (C=1) 0744 E96D A5 FF LDA ESCFLG 0745 E96F 2A ROLA ;C=0 => no escape, C=1 => escape 0746 E970 60 RTS 0747 E971 0748 E971 0749 E971 [ MOS125 = &7F 0750 E971 ;flash keyboard LEDs while waiting for printer buffer to purge 0751 E971 ;C=1 0752 E971 SPFL 0753 E971 [ STARGO = &00 0754 E971 48 PHA ;save FX call number 0755 E972 8A TXA 0756 E973 48 PHA ;save printer selection 0757 E974 20 DE E9 JSR MOSTST ;flash LEDs 0758 E977 68 PLA Acorn macro assembler Page 101 MOS46 OSWORD routines 0759 E978 AA TAX ;restore printer selection 0760 E979 68 PLA ;restore FX call number 0761 E97A 38 SEC ;restore C=1 0762 E97B ] 0763 E97B ] 0764 E97B 0765 E97B SPRINT ;change printer selection (*FX 5) 0766 E97B ; allow interrupts during wait, this means that: 0767 E97B ; (a) the printer can purge AND/OR 0768 E97B ; (b) escape can be detected 0769 E97B 58 CLI 0770 E97C 78 SEI 0771 E97D 24 FF BIT ESCFLG 0772 E97F 30 30 BMI SPR0 ;[escape detected] 0773 E981 2C D2 02 BIT PFLAG 0774 E984 [ MOS125 = &7F 0775 E984 10 EB BPL SPFL ;printer busy, flash LEDs while purging 0776 E986 | 0778 E986 ] 0779 E986 ; mention change of printer to print routines 0780 E986 20 F4 E1 JSR UPTX ;N.B. Y corrupted 0781 E989 ; interrupts may have corrupted BYTEX and BYTEY, so restore them 0782 E989 A0 00 LDYIM ZERO ;Y altered by call to UPTX 0783 E98B 84 F1 STY BYTEY 0784 E98D ; N.B. X reset at SETVX 0785 E98D ; N.B. A not altered since SPRINT 0786 E98D ; 0787 E98D V2B156 ;convert FX 1,5,6 to FX 241,245,246 0788 E98D 09 F0 ORAIM &F0 0789 E98F D0 0E BNE SETVX ;[ALWAYS jump] 0790 E991 ; 0791 E991 ARRPT ;A = $0C, set auto-repeat repeat count 0792 E991 ; N.B. previous instruction was LDX 0793 E991 ; C=1 0794 E991 D0 07 BNE ARRPT1 ;[X<>0 => do not set defaults] 0795 E993 ; set defaults 0796 E993 A2 32 LDXIM DAUTOD 0797 E995 8E 54 02 STX FARSET 0798 E998 A2 08 LDXIM DAUTOP 0799 E99A ARRPT1 ;A = $0C, C=1 0800 E99A ARDLY ;A = $0B, C=1, set auto-repeat delay count (0 => disable) 0801 E99A 69 CF ADCIM FARSET-VBASE-&01-&0B- 233 ;$01 for carry, $0B for FX base 0802 E99C ; 0803 E99C V2B34 ;C=1 0804 E99C 18 CLC 0805 E99D 69 E9 ADCIM 233 ;convert FX 3&4 to FX 236,237 0806 E99F ; 0807 E99F SETVX 0808 E99F 86 F0 STX BYTEX 0809 E9A1 ; 0810 E9A1 SETV ;set variable 0811 E9A1 ; A = FX code 0812 E9A1 ; X = value 0813 E9A1 ; Y = mask 0814 E9A1 A8 TAY ;Y := FX code 0815 E9A2 B9 90 01 LDAAY VBASE ;A := old value 0816 E9A5 AA TAX ;X := old value 0817 E9A6 25 F1 AND BYTEY ;apply mask 0818 E9A8 45 F0 EOR BYTEX ;apply value 0819 E9AA 99 90 01 STAAY VBASE ;store new value 0820 E9AD B9 91 01 LDAAY VBASE+&01 0821 E9B0 A8 TAY ;return following byte 0822 E9B1 SPR0 0823 E9B1 60 RTS 0824 E9B2 0825 E9B2 0826 E9B2 BAUDS ;baud rate table (N.B. RS423 bit set cos of B9600 definition) 0827 E9B2 BUFTYP ;**** WARNING - SUBTLE WAY TO DETECT SOUND BUFFERS **** 0828 E9B2 ; (*) = sound buffer 0829 E9B2 0080 SOUNDB * &80 0830 E9B2 64 = B9600 ;default baud rate / buffer 0 0831 E9B3 7F = &7F ;75 111 111 / buffer 1 0832 E9B4 5B = &5B ;150 011 011 / buffer 2 0833 E9B5 6D = &6D ;300 101 101 / buffer 3 0834 E9B6 C9 = &49+SOUNDB ;1200 001 001 / buffer 4 (*) 0835 E9B7 F6 = &76+SOUNDB ;2400 110 110 / buffer 5 (*) 0836 E9B8 D2 = &52+SOUNDB ;4800 010 010 / buffer 6 (*) 0837 E9B9 E4 = B9600+SOUNDB ;9600 100 100 / buffer 7 (*) 0838 E9BA 40 = &40 ;19200 000 000 / buffer 8 0839 E9BB 0840 E9BB 0841 E9BB WFVS ;wait for vertical sync 0842 E9BB AD 40 02 LDA CYCLE 0843 E9BE WFVS1 ;wait for CYCLE to alter 0844 E9BE 58 CLI ;must enable interrupts to allow CYCLE to operate 0845 E9BF ; this should give the user control immediately after VSYNC 0846 E9BF ; interrupt occurred 0847 E9BF 78 SEI 0848 E9C0 CD 40 02 CMP CYCLE 0849 E9C3 F0 F9 BEQ WFVS1 ;[CYCLE not altered] 0850 E9C5 ; 0851 E9C5 ; share exit with read VDU variable 0852 E9C5 ; 0853 E9C5 VDUVAR ;read VDU variables 0854 E9C5 BC 01 03 LDYAX VARBLE+&01 0855 E9C8 BD 00 03 LDAAX VARBLE+&00 0856 E9CB AA TAX 0857 E9CC 60 RTS 0858 E9CD 0859 E9CD 0860 E9CD RSOFT ;reset soft keys 0861 E9CD ; initialise soft key pointers 0862 E9CD ; exits with X=0 (used by RESET) 0863 E9CD ; ********** MUST NOT CORRUPT Y (SEE RESET) ********** 0864 E9CD A9 10 LDAIM NSOFTK 0865 E9CF 8D 84 02 STA USKFLG ;signal soft keys inconsistent 0866 E9D2 A2 00 LDXIM ZERO 0867 E9D4 STTA ;set soft key buffer pointers, including the two end pointers 0868 E9D4 9D 00 0B STAAX SKPTR 0869 E9D7 E8 INX 0870 E9D8 D0 FA BNE STTA 0871 E9DA ; X=0 0872 E9DA 8E 84 02 STX USKFLG ;USKFLG set to zero when soft keys consistent 0873 E9DD ; X=0 0874 E9DD 60 RTS 0875 E9DE 0876 E9DE 0877 E9DE LNK MOS48 0001 E9DE 0002 E9DE ; MOS48 0003 E9DE TTL MOS48 Miscellaneous routines Acorn macro assembler Page 102 MOS48 Miscellaneous routines 0004 E9DE OPT MOS48 Acorn macro assembler Page 103 MOS48 Miscellaneous routines 0005 E9DE ;(c) 1981 ACORN Computers Limited 0006 E9DE ;BBC Microcomputer Machine Operating System (MOS) 0007 E9DE 0008 E9DE ;Change record: 0009 E9DE ;01/03/82 PB GSINTC CR indication 0010 E9DE ;05/01/82 PB Change from printer claim to RS423 0011 E9DE 0012 E9DE ;Author(s): 0013 E9DE ;PB Paul Bond 0014 E9DE 0015 E9DE 0016 E9DE TTL MOS48 External interface routines 0017 E9DE OPT OPNEWP Acorn macro assembler Page 104 MOS48 External interface routines 0018 E9DE 0019 E9DE 0020 E9DE ; external interfaces 0021 E9DE 0022 E9DE 0023 E9DE MOSTST 0024 E9DE ; C=0 => do not set LEDs, C=1 => set LEDs 0025 E9DE ; N.B. must not corrupt X (see WRCH print section) 0026 E9DE 08 PHP ;push interrupt state 0027 E9DF 78 SEI 0028 E9E0 ; test for ESCAPE 0029 E9E0 A9 40 LDAIM &40 0030 E9E2 20 EF E9 JSR LEDSON ;conditionally set LEDs and test escape condition 0031 E9E5 30 05 BMI SHIFTX ;[escape pending, simulate SHIFT without CTRL] 0032 E9E7 ; 0033 E9E7 18 CLC ;indicate test ctrl/shift entry point 0034 E9E8 B8 CLV 0035 E9E9 20 77 F0 JSR JMIKEY 0036 E9EC ; 0037 E9EC SHIFTX ;b7(A) => CTRL, b6(A) => SHIFT 0038 E9EC 28 PLP 0039 E9ED 2A ROLA ;C => CTRL, MI => SHIFT 0040 E9EE 60 RTS 0041 E9EF 0042 E9EF 0043 E9EF LEDSON ;turn LEDs on 0044 E9EF ; **************************************** 0045 E9EF ; MUST BE ENTERED WITH INTERRUPTS DISABLED 0046 E9EF ; **************************************** 0047 E9EF ; C=0 => do not turn LEDs on, C=1 => turn LEDs on 0048 E9EF ; returns status of BIT ESCFLG 0049 E9EF 90 09 BCC LEDS0 ;[do not turn LEDs on] 0050 E9F1 ; set both LEDs (indicating a wait state) 0051 E9F1 A0 07 LDYIM &07 0052 E9F3 8C 40 FE STY PBQ ;PBQ:=$07 0053 E9F6 88 DEY 0054 E9F7 8C 40 FE STY PBQ ;PBQ:=$06 0055 E9FA LEDS0 ;set escape status 0056 E9FA 24 FF BIT ESCFLG 0057 E9FC 60 RTS 0058 E9FD 0059 E9FD CREG ;called by VDU module 0060 E9FD ; interrupts are disabled in order that a spurious 0061 E9FD ; ADC interrupt does not occur 0062 E9FD 08 PHP ;save interrupt state 0063 E9FE 78 SEI 0064 E9FF 8D 40 FE STA PBQ ;set addressable latch value 0065 EA02 28 PLP ;restore interrupt state 0066 EA03 60 RTS 0067 EA04 0068 EA04 0069 EA04 VP0 ;program vidproc register 0 (FX entry) 0070 EA04 8A TXA 0071 EA05 MVPRC0 ;set video processor register 0 0072 EA05 08 PHP 0073 EA06 78 SEI ;**** DISABLE INTERRUPTS **** 0074 EA07 8D 48 02 STA VPREGA ;update RAM image 0075 EA0A 8D 20 FE STA VPROC0 ;update ULA 0076 EA0D AD 53 02 LDA FLMRK 0077 EA10 8D 51 02 STA FLCNT ;reset flash count to mark value 0078 EA13 28 PLP 0079 EA14 60 RTS 0080 EA15 0081 EA15 VP1 ;program vidproc register 1 (FX entry) 0082 EA15 8A TXA 0083 EA16 MVPRC1 ;set video processor register 1 0084 EA16 49 07 EORIM &07 ;adjust value accounting for ULA bug 0085 EA18 08 PHP 0086 EA19 78 SEI ;**** DISABLE INTERRUPTS **** 0087 EA1A 8D 49 02 STA VPREGB ;update RAM image 0088 EA1D 8D 21 FE STA VPROC1 ;update ULA 0089 EA20 28 PLP 0090 EA21 60 RTS 0091 EA22 0092 EA22 [ MOS125 = &FF 0093 EA22 | 0094 EA22 ; fetch/store byte from MMIO without dummy read cycle 0095 EA22 ; on entry A=OSBYTE call no. X=addr lo Y=byte C=1 0096 EA22 69 65 CHEQUE ADCIM &65 ;C=1; A=&FC..FE 0097 EA24 38 SEC 0098 EA25 6A RORA ;C=0 read memory C=1 write 0099 EA26 ; fetch/store byte from I/O mem without dummy read 0100 EA26 ; on entry A=addr hi X=addr lo Y=byte C=0 read C=1 write 0101 EA26 BOUNCE 0102 EA26 85 FB STA PEEKHI ;MSB address 0103 EA28 86 FA STX PEEKLO ;LSB address 0104 EA2A A2 00 LDXIM &00 0105 EA2C 90 04 BCC BREAD 0106 EA2E 98 TYA 0107 EA2F 81 FA STAIX PEEKLO 0108 EA31 60 RTS 0109 EA32 BREAD 0110 EA32 A1 FA LDAIX PEEKLO 0111 EA34 A8 TAY 0112 EA35 38 SEC ;return C=1 from OSBYTE/OSWORD 0113 EA36 60 RTS 0114 EA37 0115 EA37 MSGON ;used by CFS 0116 EA37 ;Return EQ if messages off and not doing catalogue 0117 EA37 ;or during EXEC/SPOOL (during which messages cannot occur 0118 EA37 ;since this implies writing chars while within RDCH or WRCH) 0119 EA37 0120 EA37 A5 EB LDA ESSEMA 0121 EA39 30 22 BMI MSGONY ;Inside RDCH/WRCH -> msgs OFF 0122 EA3B 0123 EA3B A9 08 LDAIM CATBIT 0124 EA3D 25 E2 AND CFSTAT 0125 EA3F D0 04 BNE MSGONX ;Out with msgs set. 0126 EA41 0127 EA41 A9 88 LDAIM MONBIT 0128 EA43 25 BB AND USFLGS 0129 EA45 60 MSGONX RTS 0130 EA46 0131 EA46 PEEK ;read byte from I/O processor 0132 EA46 18 CLC 0133 EA47 POKE ;write byte to I/O processor 0134 EA47 AA TAX ;hold address lo-byte 0135 EA48 C8 INY ;Y=1 0136 EA49 B1 F0 LDAIY WORDX ;get address hi-byte 0137 EA4B 48 PHA ;address in X and 1,S 0138 EA4C A0 04 LDYIM &04 ;point to byte to write Acorn macro assembler Page 105 MOS48 External interface routines 0139 EA4E B1 F0 LDAIY WORDX 0140 EA50 A8 TAY ;hold byte to write 0141 EA51 68 PLA ;restore MSB of address 0142 EA52 20 26 EA JSR BOUNCE ;write byte in Y/read byte into A 0143 EA55 A0 04 LDYIM &04 0144 EA57 91 F0 STAIY WORDX ;store byte read in OSWORD block 0145 EA59 VER 0146 EA59 F0 07 BEQ PVER 0147 EA5B A2 01 LDXIM MCVER ;X=1 for OSBYTE 0,1 MOS version 1 0148 EA5D MSGONY ;used by MSGON below 0149 EA5D A9 00 LDAIM ZERO 0150 EA5F 60 RTS 0151 EA60 0152 EA60 6C FA 00 JMI JMI JMILO ;jump to specific OSBYTE routine, C=1 0153 EA63 EA62 PVER * JMI + &02 ;JMILO in zp, use high byte as BRK 0154 EA63 F7 = FX0MSG 0155 EA64 4F 53 20 = "OS " 0156 EA67 31 = VERA 0157 EA68 2E = "." 0158 EA69 32 = VERB 0159 EA6A 36 = VERC ;BRK forms terminator 0160 EA6B 0161 EA6B BADSTR 0162 EA6B 00 BRK ;report error 'Bad string' 0163 EA6C FD = BADST 0164 EA6D 42 61 64 = "Bad string" 0165 EA77 00 = ZERO ;end of message 0166 EA78 ] 0167 EA78 0168 EA78 GSINTC ;intialise for string access (read item) 0169 EA78 0170 EA78 18 CLC 0171 EA79 GSINTS ;initialise for string access (read item/rest of line) 0172 EA79 66 E4 ROR KQUOTE 0173 EA7B 20 93 E0 JSR SKIPSP ;A := LDAIY WORK 0174 EA7E C8 INY ;skip possible opening quote 0175 EA7F C9 22 CMPIM DQUOTE 0176 EA81 F0 02 BEQ CLIOQ ;[opening quote, C=1] 0177 EA83 ; no opening quote 0178 EA83 88 DEY ;adjust for erroneous skip 0179 EA84 18 CLC 0180 EA85 CLIOQ 0181 EA85 66 E4 ROR KQUOTE ;PL => not a quoted string, MI => a quoted string 0182 EA87 C9 0D CMPIM MCR ;return EQ => end-of-string, NEQ => not end-of-string 0183 EA89 60 RTS 0184 EA8A ; 0185 EA8A GSREAD ;read character from string 0186 EA8A 0187 EA8A ; reset key mask (used in top bit option) 0188 EA8A A9 00 LDAIM ZERO 0189 EA8C GSRA ;used by |! option, entered with A=$80 0190 EA8C 85 E5 STA KMASK ;KMASK := 0000 0000 (or KMASK := 1000 0000) 0191 EA8E B1 F2 LDAIY WORK ;A := next character 0192 EA90 C9 0D CMPIM MCR 0193 EA92 D0 06 BNE KEYNCR ;[not CR] 0194 EA94 ; CR found, C=1 0195 EA94 ; check that string did not open with double quote 0196 EA94 24 E4 BIT KQUOTE 0197 EA96 30 D3 BMI BADSTR ;[opening double quote without closing double quote] 0198 EA98 10 19 BPL GSR1 ;[ALWAYS jump, return C=1 and EQ=>CR] 0199 EA9A KEYNCR ;character not CR 0200 EA9A C9 20 CMPIM SPACE 0201 EA9C 90 CD BCC BADSTR ;[control character in string] 0202 EA9E D0 06 BNE KEYNSP ;[not space] 0203 EAA0 ; space character 0204 EAA0 24 E4 BIT KQUOTE 0205 EAA2 30 3E BMI GSR0 ;[in quoted string] 0206 EAA4 50 0D BVC GSR1 ;[not in quoted string and not read line, so space is terminator] 0207 EAA6 ; fall thru, space will be returned as a valid character 0208 EAA6 KEYNSP 0209 EAA6 C9 22 CMPIM DQUOTE 0210 EAA8 D0 0E BNE KEYNDQ ;[not double quote] 0211 EAAA ; double quote found 0212 EAAA 24 E4 BIT KQUOTE 0213 EAAC 10 34 BPL GSR0 ;[not in quoted string] 0214 EAAE ; in quoted string 0215 EAAE C8 INY 0216 EAAF [ MOS125 = &FF 0219 EAAF | 0220 EAAF D1 F2 CMPIY WORK ;A = DQUOTE, compare with next character 0221 EAB1 ] 0222 EAB1 F0 2F BEQ GSR0 ;["" found in quoted string] 0223 EAB3 GSR1 ;closing quote of quoted string 0224 EAB3 20 93 E0 JSR SKIPSP ;skip spaces 0225 EAB6 38 SEC 0226 EAB7 60 RTS 0227 EAB8 0228 EAB8 KEYNDQ ;character not CR or " 0229 EAB8 C9 7C CMPIM "|" ;check for pseudo-escape 0230 EABA D0 26 BNE GSR0 ;[valid string character] 0231 EABC ; 0232 EABC C8 INY 0233 EABD B1 F2 LDAIY WORK 0234 EABF C9 7C CMPIM "|" 0235 EAC1 F0 1F BEQ GSR0 ;[|| found] 0236 EAC3 ; 0237 EAC3 C9 22 CMPIM DQUOTE 0238 EAC5 F0 1B BEQ GSR0 ;[|" found] 0239 EAC7 ; 0240 EAC7 C9 21 CMPIM "!" 0241 EAC9 D0 05 BNE KEYNPL ;[not |!] 0242 EACB ; C=1 0243 EACB ; |! found - top bit option 0244 EACB C8 INY ;step to next character 0245 EACC ; C=1 0246 EACC A9 80 LDAIM &80 ;KMASK := 1000 0000 0247 EACE D0 BC BNE GSRA ;[ALWAYS jump, get next character reseting key mask] 0248 EAD0 ; NEVER fall thru 0249 EAD0 0250 EAD0 KEYNPL ;check for control character 0251 EAD0 C9 20 CMPIM SPACE 0252 EAD2 90 97 BCC BADSTR ;[string contains a control character] 0253 EAD4 ; convert to CTRL character 0254 EAD4 C9 3F CMPIM "?" 0255 EAD6 F0 08 BEQ KEYDEL 0256 EAD8 20 0B EB JSR CTRLCH 0257 EADB ; fall thru with adjusted character 0258 EADB 2C 49 D9 BIT FFBYT ;indicate character was escaped 0259 EADE 70 03 BVS GSRX ;[ALWAYS jump] 0260 EAE0 ; 0261 EAE0 KEYDEL ;|? Acorn macro assembler Page 106 MOS48 External interface routines 0262 EAE0 A9 7F LDAIM MDEL 0263 EAE2 ; 0264 EAE2 GSR0 ;valid character 0265 EAE2 B8 CLV 0266 EAE3 ; 0267 EAE3 GSRX ;exit with valid character 0268 EAE3 ; rotate in selected top bit 0269 EAE3 C8 INY ;skip to next character 0270 EAE4 05 E5 ORA KMASK ;test character for filing system applications 0271 EAE6 18 CLC 0272 EAE7 ; C=0, V=0 => not escaped, V=1 => escaped 0273 EAE7 60 RTS 0274 EAE8 0275 EAE8 0276 EAE8 [ MOS125 = &FF 0282 EAE8 ] 0283 EAE8 0284 EAE8 SHIFT ;perform shift inversion 0285 EAE8 ; 0286 EAE8 ; check for '0' character explicitly 0287 EAE8 ; 0288 EAE8 C9 30 CMPIM "0" 0289 EAEA F0 1E BEQ SHIFT0 ;[character is '0', shift '0' is '0', no action] 0290 EAEC 0291 EAEC ; convert characters in range ['A',DEL) 0292 EAEC ; 0293 EAEC C9 40 CMPIM AT 0294 EAEE F0 1A BEQ SHIFT0 ;[AT, no action] 0295 EAF0 90 12 BCC SHIFT1 ;[ch= 'A' 0298 EAF2 ; 0299 EAF2 C9 7F CMPIM MDEL 0300 EAF4 F0 14 BEQ SHIFT0 ;[ch=DEL, no action] 0301 EAF6 B0 10 BCS SHFLIP ;[ch>DEL, is softkey code] 0302 EAF8 ; 0303 EAF8 ; 'A' <= character < DEL 0304 EAF8 ; 0305 EAF8 CTRLSK ;used by CTRLCH for CTRL/softkey 0306 EAF8 49 30 EORIM &30 ;flip bit to effect shift (N.B. EORIM $10 later) 0307 EAFA ; 0308 EAFA ; N.B. this has mapped '_' to $6F and POUND to $50 0309 EAFA ; swop underline and pound characters 0310 EAFA ; 0311 EAFA C9 6F CMPIM &6F ;i.e. mapped '_' 0312 EAFC F0 04 BEQ SHIFT2 ;[underline character] 0313 EAFE C9 50 CMPIM &50 ;i.e. mapped POUND (not altered by EORIM $20 anyway) 0314 EB00 D0 02 BNE SHIFT1 ;[neither underline nor pound character] 0315 EB02 ; 0316 EB02 SHIFT2 ;swop underline and pound characters 0317 EB02 49 1F EORIM &1F 0318 EB04 ; 0319 EB04 SHIFT1 0320 EB04 0321 EB04 ; convert characters above '!' 0322 EB04 ; 0323 EB04 C9 21 CMPIM "!" 0324 EB06 90 02 BCC SHIFT0 ;[ch<'!', no action] 0325 EB08 ; 0326 EB08 ; '!' <= ch < AT 0327 EB08 ; 0328 EB08 SHFLIP 0329 EB08 49 10 EORIM &10 ;$80..$8F -> $90..$9F and vice-versa 0330 EB0A 0331 EB0A SHIFT0 0332 EB0A 60 RTS 0333 EB0B 0334 EB0B 0335 EB0B CTRLCH ;compute CTRL version of character 0336 EB0B C9 7F CMPIM MDEL 0337 EB0D F0 0E BEQ CTRL0 ;[CTRL/DEL = DEL] 0338 EB0F B0 E7 BCS CTRLSK ;[top bit set, therefore softkey needing EORIM $20] 0339 EB11 0340 EB11 ; pound & underline 0341 EB11 ; 0342 EB11 C9 60 CMPIM POUND ;make CTRL/pound = CTRL/underline 0343 EB13 D0 02 BNE CTRL1 ;[not pound character] 0344 EB15 A9 5F LDAIM "_" ;substitute underline for pound 0345 EB17 CTRL1 0346 EB17 0347 EB17 [ FALSE=0 0353 EB17 ] 0354 EB17 0355 EB17 [ FALSE=0 0361 EB17 ] 0362 EB17 0363 EB17 C9 40 CMPIM AT 0364 EB19 90 02 BCC CTRL4 ;[character < AT so do not convert] 0365 EB1B ; AT <= character < DEL, so convert 0366 EB1B 29 1F ANDIM &1F ;convert to ctrl value 0367 EB1D CTRL4 0368 EB1D 0369 EB1D CTRL0 0370 EB1D 60 RTS 0371 EB1E 0372 EB1E [ FALSE=0 0375 EB1E ] 0376 EB1E 0377 EB1E SLBOOT ;'/!BOOT' auto-boot string 0378 EB1E 2F 21 42 = "/!BOOT" 0379 EB24 0D = MCR 0380 EB25 0381 EB25 0382 EB25 BREAK ;conditionally intercept BREAK 0383 EB25 ; type of interception is in C 0384 EB25 AD 87 02 LDA BREAKI 0385 EB28 49 4C EORIM &4C 0386 EB2A D0 13 BNE BREAK0 ;[not a JMP instruction] 0387 EB2C 4C 87 02 JMP BREAKI 0388 EB2F 0389 EB2F 0390 EB2F TV ;alter TV characteristics 0391 EB2F AD 90 02 LDA VERTIC 0392 EB32 8E 90 02 STX VERTIC ;vertical height adjust 0393 EB35 AA TAX ;X := old state 0394 EB36 98 TYA 0395 EB37 29 01 ANDIM &01 0396 EB39 AC 91 02 LDY INTERL ;Y := old state 0397 EB3C 8D 91 02 STA INTERL ;interlace invert 0398 EB3F BREAK0 0399 EB3F 60 RTS Acorn macro assembler Page 107 MOS48 External interface routines 0400 EB40 0401 EB40 [ MOS125 = &FF 0416 EB40 ] 0417 EB40 0418 EB40 LNK MOS52 0001 EB40 0002 EB40 ; MOS52 0003 EB40 TTL MOS52 Sound generator 0004 EB40 OPT MOS52 Acorn macro assembler Page 108 MOS52 Sound generator 0005 EB40 ;(c) 1981 ACORN Computers Limited 0006 EB40 ;BBC Microcomputer Machine Operating System (MOS) 0007 EB40 ;Change record: 0008 EB40 ;Prototype version 14/1/82 0009 EB40 ;Author(s): 0010 EB40 ;PBM Peter Miller 0011 EB40 ;Internal variable allocation $0800 to $08C0 0012 EB40 08C0 ENV * ENVEL ;envelope table 16 bytes per envelope 0013 EB40 0804 ATTN * SNDWRK+&04 ;current attenuation 0014 EB40 0808 EPERD * ATTN +&04 ;current envelope period 0015 EB40 080C SNOTE * EPERD +&04 ;base note 0016 EB40 0810 NPERD * SNOTE +&04 ;the current frequency envelope period 0-3 0017 EB40 0814 NCONT * NPERD +&04 ;number of ticks left in current frequency period 0018 EB40 0818 DUR * NCONT +&04 ;remaining number of ticks in the current note 0019 EB40 081C DRDIV * DUR +&04 ;division of 1/100 sewc to 1/20 sec 0020 EB40 0820 ENVLP * DRDIV +&04 ;current envelope ( TIMES 16) 0021 EB40 0824 SCONT * ENVLP +&04 ;number of 1/100th secs before next envelope tick 0022 EB40 0828 WAIT * SCONT +&04 ;channel waiting for sWATGO flag 0023 EB40 082C OLDNTE * WAIT +&04 ;current note in chip 0024 EB40 0830 NTADD * OLDNTE +&04 ;current offset from base note 0025 EB40 0026 EB40 0027 EB40 0838 NOWAT * NTADD +&08 ;number of other channels required for chord 0028 EB40 0839 ATINC * NOWAT +&01 ;current rate of attn change 0029 EB40 083A PEAK * ATINC +&01 ;peak of amplitude envelope 0030 EB40 083B WATGO * PEAK +&01 ;flag <>0 => play chord 0031 EB40 083C FRACT * WATGO +&01 ;fractional part of current note 0032 EB40 083D PRDL * FRACT +&01 ;low period during convert 0033 EB40 083E PRDH * PRDL +&01 ;hign period during convert 0034 EB40 083F NOTDIF * PRDH +&01 ;Note difference used in interpolation 0035 EB40 0036 EB40 02CF FLUSH * SFLUSH -&04 0037 EB40 0800 ACTIV * MACTIV -&04 0038 EB40 0039 EB40 0040 EB40 ;Externally referenced data 0041 EB40 ;ACTIV 0042 EB40 ;FLUSH 0043 EB40 ;ENVEL 0044 EB40 ;SNDWRK 0045 EB40 ;Externally referenced routines 0046 EB40 ;EXAM 0047 EB40 ;REMOV 0048 EB40 ;Entry points 0049 EB40 ;SNDRST Initialise sound system, shut sound chip up 0050 EB40 ; Acc,X,Y ,P destroyed 0051 EB40 ;SNDIRQ Service entry point 1/100th second 0052 EB40 ; only use after initialisation 0053 EB40 ; Acc,X ,Y and P destroyed 0054 EB40 ;; A,X,P preserved, Y set to zero on exit 0055 EB40 0056 EB40 0057 EB40 MINATN ;set minimum attenuation 0058 EB40 A9 04 LDAIM &04 0059 EB42 9D 08 08 STAAX EPERD 0060 EB45 A9 C0 LDAIM &C0 0061 EB47 0062 EB47 0063 EB47 UPATN ;update attenuation 0064 EB47 9D 04 08 STAAX ATTN 0065 EB4A ; 0066 EB4A ; shut up mode ? 0067 EB4A ; 0068 EB4A AC 62 02 LDY SHUTUP 0069 EB4D F0 02 BEQ NOISY ;[sound allowed] 0070 EB4F ; sound suppressed 0071 EB4F A9 C0 LDAIM &C0 ;force minimum attenuation 0072 EB51 NOISY 0073 EB51 ; 0074 EB51 [ MOS125 = &FF 0083 EB51 | 0084 EB51 ; in: x ~b3 b2 b1 b0 x x x 0085 EB51 ;out: c2 c1 c0 1 ~b3 ~b2 ~b1 ~b0 0086 EB51 4A LSRA 0087 EB52 4A LSRA 0088 EB53 4A LSRA 0089 EB54 1D 76 EB ORAAX CHAN 0090 EB57 29 EF ANDIM &EF 0091 EB59 49 17 EORIM &17 0092 EB5B ] 0093 EB5B ;fall into the send routine 0094 EB5B SNDOUT 0095 EB5B SEND 0096 EB5B 08 PHP 0097 EB5C SENDX ;entered by code which has already done a PHP 0098 EB5C 78 SEI 0099 EB5D A0 FF LDYIM &FF 0100 EB5F 8C 43 FE STY &FE43 0101 EB62 8D 4F FE STA &FE4F 0102 EB65 C8 INY 0103 EB66 8C 40 FE STY &FE40 0104 EB69 A0 02 LDYIM &02 0105 EB6B SWAIT 0106 EB6B 88 DEY 0107 EB6C D0 FD BNE SWAIT 0108 EB6E A0 08 LDYIM &08 0109 EB70 8C 40 FE STY &FE40 0110 EB73 A0 04 LDYIM &04 0111 EB75 SWAT2 0112 EB75 88 DEY 0113 EB76 D0 FD BNE SWAT2 0114 EB78 28 PLP 0115 EB79 60 RTS 0116 EB7A RCHAN 0117 EB7A EB76 CHAN * RCHAN -&04 0118 EB7A E0 = &E0 0119 EB7B C0 = &C0 0120 EB7C A0 = &A0 0121 EB7D 80 = &80 0122 EB7E 0123 EB7E 0124 EB7E HENDS 0125 EB7E 4C 7F EC JMP ENDSW ;finished all envelope processing 0126 EB81 0127 EB81 SNDIRQ 0128 EB81 A9 00 LDAIM ZERO 0129 EB83 8D 3B 08 STA WATGO 0130 EB86 AD 38 08 LDA NOWAT 0131 EB89 D0 06 BNE MAN2 0132 EB8B EE 3B 08 INC WATGO 0133 EB8E CE 38 08 DEC NOWAT Acorn macro assembler Page 109 MOS52 Sound generator 0134 EB91 MAN2 0135 EB91 A2 08 LDXIM &08 ;X always contains current channel 0136 EB93 MNLOP 0137 EB93 CA DEX ;first real channel is 3 0138 EB94 BD 00 08 LDAAX ACTIV ;check if channel X is doing anything 0139 EB97 F0 E5 BEQ HENDS ;[channel not active so take quick route] 0140 EB99 BD CF 02 LDAAX FLUSH 0141 EB9C 30 05 BMI MAN8 ;[must abort current note] 0142 EB9E BD 18 08 LDAAX DUR 0143 EBA1 D0 03 BNE MAN10 ;[note finished] 0144 EBA3 MAN8 0145 EBA3 20 91 EC JSR NXTNT ;[get new note from queue if it exists] 0146 EBA6 MAN10 0147 EBA6 BD 18 08 LDAAX DUR 0148 EBA9 F0 13 BEQ MAN13 ;next note now 0149 EBAB C9 FF CMPIM &FF 0150 EBAD F0 12 BEQ MAN12 0151 EBAF DE 1C 08 DECAX DRDIV 0152 EBB2 D0 0D BNE MAN12 ;[not 1/20th sec tick] 0153 EBB4 A9 05 LDAIM &05 0154 EBB6 9D 1C 08 STAAX DRDIV ; set counter to wait for further 1/20th sec 0155 EBB9 DE 18 08 DECAX DUR 0156 EBBC D0 03 BNE MAN12 0157 EBBE MAN13 0158 EBBE 20 91 EC JSR NXTNT ;try to get a new note 0159 EBC1 MAN12 0160 EBC1 BD 24 08 LDAAX SCONT 0161 EBC4 F0 05 BEQ MAN11 0162 EBC6 DE 24 08 DECAX SCONT ;dec envelope scaling counter 0163 EBC9 D0 B3 BNE HENDS ;[not time for new envelope tick] 0164 EBCB MAN11 0165 EBCB BC 20 08 LDYAX ENVLP ;get envelope offset into Y 0166 EBCE [ MOS125 = &FF 0170 EBCE | 0171 EBCE C8 INY 0172 EBCF F0 AD BEQ HENDS 0173 EBD1 B9 BF 08 LDAAY ENV-&01 ;get first envelope parameter 0174 EBD4 ] 0175 EBD4 29 7F ANDIM &7F ;mask off sweep repeat bit 0176 EBD6 9D 24 08 STAAX SCONT ;set up scaling counter again 0177 EBD9 BD 08 08 LDAAX EPERD ;envelope period 0178 EBDC C9 04 CMPIM &04 ;check for 'finished' period 0179 EBDE F0 52 BEQ ENDEV ;[no longer in middle of envelope] 0180 EBE0 ; 0181 EBE0 [ MOS125 = &FF 0183 EBE0 ] 0184 EBE0 18 CLC 0185 EBE1 7D 20 08 ADCAX ENVLP ;get offset to current amplitude envelope parameters 0186 EBE4 A8 TAY ;ENV+7,Y now point to attninc rate and sENV+11 to attnlevel 0187 EBE5 B9 CB 08 LDAAY ENV+&0B ;atenuation level 0188 EBE8 38 SEC 0189 EBE9 E9 3F SBCIM &3F 0190 EBEB 8D 3A 08 STA PEAK ;temp data for following calculations 0191 EBEE B9 C7 08 LDAAY ENV+&7 ;amount by which attenuation is changed each tick 0192 EBF1 8D 39 08 STA ATINC ;temp data for calculations 0193 EBF4 BD 04 08 LDAAX ATTN 0194 EBF7 48 PHA 0195 EBF8 18 CLC 0196 EBF9 6D 39 08 ADC ATINC ;add incremnet to attenuation 0197 EBFC 50 04 BVC OK8 ;first check for 8 bit overflow 0198 EBFE [ MOS125 = &FF 0216 EBFE | 0217 EBFE ;else overflow. carry=~b7. generate &C0 if b7=0 or &3F if b7=1 0218 EBFE 09 7F ORAIM &7F ;n111 1111 C=~n 0219 EC00 69 40 ADCIM &40 ;~~nn nnnn C=n 0220 EC02 OK8 0221 EC02 C9 C0 CMPIM &C0 ;compare b7 and b6 (thanks again Woz) 0222 EC04 10 06 BPL ATOK ;if b7=b6 then value in range 0223 EC06 ;else overflow. generate &3F if b7=0 or &C0 if b7=1 0224 EC06 09 7F ORAIM &7F ;n111 1111 C=0 0225 EC08 69 40 ADCIM &40 ;~011 1111 C=n 0226 EC0A 69 80 ADCIM &80 ;nn~~ ~~~~ C=~n 0227 EC0C ATOK 0228 EC0C 9D 04 08 STAAX ATTN ;store as new attenuation 0229 EC0F CE 39 08 DEC ATINC 0230 EC12 ;the following code checks that (ATTN-PEAK)*SIGN(increment)>=0 0231 EC12 ] 0232 EC12 38 SEC 0233 EC13 ED 3A 08 SBC PEAK 0234 EC16 4D 39 08 EOR ATINC 0235 EC19 30 09 BMI SMPER ;[attenuation has not reached limit yet] 0236 EC1B AD 3A 08 LDA PEAK ;attn was too large therefore set to peak 0237 EC1E 9D 04 08 STAAX ATTN 0238 EC21 FE 08 08 INCAX EPERD ;next envelope period 0239 EC24 SMPER ;same envelope period 0240 EC24 68 PLA 0241 EC25 5D 04 08 EORAX ATTN 0242 EC28 29 F8 ANDIM &F8 0243 EC2A F0 06 BEQ NNEWA ;no new chip attenuation output (hasn't changed)] 0244 EC2C BD 04 08 LDAAX ATTN 0245 EC2F 20 47 EB JSR UPATN ;update chip attenuation 0246 EC32 NNEWA 0247 EC32 ENDEV 0248 EC32 ;frequency sweeping part of envelope 0249 EC32 BD 10 08 LDAAX NPERD 0250 EC35 C9 03 CMPIM &03 0251 EC37 F0 46 BEQ ENDSW 0252 EC39 [ MOS125 = &FF 0258 EC39 | 0259 EC39 BC 14 08 LDYAX NCONT ;number of ticks left in this frequency period 0260 EC3C D0 25 BNE GTPRD 0261 EC3E FE 10 08 INCAX NPERD ;next period 0262 EC41 C9 02 CMPIM &03-&01 ;check for period=3 =>end of all periods 0263 EC43 38 SEC ;A=next period - 1, increment it before forming pointer 0264 EC44 ] 0265 EC44 D0 11 BNE NTLF ;[not last period] 0266 EC46 BC 20 08 LDYAX ENVLP ;the following checks for bit 8 set in the first envelope byte=> no sweep repeat 0267 EC49 B9 C0 08 LDAAY ENV 0268 EC4C 30 31 BMI ENDSW ;[not a repeating sweep therefore jump to end] 0269 EC4E A9 00 LDAIM ZERO 0270 EC50 9D 30 08 STAAX NTADD ;reset amount added to note to zero for next sweep 0271 EC53 9D 10 08 STAAX NPERD ;first sweep period 0272 EC56 [ MOS125 = &FF 0276 EC56 | 0277 EC56 18 CLC ;A=next period, do not adjust 0278 EC57 NTLF 0279 EC57 ;the following points Y to the sweep parameters of the current envelope/period 0280 EC57 ] 0281 EC57 7D 20 08 ADCAX ENVLP 0282 EC5A A8 TAY 0283 EC5B B9 C4 08 LDAAY ENV+&04 Acorn macro assembler Page 110 MOS52 Sound generator 0284 EC5E 9D 14 08 STAAX NCONT ;number of cycles for this frequency period 0285 EC61 F0 1C BEQ ENDSW ;zero frequency period 0286 EC63 GTPRD 0287 EC63 DE 14 08 DECAX NCONT 0288 EC66 BD 20 08 LDAAX ENVLP 0289 EC69 18 CLC 0290 EC6A 7D 10 08 ADCAX NPERD 0291 EC6D A8 TAY 0292 EC6E B9 C1 08 LDAAY ENV+&01 ;note increment for this frequency period 0293 EC71 18 CLC 0294 EC72 7D 30 08 ADCAX NTADD 0295 EC75 9D 30 08 STAAX NTADD ;add increment to the note offset 0296 EC78 18 CLC 0297 EC79 7D 0C 08 ADCAX SNOTE 0298 EC7C 20 23 ED JSR CNVRT ;convert note to period and output 0299 EC7F ENDSW 0300 EC7F E0 04 CPXIM &04 ;'test channel number for zero' 0301 EC81 F0 0D BEQ EDUP ;[channel was zero therefore leave loop] 0302 EC83 4C 93 EB JMP MNLOP 0303 EC86 0304 EC86 0305 EC86 SNDRST 0306 EC86 A2 08 LDXIM &08 0307 EC88 ; 0308 EC88 RLOP 0309 EC88 CA DEX 0310 EC89 20 C5 EC JSR SCRST ;reset sound channel X 0311 EC8C E0 04 CPXIM &04 0312 EC8E D0 F8 BNE RLOP 0313 EC90 ; 0314 EC90 EDUP ;end of 1/100th sec processing 0315 EC90 60 RTS 0316 EC91 0317 EC91 0318 EC91 NXTNT 0319 EC91 BD 08 08 LDAAX EPERD ;get current amplitude period 0320 EC94 C9 04 CMPIM &04 ;period 4 => note has fully released 0321 EC96 F0 05 BEQ ELDDN 0322 EC98 A9 03 LDAIM &03 0323 EC9A 9D 08 08 STAAX EPERD ;put note in the release phase of the envelope 0324 EC9D ELDDN 0325 EC9D BD CF 02 LDAAX FLUSH 0326 ECA0 F0 13 BEQ NOFL ;[no flush has been flagged] 0327 ECA2 A9 00 LDAIM ZERO 0328 ECA4 9D CF 02 STAAX FLUSH ;clear the flush flag 0329 ECA7 [ MOS125 = &FF 0344 ECA7 | 0345 ECA7 A0 03 LDYIM &03 ;the following clears all wait variables 0346 ECA9 SWTLOP 0347 ECA9 99 2C 08 STAAY WAIT +&04 0348 ECAC 88 DEY 0349 ECAD 10 FA BPL SWTLOP 0350 ECAF 9D 18 08 STAAX DUR ;set duration to zero => note finished 0351 ECB2 8C 38 08 STY NOWAT ;reset chord building status 0352 ECB5 NOFL ;A=0 0353 ECB5 DD 28 08 CMPAX WAIT ;check it channel waiting for chord 0354 ECB8 F0 43 BEQ NOTWT 0355 ECBA CD 3B 08 CMP WATGO ;check if chord now ready to play 0356 ECBD F0 34 BEQ NOTGO ;[chord not ready yet] else C=0 0357 ECBF ] 0358 ECBF 9D 28 08 STAAX WAIT ;clear waiting for chord status 0359 ECC2 NNWAT 0360 ECC2 4C B6 ED JMP STRNT ;start playing note 0361 ECC5 SCRST ;reset sound channel X 0362 ECC5 20 40 EB JSR MINATN 0363 ECC8 98 TYA 0364 ECC9 9D 18 08 STAAX DUR 0365 ECCC 9D CF 02 STAAX FLUSH 0366 ECCF 9D 00 08 STAAX ACTIV 0367 ECD2 ; 0368 ECD2 ;clear wait periods to zero 0369 ECD2 ; 0370 ECD2 A0 03 LDYIM &03 0371 ECD4 CWP 0372 ECD4 99 2C 08 STAAY WAIT+&04 0373 ECD7 88 DEY 0374 ECD8 10 FA BPL CWP ;[more wait periods to clear] 0375 ECDA ; Y=$FF 0376 ECDA ; MI true 0377 ECDA ; 0378 ECDA ; indicate no channels waiting 0379 ECDA ; 0380 ECDA 8C 38 08 STY NOWAT 0381 ECDD ; 0382 ECDD 30 49 BMI FCNVRT ;[ALWAYS JUMP, set period of chip to zero] 0383 ECDF 0384 ECDF 0385 ECDF NGONG 0386 ECDF 08 PHP 0387 ECE0 78 SEI 0388 ECE1 BD 08 08 LDAAX EPERD ;while irq disabled check if active can be cleared 0389 ECE4 C9 04 CMPIM &04 ;if envelope period=4 then note finished 0390 ECE6 D0 0A BNE NOGO2 ;[note not yet released] 0391 ECE8 20 9F E4 JSR EXAM ;check for recent arrival of note 0392 ECEB 90 05 BCC NOGO2 ;queue no longer empty 0393 ECED A9 00 LDAIM ZERO 0394 ECEF 9D 00 08 STAAX ACTIV ;set channel as inactive 0395 ECF2 NOGO2 0396 ECF2 28 PLP 0397 ECF3 NOTGO 0398 ECF3 BC 20 08 LDYAX ENVLP 0399 ECF6 [ MOS125 = &FF 0401 ECF6 | 0402 ECF6 C8 INY 0403 ECF7 ] 0404 ECF7 D0 03 BNE PROG 0405 ECF9 20 40 EB JSR MINATN ;update attenuation of box envelopes 0406 ECFC PROG 0407 ECFC PRTS ;rts pointer 0408 ECFC 60 RTS 0409 ECFD 0410 ECFD 0411 ECFD NOTWT 0412 ECFD 20 9F E4 JSR EXAM ;examine byte at head of queue 0413 ED00 B0 DD BCS NGONG ;[queue empty] 0414 ED02 29 03 ANDIM &03 0415 ED04 F0 BC BEQ NNWAT ;[no chord commands for next note] 0416 ED06 AD 38 08 LDA NOWAT 0417 ED09 F0 15 BEQ SRTS ;[full chord already accepted,ignore this channel for now] 0418 ED0B FE 28 08 INCAX WAIT ;set waiting flag 0419 ED0E 2C 38 08 BIT NOWAT ;check for chord being built Acorn macro assembler Page 111 MOS52 Sound generator 0420 ED11 10 0A BPL SMCRD ;chord already being built 0421 ED13 20 9F E4 JSR EXAM ;getheader byte again 0422 ED16 29 03 ANDIM &03 ;select chord bits 0423 ED18 8D 38 08 STA NOWAT ;new chord so set number of other channels required 0424 ED1B 10 03 BPL LNOTGO 0425 ED1D SMCRD 0426 ED1D CE 38 08 DEC NOWAT ;decrement the number of channels still required for chord 0427 ED20 SRTS ;must point to RTS command 0428 ED20 LNOTGO 0429 ED20 4C F3 EC JMP NOTGO 0430 ED23 0431 ED23 0432 ED23 ;routine to convert note to period 0433 ED23 ;and output to the chip 0434 ED23 CNVRT 0435 ED23 DD 2C 08 CMPAX OLDNTE 0436 ED26 F0 D4 BEQ PRTS ;no need to update chip 0437 ED28 FCNVRT ;force note output 0438 ED28 9D 2C 08 STAAX OLDNTE 0439 ED2B E0 04 CPXIM &04 ;check if noise channel 0440 ED2D D0 08 BNE TONE 0441 ED2F 29 0F ANDIM &0F ;noise input is only 4 bits 0442 ED31 1D 76 EB ORAAX CHAN ;add channel information 0443 ED34 08 PHP ;push P (will immediately be pulled) 0444 ED35 [ MOS125 = &FF 0446 ED35 | 0447 ED35 B0 7C BCS CDONE ;output and return 0448 ED37 ] 0449 ED37 TONE ;tone channel 0450 ED37 48 PHA 0451 ED38 29 03 ANDIM &03 0452 ED3A 8D 3C 08 STA FRACT ;low 2 bits give fraction of semitone 0453 ED3D [ MOS125 = &FF 0465 ED3D | 0466 ED3D 68 PLA 0467 ED3E 4A LSRA 0468 ED3F 4A LSRA 0469 ED40 8D 3D 08 STA PRDL 0470 ED43 OCTL 0471 ED43 C9 0C CMPIM &0C ;check if note > one octave 0472 ED45 90 07 BCC ENDOL 0473 ED47 E9 0C SBCIM &0C 0474 ED49 6E 3D 08 ROR PRDL ;use PRDL as octave counter for division 0475 ED4C 30 F5 BMI OCTL ;branch always taken 0476 ED4E ] 0477 ED4E ENDOL 0478 ED4E A8 TAY 0479 ED4F AD 3D 08 LDA PRDL ;number octaves up 0480 ED52 48 PHA 0481 ED53 B9 14 EE LDAAY NTABL ;low period from table 0482 ED56 8D 3D 08 STA PRDL 0483 ED59 B9 20 EE LDAAY NTABH ;high period for lowest octave 0484 ED5C 48 PHA 0485 ED5D 29 03 ANDIM &03 0486 ED5F 8D 3E 08 STA PRDH 0487 ED62 68 PLA ;get semitone difference from top bits of NTABH 0488 ED63 4A LSRA 0489 ED64 4A LSRA 0490 ED65 4A LSRA 0491 ED66 4A LSRA 0492 ED67 8D 3F 08 STA NOTDIF 0493 ED6A AD 3D 08 LDA PRDL 0494 ED6D AC 3C 08 LDY FRACT ;number of times NOTDIF has to be added 0495 ED70 F0 0C BEQ INTRPE ;[true semitone] 0496 ED72 INTRPL 0497 ED72 ;following subtracts NOTDIF from period 0498 ED72 38 SEC 0499 ED73 ED 3F 08 SBC NOTDIF 0500 ED76 B0 03 BCS INTRPO 0501 ED78 CE 3E 08 DEC PRDH 0502 ED7B INTRPO 0503 ED7B 88 DEY 0504 ED7C D0 F4 BNE INTRPL ;[add another fraction] 0505 ED7E INTRPE 0506 ED7E 8D 3D 08 STA PRDL 0507 ED81 68 PLA 0508 ED82 [ MOS125 = &FF 0516 ED82 | 0517 ED82 10 09 BPL ODONE ;if lowest octave then no shifts 0518 ED84 SSHIFT 0519 ED84 4E 3E 08 LSR PRDH ;divide period by 2 0520 ED87 6E 3D 08 ROR PRDL 0521 ED8A 0A ASLA 0522 ED8B 30 F7 BMI SSHIFT ;[up another octave] 0523 ED8D ] 0524 ED8D ODONE 0525 ED8D AD 3D 08 LDA PRDL ;extract low four bits of period 0526 ED90 18 CLC 0527 ED91 7D 3D C4 ADCAX SCHOFF 0528 ED94 8D 3D 08 STA PRDL 0529 ED97 90 03 BCC NOFOV 0530 ED99 EE 3E 08 INC PRDH 0531 ED9C NOFOV 0532 ED9C 29 0F ANDIM &0F 0533 ED9E 1D 76 EB ORAAX CHAN ;add channel address 0534 EDA1 08 PHP 0535 EDA2 78 SEI ;make sure another request does not mess up sequence 0536 EDA3 20 5B EB JSR SEND ;output to chip 0537 EDA6 AD 3D 08 LDA PRDL ;get next 6 bits of period 0538 EDA9 4E 3E 08 LSR PRDH 0539 EDAC 6A RORA 0540 EDAD 4E 3E 08 LSR PRDH 0541 EDB0 6A RORA 0542 EDB1 4A LSRA ;transfer to low 6 bits of Acc 0543 EDB2 4A LSRA 0544 EDB3 CDONE 0545 EDB3 4C 5C EB JMP SENDX ;output period to chip 0546 EDB6 ;routine to start note at head of queue 0547 EDB6 STRNT 0548 EDB6 08 PHP ;start indivisible section to stop new 0549 EDB7 78 SEI ;note being added to queue half way through extraction 0550 EDB8 20 A4 E4 JSR REMOV ;get byte at head queue 0551 EDBB [ MOS125 = &FF 0558 EDBB | 0559 EDBB A8 TAY ;save byte at head queue 0560 EDBC 29 04 ANDIM &04 ;extract 'continue' bit 0561 EDBE F0 12 BEQ NOCONT ;[not continue] 0562 EDC0 BC 20 08 LDYAX ENVLP ;must check for continue to auto envelope 0563 EDC3 C8 INY 0564 EDC4 ] 0565 EDC4 D0 03 BNE SCON1 Acorn macro assembler Page 112 MOS52 Sound generator 0566 EDC6 20 40 EB JSR MINATN ;update attenuation 0567 EDC9 SCON1 0568 EDC9 20 A4 E4 JSR REMOV ;throw away note 0569 EDCC 20 A4 E4 JSR REMOV ;get duration 0570 EDCF 28 PLP ;end of indivisible section 0571 EDD0 [ MOS125 = &FF 0575 EDD0 | 0576 EDD0 90 3E BCC DODUR ;C=0 from NNWAT->STRNT; always branch to update duration 0577 EDD2 NOCONT 0578 EDD2 98 TYA ;restore header byte 0579 EDD3 ] 0580 EDD3 29 F8 ANDIM &F8 ;extract 5 envelope bits 0581 EDD5 0A ASLA ;programmable envelope select bit >carry 0582 EDD6 90 0A BCC PENV ;[programmed envelope] 0583 EDD8 [ MOS125 = &FF 0588 EDD8 | 0589 EDD8 ; in: ~b3 ~b2 ~b1 ~b0 0 0 0 x 0590 EDD8 ;out: ~b3 ~b3 b2 b1 b0 1 1 1 0591 EDD8 C9 80 CMPIM &80 ;convert box envelope to signed amplitude 0592 EDDA 6A RORA 0593 EDDB 49 3F EORIM &3F 0594 EDDD ] 0595 EDDD 20 47 EB JSR UPATN 0596 EDE0 A9 FF LDAIM &FF ;flag box envelope by setting top bit of ENVLP 0597 EDE2 PENV 0598 EDE2 9D 20 08 STAAX ENVLP ;envelope pointer,envelope*16 0599 EDE5 A9 05 LDAIM &05 ;start timing first 1/20th second from now 0600 EDE7 9D 1C 08 STAAX DRDIV 0601 EDEA A9 01 LDAIM &01 0602 EDEC 9D 24 08 STAAX SCONT ;first envelope update next tick 0603 EDEF [ MOS125 = &FF 0605 EDEF | 0606 EDEF 4A LSRA 0607 EDF0 ] 0608 EDF0 9D 14 08 STAAX NCONT 0609 EDF3 9D 08 08 STAAX EPERD ;first amplittude envelope 0610 EDF6 9D 30 08 STAAX NTADD ;note add envelope starts at 0 0611 EDF9 A9 FF LDAIM &FF 0612 EDFB 9D 10 08 STAAX NPERD ;set frequency envelope to -1,incremented on first tick 0613 EDFE 20 A4 E4 JSR REMOV ;extract note byte from queue 0614 EE01 9D 0C 08 STAAX SNOTE ;store note 0615 EE04 20 A4 E4 JSR REMOV ;Remove duration 0616 EE07 28 PLP ;end of indivisible section 0617 EE08 48 PHA ;remember duration 0618 EE09 BD 0C 08 LDAAX SNOTE 0619 EE0C 20 23 ED JSR CNVRT ;convert to period and output 0620 EE0F 68 PLA ;get duration back 0621 EE10 DODUR 0622 EE10 9D 18 08 STAAX DUR ;set up duration 0623 EE13 60 RTS 0624 EE14 [ MOS125 = &FF 0625 EE14 | 0626 EE14 ;NB swapping JSR CNVRT and STAAX DUR (to save PHA/PLA) 0627 EE14 ;would cause an interrupt occurring during CNVRT to decrement 0628 EE14 ;the new count instead of the old. Preserving current order. 0629 EE14 ] 0630 EE14 0631 EE14 0632 EE14 NTABL ;lookup table for low 8 bit of period 0633 EE14 F0 = &F0 0634 EE15 B7 = &B7 0635 EE16 82 = &82 0636 EE17 4F = &4F 0637 EE18 20 = &20 0638 EE19 F3 = &F3 0639 EE1A C8 = &C8 0640 EE1B A0 = &A0 0641 EE1C 7B = &7B 0642 EE1D 57 = &57 0643 EE1E 35 = &35 0644 EE1F 16 = &16 0645 EE20 NTABH ;lookup table for high 2 bits of period 0646 EE20 E7 = &E7 ;and 6 bits of note difference being the difference 0647 EE21 D7 = &D7 ;between this and the next note 0648 EE22 CB = &CB 0649 EE23 C3 = &C3 0650 EE24 B7 = &B7 0651 EE25 AA = &AA 0652 EE26 A2 = &A2 0653 EE27 9A = &9A 0654 EE28 92 = &92 0655 EE29 8A = &8A 0656 EE2A 82 = &82 0657 EE2B 7A = &7A 0658 EE2C 0659 EE2C 0660 EE2C LNK MOS54 0001 EE2C ; MOS54 0002 EE2C TTL MOS54 SPEECH DRIVING 0003 EE2C OPT MOS54 Acorn macro assembler Page 113 MOS54 SPEECH DRIVING 0004 EE2C ;(c) 1981 ACORN Computers Limited 0005 EE2C ;BBC Microcomputer Machine Operating System (MOS) 0006 EE2C ;Change record: 0007 EE2C ;004 07-Nov-81 PBM Prototype version 0008 EE2C ;Author(s): 0009 EE2C ;Paul Bond 0010 EE2C 0011 EE2C 0012 EE2C SRINIT ;initialise SEROM environment for CFS 0013 EE2C [ NOSP = &00 0016 EE2C | 0017 EE2C A9 EF LDAIM &F0-&01 ;$01 adjusts for future INC SEROM 0018 EE2E ] 0019 EE2E ; SEROM will cycle $F0 ... $FF ... $00 ... $10 (max) 0020 EE2E 85 F5 STA SEROM 0021 EE30 [ MOS125 = &FF 0023 EE30 ] 0024 EE30 0025 EE30 0026 EE30 SRNEXT ;move on to next SEROM 0027 EE30 ; 0028 EE30 ; scans phrase ROM first, then paged ROM 0029 EE30 ; 0030 EE30 SPCPYF ;entry point from failed copyright message test 0031 EE30 A2 0D LDXIM SVISFS 0032 EE32 E6 F5 INC SEROM 0033 EE34 A4 F5 LDY SEROM 0034 EE36 [ NOSP = &00 0039 EE36 | 0040 EE36 [ MOS125 = &7F 0041 EE36 30 05 BMI SPPH ;[process PHROM, V not altered] 0042 EE38 C0 10 CPYIM NROM ;if we get here with SEROM >= NROM, 0043 EE3A 90 39 BCC SPSV ;then no paged ROM is to respond 0044 EE3C 60 RTS ;so exit C=1, call unclaimed 0045 EE3D SPPH 0046 EE3D | 0048 EE3D ] 0049 EE3D ; 0050 EE3D ; process PHROM, V not altered 0051 EE3D ; 0052 EE3D ; no need to check for speech chip present 0053 EE3D ; reads from chip will not indicate copyright message 0054 EE3D ; 0055 EE3D ; check for existence of speech SEROM 0056 EE3D ; 0057 EE3D ; set pointer to 1 0058 EE3D ; 0059 EE3D A2 00 LDXIM ZERO 0060 EE3F 86 F7 STX ROMPTR+&01 0061 EE41 E8 INX ;X := 1 0062 EE42 86 F6 STX ROMPTR+&00 0063 EE44 20 D7 EE JSR SPLOAD ;set address 0064 EE47 ; 0065 EE47 ; check for copyright (C) 0066 EE47 ; 0067 EE47 A2 03 LDXIM &03 0068 EE49 SPCPY ;V not altered 0069 EE49 20 7E EE JSR RDBYTE ;does not alter X 0070 EE4C DD 29 F5 CMPAX COPYR 0071 EE4F D0 DF BNE SPCPYF ;[failed test for copyright message] 0072 EE51 ; C=1 0073 EE51 CA DEX 0074 EE52 10 F5 BPL SPCPY 0075 EE54 ; 0076 EE54 ; C=1 0077 EE54 ; 0078 EE54 ; copyright message is present 0079 EE54 ; 0080 EE54 ; we have read 5 bytes so far 0081 EE54 ; skip more bytes allowing for copyright/title strings 0082 EE54 ; 0083 EE54 ; position serial ROM to cassette image data 0084 EE54 ; (indirect pointer held at offset $3E) 0085 EE54 ; 0086 EE54 A9 3E LDAIM &3E 0087 EE56 85 F6 STA ROMPTR+&00 0088 EE58 ; 0089 EE58 ; C=1 0090 EE58 ; 0091 EE58 SPLIND ;load address indirect, V not altered, returns C=0 0092 EE58 20 D7 EE JSR SPLOAD 0093 EE5B [ TRUE=0 0094 EE5B ; perform soft version of read-and-branch 0095 EE5B ; 0096 EE5B A2 FF LDXIM &FF 0097 EE5D RABLP 0098 EE5D ; read lo byte when X=0, hi byte when X=1 0099 EE5D 20 7E EE JSR RDBYTE ;does not corrupt X 0100 EE60 ; 0101 EE60 [ MOS125 = &FF 0108 EE60 | 0109 EE60 38 SEC ;C undefined if entered at SPLIND 0110 EE61 2A ROLA 0111 EE62 RABLO ;reverse bits in A into ROMPTR+(0/1) 0112 EE62 76 F7 RORAX ROMPTR+&01 0113 EE64 0A ASLA 0114 EE65 D0 FB BNE RABLO ;[process 8 bits] 0115 EE67 ; C=1, Y clobbered in SPLOAD->SPL->SPL1 0116 EE67 ] 0117 EE67 ; 0118 EE67 E8 INX 0119 EE68 F0 F3 BEQ RABLP ;repeat loop once more with X=0 0120 EE6A ; 0121 EE6A 18 CLC ;indicate next successful 0122 EE6B 90 6A BCC SPLOAD ;[ALWAYS jump, set indirected address AND return] 0123 EE6D | 0136 EE6D ] 0137 EE6D ] 0138 EE6D 0139 EE6D 0140 EE6D RDSPCH ;read byte from SEROM 0141 EE6D A2 0E LDXIM SVRSFS 0142 EE6F [ NOSP = &00 0144 EE6F | 0145 EE6F A4 F5 LDY SEROM 0146 EE71 30 0B BMI RDBYTE ;[reading from PHROM, V not altered] 0147 EE73 ] 0148 EE73 ; 0149 EE73 ; reading from paged ROM 0150 EE73 ; 0151 EE73 A0 FF LDYIM 0-MCVER ;enter paged ROM with M/C indicator in Y Acorn macro assembler Page 114 MOS54 SPEECH DRIVING 0152 EE75 ; 0153 EE75 SPSV ;used by read byte routine, V not altered 0154 EE75 08 PHP 0155 EE76 20 74 F1 JSR SVOP ;search for paged SEROM (N.B. SVOPSP) 0156 EE79 ; 0157 EE79 28 PLP ;restore V-flag 0158 EE7A C9 01 CMPIM &01 ;claimed => C=0, not claimed => C=1 0159 EE7C 98 TYA ;A := read character (useful for read byte routine only) 0160 EE7D 60 RTS 0161 EE7E 0162 EE7E 0163 EE7E [ NOSP = &00 0166 EE7E | 0167 EE7E RDBYTE ;read byte from speech ROM, V not altered 0168 EE7E 08 PHP 0169 EE7F 78 SEI 0170 EE80 A0 10 LDYIM SPOPRB ;set to read byte 0171 EE82 20 9B EE JSR WSPECH 0172 EE85 ; read byte (following code shorter than JSR RSPECH; PLP; RTS) 0173 EE85 A0 00 LDYIM ZERO 0174 EE87 F0 17 BEQ SENDSX ;[ALWAYS JUMP, N.B. does PLP & RTS, SEI already active] 0175 EE89 0176 EE89 0177 EE89 RSPECH ;read from speech processor, must not corrupt X 0178 EE89 A0 00 LDYIM ZERO 0179 EE8B F0 11 BEQ SENDSP ;[ALWAYS jump] 0180 EE8D ; 0181 EE8D ; 0182 EE8D SPL ;send load address nibbles 0183 EE8D ; A = hl 0184 EE8D ; h is hi-nibble 0185 EE8D ; l is lo-nibble 0186 EE8D 48 PHA 0187 EE8E 20 96 EE JSR SPL1 ;send lo-nibble 0188 EE91 68 PLA 0189 EE92 6A RORA 0190 EE93 6A RORA 0191 EE94 6A RORA 0192 EE95 6A RORA 0193 EE96 ; 0194 EE96 ; send hi-nibble 0195 EE96 ; 0196 EE96 SPL1 0197 EE96 29 0F ANDIM &0F ;isolate lo-nibble 0198 EE98 09 40 ORAIM SPOPLA 0199 EE9A ; 0200 EE9A A8 TAY ;Y := command 0201 EE9B ; 0202 EE9B WSPECH ;write to speech processor, must not corrupt X 0203 EE9B 98 TYA ;A := command 0204 EE9C A0 01 LDYIM &01 0205 EE9E ; 0206 EE9E SENDSP ;read/write from/to speech processor 0207 EE9E ; Y=0 => read 0208 EE9E ; Y=1 => write 0209 EE9E 08 PHP 0210 EE9F 78 SEI 0211 EEA0 SENDSX ;entry used by routines which have done a PHP & SEI 0212 EEA0 2C 7B 02 BIT SPFLAG 0213 EEA3 10 21 BPL SNDSX0 ;[speech chip not present] 0214 EEA5 ; 0215 EEA5 48 PHA ;save command 0216 EEA6 ; 0217 EEA6 ; select PA7-0 as inputs/outputs 0218 EEA6 ; 0219 EEA6 B9 84 F0 LDAAY SENDD 0220 EEA9 8D 43 FE STA DDRAQ 0221 EEAC ; 0222 EEAC ; place command onto data bus 0223 EEAC ; 0224 EEAC 68 PLA ;restore command 0225 EEAD 8D 4F FE STA PAPQ 0226 EEB0 ; 0227 EEB0 ; speech enable 0228 EEB0 ; 0229 EEB0 B9 86 F0 LDAAY SENDS 0230 EEB3 8D 40 FE STA PBQ 0231 EEB6 ; 0232 EEB6 ; wait for speech ready 0233 EEB6 ; 0234 EEB6 SPWAIT 0235 EEB6 2C 40 FE BIT PBQ 0236 EEB9 30 FB BMI SPWAIT ;[not ready] 0237 EEBB ; 0238 EEBB ; read possible speech data 0239 EEBB ; 0240 EEBB AD 4F FE LDA PAPQ 0241 EEBE 48 PHA 0242 EEBF ; 0243 EEBF ; speech disable 0244 EEBF ; 0245 EEBF B9 88 F0 LDAAY SENDF 0246 EEC2 8D 40 FE STA PBQ 0247 EEC5 ; 0248 EEC5 ; return 0249 EEC5 ; 0250 EEC5 68 PLA ;restore speech data (not relevant if write) 0251 EEC6 ; 0252 EEC6 SNDSX0 0253 EEC6 28 PLP 0254 EEC7 A8 TAY ;set processor status flags (useful for RSPECH) and Y (for FX calls) 0255 EEC8 60 RTS 0256 EEC9 ] 0257 EEC9 0258 EEC9 0259 EEC9 SRSKIP ;skip to SEROM pointer indicated by SRPTR 0260 EEC9 AD CB 03 LDA SRPTR+&00 0261 EECC 85 F6 STA ROMPTR+&00 0262 EECE AD CC 03 LDA SRPTR+&01 0263 EED1 85 F7 STA ROMPTR+&01 0264 EED3 [ NOSP = &00 0265 EED3 | 0266 EED3 A5 F5 LDA SEROM 0267 EED5 10 1B BPL SRSK0 ;[skipping within paged ROM] 0268 EED7 ; 0269 EED7 ; skipping within speech SEROM 0270 EED7 ; load address from SEROM/ROMPTR 0271 EED7 ; 0272 EED7 SPLOAD ;load address, must not corrupt V 0273 EED7 ; address given in SEROM/ROMPTR 0274 EED7 08 PHP Acorn macro assembler Page 115 MOS54 SPEECH DRIVING 0275 EED8 78 SEI ;N.B. uses SPWK1 0276 EED9 A5 F6 LDA ROMPTR+&00 0277 EEDB 20 8D EE JSR SPL ;send address lo-byte 0278 EEDE [ MOS125 = &FF 0291 EEDE | 0292 EEDE A5 F5 LDA SEROM 0293 EEE0 4A LSRA 0294 EEE1 6A RORA 0295 EEE2 48 PHA 0296 EEE3 6A RORA 0297 EEE4 45 F7 EOR ROMPTR+&01 0298 EEE6 29 C0 ANDIM &C0 0299 EEE8 45 F7 EOR ROMPTR+&01 0300 EEEA 20 8D EE JSR SPL ;send address hi-byte 0301 EEED 68 PLA 0302 EEEE 20 96 EE JSR SPL1 ;send address hi-nibble 0303 EEF1 ] 0304 EEF1 28 PLP 0305 EEF2 SRSK0 0306 EEF2 ] 0307 EEF2 60 RTS 0308 EEF3 0309 EEF3 0310 EEF3 [ FALSE=0 0323 EEF3 ] 0324 EEF3 0325 EEF3 0326 EEF3 < &0001 0327 EEF3 0328 EEF3 0329 EEF3 LNK MOS56 0001 EEF3 0002 EEF3 ; > MOS56 0003 EEF3 TTL MOS56 Keyboard management 0004 EEF3 OPT MOS56 Acorn macro assembler Page 116 MOS56 Keyboard management 0005 EEF3 ;(c) 1981 ACORN Computers Limited 0006 EEF3 ;BBC Microcomputer Machine Operating System (MOS) 0007 EEF3 ;Change record: 0008 EEF3 ;202 01-May-82 PB Programmable TAB key 0009 EEF3 ;.05 16-Nov-81 PB Fix CTRL/SHIFT matrix h/w problem 0010 EEF3 ;100 04-Sep-81 PB Remove SHIFT and CTRL debounce 0011 EEF3 ;Author(s): 0012 EEF3 ;PB Paul Bond 0013 EEF3 ;MP Mike Prees 0014 EEF3 ; STATUS BYTE USES (KSTAT) 0015 EEF3 ; N.B. status byte is NEVER zero 0016 EEF3 ; (CAPITALS and SHIFT lock never concurrent) 0017 EEF3 ; BIT 0 not used 0018 EEF3 ; BIT 1 not used 0019 EEF3 ; BIT 2 not used 0020 EEF3 ; BIT 3 SHIFT 0021 EEF3 ; BIT 4 not CAPITALS lock 0022 EEF3 ; BIT 5 not SHIFT lock 0023 EEF3 ; BIT 6 CTRL 0024 EEF3 ; BIT 7 shift enable (only meaningful if a lock is active) 0025 EEF3 ; SEQUENCE OF EVENTS :- 0026 EEF3 ; 1. CHECK SHIFT KEY 0027 EEF3 ; 2. CHECK CONTROL KEY 0028 EEF3 ; 3. PROCESS CURRENT KEY 0029 EEF3 ; 4. PROCESS OLD KEY 0030 EEF3 ; 5. SCAN KEYS IF REQ'D 0031 EEF3 ; 6. ENABLE CA2 IF REQ'D 0032 EEF3 0033 EEF3 0034 EEF3 KBDAW 0035 EEF3 A2 FF LDXIM &FF ;prepare to enable keyboard timer interrupts 0036 EEF5 ; 0037 EEF5 ; IF ALL KEYS UP & FORGOTTEN, RESTORE INTERRUPTS 0038 EEF5 ; 0039 EEF5 A5 EC LDA CKEY 0040 EEF7 05 ED ORA OKEY 0041 EEF9 D0 06 BNE KBDISX ;[at least one active key, so keep keyboard interrupt disabled] 0042 EEFB ; 0043 EEFB ; enable keyboard interrupt 0044 EEFB ; 0045 EEFB A9 81 LDAIM &81 0046 EEFD 8D 4E FE STA IERQ 0047 EF00 E8 INX ;X:=0, disable keyboard timer interrupts 0048 EF01 ; 0049 EF01 KBDISX 0050 EF01 8E 42 02 STX KSEMA ;set keyboard timer interrupt control flag 0051 EF04 ; $00 => disabled, $FF => enabled 0052 EF04 ; 0053 EF04 KBDIS 0054 EF04 08 PHP 0055 EF05 ; disable keyboard, coping with CAPITALS & SHIFT lock LEDs 0056 EF05 AD 5A 02 LDA KSTAT 0057 EF08 ; isolate CAPITALS lock and SHIFT lock states 0058 EF08 4A LSRA 0059 EF09 29 18 ANDIM &18 0060 EF0B ; update LED1 (CAPITALS lock) 0061 EF0B 09 06 ORAIM &06 ;use addressable latch output 6 0062 EF0D 8D 40 FE STA PBQ ;store LED1 0063 EF10 ; update LED2 (SHIFT lock) 0064 EF10 4A LSRA ;move state into bit3 0065 EF11 09 07 ORAIM &07 ;use addressable latch output 7 0066 EF13 8D 40 FE STA PBQ ;store LED2 0067 EF16 ; 0068 EF16 [ TRUE=0 0069 EF16 20 3A F1 JSR KALLOX 0070 EF19 | 0073 EF19 ] 0074 EF19 ; 0075 EF19 68 PLA 0076 EF1A 60 RTS 0077 EF1B 0078 EF1B DEFKEY ;keyboard control effect 0079 EF1B ; 0080 EF1B ; entered with: 0081 EF1B ; C=0, V=0 => SHIFT/CTRL test 0082 EF1B ; C=1, V=0 => keyboard scan 0083 EF1B ; C=0, V=1 => keyboard interrupt 0084 EF1B ; C=1, V=1 => timer interrupt 0085 EF1B ; 0086 EF1B ; route keyboard entry reason 0087 EF1B ; 0088 EF1B 50 0A BVC KEYV0 ;[V=0] 0089 EF1D ; 0090 EF1D A9 01 LDAIM &01 0091 EF1F 8D 4E FE STA IERQ 0092 EF22 ; 0093 EF22 B0 08 BCS KYBD ;[timer interrupt entry] 0094 EF24 4C 1E F0 JMP KBDAT ;[keyboard interrupt] 0095 EF27 ; 0096 EF27 KEYV0 0097 EF27 90 06 BCC TSHIFT ;[SHIFT/CTRL test] 0098 EF29 4C DD F0 JMP SKFMA ;C=1, scan keyboard 0099 EF2C 0100 EF2C KYBD ;C=1 0101 EF2C ; entered when key(s) active AND timer interrupt 0102 EF2C ; 0103 EF2C ; ensure no more keyboard timer interrupts 0104 EF2C EE 42 02 INC KSEMA ;KSEMA := 0 0105 EF2F ; 0106 EF2F TSHIFT ;C=0 0107 EF2F ; entry point used by test shift routine (uses C=1) 0108 EF2F ; clear SHIFT and CTRL status 0109 EF2F AD 5A 02 LDA KSTAT 0110 EF32 29 B7 ANDIM CTLSHI ;N.B. A will accumulate new state 0111 EF34 ; set SHIFT key status 0112 EF34 A2 00 LDXIM ZERO ;N.B. SHIFT key is at matrix entry 0 0113 EF36 20 39 F0 JSR KC ;get state of SHIFT key 0114 EF39 ; N.B. C not corrupted 0115 EF39 86 FA STX KTEMP ;save state of SHIFT key for SHIFT/CAPS invert feature 0116 EF3B ; KTEMP = 1xxx xxxx => SHIFT 0117 EF3B ; KTEMP = 0xxx xxxx => no SHIFT 0118 EF3B B8 CLV 0119 EF3C 10 05 BPL KYBD1 ;[SHIFT key not active] 0120 EF3E ; shift key active and within timer interrupt routine 0121 EF3E 2C 49 D9 BIT FFBYT 0122 EF41 09 08 ORAIM SHFT 0123 EF43 KYBD1 0124 EF43 ; set CTRL key status 0125 EF43 E8 INX ;X := 1, N.B. CTRL key is at matrix entry 1 0126 EF44 20 39 F0 JSR KC ;get state of CTRL key 0127 EF47 90 BB BCC KBDIS ;[testing CTRL and SHIFT, MI=>CTRL, V=>SHIFT] Acorn macro assembler Page 117 MOS56 Keyboard management 0128 EF49 10 02 BPL KYBD2 ;[CTRL key not active] 0129 EF4B ; CTRL key active 0130 EF4B 09 40 ORAIM CTRL 0131 EF4D KYBD2 ;A has accumulated new keyboard status 0132 EF4D 8D 5A 02 STA KSTAT ;update keyboard status 0133 EF50 ; evaluate status of the current key 0134 EF50 ; IF IT IS & WAS OPEN, THEN FORGET IT 0135 EF50 ; IF OPEN & WAS CLOSED, MARK AS OPEN 0136 EF50 ; IF CLOSED & WAS OPEN, MARK AS CLOSED 0137 EF50 ; IF CLOSED & WAS CLOSED, THEN DECREMENT 0138 EF50 ; AUTO-REPEAT COUNTER. IF THIS GOES TO 0139 EF50 ; ZERO (IT STARTS AT 1 INITIALLY) THEN 0140 EF50 ; TRANSMIT CHARACTER TO RDCH BUFFER 0141 EF50 ; (UNLESS IT IS SHF LOCK OR CAPS LOCK) 0142 EF50 ; IF AUTO REPEAT PERMANENTLY DISABLED 0143 EF50 ; THEN DON'T RESET THIS COUNTER. 0144 EF50 A6 EC LDX CKEY 0145 EF52 F0 12 BEQ KBDWU ;[no current key] 0146 EF54 ; current key exists 0147 EF54 20 39 F0 JSR KC ;get status of current key 0148 EF57 30 10 BMI KBDX ;[current key closed] 0149 EF59 ; current key open 0150 EF59 E4 EC CPX CKEY 0151 EF5B KBDW 0152 EF5B 86 EC STX CKEY ;update open/closed state of current key 0153 EF5D D0 07 BNE KBDWU ;[current key: is open was closed, or is closed was open] 0154 EF5F ; CURRENT KEY HAS BEEN OPEN FOR TWO CLOCK 0155 EF5F ; CYCLES, SO 'FORGET' IT BY ZEROING CKEY 0156 EF5F ; (KEY VALUES START AT 16 IN THIS RTNE) 0157 EF5F ; ALSO SET COUNTER TO 1 0158 EF5F ; indicate no current key 0159 EF5F A2 00 LDXIM ZERO 0160 EF61 86 EC STX CKEY 0161 EF63 FCSP ;fix to CTRL/SHIFT h/w problem 0162 EF63 20 2E F0 JSR AR ;update auto-repeat intervals 0163 EF66 KBDWU 0164 EF66 4C F8 EF JMP KBDY 0165 EF69 KBDX ;current KEY IS CLOSED:IF WAS OPEN,SIMPLY 0166 EF69 ; UPDATE STATUS,ELSE CHECK COUNTER 0167 EF69 ; AND PROCESS CHAR IF REQ'D. 0168 EF69 E4 EC CPX CKEY 0169 EF6B D0 EE BNE KBDW ;[current key: is closed, was open] 0170 EF6D ; current key is closed and was closed 0171 EF6D A5 E7 LDA ARCTR 0172 EF6F F0 23 BEQ KBDXS ;[auto-repeat suppressed] 0173 EF71 ; decrement auto-repeat countdown 0174 EF71 C6 E7 DEC ARCTR 0175 EF73 D0 1F BNE KBDXS ;[auto-repeat interval not exhausted] 0176 EF75 ; auto-repeat interval exhausted 0177 EF75 ; auto-repeat countdown := delay/repeat period 0178 EF75 AD CA 02 LDA FARCTR 0179 EF78 85 E7 STA ARCTR 0180 EF7A ; next auto-repeat interval := repeat period 0181 EF7A AD 55 02 LDA ARSET 0182 EF7D 8D CA 02 STA FARCTR 0183 EF80 ; 0184 EF80 AD 5A 02 LDA KSTAT 0185 EF83 ; test for shift lock key 0186 EF83 A6 EC LDX CKEY 0187 EF85 E0 D0 CPXIM SHLKKY ;IS THIS THE SHIFT LOCK? 0188 EF87 D0 0D BNE KCPLK ;[key is not SHIFT lock] 0189 EF89 ; 0190 EF89 ; SHIFT LOCK key processing 0191 EF89 09 90 ORAIM CAPSL+INVERT ;clear CAPITALS lock state 0192 EF8B 49 A0 EORIM SHFTL+INVERT ;flip SHIFT lock state and clear invert 0193 EF8D KEYBD3 ;update keyboard status 0194 EF8D 8D 5A 02 STA KSTAT ;store SHIFT lock state 0195 EF90 ; suppress auto-repeat 0196 EF90 A9 00 LDAIM ZERO 0197 EF92 85 E7 STA ARCTR 0198 EF94 KBDXS 0199 EF94 [ MOS125 = &FF 0201 EF94 | 0202 EF94 B0 62 BCS KBDY ;always branch 0203 EF96 ] 0204 EF96 0205 EF96 KCPLK ;CAPS key processing 0206 EF96 E0 C0 CPXIM CPLKKY 0207 EF98 D0 0E BNE KCPLK1 ;[not CAPITALS lock] 0208 EF9A ; clear SHIFT lock state 0209 EF9A 09 A0 ORAIM SHFTL+INVERT 0210 EF9C ; add in SHIFT invert status 0211 EF9C 24 FA BIT KTEMP 0212 EF9E 10 04 BPL KCPLK2 ;[not SHIFT/CAPS] 0213 EFA0 ; SHIFT/CAPS - force CAPS invert 0214 EFA0 09 10 ORAIM CAPSL 0215 EFA2 49 80 EORIM INVERT 0216 EFA4 KCPLK2 0217 EFA4 ; flip CAPITALS lock state 0218 EFA4 49 90 EORIM CAPSL+INVERT 0219 EFA6 ; set CAPITALS lock state and disable auto-repeat 0220 EFA6 [ MOS125 = &FF 0222 EFA6 | 0223 EFA6 B0 E5 BCS KEYBD3 ;C=1 from CPXIM 0224 EFA8 ] 0225 EFA8 0226 EFA8 KCPLK1 0227 EFA8 ; AT THIS POINT, WE HAVE A CHARACTER FOR RDCH 0228 EFA8 ; NOW LOOK UP CODE AND MODIFY BY SHIFT 0229 EFA8 ; CONTROL OR CAPS LOCK AS APPROPRIATE 0230 EFA8 ; convert current key code to ASCII 0231 EFA8 BD BA EF LDAAX KTBL -&80 0232 EFAB D0 03 BNE NTAB ;[not TAB key] 0233 EFAD ; TAB key 0234 EFAD AD 6B 02 LDA TABCOD 0235 EFB0 NTAB 0236 EFB0 0237 EFB0 [ FALSE=0 0256 EFB0 ] 0257 EFB0 0258 EFB0 ; setup for KSTAT tests 0259 EFB0 AE 5A 02 LDX KSTAT 0260 EFB3 86 FA STX KTEMP 0261 EFB5 ; check for CTRL 0262 EFB5 26 FA ROL KTEMP 0263 EFB7 10 07 BPL KCONV6 ;[no CTRL] 0264 EFB9 ; cannot support two-key rollover with CTRL (h/w constraint) 0265 EFB9 A6 ED LDX OKEY 0266 EFBB FCSP1 ;chained branch 0267 EFBB D0 A6 BNE FCSP ;[at least two keys pressed] 0268 EFBD ; convert character to associated control character Acorn macro assembler Page 118 MOS56 Keyboard management 0269 EFBD 20 0B EB JSR CTRLCH 0270 EFC0 KCONV6 0271 EFC0 ; check for SHIFT lock 0272 EFC0 [ MOS125 = &FF 0290 EFC0 | 0291 EFC0 26 FA ROL KTEMP 0292 EFC2 26 FA ROL KTEMP ;skip over CAPITALS lock state 0293 EFC4 90 07 BCC KCONV4 ;[SHIFT lock] 0294 EFC6 ; check for CAPS lock 0295 EFC6 30 0D BMI KCONV2 ;[no CAPS lock or SHIFT lock] 0296 EFC8 ; convert character to upper case 0297 EFC8 ; check for character in the range 'A' to 'Z' or 'a' to 'z' 0298 EFC8 20 27 E5 JSR CAPS 0299 EFCB B0 08 BCS KCONV2 ;[not alpha] 0300 EFCD ; character is an alpha 0301 EFCD KCONV4 0302 EFCD 20 E8 EA JSR SHIFT ;invert case of alpha 0303 EFD0 ] 0304 EFD0 ; check for shift disabled 0305 EFD0 AE 5A 02 LDX KSTAT 0306 EFD3 10 0B BPL KCONV1 ;[shift disabled] 0307 EFD5 KCONV2 ;check for SHIFT 0308 EFD5 26 FA ROL KTEMP 0309 EFD7 10 07 BPL KCONV1 ;[no SHIFT] 0310 EFD9 ; cannot support two-key rollover with SHIFT (h/w constraint) 0311 EFD9 A6 ED LDX OKEY 0312 EFDB D0 DE BNE FCSP1 ;[at least two keys pressed] 0313 EFDD ; shift character 0314 EFDD 20 E8 EA JSR SHIFT 0315 EFE0 KCONV1 0316 EFE0 ; 0317 EFE0 ; check for interrupt character 0318 EFE0 ; 0319 EFE0 CD 6C 02 CMP INTCH 0320 EFE3 D0 07 BNE KESC1 ;[not interrupt character] 0321 EFE5 AE 75 02 LDX ESCHAR 0322 EFE8 D0 02 BNE KESC1 ;[treat as normal character] 0323 EFEA ; 0324 EFEA ; X=0, Z=1 0325 EFEA ; 0326 EFEA 86 E7 STX ARCTR ;suppress auto-repeat for escape if escape condition enabled 0327 EFEC KESC1 0328 EFEC ; 0329 EFEC ; allow interrupts 0330 EFEC ; 0331 EFEC A8 TAY ;Y := character (will be passed to RDCHS) 0332 EFED 20 35 F1 JSR KALLOW 0333 EFF0 ; 0334 EFF0 ; insert character into RDCH buffer 0335 EFF0 ; 0336 EFF0 AD 59 02 LDA NETKDS 0337 EFF3 D0 03 BNE KBDY ;[keyboard disabled] 0338 EFF5 20 34 E5 JSR RDCHS 0339 EFF8 ; 0340 EFF8 KBDY ; NOW WE EVALUATE THE OLD KEY STATUS. 0341 EFF8 ; IF OPEN FOR 2 CLOCK CYCLES, FORGET IT 0342 EFF8 ; OTHERWISE, SIMPLY MEMORISE IT! 0343 EFF8 A6 ED LDX OKEY 0344 EFFA F0 0B BEQ KBDA ;[old key does not exist] 0345 EFFC ; 0346 EFFC ; old key exists 0347 EFFC 20 39 F0 JSR KC 0348 EFFF 86 ED STX OKEY ;remember old key state 0349 F001 30 04 BMI KBDA ;[old key closed] 0350 F003 ; 0351 F003 ; old key open 0352 F003 [ FALSE=0 0356 F003 ] 0357 F003 ; 0358 F003 ; old key: is open, was open 0359 F003 A2 00 LDXIM ZERO 0360 F005 86 ED STX OKEY ;indicate no old key 0361 F007 KBDA ; NOW CHECK TO SEE IF A SCAN IS NEEDED. 0362 F007 ; IF OLD KEY ZERO, DO SCAN. IF KEY DOWN & 0363 F007 ; NOT EQUAL CKEY THEN SET OLD=CURRENT, & THIS 0364 F007 ; ONE = CURRENT, RESET STATUS CHANGE BITS 0365 F007 A6 ED LDX OKEY 0366 F009 D0 16 BNE KBDAU ;[old key exists] 0367 F00B ; no old key so scan keyboard 0368 F00B A0 EC LDYIM CKEY 0369 F00D 20 D8 F0 JSR ISCAN 0370 F010 30 09 BMI KBDAS ;[all keys searched] 0371 F012 ; closed key found other than current key 0372 F012 ; new current key found 0373 F012 ; set old key = current key 0374 F012 A5 EC LDA CKEY 0375 F014 85 ED STA OKEY 0376 F016 KBDAR ;set new current key 0377 F016 86 EC STX CKEY ;current key := new key number 0378 F018 20 2E F0 JSR AR ;update auto-repeat intervals 0379 F01B 4C F3 EE KBDAS JMP KBDAW 0380 F01E KBDAT 0381 F01E ; ENTRY POINT FROM ANY KEY 0382 F01E ; DOWN INTERRUPT 0383 F01E ; enable keyboard by scanning random key (X) 0384 F01E 20 39 F0 JSR KC 0385 F021 KBDAU ;find new current key 0386 F021 A5 EC LDA CKEY 0387 F023 D0 F6 BNE KBDAS ;[current key exists, should only exist during power up] 0388 F025 ; scan keyboard matrix entries 0389 F025 A0 ED LDYIM OKEY 0390 F027 20 D8 F0 JSR ISCAN 0391 F02A 30 EF BMI KBDAS ;[processed all keys] 0392 F02C ; pressed key found other than old key 0393 F02C ; new current key identified 0394 F02C 10 E8 BPL KBDAR ;[ALWAYS JUMP] 0395 F02E ; NEVER fall thru 0396 F02E 0397 F02E 0398 F02E AR ;set auto-repeat interval to reflect next character 0399 F02E A2 01 LDXIM &01 0400 F030 86 E7 STX ARCTR 0401 F032 ; set next auto-repeat interval to delay period 0402 F032 AE 54 02 LDX FARSET 0403 F035 8E CA 02 STX FARCTR 0404 F038 60 RTS 0405 F039 0406 F039 0407 F039 [ FALSE=0 0414 F039 ] 0415 F039 Acorn macro assembler Page 119 MOS56 Keyboard management 0416 F039 KC 0417 F039 ; KEYBOARD ACCESS SUBROUTINE 0418 F039 ; read state of key 0419 F039 ; X = 0rrrcccc 0420 F039 ; r = row, c = column 0421 F039 ; N.B. A and C not corrupted 0422 F039 [ 1=0 ;$Tutu 0434 F039 | 0435 F039 ; enable keyboard 0436 F039 A0 03 LDYIM &03 0437 F03B 8C 40 FE STY PBQ 0438 F03E ; select VIAA PA6-PA0 as outputs 0439 F03E A0 7F LDYIM &7F 0440 F040 8C 43 FE STY DDRAQ 0441 F043 8E 4F FE STX PAPQ ;select matrix element 0442 F046 AE 4F FE LDX PAPQ ;read element status: N=0 => open, N=1 => closed 0443 F049 60 RTS 0444 F04A ] 0445 F04A 0446 F04A 0447 F04A 0448 F04A 0449 F04A ; KEY CONVERSION TABLE 0450 F04A ; ROW 0 0451 F04A ; not relevant 0452 F04A ; (consists of SHIFT, CTRL and start-up options) 0453 F04A KTBL0 0454 F04A F03A KTBL * KTBL0 -&10 0455 F04A ; ROW 1 0456 F04A 71 = "q" 0457 F04B 33 = "3" ;shift '#' 0458 F04C 34 = "4" ;shift '$' 0459 F04D 35 = "5" ;shift '%' 0460 F04E 84 = SOFTK4 ;f4 0461 F04F 38 = "8" ;shift '(' 0462 F050 87 = SOFTK7 ;f7 0463 F051 2D = "-" ;shift '=' 0464 F052 5E = "^" ;shift '~' 0465 F053 8C = CURLFT ;cursor left (fC) 0466 F054 0467 F054 ; 'hide' 6 bytes 0468 F054 [ MOS125 = &FF 0474 F054 | 0475 F054 PUTCHK 0476 F054 0477 F054 ;Output byte to cassette and add to check sum. 0478 F054 0479 F054 20 A7 F8 JSR PUTCAS 0480 F057 4C E0 F7 JMP ADDCRC 0481 F05A ] 0482 F05A 0483 F05A ; ROW 2 0484 F05A 80 = SOFTK0 ;f0 0485 F05B 77 = "w" 0486 F05C 65 = "e" 0487 F05D 74 = "t" 0488 F05E 37 = "7" ;shift single quote 0489 F05F 69 = "i" 0490 F060 39 = "9" ;shift ')' 0491 F061 30 = "0" ;same shifted 0492 F062 POUNDM 0493 F062 5F = "_" ;shift POUND 0494 F063 8E = CURDWN ;cursor down (fE) 0495 F064 0496 F064 ; 'hide' 6 bytes 0497 F064 6C FE FD JMITST JMI TSTSFT 0498 F067 [ MOS125 = &FF 0500 F067 | 0501 F067 6C 20 02 JMIEVT JMI EVTVEC ;user event 0502 F06A ] 0503 F06A 0504 F06A ; ROW 3 0505 F06A 31 = "1" ;shift '!' 0506 F06B 32 = "2" ;shift double quote 0507 F06C 64 = "d" 0508 F06D 72 = "r" 0509 F06E 36 = "6" ;shift '&' 0510 F06F 75 = "u" 0511 F070 6F = "o" 0512 F071 70 = "p" 0513 F072 5B = "[" ;shift curly left bracket 0514 F073 8F = CURUP ;cursor up (fF) 0515 F074 0516 F074 ; 'hide' 6 bytes 0517 F074 2C 49 D9 JMIKYV BIT FFBYT 0518 F077 6C 28 02 JMIKEY JMI KEYVEC 0519 F07A 0520 F07A ; ROW 4 0521 F07A 01 = &01 ;CAPS lock 0522 F07B 61 = "a" 0523 F07C 78 = "x" 0524 F07D 66 = "f" 0525 F07E 79 = "y" 0526 F07F 6A = "j" 0527 F080 6B = "k" 0528 F081 40 = AT ;same shifted 0529 F082 3A = ":" ;shift '*' 0530 F083 0D = MCR ;same shifted 0531 F084 0532 F084 [ NOSP = &00 0542 F084 | 0543 F084 ; 'hide' 6 bytes 0544 F084 SENDD 0545 F084 00 = &00 ;inputs 0546 F085 FF = &FF ;outputs 0547 F086 SENDS 0548 F086 01 = &01 ;read enable 0549 F087 02 = &02 ;write enable 0550 F088 SENDF 0551 F088 09 = &09 ;read disable 0552 F089 0A = &0A ;write disable 0553 F08A ] 0554 F08A 0555 F08A ; ROW 5 0556 F08A 02 = &02 ;SHIFT lock 0557 F08B 73 = "s" 0558 F08C 63 = "c" 0559 F08D 67 = "g" 0560 F08E 68 = "h" 0561 F08F 6E = "n" 0562 F090 6C = "l" Acorn macro assembler Page 120 MOS56 Keyboard management 0563 F091 3B = ";" ;shift '+' 0564 F092 5D = "]" ;shift curly right bracket 0565 F093 7F = MDEL ;same shifted 0566 F094 0567 F094 ; 'hide' 6 bytes 0568 F094 RMLA ;read machine low memory address 0569 F094 AC 44 02 LDY HWM 0570 F097 A2 00 LDXIM ZERO 0571 F099 60 RTS 0572 F09A 0573 F09A ; ROW 6 0574 F09A 00 = ZERO ;TAB - programmable TAB key 0575 F09B 7A = "z" 0576 F09C 20 = SPACE ;same shifted 0577 F09D 76 = "v" 0578 F09E 62 = "b" 0579 F09F 6D = "m" 0580 F0A0 2C = "," ;shift '<' 0581 F0A1 2E = "." ;shift '>' 0582 F0A2 2F = "/" ; shift '?' 0583 F0A3 8B = MCOPY ;copy character at cursor (fB) 0584 F0A4 0585 F0A4 ; 'hide' 6 bytes 0586 F0A4 JFLUSH ;flush input buffer and clear soft key expansion 0587 F0A4 AE 41 02 LDX RDCHSW ;X := input bufferid 0588 F0A7 FLUSH2 0589 F0A7 4C FD E1 JMP PURGE ;purge buffer AND return 0590 F0AA 0591 F0AA ; ROW 7 0592 F0AA 1B = ESC ;same shifted 0593 F0AB 81 = SOFTK1 ;f1 0594 F0AC 82 = SOFTK2 ;f2 0595 F0AD 83 = SOFTK3 ;f3 0596 F0AE 85 = SOFTK5 ;f5 0597 F0AF 86 = SOFTK6 ;f6 0598 F0B0 88 = SOFTK8 ;f8 0599 F0B1 89 = SOFTK9 ;f9 0600 F0B2 5C = "\" ;shift '|' 0601 F0B3 8D = CURRHT ;cursor right (fD) 0602 F0B4 ENDKT 0603 F0B4 0604 F0B4 0605 F0B4 [ MOS125 = &FF 0607 F0B4 ] 0608 F0B4 0609 F0B4 0610 F0B4 FLUSHC ;flush buffer 0611 F0B4 D0 EE BNE JFLUSH ;[flush currently selected input buffer] 0612 F0B6 ; X=0 => flush all buffers 0613 F0B6 FLSHAL ;flush all buffers 0614 F0B6 A2 08 LDXIM BUPB 0615 F0B8 FLUSH3 0616 F0B8 ; allow interrupts 0617 F0B8 58 CLI 0618 F0B9 78 SEI 0619 F0BA 20 C0 F0 JSR FLUSHS ;flush buffer given by X 0620 F0BD CA DEX 0621 F0BE 10 F8 BPL FLUSH3 0622 F0C0 ; 0623 F0C0 ; N.B. X<0, so is an invalid bufferid (and will be ignored by FLUSHS) 0624 F0C0 ; 0625 F0C0 FLUSHS ;flush specific buffer 0626 F0C0 E0 09 CPXIM BUPB +&01 0627 F0C2 90 E3 BCC FLUSH2 ;[valid bufferid] 0628 F0C4 ; invalid bufferid 0629 F0C4 60 RTS 0630 F0C5 0631 F0C5 0632 F0C5 HELP ;*HELP command 0633 F0C5 A2 09 LDXIM SVHELP 0634 F0C7 20 74 F1 JSR SVOP ;Y = offset within line of arguments 0635 F0CA ; 0636 F0CA ; Y preserved, therefore Y>=2 on return 0637 F0CA ; 0638 F0CA 20 3D FA JSR STROUT ;needs Y<>0 to print 0639 F0CD 0D = MCR 0640 F0CE 4F 53 20 = "OS " 0641 F0D1 31 = VERA 0642 F0D2 2E = "." 0643 F0D3 32 = VERB 0644 F0D4 36 = VERC 0645 F0D5 0D = MCR 0646 F0D6 00 = ZERO 0647 F0D7 ; 0648 F0D7 60 RTS 0649 F0D8 0650 F0D8 0651 F0D8 ISCAN ;scan keys from matrix address $10 0652 F0D8 18 CLC ;ignore key addressed by Y 0653 F0D9 ; 0654 F0D9 XSCANA ;FX entry, scan keys from matrix address $10, C=1 (ignore no keys) 0655 F0D9 A2 10 LDXIM &10 0656 F0DB ; 0657 F0DB XSCANB ;FX entry, scan keys from matrix address X, C=1 (ignore no keys) 0658 F0DB B0 9A BCS JMIKEY ;[route FX entries thru indirection] 0659 F0DD ; 0660 F0DD SKFMA ;scan keys from matrix address (should have C=1) 0661 F0DD ; start scan address in X 0662 F0DD ; X>=0 => scan keys starting at X 0663 F0DD ; X<0 => investigate key NOT(X) 0664 F0DD ; 0665 F0DD 8A TXA 0666 F0DE 10 05 BPL SKFMA2 ;[scan keys] 0667 F0E0 ; C=1 0668 F0E0 ; look at key 0669 F0E0 ; 0670 F0E0 20 39 F0 JSR KC ;result in top bit of X (N.B. does not alter C) 0671 F0E3 ; C=1 0672 F0E3 B0 55 BCS KALLOX ;return result in A 0673 F0E5 ; 0674 F0E5 SKFMA2 0675 F0E5 ; 0676 F0E5 08 PHP ;save request source indicator (in C) 0677 F0E6 90 02 BCC SKFMA1 ;[CKEY or OKEY entry] 0678 F0E8 A0 EE LDYIM CKEY+&02 0679 F0EA SKFMA1 0680 F0EA ; 0681 F0EA 99 DF 01 STAAY KSCSTA-CKEY ;save scan start address 0682 F0ED ; return MI => no keys, otherwise X = key 0683 F0ED A2 09 LDXIM &09 0684 F0EF ; Acorn macro assembler Page 121 MOS56 Keyboard management 0685 F0EF ISCAN1 0686 F0EF ; allow interrupts 0687 F0EF ; 0688 F0EF 20 35 F1 JSR KALLOW 0689 F0F2 ; 0690 F0F2 ; select VIAA PA6-PA0 as outputs 0691 F0F2 ; 0692 F0F2 A9 7F LDAIM &7F 0693 F0F4 8D 43 FE STA DDRAQ 0694 F0F7 ; 0695 F0F7 ; claim keyboard 0696 F0F7 ; 0697 F0F7 A9 03 LDAIM &03 0698 F0F9 8D 40 FE STA PBQ 0699 F0FC ; 0700 F0FC ; reset keyboard interrupt line 0701 F0FC ; 0702 F0FC A9 0F LDAIM &0F ;N.B. use non-existent group which does not interrupt 0703 F0FE 8D 4F FE STA PAPQ 0704 F101 ; 0705 F101 ; clear latched event 0706 F101 ; 0707 F101 A9 01 LDAIM &01 0708 F103 8D 4D FE STA IFRQ 0709 F106 ; 0710 F106 8E 4F FE STX PAPQ ;select key (force no key first time thru loop) 0711 F109 0712 F109 2C 4D FE BIT IFRQ ;test for latched event 0713 F10C F0 21 BEQ ISCAND ;[no group key pressed] 0714 F10E ; 0715 F10E ; key pressed in this group 0716 F10E ; 0717 F10E 8A TXA ;A := key at start of group 0718 F10F ; 0719 F10F ISCANC ;scan group to find pressed key within group 0720 F10F ; check key against start scan address 0721 F10F ; 0722 F10F D9 DF 01 CMPAY KSCSTA-CKEY 0723 F112 90 16 BCC ISCANE ;[ignore key] 0724 F114 ; 0725 F114 8D 4F FE STA PAPQ 0726 F117 2C 4F FE BIT PAPQ 0727 F11A 10 0E BPL ISCANE ;[individual key not pressed] 0728 F11C ; 0729 F11C ; individual key pressed 0730 F11C ; 0731 F11C ISCANB ;key press detected at key A 0732 F11C ; 0733 F11C ; key found 0734 F11C ; 0735 F11C 28 PLP 0736 F11D 08 PHP 0737 F11E B0 13 BCS ISCAN9 ;[ignore no character] 0738 F120 ; 0739 F120 48 PHA ;save key code 0740 F121 ; 0741 F121 ; check whether to ignore character 0742 F121 ; 0743 F121 59 00 00 EORAY ZERO 0744 F124 0A ASLA ;ignore top bit 0745 F125 C9 01 CMPIM &01 0746 F127 68 PLA ;restore key code 0747 F128 B0 09 BCS ISCAN9 ;[accept key] 0748 F12A ; 0749 F12A ; ignore key 0750 F12A ; 0751 F12A ISCANE ;ignore key 0752 F12A 18 CLC 0753 F12B 69 10 ADCIM &10 0754 F12D 10 E0 BPL ISCANC ;[step to next key within group] 0755 F12F ; 0756 F12F ; key group exhausted 0757 F12F ; 0758 F12F ISCAND ;scan within group failed 0759 F12F CA DEX 0760 F130 10 BD BPL ISCAN1 ;[try next group] 0761 F132 ; no key found, X<0 0762 F132 8A TXA ;set up to negate effect of TAX 0763 F133 ; 0764 F133 ISCAN9 ;accept key 0765 F133 AA TAX ;X := key address 0766 F134 ; 0767 F134 28 PLP 0768 F135 ; 0769 F135 KALLOW ;release keyboard and allow interrupts 0770 F135 ; **** MUST NOT CORRUPT Y **** 0771 F135 ; release keyboard 0772 F135 ; 0773 F135 20 3A F1 JSR KALLOX ;release keyboard 0774 F138 ; 0775 F138 ; allow interrupts 0776 F138 ; 0777 F138 58 CLI 0778 F139 78 SEI 0779 F13A ; 0780 F13A KALLOX ;release keyboard 0781 F13A A9 0B LDAIM &0B 0782 F13C 8D 40 FE STA PBQ 0783 F13F ; 0784 F13F ; return result in N 0785 F13F ; 0786 F13F 8A TXA ;N=1 => no new key, N=0 => new key in X 0787 F140 60 RTS 0788 F141 0789 F141 0790 F141 0791 F141 < 3 0792 F141 0793 F141 LNK MOS70 0001 F141 TTL C.F.S. Manifest File - MOS70 0002 F141 OPT &01 0003 F141 0004 F141 0005 MOS70 * DEFOPT 0005 F141 0005 MOS72 * DEFOPT 0006 F141 0005 MOS74 * DEFOPT 0007 F141 0005 MOS76 * DEFOPT 0008 F141 0009 F141 OPT MOS70 Acorn macro assembler Page 122 C.F.S. Manifest File - MOS70 0010 F141 0011 F141 < &0003 0012 F141 > &0002 0013 F141 0014 F141 0015 F141 ;****** C.F.S HEADER FILE ****** 0016 F141 0017 F141 0018 F141 0019 F141 ;cIOBYTS * $00 ;No longer used 0020 F141 0000 LENSW * &00 ;Zero => LOAD modify's OSFILE block 0021 F141 0001 DEBUG * &01 ;zero => messages. +ve => no messages 0022 F141 0000 TUBESW * &00 ;Zero => tube, +ve => no tube 0023 F141 00FF PREMRG * &FF ;Zero => entry indirections, +ve => none 0024 F141 00FF GLYN * &FF ;Zero => special IBG code for 0025 F141 ;Glynn. +ve => as per spec. 0026 F141 0027 F141 ;MANIFESTS 0028 F141 0029 F141 00FE ENDBYT * &FE ;Byte after end of file (GETBYT) 0030 F141 0031 F141 0091 FXCDRV * &0091 ;FX call number 0032 F141 00FF READFX * &FF 0033 F141 0000 WRITFX * &00 0034 F141 0035 F141 0001 INHAND * &0001 ;Input handle 0036 F141 0002 OUTHND * &0002 ;Output handle 0037 F141 0003 HNDS * &03 ;Both handles 0038 F141 00FD NOUTHD * &FD 0039 F141 000B FTSIZE * &000B ;File title size (incl. CR) 0040 F141 0041 F141 ;Note that the 6850 status bytes (following) 0042 F141 ;have their bottom nybble modified according to 0043 F141 ;the setting of SPEED in the routines RXINIT and TXINIT 0044 F141 0045 F141 0030 TXSTAT * &30 ;6850 TX status 0046 F141 ;TXSTAT = ~RTS lo;TXI enabled;8 bits + 1 stop 0047 F141 00D0 RXSTAT * &D0 0048 F141 ;RXSTAT = ~RTS hi;TXI disabled;8 bits + 1 stop 0049 F141 0050 F141 0002 TXBIT * &02 0051 F141 0001 RXBIT * &01 0052 F141 0004 DCDBIT * &04 0053 F141 0054 F141 0085 SERON * &85 ;Motor on/cass. on/RXCLK=0/TXCLK= 1,0,1 0055 F141 0005 SEROFF * &05 ;As SERON but motor off 0056 F141 ;ERRORS 0057 F141 0058 F141 00DF ERRBAS * &DF 0059 F141 0060 F141 00DF CFSERD * ERRBAS -&00 ;EOF 0061 F141 00DE CFSERB * ERRBAS -&01 ;Channel 0062 F141 00DD CFSERK * ERRBAS -&02 ;Address 0063 F141 00DC SYNXER * ERRBAS -&03 ;Syntax 0064 F141 00DB CFSERF * ERRBAS -&04 ;File 0065 F141 00DA CFSERH * ERRBAS -&05 ;Block 0066 F141 00D9 CFSERI * ERRBAS -&06 ;Header 0067 F141 00D8 CFSERJ * ERRBAS -&07 ;Data 0068 F141 00D8 CFSERR * CFSERJ ;Bad tape 0069 F141 0070 F141 00D7 SFSERR * ERRBAS -&08 ;Bad ROM 0071 F141 00D6 SFSER1 * ERRBAS -&09 ;File not found 0072 F141 0073 F141 00D5 CFSERL * ERRBAS -&0A ;Locked 0074 F141 0075 F141 0076 F141 ;STATUS BYTE MASKS 0077 F141 0078 F141 0001 INOPEN * &01 0079 F141 0002 OUTOPN * &02 0080 F141 0040 LSTBYT * &40 ;Last byte read (GETBYTE) 0081 F141 0080 EOFBIT * &80 ;Last byte +1 read (GETBYTE) 0082 F141 00C0 LSTEOF * &C0 ;Last byte & EOF 0083 F141 0084 F141 00F7 NCTBIT * &F7 ;Complement of CATBIT 0085 F141 003F NEFBIT * &3F ;Complement of EOFBIT/lastbyte 0086 F141 00FE NINHND * &FE ;Complement of INHAND 0087 F141 003E NECBIT * &3E ;Complement of EOFBIT/lastbyte/openin bit 0088 F141 0089 F141 0090 F141 0091 F141 ;MESSAGE/ERROR SELECTION MASKS 0092 F141 0093 F141 0094 F141 00CC ERRMSK * &CC ;Error bits to zero 0095 F141 0033 MSGMSK * &33 ;Message bits to zero 0096 F141 0088 MSGS1 * &88 ;Short messages 0097 F141 00CC MSGS2 * &CC ;Long messages 0098 F141 0099 F141 0011 ABTBIT * &11 ;Abort set 0100 F141 0022 RETBIT * &22 ;Retry set 0101 F141 0000 IGBIT * &00 ;Both error bits off => ignore 0102 F141 0030 NIGBIT * &30 ;Complement of ignore bits 0103 F141 0104 F141 00A1 DEFLT * &A1 0105 F141 0106 F141 ;Default is retry/messages for loaded and saved 0107 F141 ;files, abort/no messages for sequential files. 0108 F141 0109 F141 0110 F141 ;INFO FIELDS 0111 F141 0112 F141 000C BKINFO * FTSIZE +&01 0113 F141 000C BKLOAD * BKINFO 0114 F141 000C BKLDLO * BKLOAD 0115 F141 000D BKLDHI * BKLDLO +&01 0116 F141 0010 BKEXEC * BKLOAD +&04 0117 F141 0014 BKNOLO * BKEXEC +&04 0118 F141 0015 BKNOHI * BKNOLO +&01 ;Block no. (lo & hi) 0119 F141 0016 BKSZEL * BKNOHI +&01 0120 F141 0017 BKSZEH * BKSZEL +&01 0121 F141 0018 BKFLAG * BKSZEH +&01 ;b7 => last block 0122 F141 0019 BKSPAR * BKFLAG +&01 0123 F141 001D BKLAST * BKSPAR +&04 ;Length of info. 0124 F141 0125 F141 001D BKWORKK * BKLAST 0126 F141 001E BKWRK1 * BKWORKK +&01 0127 F141 001F BKWRK2 * BKWRK1 +&01 0128 F141 0129 F141 0130 F141 Acorn macro assembler Page 123 C.F.S. Manifest File - MOS70 0131 F141 0132 F141 ;BLOCK FLAG MASKS 0133 F141 0134 F141 0080 LASTBK * &80 ;NOTE - don't change, BMI and BVS etc. used 0135 F141 0136 F141 0137 F141 0138 F141 ;TIMES 0139 F141 0140 F141 0019 DEFGAP * &19 ;25/10 Secs inter block gap 0141 F141 0006 GAP * &06 ;SAVE/LOAD gap 0142 F141 0143 F141 0144 F141 ;BITS AND PIECES 0145 F141 0146 F141 0147 F141 0148 F141 0149 F141 0008 CATBIT * &08 ;Doing a CAT 0150 F141 0088 MONBIT * &88 ;Messages on/off 0151 F141 0152 F141 0153 F141 02EA INBSZE * CFSA ;GBYT block size (retained over FS change) 0154 F141 02EC BUFFLG * INBSZE +&02 ;Note BUFFLG & INBZSE must be contig. 0155 F141 0156 F141 02ED FINBYT * CFSD ;Last byte in GETBYT buffer 0157 F141 0158 F141 ;BUFFERS 0159 F141 0160 F141 0A00 INBUFR * &0A00 0161 F141 0900 OUTBFR * &0900 ;Sequential access I/O buffers 0162 F141 0163 F141 ;VARS 0164 F141 0165 F141 0380 VARSS * &0380 0166 F141 0300 VARPGE * &0300 0167 F141 0168 F141 0380 OUTHDR * VARSS ;Header buffer for PUTBYTE 0169 F141 039D OUTPTR * OUTHDR +BKLAST 0170 F141 039E INPTR * OUTPTR +&01 0171 F141 039F INLDEX * INPTR +&01 ;8 bytes load/exec for input file 0172 F141 03A7 INFILE * INLDEX +&08 ;GETBYTE file name 0173 F141 03B2 INFO * INFILE +FTSIZE ;Header buffer 0174 F141 03CF WORKK * INFO +BKWORKK ;Space to read CRC during RDHEAD 0175 F141 03D1 SEQGAP * WORKK +&02 0176 F141 03D2 FILNAM * SEQGAP +&01 0177 F141 03DD NEXTIN * FILNAM +FTSIZE ;Next expected block (GETBYTE) 0178 F141 03DF OLDFLG * NEXTIN +&02 0179 F141 0180 F141 03CB SRPTR * INFO +BKSPAR 0181 F141 0182 F141 0183 F141 ;CHIP LOCATIONS 0184 F141 0185 F141 FE08 STATUS * &FE08 0186 F141 FE09 PORT * &FE09 0187 F141 0188 F141 0189 F141 0190 F141 ;DOS/MOS ROUTINES & ADDRESSES 0191 F141 0192 F141 0193 F141 00FF ESCADD * &00FF ;b7 = 1 if ESCAPE occured 0194 F141 0195 F141 0196 F141 ;TUBE THINGS 0197 F141 0198 F141 0000 TUBER * &00 ;Value in A for tube READ initialisation 0199 F141 0001 TUBEW * &01 ;Value in A for tube WRITE initialisation 0200 F141 0004 TUBEX * &04 ;Value in A for tube execute 0201 F141 0202 F141 0080 TUBERL * &80 ;A reg. for tube RELEASE 0203 F141 00C0 TUBECL * &C0 ;A reg. for tube CLAIM 0204 F141 0205 F141 002B SFSEND * "+" ;Marker for end of SERROM 0206 F141 0207 F141 ; interface to code in MOS 0208 F141 ; 0209 F141 0210 F141 0211 F141 LNK MOS72 0001 F141 ; FILE -> MOS72 0002 F141 0003 F141 START 0004 F141 0005 F141 TTL C.F.S. Main Routines - INIT 0006 F141 OPT MOS72 Acorn macro assembler Page 124 C.F.S. Main Routines - INIT 0007 F141 0008 F141 0009 F141 CROM ;A=$8D, V=0 0010 F141 TAPE ;A=$8C, V=0 0011 F141 49 8C EORIM &8C 0012 F143 TAPE12 ;used by RESET, A=X=$00 0013 F143 0A ASLA 0014 F144 8D 47 02 STA SROMSW ;A=0 => *TAPE, A=2 => *ROM 0015 F147 E0 03 CPXIM &03 ;test for *TAPE3 0016 F149 4C 57 F1 JMP SOFTPT ;[ALWAYS jump] 0017 F14C 0018 F14C 0019 F14C INIT 0020 F14C 0021 F14C ;Initialises CLI and file operation 0022 F14C ;vectors. Motor turned OFF 0023 F14C 0024 F14C ;Z set => 300 baud => speed nybble = 6 0025 F14C ;Z unset => 1200 baud => speed nybble = 5 0026 F14C 0027 F14C ;Speed nybble is OR'd in with 0028 F14C ;6850 status byte during TX/RXinit 0029 F14C 0030 F14C 08 PHP 0031 F14D A9 A1 LDAIM DEFLT 0032 F14F 85 E3 STA OPTS ;User status = retry & msgs on 0033 F151 A9 19 LDAIM DEFGAP 0034 F153 8D D1 03 STA SEQGAP 0035 F156 28 PLP 0036 F157 0037 F157 ;Note CFSTAT (CFS0) set to zero by MOS free of charge 0038 F157 ;on hard reset 0039 F157 0040 F157 SOFTPT ;Soft entry point (*TAPE) 0041 F157 08 PHP 0042 F158 A9 06 LDAIM FSDIE 0043 F15A 20 8A E0 JSR JMIFSC ;present command to file system 0044 F15D A2 06 LDXIM &06 0045 F15F 28 PLP 0046 F160 F0 01 BEQ INITON 0047 F162 CA DEX 0048 F163 86 C6 INITON STX SPEED 0049 F165 ; 0050 F165 ; initialise filing system indirection table 0051 F165 ; 0052 F165 A2 0E LDXIM &0E 0053 F167 BD E3 D8 INITLP LDAAX CFSTAB -&01 0054 F16A 9D 11 02 STAAX FILVEC -&01 0055 F16D CA DEX 0056 F16E D0 F7 BNE INITLP 0057 F170 86 C2 STX ITYPE ;No i'rupts pending 0058 F172 ; 0059 F172 ; inform paged ROMs of change 0060 F172 ; 0061 F172 A2 0F LDXIM SVFSIC 0062 F174 ; 0063 F174 SVOP ;issue service ROM operati 0064 F174 ; optype in X 0065 F174 A5 F4 LDA ROMID ;save current ROM id 0066 F176 48 PHA 0067 F177 8A TXA ;A = optype 0068 F178 ; 0069 F178 A2 0F LDXIM NROM-&1 0070 F17A SVOP1 0071 F17A [ $Tutu ; Less farting about with page 02 0077 F17A | 0078 F17A FE A1 02 INCAX ROMS ;test 0079 F17D DE A1 02 DECAX ROMS ;ROMS 0080 F180 10 0B BPL SVOP2 ;[not a service ROM] 0081 F182 ] 0082 F182 ; found a service ROM 0083 F182 [ MOS125 = &FF 0086 F182 | 0087 F182 20 DB DB JSR STXROM 0088 F185 ] 0089 F185 ; call service routine 0090 F185 20 03 80 JSR ROMSFT ;initialise service ROM 0091 F188 AA TAX 0092 F189 F0 05 BEQ SVOP3 ;[service claimed, do not offer to other ROMs] 0093 F18B ; 0094 F18B A6 F4 LDX ROMID ;restore ROM id 0095 F18D SVOP2 0096 F18D CA DEX 0097 F18E 10 EA BPL SVOP1 0098 F190 ; X<>0 0099 F190 SVOP3 ;C = return code 0100 F190 ; restore caller's ROMid 0101 F190 68 PLA 0102 F191 85 F4 STA ROMID 0103 F193 8D 30 FE STA ROM 0104 F196 ; restore return code 0105 F196 8A TXA ;A=0 => claimed, A<>0 => not claimed 0106 F197 60 RTS 0107 F198 0108 F198 0109 F198 TTL C.F.S. Main Routines - ARGGO 0110 F198 OPT &01 0111 F198 0112 F198 0113 F198 ;Returns 1 if in 1200 baud cassette 0114 F198 ;2 300 0115 F198 ;3 if in SERROM filing system 0116 F198 0117 F198 ;Note SPEED is 5 if in 1200 and 6 in 300 0118 F198 0119 F198 0120 F198 ARGGO 0121 F198 09 00 ORAIM 0 0122 F19A D0 10 BNE INTRTS ;No action on non-zero entry condition 0123 F19C C0 00 CPYIM &00 0124 F19E D0 0C BNE INTRTS ;If handle not zero -> don't do 0125 F1A0 A5 C6 LDA SPEED 0126 F1A2 29 FB ANDIM &FB ;Subtract 4 0127 F1A4 0D 47 02 ORA SROMSW 0128 F1A7 0A ASLA 0129 F1A8 0D 47 02 ORA SROMSW 0130 F1AB 4A LSRA ;Uses the fact that SROMSW is either 0 or 2 0131 F1AC 60 INTRTS RTS 0132 F1AD 0133 F1AD 0134 F1AD TTL C.F.S Main Routines - FSFUNC Acorn macro assembler Page 125 C.F.S Main Routines - FSFUNC 0135 F1AD OPT &01 0136 F1AD 0137 F1AD [ MOS125 = &FF 0164 F1AD | 0165 F1AD FSFUNC 0166 F1AD 0167 F1AD ;File system operation entry pt. 0168 F1AD 0169 F1AD C9 07 CMPIM NOTAB 0170 F1AF B0 FB BCS INTRTS ;Check call legal otherwise, exit 0171 F1B1 0172 F1B1 86 BC STX TEMP 0173 F1B3 AA TAX ;Get address from table 0174 F1B4 BD F9 FB LDAAX JMPTAB +NOTAB 0175 F1B7 48 PHA ;push hi byte 0176 F1B8 BD F2 FB LDAAX JMPTAB 0177 F1BB 48 PHA ;push lo byte 0178 F1BC A6 BC LDX TEMP ;Restore argument 0179 F1BE 60 RTS ;enter routine 0180 F1BF ] 0181 F1BF 0182 F1BF TTL C.F.S. Main Routines - LOAD 0183 F1BF OPT &01 0184 F1BF 0185 F1BF 0186 F1BF ;*********** 0187 F1BF ;* L O A D * 0188 F1BF ;*********** 0189 F1BF 0190 F1BF 0191 F1BF ;On entry A NZ => load from OSFILE 0192 F1BF ; A =0 => load and run 0193 F1BF ;Differentiating between these is necessary 0194 F1BF ;so that the protection bit in the flags 0195 F1BF ;byte can be checked. 0196 F1BF 0197 F1BF 0198 F1BF [ MOS125 = &FF 0313 F1BF ] 0314 F1BF 0315 F1BF 0316 F1BF 0317 F1BF TTL C.F.S. Main Routines - FILEGO 0318 F1BF OPT &01 0319 F1BF 0320 F1BF 0321 F1BF GETFLN 0322 F1BF 0323 F1BF ;X/Y -> start of file name 0324 F1BF 0325 F1BF 0326 F1BF MOVFT 0327 F1BF 0328 F1BF ;Moves file title from ptr. pointed to by X,Y (lo,hi) 0329 F1BF ;to FILNAM. 0330 F1BF 0331 F1BF ; SEI 0332 F1BF 86 F2 STX WORK 0333 F1C1 84 F3 STY WORK +&01 0334 F1C3 A0 00 LDYIM &00 0335 F1C5 20 78 EA JSR GSINTC ;Initialise 0336 F1C8 A2 00 LDXIM &00 0337 F1CA 20 8A EA MOVFTL JSR GSREAD 0338 F1CD B0 0D BCS MOVFTX 0339 F1CF F0 08 BEQ STRERR 0340 F1D1 9D D2 03 STAAX FILNAM 0341 F1D4 E8 INX 0342 F1D5 E0 0B CPXIM FTSIZE 0343 F1D7 D0 F1 BNE MOVFTL 0344 F1D9 0345 F1D9 STRNG0 0346 F1D9 4C 6B EA STRERR JMP BADSTR 0347 F1DC 0348 F1DC A9 00 MOVFTX LDAIM &00 0349 F1DE 9D D2 03 STAAX FILNAM 0350 F1E1 ; CLI 0351 F1E1 60 RTS 0352 F1E2 0353 F1E2 0354 F1E2 FILEGO 0355 F1E2 0356 F1E2 ;Entry here from OSFILE. 0357 F1E2 0358 F1E2 48 PHA ;Store load/save indication 0359 F1E3 86 C8 STX GENPTR 0360 F1E5 84 C9 STY GENPTR +&01 0361 F1E7 0362 F1E7 A0 00 LDYIM &00 0363 F1E9 B1 C8 LDAIY GENPTR 0364 F1EB AA TAX ;Set ptr. to file name for MOVFT 0365 F1EC C8 INY 0366 F1ED B1 C8 LDAIY GENPTR 0367 F1EF A8 TAY 0368 F1F0 0369 F1F0 20 BF F1 JSR MOVFT ;File title -> FILNAM 0370 F1F3 A0 02 LDYIM &02 0371 F1F5 B1 C8 FILELP LDAIY GENPTR 0372 F1F7 99 BC 03 STAAY INFO +BKLOAD -&02 ;Set LOAD/EXEC address in header buffer 0373 F1FA 99 AE 00 STAAY BKADDR -&02 ;Optional load address stored for LOAD 0374 F1FD C8 INY 0375 F1FE C0 0A CPYIM &0A ;Ten coz 2*4 + 2 initially 0376 F200 D0 F3 BNE FILELP 0377 F202 0378 F202 68 PLA 0379 F203 [ MOS125 = &FF 0384 F203 | 0385 F203 D0 5D BNE FILENE 0386 F205 ] 0387 F205 0388 F205 ;Now doing save 0389 F205 0390 F205 8D C6 03 FILEL2 STA INFO +BKNOLO ;Set block number in header 0391 F208 8D C7 03 STA INFO +BKNOHI ;while A is zero 0392 F20B B1 C8 FILEL3 LDAIY GENPTR 0393 F20D 99 A6 00 STAAY BKADDR -&0A ;BKADDR := data start 0394 F210 C8 INY ;Also sets HIADDR which 0395 F211 ;must be contiguous with BKADDR 0396 F211 C0 12 CPYIM &12 0397 F213 D0 F6 BNE FILEL3 0398 F215 0399 F215 8A TXA ;X preserved from MOVFT Acorn macro assembler Page 126 C.F.S. Main Routines - FILEGO 0400 F216 F0 C1 BEQ STRNG0 ;Drops through to SAVE if string OK 0401 F218 0402 F218 0403 F218 TTL C.F.S Main Routines - SAVE 0404 F218 OPT &01 0405 F218 0406 F218 ;*********** 0407 F218 ;* S A V E * 0408 F218 ;*********** 0409 F218 0410 F218 0411 F218 0412 F218 ;Entry here from OSFILE call 0413 F218 0414 F218 20 1A FB JSR SETDEF 0415 F21B 0416 F21B 20 55 F5 JSR RECORD ;Prompt and motor ON 0417 F21E 0418 F21E [ TUBESW=0 0419 F21E A9 00 LDAIM TUBER ;initialise tube for reading 0420 F220 20 B0 FB JSR TBINIT 0421 F223 ] 0422 F223 0423 F223 20 D5 FB JSR BUGFIX ;Put out extra char 0424 F226 0425 F226 38 SAVELP SEC 0426 F227 A2 FD LDXIM &FD 0427 F229 [ MOS125 = &FF 0430 F229 | 0431 F229 B5 B7 SAVEL1 LDAZX (HIADDR -&FD):AND:&FF 0432 F22B F5 B3 SBCZX (BKADDR -&FD):AND:&FF 0433 F22D ] 0434 F22D 9D CB 02 STAAX INFO +BKSZEL-&FD ;Note corrupts Flags byte 0435 F230 E8 INX 0436 F231 D0 F6 BNE SAVEL1 ;Do HIADDR - BKADDR 0437 F233 A8 TAY 0438 F234 D0 0A BNE SAVEL2 ;Msb non-zero => not last block 0439 F236 0440 F236 ;Now: IF $0100 < block size THEN block size := $0100, 0441 F236 ; not last block 0442 F236 ; ELSE last block 0443 F236 0444 F236 [ MOS125 = &FF 0457 F236 | 0458 F236 CD C8 03 CMP INFO +BKSZEL ;Note A = X = Y = 0 0459 F239 2A ROLA ;if L=0 then C := (H<=1) else C := (H==0) 0460 F23A CD C9 03 CMP INFO +BKSZEH ;use constant C=1 from CMP 0461 F23D 6A RORA ;A = $80 if <=$0100, A = 0 if more 0462 F23E 30 08 BMI SAVEL3 ;if last block then don't clamp block size 0463 F240 SAVEL2 ;X = 0, A = Y = undefined 0464 F240 8A TXA ;clear last block flag 0465 F241 8E C8 03 STX INFO +BKSZEL ;Default block size = $0100 0466 F244 E8 INX 0467 F245 8E C9 03 STX INFO +BKSZEH ;Note N=0 preserved by WRBLOK 0468 F248 8D CA 03 SAVEL3 STA INFO +BKFLAG ;WRBLOK clobbers A, X 0469 F24B ] 0470 F24B 0471 F24B 20 16 F8 JSR WRBLOK ;Write out data + header 0472 F24E 30 11 BMI SAVFIN ;Last block => finished 0473 F250 0474 F250 20 5D F9 JSR ADDBKA ;Add block size to address 0475 F253 0476 F253 EE C6 03 INC INFO +BKNOLO 0477 F256 D0 CE BNE SAVELP 0478 F258 EE C7 03 INC INFO +BKNOHI ;Inc. block no. for next time 0479 F25B D0 C9 BNE SAVELP ;Assumed always +ve 0480 F25D 0481 F25D [ MOS125 = &FF 0482 F25D | 0483 F25D OLDKEY ;force old key state 0484 F25D 84 EC STY CKEY ;CKEY := 0 0485 F25F 86 ED STX OKEY ;force old key state 0486 F261 SAVFIN ;Exit from SAVE 0487 F261 60 RTS 0488 F262 0489 F262 C9 FF FILENE CMPIM &FF 0490 F264 D0 FB BNE SAVFIN 0491 F266 0492 F266 LOADGO 0493 F266 0494 F266 08 PHP ;Store interrupt status 0495 F267 48 PHA ;Store indication of load or load/run 0496 F268 20 1A FB JSR SETDEF ;Set defaults if nesc. 0497 F26B 0498 F26B AD C2 03 LDA INFO +BKEXEC 0499 F26E 48 PHA ;EQ=> use addr. from C.line or OSFILE 0500 F26F 0501 F26F 20 5C F6 JSR SRCH0 ;Find file on tape. 0502 F272 LOADL6 0503 F272 0504 F272 68 PLA 0505 F273 F0 17 BEQ LOADLB ;Use load address from command line or OSFILE 0506 F275 0507 F275 ;Move load address from OSFILE command block 0508 F275 ;and check if is $FFFFFFFF, in which case 0509 F275 ;give BAD ADDRESS error 0510 F275 0511 F275 A2 03 LDXIM &03 0512 F277 38 SEC 0513 F278 LOADL1 0514 F278 BD BE 03 LDAAX INFO +BKLOAD ;Address from command block 0515 F27B 95 B0 STAAX BKADDR 0516 F27D 90 02 BCC LOADL2 ;not ADCIM &00 as V may be in use 0517 F27F C9 FF CMPIM &FF 0518 F281 LOADL2 0519 F281 CA DEX 0520 F282 10 F4 BPL LOADL1 0521 F284 0522 F284 90 06 BCC LOADLB ;If CS, all bytes are $FF => error 0523 F286 0524 F286 20 DB FA JSR BEEPOF ;Motor off/beep 0525 F289 4C C3 E2 JMP MBADHX 0526 F28C 0527 F28C AD CA 03 LOADLB LDA INFO +BKFLAG ;Check protection bit 0528 F28F 4A LSRA ;CS -> prot. CC -> unprot 0529 F290 68 PLA ;Check if loading and running 0530 F291 90 13 BCC LOADLA ;Not protected -> carry on 0531 F293 F0 0C BEQ LOADLC ;Yes => carry on 0532 F295 0533 F295 20 E5 FA PROTER JSR CASMOF ;Turn motor off 0534 F298 ;Also called from RDBFER Acorn macro assembler Page 127 C.F.S Main Routines - SAVE 0535 F298 0536 F298 00 BRK 0537 F299 D5 = CFSERL 0538 F29A 4C 6F 63 = "Locked" 0539 F2A0 00 = &00 0540 F2A1 0541 F2A1 LOADLC 0542 F2A1 A9 03 LDAIM &03 0543 F2A3 8D 58 02 STA CRIT ;Loading/running & prot., so disable ESCAPE and trap BREAK 0544 F2A6 LOADLA 0545 F2A6 A9 30 LDAIM NIGBIT 0546 F2A8 25 BB AND USFLGS 0547 F2AA F0 04 BEQ LOADL8 ;If ignore set, just read block 0548 F2AC A5 C1 LDA HDRCRC ;Check hdr. checksum 0549 F2AE 0550 F2AE ;Don't start bg job if header CRC is no good, 0551 F2AE ;otherwise data may be loaded somewhere strange 0552 F2AE 0553 F2AE D0 0A BNE LOADL7 0554 F2B0 98 LOADL8 TYA 0555 F2B1 48 PHA ;Store "Loading" flag 0556 F2B2 20 AE FB JSR TWINIT ;Initialise tube for writing if nesc. 0557 F2B5 68 PLA 0558 F2B6 A8 TAY ;Restore "Loading" flag 0559 F2B7 20 FF F7 JSR RDBLOK 0560 F2BA 20 A7 F9 LOADL7 JSR LODHDR ;Print header and error msgs. 0561 F2BD D0 33 BNE LODRTR ;=> retry 0562 F2BF 0563 F2BF 20 5C FB JSR NXTBLK ;Next block := blk. found + 1 0564 F2C2 2C CA 03 BIT INFO +BKFLAG 0565 F2C5 30 08 BMI LOADEX ;Just loaded last block => finish 0566 F2C7 0567 F2C7 20 5D F9 JSR ADDBKA ;Add block size to BKADDR 0568 F2CA 0569 F2CA 20 AB F7 JSR RDHEAD 0570 F2CD D0 D7 BNE LOADLA ;Always jump 0571 F2CF 0572 F2CF LOADEX 0573 F2CF [ LENSW =0 ;Alter OSFILE control block 0574 F2CF A0 0A LDYIM &0A ;Length offset in OSFILE block 0575 F2D1 A5 CC LDA FSIZE ;File size set in PRTHDR 0576 F2D3 91 C8 STAIY GENPTR ;Note GENPTR kept from OSFILE 0577 F2D5 C8 INY 0578 F2D6 A5 CD LDA FSIZE + 1 0579 F2D8 91 C8 STAIY GENPTR 0580 F2DA A9 00 LDAIM &00 ;Set high bytes of length = 0 0581 F2DC C8 INY 0582 F2DD 91 C8 STAIY GENPTR 0583 F2DF C8 INY 0584 F2E0 91 C8 STAIY GENPTR 0585 F2E2 ] 0586 F2E2 0587 F2E2 28 PLP ;Restore interrupt status 0588 F2E3 0589 F2E3 FINOP 0590 F2E3 0591 F2E3 20 DB FA JSR BEEPOF ;Motor OFF/BEEP 0592 F2E6 0593 F2E6 24 BA NOOLN1 BIT ERRSW ;If error taken place, already new line 0594 F2E8 30 07 BMI FINOPX 0595 F2EA 08 NOOLIN PHP 0596 F2EB 20 39 FA JSR MSGOUT 0597 F2EE 0D = MCR 0598 F2EF 00 = &00 ;Print new line if msgs on 0599 F2F0 28 PLP 0600 F2F1 60 FINOPX RTS 0601 F2F2 0602 F2F2 0603 F2F2 0604 F2F2 20 62 F6 LODRTR JSR SEARCH ;Search for current block (BLOKNO) 0605 F2F5 D0 AF BNE LOADLA ;Try and reload data 0606 F2F7 ] 0607 F2F7 0608 F2F7 0609 F2F7 TTL C.F.S. Main Routines - RUN 0610 F2F7 OPT &01 0611 F2F7 0612 F2F7 RUN 0613 F2F7 20 BF F1 JSR GETFLN 0614 F2FA [ MOS125 = &FF 0617 F2FA | 0618 F2FA ;initialise GENPTR as this is not an OSFILE load 0619 F2FA A2 C2 LDXIM FSIZE - &0A ;note value assumed nonzero 0620 F2FC 86 C8 STX GENPTR ;so LOADEX overwrites FSIZE with itself 0621 F2FE 85 C9 STA GENPTR+1 ;A=0 from GETFLN 0622 F300 8E C2 03 STX INFO +BKEXEC ;=> >0 loads file to header addr 0623 F303 ] 0624 F303 0625 F303 ;Note, is assumed here that A = 0 from GETFLN 0626 F303 ;since LOADGO tests A 0627 F303 0628 F303 [ MOS125 = &7F 0629 F303 [ STARGO = &00 0630 F303 84 E6 STY CLIRY ;use temp, stack is snooped by CompROMs during LOADGO 0631 F305 20 66 F2 JSR LOADGO ;Load file from tape 0632 F308 A4 E6 LDY CLIRY 0633 F30A RUNGO 0634 F30A 98 TYA 0635 F30B 20 5D E0 JSR CLIXY2 ;XY = tail ptr, A = Y on entry = offset 0636 F30E 8E D0 02 STX TAILLO ;save pointer to command line tail 0637 F311 C8 INY ;permute so a page of OS ROM becomes zero 0638 F312 8C D1 02 STY TAILHI ;marking all other addresses valid 0639 F315 A8 TAY ;set up registers to simulate entry from Acorn DFS 0640 F316 A2 FF LDXIM &FF ;from filename comparison 0641 F318 38 SEC 0642 F319 [ TUBESW=0 0643 F319 2C 7A 02 BIT TUBE 0644 F31C 10 0A BPL NOTUB1 ;No tube - jump to IO proc. address 0645 F31E 0646 F31E AD C4 03 LDA INFO +BKEXEC +&02 ;Check if execution address 0647 F321 2D C5 03 AND INFO +BKEXEC +&03 ;of file is accross tube 0648 F324 C9 FF CMPIM &FF 0649 F326 D0 05 BNE RUNL1 ;Yes, set up tube call 0650 F328 A9 01 NOTUB1 LDAIM &01 ;enter with A=1, X=&FF, Y=arg offset, C=1 0651 F32A 6C C2 03 JMI INFO +BKEXEC ;No, just jump 0652 F32D 0653 F32D A2 C2 RUNL1 LDXIM INFO +BKEXEC ;Point to exec. address 0654 F32F A0 03 LDYIM /(INFO +BKEXEC ) 0655 F331 A9 04 LDAIM TUBEX ;=> execute to tube 0656 F333 4C BA FB JMP TBINT1 ;Claim tube and jump to address 0657 F336 | Acorn macro assembler Page 128 C.F.S. Main Routines - RUN 0660 F336 ] 0661 F336 | 0683 F336 ] 0684 F336 | 0706 F336 ] 0707 F336 0708 F336 0709 F336 TTL C.F.S Main Routines - CAT 0710 F336 OPT &01 0711 F336 0712 F336 0713 F336 ;********* 0714 F336 ;* C A T * 0715 F336 ;********* 0716 F336 0717 F336 0718 F336 0719 F336 CAT 0720 F336 0721 F336 ;Entered from MOS with two args 0722 F336 ;in X and Y as per OPT. These are not used. 0723 F336 0724 F336 A9 08 LDAIM CATBIT 0725 F338 20 4F F3 JSR ORSTAT 0726 F33B 20 1A FB JSR SETDEF ;Set message type etc. 0727 F33E A9 00 LDAIM &00 ;Indicate verify only 0728 F340 20 53 F3 JSR LOOK ;In CFS, will never return 0729 F343 ;In SFS, will return 0730 F343 20 EF FA JSR RELEAS ;So in SFS release RS423 0731 F346 ;NOTE - only release call outside CASMOF 0732 F346 0733 F346 0734 F346 A9 F7 CATOFF LDAIM NCTBIT 0735 F348 0736 F348 25 E2 ANDSTA AND CFSTAT 0737 F34A 85 E2 ANDSTB STA CFSTAT 0738 F34C 0739 F34C [ MOS125 = &FF 0741 F34C ] 0742 F34C 60 RTS 0743 F34D 0744 F34D ORLST 0745 F34D A9 40 LDAIM LSTBYT 0746 F34F ; 0747 F34F 05 E2 ORSTAT ORA CFSTAT 0748 F351 D0 F7 BNE ANDSTB ;Assumed always non-zero 0749 F353 0750 F353 0751 F353 0752 F353 0753 F353 0754 F353 48 LOOK PHA 0755 F354 AD 47 02 LDA SROMSW 0756 F357 F0 08 BEQ LOOKLR ;No SFS -> don't call SFS routines 0757 F359 0758 F359 20 2C EE JSR SRINIT ;Initialise SERROM ptr. 0759 F35C [ MOS125 = &FF 0761 F35C ] 0762 F35C 90 03 BCC LOOKLR 0763 F35E 0764 F35E B8 CLV ;Indicate end of rom to outside world 0765 F35F 50 5B BVC LOOKEX 0766 F361 0767 F361 20 AB F7 LOOKLR JSR RDHEAD 0768 F364 AD C6 03 LDA INFO +BKNOLO 0769 F367 85 B4 STA BLOKNO 0770 F369 AD C7 03 LDA INFO +BKNOHI 0771 F36C 85 B5 STA BLOKNO +&01 0772 F36E A2 FF LDXIM &FF 0773 F370 8E DF 03 STX OLDFLG 0774 F373 E8 INX 0775 F374 86 BA STX ERRSW 0776 F376 F0 20 BEQ LOOKL5 ;Always new line 0777 F378 0778 F378 [ MOS125 = &FF 0779 F378 | 0780 F378 50 05 LOOKL4 BVC LOOKL3 ;Header interrupted 0781 F37A A9 FF LDAIM &FF 0782 F37C 20 01 F8 JSR CHKBIN ;Check data 0783 F37F 0784 F37F A2 00 LOOKL3 LDXIM &00 0785 F381 20 CC F9 JSR CATERR ;Print errors and header 0786 F384 0787 F384 AD 47 02 LDA SROMSW 0788 F387 F0 04 BEQ LOOKL9 ;In CFS -> continue 0789 F389 24 BB BIT USFLGS 0790 F38B 50 36 BVC LOOKL8 ;=> short msgs and skip beween files 0791 F38D 0792 F38D 2C CA 03 LOOKL9 BIT INFO +BKFLAG 0793 F390 30 34 BMI LOOKLA ;Look for block zero 0794 F392 ] 0795 F392 0796 F392 20 5C FB LOOKL1 JSR NXTBLK ;Blokno := INFO +BKNO + 1 0797 F395 0798 F395 20 AB F7 JSR RDHEAD ;Read header 0799 F398 AD 47 02 LOOKL5 LDA SROMSW 0800 F39B F0 02 BEQ LOOKL7 0801 F39D 0802 F39D ;Check V from RDHEAD 0803 F39D 0804 F39D 50 1D BVC LOOKEX ;In SFS and VC => end of all ROMs 0805 F39F 0806 F39F 68 LOOKL7 PLA 0807 F3A0 48 PHA ;Check if just verifying 0808 F3A1 F0 D5 BEQ LOOKL4 ;If just verifying, continue 0809 F3A3 20 65 FA JSR CMPFT ;Otherwise, check file titles 0810 F3A6 D0 16 BNE LOOKL2 ;Not the same, continue 0811 F3A8 A9 30 LDAIM NIGBIT 0812 F3AA 25 BB AND USFLGS 0813 F3AC F0 0E BEQ LOOKEX ;If ignore set, just exit 0814 F3AE 0815 F3AE AD C6 03 LDA INFO +BKNOLO ;Otherwise, check block no. 0816 F3B1 C5 B6 CMP SRCHBK 0817 F3B3 D0 09 BNE LOOKL2 ;Not found ... 0818 F3B5 AD C7 03 LDA INFO +BKNOHI 0819 F3B8 C5 B7 CMP SRCHBK +&01 0820 F3BA D0 02 BNE LOOKL2 0821 F3BC 68 LOOKEX PLA 0822 F3BD 0823 F3BD ;On exit, V indicates in CFS if header 0824 F3BD ;interrupted by DCD. In SFS, indicates Acorn macro assembler Page 129 C.F.S Main Routines - CAT 0825 F3BD ;if end of ROM filing system reached. 0826 F3BD 0827 F3BD 60 RTS 0828 F3BE 0829 F3BE LOOKL2 0830 F3BE 0831 F3BE ;Here, file not recognised. In CFS, just 0832 F3BE ;carry on reading next block. In SFS, 0833 F3BE ;skip to block zero of next file. 0834 F3BE 0835 F3BE AD 47 02 LDA SROMSW 0836 F3C1 F0 B5 BEQ LOOKL4 ;In CFS, carry on 0837 F3C3 20 C9 EE LOOKL8 JSR SRSKIP ;Not recognised => skip 0838 F3C6 A9 FF LOOKLA LDAIM &FF 0839 F3C8 8D C6 03 STA INFO +BKNOLO ;Look for block zero of next file 0840 F3CB 8D C7 03 STA INFO +BKNOHI 0841 F3CE D0 C2 BNE LOOKL1 0842 F3D0 0843 F3D0 [ MOS125 = &FF 0859 F3D0 ] 0860 F3D0 0861 F3D0 0862 F3D0 TTL C.F.S Main Routines - FIND 0863 F3D0 OPT &01 0864 F3D0 0865 F3D0 ;****** SEQUENTIAL ACCESS ****** 0866 F3D0 0867 F3D0 0868 F3D0 0869 F3D0 ;*********** 0870 F3D0 ;* F I N D * 0871 F3D0 ;*********** 0872 F3D0 0873 F3D0 0874 F3D0 FIND ;FIND 0875 F3D0 0876 F3D0 0877 F3D0 ;Entered from OSFIND: 0878 F3D0 0879 F3D0 ;A NZ => open 0880 F3D0 ;b6 => file already exists and opened for read/ud 0881 F3D0 ;A EQ => shut 0882 F3D0 0883 F3D0 ;For open: X,Y -> file name lo,hi 0884 F3D0 0885 F3D0 ;For shut: Y = handle. If zero, all files shut. 0886 F3D0 0887 F3D0 0888 F3D0 0889 F3D0 85 BC STA TEMP 0890 F3D2 8A TXA 0891 F3D3 48 PHA 0892 F3D4 98 TYA 0893 F3D5 48 PHA 0894 F3D6 A5 BC LDA TEMP 0895 F3D8 D0 1E BNE FINDON 0896 F3DA 0897 F3DA 98 TYA 0898 F3DB D0 0C BNE SHUTL1 ;Y non-zero => shut one file 0899 F3DD ; 0900 F3DD 20 D1 E2 JSR SHUTES ;shut EXEC and SPOOL files opened by CFS 0901 F3E0 20 7E F4 JSR SHUTW ;Else shut write file 0902 F3E3 ; Shut read file and exit 0903 F3E3 46 E2 SHUTR LSR CFSTAT 0904 F3E5 06 E2 ASL CFSTAT ;Note assumes input bit = b0 0905 F3E7 ; C=0 0906 F3E7 90 0C BCC JFINDEX ;[ALWAYS jump] 0907 F3E9 ; 0908 F3E9 ; 0909 F3E9 4A SHUTL1 LSRA 0910 F3EA B0 F7 BCS SHUTR ;Shut input file 0911 F3EC 4A LSRA 0912 F3ED B0 03 BCS SHUTL2 ;Shut output file 0913 F3EF 0914 F3EF 4C A4 FB JMP HNDERR ;Invalid handle 0915 F3F2 0916 F3F2 20 7E F4 SHUTL2 JSR SHUTW 0917 F3F5 JFINDEX 0918 F3F5 4C 77 F4 JMP FINDEX 0919 F3F8 0920 F3F8 0921 F3F8 0922 F3F8 20 BF F1 FINDON JSR MOVFT 0923 F3FB 0924 F3FB 24 BC BIT TEMP 0925 F3FD 50 3D BVC FINDO ;Find for output if b.6 = 0 0926 F3FF 0927 F3FF ;Opening files already open 0928 F3FF ;is the same as if not already open 0929 F3FF 0930 F3FF 0931 F3FF ;Open for reading 0932 F3FF ;Set handle and read in first buffer 0933 F3FF 0934 F3FF A9 00 LDAIM &00 0935 F401 8D 9E 03 STA INPTR ;Set buffer ptr. := 0 0936 F404 8D DD 03 STA NEXTIN 0937 F407 8D DE 03 STA NEXTIN +&01 ;Set expected block := 0 0938 F40A 0939 F40A A9 3E LDAIM NECBIT ;End of file/last byte unset/input file closed 0940 F40C 20 48 F3 JSR ANDSTA 0941 F40F 0942 F40F 20 0D FB JSR SETSDF ;Set seq. access default 0943 F412 0944 F412 08 PHP ;Store interrupt status 0945 F413 20 5C F6 JSR SRCH0 ;Find file, first block. 0946 F416 20 E4 F6 JSR RDBFRS ;Check hdr. read ok, and get first bfr. 0947 F419 28 PLP ;Restore interrupt status 0948 F41A 0949 F41A A2 FF LDXIM &FF 0950 F41C E8 FINDL5 INX ;Make file name found = file name 0951 F41D BD B2 03 LDAAX INFO ;for subsequent block reads 0952 F420 9D A7 03 STAAX INFILE ;so that OPENIN "" locks onto one filet block. 0953 F423 D0 F7 BNE FINDL5 0954 F425 0955 F425 A9 01 LDAIM INOPEN 0956 F427 20 4F F3 JSR ORSTAT 0957 F42A AD EA 02 LDA INBSZE 0958 F42D 0D EB 02 ORA INBSZE +&01 0959 F430 D0 03 BNE FINDL6 ;If non-empty, don't worry 0960 F432 20 4D F3 JSR ORLST ;Otherwise, at end of file Acorn macro assembler Page 130 C.F.S Main Routines - FIND 0961 F435 0962 F435 A9 01 FINDL6 LDAIM INHAND 0963 F437 0D 47 02 ORA SROMSW ;If in SFS, return 3 0964 F43A D0 39 BNE OPENEX ;Return input handle 0965 F43C 0966 F43C 0967 F43C 0968 F43C 8A FINDO TXA ;Can't openout "" 0969 F43D D0 03 BNE FINABC 0970 F43F 4C 6B EA JMP BADSTR 0971 F442 0972 F442 A2 FF FINABC LDXIM &FF 0973 F444 E8 FINDL2 INX 0974 F445 BD D2 03 LDAAX FILNAM ;Store output file name 0975 F448 9D 80 03 STAAX OUTHDR 0976 F44B D0 F7 BNE FINDL2 0977 F44D 0978 F44D A9 FF LDAIM &FF 0979 F44F A2 08 LDXIM &08 0980 F451 9D 8B 03 FINDL4 STAAX OUTHDR +BKLOAD -&01 0981 F454 CA DEX 0982 F455 D0 FA BNE FINDL4 ;Set load/EXEC address to default value 0983 F457 0984 F457 8A TXA 0985 F458 A2 14 LDXIM BKNOLO 0986 F45A 0987 F45A ;Set block no./block len./last bk. =0 0988 F45A ;Note also sets OUTPTR which must 0989 F45A ;be contiguous with OUTHDR 0990 F45A 0991 F45A 9D 80 03 FINDL3 STAAX OUTHDR 0992 F45D E8 INX 0993 F45E E0 1E CPXIM BKLAST +&01 0994 F460 D0 F8 BNE FINDL3 ;Note carry set 0995 F462 2E 97 03 ROL OUTHDR +BKSZEH ;Set hi byte of size 0996 F465 0997 F465 20 1A FB JSR SETDEF ;If default, print prompt 0998 F468 20 55 F5 JSR RECORD 0999 F46B 20 E5 FA JSR CASMOF ;OFF for putbyte call 1000 F46E 1001 F46E A9 02 LDAIM OUTOPN 1002 F470 20 4F F3 JSR ORSTAT ;Indicate file open for output 1003 F473 1004 F473 A9 02 LDAIM OUTHND 1005 F475 1006 F475 85 BC OPENEX STA TEMP 1007 F477 FINDEX ;Common exit for PUT/GETBYTE and FIND 1008 F477 68 GBEXX PLA 1009 F478 A8 TAY 1010 F479 68 PLA 1011 F47A AA TAX 1012 F47B A5 BC LDA TEMP 1013 F47D FINDXX 1014 F47D 60 RTS 1015 F47E 1016 F47E 1017 F47E 1018 F47E 1019 F47E 1020 F47E 1021 F47E SHUTW 1022 F47E 1023 F47E A9 02 LDAIM OUTHND 1024 F480 25 E2 AND CFSTAT 1025 F482 F0 F9 BEQ FINDXX ;If already shut, dont bother 1026 F484 1027 F484 A9 00 LDAIM &00 1028 F486 8D 97 03 STA OUTHDR +BKSZEH 1029 F489 1030 F489 A9 80 LDAIM LASTBK 1031 F48B AE 9D 03 LDX OUTPTR 1032 F48E 8E 96 03 STX OUTHDR +BKSZEL 1033 F491 8D 98 03 STA OUTHDR +BKFLAG 1034 F494 20 9C F4 JSR WRTBFR ;Write out block 1035 F497 A9 FD LDAIM NOUTHD 1036 F499 4C 48 F3 JMP ANDSTA ;Mark file as closed 1037 F49C 1038 F49C 1039 F49C WRTBFR ;Write out buffer 1040 F49C 1041 F49C 20 0D FB JSR SETSDF ;Set sequential defaults 1042 F49F 1043 F49F A2 11 LDXIM BKLAST -BKLOAD 1044 F4A1 BD 8C 03 WRTBL3 LDAAX OUTHDR +BKLOAD 1045 F4A4 9D BE 03 STAAX INFO +BKLOAD 1046 F4A7 CA DEX 1047 F4A8 10 F7 BPL WRTBL3 1048 F4AA 1049 F4AA ; Set buffer address for WBLOCK call 1050 F4AA 1051 F4AA 86 B2 STX BKADDR +&02 1052 F4AC 86 B3 STX BKADDR +&03 ;Output buffer is in IO proc. 1053 F4AE 1054 F4AE 0000 T * OUTBFR:SHL: 8 1055 F4AE [ T=0 1056 F4AE E8 INX 1057 F4AF 86 B0 STX BKADDR ;If OUTBFR on page boundary, set lo byte = 0 1058 F4B1 | 1061 F4B1 ] 1062 F4B1 1063 F4B1 A9 09 LDAIM /(OUTBFR ) 1064 F4B3 85 B1 STA BKADDR +&01 1065 F4B5 1066 F4B5 A2 7F LDXIM OUTHDR -&01 1067 F4B7 20 74 FB JSR MOVFN ;File name -> FILNAM etc. 1068 F4BA 8D DF 03 STA OLDFLG 1069 F4BD 1070 F4BD 20 81 FB JSR MOTONW ;Motor on and select output drive 1071 F4C0 20 D5 FB JSR BUGFIX 1072 F4C3 20 16 F8 JSR WBLOCK ;Write out block 1073 F4C6 EE 94 03 INC OUTHDR +BKNOLO ;Next block 1074 F4C9 D0 03 BNE WRTBL4 1075 F4CB EE 95 03 INC OUTHDR +BKNOHI 1076 F4CE 60 WRTBL4 RTS 1077 F4CF 1078 F4CF 1079 F4CF 1080 F4CF 1081 F4CF 1082 F4CF 1083 F4CF Acorn macro assembler Page 131 C.F.S Main Routines - FIND 1084 F4CF 1085 F4CF TTL C.F.S. Main Routines - GETBYTE 1086 F4CF OPT &01 1087 F4CF 1088 F4CF 1089 F4CF ;****************** 1090 F4CF ;* G E T B Y T E * 1091 F4CF ;****************** 1092 F4CF 1093 F4CF 1094 F4CF GETBYT 1095 F4CF 1096 F4CF 8A TXA 1097 F4D0 48 PHA 1098 F4D1 98 TYA 1099 F4D2 48 PHA 1100 F4D3 A9 01 LDAIM INHAND 1101 F4D5 20 8F FB JSR CHKHND ;Is handle open ? 1102 F4D8 1103 F4D8 A5 E2 LDA CFSTAT 1104 F4DA 0A ASLA 1105 F4DB B0 4F BCS GBEOF ;=> Going past end of file 1106 F4DD 0A ASLA 1107 F4DE 90 09 BCC GBLF ;=> Not getting last byte 1108 F4E0 1109 F4E0 ;Here indicate next GB call 1110 F4E0 ;goes off end of file 1111 F4E0 1112 F4E0 A9 80 LDAIM EOFBIT 1113 F4E2 20 4F F3 JSR ORSTAT 1114 F4E5 1115 F4E5 ;Carry still set from above 1116 F4E5 1117 F4E5 A9 FE LDAIM ENDBYT ;Byte after end of file 1118 F4E7 B0 38 BCS GBEXY 1119 F4E9 1120 F4E9 AE 9E 03 GBLF LDX INPTR 1121 F4EC E8 INX 1122 F4ED EC EA 02 CPX INBSZE ;Is last byte of buffer ? 1123 F4F0 D0 2A BNE GBLDE ;Nope -> continue 1124 F4F2 1125 F4F2 1126 F4F2 2C EC 02 BIT BUFFLG ;Check if in last block. If so, are reading 1127 F4F5 30 22 BMI GBLH ;last byte of last block => exit 1128 F4F7 1129 F4F7 ;Read last byte of block. NOTE this is kept in a location 1130 F4F7 ;separate from the rest of the block buffer, so that if the 1131 F4F7 ;next block being read aborts and corrupts the block buffer, 1132 F4F7 ;a subsequent retry will still provide the last byte of the 1133 F4F7 ;previous block. The variable FINBYT is updated in RDBFER after 1134 F4F7 ;the background block read has succesfully completed. 1135 F4F7 1136 F4F7 AD ED 02 LDA FINBYT 1137 F4FA 48 PHA ;Store final byte of this block 1138 F4FB 20 0D FB JSR SETSDF ;Set sequential defaults 1139 F4FE 08 PHP ;Store I'rupt status 1140 F4FF 20 DC F6 JSR RDBFER ;Read buffer for next GETBYTE call 1141 F502 28 PLP ;Restore I'rupt status 1142 F503 68 PLA ;Restore final byte of previous buffer 1143 F504 85 BC STA TEMP ;Store for later use 1144 F506 1145 F506 18 CLC ;Prepare for non-end of file exit 1146 F507 2C EC 02 BIT BUFFLG 1147 F50A 10 17 BPL GBEXIT ;Exit, result = TEMP, carry clear 1148 F50C 1149 F50C AD EA 02 LDA INBSZE ;If here, is last block 1150 F50F 0D EB 02 ORA INBSZE +&01 1151 F512 D0 0F BNE GBEXIT ;Last block, is not empty 1152 F514 20 4D F3 JSR ORLST ;If is last block, and empty 1153 F517 D0 0A BNE GBEXIT ;then this is the last byte 1154 F519 ;So set last byte bit and exit, C = 0 1155 F519 1156 F519 GBLH 1157 F519 20 4D F3 JSR ORLST ;Otherwise, reading last byte. 1158 F51C 1159 F51C ;So exit, carry clear 1160 F51C 1161 F51C CA GBLDE DEX 1162 F51D 18 CLC ;Carry clear unless byte AFTER last byte of file 1163 F51E BD 00 0A LDAAX INBUFR ;GET BYTE ! 1164 F521 85 BC GBEXY STA TEMP 1165 F523 EE 9E 03 GBEXIT INC INPTR ;Inc. buffer ptr. for next time 1166 F526 4C 77 F4 JMP GBEXX ;Share exit with PUTBYT 1167 F529 1168 F529 [ MOS125 = &FF 1169 F529 | 1170 F529 COPYR ;here to save a byte 1171 F529 29 = ")" 1172 F52A 43 = "C" 1173 F52B 28 = "(" ;BRK forms terminator 1174 F52C ] 1175 F52C 1176 F52C 00 GBEOF BRK 1177 F52D DF = CFSERD 1178 F52E 45 = "E" 1179 F52F 4F = "O" 1180 F530 46 = "F" 1181 F531 00 = &00 1182 F532 1183 F532 TTL C.F.S. Main Routines - PUTBYTE 1184 F532 OPT &01 1185 F532 1186 F532 1187 F532 ;****************** 1188 F532 ;* P U T B Y T E * 1189 F532 ;****************** 1190 F532 1191 F532 1192 F532 [ MOS125 = &FF 1223 F532 | 1224 F532 PUTBYT 1225 F532 1226 F532 ;Note, IADDR not used in this 1227 F532 ;function coz RX interrupts are "disabled" 1228 F532 ;by TXFLAG (see IRUPT) 1229 F532 1230 F532 48 PHA 1231 F533 8A TXA 1232 F534 48 PHA 1233 F535 98 TYA 1234 F536 48 PHA Acorn macro assembler Page 132 C.F.S. Main Routines - PUTBYTE 1235 F537 A9 02 LDAIM OUTHND 1236 F539 20 8F FB JSR CHKHND ;Check handle open 1237 F53C 1238 F53C BA TSX 1239 F53D BD 03 01 LDAAX &0103 1240 F540 AE 9D 03 LDX OUTPTR 1241 F543 9D 00 09 STAAX OUTBFR 1242 F546 E8 INX 1243 F547 D0 06 BNE PBEXIT ;Test if last byte of buffer 1244 F549 20 9C F4 JSR WRTBFR ;Buffer full, write out. 1245 F54C 20 E5 FA JSR CASMOF 1246 F54F 1247 F54F EE 9D 03 PBEXIT INC OUTPTR 1248 F552 1249 F552 ;Increment pointer after writing block out so that 1250 F552 ;user can retry if block is interrupted 1251 F552 ;by ESCAPE. 1252 F552 1253 F552 4C 60 E1 JMP PLYXAR 1254 F555 ;and now IADDR is not used at all. 1255 F555 ] 1256 F555 1257 F555 1258 F555 1259 F555 1260 F555 LNK MOS74 0001 F555 0002 F555 ;File - MOS74 0003 F555 0004 F555 TTL C.F.S Main Routines - OPT 0005 F555 OPT &01 0006 F555 0007 F555 [ MOS125 = &FF 0037 F555 | 0038 F555 RECORD 0039 F555 0040 F555 AD 47 02 LDA SROMSW 0041 F558 D0 2E BNE OPTERR ;OK if not in SFS 0042 F55A 20 81 FB JSR MOTONW ;Motor ON for OUTPUT 0043 F55D 20 D5 FB JSR BUGFIX 0044 F560 20 37 EA JSR MSGON 0045 F563 F0 45 BEQ RECEXX 0046 F565 0047 F565 20 39 FA JSR MSGOUT ;If messages ON, prompt 0048 F568 52 45 43 = "RECORD then RETURN" 0049 F57A 00 = &00 0050 F57B 0051 F57B 20 88 F9 GETCR1 JSR ESCAPE 0052 F57E 20 E0 FF JSR OSRDCH 0053 F581 C9 0D CMPIM MCR 0054 F583 D0 F6 BNE GETCR1 0055 F585 4C E7 FF JMP OSNEWL 0056 F588 0057 F588 0058 F588 4C 55 E3 OPTERR JMP MBDCMD 0059 F58B 0060 F58B ;Entered with two args in X & Y decoded from 0061 F58B ;command line by MOS. 0062 F58B 0063 F58B E0 03 CFSOPT CPXIM &03 0064 F58D F0 1C BEQ SETGAP 0065 F58F B0 F7 BCS OPTERR 0066 F591 A9 A1 LDAIM DEFLT 0067 F593 C0 03 CPYIM &03 0068 F595 CA DEX 0069 F596 30 10 BMI SETFL1 0070 F598 B0 EE BCS OPTERR 0071 F59A F0 05 BEQ MSGS 0072 F59C ERRS 0073 F59C C8 INY 0074 F59D C8 INY 0075 F59E C8 INY 0076 F59F 49 FF EORIM MSGMSK:EOR:ERRMSK ;Mask out error and default bits 0077 F5A1 49 92 MSGS EORIM DEFLT:EOR:MSGMSK 0078 F5A3 XSETFLG 0079 F5A3 25 E3 AND OPTS 0080 F5A5 19 AF F6 ORAAY OPTTAB 0081 F5A8 SETFL1 0082 F5A8 85 E3 STA OPTS 0083 F5AA RECEXX 0084 F5AA 60 RTS 0085 F5AB ] 0086 F5AB 0087 F5AB 98 SETGAP TYA 0088 F5AC 30 02 BMI SETGP2 ; >127 => default 0089 F5AE D0 02 BNE SETGP1 ; 0 < gap < 128 => OK 0090 F5B0 A9 19 SETGP2 LDAIM DEFGAP 0091 F5B2 8D D1 03 SETGP1 STA SEQGAP 0092 F5B5 60 RTS 0093 F5B6 0094 F5B6 [ MOS125 = &FF 0105 F5B6 ] 0106 F5B6 0107 F5B6 TTL Main Routines - Interrupt routine 0108 F5B6 OPT &01 0109 F5B6 0110 F5B6 IRUPT 0111 F5B6 0112 F5B6 C6 C0 DEC IFLAG 0113 F5B8 AD 47 02 LDA SROMSW ;Is SFS active ? 0114 F5BB F0 06 BEQ NOTSPK ;Nope 0115 F5BD ;GoMMC tape patch has F58D NOP;NOP 0116 F5BD 0117 F5BD 20 6D EE JSR RDSPCH ;Yes, get next byte from ROM 0118 F5C0 [ MOS125 = &FF 0120 F5C0 ] 0121 F5C0 18 CLC ;Clear carry => no DCD 0122 F5C1 90 1A BCC DOIRPT ;Do as per cassette irupt 0123 F5C3 0124 F5C3 AD 08 FE NOTSPK LDA STATUS 0125 F5C6 48 PHA 0126 F5C7 29 02 ANDIM TXBIT 0127 F5C9 F0 0B BEQ ITXON ;No TX interrupt 0128 F5CB A4 CA LDY TXFLAG 0129 F5CD F0 07 BEQ ITXON ;0 => receiving 0130 F5CF 0131 F5CF ;Here, transmiting byte .... 0132 F5CF 0133 F5CF 68 PLA ;Restore stack 0134 F5D0 A5 BD LDA IBUF 0135 F5D2 8D 09 FE STA PORT Acorn macro assembler Page 133 Main Routines - Interrupt routine 0136 F5D5 60 RTS 0137 F5D6 0138 F5D6 0139 F5D6 ITXON 0140 F5D6 0141 F5D6 ;If receiving byte, check IFLAG to see 0142 F5D6 ;where to put it. 0143 F5D6 0144 F5D6 AC 09 FE LDY PORT ;Cancel interrupt 0145 F5D9 68 PLA ;Pull status 0146 F5DA 4A LSRA 0147 F5DB 4A LSRA 0148 F5DC 4A LSRA ;C = 1 => DCD; C = 0 => no DCD 0149 F5DD A6 C2 DOIRPT LDX ITYPE 0150 F5DF F0 67 BEQ IEX ;0 => no task pending 0151 F5E1 0152 F5E1 0153 F5E1 CA DEX 0154 F5E2 D0 06 BNE FNDHDR ;X <> 1 => not DCD task 0155 F5E4 90 62 BCC IEX ;=> DCD Not yet found 0156 F5E6 A0 02 LDYIM &02 0157 F5E8 D0 5C BNE NEWINT ;Go on to look find hdr. 0158 F5EA 0159 F5EA CA FNDHDR DEX 0160 F5EB D0 13 BNE RDCHAR ;X <> 2 => not header task 0161 F5ED B0 59 BCS IEX ;Ignore DCD if present 0162 F5EF 98 TYA ;Get stuff from port 0163 F5F0 20 6B FB JSR SETJOB ;Set CHKSUM etc. 0164 F5F3 A0 03 LDYIM &03 ;New task 0165 F5F5 0166 F5F5 [ GLYN=0 0170 F5F5 ] 0171 F5F5 0172 F5F5 C9 2A CMPIM "*" 0173 F5F7 F0 4D BEQ NEWINT ;Set read chars 0174 F5F9 20 43 FB JSR RXINIT ;Reset ULA (should be BLIP) 0175 F5FC A0 01 LDYIM &01 0176 F5FE D0 46 BNE NEWINT ;Otherwise, wait for DCD 0177 F600 0178 F600 CA RDCHAR DEX 0179 F601 D0 0A BNE RDBLK ;X <> 3 => not RDCHAR task 0180 F603 B0 03 BCS GOTDCD ;DCD found, not char 0181 F605 84 BD STY IBUF ;Store char read 0182 F607 [ MOS125 = &FF 0184 F607 | 0185 F607 60 RTS 0186 F608 ] 0187 F608 A9 80 GOTDCD LDAIM &80 0188 F60A 85 C0 STA IFLAG ;Indicate DCD 0189 F60C [ MOS125 = &FF 0191 F60C | 0192 F60C 60 RTS 0193 F60D ] 0194 F60D 0195 F60D CA RDBLK DEX ;X <> 4=> not RDBLK 0196 F60E D0 29 BNE SUMIN 0197 F610 B0 2F BCS IFIN ;If DCD, finish immediately 0198 F612 98 TYA 0199 F613 20 E0 F7 JSR ADDCRC 0200 F616 A4 BC LDY TEMP ;(pointer) 0201 F618 E6 BC INC TEMP 0202 F61A 24 BD BIT IBUF 0203 F61C 30 0D BMI RDBLKA ;=> just verify, don't store 0204 F61E 0205 F61E [ TUBESW=0 0206 F61E 20 C6 FB JSR TUBCHK ;Check tube present and top bytes of address 0207 F621 F0 05 BEQ RDBLKB ;No need to tube. (NOTE TUBCHK DOES TAX to preserve A) 0208 F623 0209 F623 8E E5 FE STX TREG3 ;Otherwise, push to tube R3 0210 F626 D0 03 BNE RDBLKA ;And continue 0211 F628 0212 F628 8A RDBLKB TXA 0213 F629 91 B0 STAIY BKADDR ;Store in IO proc. 0214 F62B | 0216 F62B ] 0217 F62B 0218 F62B C8 RDBLKA INY 0219 F62C CC C8 03 CPY INFO +BKSZEL ;** 1 BYTE SIZE ONLY ** 0220 F62F D0 17 BNE IEX ;Keep going 0221 F631 0222 F631 ;Have here finished reading data, so 0223 F631 ;read two more bytes of CRC without storing 0224 F631 0225 F631 A9 01 LDAIM &01 ;Set counter 0226 F633 85 BC STA TEMP 0227 F635 A0 05 LDYIM &05 0228 F637 D0 0D BNE NEWINT 0229 F639 0230 F639 0231 F639 SUMIN 0232 F639 0233 F639 ;Here, assumed X = 5 0234 F639 0235 F639 98 TYA 0236 F63A 20 E0 F7 JSR ADDCRC 0237 F63D C6 BC DEC TEMP 0238 F63F 10 07 BPL IEX ;One more to go 0239 F641 0240 F641 ;If here, finished, so mark BG job finished 0241 F641 0242 F641 20 39 FB IFIN JSR CRESET 0243 F644 A0 00 LDYIM &00 0244 F646 84 C2 NEWINT STY ITYPE 0245 F648 60 IEX RTS 0246 F649 0247 F649 TTL C.F.S. Main routines - EOF 0248 F649 OPT MOS74 Acorn macro assembler Page 134 C.F.S. Main routines - EOF 0249 F649 0250 F649 48 CFSEOF PHA ;First store Y and A 0251 F64A 98 TYA 0252 F64B 48 PHA 0253 F64C 8A TXA ;Transfer handle to Y 0254 F64D A8 TAY ;for checking. 0255 F64E A9 03 LDAIM HNDS ;Both handles 0256 F650 20 8F FB JSR CHKHND ;NOTE - CORRUPTS Y 0257 F653 0258 F653 A5 E2 LDA CFSTAT 0259 F655 29 40 ANDIM LSTBYT 0260 F657 AA TAX ;Result (zero or non-zero) in X 0261 F658 68 PLA 0262 F659 A8 TAY 0263 F65A 68 PLA ;Restore A and Y 0264 F65B 60 RTS 0265 F65C 0266 F65C TTL C.F.S. UTILITIES - MOS74 0267 F65C OPT &01 0268 F65C 0269 F65C ;****** CASSETTE UTILITIES ****** 0270 F65C 0271 F65C 0272 F65C A9 00 SRCH0 LDAIM &00 0273 F65E 85 B4 STA BLOKNO 0274 F660 85 B5 STA BLOKNO +&01 0275 F662 0276 F662 SEARCH 0277 F662 0278 F662 0279 F662 ;File title pointed to by FTPTR. 0280 F662 ;Block number in BLOKNO. 0281 F662 0282 F662 ;Tool through tape until found. If messages 0283 F662 ;on, print header info and checksum messages. 0284 F662 0285 F662 A5 B4 LDA BLOKNO 0286 F664 48 PHA 0287 F665 85 B6 STA SRCHBK 0288 F667 A5 B5 LDA BLOKNO +&01 0289 F669 48 PHA 0290 F66A 85 B7 STA SRCHBK +&01 ;Set block to search for 0291 F66C 20 39 FA JSR MSGOUT 0292 F66F 53 65 61 = "Searching",MCR,&00 0293 F67A A9 FF LDAIM &FF ;=> search and validate 0294 F67C 20 53 F3 JSR LOOK 0295 F67F 68 PLA 0296 F680 85 B5 STA BLOKNO +&01 0297 F682 68 PLA 0298 F683 85 B4 STA BLOKNO 0299 F685 A5 B6 LDA SRCHBK 0300 F687 05 B7 ORA SRCHBK+&01 0301 F689 D0 0D BNE SRCHXX 0302 F68B 0303 F68B ;If finding first block, set next expected 0304 F68B ;block to zero so that a load will not 0305 F68B ;fail because of a new file breaking into 0306 F68B ;a previous one thus causing non-sequential 0307 F68B ;blocks and therefore a block? error. 0308 F68B 0309 F68B 85 B4 STA BLOKNO ;If first block, no block error 0310 F68D 85 B5 STA BLOKNO +&01 0311 F68F 0312 F68F ;Check header CRC so that we only latch 0313 F68F ;onto non-corrupt file names 0314 F68F 0315 F68F A5 C1 LDA HDRCRC 0316 F691 D0 05 BNE SRCHXX 0317 F693 A2 B1 LDXIM INFO -&01 ;Make sure looking for 0318 F695 20 74 FB JSR MOVFN ;file name found in subsequent blocks 0319 F698 SRCHXX ;Check if run off the end of SROM system 0320 F698 0321 F698 AD 47 02 LDA SROMSW 0322 F69B F0 18 BEQ SRCHYY ;In CFS, carry on 0323 F69D 70 16 BVS SRCHYY ;Not end of ROM => continue 0324 F69F FNF 0325 F69F 00 BRK 0326 F6A0 D6 = SFSER1 0327 F6A1 [ MOS125 = &FF 0329 F6A1 | 0330 F6A1 46 69 6C = "File not found" 0331 F6AF OPTTAB 0332 F6AF 00 = &00 ;Messages off 0333 F6B0 88 = MSGS1 ;Short messages 0334 F6B1 CC = MSGS2 ;Long messages 0335 F6B2 00 = IGBIT 0336 F6B3 22 = RETBIT 0337 F6B4 11 = ABTBIT 0338 F6B5 ] 0339 F6B5 0340 F6B5 A0 FF SRCHYY LDYIM &FF ;For LOAD and RDBFER 0341 F6B7 8C DF 03 STY OLDFLG ;Fool PRTHDR to print 0342 F6BA ;extra blank line after "Loading" message 0343 F6BA 60 RTS 0344 F6BB 0345 F6BB 0346 F6BB ECLOSE ;close EXEC file 0347 F6BB 0348 F6BB A9 00 LDAIM ZERO 0349 F6BD ; 0350 F6BD EXEC ; EXEC 0351 F6BD 0352 F6BD ; XY -> filename 0353 F6BD ; A = $00 0354 F6BD ; 0355 F6BD ; does not corrupt Y if just closing file (used by SHUTES) 0356 F6BD ; 0357 F6BD 08 PHP ;remember whether to just close exec file 0358 F6BE 84 E6 STY EXECY ;save Y 0359 F6C0 ; close any previous exec file 0360 F6C0 AC 56 02 LDY EXECH 0361 F6C3 8D 56 02 STA EXECH ;clear execing 0362 F6C6 F0 03 BEQ EXEC2 ;[no current exec file, avoid closing all files] 0363 F6C8 ; A=0 0364 F6C8 20 CE FF JSR OSFIND ;close previous exec file (assumes X not corrupted) 0365 F6CB EXEC2 0366 F6CB A4 E6 LDY EXECY ;restore Y 0367 F6CD 28 PLP 0368 F6CE F0 0B BEQ EXEC0 ;[just stop execing] 0369 F6D0 ; try opening specified file 0370 F6D0 A9 40 LDAIM &40 ;open file for input Acorn macro assembler Page 135 C.F.S. UTILITIES - MOS74 0371 F6D2 20 CE FF JSR OSFIND 0372 F6D5 A8 TAY 0373 F6D6 F0 C7 BEQ FNF ;[file not found] 0374 F6D8 8D 56 02 STA EXECH ;remember exec file handle 0375 F6DB EXEC0 ;Z=1 0376 F6DB 60 RTS 0377 F6DC 0378 F6DC 0379 F6DC RDBFER 0380 F6DC 0381 F6DC 0382 F6DC ;Read a block into input buffer. Used in GETBYTE 0383 F6DC 0384 F6DC A2 A6 LDXIM INFILE -&01 0385 F6DE 20 74 FB JSR MOVFN ;Set file searching for 0386 F6E1 20 AB F7 JSR RDHEAD 0387 F6E4 0388 F6E4 RDBFRS 0389 F6E4 0390 F6E4 AD CA 03 LDA INFO +BKFLAG ;Check protection bit 0391 F6E7 4A LSRA 0392 F6E8 90 03 BCC RDBFLL ;Not protected -> continue 0393 F6EA 4C 95 F2 JMP PROTER ;Protected -> error 0394 F6ED 0395 F6ED AD DD 03 RDBFLL LDA NEXTIN 0396 F6F0 85 B4 STA BLOKNO 0397 F6F2 AD DE 03 LDA NEXTIN +&01 0398 F6F5 85 B5 STA BLOKNO +&01 ;Set block no. to check 0399 F6F7 0400 F6F7 A9 00 LDAIM INBUFR 0401 F6F9 85 B0 STA BKADDR 0402 F6FB A9 0A LDAIM /(INBUFR ) 0403 F6FD 85 B1 STA BKADDR +&01 0404 F6FF A9 FF LDAIM &FF 0405 F701 85 B2 STA BKADDR +&02 0406 F703 85 B3 STA BKADDR +&03 ;Input buffer is in IO proc. 0407 F705 20 FF F7 JSR READBK ;Read data into buffer 0408 F708 20 A7 F9 JSR LODHDR 0409 F70B D0 25 BNE RDBERR 0410 F70D 0411 F70D ;Data read ok, inc. next expected block. 0412 F70D 0413 F70D AD FF 0A LDA INBUFR +&FF 0414 F710 8D ED 02 STA FINBYT ;Store final byte of this buffer in safe place 0415 F713 0416 F713 20 5C FB JSR NXTBLK ;Next block = current block + 1 0417 F716 ;NOTE - corrupts BLOKNO 0418 F716 0419 F716 8E DD 03 STX NEXTIN 0420 F719 8C DE 03 STY NEXTIN +&01 0421 F71C 0422 F71C A2 02 LDXIM &02 0423 F71E 0424 F71E ;Set block size and flag byte 0425 F71E 0426 F71E BD C8 03 RDBFL1 LDAAX INFO +BKSZEL 0427 F721 9D EA 02 STAAX INBSZE 0428 F724 CA DEX 0429 F725 10 F7 BPL RDBFL1 0430 F727 2C EC 02 BIT BUFFLG 0431 F72A 10 03 BPL RDBFL8 0432 F72C 20 E6 F2 JSR NOOLN1 ;If last block, new line 0433 F72F 0434 F72F 4C E5 FA RDBFL8 JMP CASMOF ;Motor off, exit 0435 F732 0436 F732 ;From here down, dealing with errors 0437 F732 0438 F732 RDBERR 0439 F732 0440 F732 ;Retry - search for block number, and 0441 F732 ;then go back to RDBFRS. 0442 F732 0443 F732 20 62 F6 JSR SEARCH ;FTPTR already set by RDHEAD. 0444 F735 D0 AD BNE RDBFRS ;Restart (always jump back) 0445 F737 0446 F737 0447 F737 0448 F737 0449 F737 0450 F737 C9 2A RDHDLC CMPIM "*" 0451 F739 F0 37 BEQ RDHDLA ;Char OK, go on to rest of block 0452 F73B C9 23 CMPIM "#" ;Is this a short header ?? 0453 F73D D0 0F BNE ROMER ;No -> illegal char -> error 0454 F73F EE C6 03 INC INFO +BKNOLO ;Have "read" short block header, so 0455 F742 D0 03 BNE RDHDX2 ;increment block number as if we have read whole header 0456 F744 EE C7 03 INC INFO +BKNOHI 0457 F747 A2 FF RDHDX2 LDXIM &FF ;Prepare for non-DCD exit 0458 F749 2C 49 D9 BIT FFBYT ;Set the V flag => not end of SFS 0459 F74C D0 55 BNE RDHDX1 ;Assumed always +ve 0460 F74E 0461 F74E A9 F7 ROMER LDAIM NCTBIT 0462 F750 0463 F750 ;Switch CAT bit off so messages not in a funny 0464 F750 ;state if error occurs in *CAT 0465 F750 0466 F750 20 48 F3 JSR ANDSTA 0467 F753 00 BRK 0468 F754 D7 = SFSERR 0469 F755 42 61 64 = "Bad ROM" 0470 F75C 00 = &00 0471 F75D 0472 F75D RDHDL2 0473 F75D 0474 F75D ;Here, set motor on and 6850 init etc. 0475 F75D 0476 F75D A0 FF LDYIM READFX ;Indicate read 0477 F75F 20 83 FB JSR MOTON ;Motor ON and drive select 0478 F762 A9 01 LDAIM &01 0479 F764 85 C2 STA ITYPE 0480 F766 20 43 FB JSR RXINIT ;Init 6850 and blip motor 0481 F769 0482 F769 ;Wait for DCD and '* character indicating 0483 F769 ;start of block. 0484 F769 0485 F769 20 88 F9 GETHLP JSR ESCAPE 0486 F76C A9 03 LDAIM &03 0487 F76E C5 C2 CMP ITYPE 0488 F770 D0 F7 BNE GETHLP 0489 F772 0490 F772 A0 00 RDHDLA LDYIM &00 0491 F774 20 6F FB JSR SETJB1 ;Set cheksum etc. Acorn macro assembler Page 136 C.F.S. UTILITIES - MOS74 0492 F777 0493 F777 20 C7 F7 RDHDL1 JSR CASIN ;Read and add to checksum 0494 F77A 50 1A BVC RDHDEX ;Header interrupted by DCD 0495 F77C 99 B2 03 STAAY INFO ;Store in INFO 0496 F77F F0 06 BEQ RDHDL3 ;End of file title (Z set in CASIN) 0497 F781 C8 INY 0498 F782 C0 0B CPYIM FTSIZE ;Attempting to read over f.t. end 0499 F784 D0 F1 BNE RDHDL1 ;No, => continue 0500 F786 88 DEY 0501 F787 0502 F787 A2 0C RDHDL3 LDXIM BKINFO ;Now read all info. 0503 F789 20 C7 F7 RDHDL4 JSR CASIN 0504 F78C 50 08 BVC RDHDEX ;Header interrupted by DCD 0505 F78E 9D B2 03 STAAX INFO 0506 F791 E8 INX 0507 F792 E0 1F CPXIM BKLAST +&02 0508 F794 D0 F3 BNE RDHDL4 0509 F796 0510 F796 98 RDHDEX TYA 0511 F797 AA TAX ;Preserve Y for exit 0512 F798 A9 00 LDAIM &00 0513 F79A 99 B2 03 STAAY INFO ;Terminate f.t. 0514 F79D A5 BE LDA CHKSUM 0515 F79F 05 BF ORA CHKSUM +&01 0516 F7A1 85 C1 STA HDRCRC ;Store CRC indication 0517 F7A3 20 6B FB RDHDX1 JSR SETJOB 0518 F7A6 84 C2 STY ITYPE ;If header interrupted => block fin. 0519 F7A8 0520 F7A8 8A TXA 0521 F7A9 D0 1B BNE RDHDXX 0522 F7AB 0523 F7AB RDHEAD 0524 F7AB 0525 F7AB ;Read header info into INFO. Check file title 0526 F7AB ;against FTPTR, and print header info. 0527 F7AB 0528 F7AB ;First, wait for DCD followed by "*" 0529 F7AB 0530 F7AB AD 47 02 LDA SROMSW 0531 F7AE F0 AD BEQ RDHDL2 ;SFS not enabled, carry on 0532 F7B0 ;GoMMC tape patch has F77E NOP;NOP 0533 F7B0 0534 F7B0 ;Here, SFS enabled, so read first char 0535 F7B0 ;(assumed to be "*") and go on to read 0536 F7B0 ;rest of block. 0537 F7B0 0538 F7B0 RDHDLD 0539 F7B0 20 6D EE JSR RDSPCH 0540 F7B3 C9 2B CMPIM SFSEND ;Is "end of ROM" char ? 0541 F7B5 D0 80 BNE RDHDLC 0542 F7B7 A9 08 LDAIM CATBIT 0543 F7B9 25 E2 AND CFSTAT 0544 F7BB F0 03 BEQ RDHDL5 ;If not in CAT, don't do new line 0545 F7BD 0546 F7BD 20 EA F2 JSR NOOLIN ;New line between ROMs 0547 F7C0 20 30 EE RDHDL5 JSR SRNEXT 0548 F7C3 0549 F7C3 ;Carry clear => not at end of filing system, so 0550 F7C3 ;read next character, assumed still to be start 0551 F7C3 ;of header although in new rom. 0552 F7C3 0553 F7C3 90 EB BCC RDHDLD 0554 F7C5 0555 F7C5 ;Carry set => end of filing system, so 0556 F7C5 ;indicate to outside world in V flag 0557 F7C5 B8 CLV 0558 F7C6 [ MOS125 = &FF 0559 F7C6 | 0560 F7C6 RDHDXX 0561 F7C6 ] 0562 F7C6 60 RTS 0563 F7C7 0564 F7C7 ;Note assumed exit with Y = 0 0565 F7C7 ;for LOAD and RDBFRS 0566 F7C7 0567 F7C7 0568 F7C7 0569 F7C7 0570 F7C7 0571 F7C7 CASIN 0572 F7C7 AD 47 02 LDA SROMSW ;is SFS on ? 0573 F7CA F0 11 BEQ CASIN1 ;Nope, read from tape 0574 F7CC ;GoMMC tape patch has F79A NOP;NOP 0575 F7CC 0576 F7CC ;Force a read from ROM & set IRUPT flag 0577 F7CC 0578 F7CC 8A TXA 0579 F7CD 48 PHA 0580 F7CE 98 TYA 0581 F7CF 48 PHA 0582 F7D0 20 6D EE JSR RDSPCH 0583 F7D3 85 BD STA IBUF 0584 F7D5 A9 FF LDAIM &FF 0585 F7D7 85 C0 STA IFLAG ;=> irupt occurred, no DCD 0586 F7D9 68 PLA 0587 F7DA A8 TAY 0588 F7DB 68 PLA 0589 F7DC AA TAX 0590 F7DD 0591 F7DD 20 A9 F8 CASIN1 JSR IWAIT 0592 F7E0 0593 F7E0 ;Note A=IBUF after IWAIT 0594 F7E0 0595 F7E0 [ DEBUG=0 0601 F7E0 ] 0602 F7E0 0603 F7E0 [ MOS125 = &FF 0633 F7E0 | 0634 F7E0 ;Can't move to MOS05 to branch to OCSREX, fallthrough from CASIN1! 0635 F7E0 08 ADDCRC PHP 0636 F7E1 48 PHA 0637 F7E2 0638 F7E2 0021 CCITTL * &21 0639 F7E2 0010 CCITTH * &10 0640 F7E2 0641 F7E2 45 BF EOR CHKSUM +&01 0642 F7E4 38 SEC 0643 F7E5 66 BF ROR CHKSUM +&01 0644 F7E7 06 BE CRC1 ASL CHKSUM 0645 F7E9 2A ROLA 0646 F7EA 90 0A BCC CRC2 Acorn macro assembler Page 137 C.F.S. UTILITIES - MOS74 0647 F7EC 48 PHA 0648 F7ED A5 BE LDA CHKSUM 0649 F7EF 49 21 EORIM CCITTL 0650 F7F1 85 BE STA CHKSUM 0651 F7F3 68 PLA 0652 F7F4 49 10 EORIM CCITTH 0653 F7F6 46 BF CRC2 LSR CHKSUM +&01 0654 F7F8 D0 ED BNE CRC1 0655 F7FA 85 BF STA CHKSUM +&01 0656 F7FC 68 PLA 0657 F7FD 28 PLP 0658 F7FE 60 RTS 0659 F7FF ] 0660 F7FF 0661 F7FF 0662 F7FF 0663 F7FF 0664 F7FF RDBLOK 0665 F7FF 0666 F7FF READBK 0667 F7FF 0668 F7FF ;Sets up BG job to read data into BKADDR 0669 F7FF ;and read CRC. 0670 F7FF 0671 F7FF ;Note: must not corrupt Y ! 0672 F7FF 0673 F7FF A9 00 LDAIM &00 0674 F801 85 BD CHKBIN STA IBUF ;Indicate read to memory 0675 F803 A2 00 LDXIM &00 0676 F805 86 BC STX TEMP ;Pointer into data 0677 F807 ;If empty, data read finished, X=$00 0678 F807 50 0A BVC RDBKEM ;If V clear from header read 0679 F809 ;just ignore all data (since hdr. 0680 F809 ;interrupted by DCD). 0681 F809 0682 F809 AD C8 03 LDA INFO +BKSZEL 0683 F80C 0D C9 03 ORA INFO +BKSZEH 0684 F80F F0 02 BEQ RDBKEM ;Empty block => no BG job 0685 F811 0686 F811 A2 04 LDXIM &04 0687 F813 86 C2 RDBKEM STX ITYPE 0688 F815 0689 F815 ;V not important from here on 0690 F815 0691 F815 60 RTS 0692 F816 0693 F816 0694 F816 0695 F816 0696 F816 WRBLOK 0697 F816 0698 F816 WBLOCK 0699 F816 0700 F816 ;Write block pointed to by BKADDR. Expects header info 0701 F816 ;to be in INFO and file name in FILNAM. 0702 F816 0703 F816 ;Assumes 6850 is in reset state, and SERPROC 0704 F816 ;is set with motor on. 0705 F816 0706 F816 08 PHP ;Save I'rupt state 0707 F817 A2 03 LDXIM &03 ;Set spare bytes 0708 F819 A9 00 LDAIM &00 0709 F81B 9D CB 03 SETSPR STAAX INFO +BKSPAR 0710 F81E CA DEX 0711 F81F 10 FA BPL SETSPR 0712 F821 0713 F821 AD C6 03 LDA INFO +BKNOLO 0714 F824 0D C7 03 ORA INFO +BKNOHI 0715 F827 D0 05 BNE WRBKL5 ;Not first block, continue 0716 F829 20 B7 F8 JSR LEADER 0717 F82C F0 03 BEQ WRBKL4 ;Always Z exit 0718 F82E 0719 F82E 20 BB F8 WRBKL5 JSR PUTGAP ;Put out inter-block gap 0720 F831 0721 F831 A9 2A WRBKL4 LDAIM "*" 0722 F833 85 BD STA IBUF ;Start of block char is output IMMEDIATELY 0723 F835 ;on TXINIT. 0724 F835 0725 F835 20 6B FB JSR SETJOB 0726 F838 0727 F838 20 3D FB JSR TXINIT ;Get 6850 ready 0728 F83B 20 A9 F8 JSR IWAIT ;Wait for * to go out 0729 F83E 0730 F83E 88 DEY ;Set zero by SETJOB 0731 F83F C8 WRBKL1 INY 0732 F840 B9 D2 03 LDAAY FILNAM ;Set Z flag if file terminator 0733 F843 99 B2 03 STAAY INFO ;PRTHDR expects INFO to have f.t. in it 0734 F846 20 54 F0 JSR PUTCHK 0735 F849 0736 F849 ;Note Z flag kept over PUTCHK 0737 F849 0738 F849 D0 F4 BNE WRBKL1 ;File title out. 0739 F84B 0740 F84B A2 0C LDXIM BKINFO 0741 F84D BD B2 03 WRBKL2 LDAAX INFO ;Rest of header to tape 0742 F850 20 54 F0 JSR PUTCHK 0743 F853 E8 INX 0744 F854 E0 1D CPXIM BKLAST 0745 F856 D0 F5 BNE WRBKL2 0746 F858 0747 F858 20 A0 F8 JSR PUTCRC 0748 F85B 0749 F85B AD C8 03 LDA INFO +BKSZEL 0750 F85E 0D C9 03 ORA INFO +BKSZEH 0751 F861 F0 1D BEQ WRBKEM ;Empty block 0752 F863 0753 F863 A0 00 LDYIM &00 0754 F865 20 6F FB JSR SETJB1 0755 F868 WRBKL3 0756 F868 [ MOS125 = &FF 0768 F868 | 0769 F868 [ TUBESW=0 0770 F868 20 C6 FB JSR TUBCHK ;Check tube present and top two bytes of address 0771 F86B F0 05 BEQ WRBKL6 ;Yes, continue. (Note TAX done in TUBCHK) 0772 F86D AD E5 FE LDA TREG3 ;No, get from tube 0773 F870 90 02 BCC WRBKL7 ;skip IO read (always; TUBCHK returns CC if Tube) 0774 F872 0775 F872 WRBKL6 0776 F872 B1 B0 LDAIY BKADDR ;Load byte from IO proc. 0777 F874 WRBKL7 0778 F874 | Acorn macro assembler Page 138 C.F.S. UTILITIES - MOS74 0780 F874 ] 0781 F874 ] 0782 F874 0783 F874 20 54 F0 JSR PUTCHK ;Output data 0784 F877 C8 INY 0785 F878 CC C8 03 CPY INFO +BKSZEL 0786 F87B D0 EB BNE WRBKL3 0787 F87D 0788 F87D 20 A0 F8 JSR PUTCRC 0789 F880 20 A9 F8 WRBKEM JSR IWAIT ;Wait for irupt => char on tape 0790 F883 20 A9 F8 JSR IWAIT 0791 F886 20 39 FB JSR CRESET ;Reset for interblock gap 0792 F889 A9 01 LDAIM &01 0793 F88B 20 BD F8 JSR PAUSE ;1/10 sec delay to clear heads 0794 F88E 28 PLP ;Restore I'rupt status 0795 F88F 0796 F88F 20 DE F8 JSR SAVHDR ;Finally, print info 0797 F892 2C CA 03 BIT INFO +BKFLAG 0798 F895 10 08 BPL WRBKEX ;Not last block 0799 F897 08 PHP 0800 F898 20 B7 F8 JSR TAIL 0801 F89B 20 E3 F2 JSR FINOP 0802 F89E 28 PLP 0803 F89F 0804 F89F ;Exit MI if last block, PL otherwise 0805 F89F 60 WRBKEX RTS 0806 F8A0 0807 F8A0 0808 F8A0 0809 F8A0 0810 F8A0 0811 F8A0 0812 F8A0 [ MOS125 = &FF 0819 F8A0 ] 0820 F8A0 0821 F8A0 0822 F8A0 0823 F8A0 0824 F8A0 A5 BF PUTCRC LDA CHKSUM +&01 0825 F8A2 20 A7 F8 JSR PUTCAS 0826 F8A5 A5 BE LDA CHKSUM 0827 F8A7 0828 F8A7 0829 F8A7 PUTCAS 0830 F8A7 0831 F8A7 ;Put byte to cassette 0832 F8A7 0833 F8A7 85 BD STA IBUF 0834 F8A9 0835 F8A9 20 88 F9 IWAIT JSR ESCAPE 0836 F8AC 24 C0 BIT IFLAG 0837 F8AE 10 F9 BPL IWAIT 0838 F8B0 0839 F8B0 A9 00 LDAIM &00 0840 F8B2 85 C0 STA IFLAG ;Zero IFLAG 0841 F8B4 A5 BD LDA IBUF ;Restore A 0842 F8B6 60 RTS ;Note V preserved 0843 F8B7 0844 F8B7 0845 F8B7 0846 F8B7 LEADER 0847 F8B7 0848 F8B7 TAIL 0849 F8B7 0850 F8B7 ;Assumes RESET done by WRBLOK 0851 F8B7 0852 F8B7 A9 32 LDAIM &32 0853 F8B9 D0 02 BNE PAUSE ;5 secs hitone altogether. 0854 F8BB 0855 F8BB 0856 F8BB 0857 F8BB PUTGAP 0858 F8BB 0859 F8BB ;Note is assumed indivisible by PUTBYT 0860 F8BB 0861 F8BB A5 C7 LDA GAPTIM 0862 F8BD 0863 F8BD PAUSE 0864 F8BD 0865 F8BD ;Pause for A/10 secs (while putting out 0866 F8BD ;leaders and gaps mainly). 0867 F8BD 0868 F8BD A2 05 LDXIM &05 0869 F8BF 8D 40 02 PSLOP1 STA CYCLE 0870 F8C2 20 88 F9 PSLOOP JSR ESCAPE 0871 F8C5 2C 40 02 BIT CYCLE 0872 F8C8 10 F8 BPL PSLOOP 0873 F8CA CA DEX 0874 F8CB D0 F2 BNE PSLOP1 0875 F8CD 60 RTS 0876 F8CE 0877 F8CE 0878 F8CE 0879 F8CE PRTHDR 0880 F8CE 0881 F8CE ;Print header details. 0882 F8CE ;Keeps count of file size and prints 0883 F8CE ;total file length when last block is indicated. 0884 F8CE ;Expects block info to be in INFO. 0885 F8CE 0886 F8CE 0887 F8CE AD C6 03 LDA INFO +BKNOLO 0888 F8D1 0D C7 03 ORA INFO +BKNOHI 0889 F8D4 F0 05 BEQ PRTHL8 ;If first block, is new file 0890 F8D6 2C DF 03 BIT OLDFLG ;If previous block = last block 0891 F8D9 10 03 BPL PRTHL3 ;then new line 0892 F8DB 0893 F8DB PRTHDL 0894 F8DB 20 E6 F2 PRTHL8 JSR NOOLN1 ;New line if messages on and no error 0895 F8DE 0896 F8DE SAVHDR 0897 F8DE 0898 F8DE ;Entry from WRBLOK 0899 F8DE 0900 F8DE [ MOS125 = &7F 0901 F8DE ;Set FSIZE here for correct OSFILE block whether messages on/off 0902 F8DE PRTHL3 0903 F8DE AD C8 03 LDA INFO +BKSZEL 0904 F8E1 85 CC STA FSIZE 0905 F8E3 AD C6 03 LDA INFO +BKNOLO 0906 F8E6 18 CLC Acorn macro assembler Page 139 C.F.S. UTILITIES - MOS74 0907 F8E7 6D C9 03 ADC INFO +BKSZEH 0908 F8EA 85 CD STA FSIZE + 1 0909 F8EC A0 00 LDYIM &00 0910 F8EE | 0912 F8EE ] 0913 F8EE 84 BA STY ERRSW 0914 F8F0 AD CA 03 LDA INFO +BKFLAG 0915 F8F3 8D DF 03 STA OLDFLG ;Set prev. flag 0916 F8F6 0917 F8F6 0918 F8F6 20 37 EA JSR MSGON 0919 F8F9 F0 61 BEQ PRTHLX ;Messages off => exit 0920 F8FB 0921 F8FB [ MOS125 = &FF 0924 F8FB | 0925 F8FB 20 EC FF JSR WRCR 0926 F8FE ] 0927 F8FE 0928 F8FE ; Note assumed here Y is preserved over 0929 F8FE ;calls to MSGON and OSWRCH. 0930 F8FE 0931 F8FE B9 B2 03 PRTHL1 LDAAY INFO 0932 F901 F0 10 BEQ PRTHL2 ;Zero terminator for filename 0933 F903 0934 F903 C9 20 CMPIM &20 0935 F905 90 04 BCC PRTHLD ;A<$20 => control char => invalid 0936 F907 C9 7F CMPIM &7F 0937 F909 90 02 BCC PRTHLC ;$20<=A<$7F => Valid 0938 F90B 0939 F90B A9 3F PRTHLD LDAIM "?" ;Otherwise, print ?? 0940 F90D 20 EE FF PRTHLC JSR OSWRCH ;Write file title 0941 F910 C8 INY 0942 F911 D0 EB BNE PRTHL1 0943 F913 0944 F913 AD 47 02 PRTHL2 LDA SROMSW 0945 F916 F0 04 BEQ PRTHLF ;In CFS -> continue 0946 F918 24 BB BIT USFLGS 0947 F91A 50 40 BVC PRTHLX ;SFS short msgs => file name only 0948 F91C 0949 F91C 20 84 F9 PRTHLF JSR PRTSP 0950 F91F C8 INY 0951 F920 C0 0B CPYIM FTSIZE 0952 F922 90 EF BCC PRTHL2 0953 F924 0954 F924 AD C6 03 LDA INFO +BKNOLO 0955 F927 AA TAX ;Store for final length 0956 F928 20 6D F9 JSR WHEX ;Write block no. lo 0957 F92B 0958 F92B 2C CA 03 BIT INFO +BKFLAG 0959 F92E 10 2C BPL PRTHLX ;Not last block -> finish 0960 F930 0961 F930 ;Here, is last block -> print total length 0962 F930 0963 F930 [ MOS125 = &7F 0964 F930 A5 CD LDA FSIZE + 1 0965 F932 20 68 F9 JSR WSPHEX 0966 F935 A5 CC LDA FSIZE 0967 F937 | 0979 F937 ] 0980 F937 20 6D F9 JSR WHEX 0981 F93A 0982 F93A 24 BB BIT USFLGS 0983 F93C 50 1E BVC PRTHLX ;=> Short messages => exit 0984 F93E 0985 F93E ;Here doing long messages 0986 F93E 0987 F93E A2 04 LDXIM &04 0988 F940 20 84 F9 PRTHLV JSR PRTSP 0989 F943 CA DEX 0990 F944 D0 FA BNE PRTHLV 0991 F946 0992 F946 A2 0F LDXIM BKLOAD +&03 0993 F948 20 50 F9 JSR PRTHLT 0994 F94B 20 84 F9 JSR PRTSP 0995 F94E A2 13 LDXIM BKEXEC +&03 0996 F950 0997 F950 A0 04 PRTHLT LDYIM &04 0998 F952 BD B2 03 PRTHLU LDAAX INFO 0999 F955 20 6D F9 JSR WHEX 1000 F958 CA DEX 1001 F959 88 DEY 1002 F95A D0 F6 BNE PRTHLU 1003 F95C 1004 F95C [ MOS125 = &FF 1006 F95C ] 1007 F95C 60 PRTHLX RTS 1008 F95D 1009 F95D 1010 F95D 1011 F95D 1012 F95D [ MOS125 = &FF 1034 F95D ] 1035 F95D 1036 F95D 1037 F95D LNK MOS76 0001 F95D 0002 F95D TTL C.F.S. - I/O Utilities -> MOS76 0003 F95D OPT MOS76 Acorn macro assembler Page 140 C.F.S. - I/O Utilities -> MOS76 0004 F95D 0005 F95D 0006 F95D ;****** UTILITIES II ****** 0007 F95D 0008 F95D ADDBKA 0009 F95D 0010 F95D ;Increment block pointer by 256 bytes, assuming that 0011 F95D ;block received is 256 bytes long. Note BKADDR is 4 bytes 0012 F95D 0013 F95D E6 B1 INC BKADDR +&01 0014 F95F D0 06 BNE ADDBK1 0015 F961 E6 B2 INC BKADDR +&02 0016 F963 D0 02 BNE ADDBK1 0017 F965 E6 B3 INC BKADDR +&03 0018 F967 60 ADDBK1 RTS 0019 F968 0020 F968 0021 F968 0022 F968 0023 F968 48 WSPHEX PHA 0024 F969 20 84 F9 JSR PRTSP 0025 F96C 68 PLA 0026 F96D 48 WHEX PHA 0027 F96E 4A LSRA 0028 F96F 4A LSRA 0029 F970 4A LSRA 0030 F971 4A LSRA 0031 F972 20 76 F9 JSR WDIGIT 0032 F975 68 PLA 0033 F976 18 WDIGIT CLC 0034 F977 29 0F ANDIM &0F 0035 F979 69 30 ADCIM "0" 0036 F97B C9 3A CMPIM &3A 0037 F97D 90 02 BCC HXDSKP 0038 F97F 69 06 ADCIM &06 0039 F981 4C EE FF HXDSKP JMP OSWRCH 0040 F984 0041 F984 0042 F984 0043 F984 0044 F984 A9 20 PRTSP LDAIM SPACE 0045 F986 D0 F9 BNE HXDSKP 0046 F988 0047 F988 0048 F988 ESCAPE 0049 F988 0050 F988 ;Checks ESCAPE happened. If so, does error 0051 F988 ;break with appropriate message after 0052 F988 ;acknowldging the ESCAPE. 0053 F988 0054 F988 ;Also switches off various status bits 0055 F988 ;Motor switched OFF 0056 F988 0057 F988 ;Note, no test is done if inside WRCH or RDCH 0058 F988 ;so that ESCAPE cannot occur inside EXEC/SPOOL 0059 F988 0060 F988 08 PHP 0061 F989 24 EB BIT ESSEMA 0062 F98B 30 04 BMI ESCLL0 ;Inside WRCH or RDCH -> no ESCAPE 0063 F98D 24 FF BIT ESCADD 0064 F98F 30 02 BMI ESCERR 0065 F991 ESCLL0 0066 F991 28 PLP 0067 F992 60 RTS 0068 F993 0069 F993 ESCERR 0070 F993 0071 F993 20 46 F3 JSR CATOFF ;Switch CAT bit off 0072 F996 20 E5 FA JSR CASMOF ;Motor OFF/release 0073 F999 0074 F999 A9 7E LDAIM &7E 0075 F99B 20 F4 FF JSR OSBYTE ;Acknowledge ESC to MOS 0076 F99E 0077 F99E 00 BRK ;Then error 0078 F99F 11 45 73 = &11,"Escape",0 0079 F9A7 0080 F9A7 0081 F9A7 0082 F9A7 0083 F9A7 0084 F9A7 98 LODHDR TYA 0085 F9A8 F0 0D BEQ LODHD1 ;Print message depending on Y 0086 F9AA 20 39 FA JSR MSGOUT 0087 F9AD 0D 4C 6F = MCR,"Loading",MCR,0 0088 F9B7 0089 F9B7 0090 F9B7 0091 F9B7 LODHD1 0092 F9B7 0093 F9B7 85 BA STA ERRSW ;A always zero at this point 0094 F9B9 ;Set ERRSW so always extra line after "Loading" 0095 F9B9 ;and before file name. 0096 F9B9 0097 F9B9 0098 F9B9 A2 FF LDXIM &FF ;Set "abort if nesc." flag 0099 F9BB A5 C1 LDA HDRCRC 0100 F9BD D0 0D BNE HDRCHK ;Header CRC error takes precedence over 0101 F9BF ;file and block errors, since a header error may 0102 F9BF ;spuriously cause either or both of these. 0103 F9BF 0104 F9BF 20 65 FA JSR CMPFT 0105 F9C2 0106 F9C2 08 PHP ;Store EQ bit from CMPFT 0107 F9C3 A2 FF LDXIM &FF ;Set "abort if nesc." flag 0108 F9C5 A0 8C LDYIM FILEER 0109 F9C7 A9 FA LDAIM /(FILEER ) ;Set error pointers 0110 F9C9 28 PLP 0111 F9CA 0112 F9CA D0 1C BNE TAPER0 ;Files don't match 0113 F9CC 0114 F9CC CATERR ;Entry from catalogue here 0115 F9CC HDRCHK 0116 F9CC A0 81 LDYIM DATAER ;Set lo byte of error pointer 0117 F9CE A5 C1 LDA HDRCRC ;Was header CRC ok ? 0118 F9D0 F0 04 BEQ CHKBKN ;Yes, check block no. 0119 F9D2 A9 FA LDAIM /(DATAER ) ;No, do error 0120 F9D4 D0 12 BNE TAPER0 0121 F9D6 0122 F9D6 0123 F9D6 AD C6 03 CHKBKN LDA INFO +BKNOLO ;Is expected block ?? 0124 F9D9 C5 B4 CMP BLOKNO Acorn macro assembler Page 141 C.F.S. - I/O Utilities -> MOS76 0125 F9DB D0 07 BNE BLKERR 0126 F9DD AD C7 03 LDA INFO +BKNOHI 0127 F9E0 C5 B5 CMP BLOKNO +&01 0128 F9E2 F0 13 BEQ CHEKSM ;No error -> go on 0129 F9E4 0130 F9E4 A0 97 BLKERR LDYIM BLOKER 0131 F9E6 A9 FA LDAIM /(BLOKER ) 0132 F9E8 0133 F9E8 48 TAPER0 PHA ;Store error ptr. 0134 F9E9 98 TYA 0135 F9EA 48 PHA 0136 F9EB 8A TXA ;Store "abort if nesc." flag 0137 F9EC 48 PHA 0138 F9ED 20 DB F8 JSR PRTHDL ;Print header ON NEW LINE 0139 F9F0 68 PLA 0140 F9F1 AA TAX 0141 F9F2 68 PLA 0142 F9F3 A8 TAY 0143 F9F4 68 PLA 0144 F9F5 D0 14 BNE TAPERR 0145 F9F7 0146 F9F7 8A CHEKSM TXA 0147 F9F8 48 PHA ;Store X over possible IRUPT call 0148 F9F9 20 CE F8 JSR PRTHDR ; Print header info. 0149 F9FC 0150 F9FC 20 C9 FA JSR CHEKLP ;Wait for end of BG job 0151 F9FF ;In SFS, CHEKLP reads next SFS block 0152 F9FF 0153 F9FF ;Note X & Y corrupted by IRUPT, which 0154 F9FF ;is only called when SROM system active. 0155 F9FF ;Y is restored at ERREXT. 0156 F9FF ; 0157 F9FF 68 PLA 0158 FA00 AA TAX ;Restore "abort if nesc." flag 0159 FA01 0160 FA01 A5 BE LDA CHKSUM 0161 FA03 05 BF ORA CHKSUM +&01 0162 FA05 F0 79 BEQ ERREXX ;No errors, tape ok, exit 0163 FA07 0164 FA07 A0 81 LDYIM DATAER ;Set message ptr. 0165 FA09 A9 FA LDAIM /(DATAER ) 0166 FA0B 0167 FA0B C6 BA TAPERR DEC ERRSW 0168 FA0D 48 PHA ;Store hi byte of error pointer 0169 FA0E 0170 FA0E 24 EB BIT ESSEMA 0171 FA10 30 0D BMI ERRABT ;During EXEC/SPOOL can ABORT ONLY ! 0172 FA12 0173 FA12 8A TXA ;If X = 0 => print only, X = $FF abort if nesc. 0174 FA13 2D 47 02 AND SROMSW ;If not cataloging, and SROM => abort 0175 FA16 D0 07 BNE ERRABT 0176 FA18 8A TXA ;Otherwise, check if "abort on error" option set 0177 FA19 ;If so, do BRK 0178 FA19 0179 FA19 29 11 ANDIM ABTBIT 0180 FA1B 25 BB AND USFLGS 0181 FA1D F0 10 BEQ PRTERR ;Abort not set => print 0182 FA1F 0183 FA1F 68 ERRABT PLA 0184 FA20 85 B9 STA FTPTR +&01 ;Set error pointer 0185 FA22 84 B8 STY FTPTR 0186 FA24 20 BB F6 JSR ECLOSE ;close EXEC file 0187 FA27 46 EB LSR ESSEMA ;Switch off critical region 0188 FA29 20 DB FA JSR BEEPOF ;Motor off/BEEP 0189 FA2C 6C B8 00 JMI FTPTR ;Abort = break with error msg. 0190 FA2F 0191 FA2F 68 PRTERR PLA ;Restore hi byte of pointer 0192 FA30 0193 FA30 ;Now must add ONE to pointer to get past BRK 0194 FA30 ;at front of message. Note MSGOUT does an INC 0195 FA30 ;before printing, so don't have to add 2. 0196 FA30 0197 FA30 C8 INY ;Inc lo byte past BRK instruction 0198 FA31 D0 03 BNE PRTEON 0199 FA33 18 CLC 0200 FA34 69 01 ADCIM &01 0201 FA36 48 PRTEON PHA ;Set stack for MSGOUT 0202 FA37 98 TYA 0203 FA38 48 PHA 0204 FA39 ; Print message and enter code 0205 FA39 ; directly AFTER message 0206 FA39 ; 0207 FA39 MSGOUT 0208 FA39 0209 FA39 ;Enter here for messages printed if MSGON 0210 FA39 ;Note, X must be preserved 0211 FA39 0212 FA39 20 37 EA JSR MSGON 0213 FA3C A8 TAY ;Store for STROUT 0214 FA3D 0215 FA3D STROUT 0216 FA3D 0217 FA3D 0218 FA3D 68 PLA 0219 FA3E 85 B8 STA FTPTR 0220 FA40 68 PLA 0221 FA41 85 B9 STA FTPTR +&01 0222 FA43 98 TYA 0223 FA44 08 PHP ;Z bit => print 0224 FA45 E6 B8 VSTRLP INC FTPTR 0225 FA47 D0 02 BNE VSTRL1 0226 FA49 E6 B9 INC FTPTR +&01 0227 FA4B A0 00 VSTRL1 LDYIM &00 0228 FA4D B1 B8 LDAIY FTPTR 0229 FA4F F0 0A BEQ VSTREX 0230 FA51 28 PLP 0231 FA52 08 PHP 0232 FA53 F0 F0 BEQ VSTRLP ;If Z set => don't print 0233 FA55 20 E3 FF JSR OSASCI 0234 FA58 4C 45 FA JMP VSTRLP 0235 FA5B 28 VSTREX PLP ;Restore stack 0236 FA5C E6 B8 INC FTPTR 0237 FA5E D0 02 BNE VSTREZ 0238 FA60 E6 B9 INC FTPTR +&01 0239 FA62 0240 FA62 ;Exit always with Z CLEAR 0241 FA62 0242 FA62 6C B8 00 VSTREZ JMI FTPTR 0243 FA65 0244 FA65 0245 FA65 CMPFT Acorn macro assembler Page 142 C.F.S. - I/O Utilities -> MOS76 0246 FA65 A2 FF LDXIM &FF 0247 FA67 CMPFT2 0248 FA67 E8 INX 0249 FA68 CMPFT1 ;match filename, equating cases 0250 FA68 BD D2 03 LDAAX FILNAM 0251 FA6B D0 07 BNE CMPFT3 ;[not at end of filename] 0252 FA6D ; 0253 FA6D ; at end of filename, either: 0254 FA6D ; X=0 => match on filename "" (null filename) 0255 FA6D ; X<>0 => INFO(X)=0 => match, <>0 => no match 0256 FA6D ; 0257 FA6D 8A TXA 0258 FA6E F0 03 BEQ CMPFT0 ;[match on filename "", return EQ status] 0259 FA70 BD B2 03 LDAAX INFO 0260 FA73 CMPFT0 ;EQ => match, NE => no match 0261 FA73 60 RTS 0262 FA74 0263 FA74 CMPFT3 ;not at end of filename 0264 FA74 20 27 E5 JSR CAPS 0265 FA77 5D B2 03 EORAX INFO 0266 FA7A B0 02 BCS NALPHA 0267 FA7C ; filename character is a letter 0268 FA7C 29 DF ANDIM &DF ;equate cases 0269 FA7E NALPHA 0270 FA7E F0 E7 BEQ CMPFT2 0271 FA80 ; filenames not equal 0272 FA80 ; return NE status 0273 FA80 ERREXX ;Called from around CSON1 0274 FA80 60 RTS 0275 FA81 0276 FA81 0277 FA81 0278 FA81 00 DATAER BRK 0279 FA82 D8 = CFSERJ 0280 FA83 0D 44 61 = MCR,"Data?",0 0281 FA8A 0282 FA8A D0 15 BNE REWIND ;Z always CLEAR after MSGOUT 0283 FA8C 00 FILEER BRK 0284 FA8D DB = CFSERF 0285 FA8E 0D 46 69 = MCR,"File?",0 0286 FA95 0287 FA95 D0 0A BNE REWIND ;Z always CLEAR after MSGOUT 0288 FA97 00 BLOKER BRK 0289 FA98 DA = CFSERH 0290 FA99 0D 42 6C = MCR,"Block?",0 0291 FAA1 0292 FAA1 0293 FAA1 A5 BA REWIND LDA ERRSW 0294 FAA3 F0 21 BEQ ERROEX ;If no error, leave 0295 FAA5 8A TXA 0296 FAA6 F0 1E BEQ ERROEX ;If only printing, no retry 0297 FAA8 A9 22 LDAIM RETBIT ;Otherwise, see if RETRY set 0298 FAAA 24 BB BIT USFLGS 0299 FAAC F0 18 BEQ ERROEX 0300 FAAE 20 39 FB JSR CRESET 0301 FAB1 A8 TAY ;Assume A is non-zero from RESET 0302 FAB2 20 3D FA JSR STROUT 0303 FAB5 0D 07 52 = MCR,BEL,"Rewind tape",MCR,MCR,0 0304 FAC5 0305 FAC5 0306 FAC5 ;Note NZ set by VSTRIN here 0307 FAC5 60 CSON1 RTS 0308 FAC6 0309 FAC6 0310 FAC6 20 EA F2 ERROEX JSR NOOLIN ;New line if msgs on 0311 FAC9 0312 FAC9 ;Wait for BG job to finish since if IGNORE set, must 0313 FAC9 ;allow LOADs etc. to complete. 0314 FAC9 0315 FAC9 A5 C2 CHEKLP LDA ITYPE 0316 FACB F0 F8 BEQ CSON1 ;If BG job finished exit with EQ status 0317 FACD 0318 FACD ;Note: loop must check ITYPE first, coz may be no 0319 FACD ;BG job in the case of zero length file. Therefore 0320 FACD ;don't want to read next SROM byte. 0321 FACD 0322 FACD 20 88 F9 JSR ESCAPE 0323 FAD0 AD 47 02 LDA SROMSW 0324 FAD3 F0 F4 BEQ CHEKLP ;If no speech, wait for end 0325 FAD5 ;GoMMC tape patch has FAE0 NOP;NOP 0326 FAD5 20 B6 F5 JSR IRUPT ;Otherwise, get next byte 0327 FAD8 4C C9 FA JMP CHEKLP ;And loop 0328 FADB 0329 FADB 0330 FADB 0331 FADB ;CHIP CONTROL 0332 FADB 0333 FADB 20 37 EA BEEPOF JSR MSGON 0334 FADE F0 05 BEQ CASMOF 0335 FAE0 A9 07 LDAIM &07 0336 FAE2 20 EE FF JSR OSWRCH ;Cannot use MSGOUT, coz called from inside it 0337 FAE5 A9 80 CASMOF LDAIM TUBERL ;Tube release number 0338 FAE7 20 B0 FB JSR TBINIT ;Release tube 0339 FAEA 0340 FAEA ;NOTE - TBINIT checks BKADDR. However, either at this point 0341 FAEA ;the tube has been claimed, in which case BKADDR is still a 0342 FAEA ;tube address and the release will go through; or the tube 0343 FAEA ;has not been claimed, in which case it don't matter if the 0344 FAEA ;release don't happen. NOTE also that a claim is done in 0345 FAEA ;TBINIT before the release, so that spurious claims may 0346 FAEA ;result depending on the values in BKADDR. These will, however 0347 FAEA ;be immediately released again. 0348 FAEA 0349 FAEA A2 00 LDXIM &00 0350 FAEC 20 88 FB JSR CMOTOR ;Motor off: drive set in MOTOR. 0351 FAEF ; 0352 FAEF RELEAS 0353 FAEF ; called by CFS on exit from any cassette operation 0354 FAEF ; N.B. RS423 might not have been claimed beforehand 0355 FAEF ; 0356 FAEF 08 PHP 0357 FAF0 78 SEI ;must disable interrupts 0358 FAF1 ; 0359 FAF1 ; restore MOS 6850 and serproc byte 0360 FAF1 ; 0361 FAF1 AD 82 02 LDA SPREGA 0362 FAF4 8D 10 FE STA SERPRC 0363 FAF7 ; 0364 FAF7 A9 00 LDAIM ZERO 0365 FAF9 85 EA STA RSTUT 0366 FAFB F0 01 BEQ RELX ;[ALWAYS jump] Acorn macro assembler Page 143 C.F.S. - I/O Utilities -> MOS76 0367 FAFD ; 0368 FAFD MC6850 0369 FAFD 08 PHP 0370 FAFE ; 0371 FAFE RELX 0372 FAFE ; CORRUPTS A 0373 FAFE ; setup MC6850 0374 FAFE ; disable Rx/Tx interrupts 0375 FAFE ; divide by 64, 7 data bits + 1 stop bit, even parity 0376 FAFE ; or 8 bits, one stop bit, no parity!! 0377 FAFE ; 0378 FAFE 20 39 FB JSR CRESET ;master reset 0379 FB01 ; 0380 FB01 ; reset data format bits 0381 FB01 ; 0382 FB01 AD 50 02 LDA RSCTFL 0383 FB04 ; 0384 FB04 4C D9 E1 JMP STARSC ;share code with 'RS423' 0385 FB07 0386 FB07 0387 FB07 RSWT1 0388 FB07 28 PLP 0389 FB08 24 FF BIT ESCFLG 0390 FB0A 10 18 BPL CLAIM ;[no escape, ALWAYS jump] 0391 FB0C ; 0392 FB0C ; escape condition 0393 FB0C ; 0394 FB0C 60 RTS 0395 FB0D 0396 FB0D 0397 FB0D A5 E3 SETSDF LDA OPTS ;Set options for sequential access 0398 FB0F 0A ASLA ;=> bottom nybble of OPTS 0399 FB10 0A ASLA 0400 FB11 0A ASLA 0401 FB12 0A ASLA 0402 FB13 85 BB STA USFLGS 0403 FB15 AD D1 03 LDA SEQGAP ;Set (variable) PUTBYTE gap time 0404 FB18 D0 08 BNE GAPOUT ;[ALWAYS JUMP] 0405 FB1A ; 0406 FB1A A5 E3 SETDEF LDA OPTS 0407 FB1C 29 F0 ANDIM &F0 ;Chop out seq. opts 0408 FB1E 85 BB STA USFLGS ;Set options for load/save operation 0409 FB20 [ GLYN =0 ;If special system for glyn 0411 FB20 | 0412 FB20 A9 06 LDAIM GAP ;Set SAVE gap -> unchangeable 0413 FB22 ] 0414 FB22 85 C7 GAPOUT STA GAPTIM 0415 FB24 ; 0416 FB24 ; fall thru into CLAIM 0417 FB24 ; 0418 FB24 CLAIM 0419 FB24 ; Claim RS423 h/w interface 0420 FB24 ; Called by CFS 0421 FB24 58 CLI 0422 FB25 08 PHP 0423 FB26 78 SEI 0424 FB27 2C 4F 02 BIT RSFLAG 0425 FB2A 10 DB BPL RSWT1 ;[RS423 busy] 0426 FB2C A5 EA LDA RSTUT 0427 FB2E 30 D7 BMI RSWT1 ;[RS423 dormant, but still timing out] 0428 FB30 ; RS423 dormant and timed out OR claimed => RS423 available 0429 FB30 ; RSTUT>=0 0430 FB30 ; headline: 'CFS Claims RS423' 0431 FB30 A9 01 LDAIM &01 ;allow for many call claims 0432 FB32 85 EA STA RSTUT ;RSTUT := 1 0433 FB34 0434 FB34 [ &00=0 0435 FB34 20 39 FB JSR CRESET 0436 FB37 28 PLP 0437 FB38 60 RTS 0438 FB39 | 0441 FB39 ] 0442 FB39 0443 FB39 0444 FB39 A9 03 CRESET LDAIM &03 0445 FB3B D0 1B BNE SETCHP 0446 FB3D 0447 FB3D 0448 FB3D TXINIT 0449 FB3D A9 30 LDAIM TXSTAT 0450 FB3F 85 CA STA TXFLAG 0451 FB41 D0 13 BNE CHPINT 0452 FB43 0453 FB43 A9 05 RXINIT LDAIM SEROFF 0454 FB45 0455 FB45 ;Switch motor off without going through OS 0456 FB45 ;coz don't want user to be bothered with each 0457 FB45 ;motor blip 0458 FB45 0459 FB45 8D 10 FE STA SERPRC 0460 FB48 0461 FB48 A2 FF LDXIM &FF ;250 * 2.5 usecs = 1 millisec 0462 FB4A CA RXINL1 DEX 0463 FB4B D0 FD BNE RXINL1 0464 FB4D 86 CA STX TXFLAG 0465 FB4F 0466 FB4F A9 85 LDAIM SERON 0467 FB51 8D 10 FE STA SERPRC ;Motor on again 0468 FB54 0469 FB54 A9 D0 LDAIM RXSTAT 0470 FB56 05 C6 CHPINT ORA SPEED ;Put in bottom bit, set in INIT from MOS 0471 FB58 8D 08 FE SETCHP STA STATUS 0472 FB5B 60 RTS 0473 FB5C 0474 FB5C 0475 FB5C AE C6 03 NXTBLK LDX INFO +BKNOLO 0476 FB5F AC C7 03 LDY INFO +BKNOHI 0477 FB62 E8 INX 0478 FB63 86 B4 STX BLOKNO 0479 FB65 D0 01 BNE NXTBLX 0480 FB67 C8 INY 0481 FB68 84 B5 NXTBLX STY BLOKNO +&01 0482 FB6A 60 RTS 0483 FB6B 0484 FB6B A0 00 SETJOB LDYIM &00 0485 FB6D 84 C0 STY IFLAG 0486 FB6F 84 BE SETJB1 STY CHKSUM 0487 FB71 84 BF STY CHKSUM +&01 0488 FB73 60 RTS 0489 FB74 0490 FB74 Acorn macro assembler Page 144 C.F.S. - I/O Utilities -> MOS76 0491 FB74 A0 FF MOVFN LDYIM &FF 0492 FB76 C8 MOVFNL INY 0493 FB77 E8 INX 0494 FB78 BD 00 03 LDAAX VARPGE 0495 FB7B 99 D2 03 STAAY FILNAM 0496 FB7E D0 F6 BNE MOVFNL 0497 FB80 60 RTS 0498 FB81 0499 FB81 0500 FB81 A0 00 MOTONW LDYIM WRITFX ;Motor on for output 0501 FB83 58 MOTON CLI ;Ensure can talk to tape 0502 FB84 A2 01 LDXIM &01 ;Motor on 0503 FB86 84 C3 STY CURDRV ;Store current drive 0504 FB88 A9 89 CMOTOR LDAIM FXMOTR ;=> motor function 0505 FB8A 0506 FB8A ;Load drive number into Y, so switching motor 0507 FB8A ;off is always done with the drive most recently 0508 FB8A ;switched on (seems logical). 0509 FB8A 0510 FB8A A4 C3 LDY CURDRV 0511 FB8C 4C F4 FF JMP OSBYTE 0512 FB8F 0513 FB8F CHKHND 0514 FB8F 0515 FB8F ;Check handle in Y is open 0516 FB8F ;and corresponds to mask in A 0517 FB8F 0518 FB8F 85 BC STA TEMP 0519 FB91 98 TYA 0520 FB92 4D 47 02 EOR SROMSW ;Reverse SFS bit in handle if in SFS 0521 FB95 A8 TAY 0522 FB96 A5 E2 LDA CFSTAT 0523 FB98 25 BC AND TEMP ;Mask out bits not required 0524 FB9A 4A LSRA 0525 FB9B 88 DEY 0526 FB9C F0 04 BEQ CHKHN1 0527 FB9E 4A LSRA 0528 FB9F 88 DEY 0529 FBA0 D0 02 BNE HNDERR 0530 FBA2 B0 4D CHKHN1 BCS CHKHXX 0531 FBA4 0532 FBA4 0533 FBA4 00 HNDERR BRK 0534 FBA5 DE = CFSERB 0535 FBA6 43 68 61 = "Channel",0 0536 FBAE 0537 FBAE 0538 FBAE 0539 FBAE TWINIT 0540 FBAE A9 01 LDAIM TUBEW ;Write init. for tube 0541 FBB0 TBINIT 0542 FBB0 ;Check the address at BKADDR is accross tube 0543 FBB0 ;and that tube is present. If so, claim tube, and call 0544 FBB0 ;address routine with value origionally in A on entry. 0545 FBB0 0546 FBB0 20 C6 FB JSR TUBCHK ;Check address + tube present. 0547 FBB3 F0 3C BEQ TINIT0 ;Don't tube. (NOTE TAX done in TUBCHK) 0548 FBB5 8A TXA ;Restore tube reason code 0549 FBB6 A2 B0 LDXIM BKADDR 0550 FBB8 A0 00 LDYIM /(BKADDR ) ;Address for tube routine 0551 FBBA 48 TBINT1 PHA ;Entry from RUN with non-BKADDR address 0552 FBBB A9 C0 LDAIM TUBECL ;"Claim" reason code 0553 FBBD 20 06 04 TUBELP JSR TBADDR ;Attempt claim 0554 FBC0 90 FB BCC TUBELP ;Continue to try and claim 0555 FBC2 68 PLA ;Restore address reason code 0556 FBC3 4C 06 04 JMP TBADDR 0557 FBC6 0558 FBC6 0559 FBC6 0560 FBC6 AA TUBCHK TAX ;Store A 0561 FBC7 A5 B2 LDA BKADDR +&02 0562 FBC9 25 B3 AND BKADDR +&03 0563 FBCB C9 FF CMPIM &FF ;If $FF, address is IO proc., so exit 0564 FBCD F0 05 BEQ TUBCHX 0565 FBCF AD 7A 02 LDA TUBE 0566 FBD2 29 80 ANDIM &80 ;Returns NZ if tube present, EQ if not 0567 FBD4 60 TUBCHX RTS 0568 FBD5 0569 FBD5 0570 FBD5 0571 FBD5 BUGFIX 0572 FBD5 0573 FBD5 ;When the 6850 counter divide bits are reset, it 0574 FBD5 ;is possible for the SERPROC to get out of synch. 0575 FBD5 ;for a few bits. This has the effect of corrupting 0576 FBD5 ;the first character of the first block of a SAVE, 0577 FBD5 ;or the first character of ANY block during sequential 0578 FBD5 ;access (since the 6850 is reset for every block 0579 FBD5 ;during putbytes). 0580 FBD5 ; The cure is to write a dummy byte to tape at the 0581 FBD5 ;start of a SAVE, and at the start of every block 0582 FBD5 ;during putbytes. This must be done by polling, 0583 FBD5 ;since there must be a period of high-tone after 0584 FBD5 ;the dummy byte, which is difficult to accomplish 0585 FBD5 ;if the 6850 is interrupting all the time. 0586 FBD5 ; BUGFIX is thus called after the SERPROC is set 0587 FBD5 ;and before the 6850 is set to interrupt during 0588 FBD5 ;a block write operation. 0589 FBD5 0590 FBD5 A9 85 LDAIM SERON 0591 FBD7 8D 10 FE STA SERPRC ;Set SERPROC on 0592 FBDA 20 39 FB JSR CRESET ;Reset 6850 to be on safe side 0593 FBDD A9 10 LDAIM &10 0594 FBDF 20 56 FB JSR CHPINT ;Set 6850 at appropriate clock rate 0595 FBE2 0596 FBE2 20 88 F9 BUGLP JSR ESCAPE 0597 FBE5 AD 08 FE LDA STATUS 0598 FBE8 29 02 ANDIM &02 ;Ready to TX ? 0599 FBEA F0 F6 BEQ BUGLP ;Nope -> loop 0600 FBEC A9 AA LDAIM &AA 0601 FBEE 8D 09 FE STA PORT ;Shove out the dummy byte 0602 FBF1 CHKHXX 0603 FBF1 TINIT0 0604 FBF1 60 RTS 0605 FBF2 0606 FBF2 [ MOS125 = &FF 0607 FBF2 | 0608 FBF2 ;FSC jump table moved to end of main section. 0609 FBF2 ;This displaces the free space into the middle 0610 FBF2 ;of the ROM where it can be used for any purpose 0611 FBF2 ;(an opcode or branch address at &FBFF would cause Acorn macro assembler Page 145 C.F.S. - I/O Utilities -> MOS76 0612 FBF2 ;a dummy read cycle in FRED.) 0613 FBF2 0614 FBF2 JMPTAB 0615 FBF2 8A = CFSOPT-&01 0616 FBF3 48 = CFSEOF-&01 0617 FBF4 F6 = RUN-&01 ;"*." 0618 FBF5 54 = MBDCMD-&01 ;"*" = Bad command 0619 FBF6 F6 = RUN-&01 ;"*RUN " 0620 FBF7 35 = CAT-&01 0621 FBF8 D0 = SHUTES-&01 ;die 0622 FBF9 0007 NOTAB * .-JMPTAB 0623 FBF9 F5 = /(CFSOPT-&01) 0624 FBFA F6 = /(CFSEOF-&01) 0625 FBFB F2 = /(RUN-&01) 0626 FBFC E3 = /(MBDCMD-&01) 0627 FBFD F2 = /(RUN-&01) 0628 FBFE F3 = /(CAT-&01) 0629 FBFF E2 = /(SHUTES-&01) 0630 FC00 0631 FC00 ;MOS 1.25: Adjust padding in MOS38 to hit &FC00 here 0632 FC00 ] 0633 FC00 0634 FC00 END 0635 FC00 0636 FC00 [ $Tutu 0638 FC00 ] 0639 FC00 0640 FC00 ; pad with zero bytes to ensure ROM CRCs consistent 0641 FC00 00 00 00 % &100 0642 FD00 0643 FD00 [ . > &FC00+&100 0645 FD00 ] 0646 FD00 0647 FD00 < 1 0648 FD00 0649 FD00 LNK MOS99 0001 FD00 ; MOS99 0002 FD00 TTL MOS99 Operating system ROM entry points and hardware vectors 0003 FD00 OPT MOS99 Acorn macro assembler Page 146 MOS99 Operating system ROM entry points and hardware vectors 0004 FD00 0005 FD00 ;(c) 1981 ACORN Computers Limited 0006 FD00 ;BBC Microcomputer Machine Operating System (MOS) 0007 FD00 0008 FD00 ;Change record: 0009 FD00 0010 FD00 ;Author(s): 0011 FD00 ;PB Paul Bond 0012 FD00 0013 FD00 ORG &FC00 0014 FC00 0015 FC00 28 43 29 = "(C) 1981 Acorn Computers Ltd." 0016 FC1D 54 68 61 = "Thanks are due to the following contributors to the development of the BBC Computer " 0017 FC71 28 61 6D = "(among others too numerous to mention):- " 0018 FC9A 44 61 76 = "David Allen," 0019 FCA6 42 6F 62 = "Bob Austin," 0020 FCB1 52 61 6D = "Ram Banerjee," 0021 FCBE 50 61 75 = "Paul Bond," 0022 FCC8 41 6C 6C = "Allen Boothroyd," 0023 FCD8 43 61 6D = "Cambridge," 0024 FCE2 43 6C 65 = "Cleartone," 0025 FCEC 4A 6F 68 = "John Coll," 0026 FCF6 4A 6F 68 = "John Cox," 0027 FCFF 41 6E 64 = "Andy Cripps," 0028 FD0B 43 68 72 = "Chris Curry," 0029 FD17 36 35 30 = "6502 designers," 0030 FD26 4A 65 72 = "Jeremy Dion," 0031 FD32 54 69 6D = "Tim Dobson," 0032 FD3D 4A 6F 65 = "Joe Dunn," 0033 FD46 50 61 75 = "Paul Farrell," 0034 FD53 46 65 72 = "Ferranti," 0035 FD5C 53 74 65 = "Steve Furber," 0036 FD69 4A 6F 6E = "Jon Gibbons," 0037 FD75 41 6E 64 = "Andrew Gordon," 0038 FD83 4C 61 77 = "Lawrence Hardwick," 0039 FD95 44 79 6C = "Dylan Harris," 0040 FDA2 48 65 72 = "Hermann Hauser," 0041 FDB1 48 69 74 = "Hitachi," 0042 FDB9 41 6E 64 = "Andy Hopper," 0043 FDC5 49 43 4C = "ICL," 0044 FDC9 4D 61 72 = "Martin Jackson," 0045 FDD8 42 72 69 = "Brian Jones," 0046 FDE4 43 68 72 = "Chris Jordan," 0047 FDF1 44 61 76 = "David King," 0048 FDFC 44 61 76 = "David Kitson," 0049 FE09 50 61 75 = "Paul Kriwaczek," 0050 FE18 43 6F 6D = "Computer Laboratory," 0051 FE2C 50 65 74 = "Peter Miller," 0052 FE39 41 72 74 = "Arthur Norman," 0053 FE47 47 6C 79 = "Glyn Phillips," 0054 FE55 4D 69 6B = "Mike Prees," 0055 FE60 4A 6F 68 = "John Radcliffe," 0056 FE6F 57 69 6C = "Wilberforce Road," 0057 FE80 50 65 74 = "Peter Robinson," 0058 FE8F 52 69 63 = "Richard Russell," 0059 FE9F 4B 69 6D = "Kim Spence-Jones," 0060 FEB0 47 72 61 = "Graham Tebby," 0061 FEBD 4A 6F 6E = "Jon Thackray," 0062 FECA 43 68 72 = "Chris Turner," 0063 FED7 41 64 72 = "Adrian Warner," 0064 FEE5 52 6F 67 = "Roger Wilson," 0065 FEF2 41 6C 61 = "Alan Wright." 0066 FEFE ; 0067 FEFE ; test ROM indirection 0068 FEFE 5F = MRESET 0069 FEFF D9 = /(MRESET ) 0070 FF00 0071 FF00 ; ORG $FF00 0072 FF00 ; Page $FF contains code which has to be located at a fixed 0073 FF00 ; place in memory. Two main types of code come into this 0074 FF00 ; category: 0075 FF00 ; (a) Code to call a routine located in a paged ROM 0076 FF00 ; (b) Fixed OS calls 0077 FF00 0078 FF00 ; Calls to the operating system are normally made by calling 0079 FF00 ; JMIs located at the top of the address space of the m/c. 0080 FF00 ; The indirection vectors are located in page 2 starting at 0081 FF00 ; $0200. To redirect an OS call which indirects thru location 0082 FF00 ; $0200+2*x: 0083 FF00 ; (a) Set up a 3-byte tuple at location ROMVEC+3*x to refer 0084 FF00 ; to the paged ROM entry point 0085 FF00 ; (b) Set the OS indirection at location $0200+2*x to value 0086 FF00 ; $FF00+3*x 0087 FF00 ; A JMI $0200+2*x will then result in the routine in paged ROM 0088 FF00 ; being called. The routine is entered with A, X, Y and P 0089 FF00 ; unaltered since the point of call. Similarly, no registers 0090 FF00 ; are corrupted on return from the routine. 0091 FF00 ; 0092 FF00 ; Locations $FF00 onwards contain JSRs to the same location (OSROM); 0093 FF00 ; thus when OSROM is entered the top entry on the stack determines 0094 FF00 ; which JSR OSROM was called, enabling the OS call made to be 0095 FF00 ; identified (by convention paged ROM routed indirections thru 0096 FF00 ; $0200+2*x jump to location $FF00+3*x). 0097 FF00 0098 FF00 ROMUSR 0099 FF00 20 92 FF JSR OSROM 0100 FF03 0101 FF03 ROMBRK 0102 FF03 20 92 FF JSR OSROM 0103 FF06 0104 FF06 ROMIRA 0105 FF06 20 92 FF JSR OSROM 0106 FF09 0107 FF09 ROMIRB 0108 FF09 20 92 FF JSR OSROM 0109 FF0C 0110 FF0C ROMCOM 0111 FF0C 20 92 FF JSR OSROM 0112 FF0F 0113 FF0F ROMBYT 0114 FF0F 20 92 FF JSR OSROM 0115 FF12 0116 FF12 ROMWRD 0117 FF12 20 92 FF JSR OSROM 0118 FF15 0119 FF15 ROMWRC 0120 FF15 20 92 FF JSR OSROM 0121 FF18 0122 FF18 ROMRDC 0123 FF18 20 92 FF JSR OSROM 0124 FF1B Acorn macro assembler Page 147 MOS99 Operating system ROM entry points and hardware vectors 0125 FF1B ROMFIL 0126 FF1B 20 92 FF JSR OSROM 0127 FF1E 0128 FF1E ROMARG 0129 FF1E 20 92 FF JSR OSROM 0130 FF21 0131 FF21 ROMBGT 0132 FF21 20 92 FF JSR OSROM 0133 FF24 0134 FF24 ROMBPT 0135 FF24 20 92 FF JSR OSROM 0136 FF27 0137 FF27 ROMGPB 0138 FF27 20 92 FF JSR OSROM 0139 FF2A 0140 FF2A ROMFND 0141 FF2A 20 92 FF JSR OSROM 0142 FF2D 0143 FF2D ROMFSC 0144 FF2D 20 92 FF JSR OSROM 0145 FF30 0146 FF30 ROMEVT 0147 FF30 20 92 FF JSR OSROM 0148 FF33 0149 FF33 ROMUPT 0150 FF33 20 92 FF JSR OSROM 0151 FF36 0152 FF36 ROMNET 0153 FF36 20 92 FF JSR OSROM 0154 FF39 0155 FF39 ROMVDU 0156 FF39 20 92 FF JSR OSROM 0157 FF3C 0158 FF3C ROMKEY 0159 FF3C 20 92 FF JSR OSROM 0160 FF3F 0161 FF3F ROMINS 0162 FF3F 20 92 FF JSR OSROM 0163 FF42 0164 FF42 ROMREM 0165 FF42 20 92 FF JSR OSROM 0166 FF45 0167 FF45 ROMCNP 0168 FF45 20 92 FF JSR OSROM 0169 FF48 0170 FF48 20 92 FF JSR OSROM 0171 FF4B 0172 FF4B 20 92 FF JSR OSROM 0173 FF4E 0174 FF4E 20 92 FF JSR OSROM 0175 FF51 0176 FF51 [ MOS125 = &FF 0276 FF51 ] 0277 FF51 0278 FF51 [ MOS125 = &7F 0279 FF51 [ STARGO = &00 0280 FF51 00 % 1 ;1 byte padding 0281 FF52 0282 FF52 ARGSW 0283 FF52 C9 01 CMPIM &01 0284 FF54 D0 0D BNE UPARGS 0285 FF56 C0 00 CPYIM &00 0286 FF58 D0 09 BNE UPARGS 0287 FF5A AC D1 02 LDY TAILHI ;OSARGS A=1, Y=0 return command line tail 0288 FF5D F0 04 BEQ UPARGS ;return *GO/CFS pointer if valid 0289 FF5F 88 DEY 0290 FF60 4C 96 DF JMP RETAIL 0291 FF63 UPARGS ;call upstream OSARGS 0292 FF63 6C 14 02 JMI ARGVEC 0293 FF66 | 0295 FF66 ] 0296 FF66 FXBPUT ;FX entry, C=1 0297 FF66 8A TXA ;A = character 0298 FF67 B0 6B BCS OSBPUT ;[ALWAYS jump] 0299 FF69 ] 0300 FF69 0301 FF69 [ MOS125 = &00 0303 FF69 ] 0304 FF69 0305 FF69 [ MOS125 = &FF 0306 FF69 | 0307 FF69 48 FUDGE PHA 0308 FF6A 48 PHA 0309 FF6B 08 PHP 0310 FF6C 48 PHA 0311 FF6D 8A TXA 0312 FF6E 48 PHA 0313 FF6F 98 TYA 0314 FF70 48 PHA 0315 FF71 BA TSX ;y x a p a a 88 FF el eh cl ch 0316 FF72 BC 09 01 LDYAX &0109 ;get vector offset+2 0317 FF75 B9 9D 0D LDAAY ROMVEC-&02+&00 0318 FF78 9D 05 01 STAAX &0105 ;copy LSB vector over placeholder 0319 FF7B B9 9E 0D LDAAY ROMVEC-&02+&01 0320 FF7E 9D 06 01 STAAX &0106 ;copy MSB vector over placeholder 0321 FF81 A5 F4 LDA ROMID ;copy ROM slot over MSB vector offset 0322 FF83 9D 0A 01 STAAX &010A ;y x a p vl vh 88 FF el r cl ch 0323 FF86 68 PLA ;Y in A ready to restore 0324 FF87 BE 9F 0D LDXAY ROMVEC-&02+&02 ;get vector ROM slot 0325 FF8A A8 TAY ;restore Y 0326 FF8B 68 PLA ;X in A ready to restore 0327 FF8C 20 DB DB JSR STXROM ;set destination ROM slot 0328 FF8F AA TAX ;restore X 0329 FF90 68 PLA ;restore A 0330 FF91 40 RTI ;restore P and jump to vector 0331 FF92 0332 FF92 20 69 FF OSROM JSR FUDGE ;push restore address on stack, RTS returns below 0333 FF95 ;routine to restore ROM slot from indirection 0334 FF95 08 PHP 0335 FF96 48 PHA 0336 FF97 8A TXA 0337 FF98 48 PHA 0338 FF99 BA TSX ;x a p el r cl ch 0339 FF9A BD 05 01 LDAAX &0105 0340 FF9D 85 F4 STA ROMID 0341 FF9F 8D 30 FE STA ROM ;restore ROM slot 0342 FFA2 BD 03 01 LDAAX &0103 0343 FFA5 9D 04 01 STAAX &0104 0344 FFA8 9D 05 01 STAAX &0105 ;copy status over vec offset and ROM slot 0345 FFAB 68 PLA 0346 FFAC AA TAX ;restore X Acorn macro assembler Page 148 MOS99 Operating system ROM entry points and hardware vectors 0347 FFAD 68 PLA ;restore A 0348 FFAE 28 PLP 0349 FFAF 28 PLP 0350 FFB0 28 PLP ;restore status (and discard 2 copies) 0351 FFB1 VINUSE ;target of vectors in use by a client waiting for a server 0352 FFB1 EA NOP 0353 FFB2 DEFEVT ;default EVENT routine 0354 FFB2 DEFUPT ;default user print routine (simulate printer busy) 0355 FFB2 DEFNET ;default net routine (simulate printer busy) 0356 FFB2 RTS 0357 FFB2 60 RTS 0358 FFB3 ] 0359 FFB3 0360 FFB3 [ MOS125 = &7F 0361 FFB3 ;FXBPUT gives up its place to OSWRSC 0362 FFB3 ;to keep VINUSE and RTS in the same place 0363 FFB3 | 0367 FFB3 ] 0368 FFB3 0369 FFB3 [ MOS125 = &FF 0381 FFB3 ] 0382 FFB3 0383 FFB3 [ MOS125 = &7F 0384 FFB3 4C 1C D1 OSWRSC JMP WRSC 0385 FFB6 ] 0386 FFB6 0387 FFB6 ; security copy of indirection data 0388 FFB6 36 = VLEN 0389 FFB7 D2 = IPAGE2 0390 FFB8 D8 = /(IPAGE2 ) 0391 FFB9 ; 0392 FFB9 4C D0 DB JMP RPROM ;read byte from paged ROM 0393 FFBC 4C C0 C4 JMP VDU ;raw VDU WRCH (corrupts A, X and Y) 0394 FFBF 4C D8 E4 JMP EVENT ;signal event 0395 FFC2 4C 79 EA JMP GSINTS ;used by paged ROMs 0396 FFC5 4C 8A EA JMP GSREAD ;used by paged ROMs 0397 FFC8 4C 71 DE JMP RDCH ;used by tube 0398 FFCB 4C F6 E0 JMP WRCH ;used by tube 0399 FFCE 6C 1C 02 OSFIND JMI FNDVEC 0400 FFD1 0401 FFD1 6C 1A 02 OSBGPB JMI GPBVEC 0402 FFD4 6C 18 02 OSBPUT JMI BPTVEC 0403 FFD7 6C 16 02 OSBGET JMI BGTVEC 0404 FFDA [ MOS125 = &7F 0405 FFDA [ STARGO = &00 0406 FFDA 4C 52 FF OSARGS JMP ARGSW 0407 FFDD | 0409 FFDD ] 0410 FFDD | 0412 FFDD ] 0413 FFDD 6C 12 02 OSFILE JMI FILVEC 0414 FFE0 6C 10 02 OSRDCH JMI RDCVEC 0415 FFE3 C9 0D OSASCI CMPIM MCR 0416 FFE5 D0 07 BNE OSWRCH 0417 FFE7 A9 0A OSNEWL LDAIM MLF 0418 FFE9 20 EE FF JSR OSWRCH 0419 FFEC [ MOS125 = &FF 0420 FFEC | 0421 FFEC WRCR 0422 FFEC ] 0423 FFEC A9 0D LDAIM MCR 0424 FFEE 6C 0E 02 OSWRCH JMI WRCVEC 0425 FFF1 6C 0C 02 OSWORD JMI WORVEC 0426 FFF4 6C 0A 02 OSBYTE JMI BYTVEC 0427 FFF7 6C 08 02 OSCLI JMI COMVEC 0428 FFFA 0429 FFFA ; hardware vectors 0430 FFFA 00 = NMI ;non-maskable interrupt 0431 FFFB 0D = /(NMI ) 0432 FFFC 5F = MRESET ;hardware reset 0433 FFFD D9 = /(MRESET ) 0434 FFFE E1 = IRQ ;interrupt 0435 FFFF DB = /(IRQ ) 0436 0000 ENDROM ;end of ROM 0437 0000 0438 0000 [ ENDROM=0 0439 0000 | 0441 0000 ] 0442 0000 0443 0000 TTL BBC Microcomputer Machine Operating System (MOS) 0444 0000 0445 0000 OPT OPPON 0446 0000 0447 0000 END Assembly finished, no errors Action : *spool This Perl script creates the slack columns from the raw listing. Copy the text between the cut lines. Paste it into a new file, slack.pl, and remove the first 30 characters from each line. Then call it with perl slack.pl stargo.asm.txt >stargo-slack.txt -------->8--- #!/usr/bin/perl $base=0xc000; @slack = (0x80) x 0x4001; open(ASM,'<'.shift(@ARGV))or die; while(){ y/ -~//cd; if(/^Action :\s*asm\s+([A-Z0-9._-]+)/i) { $file=sprintf("%-7s",$1); } elsif(/^[0-9A-F]{4} [0-9A-F]{4} ...... LNK\s+([A-Z0-9._-]+)\s*$/) { $file=sprintf("%-7s",$1); # Link filename not held over as LNK lines do not assemble instructions. } elsif(/^([0-9A-F]{4}) ([0-9A-F]{4}) .. .. .. /) { $line=$1; $pc=hex($2); $label[$pc-$base] = $file.' '.$line.' '.$2 if $pc >= $base; } if(/^([0-9A-F]{4}) ([0-9A-F]{4}) [13579BDF]0 ([0-9A-F]{2}) ...... B/){ $line=$1; $pc=hex($2); $op=hex($3); if($op & 0x80) { $dest = $pc + 2 - 0x100 + $op; $slack = $op - 0x80; for($i = $pc + 2 - $base + $op - 0xFF; $i <= $pc - $base; ++$i) { if($slack[$i] > $slack) { $slack[$i] = $slack; $source[$i] = $pc-$base; } } } else { $dest = $pc + 2 + $op; $slack = 0x7f - $op; for($i = $pc + 2 - $base; $i <= $pc + 2 - $base + $op; ++$i) { if($slack[$i] > $slack) { $slack[$i] = $slack; $source[$i] = $pc-$base; } } } } } undef $file; undef $link; seek(ASM,0,0); while(){ y/ -~//cd; if(/^Action :\s*asm\s+([A-Z0-9._-]+)/i) { $link=sprintf("%-7s",$1); } elsif(/^[0-9A-F]{4} [0-9A-F]{4} ...... LNK\s+([A-Z0-9._-]+)\s*$/) { $link=sprintf("%-7s",$1); } elsif(/^[0-9A-F]{4} [0-9A-F]{4} ...... END\s*$/) { $link=sprintf("%-7s",""); } if(/^([0-9A-F]{4}) ([0-9A-F]{4})(.*)$/) { $line=$1; $pc=hex($2); $source=$3; if($pc>=$base && $slack[$pc-$base] < 0x80) { printf("%-17s %s%02X %-7s %s\n", (($pc>=$base && defined($source[$pc-$base]) && defined($label[$source[$pc-$base]])) ? $label[$source[$pc-$base]] : ''), (($source[$pc-$base] < $pc-$base) ? 'v' : '^'), $slack[$pc-$base], $file, $_); } else { printf(" -- %-7s %s\n", $file, $_); } } else { printf(" %-7s %s\n", $file, $_); } if(defined($link)) { $file=$link; undef $link; } } -------->8--- End of stargo-slack.txt