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