is it like functions in normal programming?
No, functions are all done in assembly. You pass arguments to functions through the axy registers, sometimes some flags, and temp memory allocations in the zero page, and call them with jsr and jmp.
.segment seems to be something I haven't although reading about it I think it jumps to other parts of the rom?
Sort of... we need to talk about what
jumps to different parts (segments) of the rom. I think you're aware of the normal program counter, ie, the cpu register keeping score of where in the program we are during runtime
. This is not what jumps.
There is also a second concept of "program counter", somewhat confusingly. This the program counter of your assembler and/or linker, which lays down code and data into your rom image file at build time
. This is what jumps around. Maybe think of it as a needle in a programmable sewing machine. The .segment directive creates a sort of label. In your linker config file, you associate those special labels with exact "coordinates" on the cloth. The linker will instruct the needle to jump to these predefined positions of the cloth and lay something down there.
Vectors, for example, are always at the very end of ROM, or even repeated last in every bank in some cases where the last portion of the address range is bank switchable. So it's neat to instead of defining the address of the vectors manually with padding, simply write your three vectors under the segment called vectors and the linker will take care of the rest for you.
Also be sure to check out the linker documentation on the same page.