diff options
author | uruk | 2013-06-18 10:23:29 +0200 |
---|---|---|
committer | uruk | 2013-06-18 10:23:29 +0200 |
commit | 38bc20a0763f0f83ea3c0a94a68a1edea0d08514 (patch) | |
tree | 8d71d5d2dec96e83e2fcce7c5378e9f2da94130e /engines/avalanche/tripoop.cpp | |
parent | a3025b8dad7abfe845c57aee3703451c223fc2e6 (diff) | |
download | scummvm-rg350-38bc20a0763f0f83ea3c0a94a68a1edea0d08514.tar.gz scummvm-rg350-38bc20a0763f0f83ea3c0a94a68a1edea0d08514.tar.bz2 scummvm-rg350-38bc20a0763f0f83ea3c0a94a68a1edea0d08514.zip |
AVALANCHE: Use Artistic Style.
Diffstat (limited to 'engines/avalanche/tripoop.cpp')
-rw-r--r-- | engines/avalanche/tripoop.cpp | 498 |
1 files changed, 281 insertions, 217 deletions
diff --git a/engines/avalanche/tripoop.cpp b/engines/avalanche/tripoop.cpp index 0edd926628..2fe8f5f4cb 100644 --- a/engines/avalanche/tripoop.cpp +++ b/engines/avalanche/tripoop.cpp @@ -11,7 +11,7 @@ * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License @@ -39,280 +39,344 @@ const integer left = 3; const integer numtr = 1; /* current max no. of sprites */ struct adxtype { - varying_string<12> name; /* name of character */ - byte num; /* number of pictures */ - byte xl,yl; /* x & y lengths of pictures */ - byte seq; /* how many in one stride */ - word size; /* the size of one picture */ - byte fgc,bgc; /* foreground & background bubble colours */ + varying_string<12> name; /* name of character */ + byte num; /* number of pictures */ + byte xl, yl; /* x & y lengths of pictures */ + byte seq; /* how many in one stride */ + word size; /* the size of one picture */ + byte fgc, bgc; /* foreground & background bubble colours */ }; class triptype { public: - adxtype a; /* vital statistics */ - byte face,step; - integer x,y; /* current xy coords */ - integer ox,oy; /* last xy coords */ - integer tax,tay; /* "behind" taken at... */ - shortint ix,iy; /* amount to move sprite by, each step */ - matrix<1,24,0,1,pointer> pic; /* the pictures themselves */ - boolean quick,visible,homing; - pointer behind; /* what's behind you */ - integer hx,hy; /* homing x & y coords */ - - triptype* init(byte spritenum); /* loads & sets up the sprite */ - void original(); /* just sets Quick to false */ - void andexor(); /* drops sprite onto screen 1 */ - void turn(byte whichway); /* turns him round */ - void appear(integer wx,integer wy, byte wf); /* switches him on */ - void walk(); /* prepares for do_it, andexor, etc. */ - void do_it(); /* Actually copies the picture over */ - void getback(); /* gets background before sprite is drawn */ - void putback(); /* ...and wipes sprite from screen 1 */ - void walkto(integer xx,integer yy); /* home in on a point */ - void stophoming(); /* self-explanatory */ - void homestep(); /* calculates ix & iy for one homing step */ - void speed(shortint xx,shortint yy); /* sets ix & iy, non-homing, etc */ - void halt(); /* Stops the sprite from moving */ + adxtype a; /* vital statistics */ + byte face, step; + integer x, y; /* current xy coords */ + integer ox, oy; /* last xy coords */ + integer tax, tay; /* "behind" taken at... */ + shortint ix, iy; /* amount to move sprite by, each step */ + matrix<1, 24, 0, 1, pointer> pic; /* the pictures themselves */ + boolean quick, visible, homing; + pointer behind; /* what's behind you */ + integer hx, hy; /* homing x & y coords */ + + triptype *init(byte spritenum); /* loads & sets up the sprite */ + void original(); /* just sets Quick to false */ + void andexor(); /* drops sprite onto screen 1 */ + void turn(byte whichway); /* turns him round */ + void appear(integer wx, integer wy, byte wf); /* switches him on */ + void walk(); /* prepares for do_it, andexor, etc. */ + void do_it(); /* Actually copies the picture over */ + void getback(); /* gets background before sprite is drawn */ + void putback(); /* ...and wipes sprite from screen 1 */ + void walkto(integer xx, integer yy); /* home in on a point */ + void stophoming(); /* self-explanatory */ + void homestep(); /* calculates ix & iy for one homing step */ + void speed(shortint xx, shortint yy); /* sets ix & iy, non-homing, etc */ + void halt(); /* Stops the sprite from moving */ }; -integer gd,gm; -array<1,1,triptype> tr; +integer gd, gm; +array<1, 1, triptype> tr; -void copier(integer x1,integer y1,integer x2,integer y2,integer x3,integer y3,integer x4,integer y4); +void copier(integer x1, integer y1, integer x2, integer y2, integer x3, integer y3, integer x4, integer y4); -static boolean dropin(integer xc,integer yc,integer x1,integer y1,integer x2,integer y2) +static boolean dropin(integer xc, integer yc, integer x1, integer y1, integer x2, integer y2) /* Dropin returns True if the point xc,yc falls within the 1-2 rectangle. */ -{boolean dropin_result; -; - dropin_result=((xc>=x1) && (xc<=x2) && (yc>=y1) && (yc<=y2)); -return dropin_result; +{ + boolean dropin_result; + ; + dropin_result = ((xc >= x1) && (xc <= x2) && (yc >= y1) && (yc <= y2)); + return dropin_result; } -static void transfer(integer x1,integer y1,integer x2,integer y2) -{ - pointer p,q; word s; -; - s=imagesize(x1,y1,x2,y2); setfillstyle(1,0); - mark(q); getmem(p,s); - setactivepage(1); getimage(x1,y1,x2,y2,p); - setactivepage(0); putimage(x1,y1,p,copyput); - setactivepage(1); release(q); +static void transfer(integer x1, integer y1, integer x2, integer y2) { + pointer p, q; + word s; + ; + s = imagesize(x1, y1, x2, y2); + setfillstyle(1, 0); + mark(q); + getmem(p, s); + setactivepage(1); + getimage(x1, y1, x2, y2, p); + setactivepage(0); + putimage(x1, y1, p, copyput); + setactivepage(1); + release(q); } -static integer lesser(integer a,integer b) -{integer lesser_result; -; - if (a<b) lesser_result=a; else lesser_result=b; -return lesser_result; +static integer lesser(integer a, integer b) { + integer lesser_result; + ; + if (a < b) lesser_result = a; + else lesser_result = b; + return lesser_result; } -static integer greater(integer a,integer b) -{integer greater_result; -; - if (a>b) greater_result=a; else greater_result=b; -return greater_result; +static integer greater(integer a, integer b) { + integer greater_result; + ; + if (a > b) greater_result = a; + else greater_result = b; + return greater_result; } -void copier(integer x1,integer y1,integer x2,integer y2,integer x3,integer y3,integer x4,integer y4) - -{; - if (dropin(x3,y3,x1,y1,x2,y2) - || dropin(x3,y4,x1,y1,x2,y2) - || dropin(x4,y3,x1,y1,x2,y2) - || dropin(x4,y4,x1,y1,x2,y2)) - {; /* Overlaps */ - transfer(lesser(x1,x3),lesser(y1,y3),greater(x2,x4),greater(y2,y4)); - } else - {; /* Doesn't overlap- copy both of them seperately */ - transfer(x3,y3,x4,y4); /* backwards- why not...? */ - transfer(x1,y1,x2,y2); - } -} +void copier(integer x1, integer y1, integer x2, integer y2, integer x3, integer y3, integer x4, integer y4) -void setup() { - integer gd,gm; -; - gd=3; gm=0; initgraph(gd,gm,""); - for( gd=0; gd <= 1; gd ++) - {; - setactivepage(gd); - setfillstyle(9,1); bar(0,0,640,200); - } - for( gm=1; gm <= numtr; gm ++) tr[gm].original(); + ; + if (dropin(x3, y3, x1, y1, x2, y2) + || dropin(x3, y4, x1, y1, x2, y2) + || dropin(x4, y3, x1, y1, x2, y2) + || dropin(x4, y4, x1, y1, x2, y2)) { + ; /* Overlaps */ + transfer(lesser(x1, x3), lesser(y1, y3), greater(x2, x4), greater(y2, y4)); + } else { + ; /* Doesn't overlap- copy both of them seperately */ + transfer(x3, y3, x4, y4); /* backwards- why not...? */ + transfer(x1, y1, x2, y2); + } } -triptype* triptype::init(byte spritenum) -{ - integer gd,gm; word s; untyped_file f; varying_string<2> xx; pointer p,q; word bigsize; - byte sort,n; -; - str(spritenum,xx); assign(f,string("v:sprite")+xx+".avd"); - reset(f,1); seek(f,59); - blockread(f,a,sizeof(a)); blockread(f,bigsize,2); - setvisualpage(3); setactivepage(3); - for( sort=0; sort <= 1; sort ++) - {; - mark(q); getmem(p,bigsize); - blockread(f,p,bigsize); - putimage(0,0,p,0); release(q); n=1; - { adxtype& with = a; - for( gm=0; gm <= (with.num / with.seq)-1; gm ++) /* directions */ - for( gd=0; gd <= with.seq-1; gd ++) /* steps */ - {; - getmem(pic[n][sort],a.size); /* grab the memory */ - getimage((gm / 2)*(with.xl*6)+gd*with.xl,(gm % 2)*with.yl, - (gm / 2)*(with.xl*6)+gd*with.xl+with.xl-1,(gm % 2)*with.yl+with.yl-1, - pic[n][sort]); /* grab the pic */ - putimage((gm / 2)*(with.xl*6)+gd*with.xl,(gm % 2)*with.yl, - pic[n][sort],notput); /* test the pic */ - n += 1; - }} - } - close(f); setactivepage(0); setvisualpage(0); - x=0; y=0; quick=true; visible=false; getmem(behind,a.size); - homing=false; ix=0; iy=0; -return this; +void setup() { + integer gd, gm; + ; + gd = 3; + gm = 0; + initgraph(gd, gm, ""); + for (gd = 0; gd <= 1; gd ++) { + ; + setactivepage(gd); + setfillstyle(9, 1); + bar(0, 0, 640, 200); + } + for (gm = 1; gm <= numtr; gm ++) tr[gm].original(); } -void triptype::original() -{; - quick=false; +triptype *triptype::init(byte spritenum) { + integer gd, gm; + word s; + untyped_file f; + varying_string<2> xx; + pointer p, q; + word bigsize; + byte sort, n; + ; + str(spritenum, xx); + assign(f, string("v:sprite") + xx + ".avd"); + reset(f, 1); + seek(f, 59); + blockread(f, a, sizeof(a)); + blockread(f, bigsize, 2); + setvisualpage(3); + setactivepage(3); + for (sort = 0; sort <= 1; sort ++) { + ; + mark(q); + getmem(p, bigsize); + blockread(f, p, bigsize); + putimage(0, 0, p, 0); + release(q); + n = 1; + { + adxtype &with = a; + for (gm = 0; gm <= (with.num / with.seq) - 1; gm ++) /* directions */ + for (gd = 0; gd <= with.seq - 1; gd ++) { /* steps */ + ; + getmem(pic[n][sort], a.size); /* grab the memory */ + getimage((gm / 2) * (with.xl * 6) + gd * with.xl, (gm % 2)*with.yl, + (gm / 2) * (with.xl * 6) + gd * with.xl + with.xl - 1, (gm % 2)*with.yl + with.yl - 1, + pic[n][sort]); /* grab the pic */ + putimage((gm / 2) * (with.xl * 6) + gd * with.xl, (gm % 2)*with.yl, + pic[n][sort], notput); /* test the pic */ + n += 1; + } + } + } + close(f); + setactivepage(0); + setvisualpage(0); + x = 0; + y = 0; + quick = true; + visible = false; + getmem(behind, a.size); + homing = false; + ix = 0; + iy = 0; + return this; } -void triptype::getback() -{; - tax=x; tay=y; - getimage(x,y,x+a.xl,y+a.yl,behind); +void triptype::original() { + ; + quick = false; } -void triptype::andexor() -{ - byte picnum; /* Picnum, Picnic, what ye heck */ -; - picnum=face*a.seq+step+1; - putimage(x,y,pic[picnum][0],andput); - putimage(x,y,pic[picnum][1],xorput); +void triptype::getback() { + ; + tax = x; + tay = y; + getimage(x, y, x + a.xl, y + a.yl, behind); } -void triptype::turn(byte whichway) -{; - face=whichway; step=0; +void triptype::andexor() { + byte picnum; /* Picnum, Picnic, what ye heck */ + ; + picnum = face * a.seq + step + 1; + putimage(x, y, pic[picnum][0], andput); + putimage(x, y, pic[picnum][1], xorput); } -void triptype::appear(integer wx,integer wy, byte wf) -{; - x=wx; y=wy; ox=wx; oy=wy; turn(wf); visible=true; +void triptype::turn(byte whichway) { + ; + face = whichway; + step = 0; } -void triptype::walk() -{; - ox=x; oy=y; - if (homing) homestep(); - x=x+ix; y=y+iy; - step += 1; if (step==a.seq) step=0; getback(); +void triptype::appear(integer wx, integer wy, byte wf) { + ; + x = wx; + y = wy; + ox = wx; + oy = wy; + turn(wf); + visible = true; } -void triptype::do_it() -{; - copier(ox,oy,ox+a.xl,oy+a.yl,x,y,x+a.xl,y+a.yl); +void triptype::walk() { + ; + ox = x; + oy = y; + if (homing) homestep(); + x = x + ix; + y = y + iy; + step += 1; + if (step == a.seq) step = 0; + getback(); } -void triptype::putback() -{; - putimage(tax,tay,behind,0); +void triptype::do_it() { + ; + copier(ox, oy, ox + a.xl, oy + a.yl, x, y, x + a.xl, y + a.yl); } -void triptype::walkto(integer xx,integer yy) -{; - speed(xx-x,yy-y); hx=xx; hy=yy; homing=true; +void triptype::putback() { + ; + putimage(tax, tay, behind, 0); } -void triptype::stophoming() -{; - homing=false; +void triptype::walkto(integer xx, integer yy) { + ; + speed(xx - x, yy - y); + hx = xx; + hy = yy; + homing = true; } -void triptype::homestep() -{ - integer temp; -; - if ((hx==x) && (hy==y)) - {; /* touching the target */ - homing=false; return; - } - ix=0; iy=0; - if (hy!=y) - {; - temp=hy-y; if (temp>4) iy=4; else if (temp<-4) iy=-4; else iy=temp; - } - if (hx!=x) - {; - temp=hx-x; if (temp>4) ix=4; else if (temp<-4) ix=-4; else ix=temp; - } +void triptype::stophoming() { + ; + homing = false; } -void triptype::speed(shortint xx,shortint yy) -{; - ix=xx; iy=yy; - if ((ix==0) && (iy==0)) return; /* no movement */ - if (ix==0) - {; /* No horz movement */ - if (iy<0) turn(up); else turn(down); - } else - {; - if (ix<0) turn(left); else turn(right); - } +void triptype::homestep() { + integer temp; + ; + if ((hx == x) && (hy == y)) { + ; /* touching the target */ + homing = false; + return; + } + ix = 0; + iy = 0; + if (hy != y) { + ; + temp = hy - y; + if (temp > 4) iy = 4; + else if (temp < -4) iy = -4; + else iy = temp; + } + if (hx != x) { + ; + temp = hx - x; + if (temp > 4) ix = 4; + else if (temp < -4) ix = -4; + else ix = temp; + } } -void triptype::halt() -{; - ix=0; iy=0; homing=false; +void triptype::speed(shortint xx, shortint yy) { + ; + ix = xx; + iy = yy; + if ((ix == 0) && (iy == 0)) return; /* no movement */ + if (ix == 0) { + ; /* No horz movement */ + if (iy < 0) turn(up); + else turn(down); + } else { + ; + if (ix < 0) turn(left); + else turn(right); + } } -void trip() -{ - byte fv; -; - for( fv=1; fv <= numtr; fv ++) - { - triptype& with = tr[fv]; - ; - walk(); - if (with.quick && with.visible) andexor(); - do_it(); - putback(); - } +void triptype::halt() { + ; + ix = 0; + iy = 0; + homing = false; +} + +void trip() { + byte fv; + ; + for (fv = 1; fv <= numtr; fv ++) { + triptype &with = tr[fv]; + ; + walk(); + if (with.quick && with.visible) andexor(); + do_it(); + putback(); + } } -int main(int argc, const char* argv[]) -{pio_initialize(argc, argv); -; - setup(); - { - triptype& with = tr[1]; - ; - init(1); - appear(600,100,left); - do { - /* - speed(-5,0); repeat trip until keypressed or (x= 0); - speed( 5,0); repeat trip until keypressed or (x=600); - */ - walkto( 10, 10); do { trip(); } while (!(keypressed() || ! with.homing)); - walkto( 70,150); do { trip(); } while (!(keypressed() || ! with.homing)); - walkto(600, 77); do { trip(); } while (!(keypressed() || ! with.homing)); - } while (!keypressed()); - } -return EXIT_SUCCESS; +int main(int argc, const char *argv[]) { + pio_initialize(argc, argv); + ; + setup(); + { + triptype &with = tr[1]; + ; + init(1); + appear(600, 100, left); + do { + /* + speed(-5,0); repeat trip until keypressed or (x= 0); + speed( 5,0); repeat trip until keypressed or (x=600); + */ + walkto(10, 10); + do { + trip(); + } while (!(keypressed() || ! with.homing)); + walkto(70, 150); + do { + trip(); + } while (!(keypressed() || ! with.homing)); + walkto(600, 77); + do { + trip(); + } while (!(keypressed() || ! with.homing)); + } while (!keypressed()); + } + return EXIT_SUCCESS; } } // End of namespace Avalanche.
\ No newline at end of file |