BBS: Inland Empire Archive Date: 06-23-92 (10:19) Number: 1133 From: MARK BUTLER Refer#: NONE To: DARYL POSNETT Recvd: YES Subj: Porting code Conf: (2) Quik_Bas
On 06-20-92 Daryl Posnett wrote to Derek Lyons... DL> I know how you feel... after a week of trying to get printf to do DL> something simple like "Hello World" I gave up... DP> You guys are gonna make people think C is hard or something. Yeh, the next think y'know they'll be saying that the following C snippet isn't a whole lot simpler than using Basic's... SOUND 750, 4: SOUND 55, 4 `----------------------' \| I mean, why go to all _this_ trouble when anyone can see it's _SO_ much easier to say the _exact_ same thing in C this way.... --------------------------8< CUT HERE 8<---------------------------- #include <time.h> static unsigned control; static int control_flag = 1; main() { note(750,4); note(550,4); } static void speaker_toggle(void) { if ( control_flag ) { control = inp( 0x61 ); control_flag = 0; } outp( 0x61, (inp( 0x61 ) & 0xFE) ^ 2 ); } static void sound( int frequency ) { unsigned divisor; divisor = (unsigned)( 1193180L / frequency ); if ( control_flag ) { outp( 0x43, 0xB6 ); outp( 0x42, divisor % 256 ); outp( 0x42, divisor / 256 ); control = inp( 0x61 ); control_flag = 0; } else { divisor = (unsigned)( 1193180L / frequency ); outp( 0x42, divisor % 256 ); outp( 0x42, divisor / 256 ); } outp( 0x61, control | 3 ); } static void silence(void) { outp( 0x61, control ); control_flag = 1; } static void wait_ticks( unsigned ticks ) { clock_t now; do { now = clock(); while ( clock() == now ) {;} } while ( --ticks ); } note( int frequency, int ticks ) { sound( frequency ); wait_ticks( ticks ); silence(); } --------------------------8< CUT HERE 8<---------------------------- Now wasn't that a whole lot easier? Those guys'll just never learn I guess, Daryl! <grin> --------------> MHB ;^] ... OFFLINE 1.39 * Every absurdity has a champion to defend it --- DB B1073/001271 * Origin: * Bare Bones BBS * (1:105/360)
Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET