; SPDX-License-Identifier: MIT ; Probe 06: the S-CPU/S-SMP port race (snes-python docs/status.md "The port races"). ; ; The question. Kishin Douji Zenki's S-SMP clears its four input ports (CONTROL $F1 bits ; 4-5) and then reads them, looping until all four read zero, while its S-CPU rewrites ; $2141 = $10 in a loop and waits for $AA: ; ; S-SMP 0965 mov a,$1D / or a,#$30 / mov $F1,a / nop / mov a,$F4 / or a,$F5 / ; or a,$F6 / or a,$F7 / bne $0965 ; S-CPU DA03D4 lda #$10 / sta $2141 / lda $2140 / cmp $2140 / bne -6 / cmp #$AA / bne -17 ; ; (read off the board's run of the game, 2026-11-24). The S-SMP's read of $F5 starts 8 ; S-SMP cycles after its CONTROL write; the S-CPU's loop is 126 master clocks in FastROM ; (6.01 S-SMP cycles), 166 across the line's DRAM refresh (7.91). If every write is ; visible at once and the clear acts at once, the zero can never be seen; the game boots ; on a console, so on a console it is. Somewhere inside one S-SMP cycle (21 master ; clocks) the window is shorter than 8 cycles: where in its cycle the clear acts, where ; the read samples, where a write lands. ; ; The measurement. The S-SMP runs a trial T times: a pseudo-random delay (an 8-bit LFSR, ; 1-16 DBNZ turns, so the trials land at every phase of the S-CPU's loop and of the ; refresh), the clear (mov a,#$30 / mov $F1,a: Zenki's instruction), D-3 cycles of ; padding, a read of $F5 (mov a,$F5: the read is the instruction's third cycle; D = 4 ; reads with mov a,!$00F5), and counts the trials whose read was not zero. Meanwhile the ; S-CPU runs one of 13 write loops, each rewriting $2141 = $10 once a turn, every M ; master clocks (M from the documented access times: ROM 8 clocks slow, 6 fast with ; MEMSEL; WRAM 8; B-bus and internal cycles 6; DOC fullsnes "CPU Clock Cycles", anomie's ; timing document), from bank $00 (SlowROM) or bank $80 with MEMSEL = 1 (FastROM): 26 ; values of M from 78 to 338. Grid: 11 S-SMP variants (D = 3..12, and Zenki's own ; sequence reading all four ports, "Z") x 26 loops = 286 cells. ; ; Reading it. With the trial's phase uniform, a trial sees zero when no write falls in ; the window W (master clocks from the clear taking effect to the read sampling). The ; S-CPU's writes come every M clocks, one gap per 1364-clock line is M + 40 (refresh), so ; hits/T = [(1324/M - 1) max(0, M - W) + max(0, M + 40 - W)] / 1364; ; scripts/port_race_results.py fits W for every D. W(D) - D x 20.97 is the answer the ; board needs, below one S-SMP cycle. ; ; The run order puts Zenki's own loop first (4096 trials a cell, 512 elsewhere). About ; 30 seconds on a console. Robust to resets as the probe suite is: a cell is marked ; started before it runs; a boot that finds a started cell marks it interrupted and goes ; on with the next one. The S-SMP is re-uploaded on every boot (reset resets it). ; ; Battery RAM (8 KiB at $70:0000; scripts/port_race_results.py decodes it): ; $0000 "SNESPRB6" ; $0008 format (1) $0009 run state: 0 new, 1 running, 2 complete ; $000A boots (16) $000C runs (16) ; $000E cells (16) $0010 next cell (16) ; $0012 cells interrupted by a reset (16) ; $0014 times the S-SMP did not answer (8) ; $0040 cells, 12 bytes each: loop (0-12), speed (1 fast, 0 slow), S-SMP variant ; (0-10), D (S-SMP cycles from the CONTROL write's cycle to the $F5 read's), T/256, ; M (16, master clocks), misses (16: reads that were not zero), status (0 not ; run, 1 started, 2 done, 3 interrupted), 2 spare ; ; The S-SMP program is written below as bytes (anomie's SPC700 opcode table; its cycle ; counts from spc700-python's table), assembled at its own address with .org. .include "common.inc" FORMAT = 1 SRAM_SIZE = $2000 NLOOPS = 13 NVARS = 11 NCELLS = NLOOPS * 2 * NVARS CELL = 12 S_FORMAT = $0008 S_STATE = $0009 S_BOOTS = $000A S_RUNS = $000C S_NCELLS = $000E S_NEXT = $0010 S_INTER = $0012 S_NOANS = $0014 S_CELLS = $0040 C_LOOP = 0 C_SPEED = 1 C_VAR = 2 C_D = 3 C_T256 = 4 C_M = 5 C_MISS = 7 C_STATUS = 9 MEMSEL = $420D JOY1H = $4219 SPC_ORG = $0200 ; S-CPU direct page ($10 up; $00-$0F is common.inc's) cell = $10 ; 16-bit, the cell index cptr = $12 ; 16-bit, the cell's offset in battery RAM rptr = $14 ; 24-bit, the write loop to call tmp = $18 ; 16-bit tmp2 = $1A ; 16-bit li = $1C ; loop index (table order) while building cells si = $1D ; speed index vi = $1E ; variant index held = $20 ; 16-bit wait = $22 ; 24-bit timeout counter .segment "CODE" Reset: ProbeStart stz MEMSEL jsr InitPPU jsr SramBoot jsr InitPPU PrintAt 2, TitleText PrintAt 3, SubtitleText PrintAt 5, Run1Text PrintAt 7, CellText PrintAt 11, Help1Text PrintAt 12, Help2Text PrintAt 13, Help3Text lda #$0F sta INIDISP jsr UploadSpc bcc :+ jmp NoAnswer : lda #$A5 ; the S-SMP program's "ready" jsr WaitPort0 bcc CellLoop jmp NoAnswer CellLoop: rep #$20 .a16 lda f:SRAM+S_NEXT cmp #NCELLS bcc :+ sep #$20 .a8 jmp AllDone : .a16 sta cell asl a ; cptr = S_CELLS + cell x 12 asl a sta tmp asl a clc adc tmp adc #S_CELLS sta cptr sep #$20 .a8 ldx cptr lda #1 sta f:SRAM+C_STATUS,x jsr ShowProgress ; The write loop: its address, in bank $80 (FastROM) or $00 (SlowROM). ldx cptr lda f:SRAM+C_LOOP,x rep #$20 .a16 and #$00FF asl a tay lda LoopAddr,y sta rptr sep #$20 .a8 ldx cptr lda f:SRAM+C_SPEED,x sta MEMSEL beq :+ lda #$80 : sta rptr+2 ; The command: variant on port 2, trials/256 on port 3, the raced value on port 1, ; then port 0 non-zero last. The S-SMP answers $55 and waits 1.5 ms before its first ; trial, by when the write loop is running. lda f:SRAM+C_VAR,x sta APUIO2 lda f:SRAM+C_T256,x sta APUIO3 lda #$10 sta APUIO1 lda #$01 sta APUIO0 lda #$55 jsr WaitPort0 bcs NoAnswer phk ; JSL to [rptr]: the loop ends with RTL per @back-1 jml [rptr] @back: .a8 .i16 stz MEMSEL jsr ReadResult ; tmp = misses ldx cptr lda tmp sta f:SRAM+C_MISS,x lda tmp+1 sta f:SRAM+C_MISS+1,x lda #2 sta f:SRAM+C_STATUS,x rep #$20 .a16 lda f:SRAM+S_NEXT inc a sta f:SRAM+S_NEXT sep #$20 .a8 jmp CellLoop NoAnswer: .a8 lda f:SRAM+S_NOANS inc a beq :+ sta f:SRAM+S_NOANS : lda #$80 sta INIDISP jsr InitPPU PrintAt 2, TitleText PrintAt 6, NoAns1Text PrintAt 7, NoAns2Text PrintAt 8, NoAns3Text jmp ShowAndHalt AllDone: .a8 lda #2 sta f:SRAM+S_STATE jsr DoneScreen jmp ShowAndHalt ; Battery RAM: format it if it is not ours, count the boot, and start, resume or show ; the finished run. SramBoot: .a8 ldx #$0000 : lda f:SRAM,x cmp Magic,x bne @format inx cpx #8 bne :- lda f:SRAM+S_FORMAT cmp #FORMAT beq @ours @format: ldx #$0000 : lda #$00 sta f:SRAM,x inx cpx #SRAM_SIZE bne :- ldx #$0000 : lda Magic,x sta f:SRAM,x inx cpx #8 bne :- lda #FORMAT sta f:SRAM+S_FORMAT @ours: rep #$20 .a16 lda f:SRAM+S_BOOTS inc a sta f:SRAM+S_BOOTS sep #$20 .a8 lda f:SRAM+S_STATE cmp #2 bne :+ jsr DoneScreen ; returns when START + SELECT ask for a new run lda #0 sta f:SRAM+S_STATE : lda f:SRAM+S_STATE bne @resume jmp NewRun @resume: ; A started cell at boot was cut short by a reset: mark it and go on. rep #$20 .a16 lda f:SRAM+S_NEXT cmp #NCELLS bcs @out asl a asl a sta tmp asl a clc adc tmp adc #S_CELLS tax sep #$20 .a8 lda f:SRAM+C_STATUS,x cmp #1 bne @out lda #3 sta f:SRAM+C_STATUS,x rep #$20 .a16 lda f:SRAM+S_NEXT inc a sta f:SRAM+S_NEXT lda f:SRAM+S_INTER inc a sta f:SRAM+S_INTER @out: sep #$20 .a8 rts ; A new run: count it, lay out the cells from the loop and variant tables. NewRun: .a8 rep #$20 .a16 lda f:SRAM+S_RUNS inc a sta f:SRAM+S_RUNS lda #NCELLS sta f:SRAM+S_NCELLS lda #0 sta f:SRAM+S_NEXT sta f:SRAM+S_INTER ldx #S_CELLS ; clear the cell area : sta f:SRAM,x inx inx cpx #S_CELLS + NCELLS * CELL bne :- sep #$20 .a8 ldx #S_CELLS stz li @loop: stz si @speed: stz vi @var: ; loop number: RunOrder[li] phx rep #$20 .a16 lda li and #$00FF tax sep #$20 .a8 lda RunOrder,x sta tmp ; loop number stz tmp+1 plx sta f:SRAM+C_LOOP,x lda si ; speed: fast first (1), then slow (0) eor #1 sta f:SRAM+C_SPEED,x sta tmp2 ; 1 fast lda vi sta f:SRAM+C_VAR,x phx rep #$20 .a16 and #$00FF tax sep #$20 .a8 lda VarD,x sta tmp2+1 ; D lda tmp ; M: LoopM[loop x 2 + slow] (fast first in each pair) asl a ora #$01 sec sbc tmp2 ; 8-bit: minus 1 when fast rep #$20 .a16 and #$00FF asl a tax lda LoopM,x sta tmp sep #$20 .a8 plx lda tmp2+1 sta f:SRAM+C_D,x lda tmp sta f:SRAM+C_M,x lda tmp+1 sta f:SRAM+C_M+1,x lda f:SRAM+C_LOOP,x ; trials: 4096 on Zenki's own loop, 512 elsewhere cmp #ZENKI_LOOP bne :+ lda #16 bra :++ : lda #2 : sta f:SRAM+C_T256,x rep #$20 .a16 txa clc adc #CELL tax sep #$20 .a8 inc vi lda vi cmp #NVARS beq :+ jmp @var : inc si lda si cmp #2 beq :+ jmp @speed : inc li lda li cmp #NLOOPS beq :+ jmp @loop : lda #1 sta f:SRAM+S_STATE rts ; The cell number (1-based) and the total, at row 7. ShowProgress: .a8 jsr WaitVblankStart rep #$20 .a16 lda cell inc a sta tmp2 sep #$20 .a8 ldx #MAP + 7*32 + 7 stx VMADD jsr PrintDec4 rts ; Print tmp2 (16-bit, under 10000) as four decimal digits at the VRAM address. PrintDec4: .a8 ldy #0 @digit: stz tmp ; the digit rep #$20 .a16 @sub: lda tmp2 sec sbc Powers,y bcc @put sta tmp2 sep #$20 .a8 inc tmp rep #$20 .a16 bra @sub @put: sep #$20 .a8 lda tmp clc adc #'0' jsr PutChar iny iny cpy #8 bne @digit rts ; Port 0 = A, with a timeout of a few seconds: carry set if it never came. WaitPort0: .a8 sta tmp stz wait stz wait+1 lda #$04 ; 4 x 65536 polls of about 27 cycles sta wait+2 @poll: lda APUIO0 cmp tmp beq @ok rep #$20 .a16 dec wait sep #$20 ; (SEP leaves Z: the 16-bit DEC's) .a8 bne @poll dec wait+2 bne @poll sec rts @ok: clc rts ; tmp = the S-SMP's count on ports 1 (low) and 2 (high), read until two reads agree. ReadResult: .a8 lda APUIO1 sta tmp lda APUIO2 sta tmp+1 lda APUIO1 cmp tmp bne ReadResult lda APUIO2 cmp tmp+1 bne ReadResult rts ; The IPL ROM's transfer protocol (wiki/Booting the SPC700; as probes/clock_ratio), with ; a timeout on the IPL's $BBAA. Carry set if the S-SMP never answered. UploadSpc: .a8 stz wait stz wait+1 lda #$08 ; 8 x 65536 polls sta wait+2 rep #$20 .a16 @ready: lda APUIO0 cmp #$BBAA beq @go dec wait bne @ready sep #$20 .a8 dec wait+2 rep #$20 .a16 bne @ready sep #$20 .a8 sec rts @go: .a16 lda #SPC_ORG sta APUIO2 sep #$20 .a8 lda #$01 sta APUIO1 lda #$CC sta APUIO0 : cmp APUIO0 bne :- ldx #$0000 @byte: lda SpcProgram,x sta APUIO1 txa ; 8-bit A: the index's low byte sta APUIO0 : cmp APUIO0 bne :- inx cpx #SpcProgramEnd - SpcProgram bne @byte rep #$20 .a16 lda #SPC_ORG sta APUIO2 sep #$20 .a8 stz APUIO1 ; 0: jump to the entry point txa clc adc #2 bne :+ inc a ; never 0 : sta APUIO0 clc rts ; The finished run: what the photo should carry, then wait for START + SELECT (3 s). DoneScreen: .a8 lda #$80 sta INIDISP stz NMITIMEN jsr InitPPU PrintAt 2, TitleText PrintAt 3, SubtitleText PrintAt 5, DoneText ldx #MAP + 6*32 + 2 ldy #RunsText jsr Print rep #$20 .a16 lda f:SRAM+S_RUNS sta tmp2 sep #$20 .a8 jsr PrintDec4 ldx #MAP + 7*32 + 2 ldy #InterText jsr Print rep #$20 .a16 lda f:SRAM+S_INTER sta tmp2 sep #$20 .a8 jsr PrintDec4 PrintAt 9, Zenki1Text ldx #MAP + 10*32 + 2 ldy #ZenkiFzText jsr Print ldx #S_CELLS + ZENKI_FAST_Z * CELL jsr PrintHits ldx #MAP + 11*32 + 2 ldy #ZenkiF8Text jsr Print ldx #S_CELLS + ZENKI_FAST_D8 * CELL jsr PrintHits ldx #MAP + 12*32 + 2 ldy #ZenkiSzText jsr Print ldx #S_CELLS + ZENKI_SLOW_Z * CELL jsr PrintHits PrintAt 15, Done1Text PrintAt 16, Done2Text PrintAt 17, Done3Text PrintAt 20, Again1Text PrintAt 21, Again2Text lda #$0F sta INIDISP lda #$01 ; auto-joypad read on sta NMITIMEN rep #$20 .a16 stz held sep #$20 .a8 @frame: jsr WaitVblankStart : lda HVBJOY ; auto-read finished and #$01 bne :- lda JOY1H and #$30 ; START + SELECT cmp #$30 beq :+ rep #$20 .a16 stz held sep #$20 .a8 bra @frame : rep #$20 .a16 inc held lda held cmp #180 sep #$20 .a8 bcc @frame stz NMITIMEN lda #$80 sta INIDISP rts ; X = a cell's offset: print its hits (T - misses) "OF" T, or "NOT RUN". PrintHits: .a8 lda f:SRAM+C_STATUS,x cmp #2 beq :+ ldy #NotRunText jmp PrintHere : lda f:SRAM+C_T256,x sta tmp+1 stz tmp rep #$20 .a16 lda tmp sec sbc f:SRAM+C_MISS,x sta tmp2 lda tmp pha sep #$20 .a8 jsr PrintDec4 ldy #OfText jsr PrintHere rep #$20 .a16 pla sta tmp2 sep #$20 .a8 jmp PrintDec4 ; --- the S-CPU write loops --------------------------------------------------------------- ; ; Each rewrites $2141 = $10 once a turn and leaves when the S-SMP shows $AA on port 0. ; Called by JSL in bank $00 (SlowROM) or $80 (FastROM, MEMSEL = 1); 8-bit A, 16-bit X/Y ; in and out. A turn of the generic loop (stx abs, the padding, lda abs, cmp #, bne ; taken in native mode) is 10 ROM fetches, a B-bus write and read and one internal ; cycle: 78 master clocks fast, 98 slow; each NOP adds a fetch and an internal cycle ; (12 / 14), each BIT dp two fetches and a WRAM read (20 / 24). DOC fullsnes "CPU Clock ; Cycles"; WDC's cycle table (65816-python). The board's bus gives the same periods ; (scripts/port_race_run.py --check-periods). .macro WriteLoop nops, bits .local turn sep #$10 .i8 ldx #$10 turn: stx APUIO1 .repeat nops nop .endrep .repeat bits bit z:$00 .endrep lda APUIO0 cmp #$AA bne turn rep #$10 .i16 rtl .endmacro Loop0: WriteLoop 0, 0 Loop1: WriteLoop 1, 0 Loop2: WriteLoop 0, 1 Loop3: WriteLoop 2, 0 Loop4: WriteLoop 1, 1 Loop5: WriteLoop 0, 2 Loop6: WriteLoop 1, 2 Loop7: WriteLoop 0, 3 Loop8: WriteLoop 0, 4 Loop9: WriteLoop 0, 5 Loop10: WriteLoop 0, 7 Loop11: WriteLoop 0, 10 ; Zenki's own loop (DA03D4), byte for byte: 17 ROM fetches, three B-bus accesses and one ; internal cycle a turn: 126 master clocks fast, 160 slow. Loop12: .a8 @turn: lda #$10 sta APUIO1 @stable: lda APUIO0 cmp APUIO0 bne @stable cmp #$AA bne @turn rtl .segment "RODATA" ZENKI_LOOP = 12 ; Cell numbers of the three on the done screen (RunOrder puts loop 12 first, fast first). ZENKI_FAST_D8 = 5 ZENKI_FAST_Z = 10 ZENKI_SLOW_Z = NVARS + 10 LoopAddr: .addr Loop0, Loop1, Loop2, Loop3, Loop4, Loop5, Loop6 .addr Loop7, Loop8, Loop9, Loop10, Loop11, Loop12 ; M, master clocks a turn: fast, slow for each loop. Fast = 78 + 12 x NOPs + 20 x BITs, ; slow = 98 + 14 x NOPs + 24 x BITs (the WriteLoop arguments above). LoopM: .word 78, 98, 90, 112, 98, 122 ; loops 0-2: (0,0) (1,0) (0,1) .word 102, 126, 110, 136, 118, 146 ; loops 3-5: (2,0) (1,1) (0,2) .word 130, 160, 138, 170, 158, 194 ; loops 6-8: (1,2) (0,3) (0,4) .word 178, 218, 218, 266, 278, 338 ; loops 9-11: (0,5) (0,7) (0,10) .word 126, 160 ; loop 12: Zenki's RunOrder: .byte 12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ; D per S-SMP variant: cycles from the CONTROL write's cycle to the $F5 read's. VarD: .byte 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 8 Powers: .word 1000, 100, 10, 1 ; --- the S-SMP program ------------------------------------------------------------------- ; ; Direct page: $00-$01 misses, $02-$03 trials left, $04 LFSR. ; Ports out: $F4 = $A5 ready, $55 command taken, $AA cell done (count on $F5, $F6). MLO = $00 MHI = $01 CNTL = $02 CNTH = $03 LFSR = $04 ; A relative branch: opcode, then the offset from the next instruction. .macro SBr op, target .local here here: .assert (target) - (here + 2) >= -128 && (target) - (here + 2) <= 127, error, "branch range" .byte op, <((target) - (here + 2)) .endmacro ; The trial's head: an LFSR step (x^8+x^4+x^3+x^2+1, period 255), 1-16 turns of DBNZ Y ; (6 cycles a turn, 4 the last), then the clear: mov a,#$30 / mov $F1,a (the write is the ; fourth cycle of MOV dp,A). Timers off and the IPL ROM unmapped are side effects. .macro TrialHead .local skip, spin .byte $E4, LFSR ; mov a,LFSR .byte $1C ; asl a SBr $90, skip ; bcc skip .byte $48, $1D ; eor a,#$1D skip: .byte $C4, LFSR ; mov LFSR,a .byte $28, $0F ; and a,#$0F .byte $FD ; mov y,a .byte $FC ; inc y spin: SBr $FE, spin ; dbnz y,spin .byte $E8, $30 ; mov a,#$30 .byte $C4, $F1 ; mov $F1,a the clear .endmacro ; The tail: C = (A >= 1), a miss; add C to the 16-bit count; T turns. .macro TrialTail first .byte $68, $01 ; cmp a,#1 .byte $E4, MLO ; mov a,MLO .byte $88, $00 ; adc a,#0 .byte $C4, MLO ; mov MLO,a .byte $E4, MHI ; mov a,MHI .byte $88, $00 ; adc a,#0 .byte $C4, MHI ; mov MHI,a .byte $1A, CNTL ; decw CNTL SBr $D0, first ; bne first .byte $5F, SpcDone ; jmp !SpcDone .endmacro ; A variant: nops NOPs and movs MOV A,dp (3 cycles; A is reloaded by the read) of padding, ; then mov a,$F5 (or mov a,!$00F5 when abs is 1). .macro Variant nops, movs, abs .local first first: TrialHead .repeat nops .byte $00 ; nop .endrep .repeat movs .byte $E4, MLO ; mov a,MLO 3 cycles of padding .endrep .if abs .byte $E5, $F5, $00 ; mov a,!$00F5 read in the fourth cycle .else .byte $E4, $F5 ; mov a,$F5 read in the third cycle .endif TrialTail first .endmacro SpcProgram: .org SPC_ORG SpcStart: .byte $E8, $30 ; mov a,#$30 .byte $C4, $F1 ; mov $F1,a clear the ports the upload left .byte $8F, $01, LFSR ; mov LFSR,#1 .byte $8F, $A5, $F4 ; mov $F4,#$A5 ready SpcWait: .byte $E4, $F4 ; mov a,$F4 SBr $F0, SpcWait ; beq SpcWait (port 0 is zero after every clear) .byte $E4, $F6 ; mov a,$F6 variant .byte $28, $0F ; and a,#$0F .byte $1C ; asl a .byte $5D ; mov x,a .byte $E4, $F7 ; mov a,$F7 trials / 256 .byte $C4, CNTH ; mov CNTH,a .byte $8F, $00, CNTL ; mov CNTL,#0 .byte $8F, $00, MLO ; mov MLO,#0 .byte $8F, $00, MHI ; mov MHI,#0 .byte $8F, $55, $F4 ; mov $F4,#$55 command taken .byte $8D, $00 ; mov y,#0 SpcDelay: SBr $FE, SpcDelay ; dbnz y 256 turns, 1.5 ms .byte $1F, VariantTable ; jmp [!VariantTable+x] SpcDone: .byte $FA, MLO, $F5 ; mov $F5,MLO .byte $FA, MHI, $F6 ; mov $F6,MHI .byte $8F, $AA, $F4 ; mov $F4,#$AA done .byte $5F, SpcWait ; jmp !SpcWait VariantTable: .addr Var0, Var1, Var2, Var3, Var4, Var5, Var6, Var7, Var8, Var9, Var10 Var0: Variant 0, 0, 0 ; D = 3 Var1: Variant 0, 0, 1 ; D = 4 Var2: Variant 1, 0, 0 ; D = 5 Var3: Variant 0, 1, 0 ; D = 6 Var4: Variant 2, 0, 0 ; D = 7 Var5: Variant 1, 1, 0 ; D = 8 Var6: Variant 3, 0, 0 ; D = 9 Var7: Variant 2, 1, 0 ; D = 10 Var8: Variant 4, 0, 0 ; D = 11 Var9: Variant 3, 1, 0 ; D = 12 ; Zenki's sequence after the clear: nop / mov a,$F4 / or a,$F5 / or a,$F6 / or a,$F7 ; (the $F5 read starts 8 cycles after the write); a hit is all four zero. Var10: TrialHead .byte $00 ; nop .byte $E4, $F4 ; mov a,$F4 .byte $04, $F5 ; or a,$F5 .byte $04, $F6 ; or a,$F6 .byte $04, $F7 ; or a,$F7 TrialTail Var10 SpcEnd: .reloc SpcProgramEnd: .assert SpcEnd - SPC_ORG = SpcProgramEnd - SpcProgram, error, "SPC program size" Magic: .byte "SNESPRB6" TitleText: .byte "SNES PROBE PACK", 0 SubtitleText: .byte "06 S-CPU/S-SMP PORT RACE", 0 Run1Text: .byte "MEASURING, ABOUT 30 SECONDS", 0 CellText: .byte "CELL OF 0286", 0 Help1Text: .byte "IF THE CELL NUMBER STOPS", 0 Help2Text: .byte "FOR 10 SECONDS, PRESS RESET:", 0 Help3Text: .byte "IT GOES ON WITH THE NEXT ONE.", 0 NoAns1Text: .byte "THE S-SMP DID NOT ANSWER.", 0 NoAns2Text: .byte "POWER OFF, WAIT 10 SECONDS,", 0 NoAns3Text: .byte "POWER ON AND START IT AGAIN.", 0 DoneText: .byte "ALL DONE.", 0 RunsText: .byte "RUN COUNT ", 0 InterText: .byte "CELLS CUT BY RESET ", 0 Zenki1Text: .byte "ZENKI LOOP, HITS:", 0 ZenkiFzText: .byte "FAST, ZENKI ", 0 ZenkiF8Text: .byte "FAST, D=8 ", 0 ZenkiSzText: .byte "SLOW, ZENKI ", 0 NotRunText: .byte "NOT RUN", 0 OfText: .byte " OF ", 0 Done1Text: .byte "PHOTOGRAPH THIS SCREEN, THEN", 0 Done2Text: .byte "POWER OFF AND SEND", 0 Done3Text: .byte "SAVE/PORT-RACE.SRM", 0 Again1Text: .byte "NEW RUN: RESET, THEN HOLD", 0 Again2Text: .byte "START AND SELECT 3 SECONDS", 0 ProbeTail "SNES PROBE PORT RACE ", $03