Overview
Comment: | Implement the text editor, for editing the level title and level strings (currently, only editing the title is implemented). |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
1665c0ca5dbc9c6a1adbf1b47f997946 |
User & Date: | user on 2021-03-27 08:21:14 |
Other Links: | manifest | tags |
Context
2021-03-27
| ||
22:08 | Add 'lt' for setting level title by SQL codes, and make ^P in the text editor to remember the last character picket check-in: 7518eafb66 user: user tags: trunk | |
08:21 | Implement the text editor, for editing the level title and level strings (currently, only editing the title is implemented). check-in: 1665c0ca5d user: user tags: trunk | |
2021-03-26
| ||
03:55 | Implement the Chebyshev, Manhattan, Rel, and Seek instructions. check-in: 7db27bc31e user: user tags: trunk | |
Changes
Modified bindings.doc from [b05d9a34cf] to [f99b352e8c].
︙ | ︙ | |||
105 106 107 108 109 110 111 112 113 114 115 116 117 118 | Add a new level (after the last one). The new level has the same dimensions as the current level, but contains no objects or strings, and the title is set to "New Level". '^S' Save level. '^a' <location> Add an object with the current MRU values to that location, if there is not already another object of the same class there. '^c' Display the class selection menu. | > > > | 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | Add a new level (after the last one). The new level has the same dimensions as the current level, but contains no objects or strings, and the title is set to "New Level". '^S' Save level. '^T' Edit the level title. '^a' <location> Add an object with the current MRU values to that location, if there is not already another object of the same class there. '^c' Display the class selection menu. |
︙ | ︙ |
Modified default.heromeshrc from [7cb4207d79] to [bcc7dad1c1].
︙ | ︙ | |||
141 142 143 144 145 146 147 148 149 150 151 152 153 154 | ?.editKey.C: select 'lc',:level_code where :level_code=cast(:level_code as int); ?.editKey.F: with n(n) as (select 65 union all select n+1 h from n where h<=64*pfheight()+65) select '^a',n from n; ?.editKey.R: select 're',substr(:resize,1,instr(:resize,'x')-1),substr(:resize,instr(:resize,'x')+1) where length(:resize); ?.editKey.ctrl.N: ^N ?.editKey.ctrl.P: ^P ?.editKey.ctrl.Q: ^Q ?.editKey.ctrl.S: ^S ?.editKey.ctrl.X: select 're',pfwidth(),pfheight(); ?.editKey.space: ^c ?.editKey.return: ^e ?.editKey.f1: select 'im',:Import_Level; ?.editKey.f2: select 'ex',:Export_Level; ?.editClick.left: ^a ?.editClick.alt.left: ^u | > | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | ?.editKey.C: select 'lc',:level_code where :level_code=cast(:level_code as int); ?.editKey.F: with n(n) as (select 65 union all select n+1 h from n where h<=64*pfheight()+65) select '^a',n from n; ?.editKey.R: select 're',substr(:resize,1,instr(:resize,'x')-1),substr(:resize,instr(:resize,'x')+1) where length(:resize); ?.editKey.ctrl.N: ^N ?.editKey.ctrl.P: ^P ?.editKey.ctrl.Q: ^Q ?.editKey.ctrl.S: ^S ?.editKey.ctrl.T: ^T ?.editKey.ctrl.X: select 're',pfwidth(),pfheight(); ?.editKey.space: ^c ?.editKey.return: ^e ?.editKey.f1: select 'im',:Import_Level; ?.editKey.f2: select 'ex',:Export_Level; ?.editClick.left: ^a ?.editClick.alt.left: ^u |
︙ | ︙ |
Modified edit.c from [52228f0c2a] to [53e03af8b4].
︙ | ︙ | |||
969 970 971 972 973 974 975 | free(level_title); level_title=import_string(p+1); break; case '%': if(nlevelstrings>0x2000) { screen_message("Too many level strings"); } else { | | | 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 | free(level_title); level_title=import_string(p+1); break; case '%': if(nlevelstrings>0x2000) { screen_message("Too many level strings"); } else { levelstrings=realloc(levelstrings,(nlevelstrings+1)*sizeof(unsigned char*)); if(!levelstrings) fatal("Allocation failed\n"); levelstrings[nlevelstrings++]=import_string(p+1); } break; default: if(*p && *p!=';') { bad: |
︙ | ︙ | |||
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 | level_id=i; free(level_title); level_title=strdup("New Level"); if(!level_title) fatal("Allocation failed\n"); level_changed=level_version=level_code=0; level_ord=level_nindex+1; } static int editor_command(int prev,int cmd,int number,int argc,sqlite3_stmt*args,void*aux) { int x,y; switch(cmd) { case '^a': // Add object (no duplicates) if(prev) return prev; add_object_at(number&63?:64,number/64?:64,mru+curmru,1); | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 | level_id=i; free(level_title); level_title=strdup("New Level"); if(!level_title) fatal("Allocation failed\n"); level_changed=level_version=level_code=0; level_ord=level_nindex+1; } static int cursor_end(const Uint8*s) { int i=0; for(;;) { if(*s==10 || !*s) return i; if(*s==31 && s[1]) s++; i++; s++; } } static inline Uint8 pick_character(void) { SDL_Rect r; SDL_Event ev; Uint8 buf[17]; int i,j; Uint8 p=0; redraw: r.x=r.y=4; r.w=r.h=0x9C; SDL_FillRect(screen,&r,0xF8); SDL_LockSurface(screen); draw_text(24,8,"0123456789ABCDEF",0xF8,0xF3); buf[16]=0; for(i=0;i<16;i++) { snprintf(buf,2,"%X",i); draw_text(8,(i+3)<<3,buf,0xF8,0xF3); for(j=0;j<16;j++) buf[j]=(i<<4)|j?:255; draw_text(24,(i+3)<<3,buf,0xF8,0xFF); } buf[0]=p?:255; buf[1]=0; i=p>>4; j=p&15; draw_text((j+3)<<3,(i+3)<<3,buf,0xF2,0xFE); SDL_UnlockSurface(screen); SDL_Flip(screen); while(SDL_WaitEvent(&ev)) { switch(ev.type) { case SDL_QUIT: SDL_PushEvent(&ev); return; case SDL_KEYDOWN: switch(ev.key.keysym.sym) { case SDLK_RETURN: case SDLK_SPACE: case SDLK_KP_ENTER: return p?:255; case SDLK_KP2: if(ev.key.keysym.mod&KMOD_NUM) goto norm; //fallthrough case SDLK_DOWN: p+=16; break; case SDLK_KP4: if(ev.key.keysym.mod&KMOD_NUM) goto norm; //fallthrough case SDLK_LEFT: p--; break; case SDLK_KP6: if(ev.key.keysym.mod&KMOD_NUM) goto norm; //fallthrough case SDLK_RIGHT: p++; break; case SDLK_KP8: if(ev.key.keysym.mod&KMOD_NUM) goto norm; //fallthrough case SDLK_UP: p-=16; break; default: norm: i=ev.key.keysym.unicode; if(i>='0' && i<='9') p=(p<<4)|(i-'0'); if(i>='A' && i<='F') p=(p<<4)|(i+10-'A'); if(i>='a' && i<='f') p=(p<<4)|(i+10-'a'); if(i==13 || i==10) return p?:255; } goto redraw; case SDL_VIDEOEXPOSE: goto redraw; } } } static void edit_string(unsigned char**ps) { SDL_Rect rect; SDL_Event ev; char buf[19]; Uint8*s=malloc(0x3000); Uint8*cp; Uint16 li[64]; int c,e,i,j,n,r,sz; char o=0; char d=0; if(!s) fatal("Allocation failed\n"); if(*ps) strncpy(s,*ps,0x2FFD); else *s=0; s[0x2FFD]=0; *li=0; c=r=0; redraw: e=0; redraw2: set_cursor(XC_xterm); rect.x=rect.y=0; rect.w=screen->w; rect.h=screen->h; SDL_FillRect(screen,&rect,0xF0); rect.h=24; SDL_FillRect(screen,&rect,0xF1); SDL_LockSurface(screen); if(ps==&level_title) { draw_text(0,16," Title: ",0xF9,0xFF); } else { snprintf(buf,19," String %d: ",(int)(ps-levelstrings)); draw_text(0,16,buf,0xF9,0xFF); } draw_text(160,16,o?"OVR":"INS",0xF1,0xFE); draw_text(0,0,"<Esc> Cancel <F1> Preview <F2> Save <\x18\x19\x1A\x1B> MoveCursor <^P> InsertChar <^Y> DelLine",0xF1,0xFB); draw_text(0,8,"ALT+ <0-7> Color <B> Bar <C> Center <I> Image <L> Left <Q> Quiz",0xF1,0xFB); draw_text(0,24,"\x10",0xF0,0xF1); cp=0; for(i=j=n=0;s[i] && n<63;) { draw_text(0,(n+3)<<3,"\x10",0xF0,0xF1); i+=draw_text_line(8,(n+3)<<3,s+i,r==n?c:-1,&cp); if(j=(s[i]==10)) i++; sz=li[++n]=i; } if(!i) { sz=li[n=1]=r=c=0; cp=s; draw_text(8,24,"\xFE",0xFF,0xFE); } else if(j && n<63) { draw_text(0,(n+3)<<3,"\x10",0xF0,0xF1); draw_text(8,(n+3)<<3,"\xFE",r==n?0xFF:0xF0,r==n?0xFE:0xF1); if(r==n) cp=s+i,c=0; li[++n]=i; } if(r && r>=n) r--,e=0; if(n<63) li[n+1]=0xFFFF; SDL_UnlockSurface(screen); if(!cp) { if(e) fatal("Confusion in edit_string\n"); c=cursor_end(s+li[r]); e=1; goto redraw2; } if(d) { d=0; goto del; } snprintf(buf,19,"%d,%d / %d [%d]",r+1,c,n,sz); draw_text(200,16,buf,0xF1,0xFA); SDL_Flip(screen); while(SDL_WaitEvent(&ev)) { switch(ev.type) { case SDL_QUIT: SDL_PushEvent(&ev); return; case SDL_KEYDOWN: switch(ev.key.keysym.sym) { case SDLK_ESCAPE: return; case SDLK_F1: modal_draw_popup(s); break; case SDLK_F2: free(*ps); *ps=s; return; case SDLK_KP0: if(ev.key.keysym.mod&KMOD_NUM) goto norm; //fallthrough case SDLK_INSERT: ins: o^=1; break; case SDLK_KP1: if(ev.key.keysym.mod&KMOD_NUM) goto norm; //fallthrough case SDLK_END: end: c=cursor_end(s+li[r]); break; case SDLK_KP2: if(ev.key.keysym.mod&KMOD_NUM) goto norm; //fallthrough case SDLK_DOWN: down: if(r<63 && li[r+1]!=0xFFFF) ++r; break; case SDLK_KP4: if(ev.key.keysym.mod&KMOD_NUM) goto norm; //fallthrough case SDLK_LEFT: left: if(c) --c; break; case SDLK_KP6: if(ev.key.keysym.mod&KMOD_NUM) goto norm; //fallthrough case SDLK_RIGHT: right: ++c; break; case SDLK_KP7: if(ev.key.keysym.mod&KMOD_NUM) goto norm; //fallthrough case SDLK_HOME: home: c=0; break; case SDLK_KP8: if(ev.key.keysym.mod&KMOD_NUM) goto norm; //fallthrough case SDLK_UP: up: if(r) --r; break; case SDLK_KP_PERIOD: if(ev.key.keysym.mod&KMOD_NUM) goto norm; //fallthrough case SDLK_DELETE: del: if(!*cp) break; i=(*cp==31?2:1); memmove(cp,cp+i,(s+sz)-(cp+i-1)); break; case SDLK_BACKSPACE: back: if(cp==s || !c) break; c--; d=1; break; default: norm: i=ev.key.keysym.unicode; if(ev.key.keysym.mod&(KMOD_ALT|KMOD_META)) { switch(ev.key.keysym.sym) { case SDLK_0: i=1; goto addch; case SDLK_1: i=2; goto addch; case SDLK_2: i=3; goto addch; case SDLK_3: i=4; goto addch; case SDLK_4: i=5; goto addch; case SDLK_5: i=6; goto addch; case SDLK_6: i=7; goto addch; case SDLK_7: i=8; goto addch; case SDLK_b: i=15; goto addch; case SDLK_c: i=12; goto addch; case SDLK_i: i=14; goto addch; case SDLK_l: i=11; goto addch; case SDLK_n: i=10; goto addch; case SDLK_q: i=16; goto addch; } } if(i<32) { switch(i+64) { case 'A': goto home; case 'D': goto right; case 'E': goto up; case 'F': goto end; case 'G': goto del; case 'H': goto back; case 'M': i=10; goto addch; case 'P': goto specialchar; case 'S': goto left; case 'W': r=c=0; break; case 'X': goto down; case 'V': goto ins; case 'Y': goto erase; case 'Z': r=n?n-1:0; c=0; break; } } else if(i<127) { addch: if(i==10 && n>62) break; if(sz>=0x2FFC) break; if(o && *cp==31) memmove(cp,cp+1,(s+sz)-cp); if(!*cp) cp[1]=0; if(!o) memmove(cp+1,cp,(s+sz+1)-cp); *cp=i; if(i==10) r++,c=0; else c++; } break; } goto redraw; case SDL_VIDEOEXPOSE: goto redraw; } } erase: c=0; if(li[r+1]==0xFFFF) s[li[r]]=0; else memmove(s+li[r],s+li[r+1],sz+1-li[r+1]); if(r && r==n-1) --r; goto redraw; specialchar: if(sz>=0x2FFA) goto redraw; i=pick_character(); if(i>=32) goto addch; if(o && *cp==31) memmove(cp,cp+1,(s+sz)-cp); if(!*cp) cp[1]=0; memmove(cp+1,cp,(s+sz+1)-cp); if(!o) memmove(cp+1,cp,(s+sz+1)-cp); *cp=31; cp[1]=i; c++; goto redraw; } static int editor_command(int prev,int cmd,int number,int argc,sqlite3_stmt*args,void*aux) { int x,y; switch(cmd) { case '^a': // Add object (no duplicates) if(prev) return prev; add_object_at(number&63?:64,number/64?:64,mru+curmru,1); |
︙ | ︙ | |||
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 | case '^P': // Play return -2; case '^Q': // Quit return -1; case '^S': // Save level save_level(); return 1; case 'ex': // Export level if(argc<2) return prev; export_level(sqlite3_column_text(args,1)); return prev; case 'go': // Select level load_level(number); return 1; | > > > | 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 | case '^P': // Play return -2; case '^Q': // Quit return -1; case '^S': // Save level save_level(); return 1; case '^T': // Level title edit_string(&level_title); return 0; case 'ex': // Export level if(argc<2) return prev; export_level(sqlite3_column_text(args,1)); return prev; case 'go': // Select level load_level(number); return 1; |
︙ | ︙ |
Modified exec.c from [664301a3a6] to [0b49747d29].
︙ | ︙ | |||
30 31 32 33 34 35 36 | Uint8 pfwidth,pfheight; Sint8 gameover,key_ignored; Uint8 generation_number_inc; Uint32 move_number; unsigned char*quiz_text; Inventory*inventory; Uint32 ninventory; | | | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | Uint8 pfwidth,pfheight; Sint8 gameover,key_ignored; Uint8 generation_number_inc; Uint32 move_number; unsigned char*quiz_text; Inventory*inventory; Uint32 ninventory; unsigned char**levelstrings; Uint16 nlevelstrings; Value*array_data; Uint16 ndeadanim; DeadAnimation*deadanim; Uint8 no_dead_anim; typedef struct { |
︙ | ︙ | |||
70 71 72 73 74 75 76 | static Value send_message(Uint32 from,Uint32 to,Uint16 msg,Value arg1,Value arg2,Value arg3); static Uint32 broadcast(Uint32 from,int c,Uint16 msg,Value arg1,Value arg2,Value arg3,int s); static Value destroy(Uint32 from,Uint32 to,Uint32 why); static const Sint8 x_delta[8]={1,1,0,-1,-1,-1,0,1}; static const Sint8 y_delta[8]={0,-1,-1,-1,0,1,1,1}; | | | | 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | static Value send_message(Uint32 from,Uint32 to,Uint16 msg,Value arg1,Value arg2,Value arg3); static Uint32 broadcast(Uint32 from,int c,Uint16 msg,Value arg1,Value arg2,Value arg3,int s); static Value destroy(Uint32 from,Uint32 to,Uint32 why); static const Sint8 x_delta[8]={1,1,0,-1,-1,-1,0,1}; static const Sint8 y_delta[8]={0,-1,-1,-1,0,1,1,1}; const unsigned char*value_string_ptr(Value v) { switch(v.t) { case TY_STRING: return stringpool[v.u]; case TY_LEVELSTRING: return v.u<nlevelstrings?levelstrings[v.u]:(unsigned char*)"<Invalid level string>"; default: fatal("Internal confusion: Trying to get string pointer for a non-string\n"); } } void pfunlink(Uint32 n) { Object*o=objects[n]; if(o->down==VOIDLINK) playfield[o->x+o->y*64-65]=o->up; |
︙ | ︙ |
Modified heromesh.h from [75d4788d3e] to [81f8d108e9].
︙ | ︙ | |||
100 101 102 103 104 105 106 107 108 109 110 111 112 113 | // Use only when screen is unlocked void draw_picture(int x,int y,Uint16 img); void draw_cell(int x,int y); // Use only when screen is locked void draw_text(int x,int y,const unsigned char*t,int bg,int fg); void draw_key(int x,int y,int k,int bg,int fg); const char*screen_prompt(const char*txt); int screen_message(const char*txt); int scrollbar(int*cur,int page,int max,SDL_Event*ev,SDL_Rect*re); | > | 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | // Use only when screen is unlocked void draw_picture(int x,int y,Uint16 img); void draw_cell(int x,int y); // Use only when screen is locked void draw_text(int x,int y,const unsigned char*t,int bg,int fg); int draw_text_line(int x,int y,unsigned char*t,int cur,Uint8**cp); void draw_key(int x,int y,int k,int bg,int fg); const char*screen_prompt(const char*txt); int screen_message(const char*txt); int scrollbar(int*cur,int page,int max,SDL_Event*ev,SDL_Rect*re); |
︙ | ︙ | |||
253 254 255 256 257 258 259 | extern Uint8 pfwidth,pfheight; extern Sint8 gameover,key_ignored; extern Uint8 generation_number_inc; extern Uint32 move_number; extern unsigned char*quiz_text; extern Inventory*inventory; extern Uint32 ninventory; | | | | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 | extern Uint8 pfwidth,pfheight; extern Sint8 gameover,key_ignored; extern Uint8 generation_number_inc; extern Uint32 move_number; extern unsigned char*quiz_text; extern Inventory*inventory; extern Uint32 ninventory; extern unsigned char**levelstrings; extern Uint16 nlevelstrings; extern Value*array_data; extern Uint16 ndeadanim; extern DeadAnimation*deadanim; extern Uint8 no_dead_anim; const unsigned char*value_string_ptr(Value v); void pfunlink(Uint32 n); void pflink(Uint32 n); Uint32 objalloc(Uint16 c); void objtrash(Uint32 n); void annihilate(void); const char*execute_turn(int key); const char*init_level(void); |
︙ | ︙ |
Modified main.c from [d4bdc87885] to [021cdac3a0].
︙ | ︙ | |||
335 336 337 338 339 340 341 | } // Level strings i=0; while(p<end) { if(i>=max_objects) goto bad3; q=memchr(p,0,end-p); if(!q) goto bad1; | | | 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | } // Level strings i=0; while(p<end) { if(i>=max_objects) goto bad3; q=memchr(p,0,end-p); if(!q) goto bad1; levelstrings=realloc(levelstrings,(i+1)*sizeof(unsigned char*)); if(!levelstrings) fatal("Allocation failed\n"); levelstrings[i]=strdup(p); if(!levelstrings[i]) fatal("Allocation failed\n"); p=q+1; i++; } nlevelstrings=i; |
︙ | ︙ |
Modified picture.c from [370dd766bc] to [612e3375bc].
︙ | ︙ | |||
131 132 133 134 135 136 137 138 139 140 141 142 143 144 | ++f; } t++; if(!--len) return; pix+=8; } } void draw_key(int x,int y,int k,int bg,int fg) { // To be called only when screen is locked! Uint8*p=screen->pixels; Uint16 pitch=screen->pitch; int xx,yy; const unsigned char*f; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | ++f; } t++; if(!--len) return; pix+=8; } } int draw_text_line(int x,int y,unsigned char*t,int cur,Uint8**cp) { // To be called only when screen is locked! int len=strlen(t); const unsigned char*s=t; Uint8*pix=screen->pixels; Uint8*p; Uint16 pitch=screen->pitch; int bg,fg,xx,yy; char isimg=0; char e=0; const unsigned char*f; if(!*t) return 0; len=(screen->w-x)>>3; if(len<=0 || y+8>screen->h) return len<1?1:len; pix+=y*pitch+x; for(;;) { if(!cur) *cp=t; if(*t==10) { f=fontdata+(17<<3); bg=0xF0,fg=0xF1; e=1; } else if(!*t) { f=fontdata+(254<<3); bg=0xF0,fg=0xF1; e=1; } else if(*t<31) { f=fontdata+(" 01234567?NLC#IBQ???????????????"[*t]<<3); if(*t==14) isimg=1; bg=0xF3,fg=0xF0; } else { if(*t==31 && t[1]) t++; f=fontdata+(*t<<3); bg=0xF0,fg=isimg?0xF2:0xF7; } if(!cur--) bg^=15,fg^=15; p=pix; for(yy=0;yy<8;yy++) { for(xx=0;xx<8;xx++) p[xx]=(*f<<xx)&128?fg:bg; p+=pitch; ++f; } if(*t=='\\') isimg=0; if(!--len || e) return t-s; t++; pix+=8; } } void draw_key(int x,int y,int k,int bg,int fg) { // To be called only when screen is locked! Uint8*p=screen->pixels; Uint16 pitch=screen->pitch; int xx,yy; const unsigned char*f; |
︙ | ︙ |