Changeset 5


Ignore:
Timestamp:
02/26/07 17:11:21 (6 years ago)
Author:
vitalyb
Message:
  • Label support for BASIC interpreter, eliminate line numbers.
  • s/shot/shoot/
Location:
trunk
Files:
3 added
1 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/THANKS

    r1 r5  
    44 
    55* Pablo dAngelo for 
    6     useful ideas and suggestion 
     6    useful ideas and suggestion, BASIC interpreter 
     7    extensions 
    78 
    89* Adam Dunkels for 
  • trunk/core/conf.c

    r1 r5  
    2828const char *ubasic_script_default = 
    2929#if 1 
    30     "1 sleep 1000\n" 
    31     "2 if a<1 then let a=2\n" 
    32     "3 if b<1 then let b=3\n" 
    33     "4 for s=1 to a\n" 
    34     "5 shot\n" 
    35     "6 for n=1 to b\n" 
    36     "7 click \"right\"\n" 
    37     "8 next n\n" 
    38     "9 next s\n" 
    39     "10 shot\n" 
    40     "11 end\n"; 
     30    "sleep 1000\n" 
     31    "if a<1 then let a=2\n" 
     32    "if b<1 then let b=3\n" 
     33    "for s=1 to a\n" 
     34    "shoot\n" 
     35    "for n=1 to b\n" 
     36    "click \"right\"\n" 
     37    "next n\n" 
     38    "next s\n" 
     39    "shoot\n" 
     40    "end\n"; 
    4141#else 
    42     "1 sleep 1000\n" 
    43     "2 if a<1 then let a=2\n" 
    44     "4 for s=1 to a\n" 
    45     "5 shot\n" 
    46     "7 set_tv_rel b\n" 
    47     "9 next s\n" 
    48     "10 shot\n" 
    49     "11 end\n"; 
     42    "sleep 1000\n" 
     43    "if a<1 then let a=2\n" 
     44    "for s=1 to a\n" 
     45    "shoot\n" 
     46    "set_tv_rel b\n" 
     47    "next s\n" 
     48    "shoot\n" 
     49    "end\n"; 
    5050#endif 
    5151 
  • trunk/core/gui.c

    r1 r5  
    210210 
    211211#ifdef HISTO 
    212     if (conf_show_histo && kbd_is_key_pressed(KEY_SHOT_HALF)){ 
     212    if (conf_show_histo && kbd_is_key_pressed(KEY_SHOOT_HALF)){ 
    213213        const int hx=219; 
    214214        const int hy=48; 
     
    460460    if (ubasic_error){ 
    461461        const char *msg; 
    462         switch (ubasic_error){ 
    463         case 1: 
    464             msg = "Parse err."; 
    465             break; 
    466         case 2: 
    467             msg = "Unk stmt"; 
    468             break; 
    469         case 3: 
    470             msg = "Unk key"; 
    471             break; 
    472         default: 
    473             msg = "Unk err"; 
    474         } 
    475         sprintf(osd_buf, "uBASIC:%d %s ", ubasic_line, msg); 
     462    if (ubasic_error >= UBASIC_E_ENDMARK) { 
     463        msg = ubasic_errstrings[UBASIC_E_UNKNOWN_ERROR]; 
     464    } else { 
     465            msg = ubasic_errstrings[ubasic_error]; 
     466        } 
     467        sprintf(osd_buf, "uBASIC:%d %s ", ubasic_linenumber(), msg); 
    476468        draw_txt_string(0, 0, osd_buf); 
    477469    } 
  • trunk/core/kbd.c

    r1 r5  
    1010#define SCRIPT_END      0 
    1111#define SCRIPT_CLICK    1 
    12 #define SCRIPT_SHOT     2 
     12#define SCRIPT_SHOOT    2 
    1313#define SCRIPT_SLEEP    3 
    1414#define SCRIPT_PRESS    4 
     
    5151} 
    5252 
    53 void kbd_sched_shot() 
     53void kbd_sched_shoot() 
    5454{ 
    5555// WARNING stack program flow is reversed 
     
    5959    KBD_STACK_PUSH(SCRIPT_WAIT_SAVE); 
    6060 
    61     KBD_STACK_PUSH(KEY_SHOT_FULL); 
     61    KBD_STACK_PUSH(KEY_SHOOT_FULL); 
    6262    KBD_STACK_PUSH(SCRIPT_RELEASE); 
    6363 
    6464    kbd_sched_delay(20); 
    6565 
    66     KBD_STACK_PUSH(KEY_SHOT_FULL); 
     66    KBD_STACK_PUSH(KEY_SHOOT_FULL); 
    6767    KBD_STACK_PUSH(SCRIPT_PRESS); 
    6868 
     
    152152} 
    153153 
    154 void ubasic_camera_shot() 
    155 { 
    156     kbd_sched_shot(); 
     154void ubasic_camera_shoot() 
     155{ 
     156    kbd_sched_shoot(); 
    157157} 
    158158 
     
    160160{ 
    161161/* Alternative keyboard mode stated/exited by pressing print key. 
    162  * While running Alt. mode shot key will start a script execution. 
     162 * While running Alt. mode shoot key will start a script execution. 
    163163 */ 
    164164 
     
    177177        } 
    178178 
    179         if (kbd_is_key_pressed(KEY_SHOT_FULL)){ 
     179        if (kbd_is_key_pressed(KEY_SHOOT_FULL)){ 
    180180            key_pressed = 1; 
    181181            if (!state_kbd_script_run){ 
     
    216216    { KEY_RIGHT, "right" }, 
    217217    { KEY_SET, "set" }, 
    218     { KEY_SHOT_HALF, "shot_half" }, 
    219     { KEY_SHOT_FULL, "shot_full" }, 
     218    { KEY_SHOOT_HALF, "shoot_half" }, 
     219    { KEY_SHOOT_FULL, "shoot_full" }, 
    220220    { KEY_ZOOM_IN, "zoom_in" }, 
    221221    { KEY_ZOOM_OUT, "zoom_out" }, 
  • trunk/include/keyboard.h

    r1 r5  
    77#define KEY_RIGHT       4 
    88#define KEY_SET         5 
    9 #define KEY_SHOT_HALF   6 
    10 #define KEY_SHOT_FULL   7 
     9#define KEY_SHOOT_HALF  6 
     10#define KEY_SHOOT_FULL  7 
    1111#define KEY_ZOOM_IN     8 
    1212#define KEY_ZOOM_OUT    9 
  • trunk/include/ubasic.h

    r1 r5  
    1 #ifndef UBASIC_H 
    2 #define UBASIC_H 
     1/* 
     2 * Copyright (c) 2006, Adam Dunkels 
     3 * All rights reserved. 
     4 * 
     5 * Redistribution and use in source and binary forms, with or without 
     6 * modification, are permitted provided that the following conditions 
     7 * are met: 
     8 * 1. Redistributions of source code must retain the above copyright 
     9 *    notice, this list of conditions and the following disclaimer. 
     10 * 2. Redistributions in binary form must reproduce the above copyright 
     11 *    notice, this list of conditions and the following disclaimer in the 
     12 *    documentation and/or other materials provided with the distribution. 
     13 * 3. Neither the name of the author nor the names of its contributors 
     14 *    may be used to endorse or promote products derived from this software 
     15 *    without specific prior written permission. 
     16 * 
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 
     18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
     19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
     20 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 
     21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
     22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
     23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
     24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
     25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
     26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
     27 * SUCH DAMAGE. 
     28 * 
     29 */ 
     30 
     31#ifndef __UBASIC_H__ 
     32#define __UBASIC_H__ 
     33 
     34enum ubasic_errors 
     35{ 
     36    UBASIC_E_NONE = 0, 
     37    UBASIC_E_PARSE, 
     38    UBASIC_E_UNK_STATEMENT, 
     39    UBASIC_E_UNK_KEY, 
     40    UBASIC_E_UNK_LABEL, 
     41    UBASIC_E_GOSUB_STACK_EXHAUSTED, 
     42    UBASIC_E_UNMATCHED_RETURN, 
     43    UBASIC_E_UNKNOWN_ERROR, 
     44    UBASIC_E_ENDMARK 
     45}; 
     46 
     47/** holds short error messages for all known ubasic_errors */ 
     48extern const char *ubasic_errstrings[UBASIC_E_ENDMARK]; 
    349 
    450extern int ubasic_error; 
    5 extern int ubasic_line; 
    651 
    752void ubasic_init(const char *program); 
    853void ubasic_run(void); 
    954int ubasic_finished(void); 
     55int ubasic_linenumber(); 
    1056 
    1157int ubasic_get_variable(int varnum); 
    1258void ubasic_set_variable(int varum, int value); 
    1359 
    14 #endif 
     60#endif /* __UBASIC_H__ */ 
  • trunk/lib/ubasic/Makefile

    r1 r5  
    88 
    99check: 
    10         gcc -DTEST -o test *.c 
     10        gcc -Wall -DTEST -o test *.c 
    1111 
    1212clean: 
  • trunk/lib/ubasic/README

    r1 r5  
    22http://www.sics.se/~adam/ubasic/ 
    33 
    4 functions stubs for camera control added by Pablo d'Angelo 
     4Pablo d'Angelo improved the parser to support labels and removed 
     5the line numbers. 
    56 
  • trunk/lib/ubasic/camera_functions.c

    r1 r5  
    11#ifdef TEST 
     2 
     3#include <stdio.h> 
     4 
    25void ubasic_camera_click(const char *s) 
    36{ 
     
    58} 
    69 
    7 void ubasic_camera_sleep(long v) 
     10void ubasic_camera_sleep(int v) 
    811{ 
    912    printf("***sleep %d***\n",v); 
    1013} 
    1114 
    12 void ubasic_camera_shot() 
     15void ubasic_camera_shoot() 
    1316{ 
    14     printf("***shot***\n"); 
     17    printf("***shoot***\n"); 
    1518} 
    1619 
    17 //##################################### 
    18 #if 0 
    19 const char *ub_script = 
    20     "10 sleep 3000\n" 
     20void shooting_set_tv(int v) 
     21{ 
     22    printf("***set tv %d***\n",v); 
     23} 
    2124 
    22     "20 shot\n" 
     25void shooting_set_tv_rel(int v) 
     26{ 
     27    printf("***set tv rel %d***\n",v); 
     28} 
    2329 
    24     "30 click \"right\"\n" 
    25     "40 click \"right\"\n" 
    26     "50 click \"right\"\n" 
     30void shooting_set_av(int v) 
     31{ 
     32    printf("***set av %d***\n",v); 
     33} 
    2734 
    28     "60 shot\n" 
     35void shooting_set_av_rel(int v) 
     36{ 
     37    printf("***set av rel %d***\n",v); 
     38} 
    2939 
    30     "70 click \"right\"\n" 
    31     "80 click \"right\"\n" 
    32     "90 click \"right\"\n" 
     40int shooting_get_tv() 
     41{ 
     42    return 0; 
     43} 
    3344 
    34     "100 shot\n" 
     45int shooting_get_av() 
     46{ 
     47    return 0; 
     48} 
    3549 
    36     "110 click \"right\"\n" 
    37     "120 click \"right\"\n" 
    38     "130 click \"right\"\n" 
    3950 
    40     "140 shot\n" 
    41  
    42     "500 end\n" 
    43     ; 
    44 #elif 0 
    45 const char *ub_script = 
    46     "10 sleep 1000\n" 
    47     "20 for s = 1 to 5\n" 
    48     "30 shot\n" 
    49     "40 for n = 1 to 3\n" 
    50     "50 click \"right\"\n" 
    51     "60 next n\n" 
    52     "70 next s\n" 
    53     "80 end\n" 
    54     ; 
    55 #else 
    56 const char *ub_script = 
    57     "10 sleep 1000\n" 
    58     "11 let a = 0\n" 
    59     "12 let b = 2\n" 
    60     "12 if a < 1 then let a = 3\n" 
    61     "20 for s = 1 to a\n" 
    62     "30 shot\n" 
    63     "40 for n = 1 to b\n" 
    64     "50 click \"right\"\n" 
    65     "60 next n\n" 
    66     "70 next s\n" 
    67     "80 end\n"; 
    6851#endif 
    69  
    70 int main() 
    71 { 
    72     ubasic_init(ub_script); 
    73     do { 
    74         ubasic_run(); 
    75     } while(!ubasic_finished()); 
    76  
    77 } 
    78 #endif 
  • trunk/lib/ubasic/camera_functions.h

    r1 r5  
    22void ubasic_camera_click(const char *s); 
    33void ubasic_camera_sleep(long v); 
    4 void ubasic_camera_shot(); 
     4void ubasic_camera_shoot(); 
    55 
  • trunk/lib/ubasic/tokenizer.c

    r1 r5  
    3232 
    3333#if DEBUG 
    34 #define DEBUG_PRINTF(...)  printf(__VA_ARGS__) 
     34#define DEBUG_PRINTF(...)  fprintf(stderr,__VA_ARGS__) 
    3535#else 
    3636#define DEBUG_PRINTF(...) 
     
    4949}; 
    5050 
    51 static int current_token = TOKENIZER_ERROR; 
     51static ubasic_token current_token = TOKENIZER_ERROR; 
     52static int current_line = 0; 
    5253 
    5354static const struct keyword_token keywords[] = { 
     
    6667 
    6768  {"click", TOKENIZER_CLICK}, 
    68   {"shot", TOKENIZER_SHOT}, 
     69  {"shot", TOKENIZER_SHOOT}, // for compatibility 
     70  {"shoot", TOKENIZER_SHOOT}, 
    6971  {"sleep", TOKENIZER_SLEEP},  
    7072 
     
    8789{ 
    8890  if(*ptr == '\n') { 
    89     return TOKENIZER_CR; 
    90   } else if(*ptr == '\r') { 
    9191    return TOKENIZER_CR; 
    9292  } else if(*ptr == ',') { 
     
    130130  DEBUG_PRINTF("get_next_token(): '%s'\n", ptr); 
    131131 
     132  // eat all whitespace 
     133  while(*ptr == ' ' || *ptr == '\t' || *ptr == '\r') ptr++; 
     134 
    132135  if(*ptr == 0) { 
    133136    return TOKENIZER_ENDOFINPUT; 
     
    152155    DEBUG_PRINTF("get_next_token: error due to too long number\n"); 
    153156    return TOKENIZER_ERROR; 
     157  } else if(*ptr == ':') { 
     158    // label 
     159    nextptr = ptr; 
     160    do { 
     161      ++nextptr; 
     162    } while(*nextptr != ' ' && * nextptr != '\n' && *nextptr != '\t'); 
     163    return TOKENIZER_LABEL; 
    154164  } else if((i=singlechar()) != 0) { 
    155165    if (i == TOKENIZER_CR){ 
    156         // eliminate empty lines, support cr+lf line ending 
    157         do { 
    158             ptr++; 
    159         } while (singlechar() == TOKENIZER_CR); 
    160         ptr--; 
     166      // move to next line, and skip all following empty lines as well 
     167      while (singlechar() == TOKENIZER_CR)  
     168      { 
     169        current_line++; 
     170        ptr++; 
     171        // eat all whitespace 
     172        while(*ptr == ' ' || *ptr == '\t' || *ptr == '\r') ptr++; 
     173      }; 
     174      ptr--; 
     175      // dangelo: now the last char might point to a whitespace instead of 
     176      // a CR. I hope that doesn't break anything. 
    161177    } 
    162178    nextptr = ptr + 1; 
    163  
    164179    return i; 
    165180  } else if(*ptr == '"') { 
     
    192207{ 
    193208  ptr = program; 
     209  current_line = 1; 
    194210  current_token = get_next_token(); 
    195211} 
     
    247263/*---------------------------------------------------------------------------*/ 
    248264void 
     265tokenizer_label(char *dest, int len) 
     266{ 
     267  char *string_end; 
     268  char *string_end2; 
     269  int string_len; 
     270   
     271  if(tokenizer_token() != TOKENIZER_LABEL) { 
     272    return; 
     273  } 
     274  // allow string \n and space to end labels 
     275  // TODO: allow tabs as well 
     276  string_end = strchr(ptr + 1, ' '); 
     277  string_end2 = strchr(ptr + 1, '\n'); 
     278  if (string_end == NULL) 
     279    string_end = string_end2; 
     280  else if (string_end2 == NULL) { 
     281 
     282  } 
     283  else if (string_end2 < string_end) 
     284    string_end = string_end2; 
     285 
     286  if(string_end == NULL) { 
     287    return; 
     288  } 
     289  string_len = string_end - ptr - 1; 
     290  if(len < string_len) { 
     291    string_len = len; 
     292  } 
     293  memcpy(dest, ptr + 1, string_len); 
     294  dest[string_len] = 0; 
     295} 
     296/*---------------------------------------------------------------------------*/ 
     297void 
    249298tokenizer_error_print(void) 
    250299{ 
     
    264313} 
    265314/*---------------------------------------------------------------------------*/ 
     315int tokenizer_line_number(void) 
     316{ 
     317  return current_line; 
     318} 
  • trunk/lib/ubasic/tokenizer.h

    r1 r5  
    3131#define __TOKENIZER_H__ 
    3232 
    33 enum { 
     33typedef enum { 
    3434  TOKENIZER_ERROR, 
    3535  TOKENIZER_ENDOFINPUT, 
     
    6565  TOKENIZER_EQ, 
    6666  TOKENIZER_CR, 
     67  TOKENIZER_LABEL, 
    6768  TOKENIZER_SLEEP, 
    6869  TOKENIZER_CLICK, 
    69   TOKENIZER_SHOT, 
     70  TOKENIZER_SHOOT, 
    7071  TOKENIZER_GET_TV, 
    7172  TOKENIZER_SET_TV, 
     
    7374  TOKENIZER_GET_AV, 
    7475  TOKENIZER_SET_AV, 
    75   TOKENIZER_SET_AV_REL, 
    76  
    77 }; 
     76  TOKENIZER_SET_AV_REL 
     77} ubasic_token; 
    7878 
    7979void tokenizer_init(const char *program); 
     
    8383int tokenizer_variable_num(void); 
    8484void tokenizer_string(char *dest, int len); 
     85void tokenizer_label(char *dest, int len); 
     86 
     87int tokenizer_line_number(void); 
     88void tokenizer_skip_line(void); 
    8589 
    8690int tokenizer_finished(void); 
  • trunk/lib/ubasic/ubasic.c

    r1 r5  
    3030 
    3131#if DEBUG 
    32 #define DEBUG_PRINTF(...)  printf(__VA_ARGS__) 
     32#define DEBUG_PRINTF(...)  fprintf(stderr, __VA_ARGS__) 
    3333#else 
    3434#define DEBUG_PRINTF(...) 
     
    4242 
    4343#include "stdlib.h" /* exit() */ 
     44 
     45#ifdef DEBUG 
     46#include <stdio.h> 
     47#endif 
    4448 
    4549static char const *program_ptr; 
     
    7074 
    7175int ubasic_error; 
    72 int ubasic_line; 
     76const char *ubasic_errstrings[UBASIC_E_ENDMARK] =  
     77{ 
     78    "No err", 
     79    "Parse err", 
     80    "Unk stmt", 
     81    "Unk key", 
     82    "Unk label", 
     83    "Stack ful", 
     84    "bad return", 
     85    "Unk err"  
     86}; 
     87 
     88/*---------------------------------------------------------------------------*/ 
     89int 
     90ubasic_linenumber() 
     91{ 
     92  return tokenizer_line_number(); 
     93} 
    7394 
    7495/*---------------------------------------------------------------------------*/ 
     
    80101  tokenizer_init(program); 
    81102  ended = 0; 
    82   ubasic_error = 0; 
    83   ubasic_line = 0; 
     103  ubasic_error = UBASIC_E_NONE; 
    84104} 
    85105/*---------------------------------------------------------------------------*/ 
     
    95115     tokenizer_next(); 
    96116     ended = 1; 
    97      ubasic_error = 1; 
     117     ubasic_error = UBASIC_E_PARSE; 
    98118     return; 
    99119  } 
     
    234254  return r1; 
    235255} 
     256 
     257#if 0 
    236258/*---------------------------------------------------------------------------*/ 
    237259static void 
     
    252274  } 
    253275} 
     276#endif 
     277 
     278/*---------------------------------------------------------------------------*/ 
     279static void 
     280jump_line(int linenum) 
     281{ 
     282  tokenizer_init(program_ptr); 
     283  while(tokenizer_line_number() != linenum) { 
     284    tokenizer_next(); 
     285  } 
     286  /* swallow the CR that would be read next */ 
     287  accept(TOKENIZER_CR); 
     288 
     289} 
     290/*---------------------------------------------------------------------------*/ 
     291// TODO: error handling? 
     292static int 
     293jump_label(char * label) 
     294{ 
     295  char currLabel[MAX_STRINGLEN]; 
     296  tokenizer_init(program_ptr); 
     297  currLabel[0] = 0; 
     298  while(tokenizer_token() != TOKENIZER_ENDOFINPUT) { 
     299    tokenizer_next(); 
     300    if (tokenizer_token() == TOKENIZER_LABEL) { 
     301      tokenizer_label(currLabel, sizeof(currLabel)); 
     302      tokenizer_next(); 
     303      if(strcmp(label, currLabel) == 0) { 
     304        accept(TOKENIZER_CR); 
     305        DEBUG_PRINTF("jump_linenum: Found line %d\n", tokenizer_line_number()); 
     306        break; 
     307      } 
     308    } 
     309  } 
     310  if (tokenizer_token() == TOKENIZER_ENDOFINPUT) { 
     311      DEBUG_PRINTF("Label %s not found", label); 
     312      ubasic_error = UBASIC_E_UNK_LABEL; 
     313      return 0; 
     314  } else { 
     315      return 1; 
     316  } 
     317} 
    254318/*---------------------------------------------------------------------------*/ 
    255319static void 
     
    257321{ 
    258322  accept(TOKENIZER_GOTO); 
    259   jump_linenum(tokenizer_num()); 
     323  if(tokenizer_token() == TOKENIZER_STRING) { 
     324    tokenizer_string(string, sizeof(string)); 
     325    tokenizer_next(); 
     326    jump_label(string); 
     327  } else { 
     328    DEBUG_PRINTF("ubasic.c: goto_statement(): no label specified\n"); 
     329    // exit(1); 
     330#warning todo: well... there should be something... definitely. 
     331//    exit(1); 
     332    ended = 1; 
     333    ubasic_error = UBASIC_E_UNK_LABEL; 
     334  } 
    260335} 
    261336/*---------------------------------------------------------------------------*/ 
     
    288363  tokenizer_next(); 
    289364} 
    290  
     365/*---------------------------------------------------------------------------*/ 
    291366static void 
    292367if_statement(void) 
     
    334409gosub_statement(void) 
    335410{ 
    336   int linenum; 
    337411  accept(TOKENIZER_GOSUB); 
    338   linenum = tokenizer_num(); 
    339   accept(TOKENIZER_NUMBER); 
    340   accept(TOKENIZER_CR); 
    341   if(gosub_stack_ptr < MAX_GOSUB_STACK_DEPTH) { 
    342     gosub_stack[gosub_stack_ptr] = tokenizer_num(); 
    343     gosub_stack_ptr++; 
    344     jump_linenum(linenum); 
     412  if(tokenizer_token() == TOKENIZER_STRING) { 
     413    tokenizer_string(string, sizeof(string)); 
     414    tokenizer_next(); 
     415    accept(TOKENIZER_CR); 
     416    if(gosub_stack_ptr < MAX_GOSUB_STACK_DEPTH) { 
     417      gosub_stack[gosub_stack_ptr] = tokenizer_line_number(); 
     418      gosub_stack_ptr++; 
     419      jump_label(string); 
     420    } else { 
     421      DEBUG_PRINTF("gosub_statement: gosub stack exhausted\n"); 
     422    // exit(1); 
     423#warning todo: well... there should be something... definitely. 
     424//    exit(1); 
     425    ended = 1; 
     426    ubasic_error = UBASIC_E_GOSUB_STACK_EXHAUSTED; 
     427    } 
    345428  } else { 
    346     DEBUG_PRINTF("gosub_statement: gosub stack exhausted\n"); 
     429    DEBUG_PRINTF("ubasic.c: goto_statement(): no label specified\n"); 
     430    // exit(1); 
     431#warning todo: well... there should be something... definitely. 
     432//    exit(1); 
     433    ended = 1; 
     434    ubasic_error = UBASIC_E_UNK_LABEL; 
    347435  } 
    348436} 
     
    354442  if(gosub_stack_ptr > 0) { 
    355443    gosub_stack_ptr--; 
    356     jump_linenum(gosub_stack[gosub_stack_ptr]); 
     444    jump_line(gosub_stack[gosub_stack_ptr]); 
    357445  } else { 
    358446    DEBUG_PRINTF("return_statement: non-matching return\n"); 
     447    ended = 1; 
     448    ubasic_error = UBASIC_E_UNMATCHED_RETURN; 
    359449  } 
    360450} 
     
    373463                        ubasic_get_variable(var) + 1); 
    374464    if(ubasic_get_variable(var) <= for_stack[for_stack_ptr - 1].to) { 
    375       jump_linenum(for_stack[for_stack_ptr - 1].line_after_for); 
     465      jump_line(for_stack[for_stack_ptr - 1].line_after_for); 
    376466    } else { 
    377467      for_stack_ptr--; 
     
    400490 
    401491  if(for_stack_ptr < MAX_FOR_STACK_DEPTH) { 
    402     for_stack[for_stack_ptr].line_after_for = tokenizer_num(); 
     492    for_stack[for_stack_ptr].line_after_for = tokenizer_line_number(); 
    403493    for_stack[for_stack_ptr].for_variable = for_variable; 
    404494    for_stack[for_stack_ptr].to = to; 
     
    442532/*---------------------------------------------------------------------------*/ 
    443533static void 
    444 shot_statement(void) 
    445 { 
    446   accept(TOKENIZER_SHOT); 
    447   ubasic_camera_shot(); 
    448   DEBUG_PRINTF("End of shot\n"); 
     534shoot_statement(void) 
     535{ 
     536  accept(TOKENIZER_SHOOT); 
     537  ubasic_camera_shoot(); 
     538  DEBUG_PRINTF("End of shoot\n"); 
    449539  accept(TOKENIZER_CR); 
    450540} 
     
    514604statement(void) 
    515605{ 
    516   int token; 
    517    
     606  ubasic_token token; 
     607 
    518608  token = tokenizer_token(); 
    519    
     609 
    520610  switch(token) { 
    521611  case TOKENIZER_PRINT: 
     
    529619    click_statement(); 
    530620    break; 
    531   case TOKENIZER_SHOT: 
    532     shot_statement(); 
     621  case TOKENIZER_SHOOT: 
     622    shoot_statement(); 
    533623    break; 
    534624 
     
    585675//    exit(1); 
    586676    ended = 1; 
    587     ubasic_error = 2; 
     677    ubasic_error = UBASIC_E_UNK_STATEMENT; 
    588678  } 
    589679} 
     
    592682line_statement(void) 
    593683{ 
    594   ubasic_line = tokenizer_num(); 
    595   DEBUG_PRINTF("----------- Line number %d ---------\n", ubasic_line); 
     684  /* line numbers have been removed */ 
     685  DEBUG_PRINTF("----------- Line number %d ---------\n", tokenizer_line_number()); 
    596686  /*    current_linenum = tokenizer_num();*/ 
    597   accept(TOKENIZER_NUMBER); 
     687  if (tokenizer_token() == TOKENIZER_LABEL) { 
     688#ifdef DEBUG 
     689      tokenizer_label(string, sizeof(string)); 
     690      DEBUG_PRINTF("line_statement: label: %s\n", string ); 
     691#endif 
     692      accept(TOKENIZER_LABEL); 
     693      return; 
     694  } 
    598695  statement(); 
    599696  return; 
  • trunk/platform/a610/main.c

    r1 r5  
    267267        { KEY_RIGHT     , 0x00000004 }, 
    268268        { KEY_SET       , 0x00000100 }, 
    269         { KEY_SHOT_FULL , 0x00000030 }, // note 3 here! 
    270         { KEY_SHOT_HALF , 0x00000010 }, 
     269        { KEY_SHOOT_FULL, 0x00000030 }, // note 3 here! 
     270        { KEY_SHOOT_HALF, 0x00000010 }, 
    271271        { KEY_ZOOM_IN   , 0x00000040 }, 
    272272        { KEY_ZOOM_OUT  , 0x00000080 }, 
  • trunk/platform/a620/main.c

    r1 r5  
    267267        { KEY_RIGHT     , 0x00000004 }, 
    268268        { KEY_SET       , 0x00000100 }, 
    269         { KEY_SHOT_FULL , 0x00000030 }, // note 3 here! 
    270         { KEY_SHOT_HALF , 0x00000010 }, 
     269        { KEY_SHOOT_FULL, 0x00000030 }, // note 3 here! 
     270        { KEY_SHOOT_HALF, 0x00000010 }, 
    271271        { KEY_ZOOM_IN   , 0x00000040 }, 
    272272        { KEY_ZOOM_OUT  , 0x00000080 }, 
  • trunk/script/default.bas

    r1 r5  
    1 1 sleep 1000 
    2 2 if a<1 then let a=2 
    3 3 if b<1 then let b=3 
    4 4 for s=1 to a 
    5 5 shot 
    6 6 for n=1 to b 
    7 7 click "right" 
    8 8 next n 
    9 9 next s 
    10 10 shot 
    11 11 end 
     1sleep 1000 
     2if a<1 then let a=2 
     3if b<1 then let b=3 
     4for s=1 to a 
     5  shot 
     6  for n=1 to b 
     7    click "right" 
     8  next n 
     9next s 
     10shot 
     11end 
  • trunk/script/script.bas

    r1 r5  
    1 1 sleep 1000 
    2 4 for s=1 to 3 
    3 5 shot 
    4 6 for n=1 to 5 
    5 7 click "left" 
    6 8 next n 
    7 9 next s 
    8 10 shot 
    9 11 end 
     1sleep 1000 
     2for s=1 to 3 
     3  shot 
     4  for n=1 to 5 
     5    click "left" 
     6  next n 
     7next s 
     8shot 
     9end 
Note: See TracChangeset for help on using the changeset viewer.