]>
Commit | Line | Data |
---|---|---|
1 | title 'Bank & Move Module for the Modular CP/M 3 BIOS'\r | |
2 | \r | |
3 | ; CP/M-80 Version 3 -- Modular BIOS\r | |
4 | ; Bank and Move Module for Z180-Stamp\r | |
5 | ; Initial version 1.0\r | |
6 | ; Compile with M80, slr180, or compatible\r | |
7 | \r | |
8 | public ?move,?xmove,?bank\r | |
9 | \r | |
10 | extrn bnk2log,bnk2phy\r | |
11 | extrn @cbnk\r | |
12 | \r | |
13 | \r | |
14 | maclib z180reg.inc\r | |
15 | maclib config.inc\r | |
16 | \r | |
17 | \r | |
18 | cseg ; must be in common memory\r | |
19 | \r | |
20 | ?xmove:\r | |
21 | if banked\r | |
22 | ld (src$bnk),bc ; c -> src$bnk, b -> dst$bnk\r | |
23 | endif\r | |
24 | ret\r | |
25 | \r | |
26 | ?move:\r | |
27 | ex de,hl ; we are passed source in DE and dest in HL\r | |
28 | if banked\r | |
29 | ld a,(src$bnk) ; contains 0FEh if normal block move\r | |
30 | cp 0FEh\r | |
31 | jr nz,inter_bank_move\r | |
32 | endif\r | |
33 | ldir ; use Z80 block move instruction\r | |
34 | ex de,hl ; need next address in same regs\r | |
35 | ret\r | |
36 | \r | |
37 | ; select bank in A\r | |
38 | \r | |
39 | ?bank:\r | |
40 | if banked\r | |
41 | call bnk2log\r | |
42 | out0 (bbr),a\r | |
43 | endif\r | |
44 | ret\r | |
45 | \r | |
46 | if banked\r | |
47 | \r | |
48 | inter_bank_move: ; source in HL, dest in DE, count in BC\r | |
49 | \r | |
50 | if 1 ; works with new memory map\r | |
51 | \r | |
52 | out0 (bcr0l),c ; setup DMA count\r | |
53 | out0 (bcr0h),b\r | |
54 | \r | |
55 | push hl\r | |
56 | push de\r | |
57 | ld a,(src$bnk)\r | |
58 | call bnk2phy\r | |
59 | out0 (sar0l),l ; setup DMA src address\r | |
60 | out0 (sar0h),h\r | |
61 | out0 (sar0b),a\r | |
62 | \r | |
63 | ex de,hl\r | |
64 | ld a,(dst$bnk)\r | |
65 | call bnk2phy\r | |
66 | out0 (dar0l),l ; setup DMA dst address\r | |
67 | out0 (dar0h),h\r | |
68 | out0 (dar0b),a\r | |
69 | \r | |
70 | ld a,M_MMOD ; DMA burst mode\r | |
71 | out0 (dmode),a\r | |
72 | ld a,M_DE0+M_NDWE1 ; enable DMA0\r | |
73 | out0 (dstat),a ; move the block\r | |
74 | \r | |
75 | pop de\r | |
76 | pop hl\r | |
77 | add hl,bc ; src must point past end block\r | |
78 | ex de,hl\r | |
79 | add hl,bc ; and so must dst\r | |
80 | ld bc,0\r | |
81 | \r | |
82 | ld a,0FEh\r | |
83 | ld (src$bnk),a\r | |
84 | \r | |
85 | ret ; return with src in DE, dst in HL, count = 0\r | |
86 | \r | |
87 | else ; inefficient fall back\r | |
88 | \r | |
89 | ld (tmp$sp),sp\r | |
90 | ld sp,tmp$stk\r | |
91 | ex af,af' ;\r | |
92 | push af\r | |
93 | mv$blk:\r | |
94 | ld a,(src$bnk) ;\r | |
95 | call ?bank\r | |
96 | ld a,(hl)\r | |
97 | ex af,af' ;\r | |
98 | ld a,(dst$bnk)\r | |
99 | call ?bank\r | |
100 | ex af,af' ;\r | |
101 | ld (de),a\r | |
102 | inc de\r | |
103 | cpi\r | |
104 | jp pe,mv$blk\r | |
105 | ld a,(@cbnk)\r | |
106 | call ?bank\r | |
107 | ld a,0FEh\r | |
108 | ld (src$bnk),a\r | |
109 | ex de,hl\r | |
110 | pop af\r | |
111 | ex af,af' ;\r | |
112 | ld sp,(tmp$sp)\r | |
113 | ret\r | |
114 | \r | |
115 | ds 16\r | |
116 | tmp$stk:\r | |
117 | tmp$sp: ds 2\r | |
118 | \r | |
119 | endif\r | |
120 | \r | |
121 | src$bnk: db 0FEh\r | |
122 | dst$bnk: db 0FEh\r | |
123 | \r | |
124 | \r | |
125 | endif ;banked\r | |
126 | \r | |
127 | end\r |