Board index » delphi » Starwars Style Text Scroller

Starwars Style Text Scroller

Ok... I have seen this done many times, and I have source code all
over my HD for this type of scroll, but there is still one problem.  I
still cannot figure out exactly how to code this myself.

So if anyone could explain the theory behind the scroll...  Please
drop me a line...

Latez...

             _..-'(N0SFeratu Dem0 Gr0up 96)`-.._
          ./'. '||\\.       (\_/)       .//||` .`\.
       ./'.|'.'||||\\|..    )O O(    ..|//||||`.`|.`\.
    ./'..|'.|| |||||\`````` '`"'``''''''/||||| ||.`|..`\.
  ./'.||'.|||| ||||||||||||.     .|||||||||||| |||||.`||.`\.
 /'|||'.|||||| ||||||||||||{     }|||||||||||| ||||||.`|||`\
 '.|||'.||||||| ||||||||||||{     }|||||||||||| |||||||.`|||.`
'.||| ||||||||| |/'   ``\||``     ''||/''   `\| ||||||||| |||.`
|/' \./'     `\./         \!|\   /|!/         \./'     `\./ `\|
V    V         V          }' `\ /' `{          V         V    V
`    `         `               V               '         '    '

 

Re:Starwars Style Text Scroller


Re:Starwars Style Text Scroller


I need some help with reading/writing an array.  I have a text file,
let's call TEXT.TXT, containing strings of text, similar to below:
###################
#.........#....%%.#
#.....#......#....#
###################
(you don't need to know what it means).  I want to read in that text
into an array.  I knoow how to open files and read/write to them,
that's not a problem.  What I need help with is HOW to write to the
array.  I want each character in the text file to have its own array
entry.  I'll clear that up: The above text file is 19X4 chars.  If I
have an array[1..19,1..4] I want the char from row 1 column1 to be in
array[1,1], row 2 column 1 in array[2,1], row 3 column1 in array[3,1],
etc.  Maybe its not the most efficient way, but for now that's how I'd
like to do it.  I tried creating several FOR loops, such as:
for i:=1 to 4 do
    for j:=1 to 19 do
        read(Textfile, array[j,i];
But it doesn't work.  The way I tested to see if the above worked was
by trying to print the entire array to  the screen and see if what was
there resembled the text file. I used the same code as above to do this
(of course I used write() instead of read()).  The only thing I saw on
the screen was the top line of #####'s.  Help!
Thanks for taking the time to read this.

Jeff W.

Re:Starwars Style Text Scroller


Re:Starwars Style Text Scroller


I don't know whether to write a function or do a procedure.  I wrote
somme code in asm/turbo pascal to initialize the mouse and return the #
of buttons.  I want to either return, or somehow modify a variable that
the users pases, but I can't do it.  Functions only let you return 1
value, and when the user pases a variable name to a procedure, the
procedure just uses the value, not the actual name.  I remember
something about using pointers, but I don't know how I'd do this.
Here's an example of a function/procedure:
procedure ReturnMoreThan1Value(var1, var2 : integer);
begin
    var1:=newvalue;
    var2:=newvalue;
end;
actually, would thta work, if var1 and var2 were declared global?  And
one last question.  It's about inline assembly in tp7:
I want to call interrupt 33, function 0.  I wrote the following:

asm
    mov ax,0
    int 33
end
first of all, would that work?  If not, how do I make it work?  And,
the above function returns AX=0000 or AX=FFFF, and BX=an integer.  How
would I assign those values to variables?  Would I do something like:
asm
    mov var1, ax
    mov var2, bx
end;
WOuld that actually work, or is there a problem because FFFF doesn't
seem to be an integer to me.  Once again, thanks for your pacience and
your time.

        Jeff W.

P.S. if there is somewhere I can just ftp/www/telnet/etc. to, to get
the info and save you the trouble of writing back, let me know.
Thanks.

Re:Starwars Style Text Scroller


Re:Starwars Style Text Scroller


PS>I need some help with reading/writing an array.  I have a text file,
PS>let's call TEXT.TXT, containing strings of text, similar to below:
PS>###################
PS>#.........#....%%.#
PS>#.....#......#....#
PS>###################
PS>(you don't need to know what it means).  I want to read in that text
PS>into an array.  I knoow how to open files and read/write to them,
PS>that's not a problem.  What I need help with is HOW to write to the
PS>array.  I want each character in the text file to have its own array
PS>entry.  I'll clear that up: The above text file is 19X4 chars.  If I
PS>have an array[1..19,1..4] I want the char from row 1 column1 to be in
PS>array[1,1], row 2 column 1 in array[2,1], row 3 column1 in array[3,1],
PS>etc.  Maybe its not the most efficient way, but for now that's how I'd
PS>like to do it.  I tried creating several FOR loops, such as:
PS>for i:=1 to 4 do
PS>    for j:=1 to 19 do
PS>        read(Textfile, array[j,i];
PS>But it doesn't work.  The way I tested to see if the above worked was
PS>by trying to print the entire array to  the screen and see if what was
PS>there resembled the text file. I used the same code as above to do this
PS>(of course I used write() instead of read()).  The only thing I saw on
PS>the screen was the top line of #####'s.  Help!
PS>Thanks for taking the time to read this.

PS>Jeff W.

I'm having a little bit of trouble understanding your exact problem
without seeing the actual code you're using, but I would suspect that
the problem lies in the way you imagine the data gets writte to the
file (and the screen). You need to watch for the last (19th) element of
each row of the array when writing it to file, and add a CR/LF after it.
The same thing goes with writing to the screen.

        -- Kim Forwood --

  /-=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=-\
  $           Kim Forwood  <kim.forw...@access.cn.camriv.bc.ca>          %
  %         For what purpose is life, if one cannot live freely?         $
  \-=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=-/

Re:Starwars Style Text Scroller


Re:Starwars Style Text Scroller


Quote
In article <4ke61a$...@dfw-ixnews5.ix.netcom.com> psilo...@ix.netcom.com(Jeff W. ) writes:
>I don't know whether to write a function or do a procedure.  I wrote
>somme code in asm/turbo pascal to initialize the mouse and return the #
>of buttons.  I want to either return, or somehow modify a variable that
>the users pases, but I can't do it.  Functions only let you return 1
>value, and when the user pases a variable name to a procedure, the
>procedure just uses the value, not the actual name.  I remember
>something about using pointers, but I don't know how I'd do this.
>Here's an example of a function/procedure:
>procedure ReturnMoreThan1Value(var1, var2 : integer);
>begin
>    var1:=newvalue;
>    var2:=newvalue;
>end;
>actually, would thta work, if var1 and var2 were declared global?

In this case, that would have no effect since var1 and var2 are value
parameters.  You can change them in your procedure, but the variables you
passed are no different.  Instead, you can declare it as:

procedure ReturnMoreThan1Value (var var1, var2 : integer);

{so on and so forth}

Quote
>And one last question.  It's about inline assembly in tp7:
>I want to call interrupt 33, function 0.  I wrote the following:
>asm
>    mov ax,0
>    int 33

         ^^

A word of caution:  Make sure you specify the base correctly.  What you're
calling here is the DOS (33=21h) end of program function.  Make sure you
specify either $33 (Pascal notation) or 33h (ASM notation).

Quote
>end

If it's a procedure, it doesn't do much good.  If it's a function, all it
will return is the value in AX.  What you want to do is probably:

procedure mouseinfo (var ax_val, bx_val : word); assembler;

asm
  mov   ax,0000h
  int   33h
  les   di,[ax_val]   {get address of first parameter}
  stosw               {store AX in variable}
  les   di,[bx_val]   {get address of second parameter}
  xchg  ax,bx
  stosw               {store BX in variable}
end;

Quote
>first of all, would that work?  If not, how do I make it work?  And,
>the above function returns AX=0000 or AX=FFFF, and BX=an integer.  How
>would I assign those values to variables?  Would I do something like:
>asm
>    mov var1, ax
>    mov var2, bx
>end;

Not quite that simple.  See above sample.

Quote
>WOuld that actually work, or is there a problem because FFFF doesn't
>seem to be an integer to me.  Once again, thanks for your pacience and
>your time.

Of course it's an integer.  Why wouldn't it be?  It's 16 bits.  It's just
not what you think it is.  It's -1 in decimal.  You might want to use word
instead of integer to reduce the confusion.

Quote
>        Jeff W.
>P.S. if there is somewhere I can just ftp/www/telnet/etc. to, to get
>the info and save you the trouble of writing back, let me know.
>Thanks.

You might want to look at http://www.gdsoft.com/swag/

--
Scott F. Earnest           | We now return you to our regularly scheduled
sc...@whiplash.res.cmu.edu | chaos and mayhem. . . .

Re:Starwars Style Text Scroller


Re:Starwars Style Text Scroller


On 9 Apr 1996, Jeff W. wrote:

Quote
> I need some help with reading/writing an array.  I have a text file,
> let's call TEXT.TXT, containing strings of text, similar to below:
> ###################
> #.........#....%%.#
> #.....#......#....#
> ###################
> (you don't need to know what it means).  I want to read in that text
> into an array.  I knoow how to open files and read/write to them,
> that's not a problem.  What I need help with is HOW to write to the
> array.  I want each character in the text file to have its own array
> entry.  I'll clear that up: The above text file is 19X4 chars.  If I
> have an array[1..19,1..4] I want the char from row 1 column1 to be in
> array[1,1], row 2 column 1 in array[2,1], row 3 column1 in array[3,1],
> etc.  Maybe its not the most efficient way, but for now that's how I'd
> like to do it.  I tried creating several FOR loops, such as:
> for i:=1 to 4 do
>     for j:=1 to 19 do
>         read(Textfile, array[j,i];
> But it doesn't work.  The way I tested to see if the above worked was
> by trying to print the entire array to  the screen and see if what was
> there resembled the text file. I used the same code as above to do this
> (of course I used write() instead of read()).  The only thing I saw on
> the screen was the top line of #####'s.  Help!
> Thanks for taking the time to read this.

> Jeff W.

   I'm not sure if this will help you, but it can't hurt to try.  The
problem might be that the first line of text has spaces or such after the
last '#'.  Try this:

   for i := 1 to 4 do
      begin
         for j := 1 to 19 do
            read(Textfile,array[j,i]);
         readln(Textfile);
      end;

Hope this helps...

Re:Starwars Style Text Scroller


Re:Starwars Style Text Scroller


On 9 Apr 1996, Jeff W. wrote:

Quote
> I don't know whether to write a function or do a procedure.  I wrote
> somme code in asm/turbo pascal to initialize the mouse and return the #
> of buttons.  I want to either return, or somehow modify a variable that
> the users pases, but I can't do it.  Functions only let you return 1
> value, and when the user pases a variable name to a procedure, the
> procedure just uses the value, not the actual name.  I remember
> something about using pointers, but I don't know how I'd do this.
> Here's an example of a function/procedure:
> procedure ReturnMoreThan1Value(var1, var2 : integer);
> begin
>     var1:=newvalue;
>     var2:=newvalue;
> end;

If you want to change the values of the parameters passed to a procedure,
declare the parameters as variable types.

Change   ReturnMoreThan1Value(var1, var2 : integer);
To       ReturnMoreThan1Value(var var1, var2 : integer);

Example:

   Procedure ReturnMoreThan1Value(var var1, var2 : integer);
      begin
         var1 := newvalue;
         var2 := newvalue;
      end;

Now, if you had two integer variables declared globally, say int1 and
int2, and you passed them using:

   ReturnMoreThan1Value(int1,int2);

The values of int1 and int2 would change to whatever var1 and var2 were
changed to in that procedure.

An alternative to this, if you want to use a function, is to create a type
of array of size 2.  Have have a variable array[1] contain the first value
and array[2] contain the second.  Then have the function return the whole
array.  Using the procedure would make more sense though.

Re:Starwars Style Text Scroller


Re:Starwars Style Text Scroller


Quote
psilo...@ix.netcom.com(Jeff W. ) wrote:
>I need some help with reading/writing an array.  I have a text file,
>let's call TEXT.TXT, containing strings of text, similar to below:
>###################
>#.........#....%%.#
>#.....#......#....#
>###################
>entry.  I'll clear that up: The above text file is 19X4 chars.  If I
>have an array[1..19,1..4] I want the char from row 1 column1 to be in
>array[1,1], row 2 column 1 in array[2,1], row 3 column1 in array[3,1],
>etc.  Maybe its not the most efficient way, but for now that's how I'd
>like to do it.  I tried creating several FOR loops, such as:
>for i:=1 to 4 do
>    for j:=1 to 19 do
>        read(Textfile, array[j,i];

ok, forgive me, since I'm not at the TPx IDE right now..
But your problem is being caused by your attempt to read element
by element from a line of text.  It could be done, but that is not
the way.

If you MUST maintain the 'map' in that format, then try something like
this:
FOR Outer_Loop := 1 TO 4 DO
BEGIN
     READLN( TextFile, Line );
     FOR Inner_Loop := 1 TO Length( Line ) DO
     Array[ Inner_Loop, Outer_Loop ] := Ord( Line[ Inner_Loop ] );
END; { end of the FOR Outer_Loop }

Line would be a STRING... might need to play with the Array[ Outer,
Inner ] or Array[ Inner, Outer ]... I normally breeze right through
them, but it's about 1:00 AM here and I'm off to bed... hope that
helps.

Cordially,
Tim Little...

Go to page: [1] [2] [3]

Other Threads