2015-11-21 07:36:48 +00:00
|
|
|
//NEC uPD7725
|
|
|
|
//NEC uPD96050
|
|
|
|
|
2016-02-02 10:51:17 +00:00
|
|
|
#pragma once
|
2012-03-26 10:13:02 +00:00
|
|
|
|
|
|
|
namespace Processor {
|
|
|
|
|
|
|
|
struct uPD96050 {
|
2015-11-21 07:36:48 +00:00
|
|
|
auto power() -> void;
|
|
|
|
auto exec() -> void;
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
|
|
|
auto execOP(uint24 opcode) -> void;
|
|
|
|
auto execRT(uint24 opcode) -> void;
|
|
|
|
auto execJP(uint24 opcode) -> void;
|
|
|
|
auto execLD(uint24 opcode) -> void;
|
|
|
|
|
|
|
|
auto readSR() -> uint8;
|
|
|
|
auto writeSR(uint8 data) -> void;
|
|
|
|
|
|
|
|
auto readDR() -> uint8;
|
|
|
|
auto writeDR(uint8 data) -> void;
|
|
|
|
|
|
|
|
auto readDP(uint12 addr) -> uint8;
|
|
|
|
auto writeDP(uint12 addr, uint8 data) -> void;
|
|
|
|
|
|
|
|
auto disassemble(uint14 ip) -> string;
|
|
|
|
|
|
|
|
enum class Revision : uint { uPD7725, uPD96050 } revision;
|
2012-03-26 10:13:02 +00:00
|
|
|
uint24 programROM[16384];
|
|
|
|
uint16 dataROM[2048];
|
|
|
|
uint16 dataRAM[2048];
|
|
|
|
|
2015-11-21 07:36:48 +00:00
|
|
|
struct Flag {
|
2017-08-30 03:44:51 +00:00
|
|
|
inline operator uint() const {
|
|
|
|
return ov0 << 0 | ov1 << 1 | z << 2 | c << 3 | s0 << 4 | s1 << 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline auto operator=(uint16 data) -> Flag& {
|
|
|
|
ov0 = data.bit(0);
|
|
|
|
ov1 = data.bit(1);
|
|
|
|
z = data.bit(2);
|
|
|
|
c = data.bit(3);
|
|
|
|
s0 = data.bit(4);
|
|
|
|
s1 = data.bit(5);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
|
|
|
boolean ov0; //overflow 0
|
|
|
|
boolean ov1; //overflow 1
|
|
|
|
boolean z; //zero
|
|
|
|
boolean c; //carry
|
|
|
|
boolean s0; //sign 0
|
|
|
|
boolean s1; //sign 1
|
2015-11-21 07:36:48 +00:00
|
|
|
};
|
2012-03-26 10:13:02 +00:00
|
|
|
|
2015-11-21 07:36:48 +00:00
|
|
|
struct Status {
|
2017-08-30 03:44:51 +00:00
|
|
|
inline operator uint() const {
|
|
|
|
bool _drs = drs & !drc; //when DRC=1, DRS=0
|
|
|
|
return p0 << 0 | p1 << 1 | ei << 7 | sic << 8 | soc << 9 | drc << 10
|
2017-08-31 13:58:54 +00:00
|
|
|
| dma << 11 | _drs << 12 | usf0 << 13 | usf1 << 14 | rqm << 15;
|
2017-08-30 03:44:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline auto operator=(uint16 data) -> Status& {
|
2017-08-31 13:58:54 +00:00
|
|
|
p0 = data.bit( 0);
|
|
|
|
p1 = data.bit( 1);
|
|
|
|
ei = data.bit( 7);
|
|
|
|
sic = data.bit( 8);
|
|
|
|
soc = data.bit( 9);
|
|
|
|
drc = data.bit(10);
|
|
|
|
dma = data.bit(11);
|
|
|
|
drs = data.bit(12);
|
|
|
|
usf0 = data.bit(13);
|
|
|
|
usf1 = data.bit(14);
|
|
|
|
rqm = data.bit(15);
|
2017-08-30 03:44:51 +00:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
2017-08-31 13:58:54 +00:00
|
|
|
boolean p0; //output port 0
|
|
|
|
boolean p1; //output port 1
|
|
|
|
boolean ei; //enable interrupts
|
|
|
|
boolean sic; //serial input control (0 = 16-bit; 1 = 8-bit)
|
|
|
|
boolean soc; //serial output control (0 = 16-bit; 1 = 8-bit)
|
|
|
|
boolean drc; //data register size (0 = 16-bit; 1 = 8-bit)
|
|
|
|
boolean dma; //data register DMA mode
|
|
|
|
boolean drs; //data register status (1 = active; 0 = stopped)
|
|
|
|
boolean usf0; //user flag 0
|
|
|
|
boolean usf1; //user flag 1
|
|
|
|
boolean rqm; //request for master (=1 on internal access; =0 on external access)
|
|
|
|
|
|
|
|
//internal
|
|
|
|
boolean siack; //serial input acknowledge
|
|
|
|
boolean soack; //serial output acknowledge
|
2015-11-21 07:36:48 +00:00
|
|
|
};
|
2012-03-26 10:13:02 +00:00
|
|
|
|
2017-08-30 03:44:51 +00:00
|
|
|
struct Registers {
|
|
|
|
auto serialize(serializer&) -> void;
|
|
|
|
|
2016-02-16 09:27:55 +00:00
|
|
|
uint16 stack[16]; //LIFO
|
Update to v097r17 release.
byuu says:
Changelog:
- ruby: if DirectSoundCreate fails (no sound device present), return
false from init instead of crashing
- nall: improved edge case return values for
(basename,pathname,dirname,...)
- nall: renamed file_system_object class to inode
- nall: varuint_t replaced with VariadicNatural; which contains
.bit,.bits,.byte ala Natural/Integer
- nall: fixed boolean compilation error on Windows
- WS: popa should not restore SP
- GBA: rewrote the CPU/APU cores to use the .bit,.bits functions;
removed registers.cpp from each
Note that the GBA changes are extremely major. This is about five hours
worth of extremely delicate work. Any slight errors could break
emulation in extremely bad ways. Let's hold off on extensive testing
until the next WIP, after I do the same to the PPU.
So far ... endrift's SOUNDCNT_X I/O test is failing, although that code
didn't change, so clearly I messed up SOUNDCNT_H somehow ...
To compile on Windows:
1. change nall/string/platform.hpp line 47 to
return slice(result, 0, 3);
2. change ruby/video.wgl.cpp line 72 to
auto lock(uint32_t*& data, uint& pitch, uint width, uint height) -> bool {
3. add this line to the very top of hiro/windows/header.cpp:
#define boolean FuckYouMicrosoft
2016-02-23 11:08:44 +00:00
|
|
|
VariadicNatural pc; //program counter
|
|
|
|
VariadicNatural rp; //ROM pointer
|
|
|
|
VariadicNatural dp; //data pointer
|
2016-02-16 09:27:55 +00:00
|
|
|
uint4 sp; //stack pointer
|
2017-08-30 03:44:51 +00:00
|
|
|
uint16 si; //serial input
|
|
|
|
uint16 so; //serial output
|
2015-11-21 07:36:48 +00:00
|
|
|
int16 k;
|
|
|
|
int16 l;
|
|
|
|
int16 m;
|
|
|
|
int16 n;
|
2016-02-16 09:27:55 +00:00
|
|
|
int16 a; //accumulator
|
|
|
|
int16 b; //accumulator
|
|
|
|
uint16 tr; //temporary register
|
|
|
|
uint16 trb; //temporary register
|
|
|
|
uint16 dr; //data register
|
2017-08-30 03:44:51 +00:00
|
|
|
Status sr; //status register
|
2015-11-21 07:36:48 +00:00
|
|
|
} regs;
|
2017-08-30 03:44:51 +00:00
|
|
|
|
|
|
|
struct Flags {
|
|
|
|
Flag a;
|
|
|
|
Flag b;
|
|
|
|
} flags;
|
2012-03-26 10:13:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|