[ オリジナルレポート ]

BugID: #05371

カテゴリ 重要度 ステータス 解決状況 登録日時 最終更新
システムコア解決済み修正済み2013-11-18 06:452013-11-18 18:51
 
テスターjwdonal担当者AWJソース
バージョン0.151発生バージョン修正バージョン0.152
修正コミットプルリク
フラグ
セット SNES
セット詳細
 
概 要BRK命令実行中、PSレジスタをスタックにプッシュしているとき、SPC-700がBフラグを設定してしまう。
詳 細When the PS register is pushed to the stack during execution of the BRK instruction the B flag is getting set. This should not happen. The B flag is only set _after_ the PS register is pushed to the stack (mess is doing this part correctly). Setting the B flag before writing the PS to the stack happens on both 6502/65816 (i.e. NES/SNES processors) so I'm guessing this is an incorrect carry-over from one of those processors.

The bug is located in \src\emu\cpu\spc700\spc700.c line 703. The "GET_REG_P_BRK" should be replaced with just "GET_REG_P".

Just to re-iterate, the B flag _should_ be set _after_ the PS register is pushed to the stack (mess is already doing this properly). But the B flag should _not_ be set _before_ pushing to the stack.

I marked this bug as minor since I don't think there are many games that even look at the B flag at all. But I could be wrong...maybe there are lots of games that use it...?
再現手順Load any ROM which causes the BRK instruction to be executed on the SPC-700. I just wrote a small test ROM myself. The source for the test rom follows (compile with tasm and convert to sfc with spc2rom):

.title "brk_bug"

.fill 0200h-*,000h

start:
brk
jmp start

brk_vec:
reti

.fill $FF84-*,$00
.fill $FFC0-*,$FF ; 60 bytes of $FF for SPC2ROM

.fill 010000h-*,000h

; Start of TCALL vector space
.org $FFDE
.dw brk_vec

.end
追加情報I tested the instruction running on a real SNES using a logic analyzer and watched each cycle of the instruction as it executed. I can provide you the logic analyzer trace if you like, but I don't think that's necessary. You could test the same thing without a logic analyzer by executing the BRK instruction on a real SPC700 and then popping the last byte off the stack within the BRK service routine - you will see that the B flag was not set before it was written to the stack.
 
添付ファイル