Author Topic: Text scrolling with HuC  (Read 1279 times)

soop

  • Hero Member
  • *****
  • Posts: 2828
Text scrolling with HuC
« on: June 13, 2012, 12:44:59 AM »
Ok, I'd like to have some text appearing at the bottom of the screen, under graphics.

I figure the easiest way to do this would just be to decrease the x value and start from the right side of the screen to produce a ticker-style feed, like they have on news shows.

However, I'd also like to try a typewriter-style approach, where the text appears left-to-right one character at a time.

The only way I can think of to create the second approach (typewriter) is to create a large array with each character as a a variable, and display all the characters below [ul][li].  Not sure if that will even work, and it would be a fairly large array (4000 chars?)[/li][/ul]

And I'm not sure the first (ticker) approach would work either, because it would end up at x -988974894

_joshuaTurbo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 5160
Re: Text scrolling with HuC
« Reply #1 on: June 13, 2012, 01:34:34 AM »
Are you talking similar to like a sports ticker on the bottom of like sports games?  That's actually a great idea.  You could always make a string and call a function that you create.

Something like this:
void scroll (char *s, int x)
{
    // loops and leaves some space at the top/bottom border
    for (int i = 19; i >= 5; i--)
    {
        gotoxy (x,i); // move up one line
        cout << s; // output the string
        wait(1); // wait one second
        clrscr (); // clear the screen
    }
}

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: Text scrolling with HuC
« Reply #2 on: June 13, 2012, 02:44:47 AM »
For a scroll from the right side of the screen you are increasing the scroll value as well as the address to write the next character to.  Actually, a ticker and typewriter display both use the same concept: write a single character, increase the writing address and reading address by 1, wait a constant number of vblanks, and write the next character.  Thus you'll need 2 separate functions for setting up all these pointers, and for writing a single character.

For a ticker, you scroll the screen by a constant value, then write the next character after it's scrolled 8 pixels.  The screen writing address will need to be reset after the screen has scrolled the full width of the defined BAM (tilemap).

For a typewriter, there's no scrolling, but the writing address will need to be reset (plus a vertical offset) everytime you reach the end of the screen.

soop

  • Hero Member
  • *****
  • Posts: 2828
Re: Text scrolling with HuC
« Reply #3 on: June 13, 2012, 02:44:50 AM »
Close - but it's for my game idea TMNT - Trevor McDonalds Newsreading Tournament. It's a simple game; you have a certain time limit to read a news bulletin, which you do by bashing I and II as fast as you can, ala shooting watch.

So I was thinking either any time a button is pressed, x is decremented by 1 (ticker) or the arry is incremented by 1 (typewriter).

So it's basically your code, but instead of the wait, we'd have to increment by button presses.

Am I thinking cout is some equivilent to put_string?

soop

  • Hero Member
  • *****
  • Posts: 2828
Re: Text scrolling with HuC
« Reply #4 on: June 13, 2012, 03:31:44 AM »
For a scroll from the right side of the screen you are increasing the scroll value as well as the address to write the next character to.  Actually, a ticker and typewriter display both use the same concept: write a single character, increase the writing address and reading address by 1, wait a constant number of vblanks, and write the next character.  Thus you'll need 2 separate functions for setting up all these pointers, and for writing a single character.

For a ticker, you scroll the screen by a constant value, then write the next character after it's scrolled 8 pixels.  The screen writing address will need to be reset after the screen has scrolled the full width of the defined BAM (tilemap).

For a typewriter, there's no scrolling, but the writing address will need to be reset (plus a vertical offset) everytime you reach the end of the screen.

Oh sorry Chris, I didn't see that when I typed mine.  Ok, that makes sense.  So if I want to do the typewriter, do I put the text in an array of characters?

then I'll be like:
for $vertical_lines < x do {
  cout @line_$linenumber [1..$wordnumber];
  ++verticallines;
  if $verticallines=x then {
     verticallines=0;
     ++$linenumber;
  }
}

And then somewhere in there an interrupt to increase wordnumber if a buttonpress is detected every certasin number of vblanks

Sorry, I know that's not C, I don't know it well enough yet, but it should hopefully be clear enough?

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Text scrolling with HuC
« Reply #5 on: June 13, 2012, 03:54:13 AM »
This is all done very easily with HuC!  put_string() takes in an X and Y that is the tile offset you want to write at... 

3,2 for example would put a letter at 24,16 (each letter is 8x8, so 3 cells from the left is 24, 2 cells down is 16).

You can just write across the screen and increment the X by 1 until you reach screen capacity, and then just bump the Y down and start the whole process over.

The trickiest part in all honesty, will be getting it to happen with a nice frame delay between each letter that you write, so that it looks smooth.

Too fast = why even bother
Too slow = kill me now, this is taking forever to read!


You can store the entire chunk of text in question in an array, like you mentioned, and just step through it one character at a time and write them to screen.   Put some sort of line break delimiter in there (* or @ for example).   Any time you encounter that character in the array, kick the line down and continue onward.   It's really simple if you do it this way. 

If you have Insanity, put it in your system with a System Card 2 instead of 3.   Watch the CD Error screen.  (You can grab the demo from aetherbyte.com and do it in an emulator instead if you want).

Is this what you want to happen?  If so, it's pretty easy to set up.  If you have trouble with it, I can help out. 

I fiddled around and have it doing it in the Protocade light cycle game too.  That one plays sound too.  So it's all blerpy.
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

soop

  • Hero Member
  • *****
  • Posts: 2828
Re: Text scrolling with HuC
« Reply #6 on: June 13, 2012, 04:00:14 AM »
This is all done very easily with HuC!  put_string() takes in an X and Y that is the tile offset you want to write at... 

3,2 for example would put a letter at 24,16 (each letter is 8x8, so 3 cells from the left is 24, 2 cells down is 16).

You can just write across the screen and increment the X by 1 until you reach screen capacity, and then just bump the Y down and start the whole process over.

The trickiest part in all honesty, will be getting it to happen with a nice frame delay between each letter that you write, so that it looks smooth.

Too fast = why even bother
Too slow = kill me now, this is taking forever to read!


You can store the entire chunk of text in question in an array, like you mentioned, and just step through it one character at a time and write them to screen.   Put some sort of line break delimiter in there (* or @ for example).   Any time you encounter that character in the array, kick the line down and continue onward.   It's really simple if you do it this way. 

If you have Insanity, put it in your system with a System Card 2 instead of 3.   Watch the CD Error screen.  (You can grab the demo from aetherbyte.com and do it in an emulator instead if you want).

Is this what you want to happen?  If so, it's pretty easy to set up.  If you have trouble with it, I can help out. 

I fiddled around and have it doing it in the Protocade light cycle game too.  That one plays sound too.  So it's all blerpy.

Ok, will do - I'll have a mess about with it on the bus home too.  The lack of internet is actually a tad annoying, I was trying to find an unsecured hotspot whenever we hit traffic yesterday just to download a PC Engine emulator, and as soon as I'[d connect, we'd speed away from it.  So Yeah I'll download insanity and a few other bits when I get home.

spenoza

  • Hero Member
  • *****
  • Posts: 2751
Re: Text scrolling with HuC
« Reply #7 on: June 13, 2012, 04:05:38 AM »
I hope you won't download Insanity. It's Arkhan's game that he sells.
<a href="http://www.pcedaisakusen.net/2/34/103/show-collection.htm" class="bbc_link" target="_blank">My meager PC Engine Collection so far.</a><br><a href="https://www.pcenginefx.com/forums/" class="bbc_link" target="_blank">PC Engine Software Bible</a><br><a href="http://www.racketboy.com/forum/" c

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Text scrolling with HuC
« Reply #8 on: June 13, 2012, 04:05:47 AM »
Yeah.  All you need to do is set it to use system card 2 and try to play the game.   The error screen has typewriter text. 
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

soop

  • Hero Member
  • *****
  • Posts: 2828
Re: Text scrolling with HuC
« Reply #9 on: June 13, 2012, 04:34:57 AM »
Don't worry, if I end up playing it loads I'll donate some money :B  or give him a free copy of this game when I make it :D

Umm, this is my first crack, without a bunch of stuff (everyone's left work early to go and watch football, so I'm getting in some coding), but I've cobbled this together from a bunch of sources, so there's probably a load wrong with it;

Code: [Select]
#include "huc.h"
str ronaldo[203] = {R,o,n,a,l,d,o, ,h,a,s,n,',t, ,r,e,a,l,l,y, ,f,o,u,n,d, ,h,i,s,*,R,e,a,l, ,M,a,d,r,i,d, ,f,o,r,m, ,i,n, ,a, ,b,i,g, t,o,u,r,n,*,a,m,e,n,t, ,f,o,r, ,P,o,r,t,u,g,a,l, ,y,e,t, ,-, ,b,u,t, ,h,e,*,',s, ,o,n,l,y, ,o,n,e, ,g,o,a,l, ,a,w,a,y, ,f,r,o,m, ,m,o,v,i,*,n,g, ,a,h,e,a,d, ,o,f, ,L,u,i,s, ,F,i,g,o, ,i,n, ,t,h,e, ,a,l,*,l,-,t,i,m,e, P,o,r,t,u,g,u,e,s,e, ,l,e,a,d,i,n,g, ,g,o,a,l,s,*,c,o,r,e,r,s, ,l,i,s,t,};

int chars =0;
int x = 1;
int y = 19;
j2 = joytrg(0);

for (int i < 203)
{
if ( ronaldo[chars]=="*") { y++}
put_string (ronaldo[1..chars]; \\don't know if put_string will work?
if(j2 & JOY_B) {chars++} // if button II is pressed, add a character
clrscr ();
{

I think though that that one will keep going up forever, whereas I need to limit the text to about 2 lines at the bottom of the screen.

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Text scrolling with HuC
« Reply #10 on: June 13, 2012, 04:56:08 AM »
I hope you won't download Insanity. It's Arkhan's game that he sells.

Sometimes I wonder if you fully read everything in threads, dude.

Quote from: Arkhan
If you have Insanity, put it in your system with a System Card 2 instead of 3.   Watch the CD Error screen.  (You can grab the demo from aetherbyte.com and do it in an emulator instead if you want).



Anyway, soop,

you've got the right idea, but it's got some issues.

You need to use a while loop, not a for loop.   For loops require an initial value, an exit condition, and an increment condition:

for(i = 0; i < 203; i++)


Also, the way you have this setup, it will loop 203 times and stop.  If button 2 is never pressed, it will never show anything and it will exit.  Also,you clear the screen, so you're going to wipe out everything anyways... so you really won't ever see anything, lol.

You want a while loop:

Code: [Select]
while(i < 203)
{
  if(button 2 is pressed)
   {
       do the character printy stuff, including updating the current character pointer and all of that.  Be sure to update i, or you will never exit this loop!
   }
}

This is sloppy and needs done properly, but I think it gives you an idea of what I meant.
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

soop

  • Hero Member
  • *****
  • Posts: 2828
Re: Text scrolling with HuC
« Reply #11 on: June 13, 2012, 05:00:39 AM »
Gotcha.  This is gonna take me a while to get used to.

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Text scrolling with HuC
« Reply #12 on: June 13, 2012, 05:03:59 AM »
yeah you may want to work through some C programming tutorials first before you graduate to dealing with HuC and all of its quirks.
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.

spenoza

  • Hero Member
  • *****
  • Posts: 2751
Re: Text scrolling with HuC
« Reply #13 on: June 13, 2012, 06:03:28 AM »
*edited*

Not an appropriate line of conversation for this particular topic. Not interested in trolling the topic at hand.
« Last Edit: June 13, 2012, 07:04:08 AM by spenoza »
<a href="http://www.pcedaisakusen.net/2/34/103/show-collection.htm" class="bbc_link" target="_blank">My meager PC Engine Collection so far.</a><br><a href="https://www.pcenginefx.com/forums/" class="bbc_link" target="_blank">PC Engine Software Bible</a><br><a href="http://www.racketboy.com/forum/" c

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Text scrolling with HuC
« Reply #14 on: June 13, 2012, 06:05:56 AM »
No, I don't read every word. I read quickly, sometimes skimming, unless there appears to be some compelling reason for me to read fully. It's a forum, not a novel.

How will you know if there is a compelling reason to read fully, if you are skimming everything?

This is the internet equivalent of half-assedly listening to someone speak aloud.   It's kind of a bad idea.
[Fri 19:34]<nectarsis> been wanting to try that one for awhile now Ope
[Fri 19:33]<Opethian> l;ol huge dong

I'm a max level Forum Warrior.  I'm immortal.
If you're not ready to defend your claims, don't post em.