]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blame - cbios/move.180
time and date allways from server. 1.25ms interrupt
[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
3735c546
L
52 out0 (bcr0l),c ; setup DMA count
53 out0 (bcr0h),b
ea5293bb 54
04d6fc24
L
55 push hl
56 push de
ea5293bb
L
57 ld a,(src$bnk)
58 call bnk2phy
ea5293bb
L
59 out0 (sar0l),l ; setup DMA src address
60 out0 (sar0h),h
61 out0 (sar0b),a
62
ea5293bb
L
63 ex de,hl
64 ld a,(dst$bnk)
65 call bnk2phy
ea5293bb
L
66 out0 (dar0l),l ; setup DMA dst address
67 out0 (dar0h),h
68 out0 (dar0b),a
69
70 ld a,M_MMOD ; DMA burst mode
71 out0 (dmode),a
ea5293bb
L
72 ld a,M_DE0+M_NDWE1 ; enable DMA0
73 out0 (dstat),a ; move the block
74
ea5293bb 75 pop de
04d6fc24 76 pop hl
ea5293bb
L
77 add hl,bc ; src must point past end block
78 ex de,hl
79 add hl,bc ; and so must dst
80 ld bc,0
81
82 ld a,0FEh
83 ld (src$bnk),a
84
85 ret ; return with src in DE, dst in HL, count = 0
86
3735c546 87 else ; inefficient fall back
ea5293bb
L
88
89 ld (tmp$sp),sp
90 ld sp,tmp$stk
91 ex af,af' ;
92 push af
93mv$blk:
94 ld a,(src$bnk) ;
95 call ?bank
96 ld a,(hl)
97 ex af,af' ;
98 ld a,(dst$bnk)
99 call ?bank
100 ex af,af' ;
101 ld (de),a
ea5293bb 102 inc de
c8d8d7db
L
103 cpi
104 jp pe,mv$blk
ea5293bb
L
105 ld a,(@cbnk)
106 call ?bank
107 ld a,0FEh
108 ld (src$bnk),a
109 ex de,hl
110 pop af
111 ex af,af' ;
112 ld sp,(tmp$sp)
113 ret
114
115 ds 16
116tmp$stk:
117tmp$sp: ds 2
118
c5868b68 119 endif
ea5293bb
L
120
121src$bnk: db 0FEh
122dst$bnk: db 0FEh
123
124
c5868b68 125 endif ;banked
ea5293bb
L
126
127 end