Skip to content

Commit

Permalink
put in a skeleton execution core so you can see the code with -debug
Browse files Browse the repository at this point in the history
  • Loading branch information
David Haywood committed Nov 1, 2023
1 parent c0aa575 commit f6c933d
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 2 deletions.
2 changes: 2 additions & 0 deletions scripts/src/cpu.lua
Expand Up @@ -3899,6 +3899,8 @@ end
--------------------------------------------------

if opt_tool(CPUS, "EVOLUTION") then
table.insert(disasm_files , MAME_DIR .. "src/devices/cpu/evolution/evo.cpp")
table.insert(disasm_files , MAME_DIR .. "src/devices/cpu/evolution/evo.h")

This comment has been minimized.

Copy link
@galibert

galibert Nov 1, 2023

Member

No, these two are not disasm files, you're probably breaking unidasm there.

This comment has been minimized.

Copy link
@mamehaze

mamehaze Nov 1, 2023

Contributor

indeed, silly mistake, fixed

table.insert(disasm_files , MAME_DIR .. "src/devices/cpu/evolution/evod.cpp")
table.insert(disasm_files , MAME_DIR .. "src/devices/cpu/evolution/evod.h")
end
78 changes: 78 additions & 0 deletions src/devices/cpu/evolution/evo.cpp
@@ -0,0 +1,78 @@
// license:BSD-3-Clause
// copyright-holders:David Haywood

#include "emu.h"
#include "evo.h"
#include "evod.h"

DEFINE_DEVICE_TYPE(EVOLUTION_CPU, evo_cpu_device, "evo_cpu", "Evolution CPU")

evo_cpu_device::evo_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: cpu_device(mconfig, EVOLUTION_CPU, tag, owner, clock)
, m_program_config("program", ENDIANNESS_LITTLE, 16, 24, -1)
, m_pc(0), m_program(nullptr), m_icount(0), m_debugger_temp(0)
{
}

std::unique_ptr<util::disasm_interface> evo_cpu_device::create_disassembler()
{
return std::make_unique<evolution_disassembler>();
}

device_memory_interface::space_config_vector evo_cpu_device::memory_space_config() const
{
return space_config_vector {
std::make_pair(AS_PROGRAM, &m_program_config)
};
}

void evo_cpu_device::device_start()
{
m_pc = 0;
m_debugger_temp = 0;
m_program = &space(AS_PROGRAM);
state_add(EVO_PC, "PC", m_debugger_temp).callimport().callexport().formatstr("%08X");
state_add(STATE_GENPCBASE, "CURPC", m_debugger_temp).callimport().callexport().noshow();
set_icountptr(m_icount);
}

void evo_cpu_device::state_export(const device_state_entry &entry)
{
switch (entry.index())
{
case EVO_PC:
case STATE_GENPCBASE:
m_debugger_temp = m_pc;
break;
}
}

void evo_cpu_device::state_import(const device_state_entry &entry)
{
switch (entry.index())
{
case EVO_PC:
case STATE_GENPCBASE:
m_pc = (m_debugger_temp & 0xffffffff);
break;
}
}

void evo_cpu_device::device_reset()
{
m_pc = 0x400000;
}

void evo_cpu_device::execute_set_input(int irqline, int state)
{
}

void evo_cpu_device::execute_run()
{
while (m_icount > 0)
{
debugger_instruction_hook(m_pc);
m_pc++;
m_icount--;
}
}
50 changes: 50 additions & 0 deletions src/devices/cpu/evolution/evo.h
@@ -0,0 +1,50 @@
// license:BSD-3-Clause
// copyright-holders:David Haywood

#ifndef MAME_CPU_EVO_EVO_H
#define MAME_CPU_EVO_EVO_H

#pragma once

enum
{
EVO_PC = STATE_GENPC
};

class evo_cpu_device : public cpu_device
{
public:
evo_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

protected:
virtual void device_start() override;
virtual void device_reset() override;

virtual uint32_t execute_min_cycles() const noexcept override { return 5; }
virtual uint32_t execute_max_cycles() const noexcept override { return 5; }
virtual uint32_t execute_input_lines() const noexcept override { return 0; }
virtual void execute_run() override;
virtual void execute_set_input(int inputnum, int state) override;

virtual space_config_vector memory_space_config() const override;

virtual void state_import(const device_state_entry &entry) override;
virtual void state_export(const device_state_entry &entry) override;

virtual std::unique_ptr<util::disasm_interface> create_disassembler() override;

private:
address_space_config m_program_config;

uint32_t m_pc;

address_space *m_program;
int m_icount;

uint32_t m_debugger_temp;
};


DECLARE_DEVICE_TYPE(EVOLUTION_CPU, evo_cpu_device)

#endif // MAME_CPU_EVO_EVO_H
19 changes: 17 additions & 2 deletions src/mame/skeleton/evolution_handheld.cpp
Expand Up @@ -8,14 +8,16 @@
#include "speaker.h"
#include "screen.h"

#include "cpu/evolution/evo.h"

namespace {

class evolution_handheldgame_state : public driver_device
{
public:
evolution_handheldgame_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag)
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu")
{ }

void evolhh(machine_config &config);
Expand All @@ -25,6 +27,10 @@ class evolution_handheldgame_state : public driver_device
virtual void machine_reset() override;

uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);

required_device<evo_cpu_device> m_maincpu;

void evolution_map(address_map &map);
};

void evolution_handheldgame_state::machine_start()
Expand All @@ -44,8 +50,17 @@ uint32_t evolution_handheldgame_state::screen_update(screen_device &screen, bitm
return 0;
}

void evolution_handheldgame_state::evolution_map(address_map &map)
{
map(0x400000, 0x41ffff).rom().region("maincpu", 0x00000);
}


void evolution_handheldgame_state::evolhh(machine_config &config)
{
EVOLUTION_CPU(config, m_maincpu, XTAL(16'000'000));
m_maincpu->set_addrmap(AS_PROGRAM, &evolution_handheldgame_state::evolution_map);

screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_refresh_hz(60);
screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
Expand All @@ -57,7 +72,7 @@ void evolution_handheldgame_state::evolhh(machine_config &config)
}

ROM_START( evolhh )
ROM_REGION32_BE( 0x400000, "nand", 0 )
ROM_REGION( 0x400000, "maincpu", 0 )
ROM_LOAD( "s29gl032m90tfir4.u4", 0x000000, 0x400000, CRC(c647ca01) SHA1(a88f512d3fe8803dadc4eb6a94b5babd40c698de) )
ROM_END

Expand Down

0 comments on commit f6c933d

Please sign in to comment.