Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"Fbc has caused an error in FBC.EXE"
#11
Thanks Cha0s

Quote:1st off, i duno if you can read data from a sub. so if not youre dimming arrays "FROM 1 TO 0" could be ugly. =P

*facepalms* I completely forgot about that. You couldn't in QB. I modified inf2.bas by taking the READ statement out of the sub... that part works now (See two posts down for new file)

(p.s. I saw that and forgot to mention that some parts of the code are placeholders for use later. The file$ parameter in that sub is one, as maps will be eventually loaded from files, not data statements. Many of the data types are as well.)

Quote:its frustrating. i Highly recommend posting the entire code. its like maybe 2 pages worth, some people have posted over 1k lines. i would but i dunno if i should without your permission

It's coming in the next two posts.

--j_k
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply
#12
infantry.bas

Code:
CONST dataSource = "data\"
CONST bmpSource = "bmp\"

CONST ClassGI = 1
CONST ClassLight = 2
CONST ClassRocket = 3
CONST ClassMortar = 4
CONST ClassDoctor = 5
CONST ClassSpy = 6

CONST WeaponBullet = 1
CONST WeaponRocket = 2
CONST WeaponMortar = 3

CONST TileW = 32
CONST TileH = 32

CONST ObjW = 16
CONST ObjH = 16

CONST NumUnits = 6
CONST NumArmies = 2
CONST NumSoldiers = 32

DECLARE SUB bmpLoad (file$, array() as INTEGER)
DECLARE SUB bmpGetTile (arrayIn() as INTEGER, r as INTEGER, c as INTEGER, arrayOut() as INTEGER, w as INTEGER, h as INTEGER)
DECLARE SUB mapLoad (file$)
DECLARE SUB mapDraw (tileW as INTEGER, tileH as INTEGER)

'DIM NumUnits as Integer, NumArmies as integer, NumSoldiers as integer
DIM shared MapW as integer, MapH as integer
DIM Shared XMin as integer, Ymin as integer

MapW = 16
MapH = 16

type vid
    xMin as integer
    yMin as integer
    xRes as integer
    yRes as integer
    GameXRes as integer
    GameYRes as integer
end type

type Weapon
    x as integer
    y as integer
    alt as integer
    Owner as integer
    Firepower as integer
end type

type object
    x as integer
    y as integer
    row as integer
    col as integer
    Label as string * 16
end type

type UnitClass
    Firepower as integer
    Armor as integer
    Hitpoints as integer
    ShootX as string * 8
    ShootY as string * 8
    BurstTime as integer
    WaitTime as integer
    Weapon as integer
    Stealth as integer
    Frames as integer       'Animation frames per direction. Usually 4 (3 to walk, 1 to fire)
end type

type Soldier
    Object as object
    Class as Integer
    Hitpoints as integer
    Army as integer
    Team as integer
    InFoxhole as integer
end type

type Army
    IDColor as integer
    SoldierGFX(NumUnits) as LONG
end Type

type Terrain
     Tile as long
     Overlay as long
     Walkable as integer
     InOrOutside as integer
end Type

DIM Units(NumUnits) as UnitClass
DIM Armies(NumArmies) as Army
DIM Soldiers(NumSoldiers) as Soldier
DIM shared vid as Vid

DIM SHARED Map(MapH, MapW) as integer
DIM SHARED MapOverlay(MapH, MapW) as integer

DIM TerrainTile(0 to (TileW * TileH) / 2) as integer
DIM ObjTile(0 to (ObjW * ObjH) / 2) as integer
DIM TerrainBitmap(1) as integer
DIM UnitsBitmap(1) as integer

SCREEN 15
vid.xRes = 400
vid.yRes = 300
vid.GameXRes = 400
vid.GameYRes = 300

CALL bmpLoad (dataSource + bmpSource + "terrain.bmp", TerrainBitmap())
CALL bmpLoad (dataSource + bmpSource + "units.bmp", UnitsBitmap())

mapDraw (TileW, TileH)
sleep


END


DATA 16, 16
'      1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1

SUB bmpLoad (file$, array() as INTEGER)
    ff = FREEFILE
    OPEN file$ for binary as #ff
    size = LOF(ff)
    CLOSE #ff
    REDIM array(size - 7)
    'print size
    BLOAD file$, VARPTR(array(0))
    'PUT (0,0), Array(0)
END SUB

SUB bmpGetTile (arrayIn(), r, c, arrayOut(), w, h)
    x = (c - 1) * (w + 1)
    y = (r - 1) * (h + 1)
    GET arrayIn, (x,y)-(x + w - 1, y + h - 1), arrayOut(0)
END SUB

SUB mapLoad (file$)
        Read MapW, MapH
        REDIM Map(1 to MapW, 1 to MapH)
        REDIM MapOverlay(1 to MapW, 1 to MapH)
        vid.xMin = 0
        vid.yMin = 0
        for r = 1 to MapH
            for c = 1 to MapW
                Read Map(r, c)
            next
        next
end sub

SUB mapDraw (tileW, tileH)
        'r1 = INT(vid.yMin / TileH) + 1
        'r2 = y1 + (vid.yRes / tileH)
        'c1 = INT(vid.xMin / TileW) + 1
        'c2 = x1 + (vid.xRes / TileW)
        'x = ((c1 * TileW) - TileW) - xMin
        'y = ((r1 * TileH) - TileH) - yMin
        for r = r1 to r2
            for c = c1 to c2
                'CALL bmpGetTile (TerrainBitmap(), 1, 1, TerrainTile(), 32, 32)
                'PUT (x,y), TerrainTile(0)
                x = x + 32
            next
            y = y + 32
        next
end sub
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply
#13
inf2.bas modified. This is different from the one found in the zip file. Some stupid errors have been fixed as well (typos, putting x1 instead of c1, etc).

Code:
CONST dataSource = "data\"
CONST bmpSource = "bmp\"

CONST ClassGI = 1
CONST ClassLight = 2
CONST ClassRocket = 3
CONST ClassMortar = 4
CONST ClassDoctor = 5
CONST ClassSpy = 6

CONST WeaponBullet = 1
CONST WeaponRocket = 2
CONST WeaponMortar = 3

CONST TileW = 32
CONST TileH = 32

CONST ObjW = 16
CONST ObjH = 16

CONST NumUnits = 6
CONST NumArmies = 2
CONST NumSoldiers = 32

DECLARE SUB bmpLoad (file$, array() as INTEGER)
DECLARE SUB bmpGetTile (arrayIn() as INTEGER, r as INTEGER, c as INTEGER, arrayOut() as INTEGER, w as INTEGER, h as INTEGER)
DECLARE SUB mapLoad (file$)
DECLARE SUB mapDraw ()

DIM shared MapW as integer, MapH as integer

MapW = 16
MapH = 16

type vid
    xMin as integer
    yMin as integer
    xRes as integer
    yRes as integer
    GameXRes as integer
    GameYRes as integer
end type

type Weapon
    x as integer
    y as integer
    alt as integer
    Owner as integer
    Firepower as integer
end type

type object
    x as integer
    y as integer
    row as integer
    col as integer
    Label as string * 16
end type

type UnitClass
    Firepower as integer
    Armor as integer
    Hitpoints as integer
    ShootX as string * 8
    ShootY as string * 8
    BurstTime as integer
    WaitTime as integer
    Weapon as integer
    Stealth as integer
    Frames as integer       'Animation frames per direction. Usually 4 (3 to walk, 1 to fire)
end type

type Soldier
    Object as object
    Class as Integer
    Hitpoints as integer
    Army as integer
    Team as integer
    InFoxhole as integer
end type

type Army
    IDColor as integer
    SoldierGFX(NumUnits) as LONG
end Type

type Terrain
     Tile as long
     Overlay as long
     Walkable as integer
     InOrOutside as integer
end Type

DIM Units(NumUnits) as UnitClass
DIM Armies(NumArmies) as Army
DIM Soldiers(NumSoldiers) as Soldier
DIM SHARED vid as Vid

DIM SHARED Map(MapH, MapW) as integer
DIM SHARED MapOverlay(MapH, MapW) as integer

DIM SHARED TerrainTile(0 to (TileW * TileH) / 2) as integer
DIM SHARED ObjTile(0 to (ObjW * ObjH) / 2) as integer
DIM SHARED TerrainBitmap(0 to 1) as integer
DIM SHARED UnitsBitmap(0 to 1) as integer

SCREEN 14
vid.xMin = 0
vid.yMin = 0
vid.xRes = 320
vid.yRes = 240
vid.GameXRes = 320
vid.GameYRes = 480

bmpLoad (dataSource + bmpSource + "terrain.bmp", TerrainBitmap())
bmpGetTile (TerrainBitmap(), 1, 1, TerrainTile(), TileW, TileH)
PUT (0,0), TerrainTile(0), PSet

bmpLoad (dataSource + bmpSource + "units.bmp", UnitsBitmap())
bmpGetTile (UnitsBitmap(), 1, 1, ObjTile(), ObjW, ObjH)
PUT (0,0), ObjTile(0), PSet

Read MapW, MapH

REDIM Map(1 to MapW, 1 to MapH)
REDIM MapOverlay(1 to MapW, 1 to MapH)
vid.xMin = 0
vid.yMin = 0
for r = 1 to MapH
    for c = 1 to MapW
        Read Map(r, c)
    next
next
'mapLoad ("")

'mapDraw ()
sleep

END

DATA 16, 16
'      1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1
DATA   1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1


SUB bmpLoad (file$, array() as INTEGER)
    ff = FREEFILE
    OPEN file$ for binary as #ff
    size = LOF(ff)
    CLOSE #ff
    REDIM array(size - 7)
    'print size
    BLOAD file$, VARPTR(array(0))
    'PUT (0,0), Array(0)
END SUB

SUB bmpGetTile (arrayIn(), r, c, arrayOut(), w, h)
    x = (c - 1) * (w + 1)
    y = (r - 1) * (h + 1)
    GET arrayIn, (x,y)-(x + w - 1, y + h - 1), arrayOut(0)
END SUB

SUB mapLoad (file$)
    
end sub

SUB mapDraw ()

'        r1 = INT(vid.yMin / TileH) + 1
'       r2 = r1 + INT(vid.yRes / tileH)
'       c1 = INT(vid.xMin / TileW) + 1
'       c2 = c1 + INT(vid.xRes / TileW)
        'x = (c1 - 1) * TileW - vid.xMin
        'y = (r1 - 1) * TileH - vid.yMin
        for r = r1 to r2
            for c = c1 to c2
               ' bmpGetTile (TerrainBitmap(), 1, 1, TerrainTile(), 32, 32)
'               PUT (x,y), TerrainTile(0)
                x = x + 32
            next
            y = y + 32
        next
end sub
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply
#14
turn on option explicit, never code without it unless your prog is less than say 20 lines
quote="NecrosIhsan"]
[Image: yagl1.png]
[/quote]
Reply
#15
Quote:
SotSvart Wrote:I posted a link to this problem at freebasic.net, so v1c can look at it. FBC should'nt crash no mater what source code you compile..

well why dont you fire him. OH WAIT thats right, noones paying for anything so stop complaining that hes taking his free time to make YOU a compiler that turns YOUR qb progs into something blazing fast that windows can run natively

meh. Point is, he's working on it. Probably more than you've ever worked on any project. I dare you to dive into fbc source code and fix the problem.

No need to get angry.. I dident criticize v1c in any way, his doing a great job! And he sure is work alot more then me Heh

Tho no compiler should crash no mater what code you give it, it should report that your doing something wrong. So it was a bug, a bug that v1c now has fixed: http://www.freebasic.net/forum/viewtopic.php?t=265

edit: I dont think v1c minds getting bug reports, I would be glad to know of any bugs in my code..
Reply
#16
So it's fixed? quick. That's what I call service :lol:

Thanks for the tip, marzec. I had forgotten that option explicit had been added to fb (which is great, because debugging without it was downright infuriating at times).

thanks for all your help, guys Smile I'll try this and see if it works.

--j_k
size=9]"To announce that there must be no criticism of the president, or that we are to stand by the president, right or wrong, is not only unpatriotic and servile, but is morally treasonable to the American public." -- Theodore Roosevelt[/size]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)