Making Hugo Programs

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:smile: :sad: :eek: :shock: :cool: :-x :razz: :oops: :evil: :twisted: :wink: :idea: :arrow: :neutral: :mrgreen:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Making Hugo Programs

by Ice Cream Jonsey » Wed Dec 24, 2014 10:06 am

Posting this link as the download locations are included:

http://www.joltcountry.com/phpBB2/viewtopic.php?t=9511

by Roody_Yogurt » Sun Nov 30, 2014 9:55 am

Awesome, bruce!

by Ice Cream Jonsey » Fri Nov 28, 2014 12:19 am

It's the bees knees.

^_____________^

I just wrote Kent on the mud to seeing about getting this patched officially. I will test it on my Mac when I go to work next.

Thanks, man. You have saved an entire race of people with this.

by bruce » Wed Nov 26, 2014 7:16 pm

Does Kent read this forum?

Here are the patches. No idea if 256 bytes is really right for the buffer, or if we're really guaranteed that fname is null-terminated, but hey. You get what you pay for.

Code: Select all

--- hegcc.orig	2014-11-26 20:03:42.000000000 -0600
+++ hegcc.c	2014-11-26 20:11:15.000000000 -0600
@@ -162,7 +162,13 @@
         }
         else strcpy(fname,file);
 
-        if (strcmp(dir, "") && fname[0]=='/') strcpy(fname, fname+1);
+        if (strcmp(dir, "") && fname[0]=='/') {
+	  int i = 0;
+	  while(1) {
+	    fname[i]=fname[++i];
+	    if (fname[i] == '\0') break;
+	  }
+	}
 }

Code: Select all

--- hccomp.c.orig	2014-11-26 19:42:06.000000000 -0600
+++ hccomp.c	2014-11-26 19:53:39.000000000 -0600
@@ -317,6 +317,7 @@
 void CompilerMem(void)
 {
 	char e[64];
+	char buffer[256];
 
 	strcpy(e, "");

by bruce » Wed Nov 26, 2014 7:13 pm

Well, a little dicking around (Mavericks doesn't include gdb anymore, so I needed to switch compiler to clang and then run under lldb) shows where it's crashing:

Code: Select all

(lldb) bt
* thread #1: tid = 0x7e19f, 0x00007fff9034e286 libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007fff9034e286 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff9247542f libsystem_pthread.dylib`pthread_kill + 90
    frame #2: 0x00007fff8cb65b53 libsystem_c.dylib`abort + 129
    frame #3: 0x00007fff8cb65cca libsystem_c.dylib`abort_report_np + 181
    frame #4: 0x00007fff8cb8bdb0 libsystem_c.dylib`__chk_fail + 48
    frame #5: 0x00007fff8cb8bdc0 libsystem_c.dylib`__chk_fail_overlap + 16
    frame #6: 0x00007fff8cb8bde2 libsystem_c.dylib`__chk_overlap + 34
    frame #7: 0x00007fff8cb8c117 libsystem_c.dylib`__strcat_chk + 81
    frame #8: 0x0000000100016cf9 hc`CompilerMem + 217 at hccomp.c:332
    frame #9: 0x0000000100017766 hc`Pass1 + 422 at hcpass.c:91
    frame #10: 0x0000000100000dbb hc`main(argc=2, argv=0x00007fff5fbffb50) + 171 at hc.c:64
    frame #11: 0x00007fff8ca9f5c9 libdyld.dylib`start + 1
So then we go to hccomp.c:

Code: Select all

                        strcpy(buffer, word[1]);
                        strcat(buffer, word[2]);
                        strcat(buffer, word[3]);
                        word[1] = buffer;
                        words = 1;
It's that first strcat.

buffer is defined as extern char[] in hcheader.h.

There is no definition of buffer in hccomp.c.

So I guess it's getting implicitly initialized to some fixed size by strcpy? And then you're immediately appending to it, and the compiler is getting nervous?

So we simply declare buffer as char[256] at the top of CompilerMem.

Compilation now succeeds. And running the game in Hugor looks like it works. But still, let's see what else we find in the CLI tools.

Now he fails in the same way.

Code: Select all

    frame #7: 0x00007fff8cb8bfbf libsystem_c.dylib`__strcpy_chk + 64
    frame #8: 0x000000010001a8e1 he`hugo_splitpath(path=0x00007fff5fbffc48, drive=0x00007fff5fbff9f0, dir=0x00007fff5fbff8f0, fname=0x00007fff5fbff7f0, ext=0x00007fff5fbff6f0) + 849 at hegcc.c:165
....which is....

Code: Select all

        if (strcmp(dir, "") && fname[0]=='/') strcpy(fname, fname+1);
man strcpy tells us:

Code: Select all

     The source and destination strings should not overlap, as the behavior is undefined.
Apparently gcc on Linux lets you get away with that.

So let's replace that with a cheesy strcpy implementation instead.

Code: Select all

        if (strcmp(dir, "") && fname[0]=='/') {
          int i = 0;
          while(1) {
            fname[i]=fname[++i];
            if (fname[i] == '\0') break;
          }
        }
And now he also runs cyberganked.hex.

Moral of the story: string handling in C blows.

by Ice Cream Jonsey » Wed Nov 26, 2014 6:17 pm

Hmm. Bet it has something to do with the long file names in the WIP. Well, not long file names, but the subdirectories and filenames blew up the Unix version 'fore I fixed it.

Sent you an invitation to your f*s*f address. Through bitbucket. Thanks, man.

by bruce » Wed Nov 26, 2014 5:20 pm

So how about making with the source?

I can compile Colossal Cave and start it and play to releasing the bird at the snake (all on my Mac) and it seems to be fine.

by ICJ » Mon Nov 24, 2014 9:31 am

Hm, didn't see your note till just now. I actually hopped on my Mac, did a make and tried to compile Cyberganked.

I get this:

➜ cyberganked2 git:(master) ✗ ./hc cyberganked.hug
[1] 41939 abort ./hc cyberganked.hug

Just putting this here for now.

by bruce » Sun Nov 23, 2014 1:22 pm

Ice Cream Jonsey wrote:You grabbed the repo from here? http://hg.0branch.com/hugo-unix
Yep.
Can I send you credentials to download my WIP? If it compiles that and works then shit, I guess the fixes I put in for the Unix version would be good enough for the Mac version.
Sure.

by Ice Cream Jonsey » Sat Nov 22, 2014 11:11 pm

You grabbed the repo from here? http://hg.0branch.com/hugo-unix

I am under the impression that it wouldn't work on a Mac even though they are essentially running BSD now because it's just different enough to require specific Mac builds.

Oh wait, you ran a make. Maybe if I read your post all the way through they would make greater sense. Maybe I should do that for everyone.

Can I send you credentials to download my WIP? If it compiles that and works then shit, I guess the fixes I put in for the Unix version would be good enough for the Mac version.

by bruce » Sat Nov 22, 2014 10:36 pm

I just did an hg clone of the bitbucket source, and ran a make on OS X 10.10.

It seemed to run fine. A few warnings, but nothing too concerning. I don't have any Hugo source to test it on, but when I invoke the compiler and debugger they give me what look like appropriate startup banners:

Code: Select all

adam@i7-wired:~/Documents/src/hugo/hugo-unix$ ./hc
HUGO COMPILER v3.1.04 by Kent Tessman (c) 1995-2006
The General Coffee Company Film Productions
Unix port by Bill Lash

SYNTAX:   ./hc [options] sourcefile [objectfile[.HEX]]
OPTIONS&#58;  -<switches>  $<limit>  #<compiler>  @<directory>

SWITCHES&#58;
  -a  Abort on first error                -d  build .HDX Debuggable executable
  -f  Full object summaries               -h  generate .HLB precompiled Header
  -i  print debugging Information         -l  List compilation output to disk
  -o  display Object tree                 
  -s  display compilation Statistics      -t  Text to .LST for spellchecking
  -u  show memory Usage for objectfile    -v  Verbose compilation
  -w  Write objectfile despite errors     -x  override switches in source code

LIMIT SETTINGS&#58;  $<setting>=<new> &#40;or $list to view&#41;
DIRECTORIES&#58;     @<directory>=<actual> &#40;or @list to view&#41;

Relieved

by Erebor » Wed Nov 19, 2014 12:35 pm

Well thanks, man. And to all for replying. Especially Robb for posting that link. I'm just glad to know that I'm not insane, or such a hopeless backward newb that I'll never get anywhere.

I'll experiment with the new program, and let you know how it goes.

I actually have a couple of projects in mind that I think will look great in HUGO, that I want to do as practice.

Re: Hugo programming difficulties--(first attempt).

by Ice Cream Jonsey » Thu Nov 13, 2014 11:30 pm

Erebor wrote:The problem that I'm having seems to be that Terminal crashes immediately when I run the compiler. I've tried both double-clicking it, and running it from within Terminal, the usual way. In both cases, I end up with a "process completed" message, and a screen with which I can do nothing. This is Terminal's way of saying that the program has ended... the program which I just opened. All the menus seem to be in the right place, just inactive.

I'm not sure why this is happening.
Yeah, the Mac versions that are on the General Coffee site do not work. This ... this is tough. We were able to get a fix for Unix, but the Mac compiler is in no-man's land. :(

We did get it working for Unix. The repository is here:

http://hg.0branch.com/hugo-unix

Let me know if you can or cannot get that to work.

I realize that this is the most bullshit way to get introduced to a programming language. I get it. I had no access to a Mac, so I couldn't fix the Mac compiler (keeping in mind that, hey, I am primarily just a game-maker here, haha).

I hope that you can find a way to take this journey with us. I'm still making games in Hugo. I suspect I will be for a very long time. I do have a Mac laptop thanks to work, but that came with a price: I'm so busy at work that I haven't had time to research the specific Mac Hugo problem.

(And to confirm, the Unix compiler available through generalcoffee.com does not work - you need to grab the hc in that repo linked above.)

by Jizaboz » Tue Nov 11, 2014 8:27 am

Yeah, I wish there were a proper and pretty Hugo compiler for OSX. I end up uploading my work to a linux box to compile it, then pull it down.. which is a pain. I end up just firing up my crappy Toshiba to work on Hugo stuff.

by Roody_Yogurt » Mon Nov 10, 2014 11:47 pm

Unfortunately, yeah, the packages on the Hugo site don't work with the modern OSX and Unix OSs. ICJ and some others put together alternate packages but they have not yet been incorporated into the Hugo site. I don't have the link handy, but I'm sure ICJ will give the link as soon as he sees this thread.

Anyhow, will be happy to help out with any Hugo coding questions as soon as you get that far!

Hugo programming difficulties--(first attempt).

by Erebor » Mon Nov 10, 2014 5:13 pm

I'm not entirely sure where the appropriate place is to post this question/problem, but I'm choosing to do so here, rather than create a new topic.

Anyone is welcome to comment, but I'm specifically addressing this to Robb. I'm a Mac User, and I recently downloaded the Hugo Compiler for OS X, along with all the necessaries to get started programming for Hugo. The Hugo Book seems very straightforward and understandable. I'm well into the first two sections, and I wanted to get started playing around with the compiler. Bear in mind, that I have a basic familiarity with C++, and general computer science concepts, which I learned in college.

The problem that I'm having seems to be that Terminal crashes immediately when I run the compiler. I've tried both double-clicking it, and running it from within Terminal, the usual way. In both cases, I end up with a "process completed" message, and a screen with which I can do nothing. This is Terminal's way of saying that the program has ended... the program which I just opened. All the menus seem to be in the right place, just inactive.

I'm not sure why this is happening. I'm certain that the download from the Hugo site was perfectly suitable for Unix users in general, but there seems to be an assumption on the part of those who make these packages available that all Mac users are command line experts, which is not the case. The command line didn't even exist for us, prior to OSX. While that has been awhile, I've been a Mac user for several years (an embarrassingly long period of time), and I'm feeling like I'm having to learn about my computer all over again... being so unfamiliar with Terminal. One of my CS professors said that the GUI makes us all dependent and stupid. I suppose that's right. I like having a command line interface on my system... I'm excited about the potential for what it can accomplish. I'm just not that familiar with it. Nearly all my experience has been interacting with the system at the macro level, with the GUI. However, I don't believe I'm actually doing anything wrong here. My first impulse was to allocate more RAM for Terminal, to keep it from crashing-- which in this version of OS X, I'm no longer allowed to do.

Can someone give me some idea what's going on here? Once I get over this first hiccup, I think I can get on with my artistic endeavours... but I need something to experiment with, first.

Can we at least establish if the OSX download from the HUGO site definitely works on a system running OSX? I suspect that someone may have just given me some Unix files and hoped for the best.

by Roody_Yogurt » Fri Jan 25, 2013 10:15 am

You're welcome, hiddenheart! Sounds like one lucky class!

thanks!

by hiddenheart » Fri Jan 25, 2013 3:02 am

THANKS A LOT Roody_Yogurt for the help..

i can now report Basics of Hugo Programming Language to class...


Super Thanks!
:smile: :smile: :smile: :smile:

by Roody_Yogurt » Wed Jan 23, 2013 8:09 am

Variables have to be declared as global or local. Here is an example of declaring both:

Code: Select all

global variable_A = "red" ! start pointing to "red" 

routine SetThemVariables
&#123;
   local variable_B = 5 ! equals 5
   local variable_C, variable_D ! some local variables without starting values
   variable_A = "blue" ! now points to "blue"
   variable_B = 10 ! now equals 10

   print variable_A ! should print "blue"
   print number variable_B ! should print "10"
&#125;
Now, there are a couple different ways to get input. If you want people to type in full commands, you can use input/GetInput. GetInput is the same as input except it'll print a prompt, so:

Code: Select all

GetInput&#40;"type your answer>"&#41;
Will print "type your answer>" before expecting input from the player.

All understood words will be put into the word array; the first understood word will be put in word[1], the second understood word will be put in word[2], and so on. The first not-understood word will be put in the parse$ global variable, but all other not-understood words will be lost.

The good news is that any text your code checks for is automatically in the dictionary table and will be understood.

The other way to get input is to just use a while loop to do one-key inputs, where the player types just a letter (not full words). The simplest way to do that is:

Code: Select all


routine GetKey
&#123;
    local key
    pause ! pauses the game, waits for keypress
             ! &#40;the keypress gets sent to word&#91;0&#93;
    key = word&#91;0&#93;
    select key
        case 'a','A' &#58; "The player typed A."
        case 'b','B' &#58; "The player typed B."
        case else &#58; "And so on."
&#125;
Hope that helps! Cheer up, HH!

Declaring Variables

by hiddenheart » Wed Jan 23, 2013 4:06 am

Thanks... i Can now create output statement using hugo.. :smile:

but im wondering on how do we declare variables in hugo?...

for example in java we use:
String a="hidden";
int b=10;

then how would the code be for hugo?...

i also wonder how to get a user input in hugo...?
in other codes, we use "input.getText()"
how about in hugo?..

i already read the HUGO BOOK in pdf file and tried the codes there on how to declare variable..
just type:
x=0;

but an error occurs.. even in declaring strings..

is there any other way?..
or am i missing something?..

:sad: [/b]

Top