mirror of
https://github.com/holub/mame
synced 2025-04-21 07:52:35 +03:00
Started implementing the actual emulation of the Patinho Feio instruction set.
(previous commits provided only disasm routines)
This commit is contained in:
parent
51b8dfa01b
commit
9037168f33
@ -8,17 +8,24 @@
|
||||
#include "debugger.h"
|
||||
#include "patinho_feio.h"
|
||||
|
||||
#define CI m_ci //The program counter is called "contador de instrucoes" in portuguese
|
||||
#define PC m_pc //The program counter is called "contador de instrucoes" in portuguese
|
||||
#define ACC m_acc
|
||||
|
||||
#define READ_BYTE_PATINHO(A) ((signed)m_program->read_byte(A))
|
||||
#define WRITE_BYTE_PATINHO(A,V) (m_program->write_byte(A,V))
|
||||
|
||||
#define READ_INDEX_REG() READ_BYTE_PATINHO(0x000)
|
||||
#define WRITE_INDEX_REG(V) WRITE_BYTE_PATINHO(0x000, V)
|
||||
|
||||
#define ADDRESS_MASK_4K 0xFFF
|
||||
#define INCREMENT_CI_4K (CI = (CI+1) & ADDRESS_MASK_4K)
|
||||
#define INCREMENT_PC_4K (PC = (PC+1) & ADDRESS_MASK_4K)
|
||||
|
||||
const device_type PATINHO_FEIO = &device_creator<patinho_feio_cpu_device>;
|
||||
|
||||
|
||||
//Internal 4kbytes of RAM
|
||||
static ADDRESS_MAP_START(prog_8bit, AS_PROGRAM, 8, patinho_feio_cpu_device)
|
||||
AM_RANGE(0x0000, 0x0fff) AM_RAM
|
||||
AM_RANGE(0x0000, 0x0fff) AM_RAM AM_SHARE("internalram")
|
||||
ADDRESS_MAP_END
|
||||
|
||||
patinho_feio_cpu_device::patinho_feio_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
|
||||
@ -30,25 +37,25 @@ patinho_feio_cpu_device::patinho_feio_cpu_device(const machine_config &mconfig,
|
||||
|
||||
void patinho_feio_cpu_device::device_start()
|
||||
{
|
||||
m_ci = 0;
|
||||
m_acc = 0;
|
||||
|
||||
m_program = &space(AS_PROGRAM);
|
||||
|
||||
save_item(NAME(m_ci));
|
||||
save_item(NAME(m_pc));
|
||||
save_item(NAME(m_acc));
|
||||
|
||||
// Register state for debugger
|
||||
state_add( PATINHO_FEIO_CI, "CI", m_ci ).mask(0xFFF);
|
||||
state_add( PATINHO_FEIO_ACC, "ACC", m_acc ).mask(0xFF);
|
||||
|
||||
state_add( PATINHO_FEIO_CI, "CI", m_pc ).mask(0xFFF);
|
||||
state_add( PATINHO_FEIO_ACC, "ACC", m_acc ).mask(0xFF);
|
||||
state_add(STATE_GENPC, "GENPC", m_pc).formatstr("0%06O").noshow();
|
||||
|
||||
m_icountptr = &m_icount;
|
||||
m_run = true;
|
||||
}
|
||||
|
||||
|
||||
void patinho_feio_cpu_device::device_reset()
|
||||
{
|
||||
m_pc = 0xE00;
|
||||
m_acc = 0;
|
||||
m_run = true;
|
||||
}
|
||||
|
||||
/* execute instructions on this CPU until icount expires */
|
||||
@ -59,8 +66,6 @@ void patinho_feio_cpu_device::execute_run()
|
||||
if ((! m_run)){
|
||||
m_icount = 0; /* if processor is stopped, just burn cycles */
|
||||
} else {
|
||||
debugger_instruction_hook(this, CI);
|
||||
|
||||
execute_instruction();
|
||||
m_icount --;
|
||||
}
|
||||
@ -68,12 +73,64 @@ void patinho_feio_cpu_device::execute_run()
|
||||
while (m_icount > 0);
|
||||
}
|
||||
|
||||
|
||||
/* execute one instruction */
|
||||
void patinho_feio_cpu_device::execute_instruction()
|
||||
{
|
||||
// char opcode = patinho_feio_read(CI);
|
||||
INCREMENT_CI_4K;
|
||||
debugger_instruction_hook(this, PC);
|
||||
offs_t addr;
|
||||
unsigned char tmp;
|
||||
unsigned char opcode = READ_BYTE_PATINHO(PC);
|
||||
INCREMENT_PC_4K;
|
||||
|
||||
switch (opcode){
|
||||
case 0xDA:
|
||||
//CARI="Carrega Imediato":
|
||||
// Load an immediate into the accumulator
|
||||
ACC = READ_BYTE_PATINHO(PC);
|
||||
INCREMENT_PC_4K;
|
||||
return;
|
||||
case 0x9A:
|
||||
//INIB="Inibe"
|
||||
// disables interrupts
|
||||
m_interrupts_enabled = false;
|
||||
return;
|
||||
case 0x9B:
|
||||
//PERM="Permite"
|
||||
// enables interrupts
|
||||
m_interrupts_enabled = true;
|
||||
return;
|
||||
case 0x9C:
|
||||
//ESP="Espera":
|
||||
// Holds execution and waits for an interrupt to occur.
|
||||
m_run = false;
|
||||
m_wait_for_interrupt = true;
|
||||
return;
|
||||
case 0x9D:
|
||||
//PARE="Pare":
|
||||
// Holds execution. This can only be recovered by
|
||||
// manually triggering execution again by
|
||||
// pressing the "Partida" (start) button in the panel
|
||||
m_run = false;
|
||||
m_wait_for_interrupt = false;
|
||||
return;
|
||||
case 0x9E:
|
||||
//TRI="Troca com Indexador":
|
||||
// Exchange the value of the accumulator with the index register
|
||||
tmp = ACC;
|
||||
ACC = READ_INDEX_REG();
|
||||
WRITE_INDEX_REG(tmp);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (opcode & 0xF0){
|
||||
case 0x00:
|
||||
//PLA = "Pula": Jump to address
|
||||
addr = READ_BYTE_PATINHO(PC) & 0xFFF;
|
||||
INCREMENT_PC_4K;
|
||||
PC = addr;
|
||||
return;
|
||||
}
|
||||
printf("unimplemented opcode: 0x%02X\n", opcode);
|
||||
}
|
||||
|
||||
offs_t patinho_feio_cpu_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options)
|
||||
|
@ -25,11 +25,13 @@ protected:
|
||||
|
||||
/* processor registers */
|
||||
int m_acc; /* accumulator (8 bits) */
|
||||
int m_ci; /* program counter (12 bits)
|
||||
int m_pc; /* program counter (12 bits)
|
||||
(CI stands for "Contador de Instrucao") */
|
||||
|
||||
/* processor state flip-flops */
|
||||
bool m_run; /* processor is running */
|
||||
bool m_wait_for_interrupt;
|
||||
bool m_interrupts_enabled;
|
||||
|
||||
int m_address_mask; /* address mask */
|
||||
int m_icount;
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
{ }
|
||||
|
||||
DECLARE_DRIVER_INIT(patinho_feio);
|
||||
// virtual void machine_start();
|
||||
virtual void machine_start();
|
||||
// virtual void machine_reset();
|
||||
// required_device<patinho_feio_cpu_device> m_maincpu;
|
||||
};
|
||||
@ -28,35 +28,36 @@ DRIVER_INIT_MEMBER(patinho_feio_state, patinho_feio)
|
||||
{
|
||||
}
|
||||
|
||||
void patinho_feio_state::machine_start(){
|
||||
//copy the "absolute program example" from appendix G directly into RAM
|
||||
// This is a hack for setting up the computer
|
||||
// while we don't support loading programs from punched tape rolls...
|
||||
UINT8 *RAM = (UINT8 *) memshare("maincpu:internalram")->ptr();
|
||||
UINT8 *program = memregion("example_program")->base();
|
||||
memcpy(&RAM[0xE00], program, 0x0D5);
|
||||
}
|
||||
|
||||
static INPUT_PORTS_START( patinho_feio )
|
||||
// PORT_START("PANEL") /* various operator control panel switches */
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_START("PANEL") /* various operator control panel switches */
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
// PORT_BIT(?, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("control panel key") PORT_CODE(KEYCODE_?)
|
||||
INPUT_PORTS_END
|
||||
|
||||
//Internal 4kbytes of RAM
|
||||
static ADDRESS_MAP_START(patinho_program_map, AS_PROGRAM, 8, patinho_feio_state)
|
||||
AM_RANGE(0x0000, 0x0fff) AM_ROM
|
||||
ADDRESS_MAP_END
|
||||
|
||||
static MACHINE_CONFIG_START( patinho_feio, patinho_feio_state )
|
||||
/* basic machine hardware */
|
||||
/* CPU @ approx. 500 kHz (memory cycle time is 2usec) */
|
||||
MCFG_CPU_ADD("maincpu", PATINHO_FEIO, 500000)
|
||||
MCFG_CPU_PROGRAM_MAP(patinho_program_map)
|
||||
/* basic machine hardware */
|
||||
/* CPU @ approx. 500 kHz (memory cycle time is 2usec) */
|
||||
MCFG_CPU_ADD("maincpu", PATINHO_FEIO, 500000)
|
||||
MACHINE_CONFIG_END
|
||||
|
||||
ROM_START(patinho)
|
||||
/*CPU memory space*/
|
||||
ROM_REGION(0x01000,"maincpu", ROMREGION_ERASEFF)
|
||||
/* Load this into th internal RAM... */
|
||||
ROM_LOAD("apendice_g__hexam.bin", 0x000, 0x0d5, CRC(c6addc59) SHA1(126bc97247eac45c58708eaac216c2438e9e4af9) )
|
||||
ROM_START( patinho )
|
||||
ROM_REGION( 0x0d5, "example_program", 0 )
|
||||
ROM_LOAD( "apendice_g__hexam.bin", 0x000, 0x0d5, CRC(c6addc59) SHA1(126bc97247eac45c58708eaac216c2438e9e4af9) )
|
||||
ROM_END
|
||||
|
||||
/* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME */
|
||||
|
Loading…
Reference in New Issue
Block a user