Index: compile ================================================================== --- compile +++ compile @@ -1,20 +1,29 @@ #!/bin/bash -- test -f CFLAGS || echo xxx > CFLAGS test "xx$CFLAGS" = "x`cat CFLAGS`" || rm bindings.o class.o picture.o function.o exec.o echo "x$CFLAGS" > CFLAGS test "x$EXE" = "x" && EXE=~/bin/heromesh +echo 'Flags: ' "$CFLAGS" +echo 'Target filename: ' "$EXE" test instruc -nt instruc.h && node instruc.js > instruc.h test instruc.js -nt instruc.h && node instruc.js > instruc.h test names.js -nt names.h && node names.js > names.h test quarks -nt quarks.h && node quarks.js > quarks.h test quarks.js -nt quarks.h && node quarks.js > quarks.h test heromesh.h -nt "$EXE" && rm bindings.o class.o picture.o function.o exec.o test instruc.h -nt "$EXE" && rm class.o test pcfont.h -nt "$EXE" && rm picture.o test quarks.h -nt "$EXE" && rm bindings.o picture.o +echo '* bindings' test bindings.c -nt bindings.o && bash bindings.c +echo '* class' test class.c -nt class.o && bash class.c +echo '* function' test function.c -nt function.o && bash function.c +echo '* picture' test picture.c -nt picture.o && bash picture.c +echo '* exec' test exec.c -nt exec.o && bash exec.c +echo '* main' bash main.c +echo 'DONE' Index: exec.c ================================================================== --- exec.c +++ exec.c @@ -18,10 +18,11 @@ Uint32 nobjects; Value globals[0x800]; Uint32 firstobj=VOIDLINK; Uint32 lastobj=VOIDLINK; Uint32 playfield[64*64]; +Uint8 pfwidth,pfheight; typedef struct { Uint16 msg; Uint32 from; Value arg1,arg2,arg3; Index: heromesh.h ================================================================== --- heromesh.h +++ heromesh.h @@ -73,13 +73,15 @@ // == picture == extern SDL_Surface*screen; extern Uint16 picture_size; +extern int left_margin; void draw_picture(int x,int y,Uint16 img); void draw_text(int x,int y,const unsigned char*t,int bg,int fg); +void draw_cell(int x,int y); void load_pictures(void); // == class == #define CF_PLAYER 0x01 @@ -170,12 +172,13 @@ extern Object**objects; extern Uint32 nobjects; extern Value globals[0x800]; extern Uint32 firstobj,lastobj; extern Uint32 playfield[64*64]; +Uint8 pfwidth,pfheight; void pfunlink(Uint32 n); void pflink(Uint32 n); Uint32 objalloc(Uint16 c); void annihilate(void); const char*execute_turn(int key); Index: main.c ================================================================== --- main.c +++ main.c @@ -1,7 +1,7 @@ #if 0 -gcc ${CFLAGS:--s -O2} -o ${EXE:-~/bin/heromesh} main.c class.o picture.o bindings.o function.o smallxrm.o sqlite3.o `sdl-config --cflags --libs` -ldl -lpthread +gcc ${CFLAGS:--s -O2} -o ${EXE:-~/bin/heromesh} main.c class.o picture.o bindings.o function.o exec.o smallxrm.o sqlite3.o `sdl-config --cflags --libs` -ldl -lpthread exit #endif /* This program is part of Free Hero Mesh and is public domain. Index: picture.c ================================================================== --- picture.c +++ picture.c @@ -19,10 +19,11 @@ #include "quarks.h" #include "heromesh.h" SDL_Surface*screen; Uint16 picture_size; +int left_margin; static SDL_Surface*picts; static Uint8*curpic; static const char default_palette[]= @@ -86,10 +87,27 @@ // To be called only when screen is unlocked! SDL_Rect src={(img&15)*picture_size,(img>>4)*picture_size,picture_size,picture_size}; SDL_Rect dst={x,y,picture_size,picture_size}; SDL_BlitSurface(picts,&src,screen,&dst); } + +void draw_cell(int x,int y) { + // To be called only when screen is unlocked! + Uint32 o; + Class*c; + SDL_Rect dst={x,y,picture_size,picture_size}; + if(x<1 || x>64 || y<1 || y>64) return; + SDL_FillRect(screen,&dst,back_color); + o=playfield[y*64+x+65]; + while(o!=VOIDLINK) { + if(!(objects[o]->oflags&OF_INVISIBLE)) { + c=classes[objects[o]->class]; + if(objects[o]->imagenimages) draw_picture(x*picture_size+left_margin,y*picture_size,c->images[objects[o]->image]&0x7FFF); + } + o=objects[o]->up; + } +} void draw_text(int x,int y,const unsigned char*t,int bg,int fg) { // To be called only when screen is locked! int len=strlen(t); Uint8*pix=screen->pixels; @@ -336,6 +354,8 @@ h=strtol(v,0,10); SDL_EnableKeyRepeat(w,h); } else { SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL); } + optionquery[1]=Q_margin; + left_margin=strtol(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"65",0,10); } Index: quarks ================================================================== --- quarks +++ quarks @@ -3,10 +3,11 @@ ! Each line contains one name, is blank, or starts with ! for a comment. ! Graphics/screen screenWidth screenHeight +margin palette popupColors imageSize altImage editTitle Index: quarks.h ================================================================== --- quarks.h +++ quarks.h @@ -1,185 +1,187 @@ #define Q_screenWidth 2 #define Q_screenHeight 3 -#define Q_palette 4 -#define Q_popupColors 5 -#define Q_imageSize 6 -#define Q_altImage 7 -#define Q_editTitle 8 -#define Q_gameTitle 9 -#define Q_gamma 10 -#define Q_screenFlags 11 -#define Q_sfxVolume 12 -#define Q_audioBuffer 13 -#define Q_audioRate 14 -#define Q_audioFormat 15 -#define Q_musicVolume 16 -#define Q_musicFile 17 -#define Q_keyRepeat 18 -#define Q_editKey 19 -#define Q_gameKey 20 -#define Q_backspace 21 -#define Q_tab 22 -#define Q_clear 23 -#define Q_return 24 -#define Q_pause 25 -#define Q_escape 26 -#define Q_space 27 -#define Q_exclaim 28 -#define Q_quotedbl 29 -#define Q_hash 30 -#define Q_dollar 31 -#define Q_ampersand 32 -#define Q_quote 33 -#define Q_leftparen 34 -#define Q_rightparen 35 -#define Q_asterisk 36 -#define Q_plus 37 -#define Q_comma 38 -#define Q_minus 39 -#define Q_period 40 -#define Q_slash 41 -#define Q_0 42 -#define Q_1 43 -#define Q_2 44 -#define Q_3 45 -#define Q_4 46 -#define Q_5 47 -#define Q_6 48 -#define Q_7 49 -#define Q_8 50 -#define Q_9 51 -#define Q_colon 52 -#define Q_semicolon 53 -#define Q_less 54 -#define Q_equals 55 -#define Q_greater 56 -#define Q_question 57 -#define Q_at 58 -#define Q_leftbracket 59 -#define Q_rightbracket 60 -#define Q_caret 61 -#define Q_underscore 62 -#define Q_backquote 63 -#define Q_A 64 -#define Q_B 65 -#define Q_C 66 -#define Q_D 67 -#define Q_E 68 -#define Q_F 69 -#define Q_G 70 -#define Q_H 71 -#define Q_I 72 -#define Q_J 73 -#define Q_K 74 -#define Q_L 75 -#define Q_M 76 -#define Q_N 77 -#define Q_O 78 -#define Q_P 79 -#define Q_Q 80 -#define Q_R 81 -#define Q_S 82 -#define Q_T 83 -#define Q_U 84 -#define Q_V 85 -#define Q_W 86 -#define Q_X 87 -#define Q_Y 88 -#define Q_Z 89 -#define Q_delete 90 -#define Q_kp0 91 -#define Q_kp1 92 -#define Q_kp2 93 -#define Q_kp3 94 -#define Q_kp4 95 -#define Q_kp5 96 -#define Q_kp6 97 -#define Q_kp7 98 -#define Q_kp8 99 -#define Q_kp9 100 -#define Q_kp_period 101 -#define Q_kp_divide 102 -#define Q_kp_multiply 103 -#define Q_kp_minus 104 -#define Q_kp_plus 105 -#define Q_kp_enter 106 -#define Q_kp_equals 107 -#define Q_up 108 -#define Q_down 109 -#define Q_right 110 -#define Q_left 111 -#define Q_insert 112 -#define Q_home 113 -#define Q_end 114 -#define Q_pageup 115 -#define Q_pagedown 116 -#define Q_f1 117 -#define Q_f2 118 -#define Q_f3 119 -#define Q_f4 120 -#define Q_f5 121 -#define Q_f6 122 -#define Q_f7 123 -#define Q_f8 124 -#define Q_f9 125 -#define Q_f10 126 -#define Q_f11 127 -#define Q_f12 128 -#define Q_f13 129 -#define Q_f14 130 -#define Q_f15 131 -#define Q_numlock 132 -#define Q_capslock 133 -#define Q_scrollock 134 -#define Q_rshift 135 -#define Q_lshift 136 -#define Q_rctrl 137 -#define Q_lctrl 138 -#define Q_ralt 139 -#define Q_lalt 140 -#define Q_rmeta 141 -#define Q_lmeta 142 -#define Q_lsuper 143 -#define Q_rsuper 144 -#define Q_mode 145 -#define Q_help 146 -#define Q_print 147 -#define Q_sysreq 148 -#define Q_break 149 -#define Q_menu 150 -#define Q_power 151 -#define Q_euro 152 -#define Q_compose 153 -#define Q_undo 154 -#define Q_shift 155 -#define Q_ctrl 156 -#define Q_alt 157 -#define Q_meta 158 -#define Q_numLock 159 -#define Q_editClick 160 -#define Q_gameClick 161 -#define Q_allowMouseWarp 162 -#define Q_middle 163 -#define Q_class 164 -#define Q_quiz 165 -#define Q_saveSolutions 166 -#define Q_solutionComment 167 -#define Q_solutionTimestamp 168 -#define Q_sqlFile 169 -#define Q_sqlInit 170 -#define Q_sqlExtensions 171 -#define Q_sqlMemStatus 172 -#define Q_sqlSmallAllocations 173 -#define Q_sqlCoveringIndexScan 174 -#define Q_sqlPowerSafe 175 -#define Q_level 176 -#define Q_tracePrefix 177 -#define Q_stackProtection 178 +#define Q_margin 4 +#define Q_palette 5 +#define Q_popupColors 6 +#define Q_imageSize 7 +#define Q_altImage 8 +#define Q_editTitle 9 +#define Q_gameTitle 10 +#define Q_gamma 11 +#define Q_screenFlags 12 +#define Q_sfxVolume 13 +#define Q_audioBuffer 14 +#define Q_audioRate 15 +#define Q_audioFormat 16 +#define Q_musicVolume 17 +#define Q_musicFile 18 +#define Q_keyRepeat 19 +#define Q_editKey 20 +#define Q_gameKey 21 +#define Q_backspace 22 +#define Q_tab 23 +#define Q_clear 24 +#define Q_return 25 +#define Q_pause 26 +#define Q_escape 27 +#define Q_space 28 +#define Q_exclaim 29 +#define Q_quotedbl 30 +#define Q_hash 31 +#define Q_dollar 32 +#define Q_ampersand 33 +#define Q_quote 34 +#define Q_leftparen 35 +#define Q_rightparen 36 +#define Q_asterisk 37 +#define Q_plus 38 +#define Q_comma 39 +#define Q_minus 40 +#define Q_period 41 +#define Q_slash 42 +#define Q_0 43 +#define Q_1 44 +#define Q_2 45 +#define Q_3 46 +#define Q_4 47 +#define Q_5 48 +#define Q_6 49 +#define Q_7 50 +#define Q_8 51 +#define Q_9 52 +#define Q_colon 53 +#define Q_semicolon 54 +#define Q_less 55 +#define Q_equals 56 +#define Q_greater 57 +#define Q_question 58 +#define Q_at 59 +#define Q_leftbracket 60 +#define Q_rightbracket 61 +#define Q_caret 62 +#define Q_underscore 63 +#define Q_backquote 64 +#define Q_A 65 +#define Q_B 66 +#define Q_C 67 +#define Q_D 68 +#define Q_E 69 +#define Q_F 70 +#define Q_G 71 +#define Q_H 72 +#define Q_I 73 +#define Q_J 74 +#define Q_K 75 +#define Q_L 76 +#define Q_M 77 +#define Q_N 78 +#define Q_O 79 +#define Q_P 80 +#define Q_Q 81 +#define Q_R 82 +#define Q_S 83 +#define Q_T 84 +#define Q_U 85 +#define Q_V 86 +#define Q_W 87 +#define Q_X 88 +#define Q_Y 89 +#define Q_Z 90 +#define Q_delete 91 +#define Q_kp0 92 +#define Q_kp1 93 +#define Q_kp2 94 +#define Q_kp3 95 +#define Q_kp4 96 +#define Q_kp5 97 +#define Q_kp6 98 +#define Q_kp7 99 +#define Q_kp8 100 +#define Q_kp9 101 +#define Q_kp_period 102 +#define Q_kp_divide 103 +#define Q_kp_multiply 104 +#define Q_kp_minus 105 +#define Q_kp_plus 106 +#define Q_kp_enter 107 +#define Q_kp_equals 108 +#define Q_up 109 +#define Q_down 110 +#define Q_right 111 +#define Q_left 112 +#define Q_insert 113 +#define Q_home 114 +#define Q_end 115 +#define Q_pageup 116 +#define Q_pagedown 117 +#define Q_f1 118 +#define Q_f2 119 +#define Q_f3 120 +#define Q_f4 121 +#define Q_f5 122 +#define Q_f6 123 +#define Q_f7 124 +#define Q_f8 125 +#define Q_f9 126 +#define Q_f10 127 +#define Q_f11 128 +#define Q_f12 129 +#define Q_f13 130 +#define Q_f14 131 +#define Q_f15 132 +#define Q_numlock 133 +#define Q_capslock 134 +#define Q_scrollock 135 +#define Q_rshift 136 +#define Q_lshift 137 +#define Q_rctrl 138 +#define Q_lctrl 139 +#define Q_ralt 140 +#define Q_lalt 141 +#define Q_rmeta 142 +#define Q_lmeta 143 +#define Q_lsuper 144 +#define Q_rsuper 145 +#define Q_mode 146 +#define Q_help 147 +#define Q_print 148 +#define Q_sysreq 149 +#define Q_break 150 +#define Q_menu 151 +#define Q_power 152 +#define Q_euro 153 +#define Q_compose 154 +#define Q_undo 155 +#define Q_shift 156 +#define Q_ctrl 157 +#define Q_alt 158 +#define Q_meta 159 +#define Q_numLock 160 +#define Q_editClick 161 +#define Q_gameClick 162 +#define Q_allowMouseWarp 163 +#define Q_middle 164 +#define Q_class 165 +#define Q_quiz 166 +#define Q_saveSolutions 167 +#define Q_solutionComment 168 +#define Q_solutionTimestamp 169 +#define Q_sqlFile 170 +#define Q_sqlInit 171 +#define Q_sqlExtensions 172 +#define Q_sqlMemStatus 173 +#define Q_sqlSmallAllocations 174 +#define Q_sqlCoveringIndexScan 175 +#define Q_sqlPowerSafe 176 +#define Q_level 177 +#define Q_tracePrefix 178 +#define Q_stackProtection 179 static const char*const global_quarks[]={ "screenWidth", "screenHeight", + "margin", "palette", "popupColors", "imageSize", "altImage", "editTitle",