Skip to content

Commit

Permalink
CSimulator: Fix outi()
Browse files Browse the repository at this point in the history
Also use Py_BuildValue() to build argument tuples.
  • Loading branch information
skoolkid committed Mar 9, 2024
1 parent 0421474 commit e84118a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions c/csimulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1762,9 +1762,7 @@ static void out_c(CSimulatorObject* self, void* lookup, int args[]) {
byte value = r >= 0 ? REG(r) : 0;
OUT(port, value);
if (self->out_tracer) {
PyObject* m_args = PyTuple_New(2);
PyTuple_SetItem(m_args, 0, PyLong_FromLong(port));
PyTuple_SetItem(m_args, 1, PyLong_FromLong(value));
PyObject* m_args = Py_BuildValue("(IB)", port, value);
PyObject* rv = PyObject_Call(self->out_tracer, m_args, NULL);
Py_XDECREF(m_args);
if (rv == NULL) {
Expand All @@ -1787,13 +1785,11 @@ static void outi(CSimulatorObject* self, void* lookup, int args[]) {

unsigned hl = REG(L) + 256 * REG(H);
unsigned b = (REG(B) - 1) % 256;
unsigned port = REG(C) + 256 * REG(B);
unsigned value = MEMGET(hl);
unsigned port = REG(C) + 256 * b;
byte value = MEMGET(hl);
OUT(port, value);
if (self->out_tracer) {
PyObject* m_args = PyTuple_New(2);
PyTuple_SetItem(m_args, 0, PyLong_FromLong(port));
PyTuple_SetItem(m_args, 1, PyLong_FromLong(value));
PyObject* m_args = Py_BuildValue("(IB)", port, value);
PyObject* rv = PyObject_Call(self->out_tracer, m_args, NULL);
Py_XDECREF(m_args);
if (rv == NULL) {
Expand Down

0 comments on commit e84118a

Please sign in to comment.