[4f508e6] | 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 | | ------------------------------------------------------------------------------
|
---|
[8325447] | 17 | .xdef vbank
|
---|
| 18 | .xdef vfwait
|
---|
[4f508e6] | 19 |
|
---|
[8325447] | 20 | .xref v_regs
|
---|
[4f508e6] | 21 |
|
---|
[f40a309] | 22 | .text
|
---|
[4f508e6] | 23 |
|
---|
| 24 | B = 8
|
---|
| 25 |
|
---|
| 26 | OLDB = d6
|
---|
| 27 | NEWB = d7
|
---|
| 28 |
|
---|
| 29 | VSDD_R5 = 10
|
---|
| 30 | VSDD_R11 = 22
|
---|
| 31 |
|
---|
| 32 | VT_BASE = 128 | word offset of VSDD Access Table
|
---|
| 33 |
|
---|
| 34 | VT_1 = VT_BASE+300 | high time
|
---|
| 35 | VT_2 = VT_BASE+2 | low time
|
---|
| 36 |
|
---|
[f40a309] | 37 | .page
|
---|
[4f508e6] | 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 |
|
---|
[8325447] | 44 | vbank: link a6,#0 | link stack frames
|
---|
[4f508e6] | 45 | movem.l d5-d7,-(sp) | preserve registers
|
---|
[8325447] | 46 | move.w v_regs+VSDD_R5,OLDB | get v_regs[5]
|
---|
[4f508e6] | 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
|
---|
[f40a309] | 59 | bra L1
|
---|
[4f508e6] | 60 |
|
---|
| 61 | L2: 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 | ...
|
---|
[8325447] | 68 | move.w d0,v_regs+VSDD_R5 | set v_regs[5] with new BS bits
|
---|
[4f508e6] | 69 |
|
---|
[8325447] | 70 | vw1b: cmp.w #VT_1,v_regs+VSDD_R11 | wait for FRAMESTOP
|
---|
[4f508e6] | 71 | bcc vw1b | ...
|
---|
| 72 |
|
---|
[8325447] | 73 | vw2b: cmp.w #VT_1,v_regs+VSDD_R11 | ...
|
---|
[4f508e6] | 74 | bcs vw2b | ...
|
---|
| 75 |
|
---|
[8325447] | 76 | vw3b: cmp.w #VT_1,v_regs+VSDD_R11 | ...
|
---|
[4f508e6] | 77 | bcc vw3b | ...
|
---|
| 78 |
|
---|
[8325447] | 79 | vw4b: cmp.w #VT_2,v_regs+VSDD_R11 | ...
|
---|
[4f508e6] | 80 | bcs vw4b | ...
|
---|
| 81 |
|
---|
| 82 | move.w OLDB,d0 | setup to return OLDB
|
---|
| 83 |
|
---|
| 84 | L1: 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 |
|
---|
[f40a309] | 89 | .page
|
---|
[4f508e6] | 90 |
|
---|
| 91 | | ------------------------------------------------------------------------------
|
---|
| 92 | | vfwait() -- Wait for a FRAMESTOP update to transpire.
|
---|
| 93 | | ------------------------------------------------------------------------------
|
---|
| 94 |
|
---|
[8325447] | 95 | vfwait: link a6,#0 | link stack frames
|
---|
[4f508e6] | 96 |
|
---|
[8325447] | 97 | vw1a: cmp.w #VT_1,v_regs+VSDD_R11 | wait for FRAMESTOP
|
---|
[4f508e6] | 98 | bcc vw1a | ...
|
---|
| 99 |
|
---|
[8325447] | 100 | vw2a: cmp.w #VT_1,v_regs+VSDD_R11 | ...
|
---|
[4f508e6] | 101 | bcs vw2a | ...
|
---|
| 102 |
|
---|
[8325447] | 103 | vw3a: cmp.w #VT_1,v_regs+VSDD_R11 | ...
|
---|
[4f508e6] | 104 | bcc vw3a | ...
|
---|
| 105 |
|
---|
[8325447] | 106 | vw4a: cmp.w #VT_2,v_regs+VSDD_R11 | ...
|
---|
[4f508e6] | 107 | bcs vw4a | ...
|
---|
| 108 |
|
---|
| 109 | unlk a6 | unlink stack frames
|
---|
| 110 | rts | return to caller
|
---|
| 111 |
|
---|
[f40a309] | 112 | .end
|
---|