@@ -34,9 +34,9 @@ MEMF_REPLAY equ (1<<14)
34
34
VERSION = 1
35
35
REVISION = 6
36
36
37
- dc.b 0 ,'$VER: AddReplayMem 1 .6 ( 14 .2 .2020 ) Replay XRAM',0
37
+ dc.b 0 ,'$VER: AddReplayMem 1 .7 ( 19 .2 .2020 ) Replay XRAM',0
38
38
even
39
- VERSTRING dc.b 'AddReplayMem 1 .6 ( 14 .2 .2020 ) Replay XRAM',13 ,10 ,0
39
+ VERSTRING dc.b 'AddReplayMem 1 .7 ( 19 .2 .2020 ) Replay XRAM',13 ,10 ,0
40
40
even
41
41
42
42
cnop 0 ,4
@@ -54,13 +54,16 @@ romtag: dc.w RTC_MATCHWORD
54
54
tagname: dc.b 'AddReplayMem',0
55
55
even
56
56
57
+ MIN_ROM_SIZE = (4 *1024 )
58
+ MAX_ROM_SIZE = (1024 *1024 )
57
59
58
60
cnop 0 ,4
59
61
S:
60
62
kprintf "INIT: %s" ,#VERSTRING
61
63
62
64
movem .l d2 -d6 /a2 -a6 ,-(sp )
63
65
66
+ ; 1.7 - Add a dummy memory node for the $00F0.0000 replay.rom memory region (to prevent mmu.library cache-inhibit state)
64
67
; 1.6 - Fix memory trashing when probing; Change to RTF_SINGLETASK (before Exec); Add logging
65
68
; 1.5 - Make ROMable
66
69
; 1.4 - Add console logging; Fix building with vasm.
69
72
; 1.1 - Detect 24 bit (000/010/EC020) memory space (by detecting mirroring of CHIP above the 16M barrier)
70
73
; 1.0 - Probe memory to make sure it's actually present
71
74
72
- ; Check if already registered
75
+ ; Check if ROM is mapped as RAM
73
76
movea.l $4 .w,a6
77
+ lea $00f01000 ,a1
78
+ jsr _LVOTypeOfMem (a6 )
79
+ tst .l d0
80
+ bne .already_mapped
81
+
82
+ bsr MapROMasRAM
83
+ tst .l d0
84
+ bmi .quit_checksum
85
+
86
+ kprintf <" rom is %ld bytes" ,10 >,d0
87
+
88
+ .already_mapped
89
+
90
+ ; Check if already registered
74
91
lea $01001000 ,a1
75
92
jsr _LVOTypeOfMem (a6 )
76
93
tst .l d0
197
214
lea memory_added(pc ),a5
198
215
bra.b .quit
199
216
217
+ .quit_checksum lea checksum_failed(pc ),a5
218
+ bra.b .quit
200
219
.quit_present lea already_there(pc ),a5
201
220
bra.b .quit
202
221
.quit_24bit lea cpu_is_24bit(pc ),a5
229
248
230
249
name dc.b 'replay xram memory',0
231
250
name_end
251
+ romname dc.b 'replay.rom memory',0
252
+ romname_end
232
253
dos dc.b 'dos.library',0
254
+ checksum_failed dc.b 'rom checksum failed',10 ,0
233
255
already_there dc.b 'memory is already available',10 ,0
234
256
cpu_is_24bit dc.b 'cpu uses a 24bit address bus (68000 /010 /EC020)',10 ,0
235
257
probing_failed dc.b 'memory probing failed',10 ,0
236
258
alloc_failed dc.b 'memory allocation failed',10 ,0
237
259
memory_added dc.b 'memory region added',10 ,0
238
260
261
+ cnop 0 ,4
262
+
263
+ MapROMasRAM:
264
+ ; Find replay ROM size
265
+ lea $00f00000 ,a0
266
+ move.l #MIN_ROM_SIZE,d0
267
+ move.l #MAX_ROM_SIZE,d1
268
+
269
+ ; a0.l = ROM start
270
+ ; d0.l = start ROM size (16 bytes min)
271
+ ; d1.l = end ROM size (1MB max)
272
+
273
+ move.l d0 ,d7
274
+ moveq #0 ,d5
275
+ moveq #0 ,d6
276
+ .cont lsr.l #4 ,d7
277
+ bra.b .start
278
+ .loop: rept 4
279
+ add.l (a0 )+,d5
280
+ addx.l d6 ,d5
281
+ endr
282
+ .start dbf d7 ,.loop
283
+
284
+ not.l d5
285
+ beq.b .sumok
286
+ not.l d5
287
+
288
+ move.l d0 ,d7
289
+ add.l d0 ,d0
290
+ cmp.l d1 ,d0
291
+ bne.b .cont
292
+ .error moveq .l #-1 ,d0
293
+ rts
294
+ .sumok move.l d0 ,d2
295
+
296
+ ; Allocate a dummy memlist header + memlist name + 'free'list
297
+ moveq.l #MH_SIZE+MC_SIZE+(romname_end-romname),d0
298
+ moveq .l #0 ,d1
299
+ jsr _LVOAllocMem (a6 )
300
+ tst .l d0
301
+ beq .error
302
+
303
+ ; Fill out the memlist header based on the ROM details
304
+ move.l d0 ,a0
305
+ clr.l LN_SUCC(a0 )
306
+ clr.l LN_PRED(a0 )
307
+ move.b #NT_MEMORY,LN_TYPE(a0 )
308
+ move.b #-128 ,LN_PRI(a0 )
309
+ move.w #0 ,MH_ATTRIBUTES(a0 )
310
+
311
+ ; This is the 'empty' freelist node
312
+ lea MH_SIZE(a0 ),a1
313
+ move.l a1 ,MH_FIRST(a0 )
314
+ clr.l (a1 )+ ; MC_NEXT
315
+ clr.l (a1 )+ ; MC_BYTES
316
+
317
+ ; Set the ROM memory name
318
+ move.l a1 ,LN_NAME(a0 )
319
+ lea romname(pc ),a2
320
+ moveq.l #romname_end-romname,d1
321
+ .name move.b (a2 )+,(a1 )+
322
+ dbf d1 ,.name
323
+
324
+ ; Set the memlist lower and upper bound (matching ROM)
325
+ lea $00f00000 ,a1
326
+ move.l a1 ,MH_LOWER(a0 )
327
+ move.l a1 ,MH_UPPER(a0 )
328
+ add.l d2 ,MH_UPPER(a0 )
329
+ clr.l MH_FREE(a0 )
330
+
331
+ ; Use the *private* execbase member 'MemList' to enqueue the ROM memlist
332
+ move.l a0 ,a1
333
+ lea.l MemList(a6 ),a0
334
+ jsr _LVOForbid (a6 )
335
+ jsr _LVOEnqueue (a6 )
336
+ jsr _LVOPermit (a6 )
337
+
338
+ move.l d2 ,d0 ; ROM size
339
+ rts
239
340
end
240
341
0 commit comments