Hi, all, and especially the code gurus. Need some help here (you may have realized from some of my previous code posts that programming is not my strong point):
I started with the "HelloWorld" tutorial, and have done a lot of work studying it. I have un-macroed the macros,
un-subbed the subroutines, un-libbed the libraries, and in general made a nice, clean linear-flow sample program that I can use to further understand TE/HUC programming. Since I am only interested in the print-to-the-display operation, I have also removed any music/joystick/button/interrupt related code. The result is, of course, smaller and easier to analyze code.
However, I am having some trouble understanding the font stuff. So, I went back to the original "Helloworld" list file and I am reviewing it. Part of the problem is that the tutorial actually seems to perform a number of functional operations twice, and each of these two code-flows seem to be attempting to achieve the same result but in somewhat (ok,...significantly...at least to me) different manners.
Here are some general questions for which I need guidance:
1. The code under consideration is "load font", part of "startup.asm".
The first function called here is "_set_font_addr". This function gets the
font address data of $0800 as defined by #FONT_VADDR, manipulates it, and stores it into
the variable "_font_base". So...
a) Why $0800? I do not recall any docs that indicated this is a
set-in-stone address, so why was it chosen; any specific reason?
b) The resultant data stored in "_font_base" is $0080. If I change the defined
address to $0810, the result is $0081. If I use $0801, the data is $0080. Obviously,
there is a boundary/alignment consideration here. What is it? (see also question #5)
2. The next font code-activity uses the two variables "_font_color" and "font_table".
The first thing I notice are the lines "stb _font_color+1,<_bl", and "lda _font_color". These are in
preparation for the load-the-font-loop. However, I do not notice any code preceding this where any data is
stored into that variable. It is, however, loaded with data in the "_set_font_color.2" function,
but this routine is called by the actual user-C-code, which occurs well after the initialization
code previous indicated. So...
a) What's the purpose of the macro "fntcpy"? It calls "load_font", but "fntcpy" itself doesn't appear
to play any part in the code. Did I miss it?
b) What's the purpose of loading what is essentially garbage (IE: uninitialized data) into a variable, then using that variable in the load-the-font-loop. (Yes, I know the format of characters is ppppgggrrrbbb, and what it means. But is that applicable here?).
c) Why would we care what's in the "pppp..." color portion of the character, if we are later going to
completely ignore it when we use the "_set_font_color.2" function in the user code?
3. Again, in the user code, there is a function "_set_font_pal", which overwrites any data in the palette bits
in "_font_base".
So...
a) Why do it in the load-the-font-loop in the first place?
4). Yet again in the user code, is the function "_load_default_font". And again,
it seems to repeat the previous functionality of "load_font", only this time using the user data. So...
a) Why again is there this duplication of code, with data being overwritten?
5) Finally the user code function "_put_string.3" uses the variable "_font_base" (see question #1); it SEEMS to get the character description then stores it to the VDC. But this doesn't make sense, given that the font (which = the character description) has already been loaded into the video ram. Or, is the use of "_font_base" actually referencing the VRAM data itself, and not the font description (loaded from "font.inc")? If so, how does it's value relate to choosing the specific character?
As you can see, I am drawing a near-complete blank on this, although I have made good progress in everything else (so far!)
I am sure I will have more questions, based on the answers to these here. Feel free to use my email if it seems appropriate.
Many thanks to any who can provide any guidance here.
Charlie