Home » CEEFAX disks » telesoftware5.adl » 20-03-88/B\OSB18
20-03-88/B\OSB18
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
Tape/disk: | Home » CEEFAX disks » telesoftware5.adl |
Filename: | 20-03-88/B\OSB18 |
Read OK: | ✔ |
File size: | 102E bytes |
Load address: | FFFF1900 |
Exec address: | FFFF8023 |
File contents
10REM OSbits Module B/osb18 20REM Mouse Driver under Interrupts 30REM Version 3.4 28.3.87 40 50*KEY1MO.3|M|NL.|M 60*KEY10O.|M 70 80IF PAGE<&1900 THEN PRINT"I think you have a second processor"'"Please switch it off and start again":STOP 90 100code% = &A00 110 120REM Set vector + registers addresses as labels 130irq1 = &204 140data_direction_reg = &FE62 150in_out_reg = &FE60 160peripheral_control_reg = &FE6C 170interrupt_flag_reg = &FE6D 180interrupt_enable_reg = &FE6E 190 200FOR pass%=0 TO 2 STEP 2 210P%=code% 220[OPT pass% 230 240\ Reset vector and set up VIA 250 260SEI \ Disable interrupts 270 280LDA irq1 290STA old_irq1 300LDA irq1+1 310STA old_irq1+1 \ Store old contents 320 330LDA #interrupt_code MOD 256 340STA irq1 350LDA #interrupt_code DIV 256 360STA irq1+1 \ Reset IRQ1 370 380LDA interrupt_enable_reg \ Get current enable status 390ORA #24 \ Also enable CB1/2 interrupts 400STA interrupt_enable_reg \ and reset 410 420LDA peripheral_control_reg \ Get current peripheral status 430ORA #(16+64) \ Set bits 4 & 6 440STA peripheral_control_reg \ Sets behaviour of CB1 + CB2 450 460LDA #0 470STA data_direction_reg \ Set User Port to inputs 480 490CLI \ Re-enable interrupts 500RTS 510 520.scale OPT FNEQUB(2) \ Scale of mouse movement 530.x_coord OPT FNEQUD(640) \ Current cursor position 540.y_coord OPT FNEQUD(512) \ Starting centre screen 550.old_irq1 OPT FNEQUW(0) 560 570.interrupt_code 580 590\ Executed when an interrupt is generated 600 610LDA &FC 620PHA 630TXA 640PHA 650TYA 660PHA \ Store registers 670CLD \ Force binary mode (just in case) 680 690\ After confirming the user VIA has generated the interrupt 700\ look at the interrupt flag register to see if CB1 or CB2 710\ has generated the interrupt. If not then exit. 720 730LDA interrupt_flag_reg 740BPL not_intercept \ If bit 7 clear then not user VIA 750 760LDA #8 \ Is it CB2? 770BIT interrupt_flag_reg 780BNE y_pulse \ If it is then we have Y pulse 790 800LDA #16 \ Is it CB1? 810BIT interrupt_flag_reg 820BNE x_pulse \ If it is then we have X pulse 830 840.not_intercept 850 860PLA 870TAY 880PLA 890TAX 900PLA 910STA &FC \ Return registers and 920JMP (old_irq1) \ Follow old vector 930 940.y_pulse 950 960LDA #4 \ Other Y output is on PB2 970BIT in_out_reg 980BNE y_down \ If high then moving down 990 1000.y_up 1010 1020LDA y_coord 1030CLC 1040ADC scale 1050STA y_coord 1060LDA y_coord+1 1070ADC #0 1080STA y_coord+1 \ Increase y coordinate 1090JMP exit 1100 1110.y_down 1120 1130LDA y_coord 1140SEC 1150SBC scale 1160STA y_coord 1170LDA y_coord+1 1180SBC #0 1190STA y_coord+1 \ Decrease y coordinate 1200JMP exit 1210 1220.x_pulse 1230 1240LDA #1 \ Other X output is on PB1 1250BIT in_out_reg 1260BNE x_down \ If high then moving down 1270 1280.x_up 1290 1300LDA x_coord 1310CLC 1320ADC scale 1330STA x_coord 1340LDA x_coord+1 1350ADC #0 1360STA x_coord+1 \ Increase x coordinate 1370JMP exit 1380 1390.x_down 1400 1410LDA x_coord 1420SEC 1430SBC scale 1440STA x_coord 1450LDA x_coord+1 1460SBC #0 1470STA x_coord+1 \ Decrease x coordinate 1480 1490.exit 1500PLA 1510TAY 1520PLA 1530TAX 1540PLA 1550STA &FC 1560RTI \ Restore registers and exit 1570 1580] 1590 1600NEXT 1610 1620CALL code% 1630MODE4 1640VDU5 1650REPEAT 1660x=!x_coord 1670y=!y_coord 1680MOVE x,y 1690PRINT"+" 1700UNTIL FALSE 1710 1720**** EQUate a Byte **** 1730DEF FNEQUB(N%) 1740?P%=N% MOD 256 1750IF (pass% AND 3) = 3 THEN PRINT ~?P% 1760P%=P%+1 1770=pass% 1780 1790**** EQUate a Word (2 bytes) **** 1800DEF FNEQUW(N%) 1810?P%=N% MOD 256 1820P%?1=N% DIV 256 1830IF (pass% AND 3) = 3 THEN PRINT ~?P%,~?(P%+1) 1840P%=P%+2 1850=pass% 1860 1870**** EQUate a Double word (4 bytes) **** 1880DEF FNEQUD(N%) 1890LOCAL X% 1900!P%=N% 1910FOR X%=0 TO 3 1920IF (pass% AND 3) = 3 THEN PRINT ~P%?X%; 1930NEXT 1940IF (pass% AND 3) = 3 THEN PRINT 1950P%=P%+4 1960=pass%
� OSbits Module B/osb18 &� Mouse Driver under Interrupts � Version 3.4 28.3.87 ( 2*KEY1MO.3|M|NL.|M <*KEY10O.|M F P_� �<&1900 � �"I think you have a second processor"'"Please switch it off and start again":� Z dcode% = &A00 n x1� Set vector + registers addresses as labels �irq1 = &204 �data_direction_reg = &FE62 �in_out_reg = &FE60 �"peripheral_control_reg = &FE6C �interrupt_flag_reg = &FE6D � interrupt_enable_reg = &FE6E � �� pass%=0 � 2 � 2 �P%=code% �[OPT pass% � �!\ Reset vector and set up VIA � 5SEI \ Disable interrupts LDA irq1 "STA old_irq1 ,LDA irq1+1 65STA old_irq1+1 \ Store old contents @ JLDA #interrupt_code � 256 TSTA irq1 ^LDA #interrupt_code � 256 h-STA irq1+1 \ Reset IRQ1 r |<LDA interrupt_enable_reg \ Get current enable status �>�A #24 \ Also enable CB1/2 interrupts �,STA interrupt_enable_reg \ and reset � �@LDA peripheral_control_reg \ Get current peripheral status �0�A #(16+64) \ Set bits 4 & 6 �>STA peripheral_control_reg \ Sets behaviour of CB1 + CB2 � � LDA #0 �:STA data_direction_reg \ Set User Port to inputs � �7CLI \ Re-enable interrupts �RTS � 9.scale OPT �EQUB(2) \ Scale of mouse movement 9.x_coord OPT �EQUD(640) \ Current cursor position 8.y_coord OPT �EQUD(512) \ Starting centre screen &.old_irq1 OPT �EQUW(0) 0 :.interrupt_code D N.\ Executed when an interrupt is generated X bLDA &FC lPHA vTXA �PHA �TYA �2PHA \ Store registers �CCLD \ Force binary mode (just in case) � �@\ After confirming the user VIA has generated the interrupt �?\ look at the interrupt flag register to see if CB1 or CB2 �6\ has generated the interrupt. If not then exit. � �LDA interrupt_flag_reg �CBPL not_intercept \ If bit 7 clear then not user VIA � �-LDA #8 \ Is it CB2? BIT interrupt_flag_reg @BNE y_pulse \ If it is then we have Y pulse -LDA #16 \ Is it CB1? *BIT interrupt_flag_reg 4@BNE x_pulse \ If it is then we have X pulse > H.not_intercept R \PLA fTAY pPLA zTAX �PLA �7STA &FC \ Return registers and �4JMP (old_irq1) \ Follow old vector � �.y_pulse � �;LDA #4 \ Other Y output is on PB2 �BIT in_out_reg �;BNE y_down \ If high then moving down � � .y_up � �LDA y_coord CLC ADC scale STA y_coord $LDA y_coord+1 . ADC #0 88STA y_coord+1 \ Increase y coordinate BJMP exit L V.y_down ` jLDA y_coord tSEC ~ SBC scale �STA y_coord �LDA y_coord+1 � SBC #0 �8STA y_coord+1 \ Decrease y coordinate �JMP exit � �.x_pulse � �;LDA #1 \ Other X output is on PB1 �BIT in_out_reg �;BNE x_down \ If high then moving down � .x_up LDA x_coord CLC ( ADC scale 2STA x_coord <LDA x_coord+1 F ADC #0 P8STA x_coord+1 \ Increase x coordinate ZJMP exit d n.x_down x �LDA x_coord �SEC � SBC scale �STA x_coord �LDA x_coord+1 � SBC #0 �8STA x_coord+1 \ Decrease x coordinate � � .exit �PLA �TAY �PLA �TAX PLA STA &FC =RTI \ Restore registers and exit " ,] 6 @� J T� code% ^�4 h�5 r� |x=!x_coord �y=!y_coord � � x,y ��"+" �� � � �**** EQUate a Byte **** �� �EQUB(N%) �?P%=N% � 256 �� (pass% � 3) = 3 � � ~?P% �P%=P%+1 � =pass% � �%**** EQUate a Word (2 bytes) **** � �EQUW(N%) ?P%=N% � 256 P%?1=N% � 256 &'� (pass% � 3) = 3 � � ~?P%,~?(P%+1) 0P%=P%+2 : =pass% D N,**** EQUate a Double word (4 bytes) **** X� �EQUD(N%) b� X% l !P%=N% v� X%=0 � 3 �!� (pass% � 3) = 3 � � ~P%?X%; �� �� (pass% � 3) = 3 � � �P%=P%+4 � =pass% �
00000000 0d 00 0a 1e f4 20 20 20 20 4f 53 62 69 74 73 20 |..... OSbits | 00000010 4d 6f 64 75 6c 65 20 42 2f 6f 73 62 31 38 0d 00 |Module B/osb18..| 00000020 14 26 f4 20 20 20 20 4d 6f 75 73 65 20 44 72 69 |.&. Mouse Dri| 00000030 76 65 72 20 75 6e 64 65 72 20 49 6e 74 65 72 72 |ver under Interr| 00000040 75 70 74 73 0d 00 1e 1d f4 20 20 20 20 56 65 72 |upts..... Ver| 00000050 73 69 6f 6e 20 33 2e 34 20 20 32 38 2e 33 2e 38 |sion 3.4 28.3.8| 00000060 37 0d 00 28 05 20 0d 00 32 15 2a 4b 45 59 31 4d |7..(. ..2.*KEY1M| 00000070 4f 2e 33 7c 4d 7c 4e 4c 2e 7c 4d 0d 00 3c 0e 2a |O.3|M|NL.|M..<.*| 00000080 4b 45 59 31 30 4f 2e 7c 4d 0d 00 46 05 20 0d 00 |KEY10O.|M..F. ..| 00000090 50 5f e7 20 90 3c 26 31 39 30 30 20 8c 20 f1 22 |P_. .<&1900 . ."| 000000a0 49 20 74 68 69 6e 6b 20 79 6f 75 20 68 61 76 65 |I think you have| 000000b0 20 61 20 73 65 63 6f 6e 64 20 70 72 6f 63 65 73 | a second proces| 000000c0 73 6f 72 22 27 22 50 6c 65 61 73 65 20 73 77 69 |sor"'"Please swi| 000000d0 74 63 68 20 69 74 20 6f 66 66 20 61 6e 64 20 73 |tch it off and s| 000000e0 74 61 72 74 20 61 67 61 69 6e 22 3a fa 0d 00 5a |tart again":...Z| 000000f0 05 20 0d 00 64 10 63 6f 64 65 25 20 3d 20 26 41 |. ..d.code% = &A| 00000100 30 30 0d 00 6e 05 20 0d 00 78 31 f4 20 20 53 65 |00..n. ..x1. Se| 00000110 74 20 76 65 63 74 6f 72 20 2b 20 72 65 67 69 73 |t vector + regis| 00000120 74 65 72 73 20 61 64 64 72 65 73 73 65 73 20 61 |ters addresses a| 00000130 73 20 6c 61 62 65 6c 73 0d 00 82 0f 69 72 71 31 |s labels....irq1| 00000140 20 3d 20 26 32 30 34 0d 00 8c 1e 64 61 74 61 5f | = &204....data_| 00000150 64 69 72 65 63 74 69 6f 6e 5f 72 65 67 20 3d 20 |direction_reg = | 00000160 26 46 45 36 32 0d 00 96 16 69 6e 5f 6f 75 74 5f |&FE62....in_out_| 00000170 72 65 67 20 3d 20 26 46 45 36 30 0d 00 a0 22 70 |reg = &FE60..."p| 00000180 65 72 69 70 68 65 72 61 6c 5f 63 6f 6e 74 72 6f |eripheral_contro| 00000190 6c 5f 72 65 67 20 3d 20 26 46 45 36 43 0d 00 aa |l_reg = &FE6C...| 000001a0 1e 69 6e 74 65 72 72 75 70 74 5f 66 6c 61 67 5f |.interrupt_flag_| 000001b0 72 65 67 20 3d 20 26 46 45 36 44 0d 00 b4 20 69 |reg = &FE6D... i| 000001c0 6e 74 65 72 72 75 70 74 5f 65 6e 61 62 6c 65 5f |nterrupt_enable_| 000001d0 72 65 67 20 3d 20 26 46 45 36 45 0d 00 be 05 20 |reg = &FE6E.... | 000001e0 0d 00 c8 15 e3 20 70 61 73 73 25 3d 30 20 b8 20 |..... pass%=0 . | 000001f0 32 20 88 20 32 0d 00 d2 0c 50 25 3d 63 6f 64 65 |2 . 2....P%=code| 00000200 25 0d 00 dc 0e 5b 4f 50 54 20 70 61 73 73 25 0d |%....[OPT pass%.| 00000210 00 e6 05 20 0d 00 f0 21 5c 20 52 65 73 65 74 20 |... ...!\ Reset | 00000220 76 65 63 74 6f 72 20 61 6e 64 20 73 65 74 20 75 |vector and set u| 00000230 70 20 56 49 41 0d 00 fa 05 20 0d 01 04 35 53 45 |p VIA.... ...5SE| 00000240 49 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |I | 00000250 20 20 20 20 20 20 20 20 20 20 20 5c 20 44 69 73 | \ Dis| 00000260 61 62 6c 65 20 69 6e 74 65 72 72 75 70 74 73 0d |able interrupts.| 00000270 01 0e 05 20 0d 01 18 0c 4c 44 41 20 69 72 71 31 |... ....LDA irq1| 00000280 0d 01 22 10 53 54 41 20 6f 6c 64 5f 69 72 71 31 |..".STA old_irq1| 00000290 0d 01 2c 0e 4c 44 41 20 69 72 71 31 2b 31 0d 01 |..,.LDA irq1+1..| 000002a0 36 35 53 54 41 20 6f 6c 64 5f 69 72 71 31 2b 31 |65STA old_irq1+1| 000002b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c | \| 000002c0 20 53 74 6f 72 65 20 6f 6c 64 20 63 6f 6e 74 65 | Store old conte| 000002d0 6e 74 73 0d 01 40 05 20 0d 01 4a 1d 4c 44 41 20 |nts..@. ..J.LDA | 000002e0 23 69 6e 74 65 72 72 75 70 74 5f 63 6f 64 65 20 |#interrupt_code | 000002f0 83 20 32 35 36 0d 01 54 0c 53 54 41 20 69 72 71 |. 256..T.STA irq| 00000300 31 0d 01 5e 1d 4c 44 41 20 23 69 6e 74 65 72 72 |1..^.LDA #interr| 00000310 75 70 74 5f 63 6f 64 65 20 81 20 32 35 36 0d 01 |upt_code . 256..| 00000320 68 2d 53 54 41 20 69 72 71 31 2b 31 20 20 20 20 |h-STA irq1+1 | 00000330 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c | \| 00000340 20 52 65 73 65 74 20 49 52 51 31 0d 01 72 05 20 | Reset IRQ1..r. | 00000350 0d 01 7c 3c 4c 44 41 20 69 6e 74 65 72 72 75 70 |..|<LDA interrup| 00000360 74 5f 65 6e 61 62 6c 65 5f 72 65 67 20 20 20 20 |t_enable_reg | 00000370 20 5c 20 47 65 74 20 63 75 72 72 65 6e 74 20 65 | \ Get current e| 00000380 6e 61 62 6c 65 20 73 74 61 74 75 73 0d 01 86 3e |nable status...>| 00000390 84 41 20 23 32 34 20 20 20 20 20 20 20 20 20 20 |.A #24 | 000003a0 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 41 6c | \ Al| 000003b0 73 6f 20 65 6e 61 62 6c 65 20 43 42 31 2f 32 20 |so enable CB1/2 | 000003c0 69 6e 74 65 72 72 75 70 74 73 0d 01 90 2c 53 54 |interrupts...,ST| 000003d0 41 20 69 6e 74 65 72 72 75 70 74 5f 65 6e 61 62 |A interrupt_enab| 000003e0 6c 65 5f 72 65 67 20 20 20 20 20 5c 20 61 6e 64 |le_reg \ and| 000003f0 20 72 65 73 65 74 0d 01 9a 05 20 0d 01 a4 40 4c | reset.... ...@L| 00000400 44 41 20 70 65 72 69 70 68 65 72 61 6c 5f 63 6f |DA peripheral_co| 00000410 6e 74 72 6f 6c 5f 72 65 67 20 20 20 5c 20 47 65 |ntrol_reg \ Ge| 00000420 74 20 63 75 72 72 65 6e 74 20 70 65 72 69 70 68 |t current periph| 00000430 65 72 61 6c 20 73 74 61 74 75 73 0d 01 ae 30 84 |eral status...0.| 00000440 41 20 23 28 31 36 2b 36 34 29 20 20 20 20 20 20 |A #(16+64) | 00000450 20 20 20 20 20 20 20 20 20 20 20 5c 20 53 65 74 | \ Set| 00000460 20 62 69 74 73 20 34 20 26 20 36 0d 01 b8 3e 53 | bits 4 & 6...>S| 00000470 54 41 20 70 65 72 69 70 68 65 72 61 6c 5f 63 6f |TA peripheral_co| 00000480 6e 74 72 6f 6c 5f 72 65 67 20 20 20 5c 20 53 65 |ntrol_reg \ Se| 00000490 74 73 20 62 65 68 61 76 69 6f 75 72 20 6f 66 20 |ts behaviour of | 000004a0 43 42 31 20 2b 20 43 42 32 0d 01 c2 05 20 0d 01 |CB1 + CB2.... ..| 000004b0 cc 0a 4c 44 41 20 23 30 0d 01 d6 3a 53 54 41 20 |..LDA #0...:STA | 000004c0 64 61 74 61 5f 64 69 72 65 63 74 69 6f 6e 5f 72 |data_direction_r| 000004d0 65 67 20 20 20 20 20 20 20 5c 20 53 65 74 20 55 |eg \ Set U| 000004e0 73 65 72 20 50 6f 72 74 20 74 6f 20 69 6e 70 75 |ser Port to inpu| 000004f0 74 73 0d 01 e0 05 20 0d 01 ea 37 43 4c 49 20 20 |ts.... ...7CLI | 00000500 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000510 20 20 20 20 20 20 20 20 5c 20 52 65 2d 65 6e 61 | \ Re-ena| 00000520 62 6c 65 20 69 6e 74 65 72 72 75 70 74 73 0d 01 |ble interrupts..| 00000530 f4 07 52 54 53 0d 01 fe 05 20 0d 02 08 39 2e 73 |..RTS.... ...9.s| 00000540 63 61 6c 65 20 20 20 20 20 20 4f 50 54 20 a4 45 |cale OPT .E| 00000550 51 55 42 28 32 29 20 20 20 20 5c 20 53 63 61 6c |QUB(2) \ Scal| 00000560 65 20 6f 66 20 6d 6f 75 73 65 20 6d 6f 76 65 6d |e of mouse movem| 00000570 65 6e 74 0d 02 12 39 2e 78 5f 63 6f 6f 72 64 20 |ent...9.x_coord | 00000580 20 20 20 4f 50 54 20 a4 45 51 55 44 28 36 34 30 | OPT .EQUD(640| 00000590 29 20 20 5c 20 43 75 72 72 65 6e 74 20 63 75 72 |) \ Current cur| 000005a0 73 6f 72 20 70 6f 73 69 74 69 6f 6e 0d 02 1c 38 |sor position...8| 000005b0 2e 79 5f 63 6f 6f 72 64 20 20 20 20 4f 50 54 20 |.y_coord OPT | 000005c0 a4 45 51 55 44 28 35 31 32 29 20 20 5c 20 53 74 |.EQUD(512) \ St| 000005d0 61 72 74 69 6e 67 20 63 65 6e 74 72 65 20 73 63 |arting centre sc| 000005e0 72 65 65 6e 0d 02 26 1c 2e 6f 6c 64 5f 69 72 71 |reen..&..old_irq| 000005f0 31 20 20 20 4f 50 54 20 a4 45 51 55 57 28 30 29 |1 OPT .EQUW(0)| 00000600 0d 02 30 05 20 0d 02 3a 13 2e 69 6e 74 65 72 72 |..0. ..:..interr| 00000610 75 70 74 5f 63 6f 64 65 0d 02 44 05 20 0d 02 4e |upt_code..D. ..N| 00000620 2e 5c 20 20 45 78 65 63 75 74 65 64 20 77 68 65 |.\ Executed whe| 00000630 6e 20 61 6e 20 69 6e 74 65 72 72 75 70 74 20 69 |n an interrupt i| 00000640 73 20 67 65 6e 65 72 61 74 65 64 0d 02 58 05 20 |s generated..X. | 00000650 0d 02 62 0b 4c 44 41 20 26 46 43 0d 02 6c 07 50 |..b.LDA &FC..l.P| 00000660 48 41 0d 02 76 07 54 58 41 0d 02 80 07 50 48 41 |HA..v.TXA....PHA| 00000670 0d 02 8a 07 54 59 41 0d 02 94 32 50 48 41 20 20 |....TYA...2PHA | 00000680 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000690 20 20 20 20 20 20 20 20 5c 20 53 74 6f 72 65 20 | \ Store | 000006a0 72 65 67 69 73 74 65 72 73 0d 02 9e 43 43 4c 44 |registers...CCLD| 000006b0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 000006c0 20 20 20 20 20 20 20 20 20 20 5c 20 46 6f 72 63 | \ Forc| 000006d0 65 20 62 69 6e 61 72 79 20 6d 6f 64 65 20 28 6a |e binary mode (j| 000006e0 75 73 74 20 69 6e 20 63 61 73 65 29 0d 02 a8 05 |ust in case)....| 000006f0 20 0d 02 b2 40 5c 20 20 41 66 74 65 72 20 63 6f | ...@\ After co| 00000700 6e 66 69 72 6d 69 6e 67 20 74 68 65 20 75 73 65 |nfirming the use| 00000710 72 20 56 49 41 20 68 61 73 20 67 65 6e 65 72 61 |r VIA has genera| 00000720 74 65 64 20 74 68 65 20 69 6e 74 65 72 72 75 70 |ted the interrup| 00000730 74 0d 02 bc 3f 5c 20 20 6c 6f 6f 6b 20 61 74 20 |t...?\ look at | 00000740 74 68 65 20 69 6e 74 65 72 72 75 70 74 20 66 6c |the interrupt fl| 00000750 61 67 20 72 65 67 69 73 74 65 72 20 74 6f 20 73 |ag register to s| 00000760 65 65 20 69 66 20 43 42 31 20 6f 72 20 43 42 32 |ee if CB1 or CB2| 00000770 0d 02 c6 36 5c 20 20 68 61 73 20 67 65 6e 65 72 |...6\ has gener| 00000780 61 74 65 64 20 74 68 65 20 69 6e 74 65 72 72 75 |ated the interru| 00000790 70 74 2e 20 20 49 66 20 6e 6f 74 20 74 68 65 6e |pt. If not then| 000007a0 20 65 78 69 74 2e 0d 02 d0 05 20 0d 02 da 1a 4c | exit..... ....L| 000007b0 44 41 20 69 6e 74 65 72 72 75 70 74 5f 66 6c 61 |DA interrupt_fla| 000007c0 67 5f 72 65 67 0d 02 e4 43 42 50 4c 20 6e 6f 74 |g_reg...CBPL not| 000007d0 5f 69 6e 74 65 72 63 65 70 74 20 20 20 20 20 20 |_intercept | 000007e0 20 20 20 20 20 20 5c 20 49 66 20 62 69 74 20 37 | \ If bit 7| 000007f0 20 63 6c 65 61 72 20 74 68 65 6e 20 6e 6f 74 20 | clear then not | 00000800 75 73 65 72 20 56 49 41 0d 02 ee 05 20 0d 02 f8 |user VIA.... ...| 00000810 2d 4c 44 41 20 23 38 20 20 20 20 20 20 20 20 20 |-LDA #8 | 00000820 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 | \ | 00000830 49 73 20 69 74 20 43 42 32 3f 0d 03 02 1a 42 49 |Is it CB2?....BI| 00000840 54 20 69 6e 74 65 72 72 75 70 74 5f 66 6c 61 67 |T interrupt_flag| 00000850 5f 72 65 67 0d 03 0c 40 42 4e 45 20 79 5f 70 75 |_reg...@BNE y_pu| 00000860 6c 73 65 20 20 20 20 20 20 20 20 20 20 20 20 20 |lse | 00000870 20 20 20 20 20 5c 20 49 66 20 69 74 20 69 73 20 | \ If it is | 00000880 74 68 65 6e 20 77 65 20 68 61 76 65 20 59 20 70 |then we have Y p| 00000890 75 6c 73 65 0d 03 16 05 20 0d 03 20 2d 4c 44 41 |ulse.... .. -LDA| 000008a0 20 23 31 36 20 20 20 20 20 20 20 20 20 20 20 20 | #16 | 000008b0 20 20 20 20 20 20 20 20 20 20 5c 20 49 73 20 69 | \ Is i| 000008c0 74 20 43 42 31 3f 0d 03 2a 1a 42 49 54 20 69 6e |t CB1?..*.BIT in| 000008d0 74 65 72 72 75 70 74 5f 66 6c 61 67 5f 72 65 67 |terrupt_flag_reg| 000008e0 0d 03 34 40 42 4e 45 20 78 5f 70 75 6c 73 65 20 |..4@BNE x_pulse | 000008f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000900 20 5c 20 49 66 20 69 74 20 69 73 20 74 68 65 6e | \ If it is then| 00000910 20 77 65 20 68 61 76 65 20 58 20 70 75 6c 73 65 | we have X pulse| 00000920 0d 03 3e 05 20 0d 03 48 12 2e 6e 6f 74 5f 69 6e |..>. ..H..not_in| 00000930 74 65 72 63 65 70 74 0d 03 52 05 20 0d 03 5c 07 |tercept..R. ..\.| 00000940 50 4c 41 0d 03 66 07 54 41 59 0d 03 70 07 50 4c |PLA..f.TAY..p.PL| 00000950 41 0d 03 7a 07 54 41 58 0d 03 84 07 50 4c 41 0d |A..z.TAX....PLA.| 00000960 03 8e 37 53 54 41 20 26 46 43 20 20 20 20 20 20 |..7STA &FC | 00000970 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000980 5c 20 52 65 74 75 72 6e 20 72 65 67 69 73 74 65 |\ Return registe| 00000990 72 73 20 61 6e 64 0d 03 98 34 4a 4d 50 20 28 6f |rs and...4JMP (o| 000009a0 6c 64 5f 69 72 71 31 29 20 20 20 20 20 20 20 20 |ld_irq1) | 000009b0 20 20 20 20 20 20 20 5c 20 46 6f 6c 6c 6f 77 20 | \ Follow | 000009c0 6f 6c 64 20 76 65 63 74 6f 72 0d 03 a2 05 20 0d |old vector.... .| 000009d0 03 ac 0c 2e 79 5f 70 75 6c 73 65 0d 03 b6 05 20 |....y_pulse.... | 000009e0 0d 03 c0 3b 4c 44 41 20 23 34 20 20 20 20 20 20 |...;LDA #4 | 000009f0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | 00000a00 20 5c 20 4f 74 68 65 72 20 59 20 6f 75 74 70 75 | \ Other Y outpu| 00000a10 74 20 69 73 20 6f 6e 20 50 42 32 0d 03 ca 12 42 |t is on PB2....B| 00000a20 49 54 20 69 6e 5f 6f 75 74 5f 72 65 67 0d 03 d4 |IT in_out_reg...| 00000a30 3b 42 4e 45 20 79 5f 64 6f 77 6e 20 20 20 20 20 |;BNE y_down | 00000a40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c 20 | \ | 00000a50 49 66 20 68 69 67 68 20 74 68 65 6e 20 6d 6f 76 |If high then mov| 00000a60 69 6e 67 20 64 6f 77 6e 0d 03 de 05 20 0d 03 e8 |ing down.... ...| 00000a70 09 2e 79 5f 75 70 0d 03 f2 05 20 0d 03 fc 0f 4c |..y_up.... ....L| 00000a80 44 41 20 79 5f 63 6f 6f 72 64 0d 04 06 07 43 4c |DA y_coord....CL| 00000a90 43 0d 04 10 0d 41 44 43 20 73 63 61 6c 65 0d 04 |C....ADC scale..| 00000aa0 1a 0f 53 54 41 20 79 5f 63 6f 6f 72 64 0d 04 24 |..STA y_coord..$| 00000ab0 11 4c 44 41 20 79 5f 63 6f 6f 72 64 2b 31 0d 04 |.LDA y_coord+1..| 00000ac0 2e 0a 41 44 43 20 23 30 0d 04 38 38 53 54 41 20 |..ADC #0..88STA | 00000ad0 79 5f 63 6f 6f 72 64 2b 31 20 20 20 20 20 20 20 |y_coord+1 | 00000ae0 20 20 20 20 20 20 20 20 20 5c 20 49 6e 63 72 65 | \ Incre| 00000af0 61 73 65 20 79 20 63 6f 6f 72 64 69 6e 61 74 65 |ase y coordinate| 00000b00 0d 04 42 0c 4a 4d 50 20 65 78 69 74 0d 04 4c 05 |..B.JMP exit..L.| 00000b10 20 0d 04 56 0b 2e 79 5f 64 6f 77 6e 0d 04 60 05 | ..V..y_down..`.| 00000b20 20 0d 04 6a 0f 4c 44 41 20 79 5f 63 6f 6f 72 64 | ..j.LDA y_coord| 00000b30 0d 04 74 07 53 45 43 0d 04 7e 0d 53 42 43 20 73 |..t.SEC..~.SBC s| 00000b40 63 61 6c 65 0d 04 88 0f 53 54 41 20 79 5f 63 6f |cale....STA y_co| 00000b50 6f 72 64 0d 04 92 11 4c 44 41 20 79 5f 63 6f 6f |ord....LDA y_coo| 00000b60 72 64 2b 31 0d 04 9c 0a 53 42 43 20 23 30 0d 04 |rd+1....SBC #0..| 00000b70 a6 38 53 54 41 20 79 5f 63 6f 6f 72 64 2b 31 20 |.8STA y_coord+1 | 00000b80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 5c | \| 00000b90 20 44 65 63 72 65 61 73 65 20 79 20 63 6f 6f 72 | Decrease y coor| 00000ba0 64 69 6e 61 74 65 0d 04 b0 0c 4a 4d 50 20 65 78 |dinate....JMP ex| 00000bb0 69 74 0d 04 ba 05 20 0d 04 c4 0c 2e 78 5f 70 75 |it.... .....x_pu| 00000bc0 6c 73 65 0d 04 ce 05 20 0d 04 d8 3b 4c 44 41 20 |lse.... ...;LDA | 00000bd0 23 31 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |#1 | 00000be0 20 20 20 20 20 20 20 20 20 5c 20 4f 74 68 65 72 | \ Other| 00000bf0 20 58 20 6f 75 74 70 75 74 20 69 73 20 6f 6e 20 | X output is on | 00000c00 50 42 31 0d 04 e2 12 42 49 54 20 69 6e 5f 6f 75 |PB1....BIT in_ou| 00000c10 74 5f 72 65 67 0d 04 ec 3b 42 4e 45 20 78 5f 64 |t_reg...;BNE x_d| 00000c20 6f 77 6e 20 20 20 20 20 20 20 20 20 20 20 20 20 |own | 00000c30 20 20 20 20 20 20 5c 20 49 66 20 68 69 67 68 20 | \ If high | 00000c40 74 68 65 6e 20 6d 6f 76 69 6e 67 20 64 6f 77 6e |then moving down| 00000c50 0d 04 f6 05 20 0d 05 00 09 2e 78 5f 75 70 0d 05 |.... .....x_up..| 00000c60 0a 05 20 0d 05 14 0f 4c 44 41 20 78 5f 63 6f 6f |.. ....LDA x_coo| 00000c70 72 64 0d 05 1e 07 43 4c 43 0d 05 28 0d 41 44 43 |rd....CLC..(.ADC| 00000c80 20 73 63 61 6c 65 0d 05 32 0f 53 54 41 20 78 5f | scale..2.STA x_| 00000c90 63 6f 6f 72 64 0d 05 3c 11 4c 44 41 20 78 5f 63 |coord..<.LDA x_c| 00000ca0 6f 6f 72 64 2b 31 0d 05 46 0a 41 44 43 20 23 30 |oord+1..F.ADC #0| 00000cb0 0d 05 50 38 53 54 41 20 78 5f 63 6f 6f 72 64 2b |..P8STA x_coord+| 00000cc0 31 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |1 | 00000cd0 20 5c 20 49 6e 63 72 65 61 73 65 20 78 20 63 6f | \ Increase x co| 00000ce0 6f 72 64 69 6e 61 74 65 0d 05 5a 0c 4a 4d 50 20 |ordinate..Z.JMP | 00000cf0 65 78 69 74 0d 05 64 05 20 0d 05 6e 0b 2e 78 5f |exit..d. ..n..x_| 00000d00 64 6f 77 6e 0d 05 78 05 20 0d 05 82 0f 4c 44 41 |down..x. ....LDA| 00000d10 20 78 5f 63 6f 6f 72 64 0d 05 8c 07 53 45 43 0d | x_coord....SEC.| 00000d20 05 96 0d 53 42 43 20 73 63 61 6c 65 0d 05 a0 0f |...SBC scale....| 00000d30 53 54 41 20 78 5f 63 6f 6f 72 64 0d 05 aa 11 4c |STA x_coord....L| 00000d40 44 41 20 78 5f 63 6f 6f 72 64 2b 31 0d 05 b4 0a |DA x_coord+1....| 00000d50 53 42 43 20 23 30 0d 05 be 38 53 54 41 20 78 5f |SBC #0...8STA x_| 00000d60 63 6f 6f 72 64 2b 31 20 20 20 20 20 20 20 20 20 |coord+1 | 00000d70 20 20 20 20 20 20 20 5c 20 44 65 63 72 65 61 73 | \ Decreas| 00000d80 65 20 78 20 63 6f 6f 72 64 69 6e 61 74 65 0d 05 |e x coordinate..| 00000d90 c8 05 20 0d 05 d2 09 2e 65 78 69 74 0d 05 dc 07 |.. .....exit....| 00000da0 50 4c 41 0d 05 e6 07 54 41 59 0d 05 f0 07 50 4c |PLA....TAY....PL| 00000db0 41 0d 05 fa 07 54 41 58 0d 06 04 07 50 4c 41 0d |A....TAX....PLA.| 00000dc0 06 0e 0b 53 54 41 20 26 46 43 0d 06 18 3d 52 54 |...STA &FC...=RT| 00000dd0 49 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |I | 00000de0 20 20 20 20 20 20 20 20 20 20 20 5c 20 52 65 73 | \ Res| 00000df0 74 6f 72 65 20 72 65 67 69 73 74 65 72 73 20 61 |tore registers a| 00000e00 6e 64 20 65 78 69 74 0d 06 22 05 20 0d 06 2c 05 |nd exit..". ..,.| 00000e10 5d 0d 06 36 05 20 0d 06 40 05 ed 0d 06 4a 05 20 |]..6. ..@....J. | 00000e20 0d 06 54 0b d6 20 63 6f 64 65 25 0d 06 5e 06 eb |..T.. code%..^..| 00000e30 34 0d 06 68 06 ef 35 0d 06 72 05 f5 0d 06 7c 0e |4..h..5..r....|.| 00000e40 78 3d 21 78 5f 63 6f 6f 72 64 0d 06 86 0e 79 3d |x=!x_coord....y=| 00000e50 21 79 5f 63 6f 6f 72 64 0d 06 90 09 ec 20 78 2c |!y_coord..... x,| 00000e60 79 0d 06 9a 08 f1 22 2b 22 0d 06 a4 07 fd 20 a3 |y....."+"..... .| 00000e70 0d 06 ae 05 20 0d 06 b8 1b 2a 2a 2a 2a 20 45 51 |.... ....**** EQ| 00000e80 55 61 74 65 20 61 20 42 79 74 65 20 2a 2a 2a 2a |Uate a Byte ****| 00000e90 0d 06 c2 0f dd 20 a4 45 51 55 42 28 4e 25 29 0d |..... .EQUB(N%).| 00000ea0 06 cc 10 3f 50 25 3d 4e 25 20 83 20 32 35 36 0d |...?P%=N% . 256.| 00000eb0 06 d6 1e e7 20 28 70 61 73 73 25 20 80 20 33 29 |.... (pass% . 3)| 00000ec0 20 3d 20 33 20 8c 20 f1 20 7e 3f 50 25 0d 06 e0 | = 3 . . ~?P%...| 00000ed0 0b 50 25 3d 50 25 2b 31 0d 06 ea 0a 3d 70 61 73 |.P%=P%+1....=pas| 00000ee0 73 25 0d 06 f4 05 20 0d 06 fe 25 2a 2a 2a 2a 20 |s%.... ...%**** | 00000ef0 45 51 55 61 74 65 20 61 20 57 6f 72 64 20 28 32 |EQUate a Word (2| 00000f00 20 62 79 74 65 73 29 20 2a 2a 2a 2a 0d 07 08 0f | bytes) ****....| 00000f10 dd 20 a4 45 51 55 57 28 4e 25 29 0d 07 12 10 3f |. .EQUW(N%)....?| 00000f20 50 25 3d 4e 25 20 83 20 32 35 36 0d 07 1c 11 50 |P%=N% . 256....P| 00000f30 25 3f 31 3d 4e 25 20 81 20 32 35 36 0d 07 26 27 |%?1=N% . 256..&'| 00000f40 e7 20 28 70 61 73 73 25 20 80 20 33 29 20 3d 20 |. (pass% . 3) = | 00000f50 33 20 8c 20 f1 20 7e 3f 50 25 2c 7e 3f 28 50 25 |3 . . ~?P%,~?(P%| 00000f60 2b 31 29 0d 07 30 0b 50 25 3d 50 25 2b 32 0d 07 |+1)..0.P%=P%+2..| 00000f70 3a 0a 3d 70 61 73 73 25 0d 07 44 05 20 0d 07 4e |:.=pass%..D. ..N| 00000f80 2c 2a 2a 2a 2a 20 45 51 55 61 74 65 20 61 20 44 |,**** EQUate a D| 00000f90 6f 75 62 6c 65 20 77 6f 72 64 20 28 34 20 62 79 |ouble word (4 by| 00000fa0 74 65 73 29 20 2a 2a 2a 2a 0d 07 58 0f dd 20 a4 |tes) ****..X.. .| 00000fb0 45 51 55 44 28 4e 25 29 0d 07 62 08 ea 20 58 25 |EQUD(N%)..b.. X%| 00000fc0 0d 07 6c 0a 21 50 25 3d 4e 25 0d 07 76 0e e3 20 |..l.!P%=N%..v.. | 00000fd0 58 25 3d 30 20 b8 20 33 0d 07 80 21 e7 20 28 70 |X%=0 . 3...!. (p| 00000fe0 61 73 73 25 20 80 20 33 29 20 3d 20 33 20 8c 20 |ass% . 3) = 3 . | 00000ff0 f1 20 7e 50 25 3f 58 25 3b 0d 07 8a 05 ed 0d 07 |. ~P%?X%;.......| 00001000 94 19 e7 20 28 70 61 73 73 25 20 80 20 33 29 20 |... (pass% . 3) | 00001010 3d 20 33 20 8c 20 f1 0d 07 9e 0b 50 25 3d 50 25 |= 3 . .....P%=P%| 00001020 2b 34 0d 07 a8 0a 3d 70 61 73 73 25 0d ff |+4....=pass%..| 0000102e