mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
32x and sms savestates. Core-independent z80 state. SS bugfixing/refactoring.
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@868 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
a736af3ecf
commit
b4db550e41
19 changed files with 1116 additions and 848 deletions
|
@ -19,7 +19,6 @@
|
|||
|
||||
.if DRZ80_XMAP
|
||||
.equ Z80_MEM_SHIFT, 13
|
||||
;@ note: stack is locked in single bank that z80sp_base points to
|
||||
.endif
|
||||
|
||||
.if INTERRUPT_MODE
|
||||
|
@ -206,12 +205,30 @@ z80_xmap_rebase_pc:
|
|||
bxcc lr
|
||||
|
||||
z80_bad_jump:
|
||||
ldr r0,[cpucontext,#z80_read8]
|
||||
ldr r0,[r0]
|
||||
str r0,[cpucontext,#z80pc_base]
|
||||
stmfd sp!,{r3,r12,lr}
|
||||
mov lr,pc
|
||||
ldr pc,[cpucontext,#z80_rebasePC]
|
||||
mov z80pc,r0
|
||||
bx lr
|
||||
.endif
|
||||
ldmfd sp!,{r3,r12,pc}
|
||||
|
||||
z80_xmap_rebase_sp:
|
||||
ldr r1,[cpucontext,#z80_read8]
|
||||
sub r2,r0,#1
|
||||
mov r2,r2,lsl #16
|
||||
mov r2,r2,lsr #(Z80_MEM_SHIFT+16)
|
||||
ldr r1,[r1,r2,lsl #2]
|
||||
movs r1,r1,lsl #1
|
||||
strcc r1,[cpucontext,#z80sp_base]
|
||||
addcc z80sp,r1,r0
|
||||
bxcc lr
|
||||
|
||||
stmfd sp!,{r3,r12,lr}
|
||||
mov lr,pc
|
||||
ldr pc,[cpucontext,#z80_rebaseSP]
|
||||
mov z80sp,r0
|
||||
ldmfd sp!,{r3,r12,pc}
|
||||
|
||||
.endif @ DRZ80_XMAP
|
||||
|
||||
|
||||
.macro fetch cycs
|
||||
|
@ -367,15 +384,13 @@ z80_bad_jump:
|
|||
str z80pc,[cpucontext,#z80pc_pointer]
|
||||
.endif
|
||||
.if DRZ80_XMAP
|
||||
;@ XXX: SP is locked to single back z80sp_base points to.
|
||||
ldr r1,[cpucontext,#z80sp_base]
|
||||
bic r0,r0,#0x7f<<Z80_MEM_SHIFT
|
||||
add r0,r1,r0
|
||||
bl z80_xmap_rebase_sp
|
||||
.else
|
||||
stmfd sp!,{r3,r12}
|
||||
mov lr,pc
|
||||
ldr pc,[cpucontext,#z80_rebaseSP] ;@ external function must rebase sp
|
||||
ldmfd sp!,{r3,r12}
|
||||
mov z80sp,r0
|
||||
.endif
|
||||
.endm
|
||||
;@----------------------------------------------------------------------------
|
||||
|
@ -4492,7 +4507,6 @@ opcode_3_1:
|
|||
.if FAST_Z80SP
|
||||
orr r0,r0,r1, lsl #8
|
||||
rebasesp
|
||||
mov z80sp,r0
|
||||
.else
|
||||
orr z80sp,r0,r1, lsl #8
|
||||
.endif
|
||||
|
@ -5567,7 +5581,6 @@ opcode_F_9:
|
|||
.if FAST_Z80SP
|
||||
mov r0,z80hl, lsr #16
|
||||
rebasesp
|
||||
mov z80sp,r0
|
||||
.else
|
||||
mov z80sp,z80hl, lsr #16
|
||||
.endif
|
||||
|
@ -7433,7 +7446,6 @@ opcode_DD_F9:
|
|||
.if FAST_Z80SP
|
||||
ldrh r0,[z80xx,#2]
|
||||
rebasesp
|
||||
mov z80sp,r0
|
||||
.else
|
||||
ldrh z80sp,[z80xx,#2]
|
||||
.endif
|
||||
|
@ -7771,8 +7783,9 @@ opcode_ED_7B:
|
|||
readmem16
|
||||
.if FAST_Z80SP
|
||||
rebasesp
|
||||
.endif
|
||||
.else
|
||||
mov z80sp,r0
|
||||
.endif
|
||||
fetch 20
|
||||
;@LDI
|
||||
opcode_ED_A0:
|
||||
|
|
|
@ -394,8 +394,8 @@ void Cz80_Set_Reg(cz80_struc *CPU, INT32 regnum, UINT32 val)
|
|||
case CZ80_R: zR = val; break;
|
||||
case CZ80_I: zI = val; break;
|
||||
case CZ80_IM: zIM = val; break;
|
||||
case CZ80_IFF1: zIFF1 = val; break;
|
||||
case CZ80_IFF2: zIFF2 = val; break;
|
||||
case CZ80_IFF1: zIFF1 = val ? (1 << 2) : 0; break;
|
||||
case CZ80_IFF2: zIFF2 = val ? (1 << 2) : 0; break;
|
||||
case CZ80_HALT: CPU->HaltState = val; break;
|
||||
case CZ80_IRQ: CPU->IRQState = val; break;
|
||||
default: break;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "sh2.h"
|
||||
#include "../debug.h"
|
||||
#include "compiler.h"
|
||||
|
@ -85,3 +87,31 @@ void sh2_internal_irq(SH2 *sh2, int level, int vector)
|
|||
sh2->test_irq = 1;
|
||||
}
|
||||
|
||||
#define SH2_REG_SIZE (offsetof(SH2, macl) + sizeof(sh2->macl))
|
||||
|
||||
void sh2_pack(const SH2 *sh2, unsigned char *buff)
|
||||
{
|
||||
unsigned int *p;
|
||||
|
||||
memcpy(buff, sh2, SH2_REG_SIZE);
|
||||
p = (void *)(buff + SH2_REG_SIZE);
|
||||
|
||||
p[0] = sh2->pending_int_irq;
|
||||
p[1] = sh2->pending_int_vector;
|
||||
p[2] = sh2->cycles_aim;
|
||||
p[3] = sh2->cycles_done;
|
||||
}
|
||||
|
||||
void sh2_unpack(SH2 *sh2, const unsigned char *buff)
|
||||
{
|
||||
unsigned int *p;
|
||||
|
||||
memcpy(sh2, buff, SH2_REG_SIZE);
|
||||
p = (void *)(buff + SH2_REG_SIZE);
|
||||
|
||||
sh2->pending_int_irq = p[0];
|
||||
sh2->pending_int_vector = p[1];
|
||||
sh2->cycles_aim = p[2];
|
||||
sh2->cycles_done = p[3];
|
||||
}
|
||||
|
||||
|
|
|
@ -64,9 +64,14 @@ void sh2_reset(SH2 *sh2);
|
|||
void sh2_irl_irq(SH2 *sh2, int level, int nested_call);
|
||||
void sh2_internal_irq(SH2 *sh2, int level, int vector);
|
||||
void sh2_do_irq(SH2 *sh2, int level, int vector);
|
||||
void sh2_pack(const SH2 *sh2, unsigned char *buff);
|
||||
void sh2_unpack(SH2 *sh2, const unsigned char *buff);
|
||||
|
||||
void sh2_execute(SH2 *sh2, int cycles);
|
||||
|
||||
// regs, pending_int*, cycles, reserved
|
||||
#define SH2_STATE_SIZE ((24 + 2 + 2 + 12) * 4)
|
||||
|
||||
// pico memhandlers
|
||||
// XXX: move somewhere else
|
||||
unsigned int REGPARM(2) p32x_sh2_read8(unsigned int a, SH2 *sh2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue