2 * Copyright (C) 1996-1998 Szeredi Miklos
3 * Email: mszeredi@inf.bme.hu
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. See the file COPYING.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 byte
PRNM(inports
)[PORTNUM
];
31 byte
PRNM(outports
)[PORTNUM
];
42 static byte
*a64kmalloc(int num64ksegs
)
46 bigmem
= (byte
*) malloc((unsigned) (0x10000 * (num64ksegs
+ 1)));
48 fprintf(stderr
, "Out of memory!\n");
52 return (byte
*) (( (long) bigmem
& ~((long) 0xFFFF)) + 0x10000);
61 DANM(mem
) = a64kmalloc(NUM64KSEGS
);
63 srand((unsigned int) time(NULL
));
65 for(i
= 0; i
< 0x10000; i
++) DANM(mem
)[i
] = (byte
) rand();
67 memset(DANM(mem
), 0, 0x10000);
70 for(i
= 0; i
< NUMDREGS
; i
++) {
71 DANM(nr
)[i
].p
= DANM(mem
);
72 DANM(nr
)[i
].d
.d
= (dbyte
) rand();
75 for(i
= 0; i
< BACKDREGS
; i
++) {
76 DANM(br
)[i
].p
= DANM(mem
);
77 DANM(br
)[i
].d
.d
= (dbyte
) rand();
80 for(i
= 0; i
< PORTNUM
; i
++) PRNM(inports
)[i
] = PRNM(outports
)[i
] = 0;
87 /* TODO: no interrupt immediately afer EI (not important for spectrum) */
91 DANM(iff2
) = DANM(iff1
);
100 /* TODO: IM 0 emulation */
102 void PRNM(interrupt
)(int data
)
107 DANM(iff1
) = DANM(iff2
) = 0;
109 switch(DANM(it_mode
)) {
120 PCL
= DANM(mem
)[(dbyte
) (((int) RI
<< 8) + (data
& 0xFF))];
121 PCH
= DANM(mem
)[(dbyte
) (((int) RI
<< 8) + (data
& 0xFF) + 1)];
128 void PRNM(reset
)(void)
131 DANM(iff1
) = DANM(iff2
) = 0;