         nam   VDGInt
         ttl   os9 system module    

* Disassembled 98/08/23 22:06:22 by Disasm v1.6 (C) 1988 by RML

         ifp1
         use   defsfile
         endc
tylg     set   Systm+Objct   
atrv     set   ReEnt+rev
rev      set   $01
         mod   eom,name,tylg,atrv,start,size
u0000    rmb   0
size     equ   .
         fcb   $07 
name     equ   *
         fcs   /VDGInt/
         fcb   $01 
start    equ   *
         lbra  L0079
         lbra  L016D
         lbra  L094C
         lbra  L0A84
         lbra  L004A
         cmpa  #$00
         bne   L0035
         ldb   <$37,u
         lbne  L0C07
         ldd   <$44,u
         lbra  L037D
L0035    cmpa  #$01
         beq   L003B
         clrb  
         rts   
L003B    ldx   <$00A5
         leax  <$54,x
         ldd   ,x
         std   $04,x
         ldd   $02,x
         std   $06,x
         clrb  
         rts   
L004A    pshs  u,y,x
         lbsr  L0511
         ldb   #$03
L0051    pshs  b
         lbsr  L0BCA
         lbsr  L0BF4
         puls  b
         decb  
         bne   L0051
         clr   <$1E,u
         ldd   #$0200
         ldu   <$38,u
         beq   L006C
         os9   F$SRtMem 
L006C    ldb   #$E1
         leax  <$1F,u
         clra  
L0072    sta   ,x+
         decb  
         bne   L0072
         bra   L00D8
L0079    pshs  u,y,x
         bsr   L00DB
         lda   #$AF
         sta   <$41,u
         pshs  u
         ldd   #$0300
         os9   F$SRqMem 
         tfr   u,d
         tfr   u,x
         bita  #$01
         beq   L0098
         leax  >$0100,x
         bra   L009C
L0098    leau  >$0200,u
L009C    ldd   #$0100
         os9   F$SRtMem 
         puls  u
         stx   <$38,u
         stx   <$3C,u
         leax  >$0200,x
         stx   <$3A,u
         lda   #$60
         sta   <$3E,u
         sta   <$40,u
         lbsr  L02CD
         inc   <$1E,u
         ldd   <$1F,u
         lbsr  L0AB2
         leax  <$7C,u
         stx   <$2F,u
         stx   <$31,u
         ldu   <$00A5
         ldb   <$24,u
         orb   #$02
         stb   <$24,u
L00D8    clrb  
         puls  pc,u,y,x
L00DB    pshs  u,y,x,b,a
         lda   #$08
         sta   <$7B,u
         leax  >L011D,pcr
         leay  <$6B,u
L00E9    leau  >L00FB,pcr
L00ED    pshs  u
         leau  >L012D,pcr
         ldb   #$10
L00F5    lda   ,x+
         jmp   [,s]
L00F9    lda   a,u
L00FB    sta   ,y+
         decb  
         bne   L00F5
         leas  $02,s
L0102    puls  pc,u,y,x,b,a
L0104    pshs  u,y,x,b,a
         lda   >$100A
         beq   L0102
         leax  <$6B,u
         ldy   #$FFB0
         lda   >$1009
         bne   L00E9
         leau  >L00F9,pcr
         bra   L00ED
L011D    fcb   $12,$36,$09,$24,$3f,$1b,$2d,$26,$00,$12,$00
         fcb   $3f,$00,$12,$00,$26
L012D    fcb   $00,$0c,$02
         fdb   $0e07,$0905,$101c,$2c0d,$1d0b,$1b0a,$2b22,$1112
         fdb   $2103,$0113,$321e,$2d1f,$2e0f,$3c2f,$3d17,$0815
         fdb   $0627,$1626,$3619,$2a1a,$3a18,$2928,$3814,$0423
         fdb   $3325,$3524,$3420,$3b31,$3e37,$393f
         fcb   $30
L016D    cmpa  #$0F
         bls   L01D8
         cmpa  #$1B
         beq   L01D8
         cmpa  #$1E
         bcs   L01D2
         cmpa  #$1F
         bls   L01D8
         tsta  
         bmi   L01BD
         ldb   <$35,u
         beq   L019D
         cmpa  #$5E
         bne   L018D
         lda   #$00
         bra   L01BD
L018D    cmpa  #$5F
         bne   L0195
         lda   #$1F
         bra   L01BD
L0195    cmpa  #$60
         bne   L01AD
         lda   #$67
         bra   L01BD
L019D    cmpa  #$7C
         bne   L01A5
         lda   #$21
         bra   L01BD
L01A5    cmpa  #$7E
         bne   L01AD
         lda   #$2D
         bra   L01BD
L01AD    cmpa  #$60
         bcs   L01B5
         suba  #$60
         bra   L01BD
L01B5    cmpa  #$40
         bcs   L01BB
         suba  #$40
L01BB    eora  #$40
L01BD    ldx   <$3C,u
         sta   ,x+
         stx   <$3C,u
         cmpx  <$3A,u
         bcs   L01CD
         lbsr  L025A
L01CD    lbsr  L0283
L01D0    clrb  
         rts   
L01D2    lbsr  L0A50
         bcc   L01D8
         rts   
L01D8    leax  >L01E1,pcr
         lsla  
         ldd   a,x
         jmp   d,x
L01E1    fcb   $ff
         fdb   $ef00,$f901,$3e01,$7701,$6901,$0d00,$daff
         fdb   $ef00,$cc01,$8900,$b300,$e800,$ec00,$9901,$9a02
         fdb   $4903,$6203,$1603,$3003,$8203,$9103,$ae03,$e403
         fdb   $e103,$c003,$bd04,$a600,$4404,$a305,$89ff,$efff
         fdb   $ef53,$c6f5,$39ae,$c82f,$a684,$8130,$2605,$17fe
         fdb   $aa20
         fcb   $22
L0233    cmpa  #$31
         bne   L01D0
         leax  <L023F,pcr
         ldb   #$02
         lbra  L068C
L023F    ldx   <$2F,u
         ldd   ,x
         cmpa  #$10
         lbhi  L0B7E
         cmpb  #$3F
         lbhi  L0B7E
         leax  <$6B,u
         stb   a,x
L0255    lbsr  L0104
         clrb  
         rts   
L025A    ldx   <$38,u
         leax  <$20,x
L0260    ldd   ,x++
         std   <-$22,x
         cmpx  <$3A,u
         bcs   L0260
         leax  <-$20,x
         stx   <$3C,u
         lda   #$20
         ldb   #$60
L0274    stb   ,x+
         deca  
         bne   L0274
         rts   
L027A    bsr   L02E4
         tfr   x,d
         andb  #$E0
         stb   <$3D,u
L0283    ldx   <$3C,u
         lda   ,x
         sta   <$3E,u
         lda   <$41,u
         beq   L0292
L0290    sta   ,x
L0292    clrb  
         rts   
         bsr   L02E4
         leax  <$20,x
         cmpx  <$3A,u
         bcs   L02A8
         leax  <-$20,x
         pshs  x
         lbsr  L025A
         puls  x
L02A8    stx   <$3C,u
         bra   L0283
         bsr   L02E4
         cmpx  <$38,u
         bls   L02B9
         leax  -$01,x
         stx   <$3C,u
L02B9    bra   L0283
         bsr   L02E4
         leax  $01,x
         cmpx  <$3A,u
         bcc   L02C7
         stx   <$3C,u
L02C7    bra   L0283
         bsr   L02E4
         bra   L02CF
L02CD    bsr   L02DA
L02CF    lda   #$60
L02D1    sta   ,x+
         cmpx  <$3A,u
         bcs   L02D1
         bra   L0283
L02DA    bsr   L02E4
         ldx   <$38,u
         stx   <$3C,u
         bra   L0283
L02E4    ldx   <$3C,u
         lda   <$3E,u
         sta   ,x
         clrb  
         rts   
         lda   <$7C,u
         suba  #$20
         bne   L02FA
         sta   <$41,u
         bra   L02E4
L02FA    cmpa  #$0B
         bge   L0292
         cmpa  #$01
         bgt   L0306
         lda   #$AF
         bra   L0316
L0306    cmpa  #$02
         bgt   L030E
         lda   #$A0
         bra   L0316
L030E    subb  #$03
         lsla  
         lsla  
         lsla  
         lsla  
         ora   #$8F
L0316    sta   <$41,u
         ldx   <$3C,u
         lbra  L0290
         ldb   #$02
         leax  <L0327,pcr
         lbra  L068C
L0327    bsr   L02E4
         ldb   <$7D,u
         subb  #$20
         lda   #$20
         mul   
         addb  <$7C,u
         adca  #$00
         subd  #$0020
         addd  <$38,u
         cmpd  <$3A,u
         lbcc  L0292
         std   <$3C,u
         lbra  L0283
         bsr   L02E4
         tfr   x,d
         andb  #$1F
         pshs  b
         ldb   #$20
         subb  ,s+
         bra   L035D
         lbsr  L027A
         ldb   #$20
L035D    lda   #$60
         ldx   <$3C,u
L0362    sta   ,x+
         decb  
         bne   L0362
         lbra  L0283
         lbsr  L02E4
         leax  <-$20,x
         cmpx  <$38,u
         bcs   L0378
         stx   <$3C,u
L0378    lbra  L0283
L037B    clra  
         clrb  
L037D    pshs  x,a
         stb   <$45,u
         clr   <$37,u
         lda   >$FF22
         anda  #$07
         ora   ,s+
         tstb  
         bne   L0394
         anda  #$EF
         ora   <$35,u
L0394    sta   <$44,u
         tst   >$100A
         lbeq  L0427
         sta   >$FF22
         tstb  
         bne   L03B2
         stb   >$FFC0
         stb   >$FFC2
         stb   >$FFC4
         lda   <$38,u
         bra   L03BE
L03B2    stb   >$FFC0
         stb   >$FFC3
         stb   >$FFC5
         lda   <$47,u
L03BE    lbsr  L0104
         ldb   <$0090
         orb   #$80
         stb   <$0090
         stb   >$FF90
         ldb   <$0098
         andb  #$78
         stb   >$FF98
         stb   <$0098
         clrb  
         stb   >$FF99
         stb   <$0099
         stb   >$FF9A
         stb   <$009A
         tfr   a,b
         andb  #$1F
         pshs  b
         anda  #$E0
         lsra  
         lsra  
         lsra  
         lsra  
         ldx   <$004C
         leax  a,x
         ldb   $01,x
         pshs  b
         andb  #$38
         lslb  
         lslb  
         stb   <$009D
         stb   >$FF9D
         clrb  
         stb   <$009E
         stb   >$FF9E
         ldb   #$0F
         stb   <$009C
         stb   >$FF9C
         puls  a
         lsla  
         lsla  
         lsla  
         lsla  
         lsla  
         ora   ,s+
         ldb   #$07
         ldx   #$FFC6
         lsra  
L0417    lsra  
         bcs   L0420
         sta   ,x+
         leax  $01,x
         bra   L0424
L0420    leax  $01,x
         sta   ,x+
L0424    decb  
         bne   L0417
L0427    clrb  
         puls  pc,x
         leax  <L0432,pcr
         ldb   #$02
         lbra  L068C
L0432    ldb   <$46,u
         bne   L0468
         lbsr  L0C74
         bcs   L0486
         stb   <$4A,u
         stb   <$49,u
         tfr   d,x
         ldd   <$0050
         pshs  u,b,a
         ldd   <$004A
         std   <$0050
         ldb   #$01
         os9   F$MapBlk 
         tfr   u,x
         puls  u,b,a
         std   <$0050
         bcs   L0486
         stx   <$47,u
         inc   <$46,u
         lda   #$01
         ldb   #$20
         bsr   L04D9
         lbsr  L0563
L0468    lda   <$7D,u
         sta   <$66,u
         anda  #$03
         leax  >L0578,pcr
         lda   a,x
         sta   <$62,u
         sta   <$63,u
         lda   <$7C,u
         cmpa  #$01
         bls   L0487
         comb  
         ldb   #$CB
L0486    rts   
L0487    tsta  
         beq   L04A7
         ldd   #$C003
         std   <$64,u
         lda   #$01
         sta   <$3F,u
         lda   #$E0
         ldb   <$7D,u
         andb  #$08
         beq   L04A0
         lda   #$F0
L04A0    ldb   #$03
         leax  <L04EB,pcr
         bra   L04C4
L04A7    ldd   #$8001
         std   <$64,u
         lda   #$FF
         tst   <$62,u
         beq   L04BA
         sta   <$62,u
         sta   <$63,u
L04BA    sta   <$3F,u
         lda   #$F0
         ldb   #$07
         leax  <L04EF,pcr
L04C4    stb   <$5F,u
         stx   <$5D,u
         ldb   <$7D,u
         andb  #$04
         lslb  
         pshs  b
         ora   ,s+
         ldb   #$01
         lbra  L037D
L04D9    pshs  x,b,a
         clra  
         ldb   $02,s
         ldx   <$004E
         leax  d,x
         puls  b,a
L04E4    sta   ,x+
         decb  
         bne   L04E4
         puls  pc,x
L04EB    subb  #$30
         inc   <$0003
L04EF    fcb   $80,$40,$20,$10,$08,$04,$02,$01,$30,$8c,$03,$16,$01
         fcb   $8d,$a6,$c8,$7c,$a7,$c8,$7d
L0503    clr   <$7C,u
         lda   <$3F,u
         bmi   L050E
         inc   <$7C,u
L050E    lbra  L0468
L0511    ldx   <$47,u
         beq   L051B
         clra  
         ldb   #$20
         bsr   L04D9
L051B    leay  <$4A,u
         ldb   #$03
         pshs  u,b
L0522    lda   ,y+
         beq   L052D
         clrb  
         tfr   d,x
         incb  
         os9   F$DelRAM 
L052D    dec   ,s
         bgt   L0522
         ldu   ,y
         beq   L053B
         ldd   #$0200
         os9   F$SRtMem 
L053B    puls  u,b
         clr   <$46,u
         lbra  L037B
         leax  <L0549,pcr
         lbra  L068A
L0549    lda   <$7C,u
         tst   <$3F,u
         bpl   L0559
         ldb   #$FF
         anda  #$01
         beq   L0563
         bra   L0564
L0559    anda  #$03
         leax  >L0578,pcr
         ldb   a,x
         bra   L0564
L0563    clrb  
L0564    ldx   <$47,u
         leax  >$1801,x
L056B    stb   ,-x
         cmpx  <$47,u
         bhi   L056B
         clra  
         clrb  
         std   <$60,u
         rts   
L0578    fcb   $00,$55,$aa,$ff
L057C    fcb   $ec,$c8,$7c,$c1,$c0
         bcs   L0585
         ldb   #$BF
L0585    tst   <$3F,u
         bmi   L058B
         lsra  
L058B    std   <$7C,u
         rts   
         leax  <L0597,pcr
L0592    ldb   #$02
         lbra  L068C
L0597    bsr   L057C
         std   <$60,u
         clrb  
         rts   
         clr   <$62,u
         leax  <L05A6,pcr
         bra   L0592
L05A6    bsr   L057C
         std   <$60,u
         bsr   L05B0
         lbra  L067C
L05B0    lbsr  L0A58
L05B3    tfr   a,b
         comb  
         andb  ,x
         stb   ,x
         anda  <$62,u
         ora   ,x
         sta   ,x
         rts   
         clr   <$62,u
         leax  <L05CA,pcr
         bra   L0592
L05CA    bsr   L057C
         leas  -$0E,s
         std   $0C,s
         lbsr  L0A58
         stx   $02,s
         sta   $01,s
         ldd   <$60,u
         lbsr  L0A58
         sta   ,s
         clra  
         clrb  
         std   $04,s
         lda   #$BF
         suba  <$61,u
         sta   <$61,u
         lda   #$BF
         suba  <$7D,u
         sta   <$7D,u
         lda   #$FF
         sta   $06,s
         clra  
         ldb   <$60,u
         subb  <$7C,u
         sbca  #$00
         bpl   L0608
         nega  
         negb  
         sbca  #$00
         neg   $06,s
L0608    std   $08,s
         bne   L0611
         ldd   #$FFFF
         std   $04,s
L0611    lda   #$E0
         sta   $07,s
         clra  
         ldb   <$61,u
         subb  <$7D,u
         sbca  #$00
         bpl   L0626
         nega  
         negb  
         sbca  #$00
         neg   $07,s
L0626    std   $0A,s
         bra   L0632
L062A    sta   ,s
         ldd   $04,s
         subd  $0A,s
         std   $04,s
L0632    lda   ,s
         lbsr  L05B3
         cmpx  $02,s
         bne   L0641
         lda   ,s
         cmpa  $01,s
         beq   L0675
L0641    ldd   $04,s
         bpl   L064F
         addd  $08,s
         std   $04,s
         lda   $07,s
         leax  a,x
         bra   L0632
L064F    lda   ,s
         ldb   $06,s
         bpl   L0665
         lsla  
         ldb   <$3F,u
         bmi   L065C
         lsla  
L065C    bcc   L062A
         lda   <$65,u
         leax  -$01,x
         bra   L062A
L0665    lsra  
         ldb   <$3F,u
         bmi   L066C
         lsra  
L066C    bcc   L062A
         lda   <$64,u
         leax  $01,x
         bra   L062A
L0675    ldd   $0C,s
         std   <$60,u
         leas  $0E,s
L067C    lda   <$63,u
         sta   <$62,u
         clrb  
         rts   
         clr   <$62,u
         leax  <L0694,pcr
L068A    ldb   #$01
L068C    stb   <$2C,u
         stx   <$2D,u
         clrb  
         rts   
L0694    leas  -$04,s
         ldb   <$7C,u
         stb   $01,s
         clra  
         sta   ,s
         addb  $01,s
         adca  #$00
         nega  
         negb  
         sbca  #$00
         addd  #$0003
         std   $02,s
L06AB    lda   ,s
         cmpa  $01,s
         bcc   L06DD
         ldb   $01,s
         bsr   L06EB
         clra  
         ldb   $02,s
         bpl   L06C5
         ldb   ,s
         lslb  
         rola  
         lslb  
         rola  
         addd  #$0006
         bra   L06D5
L06C5    dec   $01,s
         clra  
         ldb   ,s
         subb  $01,s
         sbca  #$00
         lslb  
         rola  
         lslb  
         rola  
         addd  #$000A
L06D5    addd  $02,s
         std   $02,s
         inc   ,s
         bra   L06AB
L06DD    lda   ,s
         cmpa  $01,s
         bne   L06E7
         ldb   $01,s
         bsr   L06EB
L06E7    leas  $04,s
         bra   L067C
L06EB    leas  -$08,s
         sta   ,s
         clra  
         std   $02,s
         nega  
         negb  
         sbca  #$00
         std   $06,s
         ldb   ,s
         clra  
         std   ,s
         nega  
         negb  
         sbca  #$00
         std   $04,s
         ldx   $06,s
         bsr   L0734
         ldd   $04,s
         ldx   $02,s
         bsr   L0734
         ldd   ,s
         ldx   $02,s
         bsr   L0734
         ldd   ,s
         ldx   $06,s
         bsr   L0734
         ldd   $02,s
         ldx   ,s
         bsr   L0734
         ldd   $02,s
         ldx   $04,s
         bsr   L0734
         ldd   $06,s
         ldx   $04,s
         bsr   L0734
         ldd   $06,s
         ldx   ,s
         bsr   L0734
         leas  $08,s
         rts   
L0734    pshs  b,a
         ldb   <$61,u
         clra  
         leax  d,x
         cmpx  #$0000
         bmi   L0746
         cmpx  #$00BF
         ble   L0748
L0746    puls  pc,b,a
L0748    ldb   <$60,u
         clra  
         tst   <$3F,u
         bmi   L0753
         lslb  
         rola  
L0753    addd  ,s++
         tsta  
         beq   L0759
         rts   
L0759    pshs  b
         tfr   x,d
         puls  a
         tst   <$3F,u
         lbmi  L05B0
         lsra  
         lbra  L05B0
         clr   <$5C,u
         leas  -$07,s
         lbsr  L08DD
         lbcs  L0878
         lda   #$FF
         sta   <$6A,u
         ldd   <$60,u
         lbsr  L0883
         lda   <$67,u
         sta   <$68,u
         tst   <$3F,u
         bpl   L0793
         tsta  
         beq   L0799
         lda   #$FF
         bra   L0799
L0793    leax  >L0578,pcr
         lda   a,x
L0799    sta   <$69,u
         cmpa  <$62,u
         lbeq  L0878
         ldd   <$60,u
L07A6    suba  #$01
         bcs   L07B1
         lbsr  L0883
         bcs   L07B1
         beq   L07A6
L07B1    inca  
         std   $01,s
L07B4    lbsr  L08B6
         adda  #$01
         bcs   L07C2
         lbsr  L0883
         bcs   L07C2
         beq   L07B4
L07C2    deca  
         ldx   $01,s
         lbsr  L0905
         neg   <$6A,u
         lbsr  L0905
L07CE    lbsr  L092B
         lbcs  L0878
         tst   <$6A,u
         bpl   L07E5
         subb  #$01
         bcs   L07CE
         std   $03,s
         tfr   x,d
         decb  
         bra   L07EF
L07E5    incb  
         cmpb  #$BF
         bhi   L07CE
         std   $03,s
         tfr   x,d
         incb  
L07EF    std   $01,s
         lbsr  L0883
         bcs   L07CE
L07F6    bne   L0804
         suba  #$01
         bcc   L07FF
         inca  
         bra   L0808
L07FF    lbsr  L0883
         bcc   L07F6
L0804    adda  #$01
         bcs   L07CE
L0808    cmpd  $03,s
         bhi   L07CE
         bsr   L0883
         bcs   L07CE
         bne   L0804
         std   $05,s
         cmpd  $01,s
         bcc   L082D
         ldd   $01,s
         decb  
         cmpd  $05,s
         beq   L082D
         neg   <$6A,u
         ldx   $05,s
         lbsr  L0905
         neg   <$6A,u
L082D    ldd   $05,s
L082F    std   $01,s
L0831    bsr   L0883
         bcs   L083D
         bne   L083D
         bsr   L08B6
         adda  #$01
         bcc   L0831
L083D    deca  
         ldx   $01,s
         lbsr  L0905
         std   $05,s
         adda  #$01
         bcs   L0858
L0849    cmpd  $03,s
         bcc   L0858
         adda  #$01
         bsr   L0883
         bcs   L0858
         bne   L0849
         bra   L082F
L0858    inc   $03,s
         inc   $03,s
         ldd   $03,s
         cmpa  #$02
         lbcs  L07CE
         ldd   $05,s
         cmpd  $03,s
         lbcs  L07CE
         neg   <$6A,u
         ldx   $03,s
         lbsr  L0905
         lbra  L07CE
L0878    leas  $07,s
         clrb  
         ldb   <$5C,u
         beq   L0882
L0880    orcc  #$01
L0882    rts   
L0883    pshs  b,a
         cmpb  #$BF
         bhi   L08B2
         tst   <$3F,u
         bmi   L0892
         cmpa  #$7F
         bhi   L08B2
L0892    lbsr  L0A58
         tfr   a,b
         andb  ,x
L0899    bita  #$01
         bne   L08A8
         lsra  
         lsrb  
         tst   <$3F,u
         bmi   L0899
         lsra  
         lsrb  
         bra   L0899
L08A8    stb   <$67,u
         cmpb  <$68,u
         andcc #$FE
         puls  pc,b,a
L08B2    orcc  #$01
         puls  pc,b,a
L08B6    pshs  b,a
         lbsr  L0A58
         bita  #$80
         beq   L08D8
         ldb   <$69,u
         cmpb  ,x
         bne   L08D8
         ldb   <$62,u
         stb   ,x
         puls  b,a
         tst   <$3F,u
         bmi   L08D5
         adda  #$03
         rts   
L08D5    adda  #$07
         rts   
L08D8    lbsr  L05B3
         puls  pc,b,a
L08DD    ldx   <$5A,u
         beq   L08E7
         stx   <$58,u
L08E5    clrb  
         rts   
L08E7    pshs  u
         ldd   #$0200
         os9   F$SRqMem 
         bcc   L08F3
         puls  pc,u
L08F3    tfr   u,d
         puls  u
         std   <$56,u
         addd  #$0200
         std   <$5A,u
         std   <$58,u
         bra   L08E5
L0905    pshs  b,a
         ldd   <$58,u
         subd  #$0004
         cmpd  <$56,u
         bcs   L0924
         std   <$58,u
         tfr   d,y
         lda   <$6A,u
         sta   ,y
         stx   $01,y
         puls  b,a
         sta   $03,y
         rts   
L0924    ldb   #$F5
         stb   <$5C,u
         puls  pc,b,a
L092B    ldd   <$58,u
         cmpd  <$5A,u
         lbcc  L0880
         tfr   d,y
         addd  #$0004
         std   <$58,u
         lda   ,y
         sta   <$6A,u
         ldd   $01,y
         tfr   d,x
         lda   $03,y
         andcc #$FE
         rts   
L094C    ldx   $06,y
         cmpa  #$1C
         beq   L098E
         cmpa  #$26
         beq   L096A
         cmpa  #$25
         beq   L09BA
         cmpa  #$12
         lbeq  L0A15
         cmpa  #$91
         lbeq  L0977
         comb  
         ldb   #$D0
         rts   
L096A    clra  
         ldb   <$42,u
         std   $04,x
         ldb   <$43,u
         std   $06,x
         clrb  
         rts   
L0977    pshs  u,y,x
         leay  <$6B,u
         ldu   $04,x
         ldx   <$0050
         ldb   $06,x
         clra  
         tfr   y,x
         ldy   #$0010
         os9   F$Move   
         puls  pc,u,y,x
L098E    ldd   <$38,u
         anda  #$E0
         lsra  
         lsra  
         lsra  
         lsra  
         ldy   <$004C
         ldd   a,y
         lbsr  L0C7A
         bcs   L0A14
         pshs  b,a
         ldd   <$38,u
         anda  #$1F
         addd  ,s
         std   $04,x
         ldd   <$3C,u
         anda  #$1F
         addd  ,s++
         std   $06,x
         lda   <$21,u
         bra   L0A11
L09BA    ldd   <$3C,u
         subd  <$38,u
         pshs  b,a
         clra  
         andb  #$1F
         addb  #$20
         std   $04,x
         puls  b,a
         lsra  
         rolb  
         rolb  
         rolb  
         rolb  
         clra  
         andb  #$0F
         addb  #$20
         std   $06,x
         ldb   <$35,u
         lda   <$3E,u
         bmi   L0A11
         cmpa  #$60
         bcc   L09FC
         cmpa  #$20
         bcc   L0A00
         tstb  
         beq   L09FA
         cmpa  #$00
         bne   L09F2
         lda   #$5E
         bra   L0A11
L09F2    cmpa  #$1F
         bne   L09FA
         lda   #$5F
         bra   L0A11
L09FA    ora   #$20
L09FC    eora  #$40
         bra   L0A11
L0A00    tstb  
         bne   L0A11
         cmpa  #$21
         bne   L0A0B
         lda   #$7C
         bra   L0A11
L0A0B    cmpa  #$2D
         bne   L0A11
         lda   #$7E
L0A11    sta   $01,x
         clrb  
L0A14    rts   
L0A15    bsr   L0A50
         bcs   L0A4F
         ldd   <$60,u
         lbsr  L0A58
         tfr   a,b
         andb  ,x
L0A23    bita  #$01
         bne   L0A32
         lsra  
         lsrb  
         tst   <$3F,u
         bmi   L0A23
         lsra  
         lsrb  
         bra   L0A23
L0A32    pshs  b
         ldb   <$66,u
         andb  #$FC
         orb   ,s+
         ldx   $06,y
         stb   $01,x
         ldd   <$60,u
         std   $06,x
         ldb   <$49,u
         lbsr  L0C7A
         bcs   L0A4F
         std   $04,x
L0A4E    clrb  
L0A4F    rts   
L0A50    ldb   <$46,u
         bne   L0A4E
         lbra  L0AEE
L0A58    pshs  y,b,a
         ldb   <$3F,u
         bpl   L0A60
         lsra  
L0A60    lsra  
         lsra  
         pshs  a
         ldb   #$BF
         subb  $02,s
         lda   #$20
         mul   
         addb  ,s+
         adca  #$00
         ldy   <$47,u
         leay  d,y
         lda   ,s
         sty   ,s
         anda  <$5F,u
         ldx   <$5D,u
         lda   a,x
         puls  pc,y,x
L0A84    ldx   $06,y
         cmpa  #$28
         beq   L0AB0
         cmpa  #$80
         beq   L0AC6
         cmpa  #$81
         lbeq  L0AF2
         cmpa  #$8C
         lbeq  L0BBE
         cmpa  #$8E
         lbeq  L0B82
         cmpa  #$8B
         lbeq  L0B3A
         cmpa  #$8D
         lbeq  L0BD6
         comb  
         ldb   #$D0
         rts   
L0AB0    ldd   $06,x
L0AB2    ldb   #$10
         bita  #$01
         bne   L0AB9
         clrb  
L0AB9    stb   <$35,u
         ldd   #$2010
         inc   <$23,u
         std   <$42,u
         rts   
L0AC6    ldb   <$46,u
         beq   L0AEE
         ldd   #$0201
         leay  <$4B,u
         lbsr  L0C60
         bcs   L0AEB
         pshs  a
         lbsr  L0C74
         bcs   L0AEC
         stb   ,y
         lbsr  L0C7A
         bcs   L0AEC
         std   $04,x
         puls  b
         clra  
         std   $06,x
L0AEB    rts   
L0AEC    puls  pc,a
L0AEE    comb  
         ldb   #$F6
         rts   
L0AF2    ldb   <$46,u
         beq   L0AEE
         ldd   $06,x
         cmpd  #$0002
         bhi   L0B7E
         leay  <$4A,u
         ldb   b,y
         beq   L0B7E
         pshs  x
         stb   <$49,u
         lda   <$47,u
         anda  #$E0
         lsra  
         lsra  
         lsra  
         lsra  
         ldx   <$004A
         leax  <$40,x
         leax  a,x
         clra  
         std   ,x
         ldx   <$004A
         os9   F$SetTsk 
         puls  x
         ldd   $04,x
         beq   L0B2B
         ldb   #$01
L0B2B    stb   <$23,u
         clrb  
         rts   
L0B30    fcb   $14,$02,$15,$02,$16,$02,$1d,$04,$1e,$04
L0B3A    fcb   $e6
         fcb   $05,$c1,$04
         bhi   L0B7E
         lda   #$03
         pshs  y,x,b,a
         lda   #$03
         ldb   #$03
         leay  <$4D,u
         lbsr  L0C60
         bcs   L0B78
         sta   ,s
         ldb   $01,s
         stb   $02,y
         leax  >L0B30,pcr
         lslb  
         leax  b,x
         ldb   $01,x
         stb   $01,y
         lbsr  L0C76
         bcs   L0B78
         stb   ,y
         lda   $01,x
         lbsr  L0C7C
         bcs   L0B78
         ldx   $02,s
         std   $04,x
         ldb   ,s
         clra  
         std   $06,x
L0B78    leas  $02,s
         puls  pc,y,x
L0B7C    leas  $02,s
L0B7E    comb  
         ldb   #$BB
         rts   
L0B82    ldd   $04,x
         pshs  b,a
         cmpd  #$0004
         bhi   L0B7C
         leax  >L0B30,pcr
         lslb  
         incb  
         lda   b,x
         sta   ,s
         ldx   $06,y
         bsr   L0BAA
         bcs   L0B7C
         lda   ,s
         cmpa  $01,x
         bhi   L0B7C
         lda   $01,s
         sta   $02,x
         leas  $02,s
         bra   L0BC2
L0BAA    ldd   $06,x
         bmi   L0B7E
         beq   L0BC2
         cmpd  #$0003
         bgt   L0B7E
         bsr   L0BCA
         lda   ,x
         beq   L0B7E
         clra  
         rts   
L0BBE    bsr   L0BAA
         bcs   L0BC9
L0BC2    stb   <$37,u
         inc   <$23,u
         clrb  
L0BC9    rts   
L0BCA    pshs  b,a
         leax  <$4A,u
         lda   #$03
         mul   
         leax  b,x
         puls  pc,b,a
L0BD6    ldd   $06,x
         beq   L0B7E
         cmpd  #$0003
         bhi   L0B7E
         cmpb  <$37,u
         beq   L0B7E
         bsr   L0BCA
         beq   L0B7E
         ldb   ,x
         beq   L0B7E
         lda   $01,x
         lbsr  L0C98
         bcs   L0C06
L0BF4    lda   $01,x
         ldb   ,x
         beq   L0C06
         pshs  a
         clra  
         sta   ,x
         tfr   d,x
         puls  b
         os9   F$DelRAM 
L0C06    rts   
L0C07    cmpb  #$03
         bhi   L0C5F
         bsr   L0BCA
         ldb   ,x
         beq   L0C5F
         ldb   $02,x
         cmpb  #$04
         bhi   L0C5F
         lslb  
         pshs  x
         leax  >L0B30,pcr
         ldb   b,x
         puls  x
         stb   >$FF99
         stb   >$0099
         lda   >$0090
         anda  #$7F
         sta   >$0090
         sta   >$FF90
         lda   >$0098
         ora   #$80
         anda  #$F8
         sta   >$0098
         sta   >$FF98
         clr   >$009A
         clr   >$FF9A
         lda   ,x
         lsla  
         lsla  
         sta   >$009D
         sta   >$FF9D
         clr   >$009E
         clr   >$FF9E
         clr   >$009C
         clr   >$FF9C
         lbsr  L0104
L0C5F    rts   
L0C60    clr   ,-s
         inc   ,s
L0C64    tst   ,y
         beq   L0C72
         leay  b,y
         inc   ,s
         deca  
         bne   L0C64
         comb  
         ldb   #$CB
L0C72    puls  pc,a
L0C74    ldb   #$01
L0C76    os9   F$AlHRAM 
         rts   
L0C7A    lda   #$01
L0C7C    pshs  u,x,b,a
         bsr   L0CA9
         bcc   L0C92
         clra  
         ldb   $01,s
         tfr   d,x
         ldb   ,s
         os9   F$MapBlk 
         stb   $01,s
         tfr   u,d
         bcs   L0C96
L0C92    leas  $02,s
         puls  pc,u,x
L0C96    puls  pc,u,x,b,a
L0C98    pshs  y,x,a
         bsr   L0CA9
         bcs   L0CA7
         ldd   #$333E
L0CA1    std   ,x++
         dec   ,s
         bne   L0CA1
L0CA7    puls  pc,y,x,a
L0CA9    pshs  b,a
         lda   #$08
         sta   $01,s
         ldx   <$0050
         leax  <$50,x
         clra  
         addb  ,s
         decb  
L0CB8    cmpd  ,--x
         beq   L0CC3
         dec   $01,s
         bne   L0CB8
         bra   L0CDC
L0CC3    dec   $01,s
         dec   ,s
         beq   L0CD1
         decb  
         cmpd  ,--x
         beq   L0CC3
         bra   L0CDC
L0CD1    lda   $01,s
         lsla  
         lsla  
         lsla  
         lsla  
         lsla  
         clrb  
         leas  $02,s
         rts   
L0CDC    puls  b,a
         comb  
         ldb   #$D2
         rts   
         emod
eom      equ   *
