commit 67da655
zzo38
·
2024-03-19 19:16:56 +0000 UTC
parent ecdbb5e
Implement the new expansion commands.
3 files changed,
+34,
-15
+6,
-6
1@@ -235,7 +235,12 @@ emulator to the program), ? for parameters that may be input and/or output,
2 * for 16-bit values, and % for values of lengths other than 8-bits or
3 16-bits or if they are of a variable length.
4
5-02 >pages*
6+03 device_id uuid% >version ?extra%
7+ Loads a nonstandard device, or a nonstandard command for an existing
8+ device or that applies globally; see below section for details. This is
9+ called a "UUID-based extension".
10+
11+04 >pages*
12 Tells number of expanded memory pages. (This is the maximum valid value
13 for src_page and dst_page in expanded memory operations.) (If some of the
14 pages are read-only, then this is only the number of writable pages. The
15@@ -243,11 +248,6 @@ emulator to the program), ? for parameters that may be input and/or output,
16 systems with insufficient memory but that is able to emulate larger
17 memory by reading from the program file instead.)
18
19-03 device_id uuid% >version ?extra%
20- Loads a nonstandard device, or a nonstandard command for an existing
21- device or that applies globally; see below section for details. This is
22- called a "UUID-based extension".
23-
24 a0 offset%
25 Given a 32-bit offset, seek the currently opened file to the specified
26 absolute offset. (The effect of seeking (absolute or relative) when a
M
main.c
+21,
-8
1@@ -916,27 +916,40 @@ static void do_extension_by_uuid(Uint16 addr) {
2
3 static void system_exp(Device*dev,Uint16 addr) {
4 Uint32 src,dst;
5- Uint16 len;
6+ Uint16 len,n;
7 switch(mem[addr]) {
8- case 0x01:
9+ case 0x00:
10+ len=GET16(mem+addr+1);
11+ dst=(GET16(mem+addr+3)<<16L)|(GET16(mem+addr+5));
12+ if(dst<MEMSIZE && dst+len<=MEMSIZE) {
13+ memset(mem+dst,mem[addr+7],len);
14+ } else {
15+ if(use_debug) fprintf(stderr,"! Access expanded memory out of range\n");
16+ }
17+ break;
18+ case 0x01: case 0x02:
19 len=GET16(mem+addr+1);
20 src=(GET16(mem+addr+3)<<16L)|(GET16(mem+addr+5));
21 dst=(GET16(mem+addr+7)<<16L)|(GET16(mem+addr+9));
22- if(src+len<=MEMSIZE && dst+len<=MEMSIZE) {
23- memmove(mem+dst,mem+src,len);
24+ if(dst<MEMSIZE && src+len<=MEMSIZE && dst+len<=MEMSIZE) {
25+ if(mem[addr]==0x01) {
26+ for(n=0;n<len;n++) mem[dst+n]=mem[src+n];
27+ } else {
28+ for(n=len;n;n--) mem[dst+n-1]=mem[src+n-1];
29+ }
30 } else {
31 if(use_debug) fprintf(stderr,"! Access expanded memory out of range\n");
32 }
33 break;
34- case 0x02:
35- if(!use_extension) break;
36- PUT16(mem+addr+1,EXPANDED_MEMORY);
37- break;
38 case 0x03:
39 if(!use_extension) break;
40 mem[addr+18]=0;
41 do_extension_by_uuid(addr);
42 break;
43+ case 0x04:
44+ if(!use_extension) break;
45+ PUT16(mem+addr+1,EXPANDED_MEMORY);
46+ break;
47 }
48 }
49
+7,
-1
1@@ -332,6 +332,12 @@ will not work correctly if these values are all zero.
2
3 === Expansion ===
4
5+00 length* page* addr* value
6+ Fills the specified memory with a single-byte value.
7+
8 01 length* src_page* src_addr* dst_page* dst_addr*
9- Allows accessing expanded memory.
10+ Copy memory forward.
11+
12+02 length* src_page* src_addr* dst_page* dst_addr*
13+ Copy memory backward.
14