forked from ChuckyGang/DiagROM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DiagROM.s
12346 lines (10284 loc) · 244 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
;APS0000003600000036000072F100000036000000360000003600000036000000360000003600000036
;
;
; 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 "0" ; Versionnumber
ENDM
REV: MACRO
dc.b "9" ; Revisionmumber
ENDM
VERSION: MACRO
dc.b "V" ; Generates versionstring.
VER
dc.b "."
REV
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 = 0 ; Set to 1 if to assemble as being in ROM
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
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:
dc.b "DiagROM/DiagROM",0
Dos:
dc.b "dos.library",0
a: equ $180000
b: equ a+512*1024
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 $1111 ; 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
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
; 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.
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
; 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 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:
lea InitSerial,a0
lea .jmp1,a1
bra DumpSerial ; Dump to serial, after it jump to where a1 points at.
.jmp1:
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.
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
move.w $400,d0
cmp.w d0,d1
bne.s .ldsuds2fail
lea OK,a0
lea .ldsuds3,a1
bra DumpSerial
.ldsuds2fail:
lea FAILED,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
move.w $400,d0
cmp.w d0,d1
bne.s .ldsuds4fail
lea OK,a0
lea .ldsuds5,a1
bra DumpSerial
.ldsuds4fail:
lea FAILED,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
move.w $400,d0
cmp.w d0,d1
bne.s .ldsuds6fail
lea OK,a0
lea .ldsuds7,a1
bra DumpSerial
.ldsuds6fail:
lea FAILED,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
move.w $400,d0
cmp.w d0,d1
bne.s .ldsuds8fail
lea OK,a0
lea .ldsuds9,a1
bra DumpSerial
.ldsuds8fail:
lea FAILED,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
cmp.b d0,d1
bne .ldsuds10fail
lea OK,a0
lea .ldsuds11,a1
bra DumpSerial
.ldsuds10fail:
lea FAILED,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
move.w $400,d0
cmp.b d0,d1
bne .ldsuds12fail
lea OK,a0
lea .ldsuds13,a1
bra DumpSerial
.ldsuds12fail:
lea FAILED,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:
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 MEMCheckPatternFast,a5 ; Load list of data to test
bclr #31,d0
.memloop:
lea AddrTxt,a0 ; Prints text "Addr $"
lea .addrdone,a1
bra DumpSerial
.addrdone:
move.l a6,d1
lea .addrout,a3
bra DumpHexLong
.addrout:
move.l (a5),(a6) ; Write data to memory
move.l (a5),d1
asl.l #4,d1
and.w #$0f0,d1
move.w d1,$dff180 ; Write data to screen as green only.
move.l (a6),d4 ; Read data from memory
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:
lea RTxt,a0 ; Prints text "Read:"
lea .rtxtdone,a1
bra DumpSerial
.rtxtdone:
move.l d4,d1
lea .rbindone,a3
bra DumpHexLong
.rbindone:
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:
TOGGLEPWRLED
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,d1
lea .startdone,a3
bra DumpHexLong
.startdone:
lea EndAddrTxt,a0
lea .endaddrdone,a1
bra DumpSerial
.endaddrdone:
sub.l #$400,a6
move.l a6,d1
lea .enddone,a3
bra DumpHexLong
.enddone:
; At EXIT registers that are interesting:
; D0 = Number of usable 32Kb blocks
; D3 = First usable address
; A6 = Last usable address
sub.l #EndData-Variables,a6 ; Subtract total chipmemsize, putting workspace at end of memory
sub.l #2048,a6 ; Subtract 2Kb more, "just to be sure"
; A6 from now on points to where diagroms workspace begins. do NOT change A6
; A6 is from now on STATIC
lea Base1Txt,a0
lea .base1,a1
bra DumpSerial
.base1:
move.l a6,d1
lea .base2,a3
bra DumpHexLong
.base2:
lea Base2Txt,a0
lea .base3,a1
bra DumpSerial
.nochipatall:
lea NoChiptxt,a0
lea .base3,a1
bra DumpSerial
.base3:
;----------- Chipmemtest done
PAROUT #$fc ; Send $fd to parallelport
lea parfctxt,a0 ; And explaining simliar text to serialport.
lea .jmp12,a1
bra DumpSerial
.jmp12:
; Lets detect fastmem, do NOT touch D0, A6 or A4
; As we have several blocks to search. we do it in a subroutine instead of in-code as we did with chipmem
move.l d3,a7 ; Store start of chipmem
clr.l d1
clr.l d2
move.l #0,a0
move.l #"24BT",$4000700 ; Write "TEST" to highmem
cmp.l #"24BT",$700 ; IF memory is readable at $700 instead. we are using a cpu with 24 bit adress. no memory to detect in next routines
beq .a1200done
move.l #$4000000,a1 ; Detect motherboardmem on A3000/4000
move.l #$7ffffff,a2
lea .a3k4kdone,a3
bra DetectMBFastmem
.a3k4kdone:
move.l #$70000000,a1 ; Detect memory on A1200/4000 accelerators
move.l #$7affffff,a2
lea .a1200done,a3
bra DetectMBFastmem
.a1200done:
move.l #$200000,a1 ; Detect memory on 24 bit range
move.l #$9fffff,a2
lea .24bitdone,a3
bra DetectMBFastmem
.24bitdone:
move.l #$c00000,a1 ; Detect memory on 24 bit range
move.l #$c80000,a2
lea .fakefastdone,a3
bra DetectMBFastmem
.fakefastdone:
move.l d1,d6 ; Store size in d6 as Dumpserial uses d1
move.l a0,a5 ; Store detected mem to a5
PAROUT #$fb ; Send $fd to parallelport
lea parfbtxt,a0 ; And explaining simliar text to serialport.
lea .jmp16,a1
bra DumpSerial
.jmp16:
move.l d6,d1
move.l a5,a0 ; Restore important data from fastmemdetection
; ok we ACTUALLY did have memory here.. so this was the last time this routine was used.
cmp.l #(EndData-Variables)/32768+1,d0
bgt .enoughchip ; ok we had enough chipmem
; so we are not happy with the amount of found chipmem
cmp.l #(EndData-Variables)/16384+1,d1 ; but was there enough FASTMEM??
bgt .enoughfast ; if so, jump there (should be enoughfast..)
; OK we are is trouble.. not enough memory
cmp.l #2,d0 ; do we have extremly little chipmem
ble .nochip
; ok we did not have enough chipmem, or fastmem, but SOME chipmem
PAROUT #$81 ; Set code to $81 to paralellport, NOT ENOUGH chipmem avaible
lea par81txt,a0 ; And explaining simliar text to serialport.
lea .jmp14,a1
bra DumpSerial
.jmp14:
move.l #$0080,d6 ; set D6 to darker green
bra ERRORHALT
.nochip: ; we had NO chipmem
PAROUT #$80 ; Set code to $80 to paralellport, NO chipmem avaible
lea par80txt,a0 ; And explaining simliar text to serialport.
lea .jmp15,a1
bra DumpSerial
.jmp15:
move.l #$00f0,d6 ; set D0 to darker green
bra ERRORHALT
.enoughfast:
move.l a5,a6 ; We had enough fastmem, so lets set fastmem adress as base memory.
move.l #1,a4 ; Set do NODRAW mode.
move.l d6,d1
move.l a5,a0 ; Restore important data from fastmemdetection
bra code
.enoughchip:
; OK we had enough chipmem avaible.
move.l a4,d7
btst #0,d7 ; Check if LMB was pressed during boot
bne .LMB
cmp.l #$20000,a6 ; check if a6 is in chipmem
ble .wearechip ; if we are do not set to nodraw mode
move.l #1,d7 ; Set d7 to non 0 mode to force "nodraw" mode.
.wearechip:
bra startcode ; Start ROM for real, now with memory.
.LMB: ; LMB Pressed so we force chipmem if avaible, and if not just turn off screenstuff etc.
move.l #1,d7 ; OK we are in a nodraw mode..
cmp.l #0,a5 ; Was there any useful fastmem
beq .nofast
move.l a5,a6 ; OK we had fastmem, set it as baseadress
.nofast: ; we didnt have any fastmem, lets use chipmem but skip screenstuff.
startcode:
move.l d1,d6 ; Store size in d6 as Dumpserial uses d1
move.l a0,a5 ; Store detected mem to a1
PAROUT #$fa ; Set code to $fb to paralellport, NO chipmem avaible
lea parfatxt,a0 ; And explaining simliar text to serialport.
lea .jmp,a1
bra DumpSerial
.jmp:
move.l d6,d1
move.l a5,a0 ; Restore important data from fastmemdetection
bra code
ERRORHALT: ; This is a critical Error. stop everything. we are fucked.
move.l d6,d4 ; as d4 isnt used in motherboardcheck, store color
ERRORHALT2:
lea HALTTXT,a0 ; Tell user on serialport that we are totally halted.
lea .loop,a1
bra DumpSerial
.loop:
TOGGLEPWRLED ; Change value of Powerled.
bne .not
move.w d6,$dff180 ; Set Screencolor to d6 (usual chipmemproblem color)
bra .yes
.not:
move.w #$030,$dff180 ; just every 2:nd turn, show a DARK green color instead. making the screen flash some.
.yes:
move.l #$ffff,d7 ; Do a nonsense loop
.loopa:
move.b $bfe001,d5 ; Actually a nonsense read. but CIA space is slow to read from.
move.b $bfd400,d5 ; Actually a nonsense read. but CIA space is slow to read from.
dbf d7,.loopa
bra.w .loop ; Loop forever
code:
move.l a7,d3 ; Copy start of chipmem (temporary stored in a7) do d3
move.l a6,a7 ; ok. we have found memory. so put stack there. BUT first put a6 to a7 (SP)
move.l #Endstack-Variables,d6 ; set d7 to the stacksize
add.l d6,a7 ; and add stacksize so we have a stack
move.l a7,a6
add.l #4,a6 ; make a6 first usable address AFTER stack. for variables.
asl.l #4,d1 ; Multiply d1 with 16 to get correct number of kilobytes of fastmem.;
clr.l d2
move.l #RTEcode,$64
move.l #RTEcode,$68
move.l #RTEcode,$6c
move.l #RTEcode,$70
move.l #RTEcode,$74
move.l #RTEcode,$78
move.l #RTEcode,$7c
move.l #SSPError,0 ; Set different traps of faults that can happen
move.l #BusError,$8 ; This time to a routine that can present more data.
move.l #AddressError,$c
move.l #IllegalError,$10
move.l #DivByZero,$14
move.l #ChkInst,$18
move.l #TrapV,$1c
move.l #PrivViol,$20
move.l #Trace,$24
move.l #UnimplInst,$28
move.l #UnimplInst,$2c
move.l #Trap,$80
move.l #Trap,$84
move.l #Trap,$88
move.l #Trap,$8c
move.l #Trap,$90
move.l #Trap,$94
move.l #Trap,$98
move.l #Trap,$9c
move.l #Trap,$a0
move.l #Trap,$a4
move.l #Trap,$a8
move.l #Trap,$ac
move.l #Trap,$b0
move.l #Trap,$b4
move.l #Trap,$b8
move.l #Trap,$bc
TOGGLEPWRLED
else
; Code in NON-ROM mode
code:
clr.b $bfa001
clr.b $bfa201
clr.b $bfe001
move.b #$ff,$bfe301
move.b #3,$bfe201
bclr #1,$bfe001
lea $0,a4 ; if this is not set. bugs can happen as it can think we are in nondrawmode
lea V,a6 ; Set V as startaddress in non-rom mode.. the stackblock is more "nonsense"
; do not set any stack in this mode. it is already set.
move.l #BeforeUsed,d3
move.l #$40,d0 ; Assume 2MB of chipem when running in non ROM mode
move.b #1,RASTER-V(a6) ; Set that we DO have raster
move.l $64,irq1
move.l $68,irq2
move.l $6c,irq3
move.l $70,irq4
move.l $74,irq5
move.l $78,irq6
move.l $7c,irq7
endc
; Normal code
; Put initstuff here that consumes time, so user have time to read text on console
; Before we actually do start, lets clear all used memory
move.l a6,a0
move.l a6,d2
add.l #EndData-V,d2
.loop:
move.b #0,(a0)+
cmp.l d2,a0
blo .loop
move.l a4,d7
btst #0,d7 ; is d7 set? then we should not draw anything onscreen
beq .notset
move.b #1,NoDraw-V(a6)
.notset:
move.b #0,NoSerial-V(a6)
btst #1,d7 ; Check if noserial is to be set
beq .notset2
move.b #1,NoSerial-V(a6) ; set it
.notset2:
move.l d1,TotalFast-V(a6) ; Store total fastmem detected
move.l d1,BootMBFastmem-V(a6)
asl.l #5,d0 ; Multiply d0 with 32 as it contains number of blocks of 32K
move.l d3,ChipStart-V(a6) ; Write where detected chipmem starts
move.l d0,TotalChip-V(a6) ; Write totalchipvalue so we know how much chipmem is detected
move.l a6,d0 ; Subtract startaddress with lowest value of detected ram
sub.l #V-Variables,d0
move.l d0,ChipUnreservedAddr-V(a6)
sub.l d3,d0 ; also subtract stacksize, now we got all usable NONUSED chipmem
move.l d0,ChipUnreserved-V(a6) ; Store amount of NONRESERVED chipmem
bsr GetHWReg ; Store HW Registers
move.l ChipStart-V(a6),d1 ; Get startaddress of chipmem
move.l TotalChip-V(a6),d0 ; Get total of chipmemblocks detected
mulu #1024,d0
sub.l #$400,d0 ; Subtract first 1Kb
add.l d1,d0 ; add Startaddess of chipmem, so d0 now contains last memaddress
move.l d0,ChipEnd-V(a6) ; Write lastchipmemaddress into EndChip
cmp.b #1,NoSerial-V(a6) ; Check if noserial is set
beq .noser
move.w #2,SerialSpeed-V(a6)
bsr Init_Serial
lea DetectRasterTxt,a0
bsr SendSerial
bra .ser
.noser:
move.w #0,SerialSpeed-V(a6) ; Set Serialspeed to 0
.ser:
move.b $dff006,d0 ; Load value of raster
bsr WaitShort
bsr WaitShort
bsr WaitShort
move.b $dff006,d1 ; Load value of raster again
cmp.b d0,d1
beq .noraster ; if raster was the same, We assume we have no working raster
move.b #1,RASTER-V(a6) ; it was different so we assume we have working raster.
lea DETECTED,a0
bsr SendSerial
beq .rastercheckdone