Page 7 of 10

Re: Demptronic NFL Football

Posted: Mon Feb 06, 2017 11:28 am
by KHAN Games
Extremely excited for this. Demo works great for me. :)

Re: Demptronic NFL Football

Posted: Mon Feb 06, 2017 11:59 am
by raydempsey
rainwarrior wrote:That doesn't change anything for me, in any of the emulators I just mentioned.

It does seem to run in an older version of FCEUX though. (2.2.2)
That's the version I have. What would cause it not to run in the latest version but still run in 2.2.2? Maybe something involving initialization or MMC5 maybe...?

Re: Demptronic NFL Football

Posted: Mon Feb 06, 2017 12:15 pm
by rainwarrior
It seems to run on 2.2.3 if I switch to "Old PPU".

The new PPU is supposed to be much more accurate, but I'm not sure specifically in what ways.

The default setting is old PPU, but I think it's mainly that way to provide support for legacy TAS etc. that relies on its behaviour. If you're trying to develop new software, you would probably want to use new PPU.

Re: Demptronic NFL Football

Posted: Mon Feb 06, 2017 12:28 pm
by lidnariq
Briefly playing around with Mesen ....

You've somehow managed to spin, waiting for a sprite 0 hit in your NMI before you've successfully uploaded sprites the first time.

(Why are you using a sprite 0 hit on a mapper with IRQs?)

Re: Demptronic NFL Football

Posted: Mon Feb 06, 2017 12:47 pm
by FrankenGraphics
Did a random button mashing/holding stress test. Holding a or b means retrigging their corresponding actions. Checking for a previously recorded release in order to re-perform the action may help against these odd-looking movement patterns.

Re: Demptronic NFL Football

Posted: Mon Feb 06, 2017 4:38 pm
by raydempsey
lidnariq wrote:Briefly playing around with Mesen ....

You've somehow managed to spin, waiting for a sprite 0 hit in your NMI before you've successfully uploaded sprites the first time.

(Why are you using a sprite 0 hit on a mapper with IRQs?)
I've never used IRQs before. I just looked up on Nerdy Nights how to get a horizontal banner that doesn't scroll with the background. Not sure how to implement IRQs. Sounds like I should switch. I bet it would be easier to do other effects too. Any thoughts?

Re: Demptronic NFL Football

Posted: Mon Feb 06, 2017 4:50 pm
by raydempsey
FrankenGraphics wrote:Did a random button mashing/holding stress test. Holding a or b means retrigging their corresponding actions. Checking for a previously recorded release in order to re-perform the action may help against these odd-looking movement patterns.
That's an easy fix. I also want to randomize the sprites selected during the spin move so spin moves look more realistic. Also, when a player jumps out of bounds, the ball needs to be placed where the ball was last in bounds, not where the player landed. I need to find a good football whistle sound so people know the play is dead. Should just use a quick tone for now. I have not implemented a ball yet so this is on the back burner for now. Each sprite will have an assumed placement of the ball at that moment so touchdowns are detected when the ball crosses the plain etc.

I've spent so much energy on field logos and helmets that I'm excited to get back to programming football physics.

Re: Demptronic NFL Football

Posted: Mon Feb 06, 2017 6:34 pm
by lidnariq
raydempsey wrote:I've never used IRQs before. [...] Not sure how to implement IRQs. Sounds like I should switch. I bet it would be easier to do other effects too. Any thoughts?
It's basically just like the NMI handler, but rather than only happening at the very top of the frame, in the MMC5's case, you instead tell it to start an IRQ at scanline N. I'm not certain what a programmed value of "0" means here. It could mean the prerender scanline ... or it could mean something else.

You also need to explicitly acknowledge the IRQ source in the IRQ handler (i.e. read $5204), whereas NMIs don't need to be.

(As contrast, the MMC3 starts an IRQ after N scanlines have passed)

Re: Demptronic NFL Football

Posted: Tue Feb 07, 2017 8:54 am
by M_Tee
It's looking good. I especially like the sprite animation. However, the text at the top would definitely be (at least partially) cropped on my old CRT.

Re: Demptronic NFL Football

Posted: Tue Feb 07, 2017 11:19 am
by hackfresh
If the wiki is right then

"
IRQ Counter ($5203) = All eight bits specify the scanline number to generate IRQ at

When the MMC5 detects a scanline, the following events occur:
if the In Frame signal is clear, set it, reset the IRQ counter to 0, and clear the IRQ Pending flag
otherwise, increment the IRQ counter. If it now equals the IRQ scanline ($5203), raise IRQ Pending flag

Note the above logic makes it impossible for an IRQ to occur when $5203 (IRQ counter) is set to $00"

I'm pretty sure when I did my MMC3 to MMC5 conversion I remember I had to change almost all the places where it was loading a 00 into the IRQ register into 01's.

Re: Demptronic NFL Football

Posted: Wed Feb 08, 2017 2:22 pm
by raydempsey
hackfresh wrote:If the wiki is right then

"
IRQ Counter ($5203) = All eight bits specify the scanline number to generate IRQ at

When the MMC5 detects a scanline, the following events occur:
if the In Frame signal is clear, set it, reset the IRQ counter to 0, and clear the IRQ Pending flag
otherwise, increment the IRQ counter. If it now equals the IRQ scanline ($5203), raise IRQ Pending flag

Note the above logic makes it impossible for an IRQ to occur when $5203 (IRQ counter) is set to $00"

I'm pretty sure when I did my MMC3 to MMC5 conversion I remember I had to change almost all the places where it was loading a 00 into the IRQ register into 01's.
I am not familiar at all with working with IRQ's. All I know is they are interrupt requests and I think it's related to creating a stationary banner. Does anyone have some sample code and a little on how it's used?

Re: Demptronic NFL Football

Posted: Wed Feb 08, 2017 2:37 pm
by lidnariq
For your purposes, I think you should just be able to have an IRQ that does something like

Code: Select all

PHA
TXA
PHA
LDA $5204 ; acknowledge IRQ
LDA #0
STA $5204 ; MAYBE UNNECESSARY - disable IRQ so that it won't happen later unless it was re-enabled every vblank in the NMI)
LDA shadow_nametable
STA $2006
LDA shadow_Y
STA $2005
(insert some specific delay here so that the scroll split will happen at the right place on-screen)
LDX shadow_X
LDA shadow_last
STX $2005
STA $2006
PLA
TAX
PLA
RTI
In your main thread, make sure you've disabled other sources of IRQs (APU frame counter and DMC completion), told the 6502 to listen to IRQs (CLI), and in your NMI, tell the MMC5 to start the IRQ at the right scanline (LDA #something / STA $5203) and tell the MMC5 to enable IRQs (LDA #$80 / STA $5204)

Re: Demptronic NFL Football

Posted: Sat Jun 24, 2017 4:13 am
by raydempsey
I need to convert from a Sprite 0 hit banner to a banner created from an IRQ using the MMC5. I'd like the top part of the screen to be scrolled 0 pixels to the right, and I'd like the bottom part scrolled n pixels to the right. I've experimented with the code suggested by lidnariq but I'm not sure where to put it. Here is my init code:

Code: Select all

RESET
	lda #3
	sta $5100
	lda #3
	sta $5101   ; CHR mode 8 separate 1K banks
	lda #1
	sta $5104   ; extended RAM mode 1
	lda #$F4
	sta $5105   ; nametable mapping
	lda #$80
	sta $5114   ; bank 0 to $8000
	lda #$81
	sta $5115   ; bank 1 to $A000
	lda #1
	sta $5130
	lda #$04
	sta $5120   ; Sprite 0
	lda #$00
	sta $5121   ; Sprite 1 blank
	sta $5122   ; Sprite 2 blank
	lda #$14
	sta $5123   ; Sprite 3
	lda #0
	sta $5130
	lda #$1
	sta $5203   ; IRQ counter
	sei         ; disable IRQs
	cld         ; disable decimal mode
	ldx #$40
	stx $4017   ; disable APU frame IRQ
	ldx #$FF
	txs         ; Set up stack
	inx
	stx $2000   ; disable NMI
	stx $2001   ; disable rendering
	stx $4010   ; disable DMC IRQs
	lda #%00011111
	sta $4015
Here is my last VBlank write:

Code: Select all

	lda #0
	sta $2006
	sta $2006
	sta $2005
	sta $2005
	lda #%10010100
	sta $2000
	lda #%00011110
	sta $2001
	  - lda $2002
		and #%01000000
		bne -
	  - lda $2002
		and #%01000000
		beq -
	ldx #10
	  - dex
		bne -
	lda screen
	clc
	and #%00000001
	adc #%10010100
	sta $2000
	lda scroll
	sta $2005
	lda #80
	sta $2005
	rts
I need to know EXACTLY what code needs to changed or be added here to make the banner happen. I guess it has something to do with writing a value to $5203 and waiting to detect something from $5204 but I don't know where it should happen.

Re: Demptronic NFL Football

Posted: Sat Jun 24, 2017 11:57 am
by lidnariq
raydempsey wrote:I've experimented with the code suggested by lidnariq but I'm not sure where to put it.
Somewhere in your fixed bank, and the IRQ vector should point to it (next to the NMI and RESET vectors).

After than, setting up IRQs should be as simple as:

* In your main thread:
CLI

* In your NMI
lda #scanline_to_generate_IRQ_at
sta $5203
lda #$80
sta $5204

Re: Demptronic NFL Football

Posted: Tue Jun 27, 2017 4:54 pm
by raydempsey

Code: Select all

VBlankFieldEnd
	lda #31
	sta $5203
	lda #$80
	sta $5204
	lda screen
	clc
	and #%00000001
	adc #%10010100
	sta $2000
	lda #%00011110
	sta $2001
	lda #0  ;<-------------------- A
	sta $2005
	lda #0  ;<-------------------- B
	sta $2005
	rts
Above is my last-writes code for NMI.

Code: Select all

IRQ
	pha
	txa
	pha
	tya
	pha
	lda $5204
	lda #0
	sta $5204
	lda #0  ;<--------------- C
	sta $2006
	lda #0  ;<--------------- D
	sta $2005
	ldy #10
	-	dey
		bne -
	lda #0  ;<--------------- E
	sta $2005
	lda #0  ;<--------------- F
	sta $2006
	pla
	tay
	pla
	tax
	pla
	rti
Above is my IRQ code.

I have been trying unsuccessfully to create a banner. I don't know what the values in A thru F mean. I tried experimenting and I still don't get it. What should I do to make it so I have a banner that starts 32 scanlines down where the top has no vert or horiz scroll while the last of the scanlines look shifted to the right n pixels. What do A thru F mean and what should I put where? What am I doing wrong?