2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionLoop() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(1);
|
|
|
|
auto offset = (int8)fetch();
|
|
|
|
if(--r.cx) {
|
|
|
|
wait(3);
|
|
|
|
r.ip += offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionLoopWhile(bool value) -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(2);
|
|
|
|
auto offset = (int8)fetch();
|
|
|
|
if(--r.cx && r.f.z == value) {
|
|
|
|
wait(3);
|
|
|
|
r.ip += offset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionJumpShort() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(3);
|
|
|
|
auto offset = (int8)fetch();
|
|
|
|
r.ip += offset;
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionJumpIf(bool condition) -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
auto offset = (int8)fetch();
|
|
|
|
if(condition) r.ip += offset;
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionJumpNear() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(3);
|
|
|
|
r.ip += (int16)fetch(Word);
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionJumpFar() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(6);
|
|
|
|
auto ip = fetch(Word);
|
|
|
|
auto cs = fetch(Word);
|
|
|
|
r.cs = cs;
|
|
|
|
r.ip = ip;
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionCallNear() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(4);
|
|
|
|
auto offset = (int16)fetch(Word);
|
|
|
|
push(r.ip);
|
|
|
|
r.ip += offset;
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionCallFar() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(9);
|
|
|
|
auto ip = fetch(Word);
|
|
|
|
auto cs = fetch(Word);
|
|
|
|
push(r.cs);
|
|
|
|
push(r.ip);
|
|
|
|
r.cs = cs;
|
|
|
|
r.ip = ip;
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionReturn() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(5);
|
|
|
|
r.ip = pop();
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionReturnImm() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(5);
|
|
|
|
auto offset = fetch(Word);
|
|
|
|
r.ip = pop();
|
|
|
|
r.sp += offset;
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionReturnFar() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(7);
|
|
|
|
r.ip = pop();
|
|
|
|
r.cs = pop();
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionReturnFarImm() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(8);
|
|
|
|
auto offset = fetch(Word);
|
|
|
|
r.ip = pop();
|
|
|
|
r.cs = pop();
|
|
|
|
r.sp += offset;
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionReturnInt() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(9);
|
|
|
|
r.ip = pop();
|
|
|
|
r.cs = pop();
|
|
|
|
r.f = pop();
|
2016-02-04 21:18:06 +00:00
|
|
|
state.poll = false;
|
2016-02-04 10:29:08 +00:00
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionInt3() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(8);
|
|
|
|
interrupt(3);
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionIntImm() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(9);
|
|
|
|
interrupt(fetch());
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionInto() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(5);
|
|
|
|
interrupt(4);
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionEnter() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(7);
|
|
|
|
auto offset = fetch(Word);
|
|
|
|
auto length = fetch(Byte) & 0x1f;
|
|
|
|
push(r.bp);
|
|
|
|
r.bp = r.sp;
|
|
|
|
r.sp -= offset;
|
|
|
|
|
|
|
|
if(length) {
|
|
|
|
wait(length > 1 ? 7 : 6);
|
|
|
|
for(uint n = 1; n < length; n++) {
|
|
|
|
wait(4);
|
|
|
|
auto data = read(Word, segment(r.ss), r.bp - n * 2);
|
|
|
|
push(data);
|
|
|
|
}
|
|
|
|
push(r.bp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionLeave() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(1);
|
|
|
|
r.sp = r.bp;
|
|
|
|
r.bp = pop();
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionPushReg(uint16_t& reg) -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
push(reg);
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionPopReg(uint16_t& reg) -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
reg = pop();
|
2016-02-04 21:18:06 +00:00
|
|
|
if(® == &r.ss) state.poll = false;
|
2016-02-04 10:29:08 +00:00
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionPushFlags() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(1);
|
|
|
|
push(r.f);
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionPopFlags() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(2);
|
|
|
|
r.f = pop();
|
2016-02-04 21:18:06 +00:00
|
|
|
state.poll = false;
|
2016-02-04 10:29:08 +00:00
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionPushAll() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(8);
|
|
|
|
auto sp = r.sp;
|
|
|
|
push(r.ax);
|
|
|
|
push(r.cx);
|
|
|
|
push(r.dx);
|
|
|
|
push(r.bx);
|
|
|
|
push(sp);
|
|
|
|
push(r.bp);
|
|
|
|
push(r.si);
|
|
|
|
push(r.di);
|
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionPopAll() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
wait(7);
|
|
|
|
r.di = pop();
|
|
|
|
r.si = pop();
|
|
|
|
r.bp = pop();
|
|
|
|
auto sp = pop();
|
|
|
|
r.bx = pop();
|
|
|
|
r.dx = pop();
|
|
|
|
r.cx = pop();
|
|
|
|
r.ax = pop();
|
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
|
|
|
//r.sp is not restored
|
2016-02-04 10:29:08 +00:00
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionPushImm(Size size) -> void {
|
2016-02-16 09:27:55 +00:00
|
|
|
if(size == Byte) push((int8)fetch(Byte));
|
|
|
|
if(size == Word) push(fetch(Word));
|
2016-02-04 10:29:08 +00:00
|
|
|
}
|
|
|
|
|
2017-08-10 11:26:02 +00:00
|
|
|
auto V30MZ::instructionPopMem() -> void {
|
2016-02-04 10:29:08 +00:00
|
|
|
modRM();
|
|
|
|
setMem(Word, pop());
|
|
|
|
}
|