Date : Sat, 12 Aug 2000 00:03:48 +0100
From : James Fidell <james@...>
Subject: Re: More tape to disc transfer fun: Alien 8
Quoting Mark Usher (mu.list@...):
>
> > If I find a way to turn the BBC BASIC source into something plain ASCII,
> > I'll post it.
> There's a program BAS2TXT I had a hand in on the BBC Lives.
> http://www.nvg.ntnu.no/bbc/util/BAS2TXT.zip
>
> Should do the trick quite nicely.
A couple of mods to get it to work under Linux and the result is below.
Obviously the way I broke the decoding process was to write duplicate code,
emulating the way the VIA clocks ran down, doing the self-modification on
my code and the real code concurrently. The only particularly awkward issue
is handling the cycle-stretching that happens when the cpu reads/writes page
&FE. These days it all looks unbelievably straightforward, which is a bit
disappointing given the amount of time I put into this. Oh well :)
I haven't a clue which of the different versions of the protection
mechanism this was for, but the principle was the same for all of them.
I have disk versions of both Knight's Lore and Alien8 that I converted
from tape sitting here in my copies of my Beeb disks, so it could have been
one of those or something else entirely.
James
10clockl=&70
20clockh=&71
30latch=&72
40odd=&73
50?odd=0
60
1000FORpass=0TO3STEP3
1010P%=&3000:[ OPTpass
1020.start
1030
1040\ Set clock & latches
1050 LDA#&FF:STAclockl
1060 STAclockh:STAlatch
1070
1080\ LDX #0
1090
1100 LDX#0
1110 JSRtwo
1120
1130\ LDA &Dxx
1140
1150.incr1
1160 LDA&D00
1170 JSRfour
1180
1190\ INC &D23
1200
1210 INC&D23
1220 INCincr3+1
1230 JSRsix
1240
1250\ EOR &FE68
1260
1270 JSRfour
1280 EORclockl
1290 JSRtwo
1291 JSRzero
1300
1310\ CMP &FE69
1320
1330 JSRfour
1340 CMPclockh
1350 JSRtwo
1351 JSRzero
1360
1370\ ROL &FE68
1380
1390 PHP
1400 PHA
1410 JSRfour
1420 LDAclockl
1430 ROLA
1440 STAlatch
1450 PLA
1460 PLP
1470 JSRsix
1471 JSRzero
1480
1490\ TAY
1500
1510 TAY
1520 JSRtwo
1530
1540\ LDA &D23
1550
1560 LDA&D23
1570 JSRfour
1580
1590\ EOR &FE68
1600
1610 JSRfour
1620 EORclockl
1630 JSRtwo
1631 JSRzero
1640
1650\ STA &D1E
1660
1670 STA&D1E
1680 STAincr2+1
1690 JSRfour
1700
1710\ TYA
1720
1730 TYA
1740 JSRtwo
1750
1760\ CLC
1770
1780 CLC
1790 JSRtwo
1800
1810\ ADC #xx
1820
1830.incr2
1840 ADC#&FF
1850 JSRtwo
1860
1870\ DEC &FE69
1880
1890 JSRfour
1900 DECclockh
1910 PHP
1920 PHA
1930 LDAlatch
1940 STAclockl
1950 PLA
1960 PLP
1961 JSRzero
1970
1980\ EOR #xx
1990
2000.incr3
2010 EOR#0
2020 JSRtwo
2030
2040\ EOR &FE68
2050
2060 JSRfour
2070 EORclockl
2080 JSRtwo
2081 JSRzero
2090
2100\ EOR &FFxx
2110
2120.incr4
2130 EOR&FF80
2140 JSRfour
2150
2160\ INC &D23
2170
2180 INC&D23
2190 INCincr3+1
2200 JSRsix
2210
2220\ EOR &FE69
2230
2240 JSRfour
2250 EORclockh
2260 JSRtwo
2261 JSRzero
2270
2280\ EOR &D02,X
2290
2300 EOR&D02,X
2310 JSRfour
2320 PHP
2330 PHA
2340 CPX#&FE
2350 BCCloop1
2360 JSRone
2370.loop1
2380 PLA
2390 PLP
2400
2410\ EOR &E00,X
2420
2430 EOR&E00,X
2440 JSRfour
2450
2460\ EOR &FE68
2470
2480 JSRfour
2490 EORclockl
2500 JSRtwo
2501 JSRzero
2510
2520\ SEC
2530
2540 SEC
2550 JSRtwo
2560
2570\ ADC &D03
2580
2590 ADC&D03
2600 JSRfour
2610
2620\ LDY &FE68
2630
2640 JSRfour
2650 LDYclockl
2660 JSRtwo
2661 JSRzero
2670
2680\ STY &FE69
2690
2700 STYclockh
2710 PHP
2720 PHA
2730 LDAlatch
2740 STAclockl
2750 PLA
2760 PLP
2761 JSRzero
2770
2780\ EOR &xxxx
2790
2800.incr5
2810 EOR&C400
2820 JSRfour
2830
2840\ EOR &FE68
2850
2860 JSRfour
2870 EORclockl
2880 JSRtwo
2881 JSRzero
2890
2900\ CLC
2910
2920 CLC
2930 JSRtwo
2940
2950\ ADC &E01,X
2960
2970 ADC&E01,X
2980 JSRfour
2990 PHP
3000 PHA
3010 CPX#&FF
3020 BNEloop2
3030 JSRone
3040.loop2
3050 PLA
3060 PLP
3070
3080\ INC &D1E
3090
3100 INC&D1E
3110 INCincr2+1
3120 JSRsix
3130
3140\ TAY
3150
3160 TAY
3170 JSRtwo
3180
3190\ LDA &D1E
3200
3210 LDA&D1E
3220 JSRfour
3230
3240\ EOR &FE68
3250
3260 JSRfour
3270 EORclockl
3280 JSRtwo
3281 JSRzero
3290
3300\ STA &D1E
3310
3320 STA&D1E
3330 STAincr2+1
3340 JSRfour
3350
3360\ TYA
3370
3380 TYA
3390 JSRtwo
3400
3410\ EOR &FE69
3420
3430 JSRfour
3440 EORclockh
3450 JSRtwo
3451 JSRzero
3460
3470\ EOR &FE68
3480
3490 JSRfour
3500 EORclockl
3510 JSRtwo
3511 JSRzero
3520
3530\ STA &E00,X
3540
3550 STA&E00,X
3560 STA&4E00,X
3570 JSRfive
3580
3590\ INC &D44
3600
3610 INC&D44
3620 INCincr5+1
3630 JSRsix
3640
3650\ INX
3660
3670 INX
3680 JSRtwo
3690
3700\ BNE &D02
3710
3720 PHP
3730 PHA
3740 BEQloop3
3750 JSRone
3760.loop3
3770 JSRtwo
3780 PLA
3790 PLP
3800 BEQloop4
3810 JMPincr1
3820.loop4
3830
3840\ INC &D45
3850
3860 INC&D45
3870 INCincr5+2
3880 JSRsix
3890
3900\ LDA &D45
3910
3920 LDA&D45
3930 JSRfour
3940
3950\ CMP #E3
3960
3970 CMP#&E3
3980 JSRtwo
3990
4000\ BCC &D79
4010
4020 PHP
4030 PHA
4040 BCSloop5
4050 JSRone
4060.loop5
4070 JSRtwo
4080 PLA
4090 PLP
4100 BCCloop6
4110
4120\ LDA #C4
4130
4140 LDA#&C4
4150 JSRtwo
4160
4170\ STA &D45
4180
4190 STA&D45
4200 STAincr5+2
4210 JSRfour
4220
4230\ LDA #3
4240
4250.loop6
4260 JSRtwo
4270
4280\ STA &258
4290
4300 JSRfour
4310
4320\ LDA#4C
4330
4340 JSRtwo
4350
4360\ STA &287
4370
4380 JSRfour
4390
4400\ LDA #87
4410
4420 JSRtwo
4430
4440\ STA &288
4450
4460 JSRfour
4470
4480\ LDA #2
4490
4500 JSRtwo
4510
4520\ STA &289
4530
4540 JSRfour
4550
4560\ LDY #35
4570
4580 LDY#&35
4590 JSRtwo
4600
4610\ LDA &D940,Y
4620
4630.loop8
4640 JSRfour
4650
4660\ STA &200,Y
4670
4680 JSRfive
4690
4700\ DEY
4710
4720 DEY
4730 JSRtwo
4740
4750\ BPL &D8F
4760
4770 PHP
4780 PHA
4790 BMIloop7
4800 JSRone
4810.loop7
4820 JSRtwo
4830 PLA
4840 PLP
4850 BPLloop8
4860
4870\ LDA &D23
4880
4890 LDA&D23
4900 JSRfour
4910
4920\ EOR &FE68
4930
4940 JSRfour
4950 EORclockl
4960 JSRtwo
4961 JSRzero
4970
4980\ STA &D23
4990
5000 STA&D23
5010 STAincr3+1
5020 JSRfour
5030
5040\ INC &D28
5050
5060 INC&D28
5070 INCincr4+1
5080 JSRsix
5090
5100\ INC &D23
5110
5120 INC&D23
5130 INCincr3+1
5140 JSRsix
5150
5160\ INC &D03
5170
5180 INC&D03
5190 INCincr1+1
5200 JSRsix
5210
5220\ LDA &D03
5230
5240 LDA&D03
5250 JSRfour
5260 TAY:STA&7C00,Y
5270
5280\ CMP #0
5290
5300 CMP#0
5310 JSRtwo
5320
5330\ BEQ &DB4
5340
5350 JSRtwo
5360 BEQfinish
5370
5380\ JMP &D02
5390
5400 JSRthree
5410 JMPincr1
5420
5430.finish
5440 RTS
5450
5460.one
5470 PHP
5480 PHA
5490 INCodd
5500 LDAodd
5510 CMP#2
5520 BNEloopA
5530 JSRzero
5550 JSRtwo
5560.loopA
5570 PLA
5580 PLP
5590 RTS
5600
5610.two
5620 PHP
5630 PHA
5640 SEC
5650 LDAclockl
5660 SBC#1
5670 STAclockl
5680 LDAclockh
5690 SBC#0
5700 STAclockh
5710 PLA
5720 PLP
5730 RTS
5740
5750.three
5760 JSRone
5770 JSRtwo
5780 RTS
5790
5800.four
5810 JSRtwo
5820 JSRtwo
5830 RTS
5840
5850.five
5860 JSRfour
5870 JSRone
5880 RTS
5890
5900.six
5910 JSRfour
5920 JSRtwo
5930 RTS
5940
5950.ten
5960 JSRfive
5970 JSRfive
5980 RTS
5990
5991.zero
5992 PHP
5993 PHA
5994 LDA#0
5995 STAodd
5996 PLA
5997 PLP
5998 RTS
5999
6000]:NEXT
--
"Yield to temptation -- | Consultancy: james@...
it may not pass your way again" | http://www.cloud9.co.uk/james
|
- Lazarus Long | James Fidell