Question about Computers & Internet

1 Answer

How can multithreading be done on C Language... OR plz tell me... i want to make a programme in c... and when this program is run suppose * is falling from up to down but can i control the movement of *(symbol) using arrow key of keyboard.... i wish the direction of * which is falling from up to down to right when i press Right arrow key of keybord..n to left when i press left arrow key of keyboard...... OR Send me code of snake game in C Language....

Posted by on

  • neerajsahu Aug 30, 2008

    plz tell me a satisfiable practical answer

×

1 Answer

  • Level 2:

    An expert who has achieved level 2 by getting 100 points

    MVP:

    An expert that gotĀ 5 achievements.

    Vice President:

    An expert whose answer gotĀ voted for 100 times.

    Sniper:

    An expert who has posted more than 50 answers, of which 90% or more were rated as helpful.

  • Expert
  • 81 Answers

What you need it's assembly language here example pixel move with arrows:

// I N C L U D E S ///////////////////////////////////////////////////////////

#include <dos.h>
#include <bios.h>
#include <stdio.h>
#include <math.h>
#include <conio.h>
#include <graphics.h>
#include <stdlib.h>

// D E F I N E S /////////////////////////////////////////////////////////////

#define KEYBOARD_INT 0x09
#define KEY_BUFFER 0x60
#define KEY_CONTROL 0x61
#define INT_CONTROL 0x20

// make and break codes for the arrow keys

#define MAKE_RIGHT 77
#define MAKE_LEFT 75
#define MAKE_UP 72
#define MAKE_DOWN 80

#define BREAK_RIGHT 205
#define BREAK_LEFT 203
#define BREAK_UP 200
#define BREAK_DOWN 208

// indices into arrow key state table

#define INDEX_UP 0
#define INDEX_DOWN 1
#define INDEX_RIGHT 2
#define INDEX_LEFT 3

// G L O B A L S /////////////////////////////////////////////////////////////

void (_interrupt _far *Old_Isr)(); // holds old com port interrupt handler

int raw_key; // the global raw keyboard data

int key_table[4] = {0,0,0,0}; // the arrow key state table

// F U N C T I O N S ////////////////////////////////////////////////////////

void _interrupt _far New_Key_Int()
{
asm{
sti
in al, KEY_BUFFER
xor ah,ah
mov raw_key, ax // I get scan code
in al, KEY_CONTROL
or al, 82h
out KEY_CONTROL,al
and al,7fh
out KEY_CONTROL,al
mov al,20h
out INT_CONTROL,al
} // end inline assembly

switch(raw_key) // process the key and update the table
{
case MAKE_UP: key_table[INDEX_UP] = 1; break;

case MAKE_DOWN: key_table[INDEX_DOWN] = 1; break;

case MAKE_RIGHT: key_table[INDEX_RIGHT] = 1; break;

case MAKE_LEFT: key_table[INDEX_LEFT] = 1; break;

case BREAK_UP: key_table[INDEX_UP] = 0; break;

case BREAK_DOWN: key_table[INDEX_DOWN] = 0; break;

case BREAK_RIGHT: key_table[INDEX_RIGHT] = 0; break;

case BREAK_LEFT: key_table[INDEX_LEFT] = 0; break;

} // end switch

} // end New_Key_Int

void setvideomode(void)
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "c:\\minc\\bgi");
errorcode = graphresult();

if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* return with error code */
}

}

// M A I N ///////////////////////////////////////////////////////////////////

main()
{
int done=0,x=320,y=240; // exit flag and dot position

setvideomode();

Old_Isr = _dos_getvect(KEYBOARD_INT); // install our ISR

_dos_setvect(KEYBOARD_INT, New_Key_Int);

while(!done) // main event loop
{
if (key_table[INDEX_RIGHT]) x++;

if (key_table[INDEX_LEFT]) x--;

if (key_table[INDEX_UP]) y--;

if (key_table[INDEX_DOWN]) y++;

// draw the cyber dot
putpixel(x,y,15);
delay(10);

if (raw_key==1) // this is our exit key the make code for "esc" is 1.
done=1;

} // end while

_dos_setvect(KEYBOARD_INT, Old_Isr); // replace old ISR

closegraph();

return 0;
} // end main
Assembly is pretty hard language.
Rate me if it helped!

Posted on Jul 07, 2009

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
goodluck!

Posted on Jan 02, 2017

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

What is programer?


A programmer is someone who writes programs for a computer or for websites. Programmers write code (the source of a program) in different languages. There are set procedures on how programs have to be written.

If you are interested in becoming a programmer you need to decide what you wish to program in, pick a language and go online to research your chosen language. Amazon will sell you books on that language or you could borrow a book from your local library.

Jul 24, 2011 | Computers & Internet

1 Answer

What is machine level language


Hi, Machine languages are the only language that are understood by the computers.While easily understood by the computers machine languages are almost impossible for humans to use because they consist entirely numbers.Machine level languages are in binary codes 1, 0 which only computers can understand normally.

Advantage

The only advantage is that program of machine language run very fast because no translation program is required for the CPU.

Disadvantages


  1. It is very difficult to program in machine language. The programmer has to know details of hardware to write program.
  2. The programmer has to remember a lot of codes to write a program which results in program errors.
  3. It is difficult to debug the program.
camulus_0.jpg

Dec 31, 2010 | Computers & Internet

1 Answer

Graphic problem


Try to reinstall you'r graphic driver. If you don't remember what driver you need, then let a computer program search for it (f.eks Driver Detective, Driver Genius, Driver Agent, etc....)

Jul 29, 2009 | Compaq Computers & Internet

2 Answers

Graphics error for C language programming


If you have AMD processor so it won't work, and if have INTEL so check if the graphics install in the correct folder.

Apr 17, 2009 | ASUS EAH2600XT/HTDP - Graphics adapter -...

1 Answer

What is the basic difference between multitasking multiprogrammin


I would have expected that you would be asking the difference between
multithreading and parallel processing, which is simply a matter of using
sequential processor [multithreading] to simulate simultaneous data streams from multiple processors [parallel processing] while the terms you did inquire concerning are various terms of varying complexity which refer to the simultaneous accomplishment of various tasks.

A multithreading processor alternates the application of tasks to alternating clock cycles of the same processor.

A parallel processor has a matrix of multiple processors assigned to diverse tasks with streaming data from each clock cycle of the same processor for the same task.

multitasking simply means the simultaneous accomplishment of multiple tasks by any means including cyber or human.

Multiprogramming is the simultaneous operation of various alogorithms
where none are halted to allow the others to proceed, which process can be accomplished through with either parallel processors or a multithreaded processor.

Prior to the existence of multiple processors in a single CPU (ex. Core Duo) or even Multithreaded Processors [Pentium Four, PPC], certain types of looping algorithmic methods could be applied [and this programmer did apply such] to multiple tasks to create
the appearance that the tasks were accomplished simultaneously.
The latter was more of a Trompe l'Oeil


Apr 14, 2009 | Microsoft Windows XP Professional

1 Answer

To calculate frequence of occurence of syllables in hindi diction


Select Count(*) from <TableName> Where fieldname like '%syllable%';

Mar 15, 2009 | Computers & Internet

1 Answer

What is mean by multithreading and multitasking?


Multitasking - It means running multiple programs at 1 time.
For Example running a game and windows media player simultaneously.

Multithreadind : this means that how many data threads can the processor process at a given time.
Faster multithreading means that u ll breeze through your applications.

Contact me if this is not clear.

Jan 14, 2009 | Computers & Internet

1 Answer

Bios programing


Bro you will need to learn C language programming.
When you become C language then you will become BIOS programmer.

Dec 03, 2008 | Intel Motherboard

1 Answer

EXE files


by running them in the appropriate program

Jul 01, 2008 | Computers & Internet

4 Answers

Want to Change Language


Dont purchase cameras with japanese language in future if they dont provide translation in english..

Mar 14, 2008 | Fuji FinePix F401 Digital Camera

Not finding what you are looking for?
Computers & Internet Logo

Related Topics:

438 people viewed this question

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers

kakima

Level 3 Expert

102366 Answers

David Payne
David Payne

Level 3 Expert

14161 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...