Mail Archives: djgpp/1998/11/25/07:20:19
From: | "strikes" <lock AT omen DOT com DOT au>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | DJGPP 2.8.1 Major Bug, Do NOT ignore!
|
Date: | Wed, 25 Nov 1998 20:08:16 +0800
|
Organization: | Omen Internet
|
Lines: | 128
|
Message-ID: | <73grth$8ra$1@demeter.omen.com.au>
|
NNTP-Posting-Host: | ttye46.bandicoot.omen.com.au
|
X-Trace: | demeter.omen.com.au 911995633 9066 203.15.92.175 (25 Nov 1998 12:07:13 GMT)
|
X-Complaints-To: | abuse AT omen DOT net DOT au
|
NNTP-Posting-Date: | 25 Nov 1998 12:07:13 GMT
|
X-Newsreader: | Microsoft Outlook Express 4.72.3110.1
|
X-MimeOLE: | Produced By Microsoft MimeOLE V4.72.3110.3
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hello, I was trying to create a Conways Life simulator in DJGPP using Rhide
underneath Windoze 98 when I discovered that when I tried to
if (life1[X1][Y1-1] == 1) that the -1 did not seem to do anything. I tried
doing different variations on it but it failed. I am certain that I am doing
nothing wrong and I seriously do not know what is wrong. Anyhow, I have
included the infected program below.
---Infected C programs starts below---
#include <conio.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <pc.h>
//#include "ascii.h"
#define DIE
int life1[100][100];
int life2[100][100];
int neighbours;
typedef unsigned char byte;
int Chr,Col,Rep;
void putchr(byte Chr, byte Col, long Rep)
{
__asm__ __volatile__("
movb $0x09, %%ah\n
movb %0, %%al\n
movb $0x00, %%bh\n
movb %1, %%bl\n
movw %2, %%cx\n
int $0x10\n"
:
: "g" (Chr), "g" (Col), "g" (Rep)
);
}
int processlife(int number, int X0, int Y0)
{
int X1,Y1;
int X3,Y3;
int CsucksX,CsucksY; // failed debug attempts led to these names
X1 = X0; Y1 = Y0;
/* for (X3 = 1; X3 < 80; X3++) {
for (Y3 = 1; Y3 < 25; Y3++) {
if (number == 1) {life2[X3][Y3] = 0;} else {life1[X3][Y3] = 0;}
}} */
if (X1 > 0) { if (number == 1) {if (life1[X1-1][Y1] == 1)
{ neighbours++; }} else {if (life2[X1-1][Y1] == 1) { neighbours++; }}}
// if (X1 < 79) { if (number == 1) {if (life1[X1+1][Y1] == 1)
neighbours++; }} else {if (life2[X1+1][Y1] == 1) { neighbours++; }}}
if (Y1 > 0) { if (number == 1) {if (life1[X1][Y1-1] == 1)
{ neighbours++; }} else {if (life2[X1][Y1-1] == 1) { neighbours++; }}}
// if (Y1 < 24) { if (number == 1) {if (life1[X1][Y1+1] == 1)
neighbours++; }} else {if (life2[X1][Y1+1] == 1) { neighbours++; }}}
// if ((X1 > 0) && (Y1 > 0)) { if (number == 1) {if (life1[X1-1][Y1-1] == 1)
{ neighbours++; }} else {if (life2[X1-1][Y1-1] == 1) { neighbours++; }}}
// if ((X1 < 79) && (Y1 < 24)) { if (number == 1) {if (life1[X1+1][Y1+1] ==
1) { neighbours++; }} else {if (life2[X1+1][Y1+1] == 1) { neighbours++; }}}
// if ((X1 > 0) && (Y1 < 24)) { if (number == 1) {if (life1[X1-1][Y1+1] ==
1) { neighbours++; }} else {if (life2[X1-1][Y1+1] == 1) { neighbours++; }}}
// if ((X1 < 79) && (Y1 > 0)) { if (number == 1) {if (life1[X1+1][Y1-1] ==
1) { neighbours++; }} else {if (life2[X1+1][Y1-1] == 1) { neighbours++; }}}
if(neighbours<2) {if (number == 1) { life1[X1][Y1] = 0;} else
life2[X1][Y1] = 0;}}
if(neighbours==3) {if (number == 1) { life1[X1][Y1] = 1;} else
life2[X1][Y1] = 1;}}
if(neighbours>3) {if (number == 1) { life1[X1][Y1] = 0;} else
life2[X1][Y1] = 0;}}
gotoxy(1,1); cprintf("%d : %d : %d : %d ;
%d",neighbours,number,X1,Y1,(Y1-1));
gotoxy(X1,Y1);
if (number == 1) { if (life1[X1][Y1] == 1) { cprintf("*"); }}
if (number == 2) { if (life2[X1][Y1] == 1) { cprintf("*"); }}
if (neighbours > 0) {getch(); cprintf("%d",neighbours);} else {}
neighbours = 0;
}
printlife(int number)
{
int X2,Y2;
for (X2 = 1; X2 < 80; X2++) {
for (Y2 = 1; Y2 < 25; Y2++) {
gotoxy(X2,Y2);
if (number == 1) {if (life1[X2][Y2] == 1) {putchr(219,15,1);} else
{putchr(32,15,1);}} else if (life2[X2][Y2] == 1) {putchr(219,15,1);} else
{putchr(32,15,1);}
}}
}
main()
{
int i,X,Y;
clrscr();
life1[10][10] = 1; life1[11][10] = 1; life1[12][10] = 1;
life2[10][10] = 1; life2[11][10] = 1; life2[12][10] = 1;
for (i = 1; i < 100; i++)
{
delay(1000);
for (X = 1; X < 80; X++){
for (Y = 1; Y < 25; Y++){
processlife(1,X,Y);
}}
printlife(2);
delay(1000);
for (X = 1; X < 80; X++){
for (Y = 1; Y < 25; Y++){
processlife(2,X,Y);
}}
printlife(1);
delay(1000);
}
}
- Raw text -