2012-04-29 06:16:44 +00:00
|
|
|
#ifndef PROCESSOR_SPC700_HPP
|
|
|
|
#define PROCESSOR_SPC700_HPP
|
|
|
|
|
|
|
|
namespace Processor {
|
|
|
|
|
|
|
|
struct SPC700 {
|
2015-11-21 07:36:48 +00:00
|
|
|
virtual auto op_io() -> void = 0;
|
|
|
|
virtual auto op_read(uint16 addr) -> uint8 = 0;
|
|
|
|
virtual auto op_write(uint16 addr, uint8 data) -> void = 0;
|
|
|
|
virtual auto disassembler_read(uint16 addr) -> uint8 = 0;
|
Update to v084r01 release.
I rewrote the S-SMP processor core (implementation of the 256 opcodes),
utilizing my new 6502-like syntax. It matches what bass v05r01 uses.
Took 10 hours.
Due to being able to group the "mov reg,mem" opcodes together with
"adc/sbc/ora/and/eor/cmp" sets, the total code size was reduced from
55.7KB to 42.5KB for identical accuracy and speed.
I also dropped the trick I was using to pass register variables as
template arguments, and instead just use a switch table to pass them as
function arguments. Makes the table a lot easier to read.
Passes all of my S-SMP tests, and all of blargg's
arithmetic/cycle-timing S-SMP tests. Runs Zelda 3 great as well. Didn't
test further.
This does have the potential to cause some regressions if I've messed
anything up, and none of the above tests caught it, so as always,
testing would be appreciated.
Anyway, yeah. By writing the actual processor with this new mnemonic
set, it confirms the parallels I've made.
My guess is that Sony really did clone the 6502, but was worried about
legal implications or something and changed the mnemonics last-minute.
(Note to self: need to re-enable snes.random before v085 official.)
EDIT: oh yeah, I also commented out the ALSA snd_pcm_drain() inside
term(). Without it, there is a tiny pop when the driver is
re-initialized. But with it, the entire emulator would lock up for five
whole seconds waiting on that call to complete. I'll take the pop any
day over that.
2011-11-17 12:05:35 +00:00
|
|
|
|
2015-11-21 07:36:48 +00:00
|
|
|
auto op_step() -> void;
|
|
|
|
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
|
|
|
auto disassemble(uint16 addr, bool p) -> string;
|
2012-04-29 06:16:44 +00:00
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
#include "registers.hpp"
|
|
|
|
#include "memory.hpp"
|
|
|
|
|
2015-11-21 07:36:48 +00:00
|
|
|
Regs regs;
|
|
|
|
Word dp, sp, rd, wr, bit, ya;
|
Update to v084r01 release.
I rewrote the S-SMP processor core (implementation of the 256 opcodes),
utilizing my new 6502-like syntax. It matches what bass v05r01 uses.
Took 10 hours.
Due to being able to group the "mov reg,mem" opcodes together with
"adc/sbc/ora/and/eor/cmp" sets, the total code size was reduced from
55.7KB to 42.5KB for identical accuracy and speed.
I also dropped the trick I was using to pass register variables as
template arguments, and instead just use a switch table to pass them as
function arguments. Makes the table a lot easier to read.
Passes all of my S-SMP tests, and all of blargg's
arithmetic/cycle-timing S-SMP tests. Runs Zelda 3 great as well. Didn't
test further.
This does have the potential to cause some regressions if I've messed
anything up, and none of the above tests caught it, so as always,
testing would be appreciated.
Anyway, yeah. By writing the actual processor with this new mnemonic
set, it confirms the parallels I've made.
My guess is that Sony really did clone the 6502, but was worried about
legal implications or something and changed the mnemonics last-minute.
(Note to self: need to re-enable snes.random before v085 official.)
EDIT: oh yeah, I also commented out the ALSA snd_pcm_drain() inside
term(). Without it, there is a tiny pop when the driver is
re-initialized. But with it, the entire emulator would lock up for five
whole seconds waiting on that call to complete. I'll take the pop any
day over that.
2011-11-17 12:05:35 +00:00
|
|
|
uint8 opcode;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
Update to v084r01 release.
I rewrote the S-SMP processor core (implementation of the 256 opcodes),
utilizing my new 6502-like syntax. It matches what bass v05r01 uses.
Took 10 hours.
Due to being able to group the "mov reg,mem" opcodes together with
"adc/sbc/ora/and/eor/cmp" sets, the total code size was reduced from
55.7KB to 42.5KB for identical accuracy and speed.
I also dropped the trick I was using to pass register variables as
template arguments, and instead just use a switch table to pass them as
function arguments. Makes the table a lot easier to read.
Passes all of my S-SMP tests, and all of blargg's
arithmetic/cycle-timing S-SMP tests. Runs Zelda 3 great as well. Didn't
test further.
This does have the potential to cause some regressions if I've messed
anything up, and none of the above tests caught it, so as always,
testing would be appreciated.
Anyway, yeah. By writing the actual processor with this new mnemonic
set, it confirms the parallels I've made.
My guess is that Sony really did clone the 6502, but was worried about
legal implications or something and changed the mnemonics last-minute.
(Note to self: need to re-enable snes.random before v085 official.)
EDIT: oh yeah, I also commented out the ALSA snd_pcm_drain() inside
term(). Without it, there is a tiny pop when the driver is
re-initialized. But with it, the entire emulator would lock up for five
whole seconds waiting on that call to complete. I'll take the pop any
day over that.
2011-11-17 12:05:35 +00:00
|
|
|
protected:
|
2015-11-21 07:36:48 +00:00
|
|
|
auto op_adc(uint8, uint8) -> uint8;
|
|
|
|
auto op_and(uint8, uint8) -> uint8;
|
|
|
|
auto op_asl(uint8) -> uint8;
|
|
|
|
auto op_cmp(uint8, uint8) -> uint8;
|
|
|
|
auto op_dec(uint8) -> uint8;
|
|
|
|
auto op_eor(uint8, uint8) -> uint8;
|
|
|
|
auto op_inc(uint8) -> uint8;
|
|
|
|
auto op_ld (uint8, uint8) -> uint8;
|
|
|
|
auto op_lsr(uint8) -> uint8;
|
|
|
|
auto op_or (uint8, uint8) -> uint8;
|
|
|
|
auto op_rol(uint8) -> uint8;
|
|
|
|
auto op_ror(uint8) -> uint8;
|
|
|
|
auto op_sbc(uint8, uint8) -> uint8;
|
|
|
|
auto op_st (uint8, uint8) -> uint8;
|
|
|
|
auto op_adw(uint16, uint16) -> uint16;
|
|
|
|
auto op_cpw(uint16, uint16) -> uint16;
|
|
|
|
auto op_ldw(uint16, uint16) -> uint16;
|
|
|
|
auto op_sbw(uint16, uint16) -> uint16;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2015-11-21 07:36:48 +00:00
|
|
|
template<auto (SPC700::*op)(uint8) -> uint8> auto op_adjust(uint8&) -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8) -> uint8> auto op_adjust_addr() -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8) -> uint8> auto op_adjust_dp() -> void;
|
|
|
|
auto op_adjust_dpw(int) -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8) -> uint8> auto op_adjust_dpx() -> void;
|
|
|
|
auto op_branch(bool) -> void;
|
|
|
|
auto op_branch_bit() -> void;
|
|
|
|
auto op_pull(uint8&) -> void;
|
|
|
|
auto op_push(uint8) -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8, uint8) -> uint8> auto op_read_addr(uint8&) -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8, uint8) -> uint8> auto op_read_addri(uint8&) -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8, uint8) -> uint8> auto op_read_const(uint8&) -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8, uint8) -> uint8> auto op_read_dp(uint8&) -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8, uint8) -> uint8> auto op_read_dpi(uint8&, uint8&) -> void;
|
|
|
|
template<auto (SPC700::*op)(uint16, uint16) -> uint16> auto op_read_dpw() -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8, uint8) -> uint8> auto op_read_idpx() -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8, uint8) -> uint8> auto op_read_idpy() -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8, uint8) -> uint8> auto op_read_ix() -> void;
|
|
|
|
auto op_set_addr_bit() -> void;
|
|
|
|
auto op_set_bit() -> void;
|
|
|
|
auto op_set_flag(bool&, bool) -> void;
|
|
|
|
auto op_test_addr(bool) -> void;
|
|
|
|
auto op_transfer(uint8&, uint8&) -> void;
|
|
|
|
auto op_write_addr(uint8&) -> void;
|
|
|
|
auto op_write_addri(uint8&) -> void;
|
|
|
|
auto op_write_dp(uint8&) -> void;
|
|
|
|
auto op_write_dpi(uint8&, uint8&) -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8, uint8) -> uint8> auto op_write_dp_const() -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8, uint8) -> uint8> auto op_write_dp_dp() -> void;
|
|
|
|
template<auto (SPC700::*op)(uint8, uint8) -> uint8> auto op_write_ix_iy() -> void;
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2015-11-21 07:36:48 +00:00
|
|
|
auto op_bne_dp() -> void;
|
|
|
|
auto op_bne_dpdec() -> void;
|
|
|
|
auto op_bne_dpx() -> void;
|
|
|
|
auto op_bne_ydec() -> void;
|
|
|
|
auto op_brk() -> void;
|
|
|
|
auto op_clv() -> void;
|
|
|
|
auto op_cmc() -> void;
|
|
|
|
auto op_daa() -> void;
|
|
|
|
auto op_das() -> void;
|
|
|
|
auto op_div_ya_x() -> void;
|
|
|
|
auto op_jmp_addr() -> void;
|
|
|
|
auto op_jmp_iaddrx() -> void;
|
|
|
|
auto op_jsp_dp() -> void;
|
|
|
|
auto op_jsr_addr() -> void;
|
|
|
|
auto op_jst() -> void;
|
|
|
|
auto op_lda_ixinc() -> void;
|
|
|
|
auto op_mul_ya() -> void;
|
|
|
|
auto op_nop() -> void;
|
|
|
|
auto op_plp() -> void;
|
|
|
|
auto op_rti() -> void;
|
|
|
|
auto op_rts() -> void;
|
|
|
|
auto op_sta_idpx() -> void;
|
|
|
|
auto op_sta_idpy() -> void;
|
|
|
|
auto op_sta_ix() -> void;
|
|
|
|
auto op_sta_ixinc() -> void;
|
|
|
|
auto op_stw_dp() -> void;
|
|
|
|
auto op_wait() -> void;
|
|
|
|
auto op_xcn() -> void;
|
2010-08-09 13:28:56 +00:00
|
|
|
};
|
2012-04-29 06:16:44 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|