Raw File
1 ; _____________________________________________
2 ; | |
3 ; | Project: APPLER |
4 ; | File: MEMORY.ASM |
5 ; | Compiler: 16-bit TASM (2.5) |
6 ; | |
7 ; | Subject: Memory Emulation |
8 ; | |
9 ; | Author: Alexander Patalenski |
10 ; |_____________________________________________|
11
12 include GLOBALS.INC
13 include INTERFAC.INC
14
15 Emulate segment common
16 assume CS:Emulate,DS:Apple,ES:Video,SS:Data
17
18 WriteNA MACRO
19 DoNext
20 ENDM
21
22 ;-------------------------------------------------------------------------------
23
24 WriteRAM MACRO
25 mov [di],bh
26 DoNext
27 ENDM
28
29 ;-------------------------------------------------------------------------------
30
31 WriteROM MACRO
32 DoNext
33 ENDM
34
35 ;-------------------------------------------------------------------------------
36
37 WriteDRAM MACRO
38 Local WriteOnly,DoNotWrite
39 ;;------------------------------------------------------\
40 IFNDEF DRAM_ModefyAdr ;;
41 DRAM_ModefyAdr label word ;;
42 DRAM_ReadWrite = 3D88h ;; mov [di],bh
43 DRAM_WriteOnly = 0EBh + (WriteOnly -$-2)*100h ;; jmp short WriteOnly
44 DRAM_DoNotWrite = 0EBh + (DoNotWrite-$-2)*100h ;; jmp short DoNotWrite
45 ENDIF ;;
46 dw DRAM_WriteOnly ;;
47 ;;------------------------------------------------------/
48 ;;ReadWrite: mov [di],bh
49 DoNext
50 WriteOnly: mov SS:DRAM[di-0D000h],bh
51 DoNotWrite: DoNext
52 ENDM
53
54 ;-------------------------------------------------------------------------------
55
56 WriteTEXT MACRO Page
57 Local TextMode,GrMode,MixedGrMode,MixedHgrMode,L10
58 VideoPage = Page/4 ;; 1 or 2
59 ;;------------------------------------------------------\
60 IFNDEF TEXT_ModefyAdr ;;
61 TEXT_ModefyAdr label word ;;
62 TEXT_TextMode = 0EBh + (TextMode -$-2)*100h ;; jmp short TextMode
63 TEXT_GrMode = 0EBh + (GrMode -$-2)*100h ;; jmp short GrMode
64 TEXT_MixedGrMode= 0EBh + (MixedGrMode -$-2)*100h ;; jmp short MixedGrMode
65 TEXT_MixedHgrMode= 0EBh + (MixedHgrMode-$-2)*100h ;; jmp short MixedHgrMode
66 TEXT_NA = 3D88h ;; mov [di],bh
67 ENDIF ;;
68 IF VideoPage EQ 1 ;;
69 dw TEXT_GrMode ;;
70 ELSE ;;
71 dw TEXT_NA ;;
72 ENDIF ;;
73 ;;------------------------------------------------------/
74 ;; mov [di],bh
75 DoNext
76 TextMode: mov [di],bh
77 lahf
78 shl di,1
79 mov di,SS:TEXTadr[di-2*VideoPage*400h]
80 L10: xchg bl,bh
81 shl bx,1
82 sahf
83 mov ax,SS:TEXTchars[bx]
84 stosw
85 mov bl,0
86 DoNext
87 GrMode: mov [di],bh
88 lahf
89 shl di,1
90 mov di,SS:TEXTadr[di-2*VideoPage*400h]
91 inc di
92 sahf
93 mov al,bh
94 mov bx,offset GRcolors
95 xlat SS:[bx]
96 stosb
97 mov bl,0
98 DoNext
99 MixedGrMode: mov [di],bh
100 lahf
101 shl di,1
102 mov di,SS:TEXTadr[di-2*VideoPage*400h]
103 cmp di,20*40*2
104 jae L10
105 inc di
106 sahf
107 mov al,bh
108 mov bx,offset GRcolors
109 xlat SS:[bx]
110 stosb
111 mov bl,0
112 DoNext
113 MixedHgrMode: mov [di],bh
114 IFE VideoPage - 1
115 jmp MixedHgrMode1
116 ELSE
117 jmp MixedHgrMode2
118 ENDIF
119 ENDM
120
121 ;-------------------------------------------------------------------------------
122
123 WriteHGR MACRO Page
124 Local HgrMode,MixedMode,L10,L20
125 VideoPage = Page/20h ;; 1 or 2
126 VideoPageAdr = (VideoPage-1)*4000h ;; 0 or 4000h
127 ;;------------------------------------------------------\
128 IFNDEF HGR_ModefyAdr ;;
129 HGR_ModefyAdr label word ;;
130 HGR_HgrMode = 0EBh + (HgrMode -$-2)*100h ;; jmp short HgrMode
131 HGR_MixedMode = 0EBh + (MixedMode-$-2)*100h ;; jmp short MixedMode
132 HGR_NA = 3D88h ;; mov [di],bh
133 ENDIF ;;
134 dw HGR_NA ;;
135 ;;------------------------------------------------------/
136 ;; mov [di],bh
137 jmp near ptr L20
138 ; DoNext
139 L10: sahf
140 mov [di],bh
141 jmp near ptr L20
142 ; DoNext
143 MixedMode: mov ax,di
144 lahf
145 shl al,1
146 cmp al,2*40*2
147 jae L10
148 sahf
149 HgrMode: mov [di],bh
150 Save cx
151 mov ax,di
152 lahf
153 shl di,1
154 mov di,SS:HGRadr[di-2*VideoPage*2000h]
155 mov bl,bh
156 mov bh,al
157 and bh,00000011b
158 shl bx,1
159 mov cx,SS:HGRcolors[bx]
160 mov bx,SS:HGRmasks [bx]
161 mov al,ES:[VideoPageAdr][di]
162 and al,bh
163 xor al,ch
164 and ch,bh
165 xor al,ch
166 mov ES:[VideoPageAdr][di],al
167 shl bh,2
168 not bh
169 and bx,ES:[VideoPageAdr][di+1]
170 or cx,bx
171 mov ES:[VideoPageAdr][di+1],cx
172 sahf
173 Restore cx
174 mov bl,0
175 L20: DoNext
176 ENDM
177
178 ;-------------------------------------------------------------------------------
179
180 WriteIO MACRO
181 mov ax,di
182 lahf
183 and di,00FFh
184 shl di,1 ;; AH - flags NZ, AL - Address
185 jmp SS:C0XXWrite[di] ;; BH - save value
186 ENDM
187
188 ;===============================================================================
189
190 MemPage MACRO FromPage,ToPage,Type
191 Temp = FromPage
192 REPT ToPage+1 - FromPage
193 WriteMem Temp
194 IF 0; (Temp GE 20h) and (Temp LT 60h)
195 call synchronize
196 ENDIF
197 Write&Type Temp
198 CheckAddress ;<Type %Temp>
199 Temp = Temp+1
200 ENDM
201 ENDM
202
203 ;-------------------------------------------------------------------------------
204
205 MemPage 00h,03h,RAM
206 MemPage 04h,0Bh,TEXT
207 MemPage 0Ch,1Fh,RAM
208
209 MemPage 20h,5Fh,HGR
210
211 MemPage 060h,0BFh,RAM
212
213 MemPage 0C0h,0C0h,IO
214 MemPage 0C1h,0C1h,NA
215 MemPage 0C2h,0C2h,NA
216 MemPage 0C3h,0C3h,NA
217 MemPage 0C4h,0C4h,NA
218 MemPage 0C5h,0C5h,NA
219 MemPage 0C6h,0C6h,ROM
220 MemPage 0C7h,0C7h,NA
221
222 MemPage 0C8h,0CFh,RAM
223
224 MemPage 0D0h,0FFh,DRAM
225
226 Emulate ends
227
228 End
229
Generated by GNU Enscript 1.6.6, and GophHub 1.3.