From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2002-03-15 23:14:42
On Fri, Mar 15, 2002 at 10:40:52PM +0100, Stephan Lesch wrote: > I'm new to the list, and new to cc65 (just made the first experiences). > I'm going to write an engine for an adventure on the C64, and I'm a little > insecure if I should try writing it in C, or stay with assembler. My usual suggestion is to start with C. C on the 6502, and its implementation (cc65) do have some drawbacks compared with assembly code, but the advantages are far greater for most programs. Even if you choose to rewrite all of the code in assembler later, you will often be faster, because testing things in C is a lot easier and changes are made faster. And the nice thing about cc65 is that you don't loose the capability to code any part of your program in assembler: C and assembler will work together quite nicely. If you don't do graphics, you may even be able to make your program portable, so that it will run on other platforms supported by cc65. For example, support for the Atari is quite good thanks to the help of several Atari programmers. > 1- How far can I control the memory usage of the compiled C program. > For instance, if my compiled program fits into $2000 bytes, and > I reserve $1000 bytes for the heap, is it possible to place the > compiled program and its heap to $2000-$5000, so that the other > memory areas remain untouched? You can control memory usage of the program almost as good as with pure assembler. You may need to write your own startup code and linker config, however. The increased memory footprint (compared to an assembler program) may be a problem. > 2- Can I limit zeropage usage in a similar way, so that only addresses > between e.g. $80 and $ff are used by the C program? The compiled code plus the C and runtime libraries need 24 bytes in the zero page. You can move these locations in the zero page by changing the linker configuration and/or the startup code. > (The call-stack is located in the zeropage, right?) The call stack is located in page one, while the argument stack is located somewhere in memory (the exact location is defined in the linker config). The argument stack grows downwards, its size depends on your program. > 3- I'd like to combine the C program with independent assembler routines > (mouse driver, loader, raster IRQs, music...) - has anyone used such > routines in combination with a C program on the 64? The compiler comes with a mouse library that works on several platforms (GEOS, Atari, C64, C128 and P500). If you don't know cc65 really well, I would suggest to write any interrupt stuff in assembler - there are too many things that can go wrong when writing interrupt handlers in C. > 4- Has anyone successfully used the 64's rom routines for file access and > keyboard input? Calling ROM routines is not a problem, but Marc Rintsch has written CBM BASIC compatible file I/O routines, which offer a far nicer C interface. And the Atari library supports file real C I/O, something still missing from the Commodore parts. Keyboard input as well as text output is available on almost all systems via the conio library. You may want to have a look into the conio.h header file for a list of the available functions and a short description. Regards Uz -- Ullrich von Bassewitz uz_at_musoftware.de ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2002-03-15 23:14:41 CET