jason@cbmami.UUCP (Jason Goldberg) (03/16/91)
Hi, I am just getting my feet wet in 'C', I am a fairly experienced programmer, and am very confortable in AmigaDos, I am just trying to learn vanilla ANSI C, before I jump into Amiga specific code. I have come up with a few questions: 1. How can I get output to the printer? I have tried using fopen() with "PRT:" as the file name, and then fprintf() to send the output to the file. I tried several different modes with the fopen(), but I can't get the printer to do anything... 2. What are, or where can I find the ANSI codes for controlling the cursor in a colsole window (i.e. the CLI or WSHELL). I am trying to do stuff like cursor up, cursor down, left, right, home, clear, etc... Is there are better way than to just print the ANSI codes, keeping in mind I need to be able to do this in a console window, and not on my own screen. 3. Is there a good way to be able to read a single character from the keyboard (without a return)? I know that I can open a RAW: window but then I have to use write() instead of fprintf() or sprintf() then write()... Basically, I am just trying to find ways to write code similar to my classmates (who use Turbo C on the PC). On there machines getchar() does not need a return, and they have commands like gotoxy() to move around the cursor. Any help/pointers are greatly appreciated... -Jason- --------------------------------------------------------------------------- Jason Goldberg UUCP: ucsd!serene!cbmami!jason Del Mar, CA
forgeas@swinjm.UUCP (Jean-Michel Forgeas) (03/21/91)
In article <18d4fa1e.ARN0f18@cbmami.UUCP>, Jason Goldberg writes: > 2. What are, or where can I find the ANSI codes for controlling the cursor > in a colsole window (i.e. the CLI or WSHELL). I am trying to do stuff like The Rom Kernel Manual contains all this and more. > [...], and they have commands like gotoxy() to move around the > cursor. Any help/pointers are greatly appreciated... Something like this (certainely needs little more work): void gotoxy( char x0, char y0 ) { UBYTE temp[10]; UBYTE y1,y2, x1,x2, *ptr; ptr = temp; *(ptr++) = 0x9b; y1=y0/10; y2=y0%10; x1=x0/10; x2=x0%10; *(ptr++)=y1+0x30; *(ptr++)=y2+0x30; *(ptr++)=0x3b; *(ptr++)=x1+0x30; *(ptr++)=x2+0x30; *(ptr++)=0x48; *(ptr)=0; WriteConsole( temp ); // or what you want: fprintf... } -- \___/ Jean-Michel Forgeas \-/ cbmvax!cbmehq!cbmfra!swinjm!forgeas | The Software Winery -^- And, where is the universe ?
m0154@tnc.UUCP (GUY GARNETT) (03/22/91)
[Printing output to PRT:] Don't forget to close it. Printer output is buffered, and I don't believe that files are closed automagically when your program exits. Closing the file will ensure that all the data gets printed (and besides, it's good programming practice). [Ansi codes for controlling the cursor] I believe they are listed in both the RKM and the AmigaDOS manuals. In general, most VT-100 type codes work (and are almost identical to the codes implemented by IBM for their ANSI.SYS driver, if you are more familliar with that). The Rom Kernal Manual also documents Ansi codes for controlling the printer (they are translated to printer-specific control codes by the preferences printer driver, making your code wonderfully portable). Look under "Console Device" and "Printer Device" in the manuals. [reading RAW input from a console] I believe that there is also a sequence to place the console into RAW mode temporarily. (I think; I could be very wrong on this one) Check the AmigaDOS manual. You can probably write a simple library of these functions, and then include it in each of your programs. If you don't already have them, get a complete set of the Rom Kernal Manuals, and the AmigaDOS manual. THe RKM's are published by Addison-Wesley, and the AmigaDOS manual is published by Bantam. It is also a good idea to get a copy of the Hardware Reference Manual, and the Intuition Manual (also from Addison Wesley). Another recommended book is "Inside the Amiga with C", which explains how to do many amiga-specific things. Good Luck! Wildstar
markv@kuhub.cc.ukans.edu (03/23/91)
In article <761@tnc.UUCP>, m0154@tnc.UUCP (GUY GARNETT) writes: > > [Printing output to PRT:] > Don't forget to close it. Printer output is buffered, and I don't > believe that files are closed automagically when your program exits. > Closing the file will ensure that all the data gets printed (and > besides, it's good programming practice). If its been fopen()ed, it should close on exit, but you might try fflush() on the file handle (your checking that fopen() succeeds too I assume). > [reading RAW input from a console] > I believe that there is also a sequence to place the console into RAW > mode temporarily. (I think; I could be very wrong on this one) Check > the AmigaDOS manual. Yes there is, but it's somewhat non-trivial. You need to send an SET_RAW_MODE DOS packet to your console handler that will put your CON: only in an unbuffered mode. Remember, since there are several CON:s, you need to do DevProc("*"); not DevProc("CON:);. > You can probably write a simple library of these functions, and then > include it in each of your programs. If you don't already have them, > get a complete set of the Rom Kernal Manuals, and the AmigaDOS manual. > THe RKM's are published by Addison-Wesley, and the AmigaDOS manual is > published by Bantam. The DOS manual is out of print and can be hard to find though... > It is also a good idea to get a copy of the > Hardware Reference Manual, and the Intuition Manual (also from Addison > Wesley). Another recommended book is "Inside the Amiga with C", which > explains how to do many amiga-specific things. The "Intuition" RKM is obsolete. You want the new "Libraries and Devices" which includes the old Exec and Intuition manual, and (if you want to save a few bazillion pages of printing) the "Includes and Autodocs", also the Hardware Manual is updated. You can tell the "new" manual by its basically all-blue cover (older manuals are viturally all white). "Inside the Amiga with C" is a good book but its the second edtion of "Inside the Amiga" (no "with C" in the title) which you want to avoid because its older and obsolete, do don't get confused. > Good Luck! > > Wildstar -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mark Gooderum Only... \ Good Cheer !!! Academic Computing Services /// \___________________________ University of Kansas /// /| __ _ Bix: mgooderum \\\ /// /__| |\/| | | _ /_\ makes it Bitnet: MARKV@UKANVAX \/\/ / | | | | |__| / \ possible... Internet: markv@kuhub.cc.ukans.edu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~