-
Notifications
You must be signed in to change notification settings - Fork 1
/
jst_deg.asm
1051 lines (812 loc) · 16.6 KB
/
jst_deg.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
; *** JOTD HD Startup utility library
; *** Copyright Jean-Francois Fabre 1996-1998
;
; *** Sprite degrade part Copyright Bert Jahn 1996
XDEF AbsFun_Enhance
XDEF AbsFun_Priv_EnhanceCpu
XDEF AbsFun_Priv_EnhanceGfx
XDEF AbsFun_DegradeCpu
XDEF AbsFun_DegradeGfx
XDEF AbsFun_Degrade
XDEF AbsFun_FlushCachesSys
XDEF AbsFun_Kick37Test
XDEF AbsFun_KickVerTest
XDEF AbsFun_Priv_SetClockLoad
XDEF AbsFun_Priv_GetVBR
XDEF AbsFun_Priv_SendCDTVCommand
XDEF user_cacheflags
XDEF user_cachemask
XREF _GfxBase
XREF _DosBase
XREF RelocErr
XREF gene_variables
XREF AbsFun_AllocateTheMemory
XREF AbsFun_FreeTheMemory
XREF TaskCheck
XREF RelFun_ResetCIAs
XREF RelFun_WaitMouse
HDSTARTUP=1
;; Code below in jst_util.asm
;;ResetCIAs:
;; move.b #$c0,$bfd200 ;reinit CIAs
;; move.b #$ff,$bfd300 ;for
;; move.b #$03,$bfe201 ;KB
;; move.b #$00,$bfee01
;; move.b #$88,$bfed01
;; tst.b $bfdd00 ; acknowledge CIA-B Timer A interrupt
;; tst.b $bfed01 ; acknowledge CIA-A interrupts
;; bsr AckKeyboard
;; rts
;;AckKeyboard:
;; bset #$06,$BFEE01
;; STORE_REGS D0
;; moveq.l #1,D0
;; bsr RelFun_BeamDelay
;; RESTORE_REGS D0
;; bclr #$06,$BFEE01
;; rts
; *** this code is on its own (which is the case :-) )
_SysBase = 4
include "jst_libs.i"
include "gp_macros.i"
include "jstabs_macros.i"
include "jst_rel.i"
; *** Restore degraded things: Display, Caches, VBR...
; internal use (in InGameExitAbs)
move.l D0,A1
AbsFun_Enhance:
; the cpu stuff
bsr AbsFun_Priv_EnhanceCpu
; now the gfx stuff
bsr AbsFun_Priv_EnhanceGfx
rts
; var context is set
kill_vbi
TSTVAR_L execute_flag
bne.b .leave_vbi
; VBR is now zeroed, install our own interrupt
move.l a1,-(a7)
SETVAR_L $6C.W,old_vbi
lea dummy_vbl_handler(pc),a1
move.l a1,$6C
move.l (a7)+,a1
.leave_vbi
rts
restore_vbi
TSTVAR_L execute_flag
bne.b .leave_vbi
move.l a1,-(a7)
; vbi in case it was trashed
GETVAR_L old_vbi,a1
cmp.l #0,a1
beq.b .not_trashed
move.l a1,$6C.W
.not_trashed
move.l (a7)+,a1
.leave_vbi
rts
AbsFun_Priv_EnhanceCpu:
STORE_REGS
SET_VAR_CONTEXT
tst.b degraded_cpu
beq .skipec
TSTVAR_L execute_flag
beq.b .skipvbr
TSTVAR_L system_vbr
beq.b .skipvbr ; don't touch if already at 0
move.l _SysBase,A6
JSRLIB Disable
; restores VBR value
GETVAR_L system_vbr,D0
bsr SetVBR
; restores the zero page contents from the buffer
lea zeropage_buffer(pc),A0
lea $8.W,A1
move.l #$F8,D0
JSRGEN CopyMem
; flushes caches
JSRABS FlushCachesSys
move.l _SysBase,A6
JSRLIB Enable
.skipvbr
; restores caches
move.l oldcacheset(pc),D0
moveq.l #-1,D1
bsr EnaCaches
; ok not degraded anymore
clr.b degraded_cpu
.skipec
RESTORE_REGS
rts
AbsFun_Priv_EnhanceGfx:
STORE_REGS
SET_VAR_CONTEXT
tst.b degraded_gfx
beq .exit
bsr restore_vbi
move.l _GfxBase,D0
beq .1
lea $DFF000,A5
move.l my_copinit(PC),cop1lc(a5) ; adresse du début de la liste
; now that the copperlist is OK we restore the custom registers
; but not in the case of the EXECUTE option
TSTVAR_L execute_flag
bne.b .skip_custom_restore
JSRGEN RestoreCustomRegs
.skip_custom_restore:
move.l D0,A6
bsr EnhanceBandWidth
move.l my_actiview(PC),D0
beq.b .1
move.l D0,A1
JSRLIB LoadView
JSRLIB WaitTOF
JSRLIB WaitTOF
.1
move.l _IntuitionBase,D0
beq .skip
move.l D0,A6
move.l TheScreen,D0
beq .skip
bsr EnhanceSprites
move.l TheScreen,D0
move.l D0,A0
move.l TheScreen,A0
JSRLIB CloseScreen
bsr CloseIntuiLib
.skip
bsr CloseGFXLib
clr.b degraded_gfx
.exit
RESTORE_REGS
rts
DegradeBandWidth:
STORE_REGS
SET_VAR_CONTEXT
clr.b degraded_bdw
move.l (_GfxBase),a6
SETVAR_W (gb_system_bplcon0,A6),system_bplcon0
SETVAR_B (gb_ChipRevBits0,A6),system_chiprev_bits
cmp.l #39,(LIB_VERSION,a6)
blo .gfxold
btst #GFXB_AA_ALICE,(gb_ChipRevBits0,a6)
beq .noaga
move.b (gb_MemType,a6),oldbandwidth
move.b #BANDWIDTH_1X,(gb_MemType,a6) ;auf ECS Wert setzen
move.l #SETCHIPREV_A,D0
JSRLIB SetChipRev
move.l D0,oldchiprev
st degraded_bdw
.noaga
.gfxold
RESTORE_REGS
rts
EnhanceBandWidth:
STORE_REGS
tst.b degraded_bdw
beq .exit
move.l (_GfxBase),a6
move.l oldchiprev,D0
JSRLIB SetChipRev
move.b oldbandwidth,(gb_MemType,a6)
clr.b degraded_bdw
.exit
RESTORE_REGS
rts
AbsFun_DegradeCpu:
_DegradeCpu:
STORE_REGS
SET_VAR_CONTEXT
; no interrupts please
move.l _SysBase,A6
JSRLIB Disable
TSTVAR_L system_vbr
beq .skipzerovbr ; VBR is already at zero or 68000, skip all VBR part
; save the zero page vectors in a buffer
sub.l A0,A0
addq.l #$8,A0 ; starts at $8!
lea zeropage_buffer(pc),A1
move.l #$F8,D0
JSRGEN CopyMem
; copy VBR data to page zero
; (forget to copy $0 and $4 as FASTEXEC could mess it up!)
GETVAR_L system_vbr,A0
addq.l #8,A0
sub.l A1,A1
addq.l #8,A1
move.l #$F8,D0
JSRGEN CopyMem
; set the VBR to zero
bsr ZeroVBR
; cache flush
JSRABS FlushCachesSys
.skipzerovbr:
; enable interrupts again
move.l _SysBase,A6
JSRLIB Enable
RESTORE_REGS
bsr DisCaches
move.l D0,oldcacheset
move.b #$00,$DE0000 ; DTack (A3000/A4000 users)
st.b degraded_cpu
rts
zeropage_buffer:
BLKDECL b,$F8,0
AbsFun_DegradeGfx:
_DegradeGfx:
bsr OpenGFXLib
beq D_Exit
bsr OpenIntuiLib ; will fail on kickstart 1.3
move.l _IntuitionBase,D0
beq .skip
move.l D0,A6
sub.l a0,a0
lea ScreenTags,a1
JSRLIB OpenScreenTagList
move.l d0,TheScreen
; set sprite to common OCS resolution
move.l _GfxBase,A6
cmp.w #39,(LIB_VERSION,a6)
blo .skip
bsr DegradeSprites
.skip
move.l _DosBase,A6
move.l #20,D1
JSRLIB Delay ; wait 2/5 second before launching
move.l _GfxBase,A6
move.l gb_ActiView(A6),my_actiview
move.l gb_copinit(A6),my_copinit
sub.l A1,A1
JSRLIB LoadView
JSRLIB WaitTOF
JSRLIB WaitTOF
.wav
tst.l (gb_ActiView,a6)
bne.b .wav
JSRLIB WaitTOF
bsr DegradeBandWidth
JSRGEN ResetDisplay
; unless we're in "execute" mode, kill vertical blank
; interrupt as it writes to COP2LC (at least on kick 1.3)
bsr kill_vbi
; now adjust custom chips so AGA does not mess it all up
lea $DFF000,A5
; Panza Kick Boxing display was too large (some pixels missing)
move.w #$0,(bplcon1,A5) ; new from JST v4.7
move.w #$1200,(bplcon0,A5)
move.w #$0024,(bplcon2,A5)
move.w #$0,(bplcon3,A5)
move.w #$0,(bpl1mod,A5)
move.w #$0,(bpl2mod,A5)
; set blitter masks to all ones (Lemmings)
move.w #$FFFF,(bltafwm,A5)
move.w #$FFFF,(bltalwm,A5)
D_Exit:
st.b degraded_gfx
rts
; *** degrade the sprites
; *** thanks to Bert Jahn for the routine!!
DegradeSprites:
move.l TheScreen,A0
move.l (sc_ViewPort+vp_ColorMap,a0),a0
clr.l -(a7) ;TAG_DONE
clr.l -(a7)
move.l #VTAG_SPRITERESN_GET,-(a7)
move.l a7,a1
move.l _GfxBase,a6
JSRLIB VideoControl
addq.l #4,a7
lea oldspriteres,a0
move.l (a7)+,(a0)
addq.l #4,a7
move.l TheScreen,a0
move.l (sc_ViewPort+vp_ColorMap,a0),a0
clr.l -(a7) ;TAG_DONE
move.l #SPRITERESN_140NS,-(a7)
move.l #VTAG_SPRITERESN_SET,-(a7)
move.l a7,a1
JSRLIB VideoControl
lea (12,a7),a7
move.l TheScreen,a0
move.l _IntuitionBase,a6
JSRLIB MakeScreen ;force the changes
JSRLIB RethinkDisplay
st.b degraded_spr
rts
EnhanceSprites:
tst.b degraded_spr
beq .exit
move.l _GfxBase,A6
move.l TheScreen,a0
move.l (sc_ViewPort+vp_ColorMap,a0),a0
clr.l -(a7) ;TAG_DONE
move.l oldspriteres,-(a7)
move.l #VTAG_SPRITERESN_SET,-(a7)
move.l a7,a1
JSRLIB VideoControl
lea (12,a7),a7
move.l TheScreen,a0
move.l _IntuitionBase,a6
JSRLIB MakeScreen ;force the changes
clr.b degraded_spr
.exit
rts
; this handler allows to avoid that the system overwrites the second copperlist
; trashing display when OS is swapped to load data
; it doesn't prevent hard disk operations
; fortunately they don't depend on vertical blank or we would be screwed
dummy_vbl_handler:
move.w #$70,$DFF000+intena
rte
; *** Degrades everything
; in: D0,D1: value and mask for caches control
; (the same format as in CacheControl())
AbsFun_Degrade:
STORE_REGS
move.l D0,user_cacheflags
move.l D1,user_cachemask
bsr _DegradeCpu ; degrades caches, VBR, dtack
bsr _DegradeGfx ; degrades sprites and screen
jsr RelFun_ResetCIAs ; re-init keyboard
RESTORE_REGS
rts
DisCaches:
STORE_REGS D1-A6
SET_VAR_CONTEXT
move.l D0,D6
move.l D1,D7
JSRABS Kick37Test
tst.l D0
bne .3 ; Don't touch if KS 1.x
move.l D6,D0
move.l D7,D1
TSTVAR_L leavecaches_flag
bne .3 ; Don't touch the caches
TSTVAR_L nocaches_flag
beq .5 ; Disable ALL caches
moveq.l #0,D0
moveq.l #-1,D1
.5
move.l _SysBase,A6
JSRLIB CacheControl
move.l D0,D7
move.l _SysBase,A6
move.b AttnFlags+1(A6),D0
btst #AFB_68060,D0
beq .2
; *** remove data cache, branch cache, write cache, superscalar mode
lea DisCacheSup,A5
bsr MySupervisor
.2
move.l D7,D0
RESTORE_REGS D1-A6
rts
.3
moveq.l #0,D0
bra .2
EnaCaches:
STORE_REGS D1-A6
SET_VAR_CONTEXT
TSTVAR_L leavecaches_flag
bne .3 ; Don't touch the caches
move.l D0,D7
JSRABS Kick37Test
tst.l D0
bne .3 ; Don't touch if KS 1.x
move.l D7,D0
move.l _SysBase,A6
JSRLIB CacheControl
move.l D0,D7
move.l _SysBase,A6
move.b AttnFlags+1(A6),D0
btst #AFB_68060,D0
beq .2
lea EnaCacheSup,A5
bsr MySupervisor
.2
move.l D7,D0
RESTORE_REGS D1-A6
rts
.3
moveq.l #0,D0
bra .2
; *** Disable some '060 caches
; *** Left intact by CacheControl
; internal, only useful (and executed) for 68060 cpus
DisCacheSup:
MC68020
ori.w #$700,sr
movec cacr,D0
andi.l #$A0800000,D0
move.l D0,old060cacr
movec cacr,D0
move.l #$A0800000,D1 ; mask for specific 68060 caches
not.l D1
and.l D1,D0
movec D0,cacr
nop
; *** remove superscalar
bra .nossh
MC68060
movec pcr,D0
move.l D0,old060pcr
andi.l #$04300100,D0
movec D0,pcr
.nossh
; *** flush
CPUSHA BC
MC68000
rte
; *** Enable some '060 caches
; *** Left intact by CacheControl
EnaCacheSup:
MC68060
ori.w #$700,sr
movec cacr,D0
or.l old060cacr,D0
movec D0,cacr
bra .nossh
movec pcr,D0
or.l old060pcr,D0
movec D0,pcr
.nossh
CPUSHA BC
MC68000
rte
; *** Gets VBR value
; out: D0: VBR value
; VBR is the vector base register (interrupts, traps, exceptions)
; It exists on 68010, 68020, 68030, 68040, 68060
; Most of the games don't like it to be different from zero,
; others are originally HD-Installable :-)
; Called from a 68000, this function will return 0 in any case (no VBR)
AbsFun_Priv_GetVBR:
STORE_REGS A0
lea GetVBRSup(pc),A0
bsr OperateVBR_SYS
RESTORE_REGS A0
rts
; *** Sets VBR value
; in: D0: new VBR value
; Called from a 68000, this function will do nothing (no VBR)
; It will do nothing if the LEAVEVBR tooltype is set too (debug)
SetVBR:
STORE_REGS A0
lea SetVBRSup(pc),A0
bsr OperateVBR_HW
RESTORE_REGS A0
rts
; *** Sets VBR to zero
; It will do nothing if the LEAVEVBR tooltype is set (debug)
ZeroVBR:
STORE_REGS D1-A6
moveq.l #0,D0
lea SetVBRSup(pc),A0
bsr OperateVBR_SYS
RESTORE_REGS D1-A6
rts
; *** VBR operation
; < D0: optional param
; > D0: optional out
; < A0: routine to be called in supervisor mode
; VBR must be at 0 for this one
OperateVBR_HW:
STORE_REGS D1-D7/A0-A6
move.l _SysBase,A6
move.b AttnFlags+1(A6),D1
btst #AFB_68010,D1 ; At least 68010
beq .error
move.l $80.W,D4
move.l A0,$80.W
TRAP #0
move.l D4,$80.W
.exit
RESTORE_REGS D1-D7/A0-A6
rts
.error
moveq.l #0,D0
bra .exit
; *** VBR operation
; < D0: optional param
; > D0: optional out
; < A0: routine to be called in supervisor mode
OperateVBR_SYS:
STORE_REGS D1-D7/A0-A6
move.l A0,A5 ; supervisor function
move.l _SysBase,A6
move.b AttnFlags+1(A6),D1
btst #AFB_68010,D1 ; At least 68010
beq .error
bsr MySupervisor
.exit
RESTORE_REGS D1-D7/A0-A6
rts
.error
moveq.l #0,D0
bra .exit
; *** Supervisor call to set the VBR
SetVBRSup:
STORE_REGS A4
SET_VAR_CONTEXT
TSTVAR_L leavevbr_flag
bne .exit
CHANGEVBR D0
.exit
RESTORE_REGS A4
rte
; *** Supervisor call to get the VBR
GetVBRSup:
MC68010
movec VBR,D0
MC68000
rte
; *** open graphics library
OpenGFXLib:
STORE_REGS D1-A6
lea grname,A1
move.l _SysBase,A6
moveq.l #0,D0
JSRLIB OpenLibrary
move.l D0,_GfxBase
RESTORE_REGS D1-A6
rts
; *** close graphics library
CloseGFXLib:
STORE_REGS D0-A6
move.l _SysBase,A6
move.l _GfxBase,D0
beq .skip
move.l D0,A1
JSRLIB CloseLibrary
clr.l _GfxBase
.skip
RESTORE_REGS D0-A6
rts
; *** open intuition library
OpenIntuiLib:
STORE_REGS D1-A6
lea intname,A1
move.l _SysBase,A6
moveq.l #36,D0
JSRLIB OpenLibrary
move.l D0,_IntuitionBase
RESTORE_REGS D1-A6
rts
; *** close intuition library
CloseIntuiLib:
STORE_REGS D0-A6
move.l _SysBase,A6
move.l _IntuitionBase,D0
beq .skip
move.l D0,A1
JSRLIB CloseLibrary
clr.l _IntuitionBase
.skip
RESTORE_REGS D0-A6
rts
; *** Flushes the caches
AbsFun_FlushCachesSys:
STORE_REGS
JSRABS Kick37Test
tst.l D0
bne .2 ; Don't touch if KS 1.x
moveq.l #0,D0
moveq.l #0,D1
move.l _SysBase,A6
JSRLIB CacheControl
.2
RESTORE_REGS
rts
; *** Test ROM version
; out: D0=0 if KS>=37
; D0!=0 if KS<37
AbsFun_Kick37Test:
move.l #37,D0
JSRABS KickVerTest
rts
; *** Test if ROM version > a given version
; in: D0: kickstart version number
; out:D0=0 newer !=0 older
; This was broken since v4.5d, but now it should work
AbsFun_KickVerTest:
STORE_REGS D1/A5/A6
move.l _SysBase,A6
move.w LIB_VERSION(A6),D1 ; exec library version
cmp.w D0,D1
bcc.s .newer
moveq.l #-1,D0
.exit
RESTORE_REGS D1/A5/A6
rts
.newer
moveq.l #0,D0
bra.b .exit
; ** update system time from battery backed up clock
AbsFun_Priv_SendCDTVCommand:
STORE_REGS
move.l d0,d5
; alloc some mem for IORequest
MOVEQ #40,D0
MOVE.L #MEMF_CLEAR|MEMF_PUBLIC,D1
move.l _SysBase,A6
JSRABS AllocateTheMemory
move.l D0,io_request
beq .Quit
; open cdtv.device
MOVEA.L D0,A1
LEA cdtvname(PC),A0 ; name
MOVEQ #0,D0 ; unit 0
MOVE.L D0,D1 ; flags
JSRLIB OpenDevice
move.l D0,D6
ext D6
ext.l D6
bne .Quit ; unable to open
; wait a while if CMD_STOP
cmp.l #CMD_STOP,d5
bne.b .nowait
move.l _DosBase,A6
move.l #20,D1
JSRLIB Delay ; wait 2/5 second before launching
.nowait
; prepare the IORequest structure
MOVEQ #0,D0
MOVEA.L io_request(pc),A0
MOVE.B D0,8(A0)
MOVE.B D0,9(A0)
SUBA.L A1,A1
MOVE.L A1,10(A0)
MOVE.L A1,14(A0)
CLR.L 36(A0)
move.l io_request(pc),A0
move.l A0,A1
move.w d5,(IO_COMMAND,a1)
move.l _SysBase,A6
JSRLIB DoIO
.Quit:
; close cdtv.device if open
tst.l D6
bne .Free
MOVE.L io_request(pc),D1
beq .End
move.l D1,A1
move.l _SysBase,A6
JSRLIB CloseDevice
.Free:
; free the memory
MOVEQ #40,D0
move.l io_request(pc),A1
move.l _SysBase,A6
JSRABS FreeTheMemory
.End:
RESTORE_REGS
rts
AbsFun_Priv_SetClockLoad:
STORE_REGS
moveq.l #0,D6
not.l D6
; open battclock.resource
lea battname(pc),A1
move.l _SysBase,A6
JSRLIB OpenResource
move.l D0,BattBase
beq SCL_End
; alloc some mem for IORequest
MOVEQ #40,D0
MOVE.L #MEMF_CLEAR|MEMF_PUBLIC,D1
move.l _SysBase,A6
JSRABS AllocateTheMemory
move.l D0,io_request
beq SCL_Quit
; open timer.device
MOVEA.L D0,A1
LEA timername(PC),A0 ; name
MOVEQ #0,D0 ; unit 0
MOVE.L D0,D1 ; flags
JSRLIB OpenDevice
move.l D0,D6
ext D6
ext.l D6
bne SCL_Quit ; unable to open
; prepare the IORequest structure
MOVEQ #0,D0
MOVEA.L io_request(pc),A0
MOVE.B D0,8(A0)
MOVE.B D0,9(A0)
SUBA.L A1,A1
MOVE.L A1,10(A0)
MOVE.L A1,14(A0)
CLR.L 36(A0)
move.l BattBase(pc),A6
JSRLIB ReadBattClock
move.l io_request(pc),A0
move.l D0,32(A0) ; D0 was read from battclock
move.w #$B,28(A0)
move.l A0,A1
move.l _SysBase,A6
JSRLIB DoIO
SCL_Quit:
; close timer.device if open
tst.l D6
bne SCL_Free
MOVE.L io_request(pc),D1
beq SCL_End
move.l D1,A1
move.l _SysBase,A6
JSRLIB CloseDevice
SCL_Free:
; free the memory
MOVEQ #40,D0
move.l io_request(pc),A1
move.l _SysBase,A6
JSRABS FreeTheMemory
SCL_End:
RESTORE_REGS
rts
; < A5: user routine to call in supervisor mode
MySupervisor:
move.l TaskCheck,-(A7)
move.l _SysBase,A6
JSRLIB Supervisor
move.l (A7)+,TaskCheck
rts
io_request:
dc.l 0
my_actiview:
dc.l 0
my_copinit:
dc.l 0
oldcacheset:
dc.l 0
old060cacr:
dc.l 0
old060pcr:
dc.l 0
cache_value:
dc.l 0
cache_mask:
dc.l 0