Project Assignment Snake Game/Car Acceleration Meter Min 10 Pages 10 min Presentation Max 5 group members Submitting Date: lab 2:Dec 27, 2014 Lab 3: Dec.

Slides:



Advertisements
Similar presentations
Character Arrays (Single-Dimensional Arrays) A char data type is needed to hold a single character. To store a string we have to use a single-dimensional.
Advertisements

DOS and BIOS Interrupts DOS and BIOS interrupts are used to perform some very useful functions, such as displaying data to the monitor, reading data from.
DEVELOPING ICT SKILLS PART -TWO
 Use the Left and Right arrow keys or the Page Up and Page Down keys to move between the pages. You can also click on the pages to move forward.  To.
Programming In C++ Spring Semester 2013 Lecture 8 Programming In C++, Lecture 8 By Umer Rana.
A Guide to Unix Using Linux Fourth Edition
Introduction to C Programming
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
1 Lecture 2  Input-Process-Output  The Hello-world program  A Feet-to-inches program  Variables, expressions, assignments & initialization  printf()
Chapter 7 Programming with DOS and BIOS Function Calls Objectives: The use of DOS and BIOS function call How to read the PC’s keyboard How to send text.
MCT260-Operating Systems I Operating Systems I Using Text Editors.
Introduction to C Programming Overview of C Hello World program Unix environment C programming basics.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Basic Elements of C++ Chapter 2.
C - Input & Output When we are saying Input that means to feed some data into program. This can be given in the form of file or from command line. C programming.
TOPIC: KEYBOARD PRESENTED BY: MS. AMBER AMAR. DEFINITON OF KEYBOARD Keyboard is an input device which resembles with a type writer like keys that enables.
Input/Output  Input/Output operations are performed using input/output functions  Common input/output functions are provided as part of C’s standard.
Basic Input - Output. Output functions  printf() – is a library function that displays information on-screen. The statement can display a simple text.
CSCI 1730 January 17 th, 2012 © by Pearson Education, Inc. All Rights Reserved.
Ch 51 Internal Commands COPY and TYPE. Ch 52 Overview Will review file-naming rules.
Chapter 5: Data Input and Output Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills
Chapter Nine Advanced Shell Scripting1 System Programming Advanced Shell Scripting.
Lecture 11 Last notes on interrupts and exam review Dr. Dimitrios S. Nikolopoulos CSL/UIUC.
Unix Basics Chapter 4.
RjpSystem Level Programming Operating Systems 1 Having fun withy the Unix Operating System Praxis Week 7 Rob Pooley.
Lecture 13. Outline Standard Input and Output Standard Input and Output (I/O)– Review & more Buffered/unbuffered input Character I/O Formatted I/O Redirecting.
ECE291 Computer Engineering II Lecture 9 Josh Potts University of Illinois at Urbana- Champaign.
Yu Yuanming CSCI2100B Data Structures Tutorial 3
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Programming With C.
1 The EDIT Program The Edit program is a full screen text editor that allows you to: Create text files Create text files Edit an existing text files Edit.
1 Screen and Keyboard Operations Suthida Chaichomchuen
Windows Tutorial Common Objects ACOS: 1, 4. Using the Taskbar 1. Using the taskbar, you can switch between open programs and between open documents within.
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
Constants Numeric Constants Integer Constants Floating Point Constants Character Constants Expressions Arithmetic Operators Assignment Operators Relational.
Structure of a C program Preprocessor directive (header file) Program statement } Preprocessor directive Global variable declaration Comments Local variable.
Chapter 3: Formatted Input/Output Copyright © 2008 W. W. Norton & Company. All rights reserved. 1 Chapter 3 Formatted Input/Output.
Lecture 1 cis208 January 14 rd, Compiling %> gcc helloworld.c returns a.out %> gcc –o helloworld helloworld.c returns helloworld.
DATA TYPE AND DISPLAY Computer Programming Asst. Prof. Dr. Choopan Rattanapoka and Asst. Prof. Dr. Suphot Chunwiphat.
3 Types of Video Output for Text DOS-level INT (Int 21) Output can be easily redirected to other devices (printer, disk) Slow Speed Cannot control the.
Chapter Three The UNIX Editors.
CS Class 03 Topics  Sequence statements Input Output Assignment  Expressions Read pages Read pages 40 – 49 for next time.
Chapter-4 Managing input and Output operation.  Reading, processing and writing of data are three essential functions of a computer program.  Most programs.
CSC141- Introduction to Computer programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture – 21 Thanks for Lecture Slides:
Chapter -7 Basic function of Input/output system basics and file processing Stream classes : I/O Streams. A stream is a source or destination for collection.
{ General Layout of a Keyboard Laptop or Desktop.
Command Prompt Chapter 9 Pipes, Filters, and Redirection ©Richard Goldman 11/30/2000 Revised 10/16/2001.
ROM BIOS Chapter 9. The ROM BIOS PC computer come with a set od built in routines collectively called the ROM BIOS. These routines are permanent part.
Digital Literacy: Computer Basics
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Course Title Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
C Programming Day 2. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/LA07/003 Version No. 1.0 Union –mechanism to create user defined data types.
Components of Hardware 1. Processor Memory Input and output devices Storage 2.
CCSA 221 Programming in C INPUT AND OUTPUT OPERATIONS IN C – PART 1 1.
Principles of Programming - NI Chapter 10: Character & String : In this chapter, you’ll learn about; Fundamentals of Strings and Characters The difference.
Chapter 3: Formatted Input/Output 1 Chapter 3 Formatted Input/Output.
Chapter 1 slides1 What is C? A high-level language that is extremely useful for engineering computations. A computer language that has endured for almost.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Binary Representation in Text
Chapter Topics The Basics of a C++ Program Data Types
User-Written Functions
Zhang Hongyi CSCI2100B Data Structures Tutorial 3
Basic Elements of C++.
Guide To UNIX Using Linux Third Edition
Basic Elements of C++ Chapter 2.
Input/Output Input/Output operations are performed using input/output functions Common input/output functions are provided as part of C’s standard input/output.
I/O in C Lecture 6 Winter Quarter Engineering H192 Winter 2005
File I/O in C Lecture 7 Narrator: Lecture 7: File I/O in C.
Presentation transcript:

Project Assignment Snake Game/Car Acceleration Meter Min 10 Pages 10 min Presentation Max 5 group members Submitting Date: lab 2:Dec 27, 2014 Lab 3: Dec 22, 2014

Keyboard and Cursor Chapter 8

C’s interaction with PC computer  IBM extended character codes, which enable a program to read the function keys; cursor control keys and special key combinations  ANSI.SYS control function, which give the programmer control over where the cursor is on the screen and permit other operations as well All most all programs- word processors, database programs and games – need to make use of these capabilities to provide more sophisticated level of interaction with user

Extended keyboard codes letters, numbers and punctuation, such keys generate one-byte ASCII codes The PC provides a second set of 256 keys and key combinations by using an extended code. Extended code consists of two bytes; the first byte is 0 and the second byte is a number indicating the particular key or key combination Always 0 Extended code 2 bytes Function key F1 Normal code 1 byte Letter ‘a’

Exploring the Extended Codes #include void main(void) { clrscr(); unsigned char key, key2; while ((key=getch())!='\r') { if (key == 0) { key2 = getch(); printf("%3d %3d\n", key, key2); } else printf("%3d\n",key); } getch(); } Output:

ANSI.SYS cursor control For accessing I/O devices, ANSI.SYS file used. ANSI stands for American National Standards Institute ANSI.SYS file provides a standardized set of codes for cursor control It is a section of code written to control an I/O device, which is added to the operating system((DOS) after DOS is installed ANSI.SYS interacts all the numeric codes being sent to the screen for printing For escape code (a special sequence of characters), the ANSI.SYS file deals with the code itself, moving the cursor or performing other functions For normal character, it is simply passed on the regular video routines in ROM, which display it on the screen in the usual way

One-Key Extended Codes Second Byte(Decimal)Key that Generates Extended Codes 59 F1 60 F2 61 F3 62 F4 63 F5 64 F6 65 F7 66 F8 67 F9 68 F10 71 Home 72 Up arrow 73 Pg Up 75 Left arrow 77 Right arrow 79 End 80 Down arrow 81 Pg Dn 82 Ins 83 Del

Two-Key Extended Codes Second Byte(Decimal)Key that Generates Extended Codes 15 Shift Tab 16 to 25 Alt Q,W,E,R,T,Y,U,I,O,P 30 to 38 Alt A,S,D,F,G,H,J,K,L 44 to 50 Alt Z,X,C,V,B,N,M 84 to 93 Shift F1 to F10 94 to 103 Ctrl F1 to F to 113 Alt F1 to F Ctrl PrtSc 115 Ctrl Left Arrow 116 Ctrl Right Arrow 117 Ctrl End 118 Ctrl PgDn 119 Ctrl Home 120 to 131 Alt 1,2,3,4,5,6,7,8,9,0,-,= 132 Ctrl PgUp

Installing ANSI.SYS ANSI.SYS is an optional part of DOS Installed each time at power up of computer CONFIG.SYS file used to refer the ANSI.SYS file for installation DEVICE = C:\ANSI.SYS It incorporated with operating system

Cursor Control with ANSI.SYS Cursor control is achieved with ANSI.SYS using escape sequences All ANSI.SYS commands begin with the escape sequence, “\x1B[“. CodeEffect [2] Erase screen and home cursor [K Erase to end of line [A Cursor up one row [B Cursor down one row [C Cursor right one column [D Cursor left one column [%d;%df Cursor to row and column specified [s Save cursor position [u Restore position [%dA Cursor up number of rows specified [%dB Cursor down number of rows specified [%dC Cursor right number of columns specified [%dD Cursor left one row number of columns specified

Cursor Control with ASCI.SYS #include void main(void) { while (getche()!= '\r') printf("\x1B[B"); getch(); } #include #define C_DOWN "\x1B[B" void main(void) { while (getche()!= '\r') printf( C_DOWN); getch(); } Output: H A C K E R

Character Attributes Every character is stored in the display memory as two bytes: one for the ASCII code of the character and one for the attribute 0Turns off attributes: normal white on black 1Bold(high intensity) 4Underline 5Blinking 7Reverse video; black on white 8Invisible; black on black

Key reassignment Assigning strings to function keys enables to configure keyboard for the kind of work usually do. For example, if you write lot of C programs, you might want to list the C source files in a particular directory: C>dir*.CPP If this string assign to a function key, it save lot of time printing this prase

Assigns function keys to string typed by user #include main() { char string[81]; int key; clrscr(); printf("enter number of function key:"); gets(string); key=atoi(string); /*conver string to integer*/ puts("enter string to assign to that key:"); gets(string); printf("\x 1B[0;%d;\"%s\";13p",key+58,string); getch(); }

Command-line arguments When invoke a program from the operating system, we type program name and other various items i.e. C> notepad Letter.txt By putting the right things inside the parentheses of main, we can allow our program to read command-line argument to its heart’s content. C automatically adds the capability to read these arguments to all C programs.

Uses command-line arguments #include void main(int argc,char *argv[]) { int key; clrscr(); if(argc!=3) { printf("example usage : C>funkey0 2 dir"); exit(); } key=atoi(argv[1]); printf("\x1B[0;%d;\"%s\";13p",key+58,argv[2]); getch(); }

Redirect of input and output Redirection provides an easy way to save the results of a program; it use vaguely similar that of the [Ctrl][PrtSc] key combination to save output to the printer, except that the result can be sent to a disk. Output can be redirected to go to a file instead of the screen; input can be redirected to come from a file instead of the keyboard.

Echos typing to the screen #include main() { int ch=0; while( (ch=getch() )!='\r') putchar(ch); putchar('\r'); }