Page 4 of 4
Posted: Wed Aug 02, 2006 7:25 pm
by lynxsolaris
I ran my code through nintendulator's and FCEU's debuggers. It seems that when the program reaches the first write to $2001 it jumps back up to $8000.
Code: Select all
$8045:A9 00 LDA #$00
$8047:8D 06 20 STA $2006 = #$84
$804A:8D 06 20 STA $2006 = #$84
$804D:A9 88 LDA #$88
$804F:8D 00 20 STA $2000 = #$00
$8052:A9 18 LDA #$18 <-- Step stops here then just back to
sei @ $8000
$8054:8D 01 20 STA $2001 = #$00
$8057:AD 00 00 LDA $0000 = #$01
$805A:D0 FB BNE $8057
So I'm assuming thats why my "A" blinks because its hitting my wait for vblank routine (which I did put back in) over and over.... Anyone tell me why its jumping back up to $8000?
Thanks.
Posted: Wed Aug 02, 2006 7:36 pm
by tokumaru
It jumps back to the reset address? Are your vectors set up correctly at the end of the ROM?
Posted: Wed Aug 02, 2006 7:40 pm
by lynxsolaris
tokumaru wrote:It jumps back to the reset address? Are your vectors set up correctly at the end of the ROM?
Yes, sir. Here is my setup:
Code: Select all
.bank 1
.org $fffa
.dw reset,nmi,int
Posted: Wed Aug 02, 2006 7:41 pm
by tokumaru
I think it should be:
EDIT: This would explain the invalid opcodes (execution starts in NMI, so there is no *valid* return address when you return), and the fact that as soon as NMI's are turned on it jumps to RESET.
Posted: Wed Aug 02, 2006 7:44 pm
by lynxsolaris
tokumaru wrote:I think it should be:
DOH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! That's it! I can't believe I overlooked that. Thanks tokumaru!
Posted: Wed Aug 02, 2006 7:50 pm
by tokumaru
Yeah... we never look at the simple stuff! =)
Posted: Wed Aug 02, 2006 7:59 pm
by lynxsolaris
Yeah. This, apparently, was also the reason I had to set $2006 back to zero to get my characters in place. Once I corrected my vectors the $2005 write was enough. Makes sense.... now (been nice if it would've clicked earlier).
Posted: Thu Aug 03, 2006 4:59 am
by Disch
It's good that the NMI/RESET vector confusion was cleared up. I want to point out something a little more subtle though (which may not be a problem now, but may raise its ugly head in the future) :
lynxsolaris wrote:Code: Select all
$8045:A9 00 LDA #$00
$8047:8D 06 20 STA $2006 = #$84
$804A:8D 06 20 STA $2006 = #$84
$804D:A9 88 LDA #$88
$804F:8D 00 20 STA $2000 = #$00
$8052:A9 18 LDA #$18 <-- Step stops here then just back to
sei @ $8000
$8054:8D 01 20 STA $2001 = #$00
$8057:AD 00 00 LDA $0000 = #$01
$805A:D0 FB BNE $8057
The reason that code was jumping to the NMI vector before (which happened to actually be the RESET vector) was because you're raising $2000.7 (enabling NMIs) while the VBlank flag ($2002.7) is still set. Unless you
want NMIs to occur this way... which... typically you wouldn't... you should make sure that the VBlank flag is clear by reading $2002.
This is why I was still recommending you read $2002 right away in your NMI routine (
before you do any writes to $2000) -- to clear the flag as soon as it is set, so that unwanted additional NMIs won't trip.
Posted: Wed Aug 09, 2006 6:30 am
by lynxsolaris
Disch wrote:
This is why I was still recommending you read $2002 right away in your NMI routine (before you do any writes to $2000) -- to clear the flag as soon as it is set, so that unwanted additional NMIs won't trip.
Done. I've assimilated this into my code.
I have one more question. I've decided to place an "image" above the text to go along with the story. Each time a character appears on the screen the image "flickers". What can I do to stop the image from flickering?
Posted: Wed Aug 09, 2006 11:58 am
by Bregalad
You'd better tell us how you render your image and your text to have us be able to help you.
If you just do one $2007 write during VBlank to write text, and be sure to setup proper scroll value before the end of VBlank, this should be OK. In that case you should do something wrong with scrolling or BG enabling via $2001.
Else, if you try to change something mid-frame between your image and your text, this could cause many different problems.
Posted: Sun Aug 20, 2006 7:38 pm
by lynxsolaris
Sorry for such a late response. Because this is my test code, all I've done is basically added the image above the write of the text .... like so:
Code: Select all
lda #$21
sta $2006
lda #$28
sta $2006
ldx #$00
scene_one_loop:
lda scene_one_data,X
sta $2007
inx
cpx #$FF
bne scene_one_loop
bit $2002
lda #%10001000
sta $2000
lda #%00011000
sta $2001
;;;;; not sure if I need something here ....
ldx #$00
ldy #$62
loop_text:
lda #$00
sta $2000
sta $2001
lda #$22
sta $2006
sty $2006
lda scene_one_text,X
sta $2007
inx
iny
bit $2002
lda #%10001000
sta $2000
lda #%00011000
sta $2001
wait_again:
lda text_flag
bne wait_again
lda #$06
sta text_flag
cpx #$55
bne loop_text
The image and the text flicker ... but when its just the text it seems to be fine .... Any pointers would be great! Thanks.