-
Notifications
You must be signed in to change notification settings - Fork 36
A first example to get the ball rolling #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix the reference screenshot
I do agree the first example has to be minimal, and that the important part is to make sure you can go all the way from the C source to the binary sms ROM file, but I still think this is an example better suited for text rendering. On the other hand, I hardly can imagine some very simple example apart from something like zeroing the whole VRAM and setting the BG color to some blue or whatever. I mean, this would surely be enough to tell if the whole thing works but I understand it would be way less satisfactory. I don't know. Probably we could keep this as an 'Hello World'/'Text Render' example and create what I just said as a very basic bare minimum example and give it an appropriate name such as 'first test' - if you can compile this you're good to go. |
Ok, I created a "first test" example which sets a blue background, for SMS and GG. |
This is perfect! ❤️ Also, can you explain me the note on the makefile? The one about the |
The .PHONY directive forces a target to run every time make is invoked. Here is a demonstration of the problem this is working around. First, let's say everything is fine. Your project compiles from A to Z without errors, i.e. everything compiles you link your .RELs, get a .ihx, then convert the ihx to SMS. Let's look at the file timestamps:
Then you make a change to your main.c which results in a linking error, for instance, an undefined symbol. To do it on purpose, add
Ok, so this last sdcc execution is supposed to generate hello.ihx out of the provided rels. But the extern aaa symbol we declared on purpose here does not exist. The sdcc process ends with a non-zero value, make catches the errors and stops there. Let's look at the file timestamps again:
Oh? hello.ihx exists and has a new timestamp despite the error (sdcc returned non-zero)! The .sms file is still old, since make stopped after the error. But then, if we type make again, make only sees that only hello.sms is out of date and runs the target that converts the .ihx to .sms.
See how the last time make is telling you everything is fine and done, yet the .sms file (that Emulicious reloads automatically in my setup) is old and holds none of the changes I think I made? Sure, to get there, you have to miss the error the first time make ran, but the above is not the behaviour I want and expect when I type make. If a step fails, I want the build to fail every time I type make. In real life, link errors happens when you do not type a function name correct or are making changes to a library.. I got bitten by this a few times, hence this workaround. |
I see. I got this issues once or twice too and I thought I could solve by having the linking and conversion phase in a single recipe so to avoid that the conversion would take place without the linking, but it seems to me your approach is way better! |
Reviving this discussion because I just found out that make supports so instead of that and now if the linking phase fails (or if the ihx2sms/makesms tool fail) you get the ihx and sms file removed. When everything compiles/links/converts fine, the ihx file is retained too so next make call simply informs that there's nothing to be done. It seems to work fine but I wonder if there's something I'm overlooking here? 🤔 |
As discussed in issue #37, I know you do not like Hello World examples, but I do not agree that they are useless. Not only people usually expect one, but compiling for SMS using SDCC is different that what most people are fimilar with (i.e. it's not just gcc on Linux) and there are extra steps specific to the SMS such as converting the ihx to a .sms. So this is a nice how-to-compile example.
The example does teach the existence of the auto text renderer and how to write on the screen (using the new SMS_printstring by the way), but the way I see it the main goal here really is showing how to compile and do something minimal without any additional complexity in the way. I mean, as you suggested, using a background image instead of text would be good, and I intend to do so next. But I would not like to merely include a .c with a large data array. I would also want to show how the original png was converted using png2tile, how assets2banks was run, probably all from the Makefile. I think all this would distract from the essential, that is how to compile and quickly get something running.