source: buchla-68k/vlib/vbank.s@ bbf1e66

Last change on this file since bbf1e66 was 8325447, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Removed _ prefix.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1| ------------------------------------------------------------------------------
2| vbank.s -- VSDD bank switching control functions
3| Version 3 -- 1989-12-19 -- D.N. Lynx Crowe
4
5| unsigned
6| vbank(b)
7| unsigned b;
8
9| Set VSDD Data Segment bank to b.
10| Return old bank select value.
11
12
13| vfwait()
14
15| Wait for a FRAMESTOP update to transpire.
16| ------------------------------------------------------------------------------
17 .xdef vbank
18 .xdef vfwait
19
20 .xref v_regs
21
22 .text
23
24B = 8
25
26OLDB = d6
27NEWB = d7
28
29VSDD_R5 = 10
30VSDD_R11 = 22
31
32VT_BASE = 128 | word offset of VSDD Access Table
33
34VT_1 = VT_BASE+300 | high time
35VT_2 = VT_BASE+2 | low time
36
37 .page
38| ------------------------------------------------------------------------------
39| vbank(b) -- change VSDD Data Segment bank to b. Return old bank.
40| Assumes a 128K byte window, sets S15..S11 to zero.
41| ------------------------------------------------------------------------------
42
43
44vbank: link a6,#0 | link stack frames
45 movem.l d5-d7,-(sp) | preserve registers
46 move.w v_regs+VSDD_R5,OLDB | get v_regs[5]
47 lsr.w #6,OLDB | extract BS bits
48 move.w OLDB,d0 | ...
49 andi.w #2,d0 | ...
50 move.w OLDB,d1 | ...
51 lsr.w #2,d1 | ...
52 andi.w #1,d1 | ...
53 or.w d1,d0 | ...
54 move.w d0,OLDB | ...
55 cmp.w B(a6),OLDB | see if they're what we want
56 bne L2 | jump if not
57
58 move.w B(a6),d0 | setup to return b
59 bra L1
60
61L2: move.w B(a6),NEWB | get bank bits from b
62 lsl.w #6,NEWB | shift bits from b into BS bits
63 move.w NEWB,d0 | ...
64 andi.w #128,d0 | ...
65 lsl.w #2,NEWB | ...
66 andi.w #256,NEWB | ...
67 or.w NEWB,d0 | ...
68 move.w d0,v_regs+VSDD_R5 | set v_regs[5] with new BS bits
69
70vw1b: cmp.w #VT_1,v_regs+VSDD_R11 | wait for FRAMESTOP
71 bcc vw1b | ...
72
73vw2b: cmp.w #VT_1,v_regs+VSDD_R11 | ...
74 bcs vw2b | ...
75
76vw3b: cmp.w #VT_1,v_regs+VSDD_R11 | ...
77 bcc vw3b | ...
78
79vw4b: cmp.w #VT_2,v_regs+VSDD_R11 | ...
80 bcs vw4b | ...
81
82 move.w OLDB,d0 | setup to return OLDB
83
84L1: tst.l (sp)+ | fixup stack
85 movem.l (sp)+,OLDB-NEWB | restore registers
86 unlk a6 | unlink stack frames
87 rts | return to caller
88
89 .page
90
91| ------------------------------------------------------------------------------
92| vfwait() -- Wait for a FRAMESTOP update to transpire.
93| ------------------------------------------------------------------------------
94
95vfwait: link a6,#0 | link stack frames
96
97vw1a: cmp.w #VT_1,v_regs+VSDD_R11 | wait for FRAMESTOP
98 bcc vw1a | ...
99
100vw2a: cmp.w #VT_1,v_regs+VSDD_R11 | ...
101 bcs vw2a | ...
102
103vw3a: cmp.w #VT_1,v_regs+VSDD_R11 | ...
104 bcc vw3a | ...
105
106vw4a: cmp.w #VT_2,v_regs+VSDD_R11 | ...
107 bcs vw4a | ...
108
109 unlk a6 | unlink stack frames
110 rts | return to caller
111
112 .end
Note: See TracBrowser for help on using the repository browser.