mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-10-27 00:29:39 -04:00
adjusted timing and fixed EI in DrZ80
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@472 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
c299a73848
commit
de89bf45d7
1 changed files with 33 additions and 26 deletions
|
|
@ -360,8 +360,8 @@ pico_z80_write16: @ data, addr
|
||||||
str z80pc,[cpucontext,#z80pc_pointer]
|
str z80pc,[cpucontext,#z80pc_pointer]
|
||||||
.endif
|
.endif
|
||||||
.if DRZ80_FOR_PICODRIVE
|
.if DRZ80_FOR_PICODRIVE
|
||||||
bic r0,r0,#0xfe000
|
|
||||||
ldr r1,[cpucontext,#z80pc_base]
|
ldr r1,[cpucontext,#z80pc_base]
|
||||||
|
bic r0,r0,#0xfe000
|
||||||
add z80pc,r1,r0
|
add z80pc,r1,r0
|
||||||
.else
|
.else
|
||||||
stmfd sp!,{r3,r12}
|
stmfd sp!,{r3,r12}
|
||||||
|
|
@ -1372,30 +1372,32 @@ DrZ80Run:
|
||||||
mov z80_icount,r1 ;@ setup number of Tstates to execute
|
mov z80_icount,r1 ;@ setup number of Tstates to execute
|
||||||
|
|
||||||
.if INTERRUPT_MODE == 0
|
.if INTERRUPT_MODE == 0
|
||||||
ldrh r0,[cpucontext,#z80irq] @ 0x4C
|
ldrh r0,[cpucontext,#z80irq] @ 0x4C, irq and IFF bits
|
||||||
.endif
|
.endif
|
||||||
ldmia cpucontext,{z80pc-z80sp} ;@ load Z80 registers
|
ldmia cpucontext,{z80pc-z80sp} ;@ load Z80 registers
|
||||||
|
|
||||||
.if INTERRUPT_MODE == 0
|
.if INTERRUPT_MODE == 0
|
||||||
;@ check ints
|
;@ check ints
|
||||||
tst r0,#1
|
tst r0,#0xff
|
||||||
movnes r0,r0,lsr #8
|
movne r0,r0,lsr #8
|
||||||
blne DoInterrupt
|
tstne r0,#1
|
||||||
|
blne DoInterrupt
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
ldrb r0,[z80pc],#1 ;@ get first op code
|
|
||||||
ldr opcodes,MAIN_opcodes_POINTER2
|
ldr opcodes,MAIN_opcodes_POINTER2
|
||||||
ldr pc,[opcodes,r0, lsl #2] ;@ execute op code
|
|
||||||
|
|
||||||
MAIN_opcodes_POINTER2: .word MAIN_opcodes
|
cmp z80_icount,#0 ;@ irq might have used all cycles
|
||||||
|
ldrplb r0,[z80pc],#1
|
||||||
|
ldrpl pc,[opcodes,r0, lsl #2]
|
||||||
|
|
||||||
|
|
||||||
z80_execute_end:
|
z80_execute_end:
|
||||||
;@ save registers in CPU context
|
;@ save registers in CPU context
|
||||||
stmia cpucontext,{z80pc-z80sp} ;@ save Z80 registers
|
stmia cpucontext,{z80pc-z80sp} ;@ save Z80 registers
|
||||||
mov r0,z80_icount
|
mov r0,z80_icount
|
||||||
ldmia sp!,{r4-r12,pc} ;@ restore registers from stack and return to C code
|
ldmia sp!,{r4-r12,pc} ;@ restore registers from stack and return to C code
|
||||||
|
|
||||||
|
MAIN_opcodes_POINTER2: .word MAIN_opcodes
|
||||||
.if INTERRUPT_MODE
|
.if INTERRUPT_MODE
|
||||||
Interrupt_local: .word Interrupt
|
Interrupt_local: .word Interrupt
|
||||||
.endif
|
.endif
|
||||||
|
|
@ -1414,6 +1416,8 @@ DoInterrupt:
|
||||||
ldmia cpucontext,{z80pc-z80sp} ;@ load Z80 registers
|
ldmia cpucontext,{z80pc-z80sp} ;@ load Z80 registers
|
||||||
mov pc,lr ;@ return
|
mov pc,lr ;@ return
|
||||||
.else
|
.else
|
||||||
|
|
||||||
|
;@ r0 == z80if
|
||||||
stmfd sp!,{lr}
|
stmfd sp!,{lr}
|
||||||
|
|
||||||
tst r0,#4 ;@ check halt
|
tst r0,#4 ;@ check halt
|
||||||
|
|
@ -1426,10 +1430,9 @@ DoInterrupt:
|
||||||
strb r0,[cpucontext,#z80if]
|
strb r0,[cpucontext,#z80if]
|
||||||
|
|
||||||
;@ now check int mode
|
;@ now check int mode
|
||||||
tst r1,#1
|
cmp r1,#1
|
||||||
bne DoInterrupt_mode1
|
beq DoInterrupt_mode1
|
||||||
tst r1,#2
|
bgt DoInterrupt_mode2
|
||||||
bne DoInterrupt_mode2
|
|
||||||
|
|
||||||
DoInterrupt_mode0:
|
DoInterrupt_mode0:
|
||||||
;@ get 3 byte vector
|
;@ get 3 byte vector
|
||||||
|
|
@ -1459,6 +1462,7 @@ DoInterrupt_mode0:
|
||||||
;@ rebase new pc
|
;@ rebase new pc
|
||||||
rebasepc
|
rebasepc
|
||||||
|
|
||||||
|
eatcycles 13
|
||||||
b DoInterrupt_end
|
b DoInterrupt_end
|
||||||
|
|
||||||
1:
|
1:
|
||||||
|
|
@ -1473,6 +1477,7 @@ DoInterrupt_mode0:
|
||||||
;@ rebase new pc
|
;@ rebase new pc
|
||||||
rebasepc
|
rebasepc
|
||||||
|
|
||||||
|
eatcycles 13
|
||||||
b DoInterrupt_end
|
b DoInterrupt_end
|
||||||
|
|
||||||
DoInterrupt_mode1:
|
DoInterrupt_mode1:
|
||||||
|
|
@ -1482,6 +1487,7 @@ DoInterrupt_mode1:
|
||||||
mov r0,#0x38
|
mov r0,#0x38
|
||||||
rebasepc
|
rebasepc
|
||||||
|
|
||||||
|
eatcycles 13
|
||||||
b DoInterrupt_end
|
b DoInterrupt_end
|
||||||
|
|
||||||
DoInterrupt_mode2:
|
DoInterrupt_mode2:
|
||||||
|
|
@ -1518,18 +1524,19 @@ DoInterrupt_mode2:
|
||||||
ldmfd sp!,{r3,r12}
|
ldmfd sp!,{r3,r12}
|
||||||
mov z80pc,r0
|
mov z80pc,r0
|
||||||
.endif
|
.endif
|
||||||
|
eatcycles 17
|
||||||
|
|
||||||
DoInterrupt_end:
|
DoInterrupt_end:
|
||||||
;@ interupt accepted so callback irq interface
|
;@ interupt accepted so callback irq interface
|
||||||
ldr r0,[cpucontext, #z80irqcallback]
|
ldr r0,[cpucontext, #z80irqcallback]
|
||||||
tst r0,r0
|
tst r0,r0
|
||||||
|
streqb r0,[cpucontext,#z80irq] ;@ default handling
|
||||||
ldmeqfd sp!,{pc}
|
ldmeqfd sp!,{pc}
|
||||||
stmfd sp!,{r3,r12}
|
stmfd sp!,{r3,r12}
|
||||||
mov lr,pc
|
mov lr,pc
|
||||||
mov pc,r0 ;@ call callback function
|
mov pc,r0 ;@ call callback function
|
||||||
ldmfd sp!,{r3,r12}
|
ldmfd sp!,{r3,r12}
|
||||||
ldmfd sp!,{pc} ;@ return
|
ldmfd sp!,{pc} ;@ return
|
||||||
|
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
.data
|
.data
|
||||||
|
|
@ -5194,7 +5201,7 @@ opcode_C_8:
|
||||||
fetch 5
|
fetch 5
|
||||||
|
|
||||||
opcode_C_9_cond:
|
opcode_C_9_cond:
|
||||||
sub z80_icount,#1
|
eatcycles 1
|
||||||
;@RET
|
;@RET
|
||||||
opcode_C_9:
|
opcode_C_9:
|
||||||
opPOP
|
opPOP
|
||||||
|
|
@ -5615,13 +5622,12 @@ EI_DUMMY_opcodes_POINTER: .word EI_DUMMY_opcodes
|
||||||
;@EI
|
;@EI
|
||||||
opcode_F_B:
|
opcode_F_B:
|
||||||
ldrb r1,[cpucontext,#z80if]
|
ldrb r1,[cpucontext,#z80if]
|
||||||
tst r1,#Z80_IF1
|
mov r2,opcodes
|
||||||
bne ei_return_exit
|
|
||||||
|
|
||||||
orr r1,r1,#(Z80_IF1)|(Z80_IF2)
|
orr r1,r1,#(Z80_IF1)|(Z80_IF2)
|
||||||
strb r1,[cpucontext,#z80if]
|
strb r1,[cpucontext,#z80if]
|
||||||
|
|
||||||
mov r2,opcodes
|
ldrb r0,[z80pc],#1
|
||||||
|
eatcycles 4
|
||||||
ldr opcodes,EI_DUMMY_opcodes_POINTER
|
ldr opcodes,EI_DUMMY_opcodes_POINTER
|
||||||
ldr pc,[r2,r0, lsl #2]
|
ldr pc,[r2,r0, lsl #2]
|
||||||
|
|
||||||
|
|
@ -5629,16 +5635,17 @@ ei_return:
|
||||||
;@point that program returns from EI to check interupts
|
;@point that program returns from EI to check interupts
|
||||||
;@an interupt can not be taken directly after a EI opcode
|
;@an interupt can not be taken directly after a EI opcode
|
||||||
;@ reset z80pc and opcode pointer
|
;@ reset z80pc and opcode pointer
|
||||||
ldrh r0,[cpucontext,#z80irq] @ 0x4C
|
ldrh r0,[cpucontext,#z80irq] @ 0x4C, irq and IFF bits
|
||||||
sub z80pc,z80pc,#1
|
sub z80pc,z80pc,#1
|
||||||
ldr opcodes,MAIN_opcodes_POINTER
|
ldr opcodes,MAIN_opcodes_POINTER
|
||||||
;@ check ints
|
;@ check ints
|
||||||
tst r0,#1
|
tst r0,#0xff
|
||||||
movnes r0,r0,lsr #8
|
movne r0,r0,lsr #8
|
||||||
blne DoInterrupt
|
tstne r0,#1
|
||||||
|
blne DoInterrupt
|
||||||
|
|
||||||
;@ continue
|
;@ continue
|
||||||
ei_return_exit:
|
fetch 0
|
||||||
fetch 4
|
|
||||||
|
|
||||||
;@CALL M,NN
|
;@CALL M,NN
|
||||||
opcode_F_C:
|
opcode_F_C:
|
||||||
|
|
@ -8048,5 +8055,5 @@ opcode_ED_BB:
|
||||||
;@end_loop:
|
;@end_loop:
|
||||||
;@ b end_loop
|
;@ b end_loop
|
||||||
|
|
||||||
|
;@ vim:filetype=armasm
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue