6 ;@ MASK_EMUL MASK_MEM MASK_INDEX Jump Table
7 ;@ TRUE ? ? jumptable1 Mode 0 : M=1,X=1
8 ;@ FALSE TRUE TRUE jumptable1 Mode 0 : M=1,X=1
9 ;@ FALSE TRUE FALSE jumptable2 Mode 1 : M=1,X=0
10 ;@ FALSE FALSE TRUE jumptable4 Mode 3 : M=0,X=1
11 ;@ FALSE FALSE FALSE jumptable3 Mode 2 : M=0,X=0
13 opcodetable_lookup_addr opcodetable_lookup
15 .word jumptable3 ;@ 000
16 .word jumptable4 ;@ 001
17 .word jumptable2 ;@ 010
18 .word jumptable1 ;@ 011
19 .word jumptable1 ;@ 100
20 .word jumptable1 ;@ 101
21 .word jumptable1 ;@ 110
22 .word jumptable1 ;@ 111
25 ldr r0,opcodetable_lookup_addr
26 and r1,reg_f,MASK_EMUL MASK_MEM MASK_INDEX
27 ldr opcodes,[r0,r1,lsl#2]
47 .equ STATUS_SHIFTER, 24
48 .equ MASK_EMUL, (1<<(STATUS_SHIFTER-1))
49 .equ MASK_SHIFTER_CARRY, (STATUS_SHIFTER+1)
50 .equ MASK_CARRY, (1<<(STATUS_SHIFTER)) @ 0
51 .equ MASK_ZERO, (2<<(STATUS_SHIFTER)) @ 1
52 .equ MASK_IRQ, (4<<(STATUS_SHIFTER)) @ 2
53 .equ MASK_DECIMAL, (8<<(STATUS_SHIFTER)) @ 3
54 .equ MASK_INDEX, (16<<(STATUS_SHIFTER)) @ 4 @ 1
55 .equ MASK_MEM, (32<<(STATUS_SHIFTER)) @ 5 @ 2
56 .equ MASK_OVERFLOW, (64<<(STATUS_SHIFTER)) @ 6 @ 4
57 .equ MASK_NEG, (128<<(STATUS_SHIFTER))@ 7 @ 8
67 ;@push16 - saves a 16bit value onto stack
68 ;@ r0 = address 0x0000HHLL
69 ;@ r1 = data 0x0000HHLL
73 ldr pc,[cpu_context,#writemem16] ;@ r0 = address r1=data
77 ;@push16 - saves a 8bit value onto stack
78 ;@ r0 = address 0x0000HHLL
79 ;@ r1 = data 0x0000HHLL
83 ldr pc,[cpu_context,#writemem8] ;@ r0 = address r1=data
87 .macro mov_reg_sp_to_r0
140 ldr r1,[cpu_context,#pc_base]
145 .macro getSnesFlags reg
146 sub \reg,[cpu_context,#snes_flag_lookup]
147 ldr \reg,[\reg,reg_f>>24]
152 ;@ IRQ flag has ben raised
155 ;@ re-calculates reg_pc and pc_base
156 ;@ in: r0=new snes pc
157 ;@ out: r0=new arm pc
161 ldr pc,[cpu_context,#rebase_pc]
167 subs cycles,cycles,#\cyc
168 ldrplb r0,[reg_pc],#1
169 ldrpl pc,[opcodes,r0, lsl #2]
180 ;@ cycle count has expired
182 ;@ All cpu cycles requested have been used
183 ;@ NMI interupt has occurred
184 ;@ IRQ interupt has occurred
185 ;@ Check which counter has expired
186 ;@ if normal cycle count then exit cpu emulation
187 ;@ this will only occur while NMI and IRQ ints are NOT pending
188 ;@ if NMI cycle count then raise NMI interrupt
189 ;@ then continue cpu emulation using IRQ cycle count (if any) otherwise use remaining cycle count
190 ;@ which would already be adjusted to remove NMI cycles used.
191 ;@ count between normal cycles and IRQ cycles.
192 ;@ if IRQ cycle count then raise IRQ interrupt.
200 jumptable1: .long Op00mod1
458 jumptable2: .long Op00mod2
715 jumptable3: .long Op00mod3
972 jumptable4: .long Op00mod4
1230 ;@ ##############################################
1232 ;@ ##############################################
1236 ;@ Only used by SuperFX emulation
1238 strb r0,[cpu_context,#BRKTriggered]
1240 tst reg_f, #MASK_EMUL
1247 clearFlag #MASK_DECIMAL
1249 bic reg_p_bank, reg_p_bank, #0xFF
1261 clearFlag #MASK_DECIMAL
1263 bic reg_p_bank, reg_p_bank, #0xFF