Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compiler Issue

Status
Not open for further replies.

instinct

Programmer
Aug 23, 2003
9
0
0
CA
When using qbasic and I try to compile a program I wrote, it has the error:
0030 0560 SCREEN 13
^ Data-memory Overflow

I can't compile my program because of this error, does anyone knw how to fix it. Oh and it only occurs when I am compiling a certain program. The program is a 3d missle flying across the screen.


the code for the program is:

'************************************************
'************************************************
DECLARE SUB zbuffer ()
DECLARE SUB bcls ()
DECLARE SUB Trans (theta!, phi!, delta!, pts!)
DECLARE SUB define ()
DECLARE SUB polyfill (p1!, p2!, p3!, c%)
DIM SHARED c(360), s(360), xc, yc, zc
DIM SHARED b(4000) AS LONG
DECLARE SUB bcopy ()
DECLARE SUB BPSET (x&, y&, COLOUR%)
DIM SHARED Buffer(32002) AS INTEGER

'INPUT "3d File: ", file$
file$ = "missle.dat"
SCREEN 13
GET (0, 0)-(319, 199), Buffer

OPEN file$ FOR INPUT AS #1
INPUT #1, xc
INPUT #1, yc
INPUT #1, zc
INPUT #1, pts
DIM SHARED x(pts), y(pts), z(pts), x2(pts), y2(pts), z2(pts), x3&(pts), y3&(pts)
DIM SHARED pols
FOR i = 1 TO pts
INPUT #1, x(i)
INPUT #1, y(i)
INPUT #1, z(i)
NEXT
INPUT #1, pols
DIM SHARED poly(3, pols), cpoly%(pols)
DIM SHARED zb(pols, 2)

FOR i = 1 TO pols
INPUT #1, poly(1, i)
INPUT #1, poly(2, i)
INPUT #1, poly(3, i)
INPUT #1, cpoly%(i)
NEXT

CLOSE #1


define
theta = 45
phi = 45 + 90
delta = 360
DO
delta = (delta + 12) MOD 360
theta = (theta + 0) MOD 360
phi = (phi + 0) MOD 360
CALL Trans(theta, phi, delta, pts)
CALL zbuffer
zc = zc + 1
xc = xc + 200 / zc
yc = yc + 100 / zc
bcopy
bcls
LOOP UNTIL INKEY$ = CHR$(27) OR xc > 300

SUB bcls
a& = Buffer(0)
b& = Buffer(1)
ERASE Buffer
Buffer(0) = a&
Buffer(1) = b&
END SUB

SUB bcopy
PUT (0, 0), Buffer, PSET
END SUB

SUB BPSET (xa&, ya&, c%)
W& = Buffer(0) / 8
O& = VARPTR(Buffer(2))
offset& = (W& * ya& + xa&) + O&
DEF SEG = VARSEG(Buffer(0)) + INT(offset& / 16)
POKE offset& MOD 16, c%
DEF SEG
END SUB

SUB define
FOR i = 0 TO 360
c(i) = COS(i * 3.14 / 180)
s(i) = SIN(i * 3.14 / 180)
NEXT
END SUB

SUB polyfill (p1, p2, p3, c%)
DIM xp(3), yp(3)
xp(1) = x3&(p1)
xp(2) = x3&(p2)
xp(3) = x3&(p3)
yp(1) = y3&(p1)
yp(2) = y3&(p2)
yp(3) = y3&(p3)
FOR i = 1 TO 3
FOR j = 1 TO 3
IF yp(i) < yp(j) THEN
sav = yp(i)
yp(i) = yp(j)
yp(j) = sav
sav = xp(i)
xp(i) = xp(j)
xp(j) = sav
END IF
NEXT
NEXT
IF yp(3) <> yp(1) THEN
sy1 = 1 / (yp(3) - yp(1))
ELSE
sy1 = 1
END IF
IF yp(2) <> yp(1) THEN
sy2 = 1 / (yp(2) - yp(1))
ELSE
sy2 = 1
END IF
IF yp(3) <> yp(2) THEN
sy3 = 1 / (yp(3) - yp(2))
ELSE
sy3 = 1
END IF
sx1 = xp(3) - xp(1)
sx2 = xp(2) - xp(1)
sx3 = xp(3) - xp(2)
FOR y = yp(1) TO yp(3)
IF y <= yp(2) THEN
x1 = INT((y - yp(1)) * sy1 * sx1 + xp(1))
x2 = INT((y - yp(1)) * sy2 * sx2 + xp(1))
IF x2 < x1 THEN
sav = x1
x1 = x2
x2 = sav
END IF
ya& = y
FOR xa& = x1 TO x2
offset = INT((320 * ya& + xa&) / 16) + 1
byte = (320 * ya& + xa&) MOD 16
a = b(offset) AND 2 ^ byte
IF a = 0 THEN
b(offset) = b(offset) OR 2 ^ byte
BPSET xa&, ya&, c%
END IF

NEXT
ELSE
x1 = INT((y - yp(1)) * sy1 * sx1 + xp(1))

x2 = INT((y - yp(2)) * sy3 * sx3 + xp(2))

IF x2 < x1 THEN
sav = x1
x1 = x2
x2 = sav
END IF
ya& = y
FOR xa& = x1 TO x2
offset = INT((320 * ya& + xa&) / 16) + 1
byte = (320 * ya& + xa&) MOD 16
a = b(offset) AND 2 ^ byte
IF a = 0 THEN
b(offset) = b(offset) OR 2 ^ byte
BPSET xa&, ya&, c%
END IF

NEXT
END IF
NEXT
END SUB

SUB Trans (theta, phi, delta, pts)
t = theta
p = phi
d = delta
a = c(p) * c(d)
b = c(p) * s(d)
c = (s(p) * s(t) * c(d) - c(t) * s(d))
de = (s(p) * s(t) * s(d) + c(t) * c(d))
e = c(p) * s(t)
f = (s(p) * c(t) * c(d) + s(t) * s(d))
g = (s(p) * c(t) * s(d) - s(d) * c(d))
h = c(p) * c(t)
FOR i = 1 TO pts
x2(i) = x(i) * a + y(i) * b - z(i) * s(p)
y2(i) = x(i) * c + y(i) * de + z(i) * e
z2(i) = x(i) * f + y(i) * g + z(i) * h

x3&(i) = 256 * (x2(i) / (z2(i) + zc)) + xc
y3&(i) = 200 - (256 * (y2(i) / (z2(i) + zc)) + yc)
BPSET x3&(i), y3&(i), 15
NEXT
END SUB

SUB zbuffer
ERASE b
FOR i = 1 TO pols
zb(i, 1) = z2(poly(1, i)) + z2(poly(2, i)) + z2(poly(3, i))
zb(i, 2) = i
NEXT
FOR i = 1 TO pols
FOR j = 1 TO pols
IF zb(i, 1) < zb(j, 1) THEN
sav = zb(i, 2)
zb(i, 2) = zb(j, 2)
zb(j, 2) = sav
sav = zb(i, 1)
zb(i, 1) = zb(j, 1)
zb(j, 1) = sav

END IF
NEXT
NEXT
FOR i = 1 TO pols
a = poly(1, zb(i, 2))
b = poly(2, zb(i, 2))
c = poly(3, zb(i, 2))
polyfill a, b, c, cpoly%(zb(i, 2))
NEXT
END SUB



'*********************************
'*********************************



The Data file "missle.dat" contains this:


80
70
50
57
0 0 -11
0 1 -10
0.71 0.71 -10
1 0 -10
0.71 -0.71 -10
0 -1 -10
-0.71 -0.71 -10
-1 0 -10
-0.71 0.71 -10
0 2 -8
1.41 1.41 -8
2 0 -8
1.41 -1.41 -8
0 -2 -8
-1.41 -1.41 -8
-2 0 -8
-1.41 1.41 -8
0 2 -7
1.41 1.41 -7
2 0 -7
1.41 -1.41 -7
0 -2 -7
-1.41 -1.41 -7
-2 0 -7
-1.41 1.41 -7
0 2 8
1.41 1.41 8
2 0 8
1.41 -1.41 8
0 -2 8
-1.41 -1.41 8
-2 0 8
-1.41 1.41 8
0 2 13
1.41 1.41 13
2 0 13
1.41 -1.41 13
0 -2 13
-1.41 -1.41 13
-2 0 13
-1.41 1.41 13
0 2 14
1.41 1.41 14
2 0 14
1.41 -1.41 14
0 -2 14
-1.41 -1.41 14
-2 0 14
-1.41 1.41 14
0 4 10
4 0 10
0 -4 10
-4 0 10
0 4 14
4 0 14
0 -4 14
-4 0 14
95
1 2 3 20
1 3 4 21
1 4 5 22
1 5 6 23
1 6 7 22
1 7 8 21
1 8 9 20
2 10 11 21
2 3 11 21
3 11 12 22
3 4 12 22
4 12 13 23
4 5 13 23
5 13 14 24
5 6 14 24
6 14 15 24
6 7 15 24
7 15 16 23
7 8 16 23
8 16 17 22
8 9 17 22
9 17 10 21
9 2 10 21
10 18 19 4
10 11 19 4
11 19 20 4
11 12 20 4
12 20 21 4
12 13 21 4
13 21 22 4
13 14 22 4
14 22 23 4
14 15 23 4
15 23 24 4
15 16 24 4
16 24 25 4
16 17 25 4
17 25 18 4
17 10 18 4
18 26 27 21
18 19 27 21
19 27 28 22
19 20 28 22
20 28 29 23
20 21 29 23
21 29 30 24
21 22 30 24
22 30 31 24
22 23 31 24
23 31 32 23
23 24 32 23
24 32 33 22
24 25 33 22
25 33 26 21
25 18 26 21
26 34 35 22
26 27 35 22
27 35 36 23
27 28 36 23
28 36 37 24
28 29 37 24
29 37 38 25
29 30 38 25
30 38 39 25
30 31 39 25
31 39 40 24
31 32 40 24
32 40 41 23
32 33 41 23
33 41 34 22
33 26 34 22
34 42 43 4
34 35 43 4
35 43 44 4
35 36 44 4
36 44 45 4
36 37 45 4
37 45 46 4
37 38 46 4
38 46 47 4
38 39 47 4
39 47 48 4
39 40 48 4
40 48 49 4
40 41 49 4
41 49 42 4
41 34 42 4
26 50 54 15
26 54 42 20
28 51 55 15
28 55 44 20
30 52 56 15
30 56 46 20
32 53 57 15
32 57 48 20
 
You have a huge array, this means that all you probably have to do is to add '$DYNAMIC to the top of your program (Before DECLARE SUB zbuffer()) and start Qbasic with the /ah parameter.
 
I have tried that and it still does not work
 
I'm not sure if this makes a difference or not, but DECLARE SUBs usually come before all executable lines. Place
DIM SHARED c(360), s(360), xc, yc, zc
DIM SHARED b(4000) AS LONG
after
DECLARE SUB bcopy ()
DECLARE SUB BPSET (x&, y&, COLOUR%)
this might fix it.
 
Dim Shared is a declaration, not an executable statement.
Redim, on the other hand, is executable, also Dim X(Y) where you use a variable as the index... But if you use a Constant, it's a Declaration.

I think there is some switch you can set to use High memory... I forgot what it is... I think it was /AH (just confirmed)

If you are not starting up Qbasic with... QB /AH then you need to do so...

For more information on commandline options, see
Help>Contents>QB COMMAND LINE OPTIONS
(lower right corner)

A quick Run through of the common ones:

/Run yourcode.bas
Loads and runs your program

/L yourlib.qlb
Loads your Quick Library (if used by it self /L loads QB.QLB)

/h
High Res Display (80X50 instead of 80X25)

/AH
Allows dynamic arrays of records, fixed-length strings, and numeric data to be larger than 64K each.

/CMD string
Passes a string(s) to the Command$ function (must be last on line)
This is the function that enables you to set up your own command line commands for you program (when compiled)

Hope this helps!
Good luck,
-Josh

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
Take a look at my other posts. Notice that he IS declaring an array before the DECLARE SUB, when an array is declared, you said yorself it is a execution. Also he said he tried the /ah, I suggested that in my first post.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top