; -----------------------------------------------------------------------------
; The Hobbit - Picture decoder and displayer (c) Melbourne House
; reverse engineered by Eelco Huininga using phpDisassembler v1.08 (using 6502 architecture)
; DOS Filename   : X:\REESDICE\d\CD's\Acorn\projects\disassembler\1.08\O.PICVIEW
; Acorn filename : O.PICVIEW
; Load address   : FFFF4E00
; Exec address   : FFFF4E00
; Length         : 00000A00
; -----------------------------------------------------------------------------


; -----------------------------------------------------------------------------
; Hardware addresses
; -----------------------------------------------------------------------------

crtc_register                    = &FE00                              ; 6845 CRTC Address register
crtc_data                        = &FE01                              ; 6845 CTRC Data register

video_ula_control                = &FE20                              ; VIDEO ULA Control register
video_ula_palette                = &FE21                              ; VIDEO ULA Palette register

; -----------------------------------------------------------------------------
; OS call addresses
; -----------------------------------------------------------------------------
osrdch             = &FFE0                       ; OSRDCH Read character
osbyte             = &FFF4                       ; OSBYTE Various OS routines

.
4E00  4C 3A 4E           L:N     JMP &4E3A
4E03  00                 .       BRK
4E04  00                 .       BRK
4E05  00                 .       BRK
4E06  5C                 \       ...
4E07  00                 .       BRK
4E08  00                 .       BRK
4E09  00                 .       BRK
4E0A  00                 .       BRK
4E0B  00                 .       BRK
4E0C  00                 .       BRK
4E0D  00                 .       BRK
4E0E  00                 .       BRK
4E0F  00                 .       BRK
4E10  0A                 .       ASL A
4E11  57                 W       ...
4E12  00                 .       BRK
4E13  00                 .       BRK
4E14  00                 .       BRK
4E15  00                 .       BRK
4E16  00                 .       BRK
4E17  00                 .       BRK
4E18  00                 .       BRK
4E19  00                 .       BRK
4E1A  00                 .       BRK
4E1B  00                 .       BRK
4E1C  00                 .       BRK
4E1D  00                 .       BRK
4E1E  00                 .       BRK
4E1F  00                 .       BRK
4E20  00                 .       BRK
4E21  00                 .       BRK
4E22  00                 .       BRK
4E23  00                 .       BRK
4E24  00                 .       BRK
4E25  00                 .       BRK
4E26  00                 .       BRK
4E27  00                 .       BRK
4E28  00                 .       BRK
4E29  00                 .       BRK
4E2A  00                 .       BRK
4E2B  00                 .       BRK
4E2C  00                 .       BRK
4E2D  00                 .       BRK
4E2E  00                 .       BRK
4E2F  00                 .       BRK
4E30  00                 .       BRK
4E31  00                 .       BRK
4E32  00                 .       BRK
4E33  00                 .       BRK
4E34  00                 .       BRK
4E35  00                 .       BRK
4E36  80                 .       ...
4E37  40                 @       RTI
4E38  20 10

.
4E3A  8D 03 4E           ..N     STA &4E03                            ; Start of picture data
4E3D  20 46 56            FV     JSR &5646                            ; Switch to graphics mode
4E40  A0 00              ..      LDY #&00
.
4E42  B9 C5 00           ...     LDA &00C5,Y
4E45  99 00 57           ..W     STA &5700,Y
4E48  C8                 .       INY
4E49  C0 08              ..      CPY #&08
4E4B  D0 F5              ..      BNE &4E42
4E4D  A9 00              ..      LDA #&00
4E4F  20 54 50            TP     JSR &5054
4E52  A9 00              ..      LDA #&00                             ; Start of picture data (LSB)
4E54  85 C5              ..      STA &C5
4E56  AD 03 4E           ..N     LDA &4E03                            ; Start of picture data (MSB)
4E59  85 C6              ..      STA &C6
4E5B  A0 00              ..      LDY #&00
4E5D  B1 C5              ..      LDA (&C5),Y
4E5F  8D 41 55           .AU     STA &5541
4E62  C8                 .       INY
4E63  B1 C5              ..      LDA (&C5),Y
4E65  18                 .       CLC
4E66  6D 03 4E           m.N     ADC &4E03
4E69  8D 42 55           .BU     STA &5542
4E6C  A9 00              ..      LDA #&00
4E6E  8D 23 4E           .#N     STA &4E23
4E71  8D 24 4E           .$N     STA &4E24
4E74  20 8F 4E            .N     JSR &4E8F
4E77  EA                 .       NOP
4E78  20 E2 54            .T     JSR &54E2
4E7B  20 43 55            CU     JSR &5543
4E7E  20 4A 56            JV     JSR &564A
4E81  A0 00              ..      LDY #&00
.
4E83  B9 00 57           ..W     LDA &5700,Y
4E86  99 C5 00           ...     STA &00C5,Y
4E89  C8                 .       INY
4E8A  C0 08              ..      CPY #&08
4E8C  D0 F5              ..      BNE &4E83
4E8E  60                 `       RTS                                  ; Exit

.
4E8F  A9 02              ..      LDA #&02
4E91  85 C5              ..      STA &C5
4E93  AD 03 4E           ..N     LDA &4E03
4E96  85 C6              ..      STA &C6
4E98  20 6F 50            oP     JSR &506F
4E9B  20 D0 50            .P     JSR &50D0
4E9E  20 51 52            QR     JSR &5251
4EA1  60                 `       RTS
.
4EA2  A9 00              ..      LDA #&00
4EA4  8D 27 4E           .'N     STA &4E27
4EA7  8D 28 4E           .(N     STA &4E28
4EAA  AD 15 4E           ..N     LDA &4E15
4EAD  38                 8       SEC
4EAE  ED 25 4E           .%N     SBC &4E25
4EB1  8D 17 4E           ..N     STA &4E17
4EB4  B0 14              ..      BCS &4ECA
4EB6  A9 FF              ..      LDA #&FF
4EB8  8D 19 4E           ..N     STA &4E19
4EBB  8D 1B 4E           ..N     STA &4E1B
4EBE  A9 00              ..      LDA #&00
4EC0  38                 8       SEC
4EC1  ED 17 4E           ..N     SBC &4E17
4EC4  8D 1D 4E           ..N     STA &4E1D
4EC7  4C D5 4E           L.N     JMP &4ED5
.
4ECA  8D 1D 4E           ..N     STA &4E1D
4ECD  A9 01              ..      LDA #&01
4ECF  8D 19 4E           ..N     STA &4E19
4ED2  8D 1B 4E           ..N     STA &4E1B
.
4ED5  AD 16 4E           ..N     LDA &4E16
4ED8  38                 8       SEC
4ED9  ED 26 4E           .&N     SBC &4E26
4EDC  8D 18 4E           ..N     STA &4E18
4EDF  B0 11              ..      BCS &4EF2
4EE1  A9 FF              ..      LDA #&FF
4EE3  8D 1A 4E           ..N     STA &4E1A
4EE6  A9 00              ..      LDA #&00
4EE8  38                 8       SEC
4EE9  ED 18 4E           ..N     SBC &4E18
4EEC  8D 1E 4E           ..N     STA &4E1E
4EEF  4C FA 4E           L.N     JMP &4EFA
.
4EF2  8D 1E 4E           ..N     STA &4E1E
4EF5  A9 01              ..      LDA #&01
4EF7  8D 1A 4E           ..N     STA &4E1A
.
4EFA  A9 00              ..      LDA #&00
4EFC  8D 1C 4E           ..N     STA &4E1C
4EFF  AD 1D 4E           ..N     LDA &4E1D
4F02  38                 8       SEC
4F03  ED 1E 4E           ..N     SBC &4E1E
4F06  B0 18              ..      BCS &4F20
4F08  A9 00              ..      LDA #&00
4F0A  8D 1B 4E           ..N     STA &4E1B
4F0D  AD 1A 4E           ..N     LDA &4E1A
4F10  8D 1C 4E           ..N     STA &4E1C
4F13  AD 1D 4E           ..N     LDA &4E1D
4F16  AA                 .       TAX
4F17  AD 1E 4E           ..N     LDA &4E1E
4F1A  8D 1D 4E           ..N     STA &4E1D
4F1D  8E 1E 4E           ..N     STX &4E1E
.
4F20  AD 1D 4E           ..N     LDA &4E1D
4F23  AA                 .       TAX
4F24  E8                 .       INX
4F25  8E 21 4E           .!N     STX &4E21
4F28  4A                 J       LSR A
4F29  8D 1F 4E           ..N     STA &4E1F
4F2C  A9 00              ..      LDA #&00
4F2E  8D 20 4E           . N     STA &4E20
4F31  AD 25 4E           .%N     LDA &4E25
4F34  18                 .       CLC
4F35  6D 23 4E           m#N     ADC &4E23
4F38  8D 12 4E           ..N     STA &4E12
4F3B  90 05              ..      BCC &4F42
4F3D  A9 FF              ..      LDA #&FF
4F3F  8D 28 4E           .(N     STA &4E28
.
4F42  AD 26 4E           .&N     LDA &4E26
4F45  18                 .       CLC
4F46  6D 24 4E           m$N     ADC &4E24
4F49  8D 13 4E           ..N     STA &4E13
4F4C  B0 04              ..      BCS &4F52
4F4E  C9 98              ..      CMP #&98
4F50  90 05              ..      BCC &4F57
.
4F52  A9 FF              ..      LDA #&FF
4F54  8D 27 4E           .'N     STA &4E27
.
4F57  20 41 50            AP     JSR &5041
4F5A  CE 21 4E           .!N     DEC &4E21
4F5D  D0 0F              ..      BNE &4F6E
4F5F  AD 15 4E           ..N     LDA &4E15
4F62  8D 12 4E           ..N     STA &4E12
4F65  AD 16 4E           ..N     LDA &4E16
4F68  8D 13 4E           ..N     STA &4E13
4F6B  4C 40 50           L@P     JMP &5040
.
4F6E  A2 FF              ..      LDX #&FF
4F70  A0 00              ..      LDY #&00
4F72  AD 1F 4E           ..N     LDA &4E1F
4F75  18                 .       CLC
4F76  6D 1E 4E           m.N     ADC &4E1E
4F79  8D 1F 4E           ..N     STA &4E1F
4F7C  AD 20 4E           . N     LDA &4E20
4F7F  69 00              i.      ADC #&00
4F81  8D 20 4E           . N     STA &4E20
4F84  D0 08              ..      BNE &4F8E
4F86  AD 1F 4E           ..N     LDA &4E1F
4F89  CD 1D 4E           ..N     CMP &4E1D
4F8C  90 62              .b      BCC &4FF0
.
4F8E  AD 1F 4E           ..N     LDA &4E1F
4F91  38                 8       SEC
4F92  ED 1D 4E           ..N     SBC &4E1D
4F95  8D 1F 4E           ..N     STA &4E1F
4F98  AD 20 4E           . N     LDA &4E20
4F9B  E9 00              ..      SBC #&00
4F9D  8D 20 4E           . N     STA &4E20
4FA0  AD 12 4E           ..N     LDA &4E12
4FA3  18                 .       CLC
4FA4  6D 19 4E           m.N     ADC &4E19
4FA7  8D 12 4E           ..N     STA &4E12
4FAA  AD 19 4E           ..N     LDA &4E19
4FAD  30 0A              0.      BMI &4FB9
4FAF  F0 12              ..      BEQ &4FC3
4FB1  90 10              ..      BCC &4FC3
4FB3  8E 28 4E           .(N     STX &4E28
4FB6  4C C3 4F           L.O     JMP &4FC3
.
4FB9  AD 12 4E           ..N     LDA &4E12
4FBC  C9 FF              ..      CMP #&FF
4FBE  D0 03              ..      BNE &4FC3
4FC0  8C 28 4E           .(N     STY &4E28
.
4FC3  AD 13 4E           ..N     LDA &4E13
4FC6  18                 .       CLC
4FC7  6D 1A 4E           m.N     ADC &4E1A
4FCA  8D 13 4E           ..N     STA &4E13
4FCD  AD 1A 4E           ..N     LDA &4E1A
4FD0  30 11              0.      BMI &4FE3
4FD2  F0 19              ..      BEQ &4FED
4FD4  B0 07              ..      BCS &4FDD
4FD6  AD 13 4E           ..N     LDA &4E13
4FD9  C9 98              ..      CMP #&98
4FDB  90 10              ..      BCC &4FED
.
4FDD  8E 27 4E           .'N     STX &4E27
4FE0  4C ED 4F           L.O     JMP &4FED
.
4FE3  AD 13 4E           ..N     LDA &4E13
4FE6  C9 97              ..      CMP #&97
4FE8  D0 03              ..      BNE &4FED
4FEA  8C 27 4E           .'N     STY &4E27
.
4FED  4C 57 4F           LWO     JMP &4F57
.
4FF0  AD 12 4E           ..N     LDA &4E12
4FF3  18                 .       CLC
4FF4  6D 1B 4E           m.N     ADC &4E1B
4FF7  8D 12 4E           ..N     STA &4E12
4FFA  AD 19 4E           ..N     LDA &4E19
4FFD  30 0A              0.      BMI &5009
4FFF  F0 12              ..      BEQ &5013
5001  90 10              ..      BCC &5013
5003  8E 28 4E           .(N     STX &4E28
5006  4C 13 50           L.P     JMP &5013
.
5009  AD 12 4E           ..N     LDA &4E12
500C  C9 FF              ..      CMP #&FF
500E  D0 03              ..      BNE &5013
5010  8C 28 4E           .(N     STY &4E28
.
5013  AD 13 4E           ..N     LDA &4E13
5016  18                 .       CLC
5017  6D 1C 4E           m.N     ADC &4E1C
501A  8D 13 4E           ..N     STA &4E13
501D  AD 1A 4E           ..N     LDA &4E1A
5020  30 11              0.      BMI &5033
5022  F0 19              ..      BEQ &503D
5024  B0 07              ..      BCS &502D
5026  AD 13 4E           ..N     LDA &4E13
5029  C9 98              ..      CMP #&98
502B  90 10              ..      BCC &503D
.
502D  8E 27 4E           .'N     STX &4E27
5030  4C 57 4F           LWO     JMP &4F57
.
5033  AD 13 4E           ..N     LDA &4E13
5036  C9 97              ..      CMP #&97
5038  D0 03              ..      BNE &503D
503A  8C 27 4E           .'N     STY &4E27
.
503D  4C 57 4F           LWO     JMP &4F57
.
5040  60                 `       RTS
.
5041  AD 28 4E           .(N     LDA &4E28
5044  0D 27 4E           .'N     ORA &4E27
5047  D0 0A              ..      BNE &5053
5049  20 59 54            YT     JSR &5459
504C  B0 05              ..      BCS &5053
504E  1D 36 4E           .6N     ORA &4E36,X
5051  91 C9              ..      STA (&C9),Y
.
5053  60                 `       RTS
.
5054  48                 H       PHA
5055  AD 05 4E           ..N     LDA &4E05
5058  85 C9              ..      STA &C9
505A  AD 06 4E           ..N     LDA &4E06
505D  85 CA              ..      STA &CA
505F  A2 20              .       LDX #&20
5061  A0 00              ..      LDY #&00
5063  68                 h       PLA
.
5064  91 C9              ..      STA (&C9),Y
5066  88                 .       DEY
5067  D0 FB              ..      BNE &5064
5069  E6 CA              ..      INC &CA
506B  CA                 .       DEX
506C  D0 F6              ..      BNE &5064
506E  60                 `       RTS
.
506F  A0 00              ..      LDY #&00
5071  B1 C5              ..      LDA (&C5),Y
5073  18                 .       CLC
5074  69 02              i.      ADC #&02
5076  8D 0B 4E           ..N     STA &4E0B
5079  C8                 .       INY
507A  B1 C5              ..      LDA (&C5),Y
507C  6D 03 4E           m.N     ADC &4E03
507F  8D 0C 4E           ..N     STA &4E0C
5082  C8                 .       INY
5083  B1 C5              ..      LDA (&C5),Y
5085  8D 0F 4E           ..N     STA &4E0F
5088  C8                 .       INY
5089  B1 C5              ..      LDA (&C5),Y
508B  18                 .       CLC
508C  69 02              i.      ADC #&02
508E  8D 0D 4E           ..N     STA &4E0D
5091  C8                 .       INY
5092  B1 C5              ..      LDA (&C5),Y
5094  6D 03 4E           m.N     ADC &4E03
5097  8D 0E 4E           ..N     STA &4E0E
509A  C8                 .       INY
509B  B1 C5              ..      LDA (&C5),Y
509D  8D 2E 4E           ..N     STA &4E2E
50A0  C8                 .       INY
50A1  B1 C5              ..      LDA (&C5),Y
50A3  8D 2F 4E           ./N     STA &4E2F
50A6  C8                 .       INY
50A7  B1 C5              ..      LDA (&C5),Y
50A9  8D 30 4E           .0N     STA &4E30
50AC  C8                 .       INY
50AD  B1 C5              ..      LDA (&C5),Y
50AF  8D 31 4E           .1N     STA &4E31
50B2  A9 09              ..      LDA #&09
50B4  18                 .       CLC
50B5  65 C5              e.      ADC &C5
50B7  85 C5              ..      STA &C5
50B9  90 02              ..      BCC &50BD
50BB  E6 C6              ..      INC &C6
.
50BD  A0 00              ..      LDY #&00
50BF  B1 C5              ..      LDA (&C5),Y
50C1  8D 34 4E           .4N     STA &4E34
50C4  8C 12 4E           ..N     STY &4E12
50C7  8C 13 4E           ..N     STY &4E13
50CA  A9 08              ..      LDA #&08
50CC  8D 32 4E           .2N     STA &4E32
50CF  60                 `       RTS
.
50D0  A5 C5              ..      LDA &C5
50D2  CD 0B 4E           ..N     CMP &4E0B
50D5  D0 13              ..      BNE &50EA
50D7  A5 C6              ..      LDA &C6
50D9  CD 0C 4E           ..N     CMP &4E0C
50DC  D0 0C              ..      BNE &50EA
50DE  A9 08              ..      LDA #&08
50E0  38                 8       SEC
50E1  ED 32 4E           .2N     SBC &4E32
50E4  CD 0F 4E           ..N     CMP &4E0F
50E7  D0 01              ..      BNE &50EA
50E9  60                 `       RTS
.
50EA  20 1A 52            .R     JSR &521A
50ED  90 37              .7      BCC &5126
50EF  20 3B 51            ;Q     JSR &513B
50F2  AD 15 4E           ..N     LDA &4E15
50F5  18                 .       CLC
50F6  6D 23 4E           m#N     ADC &4E23
50F9  8D 12 4E           ..N     STA &4E12
50FC  08                 .       PHP
50FD  AD 16 4E           ..N     LDA &4E16
5100  18                 .       CLC
5101  6D 24 4E           m$N     ADC &4E24
5104  8D 13 4E           ..N     STA &4E13
5107  B0 19              ..      BCS &5122
5109  C9 98              ..      CMP #&98
510B  B0 15              ..      BCS &5122
510D  28                 (       PLP
510E  B0 03              ..      BCS &5113
5110  20 41 50            AP     JSR &5041
.
5113  AD 15 4E           ..N     LDA &4E15
5116  8D 12 4E           ..N     STA &4E12
5119  AD 16 4E           ..N     LDA &4E16
511C  8D 13 4E           ..N     STA &4E13
511F  4C D0 50           L.P     JMP &50D0
.
5122  28                 (       PLP
5123  4C 13 51           L.Q     JMP &5113
.
5126  20 3B 51            ;Q     JSR &513B
5129  AD 12 4E           ..N     LDA &4E12
512C  8D 25 4E           .%N     STA &4E25
512F  AD 13 4E           ..N     LDA &4E13
5132  8D 26 4E           .&N     STA &4E26
5135  20 A2 4E            .N     JSR &4EA2
5138  4C D0 50           L.P     JMP &50D0
.
513B  20 1A 52            .R     JSR &521A
513E  90 5F              ._      BCC &519F
5140  20 1A 52            .R     JSR &521A
5143  90 18              ..      BCC &515D
5145  AD 2E 4E           ..N     LDA &4E2E
5148  4A                 J       LSR A
5149  4A                 J       LSR A
514A  4A                 J       LSR A
514B  4A                 J       LSR A
514C  AA                 .       TAX
514D  E0 08              ..      CPX #&08
514F  90 12              ..      BCC &5163
5151  20 34 52            4R     JSR &5234
5154  AD 33 4E           .3N     LDA &4E33
5157  8D 15 4E           ..N     STA &4E15
515A  4C 70 51           LpQ     JMP &5170
.
515D  AD 2E 4E           ..N     LDA &4E2E
5160  29 0F              ).      AND #&0F
5162  AA                 .       TAX
.
5163  20 34 52            4R     JSR &5234
5166  AD 33 4E           .3N     LDA &4E33
5169  18                 .       CLC
516A  6D 12 4E           m.N     ADC &4E12
516D  8D 15 4E           ..N     STA &4E15
.
5170  20 1A 52            .R     JSR &521A
5173  90 16              ..      BCC &518B
5175  AD 2F 4E           ./N     LDA &4E2F
5178  4A                 J       LSR A
5179  4A                 J       LSR A
517A  4A                 J       LSR A
517B  4A                 J       LSR A
517C  AA                 .       TAX
517D  E0 08              ..      CPX #&08
517F  90 10              ..      BCC &5191
5181  20 34 52            4R     JSR &5234
5184  AD 33 4E           .3N     LDA &4E33
5187  8D 16 4E           ..N     STA &4E16
518A  60                 `       RTS
.
518B  AD 2F 4E           ./N     LDA &4E2F
518E  29 0F              ).      AND #&0F
5190  AA                 .       TAX
.
5191  20 34 52            4R     JSR &5234
5194  AD 33 4E           .3N     LDA &4E33
5197  18                 .       CLC
5198  6D 13 4E           m.N     ADC &4E13
519B  8D 16 4E           ..N     STA &4E16
519E  60                 `       RTS
.
519F  20 1A 52            .R     JSR &521A
51A2  90 3B              .;      BCC &51DF
51A4  20 1A 52            .R     JSR &521A
51A7  90 1C              ..      BCC &51C5
51A9  AD 31 4E           .1N     LDA &4E31
51AC  4A                 J       LSR A
51AD  4A                 J       LSR A
51AE  4A                 J       LSR A
51AF  4A                 J       LSR A
51B0  AA                 .       TAX
51B1  E0 08              ..      CPX #&08
51B3  90 16              ..      BCC &51CB
51B5  20 34 52            4R     JSR &5234
51B8  AD 33 4E           .3N     LDA &4E33
51BB  8D 16 4E           ..N     STA &4E16
51BE  AD 12 4E           ..N     LDA &4E12
51C1  8D 15 4E           ..N     STA &4E15
51C4  60                 `       RTS
.
51C5  AD 31 4E           .1N     LDA &4E31
51C8  29 0F              ).      AND #&0F
51CA  AA                 .       TAX
.
51CB  20 34 52            4R     JSR &5234
51CE  AD 33 4E           .3N     LDA &4E33
51D1  18                 .       CLC
51D2  6D 13 4E           m.N     ADC &4E13
51D5  8D 16 4E           ..N     STA &4E16
51D8  AD 12 4E           ..N     LDA &4E12
51DB  8D 15 4E           ..N     STA &4E15
51DE  60                 `       RTS
.
51DF  20 1A 52            .R     JSR &521A
51E2  90 1C              ..      BCC &5200
51E4  AD 30 4E           .0N     LDA &4E30
51E7  4A                 J       LSR A
51E8  4A                 J       LSR A
51E9  4A                 J       LSR A
51EA  4A                 J       LSR A
51EB  AA                 .       TAX
51EC  E0 08              ..      CPX #&08
51EE  90 16              ..      BCC &5206
51F0  20 34 52            4R     JSR &5234
51F3  AD 33 4E           .3N     LDA &4E33
51F6  8D 15 4E           ..N     STA &4E15
51F9  AD 13 4E           ..N     LDA &4E13
51FC  8D 16 4E           ..N     STA &4E16
51FF  60                 `       RTS
.
5200  AD 30 4E           .0N     LDA &4E30
5203  29 0F              ).      AND #&0F
5205  AA                 .       TAX
.
5206  20 34 52            4R     JSR &5234
5209  AD 33 4E           .3N     LDA &4E33
520C  18                 .       CLC
520D  6D 12 4E           m.N     ADC &4E12
5210  8D 15 4E           ..N     STA &4E15
5213  AD 13 4E           ..N     LDA &4E13
5216  8D 16 4E           ..N     STA &4E16
5219  60                 `       RTS
.
521A  0E 34 4E           .4N     ASL &4E34
521D  CE 32 4E           .2N     DEC &4E32
5220  D0 11              ..      BNE &5233
5222  A9 08              ..      LDA #&08
5224  8D 32 4E           .2N     STA &4E32
5227  20 38 55            8U     JSR &5538
522A  08                 .       PHP
522B  28                 (       PLP
522C  A0 00              ..      LDY #&00
522E  B1 C5              ..      LDA (&C5),Y
5230  8D 34 4E           .4N     STA &4E34
.
5233  60                 `       RTS
.
5234  A9 00              ..      LDA #&00
5236  8D 33 4E           .3N     STA &4E33
5239  CA                 .       DEX
523A  8E 21 4E           .!N     STX &4E21
523D  20 1A 52            .R     JSR &521A
5240  90 03              ..      BCC &5245
5242  CE 33 4E           .3N     DEC &4E33
.
5245  20 1A 52            .R     JSR &521A
5248  2E 33 4E           .3N     ROL &4E33
524B  CE 21 4E           .!N     DEC &4E21
524E  D0 F5              ..      BNE &5245
5250  60                 `       RTS
.
5251  AD 0F 4E           ..N     LDA &4E0F
5254  F0 03              ..      BEQ &5259
5256  20 38 55            8U     JSR &5538
.
5259  A5 C5              ..      LDA &C5
525B  CD 0D 4E           ..N     CMP &4E0D
525E  D0 08              ..      BNE &5268
5260  A5 C6              ..      LDA &C6
5262  CD 0E 4E           ..N     CMP &4E0E
5265  D0 01              ..      BNE &5268
5267  60                 `       RTS
.
5268  A0 00              ..      LDY #&00
526A  B1 C5              ..      LDA (&C5),Y
526C  8D 13 4E           ..N     STA &4E13
526F  20 38 55            8U     JSR &5538
5272  B1 C5              ..      LDA (&C5),Y
5274  8D 12 4E           ..N     STA &4E12
5277  20 38 55            8U     JSR &5538
527A  20 80 52            .R     JSR &5280
527D  4C 59 52           LYR     JMP &5259
.
5280  A9 00              ..      LDA #&00
5282  8D 27 4E           .'N     STA &4E27
5285  8D 28 4E           .(N     STA &4E28
5288  BA                 .       TSX
5289  8E 2B 4E           .+N     STX &4E2B
528C  AD 13 4E           ..N     LDA &4E13
528F  18                 .       CLC
5290  6D 24 4E           m$N     ADC &4E24
5293  8D 13 4E           ..N     STA &4E13
5296  B0 04              ..      BCS &529C
5298  C9 98              ..      CMP #&98
529A  90 01              ..      BCC &529D
.
529C  60                 `       RTS
.
529D  AD 12 4E           ..N     LDA &4E12
52A0  18                 .       CLC
52A1  6D 23 4E           m#N     ADC &4E23
52A4  8D 12 4E           ..N     STA &4E12
52A7  B0 F3              ..      BCS &529C
.
52A9  20 59 54            YT     JSR &5459
52AC  18                 .       CLC
52AD  AC 35 4E           .5N     LDY &4E35
52B0  AE 14 4E           ..N     LDX &4E14
52B3  B1 C9              ..      LDA (&C9),Y
52B5  3D 36 4E           =6N     AND &4E36,X
52B8  F0 01              ..      BEQ &52BB
52BA  38                 8       SEC
.
52BB  B0 0B              ..      BCS &52C8
.
52BD  20 D7 53            .S     JSR &53D7
52C0  B0 06              ..      BCS &52C8
52C2  20 0D 54            .T     JSR &540D
52C5  4C BD 52           L.R     JMP &52BD
.
52C8  A9 00              ..      LDA #&00
52CA  8D 2C 4E           .,N     STA &4E2C
52CD  8D 2D 4E           .-N     STA &4E2D
.
52D0  20 41 50            AP     JSR &5041
52D3  20 3B 53            ;S     JSR &533B
52D6  B0 16              ..      BCS &52EE
52D8  AD 2C 4E           .,N     LDA &4E2C
52DB  D0 16              ..      BNE &52F3
52DD  AE 13 4E           ..N     LDX &4E13
52E0  CA                 .       DEX
52E1  8A                 .       TXA
52E2  48                 H       PHA
52E3  AD 12 4E           ..N     LDA &4E12
52E6  48                 H       PHA
52E7  A9 01              ..      LDA #&01
52E9  8D 2C 4E           .,N     STA &4E2C
52EC  D0 05              ..      BNE &52F3
.
52EE  A9 00              ..      LDA #&00
52F0  8D 2C 4E           .,N     STA &4E2C
.
52F3  20 8C 53            .S     JSR &538C
52F6  B0 16              ..      BCS &530E
52F8  AD 2D 4E           .-N     LDA &4E2D
52FB  D0 16              ..      BNE &5313
52FD  AE 13 4E           ..N     LDX &4E13
5300  E8                 .       INX
5301  8A                 .       TXA
5302  48                 H       PHA
5303  AD 12 4E           ..N     LDA &4E12
5306  48                 H       PHA
5307  A9 01              ..      LDA #&01
5309  8D 2D 4E           .-N     STA &4E2D
530C  D0 05              ..      BNE &5313
.
530E  A9 00              ..      LDA #&00
5310  8D 2D 4E           .-N     STA &4E2D
.
5313  20 31 54            1T     JSR &5431
5316  B0 11              ..      BCS &5329
5318  18                 .       CLC
5319  AC 35 4E           .5N     LDY &4E35
531C  AE 14 4E           ..N     LDX &4E14
531F  B1 C9              ..      LDA (&C9),Y
5321  3D 36 4E           =6N     AND &4E36,X
5324  F0 01              ..      BEQ &5327
5326  38                 8       SEC
.
5327  90 A7              ..      BCC &52D0
.
5329  BA                 .       TSX
532A  EC 2B 4E           .+N     CPX &4E2B
532D  F0 0B              ..      BEQ &533A
532F  68                 h       PLA
5330  8D 12 4E           ..N     STA &4E12
5333  68                 h       PLA
5334  8D 13 4E           ..N     STA &4E13
5337  4C A9 52           L.R     JMP &52A9
.
533A  60                 `       RTS
.
533B  AD 13 4E           ..N     LDA &4E13
533E  F0 4A              .J      BEQ &538A
5340  A5 C9              ..      LDA &C9
5342  48                 H       PHA
5343  A5 CA              ..      LDA &CA
5345  48                 H       PHA
5346  AD 35 4E           .5N     LDA &4E35
5349  48                 H       PHA
534A  29 07              ).      AND #&07
534C  F0 11              ..      BEQ &535F
534E  CE 35 4E           .5N     DEC &4E35
5351  48                 H       PHA
5352  AD 35 4E           .5N     LDA &4E35
5355  C9 FF              ..      CMP #&FF
5357  D0 02              ..      BNE &535B
5359  C6 CA              ..      DEC &CA
.
535B  68                 h       PLA
535C  4C 70 53           LpS     JMP &5370
.
535F  A9 07              ..      LDA #&07
5361  0D 35 4E           .5N     ORA &4E35
5364  8D 35 4E           .5N     STA &4E35
5367  38                 8       SEC
5368  A5 C9              ..      LDA &C9
536A  A5 CA              ..      LDA &CA
536C  E9 02              ..      SBC #&02
536E  85 CA              ..      STA &CA
.
5370  18                 .       CLC
5371  AC 35 4E           .5N     LDY &4E35
5374  AE 14 4E           ..N     LDX &4E14
5377  B1 C9              ..      LDA (&C9),Y
5379  3D 36 4E           =6N     AND &4E36,X
537C  F0 01              ..      BEQ &537F
537E  38                 8       SEC
.
537F  68                 h       PLA
5380  8D 35 4E           .5N     STA &4E35
5383  68                 h       PLA
5384  85 CA              ..      STA &CA
5386  68                 h       PLA
5387  85 C9              ..      STA &C9
5389  60                 `       RTS
.
538A  38                 8       SEC
538B  60                 `       RTS
.
538C  AD 13 4E           ..N     LDA &4E13
538F  C9 97              ..      CMP #&97
5391  B0 43              .C      BCS &53D6
5393  A5 C9              ..      LDA &C9
5395  48                 H       PHA
5396  A5 CA              ..      LDA &CA
5398  48                 H       PHA
5399  AD 35 4E           .5N     LDA &4E35
539C  48                 H       PHA
539D  29 07              ).      AND #&07
539F  C9 07              ..      CMP #&07
53A1  F0 0B              ..      BEQ &53AE
53A3  EE 35 4E           .5N     INC &4E35
53A6  D0 02              ..      BNE &53AA
53A8  E6 CA              ..      INC &CA
.
53AA  EA                 .       NOP
53AB  4C BD 53           L.S     JMP &53BD
.
53AE  18                 .       CLC
53AF  A5 CA              ..      LDA &CA
53B1  69 02              i.      ADC #&02
53B3  85 CA              ..      STA &CA
53B5  AD 35 4E           .5N     LDA &4E35
53B8  29 F8              ).      AND #&F8
53BA  8D 35 4E           .5N     STA &4E35
.
53BD  18                 .       CLC
53BE  AC 35 4E           .5N     LDY &4E35
53C1  AE 14 4E           ..N     LDX &4E14
53C4  B1 C9              ..      LDA (&C9),Y
53C6  3D 36 4E           =6N     AND &4E36,X
53C9  F0 01              ..      BEQ &53CC
53CB  38                 8       SEC
.
53CC  68                 h       PLA
53CD  8D 35 4E           .5N     STA &4E35
53D0  68                 h       PLA
53D1  85 CA              ..      STA &CA
53D3  68                 h       PLA
53D4  85 C9              ..      STA &C9
.
53D6  60                 `       RTS
.
53D7  AD 12 4E           ..N     LDA &4E12
53DA  F0 2F              ./      BEQ &540B
53DC  A5 C9              ..      LDA &C9
53DE  48                 H       PHA
53DF  A5 CA              ..      LDA &CA
53E1  48                 H       PHA
53E2  AD 35 4E           .5N     LDA &4E35
53E5  48                 H       PHA
53E6  AD 14 4E           ..N     LDA &4E14
53E9  48                 H       PHA
53EA  20 15 54            .T     JSR &5415
53ED  18                 .       CLC
53EE  AC 35 4E           .5N     LDY &4E35
53F1  AE 14 4E           ..N     LDX &4E14
53F4  B1 C9              ..      LDA (&C9),Y
53F6  3D 36 4E           =6N     AND &4E36,X
53F9  F0 01              ..      BEQ &53FC
53FB  38                 8       SEC
.
53FC  68                 h       PLA
53FD  8D 14 4E           ..N     STA &4E14
5400  68                 h       PLA
5401  8D 35 4E           .5N     STA &4E35
5404  68                 h       PLA
5405  85 CA              ..      STA &CA
5407  68                 h       PLA
5408  85 C9              ..      STA &C9
540A  60                 `       RTS
.
540B  38                 8       SEC
540C  60                 `       RTS
.
540D  AD 12 4E           ..N     LDA &4E12
5410  F0 1D              ..      BEQ &542F
5412  CE 12 4E           ..N     DEC &4E12
.
5415  AE 14 4E           ..N     LDX &4E14
5418  CA                 .       DEX
5419  10 0F              ..      BPL &542A
541B  A2 03              ..      LDX #&03
541D  38                 8       SEC
541E  AD 35 4E           .5N     LDA &4E35
5421  E9 08              ..      SBC #&08
5423  8D 35 4E           .5N     STA &4E35
5426  B0 02              ..      BCS &542A
5428  C6 CA              ..      DEC &CA
.
542A  8E 14 4E           ..N     STX &4E14
542D  18                 .       CLC
542E  60                 `       RTS
.
542F  38                 8       SEC
5430  60                 `       RTS
.
5431  AD 12 4E           ..N     LDA &4E12
5434  C9 FF              ..      CMP #&FF
5436  F0 1F              ..      BEQ &5457
5438  EE 12 4E           ..N     INC &4E12
543B  AE 14 4E           ..N     LDX &4E14
543E  E8                 .       INX
543F  E0 04              ..      CPX #&04
5441  D0 0F              ..      BNE &5452
5443  A2 00              ..      LDX #&00
5445  18                 .       CLC
5446  AD 35 4E           .5N     LDA &4E35
5449  69 08              i.      ADC #&08
544B  8D 35 4E           .5N     STA &4E35
544E  90 02              ..      BCC &5452
5450  E6 CA              ..      INC &CA
.
5452  8E 14 4E           ..N     STX &4E14
5455  18                 .       CLC
5456  60                 `       RTS
.
5457  38                 8       SEC
5458  60                 `       RTS
.
5459  AD 13 4E           ..N     LDA &4E13
545C  29 F8              ).      AND #&F8
545E  4A                 J       LSR A
545F  4A                 J       LSR A
5460  A8                 .       TAY
5461  B9 B0 54           ..T     LDA &54B0,Y
5464  85 C9              ..      STA &C9
5466  B9 B1 54           ..T     LDA &54B1,Y
5469  85 CA              ..      STA &CA
546B  AD 12 4E           ..N     LDA &4E12
546E  0A                 .       ASL A
546F  A8                 .       TAY
5470  A9 00              ..      LDA #&00
5472  2A                 *       ROL A
5473  AA                 .       TAX
5474  98                 .       TYA
5475  29 F8              ).      AND #&F8
5477  8D 35 4E           .5N     STA &4E35
547A  18                 .       CLC
547B  65 C9              e.      ADC &C9
547D  8A                 .       TXA
547E  65 CA              e.      ADC &CA
5480  85 CA              ..      STA &CA
5482  AD 13 4E           ..N     LDA &4E13
5485  29 07              ).      AND #&07
5487  18                 .       CLC
5488  6D 35 4E           m5N     ADC &4E35
548B  8D 35 4E           .5N     STA &4E35
548E  A8                 .       TAY
548F  AD 12 4E           ..N     LDA &4E12
5492  29 03              ).      AND #&03
5494  8D 14 4E           ..N     STA &4E14
5497  AA                 .       TAX
5498  98                 .       TYA
5499  18                 .       CLC
549A  65 C9              e.      ADC &C9
549C  8D AE 54           ..T     STA &54AE
549F  A5 CA              ..      LDA &CA
54A1  69 00              i.      ADC #&00
54A3  8D AF 54           ..T     STA &54AF
54A6  AD AF 54           ..T     LDA &54AF
54A9  C9 7C              .|      CMP #&7C
54AB  B1 C9              ..      LDA (&C9),Y
54AD  60                 `       RTS
54AE  00                 .       BRK
54AF  00                 .       BRK
54B0  00                 .       BRK
54B1  5C                 \       ...
54B2  00                 .       BRK
54B3  5E 00 60           ^.`     LSR &6000,Y
54B6  00                 .       BRK
54B7  62                 b       ...
54B8  00                 .       BRK
54B9  64                 d       ...
54BA  00                 .       BRK
54BB  66 00              f.      ROR &00
54BD  68                 h       PLA
54BE  00                 .       BRK
54BF  6A                 j       ROR A
54C0  00                 .       BRK
54C1  6C 00 6E           l.n     JMP (&6E00)
54C4  00                 .       BRK
54C5  70 00              p.      BVS &54C7
.
54C7  72                 r       ...
54C8  00                 .       BRK
54C9  74                 t       ...
54CA  00                 .       BRK
54CB  76 00              v.      ROR &00,X
54CD  78                 x       SEI
54CE  00                 .       BRK
54CF  7A                 z       ...
54D0  00                 .       BRK
54D1  7C                 |       ...
54D2  00                 .       BRK
54D3  7E 00 80           ~..     ROR &8000,X
54D6  00                 .       BRK
54D7  82                 .       ...
54D8  00                 .       BRK
54D9  84 00              ..      STY &00
54DB  86 00              ..      STX &00
54DD  88                 .       DEY
54DE  00                 .       BRK
54DF  8A                 .       TXA
54E0  00                 .       BRK
54E1  8C AD 41           ..A     STY &41AD
54E4  55 85              U.      EOR &85,X
54E6  C5 AD              ..      CMP &AD
54E8  42                 B       ...
54E9  55 85              U.      EOR &85,X
54EB  C6 A9              ..      DEC &A9
54ED  00                 .       BRK
54EE  8D 09 4E           ..N     STA &4E09
54F1  20 F9 54            .T     JSR &54F9
54F4  A9 FF              ..      LDA #&FF
54F6  8D 09 4E           ..N     STA &4E09
.
54F9  AD 10 4E           ..N     LDA &4E10
54FC  85 CD              ..      STA &CD
54FE  AD 11 4E           ..N     LDA &4E11
5501  85 CE              ..      STA &CE
.
5503  EA                 .       NOP
5504  A0 00              ..      LDY #&00
5506  B1 C5              ..      LDA (&C5),Y
5508  20 38 55            8U     JSR &5538
550B  A8                 .       TAY
550C  29 0F              ).      AND #&0F
550E  AA                 .       TAX
550F  F0 26              .&      BEQ &5537
5511  98                 .       TYA
5512  29 F0              ).      AND #&F0
5514  2C 09 4E           ,.N     BIT &4E09
5517  10 04              ..      BPL &551D
5519  4A                 J       LSR A
551A  4A                 J       LSR A
551B  4A                 J       LSR A
551C  4A                 J       LSR A
.
551D  8D 07 4E           ..N     STA &4E07
5520  A0 00              ..      LDY #&00
.
5522  B1 CD              ..      LDA (&CD),Y
5524  2D 09 4E           -.N     AND &4E09
5527  0D 07 4E           ..N     ORA &4E07
552A  91 CD              ..      STA (&CD),Y
552C  E6 CD              ..      INC &CD
552E  D0 02              ..      BNE &5532
5530  E6 CE              ..      INC &CE
.
5532  CA                 .       DEX
5533  D0 ED              ..      BNE &5522
5535  F0 CC              ..      BEQ &5503
.
5537  60                 `       RTS
.
5538  08                 .       PHP
5539  E6 C5              ..      INC &C5
553B  D0 02              ..      BNE &553F
553D  E6 C6              ..      INC &C6
.
553F  28                 (       PLP
5540  60                 `       RTS
5541  00                 .       BRK
5542  00                 .       BRK
.
5543  A9 00              ..      LDA #&00                             ; Start address of screen LSB
5545  85 C5              ..      STA &C5
5547  A9 5C              .\      LDA #&5C                             ; Start address of screen MSB
5549  85 C6              ..      STA &C6
554B  AD 10 4E           ..N     LDA &4E10
554E  18                 .       CLC
554F  69 04              i.      ADC #&04
5551  85 CD              ..      STA &CD
5553  AD 11 4E           ..N     LDA &4E11
5556  69 00              i.      ADC #&00
5558  85 CE              ..      STA &CE
555A  A9 00              ..      LDA #&00
555C  8D 43 56           .CV     STA &5643
555F  8D 44 56           .DV     STA &5644
.
5562  A0 00              ..      LDY #&00
5564  B1 CD              ..      LDA (&CD),Y
5566  AA                 .       TAX
5567  4A                 J       LSR A
5568  4A                 J       LSR A
5569  4A                 J       LSR A
556A  4A                 J       LSR A
556B  A8                 .       TAY
556C  B9 18 56           ..V     LDA &5618,Y
556F  A8                 .       TAY
5570  4A                 J       LSR A
5571  4A                 J       LSR A
5572  8D 3C 56           .<V     STA &563C
5575  98                 .       TYA
5576  29 03              ).      AND #&03
5578  8D 3D 56           .=V     STA &563D
557B  8A                 .       TXA
557C  29 0F              ).      AND #&0F
557E  AA                 .       TAX
557F  BD 18 56           ..V     LDA &5618,X
5582  AA                 .       TAX
5583  4A                 J       LSR A
5584  4A                 J       LSR A
5585  8D 3E 56           .>V     STA &563E
5588  8A                 .       TXA
5589  29 03              ).      AND #&03
558B  8D 3F 56           .?V     STA &563F
558E  A9 10              ..      LDA #&10
5590  8D 40 56           .@V     STA &5640
.
5593  A0 00              ..      LDY #&00
5595  8C 42 56           .BV     STY &5642
5598  B1 C5              ..      LDA (&C5),Y
559A  8D 41 56           .AV     STA &5641
559D  A2 00              ..      LDX #&00
.
559F  8E 45 56           .EV     STX &5645
55A2  0E 41 56           .AV     ASL &5641
55A5  B0 0D              ..      BCS &55B4
55A7  8A                 .       TXA
55A8  29 01              ).      AND #&01
55AA  2D 40 56           -@V     AND &5640
55AD  A8                 .       TAY
55AE  B9 3E 56           .>V     LDA &563E,Y
55B1  4C BE 55           L.U     JMP &55BE
.
55B4  8A                 .       TXA
55B5  29 01              ).      AND #&01
55B7  2D 40 56           -@V     AND &5640
55BA  A8                 .       TAY
55BB  B9 3C 56           .<V     LDA &563C,Y
.
55BE  A8                 .       TAY
55BF  B9 28 56           .(V     LDA &5628,Y
55C2  18                 .       CLC
55C3  6D 45 56           mEV     ADC &5645
55C6  A8                 .       TAY
55C7  B9 2C 56           .,V     LDA &562C,Y
55CA  0D 42 56           .BV     ORA &5642
55CD  8D 42 56           .BV     STA &5642
55D0  E8                 .       INX
55D1  E0 04              ..      CPX #&04
55D3  D0 CA              ..      BNE &559F
55D5  A0 00              ..      LDY #&00
55D7  AD 42 56           .BV     LDA &5642
55DA  91 C5              ..      STA (&C5),Y
55DC  E6 C5              ..      INC &C5
55DE  D0 02              ..      BNE &55E2
55E0  E6 C6              ..      INC &C6
.
55E2  CE 40 56           .@V     DEC &5640
55E5  D0 AC              ..      BNE &5593
55E7  E6 CD              ..      INC &CD
55E9  D0 02              ..      BNE &55ED
55EB  E6 CE              ..      INC &CE
.
55ED  EE 43 56           .CV     INC &5643
55F0  AD 43 56           .CV     LDA &5643
55F3  C9 20              .       CMP #&20
55F5  F0 03              ..      BEQ &55FA
55F7  4C 62 55           LbU     JMP &5562
.
55FA  A9 08              ..      LDA #&08
55FC  18                 .       CLC
55FD  65 CD              e.      ADC &CD
55FF  85 CD              ..      STA &CD
5601  90 02              ..      BCC &5605
5603  E6 CE              ..      INC &CE
.
5605  A9 00              ..      LDA #&00
5607  8D 43 56           .CV     STA &5643
560A  EE 44 56           .DV     INC &5644
560D  AD 44 56           .DV     LDA &5644
5610  C9 10              ..      CMP #&10
5612  F0 03              ..      BEQ &5617
5614  4C 62 55           LbU     JMP &5562
.
5617  60                 `       RTS

.
5618  00                 .       BRK
5619  0A                 .       ASL A
561A  05 0E              ..      ORA &0E
561C  0D 08 0C           ...     ORA &0C08
561F  09 06              ..      ORA #&06
5621  04                 .       ...
5622  05 03              ..      ORA &03
5624  03                 .       ...
5625  0B                 .       ...
5626  0F                 .       ...
5627  00                 .       BRK

.
5628  00                 .       BRK
5629  04                 .       ...
562A  08                 .       PHP
562B  0C                 .       ...
562C  00                 .       BRK
562D  00                 .       BRK
562E  00                 .       BRK
562F  00                 .       BRK
5630  08                 .       PHP
5631  04                 .       ...
5632  02                 .       ...
5633  01 80              ..      ORA (&80,X)
5635  40                 @       RTI
5636  20 10 88            ..     JSR &8810
5639  44                 D       ...
563A  22                 "       ...
563B  11 00              ..      ORA (&00),Y
563D  00                 .       BRK
563E  00                 .       BRK
563F  00                 .       BRK
5640  00                 .       BRK
5641  00                 .       BRK
5642  00                 .       BRK
5643  00                 .       BRK
5644  00                 .       BRK
5645  00                 .       BRK
.
5646  20 61 56            aV     JSR &5661                            ; Switch to graphics mode
5649  60                 `       RTS
.
564A  20 B3 56            .V     JSR &56B3                            ; Get user input (<ENTER> or <TAB>)
564D  B0 0E              ..      BCS &565D                            ; Jump if <ENTER>
564F  20 C4 56            .V     JSR &56C4                            ; Switch to text mode
5652  20 B3 56            .V     JSR &56B3                            ; Get user input (<ENTER> or <TAB>)
5655  B0 06              ..      BCS &565D                            ; Jump if <ENTER>
5657  20 61 56            aV     JSR &5661                            ; Switch to graphics mode
565A  4C 4A 56           LJV     JMP &564A                            ; Repeat
.
565D  20 C4 56            .V     JSR &56C4                            ; Switch to text mode
5660  60                 `       RTS

; -----------------------------------------------------------------------------
; Switch to graphics mode
; -----------------------------------------------------------------------------
.
5661  A9 13              ..      LDA #&13
5663  20 F4 FF            ..     JSR osbyte                           ; OSBYTE &13: Wait for vertical sync
5666  78                 x       SEI
5667  20 E7 56            .V     JSR &56E7                            ; Wait loop
566A  A2 00              ..      LDX #&00
.
566C  BD 93 56           ..V     LDA &5693,X
566F  49 07              I.      EOR #&07
5671  8D 21 FE           .!.     STA video_ula_palette
5674  E8                 .       INX
5675  E0 10              ..      CPX #&10
5677  90 F3              ..      BCC &566C
5679  A2 00              ..      LDX #&00
.
567B  BD A3 56           ..V     LDA &56A3,X
567E  8E 00 FE           ...     STX crtc_register
5681  8D 01 FE           ...     STA crtc_data
5684  E8                 .       INX
5685  E0 0F              ..      CPX #&0F
5687  90 F2              ..      BCC &567B
5689  A9 18              ..      LDA #%00011000                       ; bit 0=0: first flash colour selected, bit 1=0: video ULA selected, bit 2-3=01: 20 characters per line, bit 4=1:high frequency clock, bit5-6=00: 1 byte per cursor, bit7=0: small cursor
568B  8D 20 FE           . .     STA video_ula_control
568E  8D 48 02           .H.     STA &0248                            ; Also update the OS copy of the video ULA control register (OSBYTE &B8)
5691  58                 X       CLI
5692  60                 `       RTS

.
5693  00                 .       DB  &00
5694  10                 .       DB  &10
5695  40                 @       DB  &40  
5696  50                 P       DB  &50
5697  21                 !       DB  &21
5698  31                 1       DB  &31
5699  61                 a       DB  &61
569A  71                 q       DB  &71
569B  82                 .       DB  &82
569C  92                 .       DB  &92
569D  C2                 .       DB  &C2
569E  D2                 .       DB  &D2
569F  A4                 .       DB  &A4
56A0  B4                 .       DB  &B4
56A1  E4                 .       DB  &E4
56A2  F4                 .       DB  &F4

.
56A3  7F                        DB  &7F                                  ; CRTC register  0 (Horizontal total)
56A4  40                 @       DB  &40                                  ; CRTC register  1 (Horizontal displayed register)
56A5  5A                 Z       DB  &5A                                  ; CRTC register  2 (Horizontal sync position)
56A6  28                 (       DB  &28                                  ; CRTC register  3 (Sync width)
56A7  26                 &       DB  &26                                  ; CRTC register  4 (Vertical total)
56A8  00                 .       DB  &00                                  ; CRTC register  5 (Vertical total adjust)
56A9  10                 .       DB  &10                                  ; CRTC register  6 (Vertical displayed)
56AA  1E                 .       DB  &1E                                  ; CRTC register  7 (Vertical sync position)
56AB  01                 .       DB  &01                                  ; CRTC register  8 (Interlace and delay)
56AC  07                 .       DB  &07                                  ; CRTC register  9 (Scan lines per character)
56AD  67                 g       DB  &67                                  ; CRTC register 10 (Cursor start)
56AE  08                 .       DB  &08                                  ; CRTC register 11 (Cursor end)
56AF  0B                 .       DB  &0B                                  ; CRTC register 12 (Displayed screen start address high order) &5C00/8=&0B80
56B0  80                 .       DB  &80                                  ; CRTC register 13 (Displayed screen start address low order) &5C00/8=&0B80
56B1  00                 .       DB  &00                                  ; CRTC register 14 (Cursor position high order)
56B2  00                 .       DB  &00                                  ; CRTC register 15 (Cursor position low order)

; -----------------------------------------------------------------------------
; Get user input (<ENTER> or <TAB>)
; -----------------------------------------------------------------------------
.
56B3  20 E0 FF            ..     JSR osrdch                           ; Read character from input stream
56B6  B0 FB              ..      BCS &56B3                            ; Repeat if error occurred
56B8  C9 0D              ..      CMP #&0D                             ; Was it <ENTER>?
56BA  D0 02              ..      BNE &56BE
56BC  38                 8       SEC
56BD  60                 `       RTS
.
56BE  C9 20              .       CMP #&20                             ; Was it <SPACE>?
56C0  D0 F1              ..      BNE &56B3                            ; Repeat if it was not
56C2  18                 .       CLC
56C3  60                 `       RTS

; -----------------------------------------------------------------------------
; Switch to text mode.
; -----------------------------------------------------------------------------
.
56C4  A9 13              ..      LDA #&13
56C6  20 F4 FF            ..     JSR osbyte                           ; OSBYTE &13: Wait for vertical sync
.
56C9  78                 x       SEI
56CA  20 E7 56            .V     JSR &56E7                            ; Wait loop
56CD  A2 00              ..      LDX #&00
.
56CF  BD F2 56           ..V     LDA &56F2,X
56D2  8E 00 FE           ...     STX crtc_register
56D5  8D 01 FE           ...     STA crtc_data
56D8  E8                 .       INX
56D9  E0 0E              ..      CPX #&0E
56DB  90 F2              ..      BCC &56CF
56DD  A9 4B              .K      LDA #%01001011                       ; bit 0=1: second flash colour selected, bit 1=1: teletext selected, bit 2-3=01: 20 characters per line, bit 4=0:low frequency clock, bit5-6=01: 2 byte per cursor, bit7=0: small cursor
56DF  8D 20 FE           . .     STA video_ula_control
56E2  8D 48 02           .H.     STA &0248                            ; Also update the OS copy of the video ULA control register (OSBYTE &B8)
56E5  58                 X       CLI
56E6  60                 `       RTS

; -----------------------------------------------------------------------------
; Wait loop
; -----------------------------------------------------------------------------
.
56E7  A2 00              ..      LDX #&00
56E9  A0 12              ..      LDY #&12
.
56EB  CA                 .       DEX
56EC  D0 FD              ..      BNE &56EB
56EE  88                 .       DEY
56EF  D0 FA              ..      BNE &56EB
56F1  60                 `       RTS

.
56F2  3F                 ?       DB  &3F                                  ; CRTC register  0 (Horizontal total)
56F3  28                 (       DB  &28                                  ; CRTC register  1 (Horizontal displayed register)
56F4  33                 3       DB  &33                                  ; CRTC register  2 (Horizontal sync position)
56F5  24                 $       DB  &24                                  ; CRTC register  3 (Sync width)
56F6  1E                 .       DB  &1E                                  ; CRTC register  4 (Vertical total)
56F7  02                 .       DB  &02                                  ; CRTC register  5 (Vertical total adjust)
56F8  19                 .       DB  &19                                  ; CRTC register  6 (Vertical displayed)
56F9  1B                 .       DB  &1B                                  ; CRTC register  7 (Vertical sync position)
56FA  93                 .       DB  &93                                  ; CRTC register  8 (Interlace and delay)
56FB  12                 .       DB  &12                                  ; CRTC register  9 (Scan lines per character)
56FC  72                 r       DB  &72                                  ; CRTC register 10 (Cursor start)
56FD  13                 .       DB  &13                                  ; CRTC register 11 (Cursor end)
56FE  28                 (       DB  &28                                  ; CRTC register 12 (Displayed screen start address high order)
56FF  00                 .       DB  &00                                  ; CRTC register 13 (Displayed screen start address low order)

5700  00                 .       BRK
5701  00                 .       BRK
5702  00                 .       BRK
5703  00                 .       BRK
5704  00                 .       BRK
5705  00                 .       BRK
5706  00                 .       BRK
5707  00                 .       BRK
5708  00                 .       BRK
5709  00                 .       BRK
570A  00                 .       BRK
570B  00                 .       BRK
570C  00                 .       BRK
570D  00                 .       BRK
570E  00                 .       BRK
570F  00                 .       BRK
5710  00                 .       BRK
5711  00                 .       BRK
5712  00                 .       BRK
5713  00                 .       BRK
5714  00                 .       BRK
5715  00                 .       BRK
5716  00                 .       BRK
5717  00                 .       BRK
5718  00                 .       BRK
5719  00                 .       BRK
571A  00                 .       BRK
571B  00                 .       BRK
571C  00                 .       BRK
571D  00                 .       BRK
571E  00                 .       BRK
571F  00                 .       BRK
5720  00                 .       BRK
5721  00                 .       BRK
5722  00                 .       BRK
5723  00                 .       BRK
5724  00                 .       BRK
5725  00                 .       BRK
5726  00                 .       BRK
5727  00                 .       BRK
5728  00                 .       BRK
5729  00                 .       BRK
572A  00                 .       BRK
572B  00                 .       BRK
572C  00                 .       BRK
572D  00                 .       BRK
572E  00                 .       BRK
572F  00                 .       BRK
5730  00                 .       BRK
5731  00                 .       BRK
5732  00                 .       BRK
5733  00                 .       BRK
5734  00                 .       BRK
5735  00                 .       BRK
5736  00                 .       BRK
5737  00                 .       BRK
5738  00                 .       BRK
5739  00                 .       BRK
573A  00                 .       BRK
573B  00                 .       BRK
573C  00                 .       BRK
573D  00                 .       BRK
573E  00                 .       BRK
573F  00                 .       BRK
5740  00                 .       BRK
5741  00                 .       BRK
5742  00                 .       BRK
5743  00                 .       BRK
5744  00                 .       BRK
5745  00                 .       BRK
5746  00                 .       BRK
5747  00                 .       BRK
5748  00                 .       BRK
5749  00                 .       BRK
574A  00                 .       BRK
574B  00                 .       BRK
574C  00                 .       BRK
574D  00                 .       BRK
574E  00                 .       BRK
574F  00                 .       BRK
5750  00                 .       BRK
5751  00                 .       BRK
5752  00                 .       BRK
5753  00                 .       BRK
5754  00                 .       BRK
5755  00                 .       BRK
5756  00                 .       BRK
5757  00                 .       BRK
5758  00                 .       BRK
5759  00                 .       BRK
575A  00                 .       BRK
575B  00                 .       BRK
575C  00                 .       BRK
575D  00                 .       BRK
575E  00                 .       BRK
575F  00                 .       BRK
5760  00                 .       BRK
5761  00                 .       BRK
5762  00                 .       BRK
5763  00                 .       BRK
5764  00                 .       BRK
5765  00                 .       BRK
5766  00                 .       BRK
5767  00                 .       BRK
5768  00                 .       BRK
5769  00                 .       BRK
576A  00                 .       BRK
576B  00                 .       BRK
576C  00                 .       BRK
576D  00                 .       BRK
576E  00                 .       BRK
576F  00                 .       BRK
5770  00                 .       BRK
5771  00                 .       BRK
5772  00                 .       BRK
5773  00                 .       BRK
5774  00                 .       BRK
5775  00                 .       BRK
5776  00                 .       BRK
5777  00                 .       BRK
5778  00                 .       BRK
5779  00                 .       BRK
577A  00                 .       BRK
577B  00                 .       BRK
577C  00                 .       BRK
577D  00                 .       BRK
577E  00                 .       BRK
577F  00                 .       BRK
5780  00                 .       BRK
5781  00                 .       BRK
5782  00                 .       BRK
5783  00                 .       BRK
5784  00                 .       BRK
5785  00                 .       BRK
5786  00                 .       BRK
5787  00                 .       BRK
5788  00                 .       BRK
5789  00                 .       BRK
578A  00                 .       BRK
578B  00                 .       BRK
578C  00                 .       BRK
578D  00                 .       BRK
578E  00                 .       BRK
578F  00                 .       BRK
5790  00                 .       BRK
5791  00                 .       BRK
5792  00                 .       BRK
5793  00                 .       BRK
5794  00                 .       BRK
5795  00                 .       BRK
5796  00                 .       BRK
5797  00                 .       BRK
5798  00                 .       BRK
5799  00                 .       BRK
579A  00                 .       BRK
579B  00                 .       BRK
579C  00                 .       BRK
579D  00                 .       BRK
579E  00                 .       BRK
579F  00                 .       BRK
57A0  00                 .       BRK
57A1  00                 .       BRK
57A2  00                 .       BRK
57A3  00                 .       BRK
57A4  00                 .       BRK
57A5  00                 .       BRK
57A6  00                 .       BRK
57A7  00                 .       BRK
57A8  00                 .       BRK
57A9  00                 .       BRK
57AA  00                 .       BRK
57AB  00                 .       BRK
57AC  00                 .       BRK
57AD  00                 .       BRK
57AE  00                 .       BRK
57AF  00                 .       BRK
57B0  00                 .       BRK
57B1  00                 .       BRK
57B2  00                 .       BRK
57B3  00                 .       BRK
57B4  00                 .       BRK
57B5  00                 .       BRK
57B6  00                 .       BRK
57B7  00                 .       BRK
57B8  00                 .       BRK
57B9  00                 .       BRK
57BA  00                 .       BRK
57BB  00                 .       BRK
57BC  00                 .       BRK
57BD  00                 .       BRK
57BE  00                 .       BRK
57BF  00                 .       BRK
57C0  00                 .       BRK
57C1  00                 .       BRK
57C2  00                 .       BRK
57C3  00                 .       BRK
57C4  00                 .       BRK
57C5  00                 .       BRK
57C6  00                 .       BRK
57C7  00                 .       BRK
57C8  00                 .       BRK
57C9  00                 .       BRK
57CA  00                 .       BRK
57CB  00                 .       BRK
57CC  00                 .       BRK
57CD  00                 .       BRK
57CE  00                 .       BRK
57CF  00                 .       BRK
57D0  00                 .       BRK
57D1  00                 .       BRK
57D2  00                 .       BRK
57D3  00                 .       BRK
57D4  00                 .       BRK
57D5  00                 .       BRK
57D6  00                 .       BRK
57D7  00                 .       BRK
57D8  00                 .       BRK
57D9  00                 .       BRK
57DA  00                 .       BRK
57DB  00                 .       BRK
57DC  00                 .       BRK
57DD  00                 .       BRK
57DE  00                 .       BRK
57DF  00                 .       BRK
57E0  00                 .       BRK
57E1  00                 .       BRK
57E2  00                 .       BRK
57E3  00                 .       BRK
57E4  00                 .       BRK
57E5  00                 .       BRK
57E6  00                 .       BRK
57E7  00                 .       BRK
57E8  00                 .       BRK
57E9  00                 .       BRK
57EA  00                 .       BRK
57EB  00                 .       BRK
57EC  00                 .       BRK
57ED  00                 .       BRK
57EE  00                 .       BRK
57EF  00                 .       BRK
57F0  00                 .       BRK
57F1  00                 .       BRK
57F2  00                 .       BRK
57F3  00                 .       BRK
57F4  00                 .       BRK
57F5  00                 .       BRK
57F6  00                 .       BRK
57F7  00                 .       BRK
57F8  00                 .       BRK
57F9  00                 .       BRK
57FA  00                 .       BRK
57FB  00                 .       BRK
57FC  00                 .       BRK
57FD  00                 .       BRK
57FE  00                 .       BRK
57FF  00                 .       BRK
