While trying to compile a piece of code someone else had written I received an error, Segment 'ZEROPAGE' overflows memory area 'ZP' by 19 bytes. This was odd, since the code was only using up 45 bytes in the ZEROPAGE segment, and I believed the Zero Page to range from $0000 to $00FF. I looked into the NES config file (cc65\cfg\nes.cfg), and found that the ZEROPAGE segment only had a size of 26 ($001A) bytes. I tried changing the size to $00FF, and everything compiled just fine.
Here are some pieces of the file:
Curious, I looked into this file some more an messed around with it a bit. There seem to be many overlapping segments, and many seemed to be out of place for what I knew of the NES. In particular I looked at ROM2, which is what the CHARS segment loads. I would think that this segment would start someplace later than $0000, so I messed with it. No matter what I changed the start value to, everything compiled fine, and there were no changes in the game when I tested it. I tried setting the value to $FFFFFFFF, and there were no problems.
I have two questions:
1. [ANSWERED] Why was the ZEROPAGE segment so small? I have learned that it ranges from $0000 to $00FF, yet in this file it only ranges from $0002 to $001C.
2. [ANSWERED] Why do these segments start in the places they do? How are these segments put together into the ROM when I compile? (This is a broad question, so a more general answer makes sense if a more detailed answer is too troublesome.)
Here are some pieces of the file:
Code:
MEMORY {
ZP: file = "", start = $0002, size = $001A, type = rw, define = yes;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
}
ZP: file = "", start = $0002, size = $001A, type = rw, define = yes;
}
SEGMENTS {
ZEROPAGE: load = ZP, type = zp;
}
Curious, I looked into this file some more an messed around with it a bit. There seem to be many overlapping segments, and many seemed to be out of place for what I knew of the NES. In particular I looked at ROM2, which is what the CHARS segment loads. I would think that this segment would start someplace later than $0000, so I messed with it. No matter what I changed the start value to, everything compiled fine, and there were no changes in the game when I tested it. I tried setting the value to $FFFFFFFF, and there were no problems.
Code:
MEMORY {
ROM2: file = %O, start = $0000, size = $2000, fill = yes;
}
SEGMENTS {
CHARS: load = ROM2, type = rw;
}
ROM2: file = %O, start = $0000, size = $2000, fill = yes;
}
SEGMENTS {
CHARS: load = ROM2, type = rw;
}
I have two questions:
1. [ANSWERED] Why was the ZEROPAGE segment so small? I have learned that it ranges from $0000 to $00FF, yet in this file it only ranges from $0002 to $001C.
2. [ANSWERED] Why do these segments start in the places they do? How are these segments put together into the ROM when I compile? (This is a broad question, so a more general answer makes sense if a more detailed answer is too troublesome.)