X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2FDrZ80%2Fdrz80.s;h=846c6362b2640f3056e80b720c8157523dfd6635;hb=2b02d6e533b114456785f39a356476eb97306fcf;hp=9b07a133b551ce8d7ee1fcb2acdfe02506b49caa;hpb=170435846c8e2309dc4011f954287f9ea861a6b6;p=picodrive.git diff --git a/cpu/DrZ80/drz80.s b/cpu/DrZ80/drz80.s index 9b07a13..846c636 100644 --- a/cpu/DrZ80/drz80.s +++ b/cpu/DrZ80/drz80.s @@ -24,7 +24,7 @@ .extern PicoRead8 .extern Pico .extern z80_write - .extern ym2612_st + .extern ym2612_read_local_z80 .endif DrZ80Ver: .long 0x0001 @@ -360,8 +360,8 @@ pico_z80_write16: @ data, addr str z80pc,[cpucontext,#z80pc_pointer] .endif .if DRZ80_FOR_PICODRIVE - bic r0,r0,#0xfe000 ldr r1,[cpucontext,#z80pc_base] + bic r0,r0,#0xfe000 add z80pc,r1,r0 .else stmfd sp!,{r3,r12} @@ -1372,30 +1372,32 @@ DrZ80Run: mov z80_icount,r1 ;@ setup number of Tstates to execute .if INTERRUPT_MODE == 0 - ldrh r0,[cpucontext,#z80irq] @ 0x4C + ldrh r0,[cpucontext,#z80irq] @ 0x4C, irq and IFF bits .endif ldmia cpucontext,{z80pc-z80sp} ;@ load Z80 registers .if INTERRUPT_MODE == 0 ;@ check ints - tst r0,#1 - movnes r0,r0,lsr #8 - blne DoInterrupt + tst r0,#0xff + movne r0,r0,lsr #8 + tstne r0,#1 + blne DoInterrupt .endif - ldrb r0,[z80pc],#1 ;@ get first op code 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: ;@ save registers in CPU context 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 +MAIN_opcodes_POINTER2: .word MAIN_opcodes .if INTERRUPT_MODE Interrupt_local: .word Interrupt .endif @@ -1414,6 +1416,8 @@ DoInterrupt: ldmia cpucontext,{z80pc-z80sp} ;@ load Z80 registers mov pc,lr ;@ return .else + + ;@ r0 == z80if stmfd sp!,{lr} tst r0,#4 ;@ check halt @@ -1426,10 +1430,9 @@ DoInterrupt: strb r0,[cpucontext,#z80if] ;@ now check int mode - tst r1,#1 - bne DoInterrupt_mode1 - tst r1,#2 - bne DoInterrupt_mode2 + cmp r1,#1 + beq DoInterrupt_mode1 + bgt DoInterrupt_mode2 DoInterrupt_mode0: ;@ get 3 byte vector @@ -1459,6 +1462,7 @@ DoInterrupt_mode0: ;@ rebase new pc rebasepc + eatcycles 13 b DoInterrupt_end 1: @@ -1473,6 +1477,7 @@ DoInterrupt_mode0: ;@ rebase new pc rebasepc + eatcycles 13 b DoInterrupt_end DoInterrupt_mode1: @@ -1482,6 +1487,7 @@ DoInterrupt_mode1: mov r0,#0x38 rebasepc + eatcycles 13 b DoInterrupt_end DoInterrupt_mode2: @@ -1518,18 +1524,19 @@ DoInterrupt_mode2: ldmfd sp!,{r3,r12} mov z80pc,r0 .endif + eatcycles 17 DoInterrupt_end: ;@ interupt accepted so callback irq interface ldr r0,[cpucontext, #z80irqcallback] tst r0,r0 + streqb r0,[cpucontext,#z80irq] ;@ default handling ldmeqfd sp!,{pc} stmfd sp!,{r3,r12} mov lr,pc mov pc,r0 ;@ call callback function ldmfd sp!,{r3,r12} ldmfd sp!,{pc} ;@ return - .endif .data @@ -4568,7 +4575,7 @@ opcode_3_8: tst z80f,#1<