2016-02-02 10:51:17 +00:00
|
|
|
#pragma once
|
2012-04-29 06:16:44 +00:00
|
|
|
|
|
|
|
namespace Processor {
|
|
|
|
|
|
|
|
struct SPC700 {
|
Update to v099r14 release.
byuu says:
Changelog:
- (u)int(max,ptr) abbreviations removed; use _t suffix now [didn't feel
like they were contributing enough to be worth it]
- cleaned up nall::integer,natural,real functionality
- toInteger, toNatural, toReal for parsing strings to numbers
- fromInteger, fromNatural, fromReal for creating strings from numbers
- (string,Markup::Node,SQL-based-classes)::(integer,natural,real)
left unchanged
- template<typename T> numeral(T value, long padding, char padchar)
-> string for print() formatting
- deduces integer,natural,real based on T ... cast the value if you
want to override
- there still exists binary,octal,hex,pointer for explicit print()
formatting
- lstring -> string_vector [but using lstring = string_vector; is
declared]
- would be nice to remove the using lstring eventually ... but that'd
probably require 10,000 lines of changes >_>
- format -> string_format [no using here; format was too ambiguous]
- using integer = Integer<sizeof(int)*8>; and using natural =
Natural<sizeof(uint)*8>; declared
- for consistency with boolean. These three are meant for creating
zero-initialized values implicitly (various uses)
- R65816::io() -> idle() and SPC700::io() -> idle() [more clear; frees
up struct IO {} io; naming]
- SFC CPU, PPU, SMP use struct IO {} io; over struct (Status,Registers) {}
(status,registers); now
- still some CPU::Status status values ... they didn't really fit into
IO functionality ... will have to think about this more
- SFC CPU, PPU, SMP now use step() exclusively instead of addClocks()
calling into step()
- SFC CPU joypad1_bits, joypad2_bits were unused; killed them
- SFC PPU CGRAM moved into PPU::Screen; since nothing else uses it
- SFC PPU OAM moved into PPU::Object; since nothing else uses it
- the raw uint8[544] array is gone. OAM::read() constructs values from
the OAM::Object[512] table now
- this avoids having to determine how we want to sub-divide the two
OAM memory sections
- this also eliminates the OAM::synchronize() functionality
- probably more I'm forgetting
The FPS fluctuations are driving me insane. This WIP went from 128fps to
137fps. Settled on 133.5fps for the final build. But nothing I changed
should have affected performance at all. This level of fluctuation makes
it damn near impossible to know whether I'm speeding things up or slowing
things down with changes.
2016-07-01 11:50:32 +00:00
|
|
|
virtual auto idle() -> void = 0;
|
2016-06-05 04:52:43 +00:00
|
|
|
virtual auto read(uint16 addr) -> uint8 = 0;
|
|
|
|
virtual auto write(uint16 addr, uint8 data) -> void = 0;
|
2016-06-28 10:43:47 +00:00
|
|
|
virtual auto readDisassembler(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
|
|
|
|
2016-06-05 04:52:43 +00:00
|
|
|
auto instruction() -> void;
|
2015-11-21 07:36:48 +00:00
|
|
|
|
|
|
|
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"
|
|
|
|
|
2016-06-08 22:26:35 +00:00
|
|
|
Registers regs;
|
|
|
|
Register 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:
|
2016-06-05 04:52:43 +00:00
|
|
|
using fps = auto (SPC700::*)(uint8) -> uint8;
|
|
|
|
using fpb = auto (SPC700::*)(uint8, uint8) -> uint8;
|
|
|
|
using fpw = auto (SPC700::*)(uint16, uint16) -> uint16;
|
2016-06-08 22:26:35 +00:00
|
|
|
using reg = uint8_t&;
|
2016-06-05 04:52:43 +00:00
|
|
|
|
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
|
|
|
|
2016-06-08 22:26:35 +00:00
|
|
|
auto op_adjust(fps, reg);
|
2016-06-05 22:10:01 +00:00
|
|
|
auto op_adjust_addr(fps);
|
|
|
|
auto op_adjust_dp(fps);
|
|
|
|
auto op_adjust_dpw(int);
|
|
|
|
auto op_adjust_dpx(fps);
|
|
|
|
auto op_branch(bool);
|
|
|
|
auto op_branch_bit();
|
2016-06-08 22:26:35 +00:00
|
|
|
auto op_pull(reg);
|
2016-06-05 22:10:01 +00:00
|
|
|
auto op_push(uint8);
|
2016-06-08 22:26:35 +00:00
|
|
|
auto op_read_addr(fpb, reg);
|
|
|
|
auto op_read_addri(fpb, reg);
|
|
|
|
auto op_read_const(fpb, reg);
|
|
|
|
auto op_read_dp(fpb, reg);
|
|
|
|
auto op_read_dpi(fpb, reg, reg);
|
2016-06-05 22:10:01 +00:00
|
|
|
auto op_read_dpw(fpw);
|
|
|
|
auto op_read_idpx(fpb);
|
|
|
|
auto op_read_idpy(fpb);
|
|
|
|
auto op_read_ix(fpb);
|
|
|
|
auto op_set_addr_bit();
|
|
|
|
auto op_set_bit();
|
2016-06-08 22:26:35 +00:00
|
|
|
auto op_set_flag(uint, bool);
|
2016-06-05 22:10:01 +00:00
|
|
|
auto op_test_addr(bool);
|
2016-06-08 22:26:35 +00:00
|
|
|
auto op_transfer(reg, reg);
|
|
|
|
auto op_write_addr(reg);
|
|
|
|
auto op_write_addri(reg);
|
|
|
|
auto op_write_dp(reg);
|
|
|
|
auto op_write_dpi(reg, reg);
|
2016-06-05 22:10:01 +00:00
|
|
|
auto op_write_dp_const(fpb);
|
|
|
|
auto op_write_dp_dp(fpb);
|
|
|
|
auto op_write_ix_iy(fpb);
|
2010-08-09 13:28:56 +00:00
|
|
|
|
2016-06-05 22:10:01 +00:00
|
|
|
auto op_bne_dp();
|
|
|
|
auto op_bne_dpdec();
|
|
|
|
auto op_bne_dpx();
|
|
|
|
auto op_bne_ydec();
|
|
|
|
auto op_brk();
|
|
|
|
auto op_clv();
|
|
|
|
auto op_cmc();
|
|
|
|
auto op_daa();
|
|
|
|
auto op_das();
|
|
|
|
auto op_div_ya_x();
|
|
|
|
auto op_jmp_addr();
|
|
|
|
auto op_jmp_iaddrx();
|
|
|
|
auto op_jsp_dp();
|
|
|
|
auto op_jsr_addr();
|
|
|
|
auto op_jst();
|
|
|
|
auto op_lda_ixinc();
|
|
|
|
auto op_mul_ya();
|
|
|
|
auto op_nop();
|
|
|
|
auto op_plp();
|
|
|
|
auto op_rti();
|
|
|
|
auto op_rts();
|
|
|
|
auto op_sta_idpx();
|
|
|
|
auto op_sta_idpy();
|
|
|
|
auto op_sta_ix();
|
|
|
|
auto op_sta_ixinc();
|
|
|
|
auto op_stw_dp();
|
|
|
|
auto op_wait();
|
|
|
|
auto op_xcn();
|
2010-08-09 13:28:56 +00:00
|
|
|
};
|
2012-04-29 06:16:44 +00:00
|
|
|
|
|
|
|
}
|