; -----------------------------------------------------------------------------
; The Hobbit - Prepare Utility (c) Melbourne House
; reverse engineered by Eelco Huininga
; DOS Filename   : O.PREPARE
; Acorn filename : O.PREPARE
; Load address   : FFFF0D03
; Exec address   : FFFF0D03
; Length         : 000008BA
; -----------------------------------------------------------------------------

; -----------------------------------------------------------------------------
; The Hobbit - Basic Disc Operating System calls
; -----------------------------------------------------------------------------
readdata           = &0491
writedata          = &049F
hobbitidentifier   = &0587
identifydisc       = &058E

; -----------------------------------------------------------------------------
; OS call addresses
; -----------------------------------------------------------------------------
osrdch             = &FFE0                       ; OSRDCH Read character
osasci             = &FFE3                       ; OSASCI Write character &0D=LF
oswrch             = &FFEE                       ; OSWRCH Write character

; -----------------------------------------------------------------------------
; Start of code
; -----------------------------------------------------------------------------
.start
0D03  20 51 0F      Q.   JSR &0F51
0D06  20 64 0F      d.   JSR showscreen
0D09  20 22 11      ".   JSR getresponse
0D0C  D0 03        ..    BNE &0D11
0D0E  4C 71 0E     Lq.   JMP &0E71
.
0D11  20 F0 13      ..   JSR printmessage        ; Prepare a picture disc
0D14  59 6F 75 20  You   EQUS "You will need "
      77 69 6C 6C  will
      20 6E 65 65   nee
      64 20        d 
0D21  00           .     EQUB &00

0D23  A5 B1        ..    LDA &B1
0D25  48           H     PHA
0D26  F0 0C        ..    BEQ &0D34
0D28  A9 2E        ..    LDA #&2E                ; Set RUN table pointer to &142E for 80 tracks
0D2A  8D 04 00     ...   STA &0004
0D2D  A9 14        ..    LDA #&14
0D2F  8D 05 00     ...   STA &0005
0D32  D0 0A        ..    BNE &0D3E
.
0D34  A9 AC        ..    LDA #&AC                ; Set RUN table pointer to &14AC for 40 tracks
0D36  8D 04 00     ...   STA &0004
0D39  A9 14        ..    LDA #&14
0D3B  8D 05 00     ...   STA &0005
.
0D3E  68           h     PLA
0D3F  18           .     CLC
0D40  49 01        I.    EOR #&01
0D42  48           H     PHA
0D43  69 01        i.    ADC #&01
0D45  20 21 14      !.   JSR print1digit
0D48  20 F0 13      ..   JSR printmessage

0D4B  20 70 69 63   pic  EQUS " picturedisk"
      74 75 72 65  ture
      64 69 73 6B  disk
0D58  00           .     EQUB &00

0D59  68           h     PLA
0D5A  48           H     PHA
0D5B  F0 05        ..    BEQ &0D62
0D5D  A9 73        .s    LDA #ASC"s"
0D5F  20 E3 FF      ..   JSR osasci
0D62  20 F0 13      ..   JSR printmessage

0D65  2E           .     EQUS "."
0D66  0D           .     EQUB &0D
0D67  20 4D 61 6B   Mak  EQUS "Make sure that "
0D6B  65 20 73 75  e su
      72 65 20 74  re t
      68 61 74 20  hat 
0D77  00           .     EQUB &00

0D78  68           h     PLA
0D79  F0 0F        ..    BEQ &0D8A
0D7B  20 F0 13      ..   JSR printmessage

0D7E  74 68 65 79  they  EQUS "they are"
      20 61 72 65   are
0D86  00           .     EQUB &00

0D87  4C 93 0D     L..   JMP &0D93
.
0D8A  20 F0 13      ..   JSR printmessage

0D8D  69 74 20 69  it i  EQUS "it is"
      73           s
0D92  00           .     EQUB &00

.
0D93  20 F0 13      ..   JSR printmessage

0D96  20 61 6C 72   alr  EQUS " already formatted."
      65 61 64 79  eady
      20 66 6F 72   for
      6D 61 74 74  matt
      65 64 2E     ed.
0DA9  0D           .     EQUB &0D
0DAA  49 66 20 6E  If n  EQUS "If not then STOP NOW and FORMAT THEM"
      6F 74 20 74  ot t
      68 65 6E 20  hen 
      53 54 4F 50  STOP
      20 4E 4F 57   NOW
      20 61 6E 64   and
      20 46 4F 52   FOR
      4D 41 54 20  MAT 
      54 48 45 4D  THEM
0DCE  0D           .     EQUB &0D
0DCF  77 69 74 68  with  EQUS "with the appropiate utility."
      20 74 68 65   the
      20 61 70 70   app
      72 6F 70 72  ropr
      69 61 74 65  iate
      20 75 74 69   uti
      6C 69 74 79  lity
      2E           .
0DEC  0D           .     EQUB &0D
0DED  00           .     EQUB &00

0DEE  20 C0 13      ..   JSR anykey
.
0DF1  A2 00        ..    LDX #&00
0DF3  20 40 0F      @.   JSR &0F40               ; Get byte from RUN table
0DF6  85 02        ..    STA &02                 ; Store RUN table command in &02
0DF8  48           H     PHA
0DF9  68           h     PLA
0DFA  D0 1E        ..    BNE &0E1A               ; Has the end of the RUN table been reached?

0DFC  00           .     BRK
0DFD  01
0DFE  50 52 45 50  PREP  EQUS "PREP-F-End of RUN reached."
      2D 46 2D 45  -F-E
      6E 64 20 6F  nd o
      66 20 52 55  f RU
      4E 20 72 65  N re
      61 63 68 65  ache
      64 2E        d.
0E18  0D           .     EQUB &0D
0E19  00           .     EQUB &00

.
0E1A  BD 2A 0F     .*.   LDA &0F2A,X
0E1D  F0 0F        ..    BEQ &0E2E
0E1F  C5 02        ..    CMP &02
0E21  D0 48        .H    BNE &0E6B
0E23  E8           .     INX
0E24  BD 2A 0F     .*.   LDA &0F2A,X
0E27  48           H     PHA
0E28  E8           .     INX
0E29  BD 2A 0F     .*.   LDA &0F2A,X
0E2C  48           H     PHA
0E2D  60           `     RTS
.
0E2E  A9 28        .(    LDA #ASC"("
0E30  20 E3 FF      ..   JSR osasci
0E33  A5 02        ..    LDA &02
0E35  20 18 14      ..   JSR print2digits
0E38  A9 29        .)    LDA #ASC")"
0E3A  20 E3 FF      ..   JSR osasci
0E3D  00           .     BRK
0E3E  01 50        .P    ORA (&50,X)
0E40  52           R     ...
0E41  45 50        EP    EOR &50
0E43  2D 46 2D     -F-   AND &2D46
0E46  49 6E        In    EOR #&6E
0E48  76 61        va    ROR &61,X
0E4A  6C 69 64     lid   JMP (&6469)
0E4D  20 63 6F      co   JSR &6F63
0E50  6D 6D 61     mma   ADC &616D
0E53  6E 64 20     nd    ROR &2064
0E56  66 6F        fo    ROR &6F
0E58  75 6E        un    ADC &6E,X
0E5A  64           d     ...
0E5B  20 69 6E      in   JSR &6E69
0E5E  20 52 55      RU   JSR &5552
0E61  4E 20 74     N t   LSR &7420
0E64  61 62        ab    ADC (&62,X)
0E66  6C 65 3A     le:   JMP (&3A65)
0E69  0D 00
.
0E6B  E8           .     INX
0E6C  E8           .     INX
0E6D  E8           .     INX
0E6E  4C 1A 0E     L..   JMP &0E1A

; -----------------------------------------------------------------------------
; Prepare a savegame disc
; -----------------------------------------------------------------------------
.preparesavegamedisc
0E71  20 F0 13      ..   JSR printmessage
0E74  54           T     ...
0E75  6F           o     ...
0E76  20 70 72      pr   JSR &7270
0E79  65 70        ep    ADC &70
0E7B  61 72        ar    ADC (&72,X)
0E7D  65 20        e     ADC &20
0E7F  61 20        a     ADC (&20,X)
0E81  73           s     ...
0E82  61 76        av    ADC (&76,X)
0E84  65 20        e     ADC &20
0E86  67           g     ...
0E87  61 6D        am    ADC (&6D,X)
0E89  65 20        e     ADC &20
0E8B  64           d     ...
0E8C  69 73        is    ADC #&73
0E8E  6B           k     ...
0E8F  2C 0D 50     ,.P   BIT &500D
0E92  6C 65 61     lea   JMP (&6165)
0E95  73           s     ...
0E96  65 20        e     ADC &20
0E98  70 6C        pl    BCS &0F06
0E9A  61 63        ac    ADC (&63,X)
0E9C  65 20        e     ADC &20
0E9E  61 20        a     ADC (&20,X)
0EA0  62           b     ...
0EA1  6C 61 6E     lan   JMP (&6E61)
0EA4  6B           k     ...
0EA5  20 46 4F      FO   JSR &4F46
0EA8  52           R     ...
0EA9  4D 41 54     MAT   EOR &5441
0EAC  54           T     ...
0EAD  45 44        ED    EOR &44
0EAF  20 64 69      di   JSR &6964
0EB2  73           s     ...
0EB3  6B           k     ...
0EB4  0D 69 6E     .in   ORA &6E69
0EB7  20 64 72      dr   JSR &7264
0EBA  69 76        iv    ADC #&76
0EBC  65 20        e     ADC &20
0EBE  30 0D        0.    BMI &0ECD
0EC0  0D 49 66     .If   ORA &6649
0EC3  20 79 6F      yo   JSR &6F79
0EC6  75 20        u     ADC &20,X
0EC8  64           d     ...
0EC9  6F           o     ...
0ECA  20 6E 6F      no   JSR &6F6E
0ECD  74           t     ...
0ECE  20 77 69      wi   JSR &6977
0ED1  73           s     ...
0ED2  68           h     PLA
0ED3  20 74 6F      to   JSR &6F74
0ED6  20 63 6F      co   JSR &6F63
0ED9  6E 74 69     nti   ROR &6974
0EDC  6E 75 65     nue   ROR &6575
0EDF  20 74 68      th   JSR &6874
0EE2  69 73        is    ADC #&73
0EE4  0D 6F 70     .op   ORA &706F
0EE7  65 72        er    ADC &72
0EE9  61 74        at    ADC (&74,X)
0EEB  69 6F        io    ADC #&6F
0EED  6E 2C 20     n,    ROR &202C
0EF0  70 72        pr    BCS &0F64
0EF2  65 73        es    ADC &73
0EF4  73           s     ...
0EF5  20 43 4F      CO   JSR &4F43
0EF8  4E 54 52     NTR   LSR &5254
0EFB  4F           O     ...
0EFC  4C 2D 42     L-B   JMP &422D
0EFF  52           R     ...
0F00  45 41        EA    EOR &41
0F02  4B           K     ...
0F03  2C 0D 61     ,.a   BIT &610D
0F06  6E 64 20     nd    ROR &2064
0F09  72           r     ...
0F0A  65 62        eb    ADC &62
0F0C  6F           o     ...
0F0D  6F           o     ...
0F0E  74           t     ...
0F0F  20 74 68      th   JSR &6874
0F12  69 73        is    ADC #&73
0F14  20 64 69      di   JSR &6964
0F17  73           s     ...
0F18  6B           k     ...
0F19  2E 0D 0D     ...   ROL &0D0D
0F1C  00           .     BRK

0F1D  A9 51        .Q    LDA #&51                ; Set RUN table pointer to &1551
0F1F  8D 04 00     ...   STA &0004
0F22  A9 15        ..    LDA #&15
0F24  8D 05 00     ...   STA &0005
0F27  4C F1 0D     L..   JMP &0DF1

; -----------------------------------------------------------------------------
; 
; -----------------------------------------------------------------------------
.
0F2A  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data (4 parameters)
0F2B  11 E9        ..    EQUW &11E9
0F2D  53           S     EQUB &53                ; Command &53: Reset pointer and save data (4 parameters)
0F2E  11 F6        ..    EQUW &11F6
0F30  52           R     EQUB &52                ; Command &52: Load data (4 parameters)
0F31  12 05        ..    EQUW &1205
0F32  57           W     EQUB &57                ; Command &57: Save data (4 parameters)
0F34  12 6B        .k    EQUW &126B
0F36  51           Q     EQUB &51                ; Command &51: Quit (0 parameters)
0F37  11 5D        ..    EQUW &115D
0F39  41           A     EQUB &41                ; Command &41: Write disc identifier (1 parameter)
0F3A  11 CB        ..    EQUW &11CB
0F3C  50           P     EQUB &50                ; Command &50: Switch disc (1 parameter)
0F3D  12 DB        ..    EQUW switchdisc-1
0F3F  00           .     BRK

; -----------------------------------------------------------------------------
; Get byte from RUN table
; -----------------------------------------------------------------------------
.
0F40  20 E4 13      ..   JSR preservexy
0F43  A0 00        ..    LDY #&00
0F45  B1 04        ..    LDA (&04),Y
0F47  E6 04        ..    INC &04
0F49  D0 02        ..    BNE &0F4D
0F4B  E6 05        ..    INC &05
.
0F4D  20 EB 13      ..   JSR restorexy
0F50  60           `     RTS

; -----------------------------------------------------------------------------
; 
; -----------------------------------------------------------------------------
.
0F51  A9 0C        ..    LDA #&0C
0F53  20 EE FF      ..   JSR oswrch
0F56  20 B7 11      ..   JSR readdiscid
0F59  A9 BD        ..    LDA #&BD
0F5B  8D BB 15     ...   STA &15BB
0F5E  A9 15        ..    LDA #&15
0F60  8D BC 15     ...   STA &15BC
0F63  60           `     RTS

; -----------------------------------------------------------------------------
; Show the main screen
; -----------------------------------------------------------------------------
.showscreen
0F64  A9 1E        ..    LDA #&1E
0F66  20 EE FF      ..   JSR oswrch
0F69  20 F0 13      ..   JSR printmessage
0F6C  20 20 20           JSR &2020
0F6F  20 42 42      BB   JSR &4242
0F72  43           C     ...
0F73  20 44 49      DI   JSR &4944
0F76  53           S     ...
0F77  4B           K     ...
0F78  20 48 4F      HO   JSR &4F48
0F7B  42           B     ...
0F7C  42           B     ...
0F7D  49 54        IT    EOR #&54
0F7F  20 56 45      VE   JSR &4556
0F82  52           R     ...
0F83  53           S     ...
0F84  49 4F        IO    EOR #&4F
0F86  4E 20 00     N .   LSR &0020
0F89  20 D5 11      ..   JSR &11D5
0F8C  20 F0 13      ..   JSR printmessage
0F8F  0D 0D 0D     ...   ORA &0D0D
0F92  42           B     ...
0F93  42           B     ...
0F94  43           C     ...
0F95  20 48 4F      HO   JSR &4F48
0F98  42           B     ...
0F99  42           B     ...
0F9A  49 54        IT    EOR #&54
0F9C  20 44 49      DI   JSR &4944
0F9F  53           S     ...
0FA0  4B           K     ...
0FA1  20 50 52      PR   JSR &5250
0FA4  45 50        EP    EOR &50
0FA6  41 52        AR    EOR (&52,X)
0FA8  45 20        E     EOR &20
0FAA  55 54        UT    EOR &54,X
0FAC  49 4C        IL    EOR #&4C
0FAE  49 54        IT    EOR #&54
0FB0  59 0D 0D     Y..   EOR &0D0D,Y
0FB3  20 20 54       T   JSR &5420
0FB6  68           h     PLA
0FB7  69 73        is    ADC #&73
0FB9  20 70 72      pr   JSR &7270
0FBC  6F           o     ...
0FBD  67           g     ...
0FBE  72           r     ...
0FBF  61 6D        am    ADC (&6D,X)
0FC1  20 6D 75      mu   JSR &756D
0FC4  73           s     ...
0FC5  74           t     ...
0FC6  20 62 65      be   JSR &6562
0FC9  20 72 75      ru   JSR &7572
0FCC  6E 20 62     n b   ROR &6220
0FCF  65 66        ef    ADC &66
0FD1  6F           o     ...
0FD2  72           r     ...
0FD3  65 20        e     ADC &20
0FD5  79 6F 75     you   ADC &756F,Y
0FD8  0D 63 61     .ca   ORA &6163
0FDB  6E 20 75     n u   ROR &7520
0FDE  73           s     ...
0FDF  65 20        e     ADC &20
0FE1  54           T     ...
0FE2  48           H     PHA
0FE3  45 20        E     EOR &20
0FE5  48           H     PHA
0FE6  4F           O     ...
0FE7  42           B     ...
0FE8  42           B     ...
0FE9  49 54        IT    EOR #&54
0FEB  2E 20 49     . I   ROL &4920
0FEE  74           t     ...
0FEF  20 28 74      (t   JSR &7428
0FF2  68           h     PLA
0FF3  69 73        is    ADC #&73
0FF5  20 70 72      pr   JSR &7270
0FF8  6F           o     ...
0FF9  67           g     ...
0FFA  72           r     ...
0FFB  61 6D        am    ADC (&6D,X)
0FFD  29 0D        ).    AND #&0D
0FFF  77           w     ...
1000  69 6C        il    ADC #&6C
1002  6C 20 70     l p   JMP (&7020)
1005  72           r     ...
1006  65 70        ep    ADC &70
1008  61 72        ar    ADC (&72,X)
100A  65 20        e     ADC &20
100C  70 69        pi    BCS &1077
100E  63           c     ...
100F  74           t     ...
1010  75 72        ur    ADC &72,X
1012  65 20        e     ADC &20
1014  64           d     ...
1015  69 73        is    ADC #&73
1017  6B           k     ...
1018  73           s     ...
1019  20 61 6E      an   JSR &6E61
101C  64           d     ...
101D  0D 73 61     .sa   ORA &6173
1020  76 65        ve    ROR &65,X
1022  2D 67 61     -ga   AND &6167
1025  6D 65 20     me    ADC &2065
1028  64           d     ...
1029  69 73        is    ADC #&73
102B  6B           k     ...
102C  73           s     ...
102D  20 66 72      fr   JSR &7266
1030  6F           o     ...
1031  6D 20 74     m t   ADC &7420
1034  68           h     PLA
1035  65 20        e     ADC &20
1037  48           H     PHA
1038  4F           O     ...
1039  42           B     ...
103A  42           B     ...
103B  49 54        IT    EOR #&54
103D  20 64 69      di   JSR &6964
1040  73           s     ...
1041  6B           k     ...
1042  2E 0D 50     ..P   ROL &500D
1045  6C 65 61     lea   JMP (&6165)
1048  73           s     ...
1049  65 20        e     ADC &20
104B  6E 6F 74     not   ROR &746F
104E  65 20        e     ADC &20
1050  74           t     ...
1051  68           h     PLA
1052  61 74        at    ADC (&74,X)
1054  20 69 6E      in   JSR &6E69
1057  66 6F        fo    ROR &6F
1059  72           r     ...
105A  6D 61 74     mat   ADC &7461
105D  69 6F        io    ADC #&6F
105F  6E 20 69     n i   ROR &6920
1062  73           s     ...
1063  20 6F 6E      on   JSR &6E6F
1066  0D 62 6F     .bo   ORA &6F62
1069  74           t     ...
106A  68           h     PLA
106B  20 73 69      si   JSR &6973
106E  64           d     ...
106F  65 73        es    ADC &73
1071  20 6F 66      of   JSR &666F
1074  20 74 68      th   JSR &6874
1077  65 20        e     ADC &20
1079  48           H     PHA
107A  4F           O     ...
107B  42           B     ...
107C  42           B     ...
107D  49 54        IT    EOR #&54
107F  20 64 69      di   JSR &6964
1082  73           s     ...
1083  6B           k     ...
1084  20 61 6E      an   JSR &6E61
1087  64           d     ...
1088  20 79 6F      yo   JSR &6F79
108B  75 0D        u.    ADC &0D,X
108D  77           w     ...
108E  69 6C        il    ADC #&6C
1090  6C 20 62     l b   JMP (&6220)
1093  65 20        e     ADC &20
1095  70 72        pr    BCS &1109
1097  6F           o     ...
1098  6D 70 74     mpt   ADC &7470
109B  65 64        ed    ADC &64
109D  20 77 68      wh   JSR &6877
10A0  65 6E        en    ADC &6E
10A2  20 74 6F      to   JSR &6F74
10A5  20 69 6E      in   JSR &6E69
10A8  73           s     ...
10A9  65 72        er    ADC &72
10AB  74           t     ...
10AC  0D 77 68     .wh   ORA &6877
10AF  69 63        ic    ADC #&63
10B1  68           h     PLA
10B2  20 73 69      si   JSR &6973
10B5  64           d     ...
10B6  65 2E        e.    ADC &2E
10B8  0D 0D 0D     ...   ORA &0D0D
10BB  20 20 20           JSR &2020
10BE  20 20 3C       <   JSR &3C20
10C1  50 3E        P>    BVC &1101
10C3  20 20 50       P   JSR &5020
10C6  52           R     ...
10C7  45 50        EP    EOR &50
10C9  41 52        AR    EOR (&52,X)
10CB  45 20        E     EOR &20
10CD  50 49        PI    BVC &1118
10CF  43           C     ...
10D0  54           T     ...
10D1  55 52        UR    EOR &52,X
10D3  45 20        E     EOR &20
10D5  44           D     ...
10D6  49 53        IS    EOR #&53
10D8  4B           K     ...
10D9  2F           /     ...
10DA  53           S     ...
10DB  0D 20 20     .     ORA &2020
10DE  20 20 20           JSR &2020
10E1  3C           <     ...
10E2  53           S     ...
10E3  3E 20 20     >     ROL &2020,X
10E6  50 52        PR    BVC &113A
10E8  45 50        EP    EOR &50
10EA  41 52        AR    EOR (&52,X)
10EC  45 20        E     EOR &20
10EE  53           S     ...
10EF  41 56        AV    EOR (&56,X)
10F1  45 20        E     EOR &20
10F3  47           G     ...
10F4  41 4D        AM    EOR (&4D,X)
10F6  45 20        E     EOR &20
10F8  44           D     ...
10F9  49 53        IS    EOR #&53
10FB  4B           K     ...
10FC  2F           /     ...
10FD  53           S     ...
10FE  0D 20 20     .     ORA &2020
1101  20 20 20           JSR &2020
1104  3C           <     ...
1105  51 3E        Q>    EOR (&3E),Y
1107  20 20 51       Q   JSR &5120
110A  55 49        UI    EOR &49,X
110C  54           T     ...
110D  0D 0D 20     ..    ORA &200D
1110  20 20 45       E   JSR &4520
1113  4E 54 45     NTE   LSR &4554
1116  52           R     ...
1117  20 43 48      CH   JSR &4843
111A  4F           O     ...
111B  49 43        IC    EOR #&43
111D  45 3A        E:    EOR &3A
111F  0D           .     EQUB &0D
1120  00           .     EQUB &00
1121  60           `     RTS

; -----------------------------------------------------------------------------
; Get response from user
; -----------------------------------------------------------------------------
.getresponse
1122  20 E0 FF      ..   JSR osrdch
1125  C9 51        .Q    CMP #&51
1127  F0 0E        ..    BEQ &1137
1129  C9 53        .S    CMP #&53
112B  F0 07        ..    BEQ &1134
112D  C9 50        .P    CMP #&50
112F  D0 F1        ..    BNE getresponse
1131  A9 01        ..    LDA #&01
1133  60           `     RTS
.
1134  A9 00        ..    LDA #&00
1136  60           `     RTS
.
1137  00           .     BRK
1138  01 54        .T    ORA (&54,X)
113A  79 70 65     ype   ADC &6570,Y
113D  20 53 68      Sh   JSR &6853
1140  69 66        if    ADC #&66
1142  74           t     ...
1143  2D 42 72     -Br   AND &7242
1146  65 61        ea    ADC &61
1148  6B           k     ...
1149  20 74 6F      to   JSR &6F74
114C  20 6C 6F      lo   JSR &6F6C
114F  61 64        ad    ADC (&64,X)
1151  20 54 48      TH   JSR &4854
1154  45 20        E     EOR &20
1156  48           H     PHA
1157  4F           O     ...
1158  42           B     ...
1159  42           B     ...
115A  49 54        IT    EOR #&54
115C  0D 00 

; -----------------------------------------------------------------------------
; 
; -----------------------------------------------------------------------------
.
115E  A9 10        ..    LDA #&10
1160  20            ..   JSR checkdisc
1163  4C 03 0D     L..   JMP &0D03
.
1166  00           .     BRK
1167  00           .     BRK
1168  00           .     BRK
1169  00           .     BRK
116A  00           .     BRK
116B  00           .     BRK
116C  00           .     BRK
116D  00           .     BRK
116E  00           .     BRK

; -----------------------------------------------------------------------------
; Write disc identifier data
; -----------------------------------------------------------------------------
.writediscid
116F  20 E4 13      ..   JSR preservexy
1172  8D 69 11     .i.   STA &1169
1175  A0 02        ..    LDY #&02
1177  B9 87 05     ...   LDA hobbitidentifier,Y
117A  99 66 11     .f.   STA &1166,Y
117D  88           .     DEY
117E  10 F7        ..    BPL &1177
1180  20 6C 05      l.   JSR &056C
1183  A9 09        ..    LDA #&09                ; Length &0009
1185  85 88        ..    STA &88
1187  A9 66        .f    LDA #&66                ; Source address &1166
1189  85 8A        ..    STA &8A
118B  A9 11        ..    LDA #&11
118D  85 8B        ..    STA &8B
118F  20 9F 04      ..   JSR writedata           ; Write 9 bytes from &1166 to track &00 sector &09
1192  90 1F        ..    BCC &11B3
.
1194  00           .     BRK
1195  01 54        .T    ORA (&54,X)
1197  68           h     PLA
1198  61 74        at    ADC (&74,X)
119A  20 64 69      di   JSR &6964
119D  73           s     ...
119E  6B           k     ...
119F  20 69 73      is   JSR &7369
11A2  20 6E 6F      no   JSR &6F6E
11A5  74           t     ...
11A6  20 66 6F      fo   JSR &6F66
11A9  72           r     ...
11AA  6D 61 74     mat   ADC &7461
11AD  74           t     ...
11AE  65 64        ed    ADC &64
11B0  21 0D        !.    AND (&0D,X)
11B2  00           .     BRK
11B3  20 EB 13      ..   JSR restorexy
11B6  60           `     RTS

; -----------------------------------------------------------------------------
; Read disc identifier data
; -----------------------------------------------------------------------------
.readdiscid
11B7  20 6C 05      l.   JSR &056C
11BA  A9 09        ..    LDA #&09                ; Length &0009
11BC  85 88        ..    STA &88
11BE  A9 66        .f    LDA #&66                ; Destination address &1166
11C0  85 8A        ..    STA &8A
11C2  A9 11        ..    LDA #&11
11C4  85 8B        ..    STA &8B
11C6  20 91 04      ..   JSR readdata            ; Read 9 bytes from track &00 sector &09 to &1166
11C9  B0 C9        ..    BCS &1194
11CB  60           `     RTS

; -----------------------------------------------------------------------------
; Write disc identifier 
; -----------------------------------------------------------------------------
.
11CC  20 40 0F      @.   JSR &0F40               ; Get byte from RUN table
11CF  20 6F 11      o.   JSR writediscid
11D2  4C F1 0D     L..   JMP &0DF1

11D5  A2 00        ..    LDX #&00
11D7  BD 6A 11     .j.   LDA &116A,X
11DA  20 E3 FF      ..   JSR osasci
11DD  E8           .     INX
11DE  E0 05        ..    CPX #&05
11E0  90 F5        ..    BCC &11D7
11E2  60           `     RTS
11E3  AD 69 11     .i.   LDA &1169
11E6  20 18 14      ..   JSR print2digits
11E9  60           `     RTS

; -----------------------------------------------------------------------------
; Reset pointer and load data (4 parameters)
; -----------------------------------------------------------------------------
.
11EA  A9 BD        ..    LDA #&BD                ; &15BD
11EC  8D BB 15     ...   STA &15BB
11EF  A9 15        ..    LDA #&15
11F1  8D BC 15     ...   STA &15BC
11F4  4C 06 12     L..   JMP &1206

; -----------------------------------------------------------------------------
; Reset pointer and save data (4 parameters)
; -----------------------------------------------------------------------------
.
11F7  A9 BD        ..    LDA #&BD                ; &15BD
11F9  8D BB 15     ...   STA &15BB
11FC  A9 15        ..    LDA #&15
11FE  8D BC 15     ...   STA &15BC
1201  4C 6C 12     Ll.   JMP &126C

; -----------------------------------------------------------------------------
; Temporary bytes
; -----------------------------------------------------------------------------
.
1204  00           .     BRK
1205  00           .     BRK

; -----------------------------------------------------------------------------
; Load data (4 parameters)
; -----------------------------------------------------------------------------
.
1206  20 A3 12      ..   JSR &12A3
1209  18           .     CLC
120A  A5 8A        ..    LDA &8A
120C  65 88        e.    ADC &88
120E  8D 04 12     ...   STA &1204
1211  A5 8B        ..    LDA &8B
1213  65 89        e.    ADC &89
1215  8D 05 12     ...   STA &1205
1218  C9 7C        .|    CMP #&7C
121A  90 28        .(    BCC &1244
121C  00           .     BRK
121D  01 50        .P    ORA (&50,X)
121F  52           R     ...
1220  45 50        EP    EOR &50
1222  2D 46 2D     -F-   AND &2D46
1225  49 6E        In    EOR #&6E
1227  73           s     ...
1228  75 66        uf    ADC &66,X
122A  66 69        fi    ROR &69
122C  63           c     ...
122D  69 65        ie    ADC #&65
122F  6E 74 20     nt    ROR &2074
1232  6D 65 6D     mem   ADC &6D65
1235  6F           o     ...
1236  72           r     ...
1237  79 20 66     y f   ADC &6620,Y
123A  6F           o     ...
123B  72           r     ...
123C  20 72 65      re   JSR &6572
123F  61 64        ad    ADC (&64,X)
1241  2E 0D 00     ...   ROL &000D
.
1244  20 91 04      ..   JSR readdata
1247  90 1D        ..    BCC &1266
1249  00           .     BRK
124A  01 50        .P    ORA (&50,X)
124C  52           R     ...
124D  45 50        EP    EOR &50
124F  2D 46 2D     -F-   AND &2D46
1252  45 72        Er    EOR &72
1254  72           r     ...
1255  6F           o     ...
1256  72           r     ...
1257  20 64 75      du   JSR &7564
125A  72           r     ...
125B  69 6E        in    ADC #&6E
125D  67           g     ...
125E  20 72 65      re   JSR &6572
1261  61 64        ad    ADC (&64,X)
1263  2E 0D 00     ...   ROL &000D
.
1266  20 98 12      ..   JSR updatepointer
1269  4C F1 0D     L..   JMP &0DF1

; -----------------------------------------------------------------------------
; Save data (4 parameters)
; -----------------------------------------------------------------------------
.
126C  20 A3 12      ..   JSR &12A3
126F  20 9F 04      ..   JSR writedata
1272  90 1E        ..    BCC &1292
1274  00           .     BRK
1275  01 50        .P    ORA (&50,X)
1277  52           R     ...
1278  45 50        EP    EOR &50
127A  2D 46 2D     -F-   AND &2D46
127D  45 72        Er    EOR &72
127F  72           r     ...
1280  6F           o     ...
1281  72           r     ...
1282  20 64 75      du   JSR &7564
1285  72           r     ...
1286  69 6E        in    ADC #&6E
1288  67           g     ...
1289  20 77 72      wr   JSR &7277
128C  69 74        it    ADC #&74
128E  65 2E        e.    ADC &2E
1290  0D           .     EQUB &0D
1291  00           .     EQUB &00
.
1292  20 98 12      ..   JSR updatepointer
1295  4C F1 0D     L..   JMP &0DF1

; -----------------------------------------------------------------------------
; Update pointer to transferbuffer
; -----------------------------------------------------------------------------
.updatepointer
1298  A5 8A        ..    LDA &8A
129A  8D BB 15     ...   STA &15BB
129D  A5 8B        ..    LDA &8B
129F  8D BC 15     ...   STA &15BC
12A2  60           `     RTS

; -----------------------------------------------------------------------------
; 
; -----------------------------------------------------------------------------
.
12A3  20 40 0F      @.   JSR &0F40               ; Get byte from RUN table
12A6  20 C7 12      ..   JSR checkdisc
12A9  20 40 0F      @.   JSR &0F40               ; Get byte from RUN table
12AC  85 B2        ..    STA &B2                 ; Track
12AE  20 40 0F      @.   JSR &0F40               ; Get byte from RUN table
12B1  85 B4        ..    STA &B4                 ; Sector
12B3  20 40 0F      @.   JSR &0F40               ; Get byte from RUN table
12B6  85 89        ..    STA &89                 ; Length (MSB)
12B8  A9 00        ..    LDA #&00
12BA  85 88        ..    STA &88                 ; Length (LSB)
12BC  AD BB 15     ...   LDA &15BB
12BF  85 8A        ..    STA &8A                 ; Load address (LSB)
12C1  AD BC 15     ...   LDA &15BC
12C4  85 8B        ..    STA &8B                 ; Load address (MSB)
12C6  60           `     RTS

; -----------------------------------------------------------------------------
; Check if the current disc is the correct one
; -----------------------------------------------------------------------------
.checkdisc
12C7  20 E4 13      ..   JSR preservexy
12CA  85 BA        ..    STA &BA
12CC  20 8E 05      ..   JSR identifydisc
12CF  C5 BA        ..    CMP &BA
12D1  F0 06        ..    BEQ &12D9
12D3  20 E7 12      ..   JSR &12E7
12D6  4C CC 12     L..   JMP &12CC
.
12D9  4C EB 13     L..   JMP restorexy

; -----------------------------------------------------------------------------
; Switch disc
; -----------------------------------------------------------------------------
.switchdisc
12DC  20 40 0F      @.   JSR &0F40               ; Get byte from RUN table
12DF  85 BA        ..    STA &BA                 ; Store disc id in &BA
12E1  20 E7 12      ..   JSR &12E7
12E4  4C F1 0D     L..   JMP &0DF1

; -----------------------------------------------------------------------------
; 
; -----------------------------------------------------------------------------
.
12E7  20 F0 13      ..   JSR printmessage
12EA  0D 50 6C     .Pl   ORA &6C50
12ED  65 61        ea    ADC &61
12EF  73           s     ...
12F0  65 20        e     ADC &20
12F2  69 6E        in    ADC #&6E
12F4  73           s     ...
12F5  65 72        er    ADC &72
12F7  74           t     ...
12F8  20 00
12FA  A5 BA        ..    LDA &BA
12FC  C9 03        ..    CMP #&03
12FE  90 1D        ..    BCC &131D
1300  48           H     PHA
1301  20 F0 13      ..   JSR printmessage
1304  74           t     ...
1305  68           h     PLA
1306  65 20        e     ADC &20
1308  00           .     BRK
1309  68           h     PLA
130A  C9 03        ..    CMP #&03
130C  F0 63        .c    BEQ &1371
130E  C9 04        ..    CMP #&04
1310  F0 25        .%    BEQ &1337
1312  C9 10        ..    CMP #&10
1314  F0 31        .1    BEQ &1347
1316  C9 20        .     CMP #&20
1318  F0 42        .B    BEQ &135C
131A  4C 8A 13     L..   JMP &138A
.
131D  20 F0 13      ..   JSR printmessage
1320  50 69        Pi    BVC &138B
1322  63           c     ...
1323  74           t     ...
1324  75 72        ur    ADC &72,X
1326  65 20        e     ADC &20
1328  64           d     ...
1329  69 73        is    ADC #&73
132B  6B           k     ...
132C  20 23 00      #.   JSR &0023
132F  A5 BA        ..    LDA &BA
1331  20 21 14      !.   JSR print1digit
1334  4C 86 13     L..   JMP &1386
1337  20 F0 13      ..   JSR printmessage
133A  53           S     ...
133B  61 76        av    ADC (&76,X)
133D  65 20        e     ADC &20
133F  67           g     ...
1340  61 6D        am    ADC (&6D,X)
1342  65 00        e.    ADC &00
1344  4C 7C 13     L|.   JMP &137C
1347  20 F0 13      ..   JSR printmessage
134A  48           H     PHA
134B  4F           O     ...
134C  42           B     ...
134D  42           B     ...
134E  49 54        IT    EOR #&54
1350  28           (     PLP
1351  53           S     ...
1352  69 64        id    ADC #&64
1354  65 20        e     ADC &20
1356  31 29        1)    AND (&29),Y
1358  00           .     BRK
1359  4C 7C 13     L|.   JMP &137C
135C  20 F0 13      ..   JSR printmessage
135F  48           H     PHA
1360  4F           O     ...
1361  42           B     ...
1362  42           B     ...
1363  49 54        IT    EOR #&54
1365  28           (     PLP
1366  53           S     ...
1367  69 64        id    ADC #&64
1369  65 20        e     ADC &20
136B  32           2     ...
136C  29 00        ).    AND #&00
136E  4C 7C 13     L|.   JMP &137C
1371  20 F0 13      ..   JSR printmessage
1374  50 69        Pi    BVC &13DF
1376  63           c     ...
1377  74           t     ...
1378  75 72        ur    ADC &72,X
137A  65 00        e.    ADC &00
137C  20 F0 13      ..   JSR printmessage
137F  20 64 69      di   JSR &6964
1382  73           s     ...
1383  6B           k     ...
1384  2E 00
1386  20 C0 13      ..   JSR anykey
1389  60           `     RTS

138A  48           H     PHA
138B  20 F0 13      ..   JSR printmessage
138E  0D 28 00     .(.   ORA &0028
1391  68           h     PLA
1392  20 18 14      ..   JSR print2digits
1395  A9 29        .)    LDA #ASC")"
1397  20 E3 FF      ..   JSR osasci
139A  00           .     BRK
139B  01 50        .P    ORA (&50,X)
139D  52           R     ...
139E  45 50        EP    EOR &50
13A0  2D 46 2D     -F-   AND &2D46
13A3  49 6E        In    EOR #&6E
13A5  76 61        va    ROR &61,X
13A7  6C 69 64     lid   JMP (&6469)
13AA  20 49 44      ID   JSR &4449
13AD  20 70 61      pa   JSR &6170
13B0  73           s     ...
13B1  73           s     ...
13B2  65 64        ed    ADC &64
13B4  20 74 6F      to   JSR &6F74
13B7  20 49 4E      IN   JSR &4E49
13BA  53           S     ...
13BB  45 52        ER    EOR &52
13BD  54           T     ...
13BE  0D 00 

; -----------------------------------------------------------------------------
; Display's "Press any key to continue" and reads a single character
; -----------------------------------------------------------------------------
.anykey
13C0  20 F0 13      ..   JSR printmessage
13C3  0D 50 72     .Pr   ORA &7250
13C6  65 73        es    ADC &73
13C8  73           s     ...
13C9  20 61 6E      an   JSR &6E61
13CC  79 20 6B     y k   ADC &6B20,Y
13CF  65 79        ey    ADC &79
13D1  20 74 6F      to   JSR &6F74
13D4  20 63 6F      co   JSR &6F63
13D7  6E 74 69     nti   ROR &6974
13DA  6E 75 65     nue   ROR &6575
13DD  2E 0D 00     ...   ROL &000D
13E0  20 E0 FF      ..   JSR osrdch
13E3  60           `     RTS

; -----------------------------------------------------------------------------
; Preserve X and Y
; -----------------------------------------------------------------------------
.preservexy
13E4  8E EE 13     ...   STX &13EE
13E7  8C EC 13     ...   STY &13EC
13EA  60           `     RTS

; -----------------------------------------------------------------------------
; Restore X and Y
; -----------------------------------------------------------------------------
.restorexy
13EB  A0 00        ..    LDY #&00
13ED  A2 00        ..    LDX #&00
13EF  60           `     RTS

; -----------------------------------------------------------------------------
; Print message
; -----------------------------------------------------------------------------
.printmessage
13F0  20 E4 13      ..   JSR preservexy
13F3  68           h     PLA
13F4  85 00        ..    STA &00
13F6  68           h     PLA
13F7  85 01        ..    STA &01
.
13F9  A0 00        ..    LDY #&00
13FB  20 11 14      ..   JSR &1411
13FE  B1 00        ..    LDA (&00),Y
1400  F0 06        ..    BEQ &1408
1402  20 E3 FF      ..   JSR osasci
1405  4C F9 13     L..   JMP &13F9
.
1408  20 11 14      ..   JSR &1411
140B  20 EB 13      ..   JSR restorexy
140E  6C 00 00     l..   JMP (&0000)              ; Return to main code
.
1411  E6 00        ..    INC &00
1413  D0 02        ..    BNE &1417
1415  E6 01        ..    INC &01
.
1417  60           `     RTS

; -----------------------------------------------------------------------------
; Print 1 or 2 digits
; -----------------------------------------------------------------------------
.print2digits
1418  48           H     PHA
1419  4A           J     LSR A
141A  4A           J     LSR A
141B  4A           J     LSR A
141C  4A           J     LSR A
141D  20 21 14      !.   JSR print1digit
1420  68           h     PLA
.print1digit
1421  29 0F        ).    AND #&0F
1423  F8           .     SED
1424  18           .     CLC
1425  69 90        i.    ADC #&90
1427  69 40        i@    ADC #&40
1429  D8           .     CLD
142A  20 E3 FF      ..   JSR osasci
142D  60           `     RTS

; -----------------------------------------------------------------------------
; RUN tables: these tables contain data which tracks and sectors need to be copied to create picture- and savegame disks
; Disc codes: &01 40-track picture disc #1
;             &02 40-track picture disc #2
;             &03 80-track picture disc
;             &04 save game disc
;             &10 game disc side 1
;             &20 game disc side 2
; Command codes: &41 Write disc identifier
;                &4C Reset pointer and load data
;                &50 Switch discs
;                &51 Quit
;                &52 Load data
;                &53 Reset pointer and save data
;                &57 Save data
; -----------------------------------------------------------------------------

; -----------------------------------------------------------------------------
; RUN table for one 80 track picture disc
; -----------------------------------------------------------------------------
.
142E  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
142F  10           .     EQUB &10                ; Parameter 1: Game disc (side 1)
1430  24           $     EQUB &24                ; Parameter 2: Track &24 (default save game data)
1431  00           .     EQUB &00                ; Parameter 3: Sector &00
1432  14           .     EQUB &14                ; Parameter 4: Length &1400

1433  52           R     EQUB &52                ; Command &52: Load data
1434  10           .     EQUB &10                ; Parameter 1: Game disc (side 1)
1435  26           &     EQUB &26                ; Parameter 2: Track &26
1436  00           .     EQUB &00                ; Parameter 3: Sector &00
1437  14           .     EQUB &14                ; Parameter 4: Length &1400

1438  52           R     EQUB &52                ; Command &52: Load data
1439  10           .     EQUB &10                ; Parameter 1: Game disc (side 1)
143A  0F           .     EQUB &0F                ; Parameter 2: Track &0F
143B  09           .     EQUB &09                ; Parameter 3: Sector &09
143C  01           .     EQUB &01                ; Parameter 4: Length &0100

143D  50           P     EQUB &50                ; Command &50: Switch disc
143E  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)

143F  41           A     EQUB &41                ; Command &41: Write disc identifier
1440  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)

1441  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1442  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)
1443  24           $     EQUB &24                ; Parameter 2: Track &24
1444  00           .     EQUB &00                ; Parameter 3: Sector &00
1445  14           .     EQUB &14                ; Parameter 4: Length &1400

1446  57           W     EQUB &57                ; Command &57: Save data
1447  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)
1448  26           &     EQUB &26                ; Parameter 2: Track &26
1449  00           .     EQUB &00                ; Parameter 3: Sector &00
144A  14           .     EQUB &14                ; Parameter 4: Length &1400

144B  57           W     EQUB &57                ; Command &57: Save data
144C  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)
144D  00           .     EQUB &00                ; Parameter 2: Track &00
144E  08           .     EQUB &08                ; Parameter 3: Sector &08
144F  01           .     EQUB &01                ; Parameter 4: Length &0100

1450  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
1451  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
1452  01           .     EQUB &01                ; Parameter 2: Track &01
1453  00           .     EQUB &00                ; Parameter 3: Sector &00
1454  0A           .     EQUB &0A                ; Parameter 4: Length &0A00

1455  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1456  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)
1457  01           .     EQUB &01                ; Parameter 2: Track &01
1458  00           .     EQUB &00                ; Parameter 3: Sector &00
1459  0A           .     EQUB &0A                ; Parameter 4: Length &0A00

145A  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
145B  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
145C  02           .     EQUB &02                ; Parameter 2: Track &02
145D  00           .     EQUB &00                ; Parameter 3: Sector &00
145E  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

145F  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1460  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)
1461  02           .     EQUB &02                ; Parameter 2: Track &02
1462  00           .     EQUB &00                ; Parameter 3: Sector &00
1463  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

1464  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
1465  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
1466  09           .     EQUB &09                ; Parameter 2: Track &09
1467  06           .     EQUB &06                ; Parameter 3: Sector &06
1468  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

1469  53           S     EQUB &53                ; Command &53: Reset pointer and save data
146A  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)
146B  09           .     EQUB &09                ; Parameter 2: Track &09
146C  06           .     EQUB &06                ; Parameter 3: Sector &06
146D  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

146E  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
146F  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
1470  11           .     EQUB &11                ; Parameter 2: Track &11
1471  02           .     EQUB &02                ; Parameter 3: Sector &02
1472  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

1473  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1474  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)
1475  11           .     EQUB &11                ; Parameter 2: Track &11
1476  02           .     EQUB &02                ; Parameter 3: Sector &02
1477  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

1478  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
1479  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
147A  18           .     EQUB &18                ; Parameter 2: Track &18
147B  08           .     EQUB &08                ; Parameter 3: Sector &08
147C  23           #     EQUB &23                ; Parameter 4: Length &2300

147D  53           S     EQUB &53                ; Command &53: Reset pointer and save data
147E  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)
147F  18           .     EQUB &18                ; Parameter 2: Track &18
1480  08           .     EQUB &08                ; Parameter 3: Sector &08
1481  23           #     EQUB &23                ; Parameter 4: Length &2300

1482  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
1483  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
1484  1D           .     EQUB &1D                ; Parameter 2: Track &1D
1485  00           .     EQUB &00                ; Parameter 3: Sector &00
1486  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

1487  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1488  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)
1489  28           (     EQUB &28                ; Parameter 2: Track &28
148A  00           .     EQUB &00                ; Parameter 3: Sector &00
148B  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

148C  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
148D  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
148E  24           $     EQUB &24                ; Parameter 2: Track &24
148F  06           .     EQUB &06                ; Parameter 3: Sector &06
1490  22           "     EQUB &22                ; Parameter 4: Length &2200

1491  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1492  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)
1493  2F           /     EQUB &2F                ; Parameter 2: Track &2F
1494  06           .     EQUB &06                ; Parameter 3: Sector &06
1495  22           "     EQUB &22                ; Parameter 4: Length &2200

1496  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
1497  10           .     EQUB &10                ; Parameter 1: Game disc (side 1)
1498  10           .     EQUB &10                ; Parameter 2: Track &10
1499  00           .     EQUB &00                ; Parameter 3: Sector &00
149A  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

149B  53           S     EQUB &53                ; Command &53: Reset pointer and save data
149C  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)
149D  33           3     EQUB &33                ; Parameter 2: Track &33
149E  00           .     EQUB &00                ; Parameter 3: Sector &00
149F  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

14A0  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
14A1  10           .     EQUB &10                ; Parameter 1: Game disc (side 1)
14A2  17           .     EQUB &17                ; Parameter 2: Track &17
14A3  06           .     EQUB &06                ; Parameter 3: Sector &06
14A4  43           C     EQUB &43                ; Parameter 4: Length &4300

14A5  53           S     EQUB &53                ; Command &53: Reset pointer and save data
14A6  03           .     EQUB &03                ; Parameter 1: Picture disc (80 tracks)
14A7  3A           :     EQUB &3A                ; Parameter 2: Track &3A
14A8  06           .     EQUB &06                ; Parameter 3: Sector &06
14A9  43           C     EQUB &43                ; Parameter 4: Length &4300

14AA  51           Q     EQUB &51                ; Command &51: Quit

14AB  00           .     EQUB &00                ; Termination byte

; -----------------------------------------------------------------------------
; RUN table for two 40 track picture discs
; -----------------------------------------------------------------------------
.
14AC  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
14AD  10           .     EQUB &10                ; Parameter 1: Game disc (side 1)
14AE  24           $     EQUB &24                ; Parameter 2: Track &24
14AF  00           .     EQUB &00                ; Parameter 3: Sector &00
14B0  14           .     EQUB &14                ; Parameter 4: Length &1400

14B1  52           R     EQUB &52                ; Command &52: Load data
14B2  10           .     EQUB &10                ; Parameter 1: Game disc (side 1)
14B3  26           &     EQUB &26                ; Parameter 2: Track &26
14B4  00           .     EQUB &00                ; Parameter 3: Sector &00
14B5  14           .     EQUB &14                ; Parameter 4: Length &1400

14B6  52           R     EQUB &52                ; Command &52: Load data
14B7  10           .     EQUB &10                ; Parameter 1: Game disc (side 1)
14B8  0F           .     EQUB &0F                ; Parameter 2: Track &0F
14B9  07           .     EQUB &07                ; Parameter 3: Sector &07
14BA  01           .     EQUB &01                ; Parameter 4: Length &0100

14BB  52           R     EQUB &52                ; Command &52: Load data
14BC  10           .     EQUB &10                ; Parameter 1: Game disc (side 1)
14BD  0F           .     EQUB &0F                ; Parameter 2: Track &0F
14BE  08           .     EQUB &08                ; Parameter 3: Sector &08
14BF  01           .     EQUB &01                ; Parameter 4: Length &0100

14C0  50           P     EQUB &50                ; Command &50: Switch disc
14C1  01           .     EQUB &01                ; Parameter 1: Picture disc 1 (40 tracks)

14C2  41           A     EQUB &41                ; Command &41: Write disc identifier
14C3  01           .     EQUB &01                ; Parameter 1: Picture disc 1 (40 tracks)

14C4  53           S     EQUB &53                ; Command &53: Reset pointer and save data
14C5  01           .     EQUB &01                ; Parameter 1: Picture disc 1 (40 tracks)
14C6  24           $     EQUB &24                ; Parameter 2: Track &24
14C7  00           .     EQUB &00                ; Parameter 3: Sector &00
14C8  14           .     EQUB &14                ; Parameter 4: Length &1400

14C9  57           W     EQUB &57                ; Command &57: Save data
14CA  01           .     EQUB &01                ; Parameter 1: Picture disc 1 (40 tracks)
14CB  26           &     EQUB &26                ; Parameter 2: Track &26
14CC  00           .     EQUB &00                ; Parameter 3: Sector &00
14CD  14           .     EQUB &14                ; Parameter 4: Length &1400

14CE  57           W     EQUB &57                ; Command &57: Save data
14CF  01           .     EQUB &01                ; Parameter 1: Picture disc 1 (40 tracks)
14D0  00           .     EQUB &00                ; Parameter 2: Track &00
14D1  08           .     EQUB &08                ; Parameter 3: Sector &08
14D2  01           .     EQUB &01                ; Parameter 4: Length &0100

14D3  50           P     EQUB &50                ; Command &50: Switch disc
14D4  02           .     EQUB &02                ; Parameter 1: Picture disc 2 (40 tracks)

14D5  41           A     EQUB &41                ; Command &41: Write disc identifier
14D6  02           .     EQUB &02                ; Parameter 1: Picture disc 2 (40 tracks)

14D7  53           S     EQUB &53                ; Command &53: Reset pointer and save data
14D8  02           .     EQUB &02                ; Parameter 1: Picture disc 2 (40 tracks)
14D9  24           $     EQUB &24                ; Parameter 2: Track &24
14DA  00           .     EQUB &00                ; Parameter 3: Sector &00
14DB  14           .     EQUB &14                ; Parameter 4: Length &1400

14DC  57           W     EQUB &57                ; Command &57: Save data
14DD  02           .     EQUB &02                ; Parameter 1: Picture disc 2 (40 tracks)
14DE  26           &     EQUB &26                ; Parameter 2: Track &26
14DF  00           .     EQUB &00                ; Parameter 3: Sector &00
14E0  14           .     EQUB &14                ; Parameter 4: Length &1400

14E1  57           W     EQUB &57                ; Command &57: Save data
14E2  02           .     EQUB &02                ; Parameter 1: Picture disc 2 (40 tracks)
14E3  00           .     EQUB &00                ; Parameter 2: Track &08
14E4  08           .     EQUB &08                ; Parameter 3: Sector &08
14E5  01           .     EQUB &01                ; Parameter 4: Length &0100

14E6  57           W     EQUB &57                ; Command &57: Save data
14E7  02           .     EQUB &02                ; Parameter 1: Picture disc 2 (40 tracks)
14E8  00           .     EQUB &00                ; Parameter 2: Track &00
14E9  08           .     EQUB &08                ; Parameter 3: Sector &08
14EA  01           .     EQUB &01                ; Parameter 4: Length &0100

14EB  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
14EC  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
14ED  01           .     EQUB &01                ; Parameter 2: Track &01
14EE  00           .     EQUB &00                ; Parameter 3: Sector &00
14EF  0A           .     EQUB &0A                ; Parameter 4: Length &0A00

14F0  53           S     EQUB &53                ; Command &53: Reset pointer and save data
14F1  01           .     EQUB &01                ; Parameter 1: Picture disc 1 (40 tracks)
14F2  01           .     EQUB &01                ; Parameter 2: Track &01
14F3  00           .     EQUB &00                ; Parameter 3: Sector &00
14F4  0A           .     EQUB &0A                ; Parameter 4: Length &0A00

14F5  53           S     EQUB &53                ; Command &53: Reset pointer and save data
14F6  02           .     EQUB &02                ; Parameter 1: Picture disc 2 (40 tracks)
14F7  01           .     EQUB &01                ; Parameter 2: Track &01
14F8  00           .     EQUB &00                ; Parameter 3: Sector &00
14F9  0A           .     EQUB &0A                ; Parameter 4: Length &0A00

14FA  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
14FB  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
14FC  02           .     EQUB &02                ; Parameter 2: Track &02
14FD  00           .     EQUB &00                ; Parameter 3: Sector &00
14FE  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

14FF  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1500  01           .     EQUB &01                ; Parameter 1: Picture disc 1 (40 tracks)
1501  02           .     EQUB &02                ; Parameter 2: Track &02
1502  00           .     EQUB &00                ; Parameter 3: Sector &00
1503  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

1504  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1505  02           .     EQUB &02                ; Parameter 1: Picture disc 2 (40 tracks)
1506  02           .     EQUB &02                ; Parameter 2: Track &02
1507  00           .     EQUB &00                ; Parameter 3: Sector &00
1508  0A           .     EQUB &0A                ; Parameter 4: Length &0A00

1509  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
150A  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
150B  09           .     EQUB &09                ; Parameter 2: Track &09
150C  06           .     EQUB &06                ; Parameter 3: Sector &06
150D  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

150E  53           S     EQUB &53                ; Command &53: Reset pointer and save data
150F  01           .     EQUB &01                ; Parameter 1: Picture disc 1 (40 tracks)
1510  09           .     EQUB &09                ; Parameter 2: Track &09
1511  06           .     EQUB &06                ; Parameter 3: Sector &06
1512  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

1513  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
1514  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
1515  11           .     EQUB &11                ; Parameter 2: Track &11
1516  02           .     EQUB &02                ; Parameter 3: Sector &02
1517  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

1518  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1519  01           .     EQUB &01                ; Parameter 1: Picture disc 1 (40 tracks)
151A  11           .     EQUB &11                ; Parameter 2: Track &11
151B  02           .     EQUB &02                ; Parameter 3: Sector &02
151C  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

151D  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
151E  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
151F  18           .     EQUB &18                ; Parameter 2: Track &18
1520  08           .     EQUB &08                ; Parameter 3: Sector &08
1521  23           #     EQUB &23                ; Parameter 4: Length &2300

1522  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1523  01           .     EQUB &01                ; Parameter 1: Picture disc 1 (40 tracks)
1524  18           .     EQUB &18                ; Parameter 2: Track &18
1525  08           .     EQUB &08                ; Parameter 3: Sector &08
1526  23           #     EQUB &23                ; Parameter 4: Length &2300

1527  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
1528  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
1529  1D           .     EQUB &1D                ; Parameter 2: Track &1D
152A  00           .     EQUB &00                ; Parameter 3: Sector &00
152B  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

152C  53           S     EQUB &53                ; Command &53: Reset pointer and save data
152D  02           .     EQUB &02                ; Parameter 1: Picture disc 2 (40 tracks)
152E  03           .     EQUB &03                ; Parameter 2: Track &03
152F  00           .     EQUB &00                ; Parameter 3: Sector &00
1530  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

1531  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
1532  20                 EQUB &20                ; Parameter 1: Game disc (side 2)
1533  24           $     EQUB &24                ; Parameter 2: Track &24
1534  06           .     EQUB &06                ; Parameter 3: Sector &06
1535  22           "     EQUB &22                ; Parameter 4: Length &2200

1536  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1537  02           .     EQUB &02                ; Parameter 1: Picture disc 2 (40 tracks)
1538  0A           .     EQUB &0A                ; Parameter 2: Track &0A
1539  06           .     EQUB &06                ; Parameter 3: Sector &06
153A  22           "     EQUB &22                ; Parameter 4: Length &2200

153B  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
153C  10           .     EQUB &10                ; Parameter 1: Game disc (side 1)
153D  10           .     EQUB &10                ; Parameter 2: Track &10
153E  00           .     EQUB &00                ; Parameter 3: Sector &00
153F  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

1540  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1541  02           .     EQUB &02                ; Parameter 1: Picture disc 2 (40 tracks)
1542  0E           .     EQUB &0E                ; Parameter 2: Track &0E
1543  00           .     EQUB &00                ; Parameter 3: Sector &00
1544  4C           L     EQUB &4C                ; Parameter 4: Length &4C00

1545  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
1546  10           .     EQUB &10                ; Parameter 1: Game disc (side 1)
1547  17           .     EQUB &17                ; Parameter 2: Track &17
1548  06           .     EQUB &06                ; Parameter 3: Sector &06
1549  43           C     EQUB &43                ; Parameter 4: Length &4300

154A  53           S     EQUB &53                ; Command &53: Reset pointer and save data
154B  02           .     EQUB &02                ; Parameter 1: Picture disc 2 (40 tracks)
154C  15           .     EQUB &15                ; Parameter 2: Track &15
154D  06           .     EQUB &06                ; Parameter 3: Sector &06
154E  43           C     EQUB &43                ; Parameter 4: Length &4300

154F  51           Q     EQUB &51                ; Command &51: Quit

1550  00           .     EQUB &00                ; Termination byte

; -----------------------------------------------------------------------------
; RUN table for save game disc
; -----------------------------------------------------------------------------
.
1551  4C           L     EQUB &4C                ; Command &4C: Reset pointer and load data
1552  10           .     EQUB &10                ; Parameter 1: Game disc (side 1)
1553  24           $     EQUB &24                ; Parameter 2: Track &24
1554  00           .     EQUB &00                ; Parameter 3: Sector &00
1555  14           .     EQUB &14                ; Parameter 4: Length &1400

1556  50           P     EQUB &50                ; Command &50: Switch disc
1557  04           .     EQUB &04                ; Parameter 1: Save game disc

1558  41           A     EQUB &41                ; Command &41: Write disc identifier
1559  04           .     EQUB &04                ; Parameter 1: Save game disc

155A  53           S     EQUB &53                ; Command &53: Reset pointer and save data
155B  04           .     EQUB &04                ; Parameter 1: Save game disc
155C  02           .     EQUB &02                ; Parameter 2: Track &02 (save game 00)
155D  00           .     EQUB &00                ; Parameter 3: Sector &00
155E  14           .     EQUB &14                ; Parameter 4: Length &1400

155F  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1560  04           .     EQUB &04                ; Parameter 1: Save game disc
1561  04           .     EQUB &04                ; Parameter 2: Track &04 (save game 01)
1562  00           .     EQUB &00                ; Parameter 3: Sector &00
1563  14           .     EQUB &14                ; Parameter 4: Length &1400

1564  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1565  04           .     EQUB &04                ; Parameter 1: Save game disc
1566  06           .     EQUB &06                ; Parameter 2: Track &06 (save game 02)
1567  00           .     EQUB &00                ; Parameter 3: Sector &00
1568  14           .     EQUB &14                ; Parameter 4: Length &1400

1569  53           S     EQUB &53                ; Command &53: Reset pointer and save data
156A  04           .     EQUB &04                ; Parameter 1: Save game disc
156B  08           .     EQUB &08                ; Parameter 2: Track &08 (save game 03)
156C  00           .     EQUB &00                ; Parameter 3: Sector &00
156D  14           .     EQUB &14                ; Parameter 4: Length &1400

156E  53           S     EQUB &53                ; Command &53: Reset pointer and save data
156F  04           .     EQUB &04                ; Parameter 1: Save game disc
1570  0A           .     EQUB &0A                ; Parameter 2: Track &0A (save game 04)
1571  00           .     EQUB &00                ; Parameter 3: Sector &00
1572  14           .     EQUB &14                ; Parameter 4: Length &1400

1573  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1574  04           .     EQUB &04                ; Parameter 1: Save game disc
1575  0C           .     EQUB &0C                ; Parameter 2: Track &0C (save game 05)
1576  00           .     EQUB &00                ; Parameter 3: Sector &00
1577  14           .     EQUB &14                ; Parameter 4: Length &1400

1578  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1579  04           .     EQUB &04                ; Parameter 1: Save game disc
157A  0E           .     EQUB &0E                ; Parameter 2: Track &0E (save game 06)
157B  00           .     EQUB &00                ; Parameter 3: Sector &00
157C  14           .     EQUB &14                ; Parameter 4: Length &1400

157D  53           S     EQUB &53                ; Command &53: Reset pointer and save data
157E  04           .     EQUB &04                ; Parameter 1: Save game disc
157F  10           .     EQUB &10                ; Parameter 2: Track &10 (save game 07)
1580  00           .     EQUB &00                ; Parameter 3: Sector &00
1581  14           .     EQUB &14                ; Parameter 4: Length &1400

1582  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1583  04           .     EQUB &04                ; Parameter 1: Save game disc
1584  12           .     EQUB &12                ; Parameter 2: Track &12 (save game 08)
1585  00           .     EQUB &00                ; Parameter 3: Sector &00
1586  14           .     EQUB &14                ; Parameter 4: Length &1400

1587  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1588  04           .     EQUB &04                ; Parameter 1: Save game disc
1589  14           .     EQUB &14                ; Parameter 2: Track &14 (save game 09)
158A  00           .     EQUB &00                ; Parameter 3: Sector &00
158B  14           .     EQUB &14                ; Parameter 4: Length &1400

158C  53           S     EQUB &53                ; Command &53: Reset pointer and save data
158D  04           .     EQUB &04                ; Parameter 1: Save game disc
158E  16           .     EQUB &16                ; Parameter 2: Track &16 (save game 10)
158F  00           .     EQUB &00                ; Parameter 3: Sector &00
1590  14           .     EQUB &14                ; Parameter 4: Length &1400

1591  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1592  04           .     EQUB &04                ; Parameter 1: Save game disc
1593  18           .     EQUB &18                ; Parameter 2: Track &18 (save game 11)
1594  00           .     EQUB &00                ; Parameter 3: Sector &00
1595  14           .     EQUB &14                ; Parameter 4: Length &1400

1596  53           S     EQUB &53                ; Command &53: Reset pointer and save data
1597  04           .     EQUB &04                ; Parameter 1: Save game disc
1598  1A           .     EQUB &1A                ; Parameter 2: Track &1A (save game 12)
1599  00           .     EQUB &00                ; Parameter 3: Sector &00
159A  14           .     EQUB &14                ; Parameter 4: Length &1400

159B  53           S     EQUB &53                ; Command &53: Reset pointer and save data
159C  04           .     EQUB &04                ; Parameter 1: Save game disc
159D  1C           .     EQUB &1C                ; Parameter 2: Track &1C (save game 13)
159E  00           .     EQUB &00                ; Parameter 3: Sector &00
159F  14           .     EQUB &14                ; Parameter 4: Length &1400

15A0  53           S     EQUB &53                ; Command &53: Reset pointer and save data
15A1  04           .     EQUB &04                ; Parameter 1: Save game disc
15A2  1E           .     EQUB &1E                ; Parameter 2: Track &1E (save game 14)
15A3  00           .     EQUB &00                ; Parameter 3: Sector &00
15A4  14           .     EQUB &14                ; Parameter 4: Length &1400

15A5  53           S     EQUB &53                ; Command &53: Reset pointer and save data
15A6  04           .     EQUB &04                ; Parameter 1: Save game disc
15A7  20                 EQUB &20                ; Parameter 2: Track &20 (save game 15)
15A8  00           .     EQUB &00                ; Parameter 3: Sector &00
15A9  14           .     EQUB &14                ; Parameter 4: Length &1400

15AA  53           S     EQUB &53                ; Command &53: Reset pointer and save data
15AB  04           .     EQUB &04                ; Parameter 1: Save game disc
15AC  22           "     EQUB &22                ; Parameter 2: Track &22 (save game 16)
15AD  00           .     EQUB &00                ; Parameter 3: Sector &00
15AE  14           .     EQUB &14                ; Parameter 4: Length &1400

15AF  53           S     EQUB &53                ; Command &53: Reset pointer and save data
15B0  04           .     EQUB &04                ; Parameter 1: Save game disc
15B1  24           $     EQUB &24                ; Parameter 2: Track &24 (save game 17)
15B2  00           .     EQUB &00                ; Parameter 3: Sector &00
15B3  14           .     EQUB &14                ; Parameter 4: Length &1400

15B4  53           S     EQUB &53                ; Command &53: Reset pointer and save data
15B5  04           .     EQUB &04                ; Parameter 1: Save game disc
15B6  26           &     EQUB &26                ; Parameter 2: Track &26 (save game ??)
15B7  00           .     EQUB &00                ; Parameter 3: Sector &00
15B8  14           .     EQUB &14                ; Parameter 4: Length &1400

15B9  51           Q     EQUB &51                ; Command &51: Quit

15BA  00           .     EQUB &00                ; Termination byte

; -----------------------------------------------------------------------------
; Pointer to buffer
; -----------------------------------------------------------------------------
.
15BB  00           .     EQUB &00                ; Pointer to buffer (LSB)
15BC  00           .     EQUB &00                ; Pointer to buffer (MSB)

; -----------------------------------------------------------------------------
; Begin of buffer
; -----------------------------------------------------------------------------
.buffer
