diff options
Diffstat (limited to 'engines/avalanche/qintro.cpp')
-rw-r--r-- | engines/avalanche/qintro.cpp | 379 |
1 files changed, 198 insertions, 181 deletions
diff --git a/engines/avalanche/qintro.cpp b/engines/avalanche/qintro.cpp index 22e6f3f1b8..0d15a9d7da 100644 --- a/engines/avalanche/qintro.cpp +++ b/engines/avalanche/qintro.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 @@ -31,7 +31,7 @@ namespace Avalanche { - /* This is a stand-alone program. */ +/* This is a stand-alone program. */ /* 0, black, remains 0. Other numbers: the bits take precedence from the left. @@ -44,15 +44,16 @@ namespace Avalanche { Second bit: 7 (light grey) First bit: 1 (blue). */ -const palettetype our_palette = - {16, - /* sic */ -{{ 0, 1, 57, 57, 7, 7, 7, 7, 63, 63, 63, 63, 63, 63, 63, 63}}}; +const palettetype our_palette = { + 16, + /* sic */ + {{ 0, 1, 57, 57, 7, 7, 7, 7, 63, 63, 63, 63, 63, 63, 63, 63}} +}; -typedef matrix<'\0','\377',1,16,byte> fonttype; +typedef matrix < '\0', '\377', 1, 16, byte > fonttype; fonttype f; -matrix<0,39,1,16,byte> next_line; +matrix<0, 39, 1, 16, byte> next_line; byte next_bitline; @@ -62,244 +63,260 @@ boolean cut_out; word cut_out_time; -array<1,117,varying_string<40> > x; +array<1, 117, varying_string<40> > x; byte this_line; -word* skellern; +word *skellern; /*$L intro.obj*/ -extern void introduction(); +extern void introduction(); -void graphmode(integer mode) -{ - registers regs; +void graphmode(integer mode) { + registers regs; - regs.ax=mode; - intr(0x10,regs); + regs.ax = mode; + intr(0x10, regs); } /* Firstly, port[$3C4]:=2; port[$3CF]:=4;, Then port[$3C5]:=1 shl bit; port[$3CF]:=bit;. */ -void loadfont() -{ - file<fonttype> ff; +void loadfont() { + file<fonttype> ff; - assign(ff,"avalot.fnt"); - reset(ff); - ff >> f; - close(ff); + assign(ff, "avalot.fnt"); + reset(ff); + ff >> f; + close(ff); } void calc_next_line() - /* This proc sets up next_line. */ +/* This proc sets up next_line. */ { - string l; - byte fv,ff; - boolean oddlen; - byte start; - byte this_; - - fillchar(next_line,sizeof(next_line),'\0'); /* All blanks. */ - - if (this_line==117) - { - cut_out=true; - return; - } - - l=x[this_line]; - this_line += 1; - - start=(20-length(l) / 2)-1; - oddlen=odd(length(l)); - - for( fv=1; fv <= length(l); fv ++) - for( ff=1; ff <= 16; ff ++) - { - this_=f[l[fv]][ff]; - if (oddlen) - { /* Odd, => 4 bits shift to the right. */ - next_line[start+fv][ff] += this_ << 4; - next_line[start+fv-1][ff] += (cardinal)this_ >> 4; - } else - { /* Even, => no bit shift. */ - next_line[start+fv][ff]=this_; - } - } - next_bitline=1; + string l; + byte fv, ff; + boolean oddlen; + byte start; + byte this_; + + fillchar(next_line, sizeof(next_line), '\0'); /* All blanks. */ + + if (this_line == 117) { + cut_out = true; + return; + } + + l = x[this_line]; + this_line += 1; + + start = (20 - length(l) / 2) - 1; + oddlen = odd(length(l)); + + for (fv = 1; fv <= length(l); fv ++) + for (ff = 1; ff <= 16; ff ++) { + this_ = f[l[fv]][ff]; + if (oddlen) { + /* Odd, => 4 bits shift to the right. */ + next_line[start + fv][ff] += this_ << 4; + next_line[start + fv - 1][ff] += (cardinal)this_ >> 4; + } else { + /* Even, => no bit shift. */ + next_line[start + fv][ff] = this_; + } + } + next_bitline = 1; } -void display() -{ - byte fv,ff; +void display() { + byte fv, ff; - if (next_bitline == 17) calc_next_line(); + if (next_bitline == 17) calc_next_line(); - if (cut_out) - { - cut_out_time -= 1; - return; - } + if (cut_out) { + cut_out_time -= 1; + return; + } - move(mem[0xa000*40],mem[0xa000*0],7960); - for( fv=0; fv <= 39; fv ++) - mem[0xa1f1*8+fv]=next_line[fv][next_bitline]; - next_bitline += 1; + move(mem[0xa000 * 40], mem[0xa000 * 0], 7960); + for (fv = 0; fv <= 39; fv ++) + mem[0xa1f1 * 8 + fv] = next_line[fv][next_bitline]; + next_bitline += 1; } -void plot_a_star(integer x,integer y) -{ - byte ofs; +void plot_a_star(integer x, integer y) { + byte ofs; - ofs=x % 8; - x=x / 8; - mem[0xa000*x+y*40] += (cardinal)128 >> ofs; + ofs = x % 8; + x = x / 8; + mem[0xa000 * x + y * 40] += (cardinal)128 >> ofs; } -void plot_some_stars(integer y) -{ - byte fv,times; - - switch (Random(7)) { - case 1: times=1; break; - case 2: times=2; break; - case 3: times=3; break; - default: return; - } - - for( fv=1; fv <= times; fv ++) - plot_a_star(Random(320),y); +void plot_some_stars(integer y) { + byte fv, times; + + switch (Random(7)) { + case 1: + times = 1; + break; + case 2: + times = 2; + break; + case 3: + times = 3; + break; + default: + return; + } + + for (fv = 1; fv <= times; fv ++) + plot_a_star(Random(320), y); } -void starry_starry_night() -{ - integer y; - byte bit; - - port[0x3c4]=2; port[0x3ce]=4; port[0x3c5]=1 << bit; port[0x3cf]=bit; - - for( bit=0; bit <= 2; bit ++) - { - port[0x3c5]=1 << bit; port[0x3cf]=bit; - for( y=1; y <= 200; y ++) - plot_some_stars(y); - } +void starry_starry_night() { + integer y; + byte bit; + + port[0x3c4] = 2; + port[0x3ce] = 4; + port[0x3c5] = 1 << bit; + port[0x3cf] = bit; + + for (bit = 0; bit <= 2; bit ++) { + port[0x3c5] = 1 << bit; + port[0x3cf] = bit; + for (y = 1; y <= 200; y ++) + plot_some_stars(y); + } } void setupgraphics() /* Fix this proc. This prog SHOULDN'T use the Graph unit. */ { - integer gd,gm; + integer gd, gm; - gd=3; gm=1; initgraph(gd,gm,""); + gd = 3; + gm = 1; + initgraph(gd, gm, ""); } -void shovestars() -{ - move(mem[0xa000*0],mem[0xa000*40],7960); - fillchar(mem[0xa000*0],40,'\0'); - plot_some_stars(0); +void shovestars() { + move(mem[0xa000 * 0], mem[0xa000 * 40], 7960); + fillchar(mem[0xa000 * 0], 40, '\0'); + plot_some_stars(0); } -void do_next_line() -{ - byte bit; - - port[0x3c4]=2; port[0x3ce]=4; - - for( bit=0; bit <= 3; bit ++) - { - port[0x3c5]=1 << bit; port[0x3cf]=bit; - - switch (bit) { - case 0: if ((displaycounter % 10)==0) shovestars(); break; - case 1: if ((displaycounter % 2)==0) shovestars(); break; - case 2: shovestars(); break; - case 3: display(); break; /* The text. */ - } - } - - if (displaycounter==40) displaycounter=0; +void do_next_line() { + byte bit; + + port[0x3c4] = 2; + port[0x3ce] = 4; + + for (bit = 0; bit <= 3; bit ++) { + port[0x3c5] = 1 << bit; + port[0x3cf] = bit; + + switch (bit) { + case 0: + if ((displaycounter % 10) == 0) shovestars(); + break; + case 1: + if ((displaycounter % 2) == 0) shovestars(); + break; + case 2: + shovestars(); + break; + case 3: + display(); + break; /* The text. */ + } + } + + if (displaycounter == 40) displaycounter = 0; } -void load_text() -{ - word fv; - char* c; - byte thisline; - - - c=addr(introduction()); - thisline=0; - fillchar(x,sizeof(x),'\0'); - - for( fv=1; fv <= 2456; fv ++) - { - switch (*c) { - case '\15': thisline += 1; break; - case '\12':/*nop*/; break; - default: x[thisline]=x[thisline]+*c; - } - - c += 1; - } +void load_text() { + word fv; + char *c; + byte thisline; + + + c = addr(introduction()); + thisline = 0; + fillchar(x, sizeof(x), '\0'); + + for (fv = 1; fv <= 2456; fv ++) { + switch (*c) { + case '\15': + thisline += 1; + break; + case '\12':/*nop*/ + ; + break; + default: + x[thisline] = x[thisline] + *c; + } + + c += 1; + } } -void check_params() -{ - word s,o; integer e; +void check_params() { + word s, o; + integer e; - if (paramstr(1)!="jsb") exit(0); - val(paramstr(2),s,e); if (e!=0) exit(0); - val(paramstr(3),o,e); if (e!=0) exit(0); - skellern=ptr(s,o+1); + if (paramstr(1) != "jsb") exit(0); + val(paramstr(2), s, e); + if (e != 0) exit(0); + val(paramstr(3), o, e); + if (e != 0) exit(0); + skellern = ptr(s, o + 1); } -int main(int argc, const char* argv[]) -{ +int main(int argc, const char *argv[]) { - pio_initialize(argc, argv); - check_params(); + pio_initialize(argc, argv); + check_params(); - setupgraphics(); + setupgraphics(); - randseed=177; checkbreak=false; + randseed = 177; + checkbreak = false; - load_text(); + load_text(); - this_line=1; + this_line = 1; - graphmode(0xd); - loadfont(); + graphmode(0xd); + loadfont(); - next_bitline=17; - displaycounter=0; + next_bitline = 17; + displaycounter = 0; - cut_out_time=333; + cut_out_time = 333; - setallpalette(our_palette); + setallpalette(our_palette); - starry_starry_night(); + starry_starry_night(); - while ((cut_out_time>0) && (! keypressed())) - { + while ((cut_out_time > 0) && (! keypressed())) { - *skellern=0; + *skellern = 0; - do_next_line(); + do_next_line(); - displaycounter += 1; + displaycounter += 1; - do {; } while (!(*skellern>0)); - } + do { + ; + } while (!(*skellern > 0)); + } - graphmode(3); - return EXIT_SUCCESS; + graphmode(3); + return EXIT_SUCCESS; } } // End of namespace Avalanche.
\ No newline at end of file |