Feature: 68K Programming Guidelines
Posted by Nick on 26 April 2000, 01:42 GMT
 François Revol, a French programmer, brings up some interesting points in our next feature, talking about establishing guidelines for coding in 68000 assembly.
 
     Ti68k open programming guidelines
  With the increasing number of z80 based TI calcs, we have come to an       incredible list of shells, at least 3 for every model, each       having it's own 'API'. Of course, some of them were designed to       be compatible with others like CrASH for Ash... But       it's far from ideal. 
   Of course, on the 68k  scene, there are only 3 models (but how many       ROM versions ? How many Hardwares ?) but it might change in the       future... And don't count on TI engineers to help you to stay       compatible...  
   One project that will help us (IMO) is        [tie], which        would allow to fill the gap between the Ti92 and the 92+/89       models... I think the most important function needed is       heaplock, which must be in the ROM, but we need to       locate it. 
   Another project that I think is the best thing that happened to the       Ti68k world since Fargo is        Prosit.        Multitasking on the is a great and fun thing. And it's only the       beginning.  
 The main reason Prosit isn't so popular is the fact it doesn't allow       DoorsOs programs (games particularly) to be loaded (and so       multitasked). The problem is DoorsOs progs, DoorsOs itself and       TI'ROM aren't designed for that. The keyboard is the perfect       example: every program reads the keyboard port directly. 
   The best design would be to isolate all hardware access in libraries       (and even the ROM calls like file access, ...) so that, by       changing a library, manually or even within an exec() function,       we could run a program both under plain DoorsOs and Prosit, and       [tie]. (Another great thing would be porting Prosit to [tie]       when it gets enough stable...). 
   Another problem is the link: There is the standard cable, the        IR-Link,        the HF-Link... Wouldn't it be good if the progs       could access any of these devices without any change ? The neat       thing would be a networking protocol which should drive       indifferently a 2 calcs cable, an IR net, or an I2C wired calc       net. It is on my project list. 
   An important point is the language: since we are now able to use       C or Pascal instead of ASM, it is possible that a       library written in ASM will be used by a C program, or be       replaced by a new version written in C. So it is important to       always follow the C calling convention (even TI engineers        do it !) for library calls at least. 
   Another step will be writing a C standard library, which would allow       porting nice programs from the UNIX world... It is also on my       project list ;-) 
   All these stuff would allow both DoorsOs/[tie] and Prosit to run a       program. 
 An example would be a program which uses grayscales. Under DoorsOs it       uses the standard gray4lib. Under Prosit it calls a special       gray4lib which tells Prosit to allocate a virtual screen and       disable the GUI untill a hotkey swaps to an other screen... 
   Modular programming is sometimes harder to get used to, but I think it        is worth to. Something I use in my progs is to include a file       named "config.h", common to all progs, in which a       CONFIG.BAT writes the target (92/92+/89), the language       (English, French,...), and I have a structure MAKE.BAT       tree to help build the progs (Have a look at       prosit_apps.zip,        there is also a nice Othello game for Prosit in bonus). 
   Last thing: don't assume your programs will be compiled under       DOS/Winblows! I had so many problems with DOS specific stuff       under Linux... I still don't understand why so much people       bother using DOS/Zin, as Linux is so great... :-(( 
   My ultimate goal is to be able to surf the net on a TI (I mean not       using any trick like Telnet83, but a real TCP/IP stack and       stuff). What about you folks, do you think it is possible ? 
   I suggest the following to be discussed as a "Ti68k Open 	Programming guidelines" Request For Comment (RFC ;-)) 
       - Be as modular as possible       
- Try to comment the source code (I know it's hard to do)       
- Always use the C calling convention       
- Isolate I/O in libraries       
- Try to think of possible 'wrappers' on ti92 for something 	that doesn't exist.       
- Think about both 92 and 89 screen/keyboard 
 Well, what do you people think? 
Talk amongst yourselves :-)