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.
28 Z80
PRNM(proc
) IBSS_ATTR
;
30 byte
PRNM(inports
)[PORTNUM
] IBSS_ATTR
;
31 byte
PRNM(outports
)[PORTNUM
] IBSS_ATTR
;
41 static byte
*a64kmalloc(int num64ksegs
)
45 bigmem
= (byte
*) my_malloc((unsigned) (0x10000 * (num64ksegs
+ 1)));
47 /*fprintf(stderr, "Out of memory!\n");*/
51 return (byte
*) (( (long) bigmem
& ~((long) 0xFFFF)) + 0x10000);
60 DANM(mem
) = a64kmalloc(NUM64KSEGS
);
62 rb
->srand((unsigned int)( rb
->get_time()->tm_sec
+rb
->get_time()->tm_min
*60 + rb
->get_time()->tm_hour
*3600));
63 for(i
= 0; i
< 0x10000; i
++) DANM(mem
)[i
] = (byte
) rb
->rand();
65 for(i
= 0; i
< NUMDREGS
; i
++) {
66 DANM(nr
)[i
].p
= DANM(mem
);
67 DANM(nr
)[i
].d
.d
= (dbyte
) rb
->rand();
70 for(i
= 0; i
< BACKDREGS
; i
++) {
71 DANM(br
)[i
].p
= DANM(mem
);
72 DANM(br
)[i
].d
.d
= (dbyte
) rb
->rand();
75 for(i
= 0; i
< PORTNUM
; i
++) PRNM(inports
)[i
] = PRNM(outports
)[i
] = 0;
82 /* TODO: no interrupt immediately afer EI (not important for spectrum) */
86 DANM(iff2
) = DANM(iff1
);
95 /* TODO: IM 0 emulation */
97 void PRNM(interrupt
)(int data
)
102 DANM(iff1
) = DANM(iff2
) = 0;
104 switch(DANM(it_mode
)) {
115 PCL
= DANM(mem
)[(dbyte
) (((int) RI
<< 8) + (data
& 0xFF))];
116 PCH
= DANM(mem
)[(dbyte
) (((int) RI
<< 8) + (data
& 0xFF) + 1)];
123 void PRNM(reset
)(void)
126 DANM(iff1
) = DANM(iff2
) = 0;