-
Notifications
You must be signed in to change notification settings - Fork 47
/
elite-loader.asm
1567 lines (1291 loc) · 32.2 KB
/
elite-loader.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\ *****************************************************************************
\* Source Code for ELITE (the loader)
\ *****************************************************************************
DISC = TRUE ; load above DFS and relocate down
PROT = FALSE ; TAPE protection
_REMOVE_CHECKSUMS = TRUE
HIMEM=&4000
;DIMTEMP%256
LOD%=&1100 ; load address of ELTcode (elite-bcfs.asm)
C%=&F40 ; assembly address of Elite game code (elite-source.asm)
S%=C%
L%=LOD%+&28 ; load address Elite game code (elite-bcfs.asm)
D%=&563A ; hardcoded size of Elite game code (elite-source.asm)
LC%=&6000-C% ; maximum size of Elite game code
svn=&7FFD
len1=15
len2=18
len=len1+len2
LE%=&B00 ; address of second stage loader (containing ENTRY2)
;REM Move Mover to here while CODE loading
IF DISC
LL%=&E00+&300 ; load address of loader
ELSE
LL%=&E00
ENDIF
;CODE=&4000
CODE=LL% ; we can assemble in place
;REM Where this loader loads
\ *****************************************************************************
\ MOS definitions
\ *****************************************************************************
MOS=S%+8 ; unused - was part of OS version test
TRTB%=4 ; MOS key translation table
NETV=&224
OSWRCH=&FFEE
OSBYTE=&FFF4
OSWORD=&FFF1
SCLI=&FFF7
IRQ1V=&204
osprnt=&234
\ *****************************************************************************
\ ZERO PAGE variables
\ *****************************************************************************
ZP=&70
P=&72
Q=&73
YY=&74
T=&75
sc=&76
BLPTR=&78
V219=&7A
K3=&80
BLCNT=&81
BLN=&83
EXCN=&85
FF=&FF
\ *****************************************************************************
\ SYSVIA definitions
\ *****************************************************************************
VIA=&FE40
USVIA=VIA
VSCAN=57-1
VEC=&7FFE
\ *****************************************************************************
\ Concatenate data files used by loader
\ *****************************************************************************
;OSCLI("L.:0.WORDS9 "+STR$~CODE)
ORG CODE
PRINT "WORDS9=",~P%
INCBIN "data/WORDS9.bin"
;OSCLI("L.:0.DIALSHP "+STR$~(CODE+&400))
ORG CODE+&400
PRINT "DIALSHP=",~P%
INCBIN "data/DIALSHP.bin"
;OSCLI("L.:2.P.ELITE "+STR$~(CODE+&C00))
ORG CODE+&C00
PRINT "P.ELITE=",~P%
INCBIN "data/P.ELITE.bin"
;OSCLI("L.:2.P.A-SOFT "+STR$~(CODE+&D00))
ORG CODE+&D00
PRINT "P.A-SOFT=",~P%
INCBIN "data/P.A-SOFT.bin"
;OSCLI("L.:2.P.(C)ASFT "+STR$~(CODE+&E00))
ORG CODE+&E00
PRINT "P.(C)ASFT=",~P%
INCBIN "data/P.(C)ASFT.bin"
;REMOSCLI("L.:2.P.NAME$ "+STR$~(CODE+&E00))
ORG LL%+&400+&800+&300
O%=CODE+&400+&800+&300
\ *****************************************************************************
\ LOADER CODE START
\ *****************************************************************************
.run
JMP ENTRY
\ *****************************************************************************
\ VDU command data
\ *****************************************************************************
B%=P%
N%=67 ; DATA 67:READ N%
EQUB 22,4,28,2,17,15,16
EQUB 23,0, 6,31,0,0,0,0,0,0
EQUB 23,0,12,12,0,0,0,0,0,0
EQUB 23,0,13, 0,0,0,0,0,0,0
EQUB 23,0, 1,32,0,0,0,0,0,0
EQUB 23,0, 2,45,0,0,0,0,0,0
EQUB 23,0,10,32,0,0,0,0,0,0
\ *****************************************************************************
\ Sound envelope data
\ *****************************************************************************
E%=P%
EQUB 1,1,0,111,-8,4,1,8, 8,-2,0,-1,112,44
EQUB 2,1,14,-18,-1,44,32,50, 6,1,0,-2,120,126
EQUB 3,1,1,-1,-3,17,32,128,1,0,0,-1,1,1
EQUB 4,1,4,-8,44,4,6,8,22,0,0,-127,126,0
MACRO FNE I%
LDX #((E%+I%*14)MOD256)
LDY #((E%+I%*14)DIV256)
LDA #8
JSR OSWORD
ENDMACRO
\ *****************************************************************************
\ Machine reset
\ *****************************************************************************
.swine
LDA #&7F
STA &FE4E
JMP (&FFFC)
\ This bit runs where it loads
\ *****************************************************************************
\ OSBYTE call with Y=0
\ *****************************************************************************
.OSB
LDY #0
JMP OSBYTE
EQUS "R.ELITEcode"
EQUB 13
EQUS "By D.Braben/I.Bell"
EQUB 13
EQUB &B0
\ *****************************************************************************
\ Addresses of various functions used by loader to obfuscate
\ *****************************************************************************
.oscliv
EQUW &FFF7
.David9
EQUW David5 ; used to direct decyrypt fn in stack to end of loop
CLD
.David23
EQUW (512-len) ; start of DOMOVE fn pushed onto stack (&1DF)
\ *****************************************************************************
\ Set up PROT1 fn to work correctly and set V219 to OSBPUT vector address
\ *****************************************************************************
.doPROT1 ; enters with A=&48;X=255
LDY#&DB
STY TRTB%
LDY #&EF \0.1 look-up keys
STY TRTB%+1
LDY #2
STY V219+1
STA PROT1-255,X ; self-mod PHA -> PROT1
LDY #&18
STY V219+1,X ; set V219 to &0218
RTS
.MHCA
EQUB &CA
.David7
BCC Ian1
\ *****************************************************************************
\ Boot code
\ *****************************************************************************
.ENTRY
SEI
CLD
\ *****************************************************************************
\ TAPE protection
\ *****************************************************************************
IF DISC=FALSE
LDA #0
LDX #FF
JSR OSBYTE
TXA
BEQ OS100
LDY &FFB6
LDA &FFB7
STA ZP
LDA &FFB8
STA ZP+1
DEY
.ABCDEFG
LDA (ZP),Y
STA &200,Y
DEY
BPL ABCDEFG
.OS100
ENDIF
\ *****************************************************************************
\ Disable all interupts
\ *****************************************************************************
LDA #&7F
STA &FE4E
STA &FE6E
\ *****************************************************************************
\ Set USERV, BRKV, IRQ2V and EVENTV to point to machine reset (&FFFC)
\ *****************************************************************************
LDA &FFFC
STA &200
STA &202
STA &206
STA &220
LDA &FFFD
STA &201
STA &203
STA &207
STA &221 \ Cold reset (Power on) on BRK,USER,& unrecog IRQ
\ *****************************************************************************
\ Ensure all vectors are pointing into MOS (&C000 and upwards)
\ *****************************************************************************
LDX #&2F-2
.purge
LDA &202,X
ORA #&C0
STA &202,X
DEX
DEX
BPL purge
\ *****************************************************************************
\ Make NETV an RTS
\ *****************************************************************************
LDA #&60
STA &232
LDA #2
STA NETV+1
LDA #&32
STA NETV \Knock out NETVEC
\ *****************************************************************************
\ Poke JSR into David2 fn and set ADC to sample 2 channels
\ *****************************************************************************
LDA #32 ; JSR absolute
EQUB &2C ; BIT absolute (skip next 2 bytes)
.Ian1
BNE David3
STA David2 ; self-mod code -> JSR at David2
LSR A
LDX #3
STX BLPTR+1
STX BLN+1
STX EXCN+1
DEX
JSR OSBYTE \ADC
EQUB &2C ; BIT absolute (skip next 2 bytes)
.FRED1
BNE David7
\ *****************************************************************************
\ Poke PHA into PROT1 fn
\ *****************************************************************************
LDX #255
LDA #&48
JSR doPROT1
\ *****************************************************************************
\ Issue *TV 255,0 command (via OSBYTE 144)
\ *****************************************************************************
LDA #144
JSR OSB \TV
\ *****************************************************************************
\ Remove BREAK intercept (via OSBYTE 247)
\ *****************************************************************************
LDA #247
LDX #0
JSR OSB \BREAK vec
\LDA#&81\LDY#FF\LDX#1\JSROSBYTE\TXA\BPLOS01 \Damn 0.1
\ *****************************************************************************
\ Set ADC to 8-bit conversion (via OSBYTE 190)
\ *****************************************************************************
LDA #190
LDX #8
JSR OSB \8bitADC
EQUB &2C ; BIT absolute (skip next 2 bytes)
.David8
BNE FRED1
\ *****************************************************************************
\ Issue paged ROM service call (via OSBYTE &8F)
\ *****************************************************************************
LDA #&8F
LDX #&C
LDY #FF
JSR OSBYTE \ claim NMIs
\ *****************************************************************************
\ Disable output buffer empty event (via OSBYTE 13)
\ *****************************************************************************
LDA #13
.abrk
LDX #0
JSR OSB \otput bffer
\ *****************************************************************************
\ Set character status flag (via OSBYTE 225)
\ *****************************************************************************
LDA #225
LDX #128
JSR OSB \fn keys
\ *****************************************************************************
\ Get address of MOS key translation table (via OSBYTE 172)
\ *****************************************************************************
LDA #172
LDX #0
LDY #255
JSR OSBYTE
STX TRTB%
STY TRTB%+1 \int-ascii table
\ *****************************************************************************
\ Disable ESCAPE, memory cleared on BREAK (via OSBYTE 200)
\ *****************************************************************************
LDA #200
LDX #3
JSR OSB
IF PROT AND DISC=0
CPX #3
BNE abrk+1 \Clear memory on BREAK
ENDIF
\ *****************************************************************************
\ Disable character entering keyboard buffer event (via OSBYTE 13)
\ *****************************************************************************
LDA #13
LDX #2
JSR OSB \kybrd buffer
\ *****************************************************************************
\ Reset stack
\ *****************************************************************************
.OS01
LDX #FF
TXS
INX
\ *****************************************************************************
\ Push 33 bytes from BEGIN% onto the stack
\ NB. loops by indirecting through 5 branches!
\ *****************************************************************************
.David3
LDA BEGIN%,X
.PROT1
INY \PHA
INX
CPX #len
BNE David8 \^stack
\ *****************************************************************************
\ Issue 67 VDU commands to set up square MODE4 screen at &6000
\ *****************************************************************************
LDA #(B% MOD256)
STA ZP
LDA #&C8 ; self-mod INY -> PROT1
STA PROT1
LDA #(B% DIV256)
STA ZP+1
LDY #0
.LOOP
LDA (ZP),Y
JSR OSWRCH
INY
CPY #N%
BNE LOOP \set up pokey-mode-4
\ *****************************************************************************
\ Disable cursor editing, keys give ASCII values (via OSBYTE 4)
\ *****************************************************************************
LDA #1
TAX
TAY
STA (V219),Y
LDA #4
JSR OSB \cursor
\ *****************************************************************************
\ Disable flashing colours (via OSBYTE 9)
\ *****************************************************************************
LDA #9
LDX #0
JSR OSB \flashing
\ *****************************************************************************
\ Poke JSR indirect into crunchit fn
\ *****************************************************************************
LDA #&6C ; JMP indirect
EOR crunchit
STA crunchit
\ *****************************************************************************
\ Define 4x sound envelopes (via OSWORD 8)
\ *****************************************************************************
FNE 0
FNE 1
FNE 2
FNE 3 \envelopes
\ *****************************************************************************
\ Move & decrypt WORDS9 to language workspace (4x pages from &1100 to &0400)
\ *****************************************************************************
LDX #4
STX P+1
LDA #(LL%DIV256)
STA ZP+1
LDY #0
LDA #256-len1
STA (V219-4,X)
STY ZP
STY P
JSR crunchit \Move WORDS9 to &400
\ *****************************************************************************
\ Move & decypt P.ELITE to screen (1x pages from &1D00 to &6300)
\ *****************************************************************************
LDX #1
LDA #((LL%DIV256)+&C)
STA ZP+1
LDA #&63
STA P+1
LDY #0
JSR crunchit
\ *****************************************************************************
\ Move & decypt P.A-SOFT to screen (1x pages from &1E00 to &6100)
\ *****************************************************************************
LDX #1
LDA #((LL%DIV256)+&D)
STA ZP+1
LDA #&61
STA P+1
LDY #0
JSR crunchit
\ *****************************************************************************
\ Move & decypt P.A-SOFT to screen (1x pages from &1F00 to &7600)
\ *****************************************************************************
LDX #1
LDA #((LL%DIV256)+&E)
STA ZP+1
LDA #&76
STA P+1
LDY #0
JSR crunchit
\ *****************************************************************************
\ Draw Saturn
\ *****************************************************************************
JSR PLL1 \draw Saturn
\ *****************************************************************************
\ Move & decypt DIALSHP to screen (1x pages from &1500 to &7800)
\ *****************************************************************************
LDX #8
LDA #((LL%DIV256)+4)
STA ZP+1
LDA #&78
STA P+1
LDY #0
STY ZP
STY BLCNT
STY P
JSR crunchit \Move DIALSHP to &7800
\ *****************************************************************************
\ Move & decypt 2x pages of code from UU% down to &0B00
\ *****************************************************************************
LDX #(3-(DISC AND1))
LDA #(UU%DIV256)
STA ZP+1
LDA #(UU%MOD256)
STA ZP
LDA #(LE%DIV256)
STA P+1
LDY #0
STY P
JSR crunchit \Move Part of this program to LE%
\ *****************************************************************************
\ Poke BRK into OS01 fn and call OSBPUT with file handle Y=0...
\ By now the address &01F1 has been sneakily placed into BPUTV (&218)
\ So this call to OSBPUT actually calls the second function placed in stack
\ *****************************************************************************
STY David3-2
\LDY#0
.David2
EQUB &AC ; self moded to JSR &FFD4
EQUW &FFD4 \JSR&FFD4
\ *****************************************************************************
\ Code should never reach here if decryption is successful!!
\ *****************************************************************************
.LBLa
LDA C%,X
EOR #&A5
STA C%,X
DEX
BNE LBLa
JMP (C%+&CF)
.swine2
JMP swine
EQUW &4CFF
\ *****************************************************************************
\ Call DOMOVE fn but inside the stack
\ *****************************************************************************
.crunchit
BRK ; JSR (David23)
EQUW David23
.RAND
EQUD &6C785349
\ *****************************************************************************
\ End of our decrypt fn inside the stack
\ *****************************************************************************
.David5
INY
CPY #(ENDBLOCK-BLOCK)
BNE David2
\ *****************************************************************************
\ Enable interupts and set IRQ1V to IRQ1 fn
\ *****************************************************************************
SEI
LDA #&C2
STA VIA+&E
LDA #&7F
STA &FE6E
LDA IRQ1V
STA VEC
LDA IRQ1V+1
BPL swine2
STA VEC+1
LDA #(IRQ1 DIV256)
STA IRQ1V+1
LDA #(IRQ1 MOD256)
STA IRQ1V
LDA #VSCAN
STA USVIA+5
CLI \ INTERRUPTS NOW OK
\ *****************************************************************************
\ Read key with time limit (via OSBYTE &81)
\ *****************************************************************************
IF DISC
LDA #&81
STA &FE4E
LDY #20
IF _REMOVE_CHECKSUMS
NOP:NOP:NOP
ELSE
JSR OSBYTE
ENDIF
LDA #1
STA &FE4E
ENDIF
\ *****************************************************************************
\ ENTRY2 already pushed onto stack at start of BLOCK code
\ *****************************************************************************
RTS \ENTRY2 on stack already
\ *****************************************************************************
\ Draw Saturn
\ *****************************************************************************
.PLL1
{
LDA VIA+4
STA RAND+1
JSR DORND
JSR SQUA2
STA ZP+1
LDA P
STA ZP
JSR DORND
STA YY
JSR SQUA2
TAX
LDA P
ADC ZP
STA ZP
TXA
ADC ZP+1
BCS PLC1
STA ZP+1
LDA #1
SBC ZP
STA ZP
LDA #&40
SBC ZP+1
STA ZP+1
BCC PLC1
JSR ROOT
LDA ZP
LSR A
TAX
LDA YY
CMP #128
ROR A
JSR PIX
.PLC1
DEC CNT
BNE PLL1
DEC CNT+1
BNE PLL1
LDX #&C2
STX EXCN
.PLL2
JSR DORND
TAX
JSR SQUA2
STA ZP+1
JSR DORND
STA YY
JSR SQUA2
ADC ZP+1
CMP #&11
BCC PLC2
LDA YY
JSR PIX
.PLC2
DEC CNT2
BNE PLL2
DEC CNT2+1
BNE PLL2
LDX MHCA
STX BLPTR
LDX #&C6
STX BLN
.PLL3
JSR DORND
STA ZP
JSR SQUA2
STA ZP+1
JSR DORND
STA YY
JSR SQUA2
STA T
ADC ZP+1
STA ZP+1
LDA ZP
CMP #128
ROR A
CMP #128
ROR A
ADC YY
TAX
JSR SQUA2
TAY
ADC ZP+1
BCS PLC3
CMP #&50
BCS PLC3
CMP #&20
BCC PLC3
TYA
ADC T
CMP #&10
BCS PL1
LDA ZP
BPL PLC3
.PL1
LDA YY
JSR PIX
.PLC3
DEC CNT3
BNE PLL3
DEC CNT3+1
BNE PLL3
.DORND
LDA RAND+1
TAX
ADC RAND+3
STA RAND+1
STX RAND+3
LDA RAND
TAX
ADC RAND+2
STA RAND
STX RAND+2
RTS
.SQUA2
BPL SQUA
EOR #FF
CLC
ADC #1
.SQUA
STA Q
STA P
LDA #0
LDY #8
LSR P
.SQL1
BCC SQ1
CLC
ADC Q
.SQ1
ROR A
ROR P
DEY
BNE SQL1
RTS
.PIX
TAY
EOR #128
LSR A
LSR A
LSR A
ORA #&60
STA ZP+1
TXA
EOR #128
AND #&F8
STA ZP
TYA
AND #7
TAY
TXA
AND #7
TAX
LDA TWOS,X
ORA (ZP),Y
STA (ZP),Y
RTS
.TWOS
EQUD &10204080
EQUD &01020408
.CNT
EQUW &500
.CNT2
EQUW &1DD
.CNT3
EQUW &500
.ROOT
LDY ZP+1
LDA ZP
STA Q
LDX #0
STX ZP
LDA #8
STA P
.LL6
CPX ZP
BCC LL7
BNE LL8
CPY #&40
BCC LL7
.LL8
TYA
SBC #&40
TAY
TXA
SBC ZP
TAX
.LL7
ROL ZP
ASL Q
TYA
ROL A
TAY
TXA
ROL A
TAX
ASL Q
TYA
ROL A
TAY
TXA
ROL A
TAX
DEC P
BNE LL6
RTS
}
\ *****************************************************************************
\ Copy BLOCK fn to stack and decrypt TUT fn
\ *****************************************************************************
.BEGIN%
EQUB (David9 DIV256)
EQUB (David9 MOD256)
EQUB &6C \JMP
EQUB (TUT DIV256)
EQUB (TUT MOD256)
EQUB &99 \STA,Y
EQUB (TUT DIV256)
EQUB (TUT MOD256)
IF _REMOVE_CHECKSUMS
EQUB &B9 \LDA,Y
ELSE
EQUB &59 \EOR,Y
ENDIF
PHA
EQUB ((BLOCK)DIV256)
EQUB ((BLOCK)MOD256)
EQUB &B9 \LDA,Y
PLA
PLA
\ *****************************************************************************
\ Copy BLOCK fn to stack and decrypt TUT fn
\
\ 01F1 : PLA
\ 01F2 : PLA
\ 01F3 : LDA 0C7C,Y ; BLOCK
\ 01F6 : PHA
\ 01F7 : EOR 0BAD,Y ; TUT
\ 01FA : STA 0BAD,Y
\ 01FD : JMP (20AD)
\
\ *****************************************************************************
\ *****************************************************************************
\ Move memory fn with EOR against loader code from OSB onwards
\ *****************************************************************************
.DOMOVE
RTS
EQUW &D0EF \BNEMVDL
DEX
EQUB ZP+1
INC P+1
EQUB &E6 \INCP+1 INCZP+1
EQUW &D0F6 \BNEMVDL
DEY
EQUB P
EQUB &91 \STA(),Y
IF _REMOVE_CHECKSUMS
NOP:NOP:NOP
ELSE
EQUB (OSB DIV256)
EQUB (OSB MOD256)
EQUB &59 \EOR
ENDIF
EQUB ZP
EQUB &B1 \LDA(),Y \ 18 Bytes ^ Stack
\ *****************************************************************************
\ DOMOVE fn as running on the stack
\
\ 01DF : LDA (70),Y
\ 01E1 : EOR 2086,Y
\ 01E4 : STA (72),Y
\ 01E6 : DEY
\ 01E7 : BNE 01DF
\ 01E9 : INC 73
\ 01EB : INC 71
\ 01ED : DEX
\ 01EE : BNE 01DF
\ 01F0 : RTS
\
\ *****************************************************************************
\ *****************************************************************************
\ This code all located at &B00
\ *****************************************************************************
.UU%
Q%=P%-LE%
ORG LE% ;P%=LE%
.CHECKbyt
BRK ; CHECKbyt checksum value calcuated in elite-checksum.py
.MAINSUM