-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeneratedCode_DecompiledAsm.cs
1895 lines (1847 loc) · 61.2 KB
/
GeneratedCode_DecompiledAsm.cs
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
using Spice86.Core.CLI;
using Spice86.Core.Emulator.CPU;
using Spice86.Shared.Emulator.Memory;
using Spice86.Shared.Interfaces;
namespace logo;
/// <summary>
/// This is the output from Jetbrains Dotpeek, which took a logo.dll assembly compiled with ReadyToRun (-p:PublishReadyToRun=true)
/// which is a form of AOT compilation done by the .NET Compiler (Roslyn)
/// The re-formed C# code from the Intermediate Language (MSIL) is below.
/// This has replaced a lot of goto ridden code with loops.
/// This is an optional step in a rewrite of "C# ASM" to high level code, but it helps a lot.
/// </summary>
public class GeneratedOverrides_DecompiledAsm : CSharpOverrideHelper
{
private const ushort CrtRegisterOffset_6C = 0x6C;
private const ushort CrtRegisterIsFunctionalFlagOffset_6E = 0x6E;
private const ushort CrtRegisterLastObservedValueOffset_6F = 0x6F;
private const ushort NumberOfFramesRemainingOffset_CB6 = 0xCB6;
protected ushort cs1; // 0x1000
protected ushort cs2; // 0xF000
public GeneratedOverrides_DecompiledAsm(Dictionary<SegmentedAddress, FunctionInformation> functionInformations, Machine machine, ILoggerService loggerService, Configuration configuration, ushort entrySegment = 0x1000) : base(functionInformations, machine, loggerService, configuration)
{
// Observed cs1 address at generation time is 0x1000. Do not set entrySegment to something else if the program is not relocatable.
cs1 = (ushort)(entrySegment + 0x0);
cs2 = (ushort)(entrySegment + 0xE000);
DefineGeneratedCodeOverrides();
DetectCodeRewrites();
SetProvidedInterruptHandlersAsOverridden();
}
public Dictionary<SegmentedAddress, FunctionInformation> FunctionInformations => _functionInformations;
public void DefineGeneratedCodeOverrides()
{
// 0x1000
DefineFunction(cs1, 0x0, EntryPoint_OpenLogoHnmFileAndRun_1000_0000_10000, false);
DefineFunction(cs1, 0x970, SetVideoMode_1000_0970_10970, false);
DefineFunction(cs1, 0x9B5, CheckCrtRegisterForChange_1000_09B5_109B5, false);
DefineFunction(cs1, 0x9D8, CommonCirclesWaitFrameAndWriteNextPaletteData_1000_09D8_109D8, false);
DefineFunction(cs1, 0xA22, ConvertLineNumberToArrayIndex_1000_0A22_10A22, false);
DefineFunction(cs1, 0xA3A, Nop_1000_0A3A_10A3A, false);
DefineFunction(cs1, 0xA51, Nop_1000_0A51_10A51, false);
DefineFunction(cs1, 0xB9A, CommonUnknown_1000_0B9A_10B9A, false);
DefineFunction(cs1, 0xC72, CirclesUnknown_display_1000_0C72_10C72, false);
DefineFunction(cs1, 0xCF4, CircleMainLoop_1000_0CF4_10CF4, false);
DefineFunction(cs1, 0xD22, CirclesDrawStep_1000_0D22_10D22, false);
DefineFunction(cs1, 0xD5F, CommonComputeNextVgaPalette_1000_0D5F_10D5F, false);
DefineFunction(cs1, 0xDBC, CirclesUnknown_1000_0DBC_10DBC, false);
DefineFunction(cs1, 0xDDE, CirclesAnimation_1000_0DDE_10DDE, false);
DefineFunction(cs1, 0xE46, HNMUnknown_1000_0E46_10E46, false);
DefineFunction(cs1, 0xE49, CommonUnknown_1000_0E49_10E49, false);
DefineFunction(cs1, 0xE4C, CommonUnknown_1000_0E4C_10E4C, false);
DefineFunction(cs1, 0xE59, CommonUnknown_display_1000_0E59_10E59, false);
DefineFunction(cs1, 0xE86, UpdatePaletteDataAddress_1000_0E86_10E86, false);
DefineFunction(cs1, 0xEAD, CommonUnknown_1000_0EAD_10EAD, false);
DefineFunction(cs1, 0xEB2, split_1000_0EB2_10EB2, false);
DefineFunction(cs1, 0xEBD, CommonUnknown_1000_0EBD_10EBD, false);
DefineFunction(cs1, 0xEFE, CommonUnknown_1000_0EFE_10EFE, false);
DefineFunction(cs1, 0xF30, CommonUnknownSplit_1000_0F30_10F30, false);
DefineFunction(cs1, 0xFA4, CirclesChangeVgaPaletteLoop_1000_0FA4_10FA4, false);
DefineFunction(cs1, 0xFCC, nop_1000_0FCC_10FCC, false);
DefineFunction(cs1, 0xFEA, HNMUnknown_1000_0FEA_10FEA, false);
DefineFunction(cs1, 0x1019, CirclesUnknown_1000_1019_11019, false);
DefineFunction(cs1, 0x105F, CirclesUnknown_1000_105F_1105F, false);
DefineFunction(cs1, 0x1085, CommonCheckForAnyKeyStroke_1000_1085_11085, false);
DefineFunction(cs1, 0x109A, HNMReadFile_AdvancePointer_CloseFile_1000_109A_1109A, false);
DefineFunction(cs1, 0x10F4, Nop_1000_10F4_110F4, false);
DefineFunction(cs1, 0x11BD, Nop_1000_11BD_111BD, false);
}
public void DetectCodeRewrites()
{
DefineExecutableArea(0x10000, 0x10090);
DefineExecutableArea(0x10970, 0x10CAF);
DefineExecutableArea(0x10CF4, 0x10ED4);
DefineExecutableArea(0x10EFE, 0x10F07);
DefineExecutableArea(0x10F30, 0x1103A);
DefineExecutableArea(0x1105F, 0x1106E);
DefineExecutableArea(0x11085, 0x11091);
DefineExecutableArea(0x1109A, 0x110C1);
DefineExecutableArea(0x110F4, 0x111C7);
DefineExecutableArea(0xF0008, 0xF000B);
DefineExecutableArea(0xF0014, 0xF0017);
DefineExecutableArea(0xF0020, 0xF0023);
}
/// <summary>
/// First pass rewrite done by the .NET Roslyn compiler (ReadyToRun pre-compilation)
/// </summary>
public virtual Action EntryPoint_OpenLogoHnmFileAndRun_1000_0000_10000(int loadOffset)
{
AX = 0x111C;
DS = AX;
AX = UInt16[ES, 2];
UInt16[DS, 0x50] = AX;
BX = 8;
NearCall(cs1, 0x12, Nop_1000_10F4_110F4);
AX = 0xC;
SI = 0x8E;
int num1 = Alu8.Sub(UInt8[DS, SI], 0);
int num2 = ZeroFlag ? 1 : 0;
UInt16[DS, 0x52] = AX;
DX = 0x5A;
NearCall(cs1, 0x2C, CirclesUnknown_1000_105F_1105F);
int num3 = Alu8.Sub(UInt8[DS, DI], 46);
if (!ZeroFlag)
{
UInt16[DS, DI] = 0x482E;
UInt16[DS, (ushort)(DI + 2U)] = 0x4D4E;
UInt8[DS, (ushort)(DI + 4U)] = 0;
}
AX = 0x3D00;
Interrupt(0x21);
DX = 0x2E;
if (!CarryFlag)
{
Stack.Push16(AX);
NearCall(cs1, 0x4C, SetVideoMode_1000_0970_10970);
NearCall(cs1, 0x4F, CirclesUnknown_1000_1019_11019);
BX = Stack.Pop16();
AX = UInt16[DS, 0x52];
NearCall(cs1, 0x56, CirclesAnimation_1000_0DDE_10DDE);
NearCall(cs1, 0x59, Nop_1000_0A51_10A51);
DX = 0;
AL = 0;
AH = 0x4C;
Interrupt(0x21);
}
AH = 0x9;
Interrupt(0x21);
AL = 0;
AH = 0x4C;
Interrupt(0x21);
CheckExternalEvents(cs1, 0x6D);
if (OverflowFlag)
throw FailAsUntested("Would have been a goto but label label_1000_0047_10047 does not exist because no instruction was found there that belongs to a function.");
DI += DI;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] += AL;
UInt8[DS, (ushort)(BX + SI)] = Alu8.Add(UInt8[DS, (ushort)(BX + SI)], AL);
throw FailAsUntested("Function does not end with return and no instruction after the body ...");
}
/// <summary>
/// First pass rewrite done by the .NET Roslyn compiler (ReadyToRun pre-compilation)
/// </summary>
public virtual Action SetVideoMode_1000_0970_10970(int loadOffset)
{
AX = 0x13;
Interrupt(0x10);
Stack.Push16(FlagRegister16);
InterruptFlag = true;
// Read CRT register from BDA
AX = 0x40;
ES = AX;
DX = UInt16[ES, 0x63];
DL = Alu8.Add(DL, 6);
// CRT register
UInt16[cs1, CrtRegisterOffset_6C] = DX;
BP = CrtRegisterOffset_6C;
CheckExternalEvents(cs1, 0x98C);
AL = Cpu.In8(DX);
AL = Alu8.And(AL, 8);
NearCall(cs1, 0x992, CheckCrtRegisterForChange_1000_09B5_109B5);
if (CarryFlag)
{
NearCall(cs1, 0x997, CheckCrtRegisterForChange_1000_09B5_109B5);
if (CarryFlag)
{
DI = SI;
UInt8[cs1, CrtRegisterLastObservedValueOffset_6F] = AH;
NearCall(cs1, 0x9A3, CheckCrtRegisterForChange_1000_09B5_109B5);
if (CarryFlag)
{
int num = Alu16.Sub(SI, DI);
UInt8[cs1, CrtRegisterIsFunctionalFlagOffset_6E] = (byte)~UInt8[cs1, CrtRegisterIsFunctionalFlagOffset_6E];
if (CarryFlag)
{
UInt8[cs1, CrtRegisterLastObservedValueOffset_6F] = AH;
}
}
}
}
FlagRegister16 = Stack.Pop16();
return NearRet();
}
/// <summary>
/// First pass rewrite done by the .NET Roslyn compiler (ReadyToRun pre-compilation)
/// </summary>
public virtual Action CheckCrtRegisterForChange_1000_09B5_109B5(int loadOffset)
{
// Initial state of CRT register in AH
// MOV AH,AL (1000_09B5 / 0x109B5)
AH = AL;
// XOR SI,SI (1000_09B7 / 0x109B7)
SI = 0;
// MOV BX,word ptr ES:[BP + 0x0] (1000_09B9 / 0x109B9)
BX = UInt16[ES, BP];
do
{
// INC SI (1000_09BD / 0x109BD)
SI = Alu16.Inc(SI);
// JNZ 0x1000:09c1 (1000_09BE / 0x109BE)
if (!ZeroFlag)
{
// IN AL,DX (1000_09C1 / 0x109C1)
CheckExternalEvents(cs1, 0x9c2);
AL = Cpu.In8(DX);
// AND AL,0x8 (1000_09C2 / 0x109C2)
AL &= 0x8;
// CMP AL,AH (1000_09C4 / 0x109C4)
Alu8.Sub(AL, AH);
// JNZ 0x1000:09d6 (1000_09C6 / 0x109C6)
if (!ZeroFlag)
{
// CRT register changed
// STC (1000_09D6 / 0x109D6)
CarryFlag = true;
// RET (1000_09D7 / 0x109D7)
return NearRet();
}
}
// DEC SI (1000_09C0 / 0x109C0)
SI = Alu16.Dec(SI);
// PUSH AX (1000_09C8 / 0x109C8)
Stack.Push16(AX);
// MOV AX,word ptr ES:[BP + 0x0] (1000_09C9 / 0x109C9)
AX = UInt16[ES, BP];
// SUB AX,BX (1000_09CD / 0x109CD)
AX -= BX;
// CMP AX,0x64 (1000_09CF / 0x109CF)
Alu16.Sub(AX, 0x64);
// POP AX (1000_09D2 / 0x109D2)
AX = Stack.Pop16();
// JC 0x1000:09bd (1000_09D3 / 0x109D3)
}
while (CarryFlag);
// RET (1000_09D5 / 0x109D5)
return NearRet();
}
/// <summary>
/// First pass rewrite done by the .NET Roslyn compiler (ReadyToRun pre-compilation)
/// </summary>
public virtual Action CommonCirclesWaitFrameAndWriteNextPaletteData_1000_09D8_109D8(int loadOffset)
{
Stack.Push16(SI);
Stack.Push16(DS);
Stack.Push16(ES);
DS = Stack.Pop16();
SI = DX;
Stack.Push16(FlagRegister16);
// CMP byte ptr CS:[0x6e],0x0 (1000_09DF / 0x109DF)
Alu8.Sub(UInt8[cs1, CrtRegisterIsFunctionalFlagOffset_6E], 0x0);
if (!ZeroFlag)
{
// CRT register (3DA)
DX = UInt16[cs1, CrtRegisterOffset_6C];
do
{
CheckExternalEvents(cs1, 0x9EC);
AL = Cpu.In8(DX);
AL &= 8;
// CMP AL,byte ptr CS:[0x6f] (1000_09EF / 0x109EF)
Alu8.Sub(AL, UInt8[cs1, CrtRegisterLastObservedValueOffset_6F]);
}
while (!ZeroFlag);
}
InterruptFlag = false;
DX = 0x3C8;
AL = BL;
Cpu.Out8(DX, AL);
DX = Alu16.Inc(DX);
AX = CX;
CX += CX;
CX += AX;
// CMP byte ptr CS:[0x6b],0x0 (1000_0A0C / 0x10A0C)
Alu8.Sub(UInt8[cs1, 0x6B], 0x0);
if (!ZeroFlag)
{
while (CX != 0)
{
CX--;
Cpu.Out8(DX, UInt8[DS, SI]);
SI = (ushort)(SI + Direction8);
}
FlagRegister16 = Stack.Pop16();
DS = Stack.Pop16();
SI = Stack.Pop16();
return NearRet();
}
ushort num4;
do
{
AL = UInt8[DS, SI];
SI = (ushort)(SI + Direction8);
Cpu.Out8(DX, AL);
num4 = CX--;
}
while (num4 != 0);
FlagRegister16 = Stack.Pop16();
DS = Stack.Pop16();
SI = Stack.Pop16();
return NearRet();
}
/// <summary>
/// First pass rewrite done by the .NET Roslyn compiler (ReadyToRun pre-compilation)
/// </summary>
public virtual Action ConvertLineNumberToArrayIndex_1000_0A22_10A22(int loadOffset)
{
// CMP BX,0xc8 (1000_0A22 / 0x10A22)
Alu16.Sub(BX, 0xC8);
// JC 0x1000:0a2b (1000_0A26 / 0x10A26)
if (CarryFlag)
{
// XCHG BL,BH (1000_0A2B / 0x10A2B)
(BH, BL) = (BL, BH);
// MOV DI,BX (1000_0A2D / 0x10A2D)
DI = BX;
// SHR DI,0x1 (1000_0A2F / 0x10A2F)
DI >>= 0x1;
// SHR DI,0x1 (1000_0A31 / 0x10A31)
DI >>= 0x1;
// ADD DI,BX (1000_0A33 / 0x10A33)
// DI += BX;
DI = Alu16.Add(DI, BX);
// XCHG BL,BH (1000_0A35 / 0x10A35)
(BH, BL) = (BL, BH);
// ADD DI,DX (1000_0A37 / 0x10A37)
// DI += DX;
DI = Alu16.Add(DI, DX);
}
// RET (1000_0A39 / 0x10A39)
return NearRet();
}
public virtual Action Nop_1000_0A3A_10A3A(int loadOffset)
{
// PUSH AX (1000_0A3A / 0x10A3A)
Stack.Push16(AX);
// PUSH CX (1000_0A3B / 0x10A3B)
Stack.Push16(CX);
// PUSH DI (1000_0A3C / 0x10A3C)
Stack.Push16(DI);
// PUSH ES (1000_0A3D / 0x10A3D)
Stack.Push16(ES);
// MOV AX,0xa000 (1000_0A3E / 0x10A3E)
AX = 0xA000;
// MOV ES,AX (1000_0A41 / 0x10A41)
ES = AX;
// XOR DI,DI (1000_0A43 / 0x10A43)
DI = 0;
// MOV CX,0x7d00 (1000_0A45 / 0x10A45)
CX = 0x7D00;
// XOR AX,AX (1000_0A48 / 0x10A48)
AX = 0;
// REP
while (CX != 0)
{
CX--;
// STOSW ES:DI (1000_0A4A / 0x10A4A)
UInt16[ES, DI] = AX;
DI = (ushort)(DI + Direction16);
}
// POP ES (1000_0A4C / 0x10A4C)
ES = Stack.Pop16();
// POP DI (1000_0A4D / 0x10A4D)
DI = Stack.Pop16();
// POP CX (1000_0A4E / 0x10A4E)
CX = Stack.Pop16();
// POP AX (1000_0A4F / 0x10A4F)
AX = Stack.Pop16();
// RET (1000_0A50 / 0x10A50)
return NearRet();
}
/// <summary>
/// First pass rewrite done by the .NET Roslyn compiler (ReadyToRun pre-compilation)
/// </summary>
public virtual Action Nop_1000_0A51_10A51(int loadOffset)
{
// PUSH DS (1000_0A51 / 0x10A51)
Stack.Push16(DS);
AX = 0xA000;
DS = AX;
ES = AX;
// XOR SI,SI
SI = 0;
// XOR DI,DI
DI = 0;
CX = 0xFA00;
ushort num1;
do
{
AL = UInt8[DS, SI];
SI += (ushort)Direction8;
if (CarryFlag)
AL = 0;
UInt8[ES, DI] = AL;
DI += (ushort)Direction8;
num1 = CX--;
}
while (num1 != 0);
DS = Stack.Pop16();
return NearRet();
}
/// <summary>
/// First pass rewrite done by the .NET Roslyn compiler (ReadyToRun pre-compilation)
/// </summary>
public virtual Action CommonUnknown_1000_0B9A_10B9A(int loadOffset)
{
if (loadOffset == 0)
{
goto label_60;
}
label_2:
BP = DX;
DI -= (ushort)(uint)BP;
DI = Alu16.Add(DI, 320);
label_3:
do
{
do
{
AL = UInt8[DS, SI];
SI += (ushort)(uint)Direction8;
AL = Alu8.Or(AL, AL);
if (!SignFlag)
{
CX = AX;
CH = 0;
++CX;
BP = Alu16.Sub(BP, CX);
ushort num = 1;
do
{
AL = UInt8[DS, SI];
SI += (ushort)(uint)Direction8;
AL = Alu8.Or(AL, AL);
if (!ZeroFlag)
{
UInt8[ES, DI] = AL;
DI += (ushort)(uint)Direction8;
if (--CX == 0)
{
BP = Alu16.Or(BP, BP);
if (CarryFlag || ZeroFlag)
{
BX = Alu16.Dec(BX);
if (!ZeroFlag)
{
goto label_2;
}
else
{
goto label_9;
}
}
else
{
goto label_3;
}
}
}
else
{
DI = Alu16.Inc(DI);
num = CX--;
}
}
while (num != 0);
BP = Alu16.Or(BP, BP);
if (CarryFlag || ZeroFlag)
{
BX = Alu16.Dec(BX);
if (ZeroFlag)
goto label_9;
else
goto label_2;
}
}
else
{
CX = 0x101;
AH = 0;
CX -= (ushort)(uint)AX;
BP = Alu16.Sub(BP, CX);
AL = UInt8[DS, SI];
SI += (ushort)(uint)Direction8;
AL = Alu8.Or(AL, AL);
if (!ZeroFlag)
{
while (CX != 0)
{
CX--;
UInt8[ES, DI] = AL;
DI += (ushort)(uint)Direction8;
}
BP = Alu16.Or(BP, BP);
}
else
{
goto label_18;
}
}
}
while (!CarryFlag && !ZeroFlag);
BX = Alu16.Dec(BX);
if (ZeroFlag)
{
goto label_9;
}
else
{
goto label_2;
}
label_18:
DI = Alu16.Add(DI, CX);
BP = Alu16.Or(BP, BP);
}
while (!CarryFlag && !ZeroFlag);
BX = Alu16.Dec(BX);
if (!ZeroFlag)
goto label_2;
label_9:
DirectionFlag = false;
UInt8[cs1, 0xA71] = 0xC7;
UInt8[cs1, 0xB2F] = 0xC7;
return FarRet();
label_60:
int num1 = (int)Alu8.Sub(CH, 0xFE);
if (CarryFlag)
return FarRet();
DI = Alu16.Or(DI, DI);
if (!SignFlag)
{
BP = DI;
BP = Alu16.And(BP, 511);
AX = DI;
NearCall(cs1, 0xBAF, ConvertLineNumberToArrayIndex_1000_0A22_10A22);
BX = CX;
BH = 0;
int num2 = Alu8.Sub(CH, byte.MaxValue);
if (!ZeroFlag)
{
BP = Alu16.Shr(BP, 1);
AX = DI;
if (!CarryFlag)
{
do
{
CX = BP;
DI = AX;
while (CX != 0)
{
--CX;
UInt16[ES, DI] = UInt16[DS, SI];
SI += (ushort)(uint)Direction16;
DI += (ushort)(uint)Direction16;
}
AX += 320;
BX = Alu16.Dec(BX);
}
while (!ZeroFlag);
return FarRet();
}
do
{
CX = BP;
DI = AX;
while (CX != 0)
{
--CX;
UInt16[ES, DI] = UInt16[DS, SI];
SI += (ushort)(uint)Direction16;
DI += (ushort)(uint)Direction16;
}
UInt8[ES, DI] = UInt8[DS, SI];
SI += (ushort)(uint)Direction8;
DI += (ushort)(uint)Direction8;
AX += 320;
BX = Alu16.Dec(BX);
}
while (!ZeroFlag);
return FarRet();
}
DX = DI;
label_76:
do
{
CX = BP;
DI = DX;
ushort num3 = 1;
do
{
AL = UInt8[DS, SI];
SI += (ushort)(uint)Direction8;
AL = Alu8.Or(AL, AL);
if (!ZeroFlag)
{
UInt8[ES, DI] = AL;
DI += (ushort)(uint)Direction8;
if (--CX == 0)
{
DX += 320;
BX = Alu16.Dec(BX);
if (ZeroFlag)
return FarRet();
goto label_76;
}
}
else
{
DI = Alu16.Inc(DI);
num3 = --CX;
}
}
while (num3 != 0);
DX += 320;
BX = Alu16.Dec(BX);
}
while (!ZeroFlag);
return FarRet();
}
BP = DI;
BP = Alu16.And(BP, 511);
AX = DI;
NearCall(cs1, 0xC05, ConvertLineNumberToArrayIndex_1000_0A22_10A22);
BX = CX;
BH = 0;
int num4 = Alu16.And(AX, 16384);
if (ZeroFlag)
{
int num5 = Alu16.And(AX, 8192);
if (!ZeroFlag)
{
UInt8[cs1, 0xA71] = 0xEF;
UInt8[cs1, 0xB2F] = 0xEF;
AH = BL;
AH = Alu8.Dec(AH);
DH = AH;
DL = (byte)0;
AL = DL;
DX >>= 1;
DX >>= 1;
DI += (ushort)(uint)AX;
DI = Alu16.Add(DI, DX);
}
DX = BP;
int num6 = Alu8.Sub(CH, byte.MaxValue);
if (!ZeroFlag)
{
while (true)
{
do
{
AL = UInt8[DS, SI];
SI += (ushort)(uint)Direction8;
AL = Alu8.Or(AL, AL);
if (!SignFlag)
{
CX = AX;
CH = 0;
++CX;
BP = Alu16.Sub(BP, CX);
while (CX != 0)
{
--CX;
UInt8[ES, DI] = UInt8[DS, SI];
SI += (ushort)(uint)Direction8;
DI += (ushort)(uint)Direction8;
}
if (CarryFlag || ZeroFlag)
{
BX = Alu16.Dec(BX);
if (ZeroFlag)
{
goto label_9;
}
else
{
goto label_37;
}
}
}
else
{
CX = 0x101;
AH = 0;
CX -= (ushort)(uint)AX;
BP = Alu16.Sub(BP, CX);
AL = UInt8[DS, SI];
SI += (ushort)(uint)Direction8;
while (CX != 0)
{
--CX;
UInt8[ES, DI] = AL;
DI += (ushort)(uint)Direction8;
}
}
}
while (!CarryFlag && !ZeroFlag);
goto label_48;
label_37:
BP = DX;
DI -= (ushort)(uint)BP;
DI = Alu16.Add(DI, 320);
continue;
label_48:
BX = Alu16.Dec(BX);
if (ZeroFlag)
{
goto label_9;
}
else
{
goto label_37;
}
}
}
else
{
goto label_3;
}
}
else
{
int num7 = Alu16.And(AX, 8192);
if (!ZeroFlag)
{
UInt8[cs1, 0xAD2] = 0xEF;
UInt8[cs1, 0xB61] = 0xEF;
AH = BL;
AH = Alu8.Dec(AH);
DH = AH;
DL = 0;
AL = DL;
DX >>= 1;
DX >>= 1;
DI += (ushort)(uint)AX;
DI += (ushort)(uint)DX;
}
DI += (ushort)(uint)BP;
DI = Alu16.Dec(DI);
DirectionFlag = true;
DX = BP;
int num8 = Alu8.Sub(CH, byte.MaxValue);
if (ZeroFlag)
{
label_21:
while (true)
{
do
{
do
{
AL = UInt8[DS, SI];
SI = Alu16.Inc(SI);
AL = Alu8.Or(AL, AL);
if (!ZeroFlag)
{
CX = AX;
CH = 0;
++CX;
BP = Alu16.Sub(BP, CX);
ushort num9 = 1;
do
{
AL = UInt8[DS, SI];
SI = Alu16.Inc(SI);
AL = Alu8.Or(AL, AL);
if (!ZeroFlag)
{
UInt8[ES, DI] = AL;
DI += (ushort)(uint)Direction8;
if (--CX == 0)
{
BP = Alu16.Or(BP, BP);
if (CarryFlag || ZeroFlag)
{
BX = Alu16.Dec(BX);
if (ZeroFlag)
{
goto label_9;
}
else
{
goto label_20;
}
}
else
{
goto label_21;
}
}
}
else
{
DI = Alu16.Dec(DI);
num9 = --CX;
}
}
while (num9 != 0);
BP = Alu16.Or(BP, BP);
if (CarryFlag || ZeroFlag)
{
BX = Alu16.Dec(BX);
if (ZeroFlag)
{
goto label_9;
}
else
{
goto label_20;
}
}
}
else
{
CX = 0x101;
AH = 0;
CX -= (ushort)(uint)AX;
BP = Alu16.Sub(BP, CX);
AL = UInt8[DS, SI];
SI = Alu16.Inc(SI);
AL = Alu8.Or(AL, AL);
if (!ZeroFlag)
{
while (CX != 0)
{
CX--;
UInt8[ES, DI] = AL;
DI += (ushort)(uint)Direction8;
}
BP = Alu16.Or(BP, BP);
}
else
{
goto label_35;
}
}
}
while (!CarryFlag && !ZeroFlag);
BX = Alu16.Dec(BX);
if (ZeroFlag)
{
goto label_9;
}
else
{
goto label_20;
}
label_35:
DI = Alu16.Sub(DI, CX);
BP = Alu16.Or(BP, BP);
}
while (!CarryFlag && !ZeroFlag);
goto label_36;
label_20:
BP = DX;
DI += (ushort)(uint)BP;
DI = Alu16.Add(DI, 320);
continue;
label_36:
BX = Alu16.Dec(BX);
if (ZeroFlag)
{
goto label_9;
}
else
{
goto label_20;
}
}
}
else
{
while (true)
{
do
{
AL = UInt8[DS, SI];
SI = Alu16.Inc(SI);
AL = Alu8.Or(AL, AL);
if (!ZeroFlag)
{
CX = AX;
CH = 0;
++CX;
BP = Alu16.Sub(BP, CX);
ushort num10;
do
{
AL = UInt8[DS, SI];
SI = Alu16.Inc(SI);
UInt8[ES, DI] = AL;
DI += (ushort)(uint)Direction8;
num10 = --CX;
}
while (num10 != 0);
BP = Alu16.Or(BP, BP);
if (CarryFlag || ZeroFlag)
{
BX = Alu16.Dec(BX);
if (ZeroFlag)
{
goto label_9;
}
else
{
goto label_49;
}
}
}
else
{
CX = 0x101;
AH = 0;
CX -= (ushort)(uint)AX;
BP = Alu16.Sub(BP, CX);
AL = UInt8[DS, SI];
SI = Alu16.Inc(SI);
while (CX != 0)
{
--CX;
UInt8[ES, DI] = AL;
DI += (ushort)(uint)Direction8;
}
BP = Alu16.Or(BP, BP);
}
}
while (!CarryFlag && !ZeroFlag);
goto label_59;
label_49:
BP = DX;
DI += (ushort)(uint)BP;
DI = Alu16.Add(DI, 320);
continue;
label_59:
BX = Alu16.Dec(BX);
if (ZeroFlag)
{
goto label_9;
}
else
{
goto label_49;
}
}
}
}
}
/// <summary>
/// First pass rewrite done by the .NET Roslyn compiler (ReadyToRun pre-compilation)
/// </summary>
public virtual Action CirclesUnknown_display_1000_0C72_10C72(int loadOffset)
{
Stack.Push16(DS);
AX = 0xA000;
ES = AX;
DS = AX;
SI = 0;
DI = 320;
DX = 0x64;
do
{
CX = 0x50;
ushort num;
do
{
AX = UInt16[DS, SI];
SI += (ushort)Direction16;
(AH, AL) = (AL, AH);