forked from ChuckyGang/DiagROM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DiagROM.s
18831 lines (15384 loc) · 360 KB
/
DiagROM.s
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
;APS0000002F0000002F000300F400030AA500030AA500030AA500030AA500030AA500030AA500030AA5
;
; DiagROM by John "Chucky" Hertell
;
; A6 is ONLY to be used as a memorypointer to variables etc. so never SET a6 in the code.
; First some definitions.
; obscene words like "kuk" marks really bad code or temporary crap.. just look away.
VER: MACRO
dc.b "1" ; Versionnumber
ENDM
REV: MACRO
dc.b "2.1" ; Revisionmumber
ENDM
VERSION: MACRO
dc.b "V" ; Generates versionstring.
VER
dc.b "."
REV
ENDM
EDITION: MACRO
; dc.b " - Revision Edition"
ENDM
PUSH: MACRO
movem.l a0-a6/d0-d7,-(a7) ;Store all registers in the stack
ENDM
POP: MACRO
movem.l (a7)+,a0-a6/d0-d7 ;Restore the registers from the stack
ENDM
TOGGLEPWRLED: MACRO
bchg #1,$bfe001
ENDM
PAROUT: MACRO
move.b \1,$bfe101
ENDM
VBLT: MACRO
.vblt\@ btst #14,$dff002
bne.s .vblt\@
ENDM
rom_base: equ $f80000 ; Originate as if data is in ROM
; Then some different modes for the assembler
rommode = 1 ; Set to 1 if to assemble as being in ROM
a1k = 0 ; Set to 1 if to assemble as for being used on A1000 (64k memrestriction)
debug = 0 ; Set to 1 to enable some debugshit in code
amiga = 1 ; Set to 1 to create an amiga header to write the ROM to disk
ifne rommode
ifeq amiga
;; if we are spitting out a rom directly then we need to make sure
;; vasm doesnt try to write out a section at the origin.
;; this is a bit of a hack to make the
org rom_base
endc
endc
PRINTT
PRINTT "Diagrom Assembling... Statistics: "
PRINTT
PRINTT Romcodesize:
PRINTV EndRom-TheStart
PRINTT
PRINTT Variablespace:
PRINTV C-V
PRINTT
PRINTT Workspace:
PRINTV EndData-V
PRINTT
PRINTT "Total Chipmem usage:"
PRINTV EndData-Variables
PRINTT
PRINTT
LOWRESSize: equ 40*256
HIRESSize: equ 80*512
ifne rommode
; If we are in ROM Mode and start.
; just save the file to disk.
ifne amiga
; First lets fix some checksums
move.l #Checksums-rom_base,d0
lea a,a0
move.l a0,a1
add.l d0,a1 ; a1 should now point to where checksums starts in memory
move.l a1,d1 ; Store startaddress of checksums in d1
move.l d1,d2
add.l #EndChecksums-Checksums,d2 ; Store endaddress of checksums in d2
clr.l d3
move.l #7,d6
.romcheckloop2:
move.l #0,d0 ; Clear D0 that calculates the checksum
move.l #$3fff,d7
.romcheckloop:
cmp.l d1,a0
bhi .higher
bra .not
.higher: ; ok we are above checksums.
cmp.l d2,a0 ; are we lower then end of checksums
bhi .not ; no. so we will do checksumcalculations
add.l #1,d3
add.l #4,a0
bra .nocalc
.not:
add.l (a0)+,d0
.nocalc:
dbf d7,.romcheckloop
.endromcheck:
move.l d0,(a1)+
dbf d6,.romcheckloop2
.slut: ; Checksums is calculated and put into code.
SaveFile:
lea .filnamn,a5
move.l $4,a6
lea Dos,a1
jsr -408(a6)
move.l d0,a6
move.l a5,d1
jsr -72(a6) ; Delete file
move.l a5,d1
move.l #1006,d2
jsr -30(a6)
beq .Error
move.l d0,.Peekare
move.l d0,d1
move.l #a,d2
move.l #b-a,d3
jsr -48(a6)
move.l .Peekare,d1
jsr -36(a6)
clr.l d0
rts
.Error:
move.l #-1,d0
rts
.Peekare:
dc.l 0
.filnamn:
ifeq a1k
dc.b "DiagROM/DiagROM",0
else
dc.b "DiagROM/DiagROMA1k",0
endc
Dos:
dc.b "dos.library",0
a: equ $45000000 ; YES! this is as dirty as yesterdays underwear, but needed.. do not do this if you care about other running stuff.. OK?
ifeq a1k
b: equ a+512*1024
else
b: equ a+64*1024
endc
endc ; end the amiga writer header.
org rom_base ; Originate as if data is in ROM
ifne amiga ;
load a ; PUT Data in where A points to, change this to a safe location for your machine.
endc
START:
PRINTT
PRINTT "--------------------------------- ROMMMODE ENABLED ---------------------------------"
PRINTT
dc.w $1114 ; this just have to be here for ROM. code starts at $2
endc
; Lets start the code.. with a jump
TheStart:
jmp Begin
dc.l POSTBusError ; Hardcoded pointers
dc.l POSTAddressError ; if something is wrong rom starts at $0
dc.l POSTIllegalError ; so this will actually be pointers to
dc.l POSTDivByZero ; traps.
dc.l POSTChkInst
dc.l POSTTrapV
dc.l POSTPrivViol
dc.l POSTTrace
dc.l POSTUnimplInst
strstart:
DC.B "IHOL : :6U6U,A,B1U1U5767U,U,8181 1 0 " ; This string will make a readable text on each 32 bit
DC.B "HILO: : U6U6A,B,U1U17576,U,U18181 0 " ; rom what socket to use. (SOME programmingsoftware does byteshift so both orders)
dc.b "$VER: DiagROM Amiga Diagnostic by John Hertell. "
dc.b "www.diagrom.com "
incbin "ram:BootDate.txt"
dc.b "- "
VERSION
strstop:
blk.b 166-(strstop-strstart),0 ; Crapdata that needs to be here
EVEN
Begin:
ifne rommode
; Code in ROM mode
clr.l d0
clr.l d1
clr.l d2
clr.l d3
clr.l d4
clr.l d5
clr.l d6
clr.l d7
lea $0,a0
lea $0,a1
lea $0,a2
lea $0,a3
lea $0,a4
lea $0,a5
lea $0,a6
lea $400,SP ; Set the stack. BUT!!! do not use it yet. we need to check chipmem first!
move.b #$ff,$bfe200
move.b #$ff,$bfe300
move.b #0,$bfe001 ; Clear register.
move.b #$ff,$bfe301
move.b #$0,$bfe101
move.b #3,$bfe201
move.b #0,$bfe001 ; Powerled will go ON! so user can see that CPU works
move.b #$40,$bfed01
move.w #$f0f,$dff180
move.w #$ff00,$dff034
move.w #$0ff,$dff180
move.b #$ff,$bfd300
or.b #$f8,$bfd100
nop
and.b #$87,$bfd100
nop
or.b #$78,$bfd100
; Lets check status of mousebuttons at start. AAAND we have ONE register not used in
move.l #POSTBusError,$8
move.l #POSTAddressError,$c
move.l #POSTIllegalError,$10
move.l #POSTDivByZero,$14
move.l #POSTChkInst,$18
move.l #POSTTrapV,$1c
move.l #POSTPrivViol,$20
move.l #POSTTrace,$24
move.l #POSTUnimplInst,$28
move.l #POSTUnimplInst,$2c
; all code. A4.. so lets store the result therea
move.b #$88,$bfed01
or.b #$40,$bfee01 ; For keyboard
; We will print the result on the serialport later.
move.l #0,d0 ; Make sure D0 is cleared.
lea AnsiNull,a0 ; Clear screen, clear ansi attributes, set default color
lea .jmp0,a1
bra DumpSerial ; Dump to serial, after it jump to where a1 points at.
.jmp0:
btst #6,$bfe001 ; Check LMB port 1
bne .NOP1LMB ; NOT pressed.. Skip to next
bset #0,d0
.NOP1LMB:
btst #7,$bfe001 ; Check LMB port 2
bne .NOP2LMB
bset #1,d0
.NOP2LMB:
btst #10,$dff016 ; Check RMB port 1
bne .NOP1RMB
bset #2,d0
.NOP1RMB:
btst #14,$dff016 ; Check RMB port 2
bne .NOP2RMB
.aaa:
move.b $dff006,$dff181
bra .aaa
bset #3,d0
.NOP2RMB:
move.l d0,a4 ; OK Store the result in a4 (YEAH I know it is not used for data.. but no mem.. and only register not used)
lea InitSerial,a0
lea .jmp1,a1
bra DumpSerial ; Dump to serial, after it jump to where a1 points at.
.jmp1:
move.w #$aaa,$dff180 ; Set screen to light grey
lea .cleardone,a0
bra DumpClearSerial
.cleardone:
lea LoopSerTest,a0
lea .loopdone,a1
bra DumpSerial
.loopdone:
move.w #$4000,$dff09a
move.w #373,$dff032 ; Set the speed of the serialport (9600BPS)
move.b #$4f,$bfd000 ; Set DTR high
move.w #$0801,$dff09a
move.w #$0801,$dff09c
TOGGLEPWRLED
clr.l d6 ; Clear D6, if this is anything else than 0 efter loopbacktest, we had an echo (adapter)
move.l #"<",d2
lea .looptst1,a0
jmp Loopbacktest
.looptst1:
move.w #$777,$dff180 ; Set screen to light grey
TOGGLEPWRLED
move.l #">",d2
lea .looptst2,a0
jmp Loopbacktest
.looptst2:
move.w #$555,$dff180 ; Set screen to light grey
TOGGLEPWRLED
cmp.b #0,d6
beq .noadapter
lea DDETECTED,a0
lea .loopdetect,a1
bra DumpSerial
.loopdetect:
; ok we had detected a loopback, lets mark it in our "secret" register (in A4 now) by setting bit 4
move.l a4,d0
bset #4,d0
move.l d0,a4 ; ok we have restored it in A4 now.
bra .goon
.noadapter:
lea NoLoopback,a0
lea .nodetect,a1
bra DumpSerial
.nodetect:
.goon:
move.l a4,$4
PAROUT #$ff ; Send #$ff to Paralellport.
lea parfftxt,a0 ; And explaining simliar text to serialport.
lea .jmp2,a1
bra DumpSerial
.jmp2:
lea Initmousetxt,a0
lea .jmp3,a1
bra DumpSerial
.jmp3:
move.l a4,d0
btst #0,d0
beq .noP1LMB
lea InitP1LMBtxt,a0
lea .noP1LMB,a1
bra DumpSerial
.noP1LMB:
btst #1,d0
beq .noP2LMB
lea InitP2LMBtxt,a0
lea .noP2LMB,a1
bra DumpSerial
.noP2LMB:
btst #2,d0
beq .noP1RMB
lea InitP1RMBtxt,a0
lea .noP1RMB,a1
bra DumpSerial
.noP1RMB:
btst #3,d0
beq .noP2RMB
lea InitP2RMBtxt,a0
lea .noP2RMB,a1
bra DumpSerial
.noP2RMB:
lea NewLineTxt,a0
lea .mousedone,a1
bra DumpSerial
.mousedone:
lea InitINTENAtxt,a0
lea .jmp4,a1
bra DumpSerial
.jmp4:
move.w #$7fff,$dff09a ; Disable all INTENA
lea InitDONEtxt,a0
lea .jmp5,a1
bra DumpSerial
.jmp5:
lea InitINTREQtxt,a0
lea .jmp6,a1
bra DumpSerial
.jmp6:
move.w #$7fff,$dff09c ; Disable all INTREQ
lea InitDONEtxt,a0
lea .jmp7,a1
bra DumpSerial
.jmp7:
lea InitDMACONtxt,a0
lea .jmp8,a1
bra DumpSerial
.jmp8:
move.w #$7fff,$dff096 ; Disable all DMACON
lea InitDONEtxt,a0
lea .jmp9,a1
bra DumpSerial
.jmp9:
move.w #$200,$dff100
move.w #0,$dff110
.RMB: ; We had RMB pressed so we skipped DMA stuff..
; next part will hopefully go so fast so the user will not release the button
; so we can force data to fastmem if any.
; Now lets check for some memory, the only thing we KNOW exists on all machines is Chipmem.
; so this will only really rely on Chipmem. but does it work? anyway. NO stack is allowed at this
; point, meaning NO Stack, no subroutines only registers A0-A6 and D0-D7 and no memory.
lea OvlTestTxt,a0
lea .ovlprt,a1
bra DumpSerial
.ovlprt:
btst #0,$bfe001
bne .noovl
lea SOK,a0
lea .ovldone,a1
bra DumpSerial
.noovl: ; OK OVL test failed. that means by misstake "stuck" LMB1 and LMB2 is false.
move.l a4,d0
bclr #0,d0 ; Clear LMB1
bclr #1,d0 ; Clear LMB2
bset #5,d0 ; Set bit 5 as OVL ERROR
move.l d0,a4 ; store it back to a4
lea SFAILED,a0
lea .ovldone,a1
bra DumpSerial
.ovldone:
lea NewLineTxt,a0
lea .ovlover,a1
bra DumpSerial
.ovlover:
PAROUT #$fe ; Send #$fe to Paralellport.
lea parfetxt,a0 ; And explaining simliar text to serialport.
lea .ldsuds1,a1
bra DumpSerial
.ldsuds1:
; Time to detect some chipmem
lea writeffff,a0
lea .ldsuds2,a1
bra DumpSerial
.ldsuds2:
move.w #$ffff,d1
move.w d1,$400
nop
move.w $400,d0
move.w $400,d0
move.w $400,d0
move.w $400,d0
move.w $400,d0
cmp.w d0,d1
bne.s .ldsuds2fail
lea SOK,a0
lea .ldsuds3,a1
bra DumpSerial
.ldsuds2fail:
lea SFAILED,a0
lea .ldsuds3,a1
bra DumpSerial
.ldsuds3:
lea NewLineTxt,a0
lea .ldsuds3nl,a1
bra DumpSerial
.ldsuds3nl:
lea write00ff,a0
lea .ldsuds4,a1
bra DumpSerial
.ldsuds4:
move.w #$00ff,d1
move.w d1,$400
nop
move.w $400,d0
move.w $400,d0
move.w $400,d0
move.w $400,d0
move.w $400,d0
cmp.w d0,d1
bne.s .ldsuds4fail
lea SOK,a0
lea .ldsuds5,a1
bra DumpSerial
.ldsuds4fail:
lea SFAILED,a0
lea .ldsuds5,a1
bra DumpSerial
.ldsuds5:
lea NewLineTxt,a0
lea .ldsuds5nl,a1
bra DumpSerial
.ldsuds5nl:
lea writeff00,a0
lea .ldsuds6,a1
bra DumpSerial
.ldsuds6:
move.w #$ff00,d1
move.w d1,$400
nop
move.w $400,d0
move.w $400,d0
move.w $400,d0
move.w $400,d0
move.w $400,d0
cmp.w d0,d1
bne.s .ldsuds6fail
lea SOK,a0
lea .ldsuds7,a1
bra DumpSerial
.ldsuds6fail:
lea SFAILED,a0
lea .ldsuds7,a1
bra DumpSerial
.ldsuds7:
lea NewLineTxt,a0
lea .ldsuds7nl,a1
bra DumpSerial
.ldsuds7nl:
lea write0000,a0
lea .ldsuds8,a1
bra DumpSerial
.ldsuds8:
move.w #$0000,d1
move.w d1,$400
nop
move.w $400,d0
move.w $400,d0
move.w $400,d0
move.w $400,d0
move.w $400,d0
cmp.w d0,d1
bne.s .ldsuds8fail
lea SOK,a0
lea .ldsuds9,a1
bra DumpSerial
.ldsuds8fail:
lea SFAILED,a0
lea .ldsuds9,a1
bra DumpSerial
.ldsuds9:
lea NewLineTxt,a0
lea .ldsuds9nl,a1
bra DumpSerial
.ldsuds9nl:
lea writebeven,a0
lea .ldsuds10,a1
bra DumpSerial
.ldsuds10:
move.w #$0,d0
move.w d0,$400
move.b #$ff,d1
move.b d1,$400
move.w #$ff00,d1
nop
move.w $400,d0
move.w $400,d0
move.w $400,d0
move.w $400,d0
move.w $400,d0
cmp.b d0,d1
bne .ldsuds10fail
lea SOK,a0
lea .ldsuds11,a1
bra DumpSerial
.ldsuds10fail:
lea SFAILED,a0
lea .ldsuds11,a1
bra DumpSerial
.ldsuds11:
lea NewLineTxt,a0
lea .ldsuds11nl,a1
bra DumpSerial
.ldsuds11nl:
lea writebodd,a0
lea .ldsuds12,a1
bra DumpSerial
.ldsuds12:
move.w #$0,d0
move.w d0,$400
move.b #$ff,d1
move.b d1,$401
move.w #$00ff,d1
nop
move.w $400,d0
move.w $400,d0
move.w $400,d0
move.w $400,d0
move.w $400,d0
cmp.b d0,d1
bne .ldsuds12fail
lea SOK,a0
lea .ldsuds13,a1
bra DumpSerial
.ldsuds12fail:
lea SFAILED,a0
lea .ldsuds13,a1
bra DumpSerial
.ldsuds13:
lea NewLineTxt,a0
lea .ldsuds13nl,a1
bra DumpSerial
.ldsuds13nl:
PAROUT #$fd ; Send #$fe to Paralellport.
lea parfdtxt,a0 ; And explaining simliar text to serialport.
lea .jmp10,a1
bra DumpSerial
.jmp10:
POSTDetectChipmem:
.tstnomore:
lea $400,a6 ; Lets scan memory, start at $400
move.l #$33333333,(a6) ; Write a number that is NOT in the memcheck table. for shadowcheck
clr.l d0
clr.l d3 ; if d3 is not null, it contains first memaddr found
lea NewLineTxt,a0
lea .nldone,a1
bra DumpSerial
.nldone:
.detectloop:
move.l (a6),d5 ; Do a backup of content
lea MEMCheckPattern,a5 ; Load list of data to test
bclr #31,d0
move.l a6,d1
asr.l #8,d1
and.w #$0f0,d1
move.w d1,$dff180 ; Write data to screen as green only.
TOGGLEPWRLED
lea AddrTxt,a0 ; Prints text "Addr $"
lea .addrdone,a1
bra DumpSerial
.addrdone:
move.l a6,d1
lea .addrout,a3
bra DumpHexLong
.addrout:
.memloop:
move.l (a5),(a6) ; Write data to memory
move.l (a5),d1
move.l (a6),d4 ; Read data from memory
move.l (a6),d4 ; Read data from memory
move.l (a6),d4 ; Read data from memory
move.l (a6),d4 ; Read data from memory
move.l (a6),d4 ; Read data from memory
move.l (a6),d4 ; Read data from memory
move.l (a6),d4 ; Read data from memory (read several times.. this will make sure it is real data)
cmp.l (a5),d4 ; Check if written data is the same as the read data.
beq .ok ; YES it is OK
cmp.l #0,d3 ; Check if d3 is 0, in that case we havent found any memory
; and user might want to see whats wrong. if we had. we are simply out of mem
bne .faildone
lea WTxt,a0 ; Prints text "Write:"
lea .wtxtdone,a1
bra DumpSerial
.wtxtdone:
move.l a6,d1 ; Print address to check
move.l (a5),d1
lea .wbindone,a3
bra DumpHexLong
.wbindone:
;------------- binary to serial
lea SpacesTxt,a0 ; Prints text "Write:"
lea .tststart,a1
bra DumpSerial
.tststart:
btst #6,$bfe001
beq .tstlmb
move.l (a5),d1
move.l d2,a0
move.l d3,a1
move.l d4,a2
move.l d7,a3
move.l #31,d3
.tstloop:
clr.l d7
btst d3,d1
beq .tstzero
move.b #"1",d7
bra .tstout
.tstzero:
move.b #"0",d7
.tstout:
move.w #$4000,$dff09a
move.w #373,$dff032 ; Set the speed of the serialport (9600BPS)
move.b #$4f,$bfd000 ; Set DTR high
move.w #$0801,$dff09a
move.w #$0801,$dff09c
move.l #40000,d2 ; Load d2 with a timeoutvariable. only test this number of times.
; IF CIA for serialport is dead we will not end up in a wait-forever-loop.
; and as we cannot use timers. we have to do this dirty style of coding...
.tsttimeoutloop:
move.b $bfe001,d4 ; just read crapdata, we do not care but reading from CIA is slow... for timeout stuff only
sub.l #1,d2 ; count down timeout value
cmp.l #0,d2 ; if 0, timeout.
beq .tstendloop
move.w $dff018,d4
btst #13,d4 ; Check TBE bit
beq.s .tsttimeoutloop
.tstendloop:
move.w #$0100,d4
move.b d7,d4
move.w d4,$dff030 ; send it to serial
move.w #$0001,$dff09c ; turn off the TBE bit
dbf d3,.tstloop
move.l a0,d2
move.l a1,d3
move.l a2,d4
move.l a3,d7
.tstlmb:
;------------- end of binary to serial
lea RTxt,a0 ; Prints text "Read:"
lea .rtxtdone,a1
bra DumpSerial
.rtxtdone:
move.l d4,d1
lea .rbindone,a3
bra DumpHexLong
.rbindone:
;------------- binary to serial
lea SpacesTxt,a0 ; Prints text "Write:"
lea .tststart1,a1
bra DumpSerial
.tststart1:
btst #6,$bfe001
beq .tstlmb1
move.l d4,d1
move.l d2,a0
move.l d3,a1
move.l d4,a2
move.l d7,a3
move.l #31,d3
.tstloop1:
clr.l d7
btst d3,d1
beq .tstzero1
move.b #"1",d7
bra .tstout1
.tstzero1:
move.b #"0",d7
.tstout1:
move.w #$4000,$dff09a
move.w #373,$dff032 ; Set the speed of the serialport (9600BPS)
move.b #$4f,$bfd000 ; Set DTR high
move.w #$0801,$dff09a
move.w #$0801,$dff09c
move.l #40000,d2 ; Load d2 with a timeoutvariable. only test this number of times.
; IF CIA for serialport is dead we will not end up in a wait-forever-loop.
; and as we cannot use timers. we have to do this dirty style of coding...
.tsttimeoutloop1:
move.b $bfe001,d4 ; just read crapdata, we do not care but reading from CIA is slow... for timeout stuff only
sub.l #1,d2 ; count down timeout value
cmp.l #0,d2 ; if 0, timeout.
beq .tstendloop1
move.w $dff018,d4
btst #13,d4 ; Check TBE bit
beq.s .tsttimeoutloop1
.tstendloop1:
move.w #$0100,d4
move.b d7,d4
move.w d4,$dff030 ; send it to serial
move.w #$0001,$dff09c ; turn off the TBE bit
dbf d3,.tstloop1
move.l a0,d2
move.l a1,d3
move.l a2,d4
move.l a3,d7
.tstlmb1:
;------------- end of binary to serial
lea SPACEFAIL,a0 ; Prints "FAILED"
lea .faildone,a1
bra DumpSerial
.faildone:
bset #31,d0 ; set bit 31 in d0 to tell we had an error
move.w #$f00,$dff180
.ok:
cmp.l #$400,a6
beq .yes400 ; if we are checking address 400, skip this
move.l $400,d4
beq .shadow ; ok, we are not checking address 400, BUT we had same data there. meaning
; we have a shadow. so exit
.yes400:
cmp.l #0,(a5)+ ; Was last longword tested null? if not, repeat
bne .memloop
btst #31,d0
bne .fail ; did we have failed memory
cmp.l #0,d3 ; check if this is the first block of good memory
bne .notfirst
move.l a6,d3 ; Store that this was the first sucessful memory
.notfirst:
add.w #1,d0 ; Add 1 to mark a sucessful block
lea SPACEOK,a0 ; Print "OK"
lea .okdone,a1
bra DumpSerial
.okdone:
lea Txt32KBlock,a0 ; Print string of number of blocks
lea .blkdone,a1
bra DumpSerial
.blkdone:
move.l d0,d1
lea .longdone,a2
bra DumpHexByte ; Print out number of OK blocks.
.fail: ; We had a failure
cmp.l #0,d3 ; Check if d3 is 0, in that case we havent found any memory yet
beq .longdone
; ok we had memory, so this is the endblock.
bra .finished ; lets stop all check. we have found it all.
.longdone:
move.l d5,(a6) ; Restore backupped data
add.l #32768,a6 ; Add 32k to a6
cmp.l #$200000,a6 ; have we scanned more then 2MB of data, exit
bhi .finished
bra .detectloop ; Do one more turn.
.shadow:
move.l #"SHDW",(a6) ; to test that we REALLY have a shadowram. write a string
cmp.l #"SHDW",$400 ; and check it at $400, if it is there aswell SHADOW
bne .yes400 ; go on checking ram. we did not have shadow
lea ShadowChiptxt,a0
lea .finished,a1
bra DumpSerial
.finished:
bclr #31,d0 ; Clear "the errorbit"
cmp.l #0,d0 ; check if we had no chipmem
beq .nochipatall
lea StartAddrTxt,a0
lea .startaddrdone,a1
bra DumpSerial
.startaddrdone:
move.l d3,a7 ; Store start of chipmem to a7
move.l d3,d1
lea .startdone,a3
bra DumpHexLong
.startdone:
lea EndAddrTxt,a0
lea .endaddrdone,a1
bra DumpSerial
.endaddrdone:
sub.l #$400,a6
move.l a6,d1
sub.l #1,d1
lea .enddone,a3
bra DumpHexLong
.enddone:
lea NewLineTxt,a0
lea .nl,a1
bra DumpSerial
.nochipatall:
lea NoChiptxt,a0
lea .nl,a1
bra DumpSerial
.nl:
; At EXIT registers that are interesting:
; D0 = Number of usable 32Kb blocks
; D3 = First usable address
; A6 = Last usable address