Demptronic NFL Football

A place where you can keep others updated about your NES-related projects through screenshots, videos or information in general.

Moderator: Moderators

User avatar
raydempsey
Posts: 159
Joined: Sat May 31, 2014 4:12 pm

Re: Demptronic NFL Football

Post by raydempsey » Mon Dec 28, 2015 9:20 pm

As you can see, the menu has progressed but the field doesn't reflect the options selected yet. My next steps will be:
1) make the top three rows of the field stationary (never did this is a game before, reading Nerdy Nights to see how)
2) figure out why the screen still temporarily tweaks out when I write to the PPU

I thought I was following a basic principle: wait for VBlank then make writes to the PPU during Vblank. The subroutines that are causing the tweaks are DrawArrow and DrawSpeed. You can see the quick glitches by navigating the menu and making adjustments to the wind speed or wind direction. The correct background tiles are being placed but always with a quick screen tweak. It almost seems like my JSR NMIwait 's aren't doing anything.

Why is this still happening? Thanks for the advice.
Attachments
NFL.nes
(384.02 KiB) Downloaded 214 times
NFL.chr
(256 KiB) Downloaded 203 times
NFL.asm
(26.66 KiB) Downloaded 208 times

User avatar
Memblers
Site Admin
Posts: 3770
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Demptronic NFL Football

Post by Memblers » Mon Dec 28, 2015 10:21 pm

It looks like it's not resetting the PPU address with $2006 after updating VRAM. You should set it to $0000 before vblank ends.

User avatar
tokumaru
Posts: 11465
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Demptronic NFL Football

Post by tokumaru » Mon Dec 28, 2015 10:41 pm

Memblers wrote:You should set it to $0000 before vblank ends.
Better yet: reset the scroll by writing to $2000 (to select a name table) and $2005 (to set X and Y scroll), which are the registers designed for this. Setting $2006 to $0000 works in some cases, but that doesn't fully set the scroll (the fine X scroll can only be changed through $2005), so it's safer to use $2000/$2005, and since you'll be doing that, writing to $2006 becomes redundant.

User avatar
raydempsey
Posts: 159
Joined: Sat May 31, 2014 4:12 pm

Re: Demptronic NFL Football

Post by raydempsey » Mon Dec 28, 2015 11:29 pm

Better yet: reset the scroll by writing to $2000 (to select a name table) and $2005 (to set X and Y scroll), which are the registers designed for this. Setting $2006 to $0000 works in some cases, but that doesn't fully set the scroll (the fine X scroll can only be changed through $2005), so it's safer to use $2000/$2005, and since you'll be doing that, writing to $2006 becomes redundant.
I'm still not sure how to change my code based on your suggestions because I am new enough that I don't understand VBlank as much as I thought. This is the code my other program uses:

Code: Select all

  LDA #%10010000
  STA $2000
  LDA #%00011110
  STA $2001
  LDA #$00
  STA $2005
  STA $2005
I know what each bit does in $2000 and $2001 and I use horizontal scrolling but I never understood why this code was so important, especially because in my other program there was no scrolling at all but removing the STA $2005 code caused bad things so I left it alone. Is this it?

3gengames
Formerly 65024U
Posts: 2269
Joined: Sat Mar 27, 2010 12:57 pm

Re: Demptronic NFL Football

Post by 3gengames » Tue Dec 29, 2015 12:29 am

It's affecting scrolling because basically all PPU registers are a copy of a single register when they're written to. You have to restore the register internally by writing the correct scroll as the last thing you do in Vblank.

User avatar
raydempsey
Posts: 159
Joined: Sat May 31, 2014 4:12 pm

Re: Demptronic NFL Football

Post by raydempsey » Tue Dec 29, 2015 2:03 am

Code: Select all

Indirect0:
  .db $00,$1E,$37,$3F
Indirect1:
  .db $F0,$F0,$F0,$F0

Code: Select all

LDX temp
LDA Indirect0,X
STA $A0
LDA Indirect1,X
STA $A1
LDY #$23
LDA [$A0],Y

Code: Select all

.bank 15
.org $F000
.db $00,$20,$CF,$71,(.etc)
This is the basic format of how I read lots of data in my programs. I know it is inefficient because I have to wrestle with hand calculating indirect addresses. If data needs to be adjusted, especially when the number of bytes is increased or decreased, this causes me to recalculate indirect addresses and it is annoying. Is there a better way?

User avatar
Memblers
Site Admin
Posts: 3770
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Demptronic NFL Football

Post by Memblers » Tue Dec 29, 2015 2:19 am

Yeah, replace the Indirect0 and 1 tables with something like this. I haven't used nesasm in a while so I'm not sure what the equivalent syntax is, check the docs. Honestly, I'd advise using a different assembler because of bad experiences I've had with nesasm (having it assemble bad code instead of giving an error message), but you can probably get by anyways, and that topic is covered in several other threads.

Code: Select all

Indirect0:
   .byte <table0, <table1, <table2 ; low byte
Indirect1:
   .byte >table0, >table1, >table2 ; high byte

.org $F000
table0: .byte $00, etc.
table1: .byte $FF, etc.
edit: Also, if you need to know the size of a table, you can do stuff like this:

Code: Select all

table0: .byte $00,$01,$02,etc.
table0_end:

table0_size: .word (table0_end - table0)
or
table0_size: .byte ((table0_end - table0) & $00FF)
Or you can use that same expression as the immediate operand of a CMP instruction or whatever. I'm kinda veering off-topic here, but anyways..

User avatar
raydempsey
Posts: 159
Joined: Sat May 31, 2014 4:12 pm

Re: Demptronic NFL Football

Post by raydempsey » Tue Dec 29, 2015 3:34 am

I am not all that fond of NESASM3 as an assembler and I've heard mostly complaints about it so I'd be willing to convert my game to Asm6 if it isn't too difficult. Will that be hard to do?

User avatar
Memblers
Site Admin
Posts: 3770
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Demptronic NFL Football

Post by Memblers » Tue Dec 29, 2015 4:39 am

It wouldn't be too hard. The main thing would be changing the way the memory is banked/padded. I haven't used ASM6 for a large project, but I think it would go something like this:

Code: Select all

.byte ; before any .org directive, define iNES header here, or just rip out your existing 16 byte header and .incbin it
.org $8000
; code here
.pad $FFFA
;vectors here, then it overflows to the next bank
.org $8000
; next bank's code
.pad $FFFA
;next bank's vectors
and so on. When you gets to the CHR data, then of course the .org doesn't matter. Just .incbin your CHR file, and it's all good as long as it started at the right offset. I'm not sure how you'd want to handle your unused/blank PRG banks, if it was me I'd probably just make some kind of skeleton file and .include it repeatedly for each bank. Or you could try just using a big .pad directive, I don't know if it'll take a larger than 16-bit address though, could try it. Maybe someone else would have a better suggestion.

The rest of the conversion should be simple text search-and-replace. Changing indirect [ to ( and ] to ), and for local labels, . to @

User avatar
raydempsey
Posts: 159
Joined: Sat May 31, 2014 4:12 pm

Re: Demptronic NFL Football

Post by raydempsey » Tue Dec 29, 2015 5:17 am

I'm going to give conversion a shot and show everything I did. I will have the before and after posted as I do. I converted to lowercase letters and that's about it. I really don't know what to do but so far I put the .iNES header above as .byte code. Not sure if that's right. Not sure what to do with the .bank 15 type stuff because it is my first error in ASM6 so far. I'll keep grinding at this until I get it.
Attachments
NFL_asm6.asm
(26.92 KiB) Downloaded 191 times
NFL_NESASM.asm
(26.84 KiB) Downloaded 198 times
Last edited by raydempsey on Tue Dec 29, 2015 5:55 am, edited 1 time in total.

User avatar
Memblers
Site Admin
Posts: 3770
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Demptronic NFL Football

Post by Memblers » Tue Dec 29, 2015 5:38 am

Yeah that sounds reasonable, I seem to recall my earliest programs always had the opcodes in caps, but I soon switched to lowercase probably because it was easier to type. It somehow looks cooler or more "official" in caps, but it's hardly worth any trouble. Actually, looking at my current project, for PIC16, it's all in C except maybe 12 lines of assembly, and it looks like I had typed those asm opcodes in caps just for looks I guess, heheh.

I always type constant values in caps though (expressions and stuff that are defined with EQU or = and such, often used for immediate # operands), it's always good practice to distinguish those from variables.

User avatar
raydempsey
Posts: 159
Joined: Sat May 31, 2014 4:12 pm

Re: Demptronic NFL Football

Post by raydempsey » Tue Dec 29, 2015 3:30 pm

OK so I've been looking at my NESASM3 code and trying to convert in to ASM6-ready code but I really don't know what to do exactly. I looked at the .NES file to retrieve the header, which I rewrote at the top of my program. I'm getting the following errors:
1) 'Illegal instruction' errors only on my .bank code.
2) 'Value out of range' errors on jmp's and jsr's
3) I'm getting tons and tons of 'PC out of range' errors on just about every line. My current code has two spaces before each thing. Should there be a tab or something?
I converted my local labels from .Skip to @Skip and will wait until it runs to implement + and - looping labels. I converted square brackets to round brackets. How do I complete the conversion?
Attachments
NFL_ASM6.asm
(26.92 KiB) Downloaded 182 times

User avatar
tokumaru
Posts: 11465
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Demptronic NFL Football

Post by tokumaru » Tue Dec 29, 2015 4:42 pm

raydempsey wrote:1) 'Illegal instruction' errors only on my .bank code.
ASM6 doesn't have a .bank command. You can use .base to start a bank instead, and .org to pad each bank until the end. Here's what a mapper 2 program with 4 PRG-ROM banks could look like in ASM6:

Code: Select all

	.incbin "header.bin"

	;bank 0
	.base $8000
	;(bank contents)
	.org $c000

	;bank 1
	.base $8000
	;(bank contents)
	.org $c000

	;bank 2
	.base $8000
	;(bank contents)
	.org $c000

	;bank 3
	.base $c000
	;(bank contents)
	.org $fffa
	.dw NMI
	.dw Reset
	.dw IRQ
As for the remaining errors, it's possible that they're being caused because of the .bank errors, which are preventing addresses from being resolved. Fix the .bank thing first and then look at the errors again to see if things got any better.

User avatar
raydempsey
Posts: 159
Joined: Sat May 31, 2014 4:12 pm

Re: Demptronic NFL Football

Post by raydempsey » Tue Dec 29, 2015 7:53 pm

I cleared up the error notifications from ASM6 but there is still something wrong. This is what I have so far taking tokumaru's advice. As you can see I am really close. First, I don't know if I have the right header because when I look at the .nes file produced, the header takes up 32 bytes for some reason. Any suggestions from here?
Attachments
NFL-ASM6.asm
(27.08 KiB) Downloaded 192 times

User avatar
Memblers
Site Admin
Posts: 3770
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Re: Demptronic NFL Football

Post by Memblers » Tue Dec 29, 2015 9:11 pm

I assembled it, the header looks OK to me. Looking in a hex editor, the code starts at offset $E010, which shows the header added 16 ($10) bytes.

It looks like you need to add more banks or change the header, the header shows 8 * 16kB PRG banks, but the asm file only creates 4 16kB PRG banks.

I'm using asm6 v1.51 BTW, kinda old, if that matters. loopy's site moved, I'm not sure where to get the newer version.

edit: yep, I changed 8 prg pages to 4 in the header, and it runs again.

Post Reply