It is currently Mon Nov 19, 2018 5:13 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: OAM filled PRG ???
PostPosted: Fri Mar 09, 2018 1:24 pm 
Offline
User avatar

Joined: Wed Sep 20, 2017 1:14 pm
Posts: 24
Location: Green Hill Zone
Hi all, I have a problem, when I use the ram I dedicated for OAM, it makes an overflow on my PRG... :?

I explain, the code below allows me to display the bar that hides the generation of the map when I scroll.
Here I set my sprites, nothing complicated.
Image
But this code which is in bank 2 (PRG2), will generate an overflow on bank 3 (PRG), really weird ...
Below is the error code.
Image

Here a part of my nes.cfg
Image

Isprite: pushing sprites into memory
Image

And my array that I push in the OAM
Image

I do not see anything weird, yet I've been looking for hours, that's why I'm calling for help.

Thank you in advance :beer:


Top
 Profile  
 
 Post subject: Re: OAM filled PRG ???
PostPosted: Fri Mar 09, 2018 1:57 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20783
Location: NE Indiana, USA (NTSC)
You might have just written too much code. Change ld65 in your linker to ld65 -m map.txt, then please upload map.txt here.


Top
 Profile  
 
 Post subject: Re: OAM filled PRG ???
PostPosted: Fri Mar 09, 2018 2:02 pm 
Offline
User avatar

Joined: Sat Jan 09, 2016 9:21 pm
Posts: 505
Location: Central Illinois, USA
I'd guess your code is actually going into the PRG segment instead of PRG0. What's your .pragma look like (and where) for setting the bank of this code you're currently writing?

edit: Tepples beat me to it, but yeah, a map file should make it obvious.

_________________
My games: http://www.bitethechili.com


Top
 Profile  
 
 Post subject: Re: OAM filled PRG ???
PostPosted: Fri Mar 09, 2018 2:06 pm 
Offline
User avatar

Joined: Wed Sep 20, 2017 1:14 pm
Posts: 24
Location: Green Hill Zone
Done

Edit: Image


Attachments:
map.txt [4.84 KiB]
Downloaded 50 times
Top
 Profile  
 
 Post subject: Re: OAM filled PRG ???
PostPosted: Fri Mar 09, 2018 2:34 pm 
Offline
User avatar

Joined: Sat Jan 09, 2016 9:21 pm
Posts: 505
Location: Central Illinois, USA
Code:

Segment list:
-------------
Name                   Start     End    Size  Align
----------------------------------------------------
..snip...
STARTUP               00C000  00C162  000163  00001
CODE                  00C163  00E56D  00240B  00001
DMC                   00E500  00F8FF  001400  00001
ONCE                  00E593  00E59E  00000C  00001
VECTORS               00FFFA  00FFFF  000006  00001


Your STARTUP plus CODE segment comes to $256e in size, which is bigger than PRG (size = $2500). Tepples was right, you have too much in CODE.

_________________
My games: http://www.bitethechili.com


Top
 Profile  
 
 Post subject: Re: OAM filled PRG ???
PostPosted: Fri Mar 09, 2018 2:43 pm 
Offline
User avatar

Joined: Wed Sep 20, 2017 1:14 pm
Posts: 24
Location: Green Hill Zone
Okay thanks ! But HideBar function is in CODE2 so why does it take up space in CODE?

If I remove HideBar function, it compiles correctly and CODE gains free bytes


Top
 Profile  
 
 Post subject: Re: OAM filled PRG ???
PostPosted: Fri Mar 09, 2018 5:59 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2334
Location: DIGDUG
Did you "include" a file somewhere inside bank2.c ?

If so, the included file might have a pragma which changes the code location.

Also, I've seen that the c library functions always end up in the "code" segment. And I think they only compile into it if they are used (not 100% sure).

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
 Post subject: Re: OAM filled PRG ???
PostPosted: Fri Mar 09, 2018 10:50 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6956
Location: Canada
dougeff wrote:
Also, I've seen that the c library functions always end up in the "code" segment. And I think they only compile into it if they are used (not 100% sure).

These are both true. Adding C code in some other location could draw more supporting CRT code into the "CODE" segment.


Top
 Profile  
 
 Post subject: Re: OAM filled PRG ???
PostPosted: Sat Mar 10, 2018 4:24 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 820
Yep, it's probably the multiplication pulling in three support functions, by 4, by 16, and arbitrary.


Top
 Profile  
 
 Post subject: Re: OAM filled PRG ???
PostPosted: Sat Mar 10, 2018 10:26 am 
Offline
User avatar

Joined: Wed Sep 20, 2017 1:14 pm
Posts: 24
Location: Green Hill Zone
okay thanks everyone for your answers ^^, and thanks for -m map.txt command, i didn't know it!


Top
 Profile  
 
 Post subject: Re: OAM filled PRG ???
PostPosted: Tue Mar 13, 2018 6:10 am 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 496
You should avoid * and / like the plague, specially when coding in C for a 6502.

I don't understand why you multiply scrollY*(temp*16). Shouldn't it be scrollY+(temp*16)? If so, this code does the same without multiplication:

Code:
void HideBar () {
   tempWord = 0;
   aux = scrollY;
   for (temp = 0; temp < 16; ++temp) {
      HIDEBAR [tempWord ++] = aux;
      HIDEBAR [tempWord ++] = 0;
      HIDEBAR [tempWord ++] = 0;
      HIDEBAR [tempWord ++] = scrollX
      aux += 16;
   }
}

_________________
http://www.mojontwins.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: mkwong98 and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group