Hi!!!
Question 1!
========
I want to make a program to print in the screen the numbers from 1 to 10 with deferent colors .For example 1(white) 2(red) 3(yellow) 4(green) ......
Is that possible through the cmd ????
Question 2!
========
How i can produce some sounds in defernet tones ,like beeps except for the '\a' ?
Are these two things possible in c++ while executing through the cmd panel?
6 1790
Hi!!!
Question 1!
========
I want to make a program to print in the screen the numbers from 1 to 10 with deferent colors .For example 1(white) 2(red) 3(yellow) 4(green) ......
Is that possible through the cmd ????
Question 2!
========
How i can produce some sounds in defernet tones ,like beeps except for the '\a' ?
Are these two things possible in c++ while executing through the cmd panel?
Hi. I did this for a project way back in college. I am looking for the source code for you. It may not be around and, if it is, I will post it. Hopefully someone else will help you out in the meantime.
OK. Found the files. They are quite big so I have cut them down to more or less essentials. Firstly 'video.h' has definitions of note frequencies and screen colors that will be used in the implementation.
Next we work out a tune on a keyboard and substitute the notes in an array and play them in sequence. Have to put in a delay between each note or we will get the fastest tune in the west :) - /* MUSIC.CPP*/
-
-
-
-
#include <stdio.h>
-
#include <stdlib.h>
-
#include <dos.h>
-
#include <conio.h>
-
#include "video.h"
-
-
int motd_notes[152] = {_G1, _G1, _C2, _C1, _E2, _E1, _G2, _G2, _G1, _E2,
-
_E1, _E2, _E1, _E2, _E1, _E2, _E2, _E2, _E1, _E2,
-
_F2, _F1, _G2, _G1, _G2, _E2, _D2, _D1, _E2, _E1,
-
_F2, _F1,
-
-
_G1, _G1, _B2, _B1, _D2, _D1, _F2, _F2, _F1, _D2,
-
_D1, _D2, _D1, _D2, _D1, _D2, _D2, _D2, _D1, _D2,
-
_E2, _E1, _F2, _F1, _F2, _D2, _C2, _C1, _D2, _D1,
-
_E2, _E1,
-
-
_G1, _G1, _C2, _C1, _E2, _E1, _G2, _G2, _G1, _E2,
-
_E1, _E2, _E1, _E2, _E1, _E2, _E2, _E2, _E1, _E2,
-
_F2, _F1, _G2, _G1, _G2, _E2, _F2, _F1, _G2, _G1,
-
_A3, _A3, _A2, _A3, _A3, _A2,
-
-
_B3, _B2, _C3, _C2, _C3, _B3, _B2, _B3, _A3, _A3,
-
_C3, _C3, _G2, _G1, _G2, _G1, _A2, _A2, _G2, _G1,
-
_G2, _F2, _F1, _F2, _D2, _D2, _C2, _C1, _C2, _C1,
-
_C2, _G1, _G2, _G1,
-
-
_C2, _C1, _G1, _G1, _E2, _E1, _C2, _C1, _G2, _G1,
-
_E2, _E1, _C2, _C1, _D2, _D1, _C2, _C2};
-
-
-
-
void motd_full(int sounds)
-
{
-
if(sounds == 1)
-
{
-
-
int a, b = 0;
-
for(a=0;a<152;a++)
-
{
-
if(kbhit() == NO)
-
{
-
sound(motd_notes[a]);
-
delay(100);
-
-
}
-
}
-
nosound();
-
-
}
-
}
-
And here is part of the code used to control the screen. There is far more code than this. I have just posted some to give you a quick look at what you can do with the screen and the computer speaker. You have to do the learning. -
#include <stdio.h>
-
#include <stdlib.h>
-
#include <conio.h>
-
#include <dos.h>
-
#include "string.h"
-
#include "video.h"
-
-
-
void set_video(int display_mode)
-
{
-
union REGS inreg;
-
-
inreg.h.ah = 0x00;
-
inreg.h.al = display_mode;
-
-
int86(0x10, &inreg, &inreg);
-
}
-
-
void cursor(int row, int column)
-
{
-
union REGS inregs;
-
-
inregs.h.ah = 0x02;
-
inregs.h.bh = 0;
-
inregs.h.dh = row;
-
inregs.h.dl = column;
-
-
int86(0x10, &inregs, &inregs);
-
-
}
-
-
void clear_prompt(int cursa, int cursb, int colf, int colb)
-
{
-
-
cursor(cursa, cursb);
-
repeat_char(255, 66, colf, colb);
-
cursor(cursa+1, 6);
-
repeat_char(255, 66, colf, colb);
-
cursor(cursa+2, 6);
-
repeat_char(255, 66, colf, colb);
-
cursor(cursa+3, 6);
-
repeat_char(255, 66, colf, colb);
-
cursor(cursa+4, 6);
-
repeat_char(255, 66, colf, colb);
-
cursor(cursa+5, 6);
-
repeat_char(255, 66, colf, colb);
-
cursor(cursa+6, 6);
-
repeat_char(255, 66, colf, colb);
-
cursor(2, 8);
-
}
-
-
void repeat_char(char ch, int howmany, int fcolour, int bcolour)
-
{
-
union REGS inregs;
-
-
inregs.h.ah = 0x09;
-
inregs.h.al = ch;
-
inregs.h.bh = 0;
-
inregs.h.bl = (bcolour << 4) | fcolour;
-
inregs.x.cx = howmany;
-
-
int86(0x10, &inregs, &inregs);
-
}
-
-
void clr_scr(int fcolour, int bcolour)
-
{
-
union REGS ireg;
-
-
ireg.h.ah = 0x07;
-
ireg.h.al = 0;
-
ireg.h.ch = 0;
-
ireg.h.cl = 0;
-
ireg.h.dh = 24;
-
ireg.h.dl = 79;
-
ireg.h.bh = (bcolour <<4) | fcolour;
-
-
int86(0x10, &ireg, &ireg);
-
-
}
-
-
void write_string(char *string, int fcolour, int bcolour, int row,
-
int column)
-
{
-
int len = strlen(string);
-
int i;
-
-
for(i=0; i < len; i++)
-
{
-
cursor(row, column+i);
-
write_char((char)*(string+i), fcolour, bcolour);
-
}
-
}
-
-
void write_char(char ch, int fcolour, int bcolour)
-
{
-
union REGS inreg;
-
-
inreg.h.ah = 0x09;
-
inreg.h.al = ch;
-
inreg.h.bh = 0;
-
inreg.h.bl = (bcolour << 4) | fcolour;
-
inreg.x.cx = 1;
-
-
int86(0x10, &inreg, &inreg);
-
}
-
-
void cursor_off(void)
-
{
-
union REGS inreg, outreg;
-
inreg.h.ah = 1;
-
inreg.x.cx = 0x0F00;
-
-
int86(0x10, &inreg, &outreg);
-
}
-
-
void cursor_on(void)
-
{
-
union REGS inreg, outreg;
-
inreg.h.ah = 1;
-
inreg.x.cx = 0x0607;
-
-
int86(0x10, &inreg, &outreg);
-
}
-
-
void set_border_colour(int colour = 0)
-
{
-
union REGS inreg;
-
-
inreg.h.ah = 0x0B;
-
inreg.h.bh = 0;
-
inreg.h.bl = colour;
-
-
int86(0x10, &inreg, &inreg);
-
}
-
-
void dreamt_display(int a, int b)
-
{
-
char *buff = "DREAM TEAM FOOTBALL";
-
-
if((a % 2) == 0)
-
{
-
set_border_colour(b);
-
clear_prompt(b+2,6,0, b);
-
clear_prompt((16-b),6,0, b);
-
write_string(buff,b+1,b,12,29);
-
}
-
write_string(buff,b+1,b,b+4,b+29);
-
write_string(buff,b+1,b,20-b,29-b);
-
}
-
Thanks !!!!!!!!
You are great man and great programmer!!!!!!!
Thanks !!!!!!!!
You are great man and great programmer!!!!!!!
Well that is a great thank you.
This was all from several years back. I am sure I stole most of the code from books etc. Looking at it now I don't understand half of it :)
I am sure I would never dream of writing code today that uses interupts to code registers directly.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Put 030516 in email subj to get thru |
last post by:
I'm trying to learn about Java MIDI programming. Specifically, I'm
interested in playing with Java MIDI sequencers (all puns intended).
I'm looking at...
|
by: Robert Gravereaux |
last post by:
I'm putting together a C# .Net forms project on win2k. The application
requires some sort of horn sound. I've never implemented any audio in .Net,
so I'm not sure how best to accomplish this.
...
|
by: June Li |
last post by:
H
I got a problem with detecting sound card with Windows xp
I am working on an application to test microphone. First I need detect if there is a sound card installed (or integrated audio...
|
by: Larry Serflaten |
last post by:
I'm adding a bit of sound to a simple game I've got going, and
I want to have several sounds on at the same time, so I go looking
to use the MCISendString commands and find they CRASH MY
COMPUTER...
|
by: anadiks |
last post by:
Problem 2: Threading:
Requirements: In a particular system there are two threads T1 and T2.
T1 is the master thread that periodically sends messages to the worker thread T2.
The system...
|
by: laredotornado |
last post by:
Hi,
Is there a cross-browser way to play short (< 25K) sound files without
spawning new windows or embedding any visual controls on the page? I
would like to click a button and hear my short...
|
by: =?Utf-8?B?VmVybm9uIFBlcHBlcnM=?= |
last post by:
I have an application that is designed for using with a bar code scanner. I
want the user to know that the scan was complete and the data was entered, so
I am playing a system sound after data...
|
by: Jake Barnes |
last post by:
I did a search on the newsgroup comp.lang.javascript. I was searching
for "how to play a sound with Javascript". I'm somewhat suprised that
the majority of entries are from the 1990s, and there are...
|
by: kid joe |
last post by:
Hello
I've got interested in learning some basic sound programming bits in
C... mainly I want to know how to go about accessing the sound devices -
reading from them mainly - in windows and...
|
by: chromis |
last post by:
Hi,
I've been struggling to get sounds to work with attachSound when the sounds are stored in a swf loaded into another swf. I came across a post on a forum which supposedly explains how to to do...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |