OpenCores
URL https://opencores.org/ocsvn/ion/ion/trunk

Subversion Repositories ion

[/] [ion/] [trunk/] [src/] [adventure/] [adv_baremetal.c] - Diff between revs 90 and 177

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 90 Rev 177
Line 34... Line 34...
/* pseudo-alloc: when called, will return a big chunk of memory. */
/* pseudo-alloc: when called, will return a big chunk of memory. */
/* we expect to be called just once, and there's no way to free the chunk. */
/* we expect to be called just once, and there's no way to free the chunk. */
void *alloc_mem(uint32_t num, uint32_t size){
void *alloc_mem(uint32_t num, uint32_t size){
    /* meant to be called only once */
    /* meant to be called only once */
    if(alloc_ptr>0){
    if(alloc_ptr>0){
        puts("alloc_mem called more than once!\n");
        printf("alloc_mem called more than once!\n");
    }
    }
    if(size > (HEAP_SIZE/4)){
    if(size > (HEAP_SIZE/4)){
        puts("Allocation error!\n");
        printf("Allocation error!\n");
    }
    }
    alloc_ptr++;
    alloc_ptr++;
    return (void *)allocatable_space;
    return (void *)allocatable_space;
}
}
 
 
void exit(uint32_t n){
void exit(uint32_t n){
    /*
    /*
    puts("Exit code ");
    printf("Exit code %d\n", n);
    print_num(n);
 
    puts("\n");
 
    */
    */
    while(1);
    while(1);
}
}
 
 
/* fake file open for adventure.txt */
/* fake file open for adventure.txt */
Line 118... Line 116...
}
}
 
 
/* Ask user if (s)he wants to use the auto-walk */
/* Ask user if (s)he wants to use the auto-walk */
void prompt_use_walkthrough(void){
void prompt_use_walkthrough(void){
    char buffer[32];
    char buffer[32];
    puts("Do you want to use the auto-walkthrough?\n");
    printf("Do you want to use the auto-walkthrough?\n");
 
 
    buffer[0] = '\0';
    buffer[0] = '\0';
    while(1){
    while(1){
        gets(buffer);
        gets(buffer);
        if(buffer[0]=='n' || buffer[0]=='N'){
        if(buffer[0]=='n' || buffer[0]=='N'){
Line 132... Line 130...
        else if(buffer[0]=='y' || buffer[0]=='Y'){
        else if(buffer[0]=='y' || buffer[0]=='Y'){
            use_walkthrough = 1;
            use_walkthrough = 1;
            break;
            break;
        }
        }
        else{
        else{
            puts("Please answer Y or N\n");
            printf("Please answer Y or N\n");
        }
        }
    }
    }
 
 
 
 
}
}
Line 155... Line 153...
    static uint32_t step = 0;
    static uint32_t step = 0;
    uint32_t i;
    uint32_t i;
 
 
    if(use_walkthrough){
    if(use_walkthrough){
        if(walkthrough[step][0] == '\0'){
        if(walkthrough[step][0] == '\0'){
            puts("<end of walkthrough, you're on your own>\n");
            printf("<end of walkthrough, you're on your own>\n");
            use_walkthrough = 0;
            use_walkthrough = 0;
        }
        }
        for(i=0;walkthrough[step][i]!='\0';i++){
        for(i=0;walkthrough[step][i]!='\0';i++){
            str[i] = walkthrough[step][i];
            str[i] = walkthrough[step][i];
        }
        }
        str[i] = '\0';
        str[i] = '\0';
        step++;
        step++;
        puts(str);
        printf(str);
        puts("\n");
        printf("\n");
        return str;
        return str;
    }
    }
    else{
    else{
        return gets(str);
        return gets(str);
    }
    }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.