Xemu [doxygen]  hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
zxemu.c
Go to the documentation of this file.
1 /* Xep128: Minimalistic Enterprise-128 emulator with focus on "exotic" hardware
2  Copyright (C)2015,2016 LGB (Gábor Lénárt) <lgblgblgb@gmail.com>
3  http://xep128.lgb.hu/
4 
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.
9 
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.
14 
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
18 
19 #include "xep128.h"
20 #include "zxemu.h"
21 #include "cpu.h"
22 #include "primoemu.h"
23 
24 
25 
26 int zxemu_on = 0;
27 
28 
29 
30 
32 {
33  data &= 128;
34  if (data == zxemu_on)
35  return;
36  zxemu_on = data;
37  DEBUG("ZXEMU: emulation is turned %s." NL, zxemu_on ? "ON" : "OFF");
38  if (zxemu_on)
39  primo_switch(0);
40  nmi_pending = 0;
41 }
42 
43 
44 static int zxemu_nmi ( void )
45 {
47  return nmi_pending;
48 }
49 
50 
51 void zxemu_write_ula ( Uint8 hiaddr, Uint8 data )
52 {
53  ports[0x40] = hiaddr; // high I/O address
54  ports[0x41] = 0xFE; // low I/O address, the ULA port
55  ports[0x42] = data; // data on the bus
56  ports[0x43] = 0; // ?? 0 = I/O kind of op
57  if (!zxemu_nmi())
58  DEBUG("ZXEMU: ULA write: no NMI (switched off)" NL);
59  DEBUG("ZXEMU: writing ULA at %04Xh (data: %02Xh)" NL, Z80_PC, data);
60 }
61 
62 
64 {
65  ports[0x40] = hiaddr;
66  ports[0x41] = 0xFE;
67  ports[0x42] = 0xFF; // ???????
68  ports[0x43] = 0;
69  if (!zxemu_nmi())
70  DEBUG("ZXEMU: ULA read: no NMI (switched off)" NL);
71  DEBUG("ZXEMU: reading ULA at %04Xh" NL, Z80_PC);
72  return zxemu_on ? 0xBF : 0xFF;
73 }
74 
75 
76 /* This function is only allowed to be called, if zxemu_on is non-zero, and attribute area is written! */
78 {
79  ports[0x40] = address >> 8;
80  ports[0x41] = address & 0xFF;
81  ports[0x42] = data;
82  ports[0x43] = 0x80;
83  zxemu_nmi();
84  DEBUG("ZXEMU: attrib-mem trap at %04Xh" NL, address);
85 }
86 
zxemu_write_ula
void zxemu_write_ula(Uint8 hiaddr, Uint8 data)
Definition: zxemu.c:52
zxemu_attribute_memory_write
void zxemu_attribute_memory_write(Uint16 address, Uint8 data)
Definition: zxemu.c:78
zxemu.h
zxemu_read_ula
Uint8 zxemu_read_ula(Uint8 hiaddr)
Definition: zxemu.c:64
zxemu_on
int zxemu_on
Definition: zxemu.c:27
m65-memcontent-generator.data
data
Definition: m65-memcontent-generator.py:119
Uint8
uint8_t Uint8
Definition: fat32.c:51
cpu.h
NL
#define NL
Definition: fat32.c:37
xep128.h
Z80_PC
#define Z80_PC
Definition: z80ex.h:121
primo_switch
void primo_switch(Uint8 data)
Definition: primoemu.c:110
zxemu_switch
void zxemu_switch(Uint8 data)
Definition: zxemu.c:32
Uint16
uint16_t Uint16
Definition: fat32.c:50
DEBUG
#define DEBUG(...)
Definition: emutools_basicdefs.h:167
primoemu.h
nmi_pending
int nmi_pending
Definition: cpu.c:47