It is currently Tue Oct 24, 2017 2:52 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Fri Apr 17, 2015 7:08 pm 
Offline

Joined: Mon Aug 25, 2014 12:46 pm
Posts: 10
Location: Massachusetts, United States
I'm attempting to write a program in ca65 that has 70-ish bytes reserved within the zero page. This is basically what it looks like:

Code:
.segment "HEADER"
   
   .byte   "NES", $1a
   .byte   2
   .byte   1
   .byte   $01, $00

.segment "STARTUP"

.segment "ZEROPAGE"

name_of_variable_here: .res 1 ; this times approx. 70

.segment "CODE"

; rest of code here


Whenever I attempt to assemble it, I get a memory area overflow error for the zero page unless I cut it down to only 26 bytes.

I think I'm misunderstanding, but I'd assume I could reserve a maximum of 256 bytes of the zero page since that's how big the zero page is (i.e. $0000 to $00ff), so why can I only reserve 26?

Do I have any real options if I want to store this data in the RAM?


Top
 Profile  
 
PostPosted: Fri Apr 17, 2015 7:14 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19122
Location: NE Indiana, USA (NTSC)
Does this happen at the assembler step, or at the linker step? If at the linker step, what does your linker script (specified with -C) look like? And when you have ld65 emit a map file (use -m map.txt), what does it look like?


Top
 Profile  
 
PostPosted: Fri Apr 17, 2015 7:30 pm 
Offline

Joined: Mon Aug 25, 2014 12:46 pm
Posts: 10
Location: Massachusetts, United States
Unfortunately, I'm new to ca65 so I'm not sure I completely understand how to to emit a map file; simply typing "ld65 -m map.txt" gives me an error that there are no object files to link. Could you give me some insight about how to emit a map file correctly?

I assemble my code using "cl65 -t nes -o game.nes main.asm", and that's where I get the error.


Top
 Profile  
 
PostPosted: Fri Apr 17, 2015 7:41 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19122
Location: NE Indiana, USA (NTSC)
BlueGoldWolf17 wrote:
Unfortunately, I'm new to ca65 so I'm not sure I completely understand how to to emit a map file; simply typing "ld65 -m map.txt" gives me an error that there are no object files to link. Could you give me some insight about how to emit a map file correctly?

Add -m map.txt to your current cl65 command line. Most useful options accepted by ld65 are also accepted by cl65.

Quote:
I assemble my code using "cl65 -t nes -o game.nes main.asm", and that's where I get the error.

Then you're using the NES linker script that ships with cc65, which indeed allows only 26 bytes of zero page for some reason of which I'm not aware:
Code:
    ZP:     file = "", start = $0002, size = $001A, type = rw, define = yes;

It also reserves 12 bytes for the vectors instead of 6, also for some reason of which I'm not aware.

Instead of -t nes, try -C nrom128.cfg where the file nrom128.cfg is in my NES project template.


Top
 Profile  
 
PostPosted: Fri Apr 17, 2015 8:35 pm 
Offline

Joined: Mon Aug 25, 2014 12:46 pm
Posts: 10
Location: Massachusetts, United States
Thank you so much for your help. Unfortunately, using nrom128.cfg, now I get a memory area overflow in the vectors segment, where my code is
Code:
.word 0, 0, 0

.word nmi


.word reset

.word 0


Hopefully I'll be able to figure it out from here. Also, my map file (prior to using your config file) seems to be this:

Modules list:
-------------
main.o:
CODE Offs=000000 Size=000148 Align=00001 Fill=0000
ZEROPAGE Offs=000000 Size=000051 Align=00001 Fill=0000
HEADER Offs=000000 Size=000008 Align=00001 Fill=0000
VECTORS Offs=000000 Size=00000C Align=00001 Fill=0000
CHARS Offs=000000 Size=002000 Align=00001 Fill=0000


Segment list:
-------------
Name Start End Size Align
----------------------------------------------------
CHARS 000000 001FFF 002000 00001
HEADER 000000 000007 000008 00001
ZEROPAGE 000002 000052 000051 00001
CODE 008000 008147 000148 00001
VECTORS 00FFF6 010001 00000C 00001

Once again, thank you. Your config file will be of much help.


Top
 Profile  
 
PostPosted: Fri Apr 17, 2015 8:57 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19122
Location: NE Indiana, USA (NTSC)
The VECTORS segment in the link script included with cc65 is oversized. Currently you're using .word 0, 0, 0 as a workaround for this oversized segment. Remove this line.


Top
 Profile  
 
PostPosted: Fri Apr 17, 2015 9:59 pm 
Offline

Joined: Mon Aug 25, 2014 12:46 pm
Posts: 10
Location: Massachusetts, United States
Ah, that would make sense.

Now my code will assemble, but my rom won't load. Some of the data seems to have changed where it shouldn't have; for example, within the .nes file, now my iNes header is CE,C5,D3,1A,02,01,01,00 when it should be 4E,45,53,1A,02,01,01,00. I changed
Code:
.segment "HEADER"
to
Code:
.segment "INESHDR"
since it seemed to be your config file's equivalent and it wouldn't assemble otherwise. Same with "CHARS" to "CHR", in which I include a CHR ROM file.

There are a few other times within the code that the four most significant bits of certain bytes are changed.

Also, there are a lot of bytes containing FF at the end of the PRG ROM.


Top
 Profile  
 
PostPosted: Fri Apr 17, 2015 11:39 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2963
Location: Tampere, Finland
BlueGoldWolf17 wrote:
Now my code will assemble, but my rom won't load. Some of the data seems to have changed where it shouldn't have; for example, within the .nes file, now my iNes header is CE,C5,D3,1A,02,01,01,00 when it should be 4E,45,53,1A,02,01,01,00.

You're using cl65, right? In cl65 the system type is set to C64 by default, so it'll do character translation to PETSCII. In ca65 the default system type is "none". So, try passing "-t none" before the "-C" switch.

Quote:
Also, there are a lot of bytes containing FF at the end of the PRG ROM.

That's fine, probably tepples defined $FF to be used as the fill byte for unused space.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Sat Apr 18, 2015 6:20 am 
Offline

Joined: Mon Aug 25, 2014 12:46 pm
Posts: 10
Location: Massachusetts, United States
Oh, I see where he defined that in the config file now. I don't know how I didn't catch that earlier.

My program works now.

Thank you so much to the both of you! My code would be nowhere without the help.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 7 guests


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