FDSSoundReset();\r
InDisk=0;\r
SelectDisk=0;\r
+\r
+#ifdef ASM_6502\r
+ {\r
+ int page;\r
+ // asm code needs pages to be set again..\r
+ for (page=12; page<28; page++) // 0x6000-0xdfff 32K RAM\r
+ Page[page]=FDSRAM - (page<<11) + ((page-12)<<11);\r
+ for (; page<32; page++) // 0xe000-0xffff 8K BIOS\r
+ Page[page]=FDSBIOS - (page<<11) + ((page-28)<<11);\r
+ }\r
+#endif\r
}\r
\r
void FCEU_FDSInsert(void)\r
\r
static void FP_FASTAPASS(1) FDSFix(int a)\r
{\r
- if((IRQa&2) && IRQCount)\r
+ if(IRQCount && (IRQa&2))\r
{\r
IRQCount-=a;\r
if(IRQCount<=0)\r
uint8 ret=0;\r
\r
/* Cheap hack. */\r
+#ifndef ASM_6502\r
if(X.IRQlow&FCEU_IQEXT) ret|=1;\r
if(X.IRQlow&FCEU_IQEXT2) ret|=2;\r
+#else\r
+ if((nes_registers[4]>>8)&FCEU_IQEXT) ret|=1;\r
+ if((nes_registers[4]>>8)&FCEU_IQEXT2) ret|=2;\r
+#endif\r
\r
if(!fceuindbg)\r
{\r
clockcount=(clockcount+1)&7;\r
}\r
\r
-static INLINE int32 FDSDoSound(void)\r
+static INLINE int32 FDSDoSound(int32 mul)\r
{\r
fdso.count+=fdso.cycles;\r
if(fdso.count>=((int64)1<<40))\r
if(fdso.count>=32768) goto dogk;\r
\r
// Might need to emulate applying the amplitude to the waveform a bit better...\r
+/*\r
{\r
int k=amplitude[0];\r
if(k>0x20) k=0x20;\r
return (fdso.cwave[b24latch68>>19]*k)*4/((SPSG[0x9]&0x3)+2);\r
}\r
+*/\r
+ return (fdso.cwave[b24latch68>>19]*mul)>>16;\r
}\r
\r
static int32 FBC=0;\r
{\r
int32 end, start;\r
int32 x;\r
+ int32 mul;\r
\r
start=FBC;\r
end=(SOUNDTS<<16)/soundtsinc;\r
return;\r
FBC=end;\r
\r
+ // hack for performance, might produce bad results..\r
+ if (!amplitude[0])\r
+ return;\r
+\r
+ switch (SPSG[0x9]&0x3)\r
+ {\r
+ default:mul = (4<<16)/2;\r
+ case 1: mul = (4<<16)/3;\r
+ case 2: mul = (4<<16)/4;\r
+ case 3: mul = (4<<16)/5;\r
+ }\r
+ {\r
+ int k=amplitude[0];\r
+ if(k>0x20) k=0x20;\r
+ mul *= k;\r
+ }\r
+\r
if(!(SPSG[0x9]&0x80))\r
for(x=start;x<end;x++)\r
{\r
- uint32 t=FDSDoSound();\r
+ uint32 t=FDSDoSound(mul);\r
t+=t>>1;\r
t>>=4;\r
Wave[x>>4]+=t; //(t>>2)-(t>>3); //>>3;\r
@@@
@@@ ¤Ê¤ó¤«Ì¾Á°¤¬ÊѤÀ¤Ê(¤É¡¼¤Ç¤â¤¤¡¼¤±¤É¡¼
@@@
-.macro CYCLE_NEXT n, hook_check=1, do_cyc_add=1
+.macro CYCLE_NEXT n, unused=0, do_cyc_add=1
@@DEBUG_INFO
.if \do_cyc_add
.endif
subs REG_CYCLE, REG_CYCLE, #\n*48<<16
ble cpu_exec_end
-.if \hook_check
tst REG_P_REST, #1<<16
- blne do_irq_hook
-.endif
+ bne do_irq_hook
+
ldrb r0, [REG_PC], #1
tst REG_P_REST, #0xff<<8
ldreq pc, [REG_OP_TABLE, r0, lsl #2]
@ do some messing to find out which IRQ is pending..
- tst REG_P_REST, #FCEU_IQNMI<<8
- bne do_int
+ @ assumption: NMI can be set only on very first run, because it is only set once before vblank..
+@ tst REG_P_REST, #FCEU_IQNMI<<8
+@ bne do_int
tst REG_P_REST, #P_REST_I_FLAG
@@ if I_FLAG=1, continue execution, don't trigger IRQ
bicne REG_P_REST, REG_P_REST, #FCEU_IQTEMP<<8
@ ldr REG_OP_TABLE, = cpu_exec_table @ set on init
- CYCLE_NEXT 0, 0
+ ldrb r0, [REG_PC], #1
+ tst REG_P_REST, #0xff<<8
+ ldreq pc, [REG_OP_TABLE, r0, lsl #2]
+
+ @ assumption: NMI can be set only on very first run, because it is only set once before vblank..
+ tst REG_P_REST, #FCEU_IQNMI<<8
+ bne do_int
+ tst REG_P_REST, #P_REST_I_FLAG
+ @@ if I_FLAG=1, continue execution, don't trigger IRQ
+ bicne REG_P_REST, REG_P_REST, #FCEU_IQTEMP<<8
+ ldrne pc, [REG_OP_TABLE, r0, lsl #2]
+ @@ I_FLAG=0 and REST is checked, we have a IRQ
+ b do_int
+
cpu_exec_end:
FLUSH_TIMESTAMP r0
tst REG_P_REST, #1<<16
- blne do_irq_hook_noflushts
+ bne do_irq_hook_final
ldr r0, =nes_registers
stmia r0, {r4-r12}
.fill 0x100, 1, 0
nes_stack:
.fill 0x700, 1, 0
-@ TODO: write code which keeps it up-to-date
pc_base:
.long 0
MapIRQHook:
do_irq_hook:
FLUSH_TIMESTAMP r0
-do_irq_hook_noflushts:
@ get irqhook cycles
and r0, REG_CYCLE, #0xff00
- bic REG_CYCLE, REG_CYCLE, #0xff00
mov r0, r0, lsr #8
#ifndef DEBUG_ASM_6502
@ I have reviewed all MapIRQHook functions, they only seem to cause IRQs, not messing cycles or something
str REG_P_REST, [REG_OP_TABLE, #(OTOFFS_NES_REGS + 0x10)] @ might set irq
- mov REG_P_REST, lr @ r8
+ mov REG_P_REST, REG_OP_TABLE @ r8
@ if somebody modifies MapIRQHook without calling reset, we are doomed
mov lr, pc
ldr pc, [REG_OP_TABLE, #OTOFFS_IRQ_HOOK]
- ldr REG_OP_TABLE, =cpu_exec_table @ got trashed because was in r12
- mov lr, REG_P_REST
+ mov REG_OP_TABLE, REG_P_REST @ got trashed because was in r12
ldr REG_P_REST, [REG_OP_TABLE, #(OTOFFS_NES_REGS + 0x10)] @ might set irq
#else
ldr r1, =mapirq_cyc_a
str r0, [r1]
mov r1, r0
#endif
+
+ ldrb r0, [REG_PC], #1
+ bic REG_CYCLE, REG_CYCLE, #0xff00
+ tst REG_P_REST, #0xff<<8
+ ldreq pc, [REG_OP_TABLE, r0, lsl #2]
+
+ @ do some messing to find out which IRQ is pending..
+ tst REG_P_REST, #P_REST_I_FLAG
+ @@ if I_FLAG=1, continue execution, don't trigger IRQ
+ bicne REG_P_REST, REG_P_REST, #FCEU_IQTEMP<<8
+ ldrne pc, [REG_OP_TABLE, r0, lsl #2]
+ @@ I_FLAG=0 and REST is checked, we have a IRQ
+ b do_int
+
+
+do_irq_hook_final:
+ ldr r1, =nes_registers
+
+ @ get irqhook cycles
+ and r0, REG_CYCLE, #0xff00
+ bic REG_CYCLE, REG_CYCLE, #0xff00
+ mov r0, r0, lsr #8
+
+ stmia r1, {r4-r12}
+
+ ldmfd r13!,{r4-r11,lr}
+
+#ifndef DEBUG_ASM_6502
+ ldr pc, [REG_OP_TABLE, #OTOFFS_IRQ_HOOK]
+#else
+ ldr r1, =mapirq_cyc_a
+ str r0, [r1]
+ mov r1, r0
bx lr
+#endif
@ vim:filetype=armasm