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

spenoza

  • Hero Member
  • *****
  • Posts: 2751
Re: Text scrolling with HuC
« Reply #15 on: June 13, 2012, 06:31:23 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:03:45 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 #16 on: June 13, 2012, 06:40:50 AM »
Reading quickly is practically the same as skimming, dude.

Bottom line, you aren't reading what people say carefully.

If you are going to respond/post, it's your job to make sure you read what people say.

I mean, you can keep flying through posts if you want.  It just means you'll probably keep posting things that you wouldn't have, had you read everything.

 
[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 #17 on: June 13, 2012, 06:48:38 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:03:33 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 #18 on: June 13, 2012, 07:23:30 AM »
Anyway, back to on-topic:

http://www.cprogramming.com/tutorial.html

Check this out Soop, to give you the right frame of reference for programming in C.

There are differences between this tutorial and HuC, but they are very minor and have to do with function declarations and loop initializers.   We can get to that later.
[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 #19 on: June 13, 2012, 10:05:41 PM »
Anyway, back to on-topic:

http://www.cprogramming.com/tutorial.html

Check this out Soop, to give you the right frame of reference for programming in C.

There are differences between this tutorial and HuC, but they are very minor and have to do with function declarations and loop initializers.   We can get to that later.


Ah!  thanks Arkhan, I actually stumbled across one of those already.  I'll have a read through.  The compiler hated that last one, something wrong with the array.

Phew, slogging through them.  Not sure how much is going in, they're not as good as the HuC ones.  On number 7, just about to move to arrays
« Last Edit: June 14, 2012, 03:14:04 AM by soop »

soop

  • Hero Member
  • *****
  • Posts: 2828
Re: Text scrolling with HuC
« Reply #20 on: June 14, 2012, 04:10:47 AM »
No good.  Are there any other tutorials?  I feel like this guy is basically introducing me to concepts, giving me one example usage, and then moving on to other things.  I know how to do what I'm thinking in AWK, but I need something a little more in-depth about arrays and strings here.

I'll have a look, but if anyone knows anything...

*edit* don't worry, I remembered we have access to a load of online programming books.  O'Reilly to the rescue!
« Last Edit: June 14, 2012, 04:29:42 AM by soop »

spenoza

  • Hero Member
  • *****
  • Posts: 2751
Re: Text scrolling with HuC
« Reply #21 on: June 14, 2012, 04:30:15 AM »
This is one of those cases where code-sharing might be nice (your latest code, I mean, not what you already posted above). We could all look at your code and those with know-how can offer advice and those without can learn from the sharing experience.
« Last Edit: June 14, 2012, 04:42:33 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

soop

  • Hero Member
  • *****
  • Posts: 2828
Re: Text scrolling with HuC
« Reply #22 on: June 14, 2012, 05:21:04 AM »
Thanks Spenoza - here's what I have so far;

Code: [Select]
#include <iostream>
#include<stdio.h>
#include<conio.h>

using namespace std;

int main ()
{
int length(8);
while (length < 203)
{

char ronaldo[203] = "Germany are favourites to win the tournament following another impressive performance and their manager Joachim Loew believes victory over Denmark is important in their final match of the group.";
printf ("%.*s\n", length, ronaldo);
length++;
clrscr();
}
}

Clrscr doesn't seem to work in the C compiler I downloaded, but everything else does.  I'll have to try it on my netbook when I .. well, actually I'm gonna go out and get drunk tonight, so maybe Friday.

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Text scrolling with HuC
« Reply #23 on: June 14, 2012, 04:38:39 PM »
im on my vita so pardon my typos. 

first you shouldnt declare a variable in the while.    next you need to allocate memory for the string and use something like strcpy to copy it in.    look up tutorials on c-strings      check cplusplus.com!!!!
[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.

Sadler

  • Hero Member
  • *****
  • Posts: 1065
Re: Text scrolling with HuC
« Reply #24 on: June 14, 2012, 04:49:59 PM »
Just in terms of syntax, in addition to what Arkhan said you've got an interesting mix of C++ and C going on there. First, I'm pretty sure your string needs to be terminated with a '\0'. conio.h should include clrscr(), what's the error message you are receiving? You don't need to use the std namespace nor include iostream if you are using C style IO.

soop

  • Hero Member
  • *****
  • Posts: 2828
Re: Text scrolling with HuC
« Reply #25 on: June 14, 2012, 10:18:41 PM »
im on my vita so pardon my typos.  

first you shouldnt declare a variable in the while.    next you need to allocate memory for the string and use something like strcpy to copy it in.    look up tutorials on c-strings      check cplusplus.com!!!!

Shit, yeah I see the mistake with declaring the string in while.  In fact, what I need to do is declare a load of strings, and actually have a pointer in the while loop, so I can switch in different strings.

But allocating memory and using strcpy?  Arrgh, C, why must you make everything so difficult?  I know it's more tailored to it, but I could have done thin is seconds with AWK or Perl...

Sadler, I'm getting "error: 'clrscr' was not declared in this scope"

Sorry for the mix of C and C++, I only really want to learn HuC, but I'm going by C++ tutorials.  I just want to get the basics right now really, so hopefully it won't matter too much.

*edit* it looks like the terminating /0 is added automatically in the format I used.  The string length was slightly over, so I edited it to
Code: [Select]
while (ronaldo[length] != '\0')Which now ends bang on the end of the string, without me manually adding the /0 to the string.

*edit 2* now I'm having trouble with pointers...
Code: [Select]
#include <iostream>
#include<stdio.h>
#include<conio.h>

using namespace std;

int main ()
{
int length(0);
char (*currentstring)[500];
char sadler[500] = "Just in terms of syntax, in addition to what Arkhan said you've got an interesting mix of C++ and C going on there. First, I'm pretty sure your string needs to be terminated with a '\0'. conio.h should include clrscr(), what's the error message you are receiving? You don't need to use the std namespace nor include iostream if you are using C style IO.";
char ronaldo[203] = "Germany are favourites to win the tournament following another impressive performance and their manager Joachim Loew believes victory over Denmark is important in their final match of the group.";
currentstring = &sadler;
while (*currentstring[length] != '\0')
{
printf ("%.*s\n", length, *currentstring, 8, 13);
length++;
}
}

I've added a second string, and called to one of them with a pointer within the loop.  When I use th asterisk in front of the pointer (to call to the memory address of the string) it just prints the first character, J.  If I remove the asterisks, which should call the actual data, it loops endlessly.

*edit 3* fixed, just needed to put brackets around the currentstring pointer.  I must say, I'm enjoying this :)

*edit 4* Thinking about making a 2 dimensional array for each block of text, comprised of 32 character blocks, as a way to keep the text to 2 lines on screen.  It might be more elegant than asterisks every 32 characters.
« Last Edit: June 15, 2012, 01:07:25 AM by soop »

soop

  • Hero Member
  • *****
  • Posts: 2828
Re: Text scrolling with HuC
« Reply #26 on: June 15, 2012, 01:29:44 AM »
Well, I've done some looking, and it appears clrscr() is non-standard, and conio.h should be avoided.
Is this ... disdain of clrscr() inapplicable to HuC?  I'd imagine a games console is different to a system console with regard to system calls and how they're used.

Still, it's a bit annoying I can't get it to work in this compiler, but it's not the end of the world.

Dammit, it looks like HuC doesn't like the syntax of this other compiler.  I just tried slotting some stuff in, and it doesn't like the arrays (I focused on that rather than the pointers) and every time I try

Code: [Select]
char myarray[10];
or

Code: [Select]
char mayarray[10] "1234567890";
it says the variable isn't declared.  Any ideas?

according to the wiki on obeybrew, I can do this, which isn't very different;

Code: [Select]
const int paldata[] = { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0};
const int sprdata[] = { 1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 10010, 11011, 12012, 13013, 14014, 15015, 16016 };

maybe it's const, maybe it's just the curleys.
« Last Edit: June 15, 2012, 02:50:04 AM by soop »

Arkhan

  • Hero Member
  • *****
  • Posts: 14142
  • Fuck Elmer.
    • Incessant Negativity Software
Re: Text scrolling with HuC
« Reply #27 on: June 15, 2012, 07:33:54 AM »
still on my vita.    remember huc is just a compiler.   it uses small c style syntax.   

when i get home i got code for you.    maybe you can come on irc.   live help is easier
[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 #28 on: June 15, 2012, 01:38:37 PM »
Fanks Ark, time difference is a bit of a bastard, it's like 1:30 am here, and I gotta sleep :D  I got next week off though so it might be better to do it then?

Besides, it's train of thought, so I can probably solve it given time, but I def.  appreciate the backup.

cabbage

  • Sr. Member
  • ****
  • Posts: 342
Re: Text scrolling with HuC
« Reply #29 on: June 15, 2012, 03:51:31 PM »
I wrote a little demo for you soop. It shows a picture at the top and prints some text at the bottom of the screen one character at a time, kind of like an RPG might. It's definitely not an example of good programming, but I put a lot of comments to hopefully help you out with HuC. I know it confused the hell out of me as I first began using it...

Anyway, here's the .rar with everything: http://pce.lifeabroad.org/files/soop1.rar

I got a little carried away so the code is rather long to paste here, but I uploaded it as a text file here for quick reference...

hope it helps at least a bit