Guest User

Untitled

a guest
Oct 6th, 2019
165
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SeppJ wird es schon wieder löschen wollen, aber ich bin der Meinung, daß dieses Forum hier genau der richtige Ort ist, um die nötige Basis und die nötigen, immer wieder gleichen Grundbausteine zu vermitteln, die es für das Programmier-"Handwerk" braucht. Also hier die GUI:
  2.  
  3. ```cpp
  4. /* Some simple routines for Window handling.
  5. Yet still in 'development'.
  6. You give it a string with widgets and then it can
  7. receive input commands from a cursor and the keys.
  8. get_input() receives widget changes, you have to
  9. check for a signal variable and then call the
  10. routine that you associate with the event.
  11. Always first put in front the widget that has 'sent'
  12. the signal . Then use readback() to copy the new
  13. state into a data structure. With update()
  14. you should be able to set the signal back
  15. to zero and also produce text label output
  16. or create new widgets during runtime.
  17. Movement of windows could be done when the
  18. window signals '3' if a certain area is clicked,
  19. which is 'dispatched' every loop run to a routine
  20. which polls for mouse cursor movement and locks
  21. it on window coordinates. '4' is release and
  22. resizing could be done in a similiar way.
  23. Display() or so to display the entire stacked
  24. structure.
  25. It doesn't work with multitasking or queueing.
  26. If you want to write some crappy DOS apps,
  27. you might find it useful.
  28.  
  29. The basic idea was to get the input elements of a certain application
  30. always in front when you need them. So you display them with a resorted stacked list.
  31. Also, after the first elements were drawn, the drawn parts of the screen get fixated with a
  32. mask when going the stack downwards.
  33. The mouse and keyboard input can be catched through the first elements from the left and
  34. this gets only overwritten when the stack depth gets deeper.
  35. It can either be catched just that they don't go to elements outside of the focus or for
  36. actual input. Elements could change input mode by setting certain values.
  37. For carets, topmost and modal windows, the application programmer has to do certain things
  38. by himself. For example, topmost windows would be in front right before the display routine
  39. call and then sorted back to their old position which is saved in the application.
  40. It is important that the application always knows how the GUI looks like and therefore it
  41. hangs until upwardly an update was done so it is still consistent.
  42. If there was timer interrupt triggerd multitasking and no main loop, this perhaps
  43. also could fail.
  44. Input from the user may get lost. However, printer and modem are more annoying.
  45. It may also be necessary to remove messages for removed windows in a loop when they are
  46. closed.
  47.  
  48. To simulate the full multitasking version with C, you have to write a bytecode emulator
  49. that executes several code sequences at once. Writing a bytecode emulator is quite simple (however,
  50. a compiler for it is much harder) and you have to simply execute one instruction of each
  51. through it's calls in the main loop run.
  52. CLI and STI are important instructions. However, they may not be needed here.
  53.  
  54. In that main loop, you could also insert a message queue and a wrapper for the window routines.
  55. It would be a linked list. When a semaphore in the window structure is 1, it copies the state
  56. into a message structure, inserts it into the list and sets the semaphore to 0. Then it examines
  57. the memory of a script. Call it ABI. When a certain byte in the memory is 0, the message structure
  58. gets copied into a certain area of the memory of the script and the byte is set to 1. This will also include
  59. other information like some sort of "hwnd" handle. The script would then call some sort of GetMessage() or
  60. PeekMessage(). The message is then removed from the list.
  61. The script can then catch that info and process the user command. The other way, inside the memory of the
  62. script another byte is set and the command for window change is appended somewhere, the message routine in the
  63. main loop sets the byte to 0 and puts the message with the data needed into the linked list and tries
  64. to send it to the GUI wrapper when it is ready. The GUI wrapper would then update the window structure with
  65. some of the routines below.
  66. Timer-triggered multitasking would require CLI and STI on critical points.
  67.  
  68. The wrapper could poll the timer function and that way, it could send double clicks by bundling two
  69. clicks together into a new message.
  70. Watch out for layer=framedepth-1 . Needs to be fixed?
  71.  
  72.  
  73. */
  74.  
  75.  
  76.  
  77.  
  78. #include <stdio.h>
  79. #include <stdlib.h>
  80. #include <string.h>
  81. #include <time.h>
  82. /*
  83. Ein einfacher Steuersequenzsstring stellt Fenster dar.
  84. Die Sequenzen werden mit einem Stapel abgearbeitet und zur Laufzeit umgebaut.
  85. Es gibt eine Update-Semaphore, die kenntlich macht, dass das betreffende Element
  86. veraendert wurde.
  87. Die Hervorhebung ergibt sich aus der Reihenfolge im Stapel.
  88. Ist das erste Element markiert, wird der Rest nicht mehr verarbeitet.
  89. Die Verarbeitung zielt dann nur noch auf die Beendigung der Sequenz.
  90.  
  91. Cursor bewegen mit h,j,k,u und klicken mit l,
  92. Konsolenfenster fuer Anzeige gross stellen
  93. */
  94. unsigned char screen[160][120];
  95. unsigned char windStr[1024];
  96.  
  97. struct
  98. {
  99. int x,y;
  100. long int xmax, ymax;
  101. int blocked;
  102. unsigned int seqstart, seqend;
  103. signed int firstheap;
  104. } framestack[20];
  105. signed int framedepth=0;
  106. unsigned int pixelbuf[20000][4];
  107. unsigned int pixcount;
  108. unsigned char screenz[160][120];
  109.  
  110.  
  111. /*
  112. Anwendung muss das Nachvorneholen selber initiieren
  113. Elemente muessen durch Identifier gezielt angesprochen werden
  114. Datenfeld muss als Pointer abgeelgt werden
  115. Eingabekommando muss in Fensterelement gespeichert werden, sodass Anwendung
  116. die Positionierung des Eingabecursors und das Einfuegen des Textes uebernehmen kann
  117. evtl. Updatesperre
  118. Löchsen und Erzeugen von Elementen?
  119.  
  120. */
  121.  
  122. /*
  123. Wird ein Fenster neu positioniert, oder wollte das Fenstersystem eine Animation
  124. beim Minimirern oder auch nur beim Radiobuttonaendern zeigen, muss das Aendern eines Objekts,
  125. das auch ausserdem nicht ganz vorne sein muss, durch einen Routinenaufruf des Fenstersystems
  126. erfolgen, der nicht einfach nur direkt die Werte aendert?
  127. Diese Routine gibt den Erfolgsstatus an die Anwendung zurueck?
  128. */
  129.  
  130. /* Ich könnte unten nochmal update() aufrufen und so etwas Tipparbeit sparen?
  131. */
  132.  
  133.  
  134. typedef
  135. struct
  136. {
  137. unsigned char type;
  138. unsigned char varname[255];
  139. unsigned char text[255];
  140. int x,y;
  141. int xabs, yabs;
  142. int xmaxabs;
  143. long int ymaxabs;
  144. long int xmax,ymax;
  145. int command;
  146. int blocked;
  147. long int param;
  148. int visible;
  149. int visible_abs;
  150.  
  151. } obj_state;
  152.  
  153.  
  154. void buildstring(char *string, obj_state *state)
  155. {
  156.  
  157. unsigned char buf[255];
  158. if ( state->type=='w')
  159. {
  160. strcpy(string,"w");
  161. strcat(string,":");
  162. strcat(string,state->varname);
  163. strcat(string,":");
  164. strcat(string,state->text);
  165. strcat(string,":");
  166.  
  167. itoa(state->xabs,buf,10),
  168. strcat(string,buf);
  169. strcat(string,":");
  170.  
  171. itoa(state->yabs,buf,10),
  172. strcat(string,buf);
  173. strcat(string,":");
  174.  
  175.  
  176. itoa(state->xmaxabs,buf,10),
  177. strcat(string,buf);
  178. strcat(string,":");
  179.  
  180.  
  181. itoa(state->ymaxabs,buf,10),
  182. strcat(string,buf);
  183. strcat(string,":");
  184.  
  185. itoa(state->blocked,buf,10),
  186. strcat(string,buf);
  187. strcat(string,":");
  188.  
  189.  
  190. itoa(state->command,buf,10),
  191. strcat(string,buf);
  192. strcat(string,":");
  193.  
  194.  
  195.  
  196. }
  197. else if ( state->type=='b')
  198. {
  199. strcpy(string,"b");
  200.  
  201. strcat(string,":");
  202. strcat(string,state->varname);
  203. strcat(string,":");
  204. strcat(string,state->text);
  205. strcat(string,":");
  206.  
  207. itoa(state->xabs,buf,10),
  208. strcat(string,buf);
  209. strcat(string,":");
  210.  
  211. itoa(state->yabs,buf,10),
  212. strcat(string,buf);
  213. strcat(string,":");
  214.  
  215.  
  216. itoa(state->xmaxabs,buf,10),
  217. strcat(string,buf);
  218. strcat(string,":");
  219.  
  220.  
  221. itoa(state->ymaxabs,buf,10),
  222. strcat(string,buf);
  223. strcat(string,":");
  224.  
  225. itoa(state->blocked,buf,10),
  226. strcat(string,buf);
  227. strcat(string,":");
  228.  
  229.  
  230. itoa(state->command,buf,10),
  231. strcat(string,buf);
  232. strcat(string,":");
  233.  
  234.  
  235.  
  236. }
  237. else if ( state->type=='t')
  238. {
  239. strcpy(string,"t");
  240.  
  241. strcat(string,":");
  242. strcat(string,state->varname);
  243. strcat(string,":");
  244. strcat(string,state->text);
  245. strcat(string,":");
  246.  
  247. itoa(state->xabs,buf,10),
  248. strcat(string,buf);
  249. strcat(string,":");
  250.  
  251. itoa(state->yabs,buf,10),
  252. strcat(string,buf);
  253. strcat(string,":");
  254.  
  255.  
  256. itoa(state->xmaxabs,buf,10),
  257. strcat(string,buf);
  258. strcat(string,":");
  259.  
  260.  
  261. itoa(state->ymaxabs,buf,10),
  262. strcat(string,buf);
  263. strcat(string,":");
  264.  
  265. itoa(state->blocked,buf,10),
  266. strcat(string,buf);
  267. strcat(string,":");
  268.  
  269.  
  270. itoa(state->command,buf,10),
  271. strcat(string,buf);
  272. strcat(string,":");
  273.  
  274.  
  275.  
  276.  
  277. }
  278.  
  279. }
  280.  
  281. void disp_edit_text(obj_state *edfield, signed int z)
  282. {
  283. long int len;
  284. len=0;
  285.  
  286. while ( edfield->x+len < edfield->xmax && *(unsigned char*)(edfield->ymax+len)!='\0' && len < 9)
  287. ppix(edfield->x+len, edfield->y, *(unsigned char *)(edfield->ymax+len),z), len++;
  288. while ( len < 10) ppix(edfield->x+len, edfield->y,219,z), len++;
  289.  
  290.  
  291. }
  292.  
  293. unsigned char get_edit_pos(obj_state *edfield, int x, int y )
  294. {
  295. int len;
  296. len=0;
  297. if ( edfield->y== y && edfield->x <= x )
  298. {
  299. while ( 1)
  300. {
  301. printf("\aEdfield x ist %d, x ist %d, y Edfield y ist %d, y ist %d",edfield->x, x,edfield->y,y ), getch();
  302. if ( len > 9 || edfield->x+len >= edfield->xmax) return 'F' ;
  303. if ( edfield->x+len ==x) return len+0x30;
  304. len++;
  305.  
  306. if ( *(unsigned char *)(edfield->ymax+len)=='\0' ) return 'F';
  307. }
  308. }
  309. else return 'F';
  310.  
  311. }
  312.  
  313.  
  314. // andere Routinen koennen readback() und update() aufrufen, spart Tipperei
  315.  
  316.  
  317. void ppix(unsigned int x, unsigned int y, unsigned char value, unsigned int z)
  318. {
  319. if ( screenz[x][y]!=255)
  320. {
  321. pixelbuf[pixcount][0]=x,
  322. pixelbuf[pixcount][1]=y,
  323. pixelbuf[pixcount][2]=value;
  324. pixelbuf[pixcount][3]=z;
  325. screenz[x][y]=z;
  326.  
  327. pixcount++;
  328. }
  329.  
  330. }
  331. void releasescreenblock(unsigned int z)
  332. {
  333. int x=0, y=0;
  334.  
  335. while ( y < 120)
  336. {
  337. x=0;
  338. while ( x < 160)
  339. {
  340. if ( screenz[x][y]==z) screenz[x][y]=255;
  341. x++;
  342. }
  343.  
  344. y++;
  345. }
  346.  
  347. }
  348.  
  349. unsigned int cursor[2];
  350.  
  351.  
  352.  
  353.  
  354.  
  355. void disp_elements(void )
  356. {
  357. unsigned int type;
  358. unsigned char text[32];
  359. unsigned char varname[32];
  360. unsigned int n2=0;
  361. unsigned int x,y,xmax,ymax;
  362. unsigned int blocked;
  363. unsigned int updateSemaph;
  364. unsigned char buf[5];
  365. unsigned int entry_p, exit_p;
  366. int n=0;
  367. entry_p=0;
  368.  
  369.  
  370. ppix(cursor[0],cursor[1],'X',1);
  371. releasescreenblock(1);
  372.  
  373. while ( 1 )
  374. {
  375. type=windStr[n];
  376.  
  377. if ( type=='e')
  378. {
  379. framedepth--;
  380.  
  381. n++;
  382. exit_p=n;
  383. framestack[framedepth].seqend=exit_p;
  384. releasescreenblock(framedepth+1);
  385.  
  386. if ( framedepth==0) return;
  387.  
  388. }
  389.  
  390. if ( type=='w' )
  391. {
  392. entry_p=n;
  393. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  394. n++;
  395. if ( windStr[n]==':' )n++; else return;
  396. n2=0;
  397. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  398. if ( windStr[n]==':' )n++; else return;
  399. varname[n2]='\0';
  400. n2=0;
  401. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  402. if ( windStr[n]==':' )n++; else return;
  403. text[n2]='\0';
  404.  
  405. n2=0;
  406. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  407. buf[n2]='\0';
  408. x=atoi(buf);
  409. if ( windStr[n]==':' )n++; else return;
  410. n2=0;
  411. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  412. buf[n2]='\0';
  413. y=atoi(buf);
  414. if ( windStr[n]==':' )n++; else return;
  415. n2=0;
  416. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  417. buf[n2]='\0';
  418. xmax=atoi(buf);
  419. if ( windStr[n]==':' )n++; else return;
  420. n2=0;
  421. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  422. buf[n2]='\0';
  423. ymax=atoi(buf);
  424. n++;
  425.  
  426. blocked=windStr[n]; n++, n++;
  427. updateSemaph=windStr[n]; n++, n++;
  428.  
  429. framestack[framedepth].x=framestack[framedepth-1].x+x;
  430. framestack[framedepth].y=framestack[framedepth-1].y+y;
  431.  
  432. x=framestack[framedepth].x;
  433. y=framestack[framedepth].y;
  434.  
  435. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax < xmax+x ?
  436. framestack[framedepth-1].xmax : xmax+x );
  437.  
  438. framestack[framedepth].ymax=( framestack[framedepth-1].ymax < ymax+y ?
  439. framestack[framedepth-1].ymax : ymax+y );
  440.  
  441. framestack[framedepth].seqstart=entry_p;
  442.  
  443. xmax=framestack[framedepth].xmax;
  444. ymax=framestack[framedepth].ymax;
  445. // max irrelevant?
  446. framedepth++;
  447.  
  448. printf("%s %d %d %d %d\n",varname,x,y,xmax,ymax), getch();
  449.  
  450.  
  451. unsigned int drawX, drawY;
  452.  
  453. drawX=x+1;
  454. while ( drawX < xmax )
  455. {
  456. drawY=y+1;
  457. while ( drawY < ymax )
  458. {
  459. ppix(drawX,drawY,' ',framedepth);
  460. drawY++;
  461.  
  462. }
  463. drawX++;
  464. }
  465.  
  466.  
  467. drawX=x;
  468. while ( drawX < xmax )
  469. {
  470. ppix(drawX,y,'#',framedepth);
  471.  
  472. ppix(drawX,ymax,'#',framedepth), drawX++;
  473.  
  474. }
  475.  
  476.  
  477. drawY=y;
  478. while ( drawY < ymax+1 )
  479. {
  480. ppix(x,drawY,'#',framedepth);
  481.  
  482. ppix(xmax,drawY,'#',framedepth), drawY++;
  483.  
  484. }
  485.  
  486. n2=0;
  487. while(n2 < strlen(text) && n2+x < xmax ) ppix(x+1+n2,y,text[n2],framedepth), n2++;
  488.  
  489.  
  490. }
  491.  
  492.  
  493. if ( type=='b' )
  494. {
  495. entry_p=n;
  496. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  497. n++;
  498. if ( windStr[n]==':' )n++; else return;
  499. n2=0;
  500. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  501. if ( windStr[n]==':' )n++; else return;
  502. varname[n2]='\0';
  503. n2=0;
  504. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  505. if ( windStr[n]==':' )n++; else return;
  506. text[n2]='\0';
  507.  
  508. n2=0;
  509. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  510. buf[n2]='\0';
  511. x=atoi(buf);
  512. if ( windStr[n]==':' )n++; else return;
  513. n2=0;
  514. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  515. buf[n2]='\0';
  516. y=atoi(buf);
  517. if ( windStr[n]==':' )n++; else return;
  518. n2=0;
  519. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  520. buf[n2]='\0';
  521. xmax=atoi(buf);
  522. if ( windStr[n]==':' )n++; else return;
  523. n2=0;
  524. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  525. buf[n2]='\0';
  526. ymax=atoi(buf);
  527. n++;
  528.  
  529. blocked=windStr[n]; n++, n++;
  530. updateSemaph=windStr[n]; n++, n++;
  531.  
  532. framestack[framedepth].x=framestack[framedepth-1].x+x;
  533. framestack[framedepth].y=framestack[framedepth-1].y+y;
  534.  
  535. x=framestack[framedepth].x;
  536. y=framestack[framedepth].y;
  537.  
  538.  
  539. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax < xmax+x ?
  540. framestack[framedepth-1].xmax : xmax+x );
  541.  
  542. framestack[framedepth].ymax=( framestack[framedepth-1].ymax < ymax+y ?
  543. framestack[framedepth-1].ymax : ymax+y );
  544.  
  545. framestack[framedepth].seqstart=entry_p;
  546.  
  547. xmax=framestack[framedepth].xmax;
  548. ymax=framestack[framedepth].ymax;
  549. framedepth++;
  550.  
  551. // max irrelevant?
  552.  
  553.  
  554. unsigned int drawX, drawY;
  555.  
  556.  
  557. drawX=x;
  558. while ( drawX < xmax )
  559. {
  560. drawY=y;
  561. while ( drawY < ymax )
  562. {
  563. ppix(drawX,drawY,'*',framedepth);
  564. drawY++;
  565.  
  566. }
  567. drawX++;
  568. }
  569.  
  570. n2=0;
  571. while(n2 < strlen(text) ) ppix(x+1+n2,y,text[n2],framedepth), n2++;
  572.  
  573. }
  574.  
  575.  
  576. if ( type=='t' )
  577. {
  578. entry_p=n;
  579. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  580. n++;
  581. if ( windStr[n]==':' )n++; else return;
  582. n2=0;
  583. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  584. if ( windStr[n]==':' )n++; else return;
  585. varname[n2]='\0';
  586. n2=0;
  587. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  588. if ( windStr[n]==':' )n++; else return;
  589. text[n2]='\0';
  590.  
  591. n2=0;
  592. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  593. buf[n2]='\0';
  594. x=atoi(buf);
  595. if ( windStr[n]==':' )n++; else return;
  596. n2=0;
  597. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  598. buf[n2]='\0';
  599. y=atoi(buf);
  600. if ( windStr[n]==':' )n++; else return;
  601. n2=0;
  602. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  603. buf[n2]='\0';
  604. xmax=atoi(buf);
  605. if ( windStr[n]==':' )n++; else return;
  606. n2=0;
  607. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  608. buf[n2]='\0';
  609. ymax=atoi(buf);
  610. n++;
  611.  
  612. blocked=windStr[n]; n++, n++;
  613. updateSemaph=windStr[n]; n++, n++;
  614.  
  615. framestack[framedepth].x=framestack[framedepth-1].x+x;
  616. framestack[framedepth].y=framestack[framedepth-1].y+y;
  617.  
  618. x=framestack[framedepth].x;
  619. y=framestack[framedepth].y;
  620.  
  621.  
  622. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax < xmax+x ?
  623. framestack[framedepth-1].xmax : xmax+x );
  624.  
  625. /*
  626. framestack[framedepth].ymax=( framestack[framedepth-1].ymax < y+1 ?
  627. framestack[framedepth-1].ymax : y+1 );
  628. */
  629. framestack[framedepth].seqstart=entry_p;
  630.  
  631. framedepth++;
  632.  
  633. // max irrelevant?
  634.  
  635.  
  636. unsigned int drawX, drawY;
  637.  
  638. obj_state edfield;
  639. edfield.x=x, edfield.y=y,
  640. edfield.xmax=xmax+x;
  641. edfield.ymax=ymax;
  642.  
  643.  
  644. drawX=x;
  645. drawY=y; if ( framestack[framedepth-1].ymax > framestack[framedepth-1].y)
  646. disp_edit_text(&edfield, framedepth);
  647. }
  648.  
  649.  
  650.  
  651.  
  652. }
  653.  
  654. }
  655.  
  656.  
  657.  
  658. void clearScreen()
  659. {
  660. int x=0, y=0;
  661. while ( y < 80 )
  662. {
  663. x=0;
  664. while ( x < 160 )
  665. {
  666. screen[x][y]=' ';
  667. screenz[x][y]=0;
  668. x++;
  669. }
  670. y++;
  671. }
  672. }
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679. int readback(char *identifier, obj_state *status)
  680. {
  681.  
  682.  
  683.  
  684. unsigned int type;
  685. unsigned char text[32];
  686. unsigned char varname[32];
  687. unsigned int n2=0;
  688. unsigned int x,y,xmax,ymax;
  689. unsigned int blocked;
  690. unsigned int updateSemaph;
  691. unsigned char buf[5];
  692. unsigned int entry_p, exit_p;
  693. int weisdown, layer;
  694. unsigned int xabs, yabs;
  695.  
  696. int n=0;
  697. weisdown=0;
  698.  
  699. signed int framepos;
  700. unsigned char identifiers[10][255];
  701. unsigned int ident_len=0;
  702. n=0;
  703.  
  704. identifiers[0][0]='\0';
  705. while ( identifier[n2]!='\0')
  706. {
  707. identifiers[ident_len][n]=identifier[n2];
  708. n2++ ,n++;
  709. if (identifier[n2]==':' || identifier[n2]=='\0')
  710. {
  711. identifiers[ident_len][n]='\0';
  712. ident_len++;
  713. if ( identifier[n2]=='\0') break; else n2++;
  714. n=0;
  715. }
  716.  
  717. }
  718.  
  719.  
  720. printf("%s suche ich", identifiers[0]);
  721.  
  722. n2=0;
  723.  
  724. framepos=-1;
  725.  
  726. n=1;
  727. framestack[0].firstheap=0;
  728.  
  729. while ( n < 20)
  730. {
  731.  
  732. framestack[n].firstheap=-1;
  733. n++;
  734. }
  735.  
  736. unsigned int ignore;
  737. ignore=0;
  738. layer=0;
  739. n=0;
  740.  
  741. while ( 1 )
  742. {
  743. type=windStr[n];
  744.  
  745. if ( type=='e')
  746. {
  747. framedepth--;
  748.  
  749. n++;
  750. exit_p=n;
  751. framestack[framedepth].seqend=exit_p;
  752.  
  753.  
  754. if ( weisdown==1&& framedepth <= layer
  755. && layer==ident_len) ignore=1;
  756. if ( framedepth==0) break;
  757.  
  758. }
  759. //else weisdown=0;
  760.  
  761. if ( type=='w' )
  762. {
  763. entry_p=n;
  764. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  765. n++;
  766. if ( windStr[n]==':' )n++; else return;
  767. n2=0;
  768. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  769. if ( windStr[n]==':' )n++; else return;
  770. varname[n2]='\0';
  771. n2=0;
  772. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  773. if ( windStr[n]==':' )n++; else return;
  774. text[n2]='\0';
  775.  
  776. n2=0;
  777. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  778. buf[n2]='\0';
  779. x=atoi(buf);
  780. if ( windStr[n]==':' )n++; else return;
  781. n2=0;
  782. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  783. buf[n2]='\0';
  784. y=atoi(buf);
  785. if ( windStr[n]==':' )n++; else return;
  786. n2=0;
  787. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  788. buf[n2]='\0';
  789. xmax=atoi(buf);
  790. if ( windStr[n]==':' )n++; else return;
  791. n2=0;
  792. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  793. buf[n2]='\0';
  794. ymax=atoi(buf);
  795. n++;
  796.  
  797. blocked=windStr[n]; n++, n++;
  798. updateSemaph=windStr[n]; n++, n++;
  799.  
  800. if ( ignore==0)
  801. {
  802. framestack[framedepth].x=framestack[framedepth-1].x+x;
  803. framestack[framedepth].y=framestack[framedepth-1].y+y;
  804. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax < xmax ?
  805. framestack[framedepth-1].xmax : xmax );
  806.  
  807. framestack[framedepth].ymax=( framestack[framedepth-1].ymax < ymax ?
  808. framestack[framedepth-1].ymax : ymax );
  809.  
  810. framestack[framedepth].seqstart=entry_p;
  811. framestack[framedepth].firstheap=n;
  812.  
  813. xabs=x, yabs=y;
  814.  
  815. x=framestack[framedepth].x;
  816. y=framestack[framedepth].y;
  817. // max irrelevant?
  818. framedepth++;
  819.  
  820.  
  821. unsigned int drawX, drawY;
  822.  
  823. drawX=x;
  824.  
  825.  
  826. if ( layer <= ident_len && framedepth-1 <= ident_len&& framedepth-2==layer)
  827. if ( strcmp(identifiers[layer],varname)==0 )
  828. {
  829. //windStr[n-2]='1'; //Semaphore gesetzt
  830.  
  831. status->type='w';
  832. strcpy ( status->text, text), strcpy( status->varname, varname);
  833. status->x=x, status->y=y,
  834. status->xmax=xmax, status->ymax=ymax,
  835. status->xabs=xabs, status->yabs=yabs;
  836.  
  837. status->blocked=blocked, status->command=updateSemaph;
  838.  
  839.  
  840. // printf(">>%s geblickt<<", varname), getch();
  841.  
  842. weisdown=1;
  843. layer=framedepth-1;
  844. framepos=framedepth-1;
  845.  
  846. }
  847.  
  848. }
  849. //else
  850. //framedepth--;
  851. //printf("%s %d %d %d %d %d\n",varname, x,y,xmax,ymax, weisdown), getch();
  852.  
  853.  
  854. }
  855.  
  856.  
  857. if ( type=='b' )
  858. {
  859. entry_p=n;
  860. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  861. n++;
  862. if ( windStr[n]==':' )n++; else return;
  863. n2=0;
  864. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  865. if ( windStr[n]==':' )n++; else return;
  866. varname[n2]='\0';
  867.  
  868. n2=0;
  869. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  870. if ( windStr[n]==':' )n++; else return;
  871. text[n2]='\0';
  872.  
  873. n2=0;
  874. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  875. buf[n2]='\0';
  876. x=atoi(buf);
  877. if ( windStr[n]==':' )n++; else return;
  878. n2=0;
  879. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  880. buf[n2]='\0';
  881. y=atoi(buf);
  882. if ( windStr[n]==':' )n++; else return;
  883. n2=0;
  884. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  885. buf[n2]='\0';
  886. xmax=atoi(buf);
  887. if ( windStr[n]==':' )n++; else return;
  888. n2=0;
  889. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  890. buf[n2]='\0';
  891. ymax=atoi(buf);
  892. n++;
  893.  
  894. blocked=windStr[n]; n++, n++;
  895. updateSemaph=windStr[n]; n++, n++;
  896.  
  897. if ( ignore==0)
  898. {
  899. framestack[framedepth].x=framestack[framedepth-1].x+x;
  900. framestack[framedepth].y=framestack[framedepth-1].y+y;
  901. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax+x < xmax ?
  902. framestack[framedepth-1].xmax+x : xmax );
  903.  
  904. framestack[framedepth].ymax=( framestack[framedepth-1].ymax+y < ymax ?
  905. framestack[framedepth-1].ymax+y : ymax );
  906.  
  907. framestack[framedepth].seqstart=entry_p;
  908. framestack[framedepth].firstheap=n;
  909.  
  910. xabs=x, yabs=y;
  911.  
  912. x=framestack[framedepth].x;
  913. y=framestack[framedepth].y;
  914. // max irrelevant?
  915.  
  916. framedepth++;
  917.  
  918.  
  919. unsigned int drawX, drawY;
  920.  
  921. if ( layer <= ident_len && framedepth-1 <= ident_len&& framedepth-2==layer)
  922. if ( strcmp(identifiers[layer],varname)==0 )
  923. {
  924. // windStr[n-2]='1'; //Semaphore gesetzt
  925.  
  926. status->type='b';
  927. strcpy ( status->text, text), strcpy( status->varname, varname);
  928. status->x=x, status->y=y,
  929. status->xmax=xmax, status->ymax=ymax,
  930. status->xabs=xabs, status->yabs=yabs;
  931.  
  932. status->blocked=blocked, status->command=updateSemaph;
  933.  
  934. //printf("Button geklickt"), getch();
  935. framepos=framedepth-1;
  936. layer=framedepth-1;
  937. weisdown=1;
  938. }
  939. //else
  940. //framedepth--;
  941.  
  942. }
  943.  
  944.  
  945. }
  946.  
  947.  
  948. if ( type=='t' )
  949. {
  950. entry_p=n;
  951. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  952. n++;
  953. if ( windStr[n]==':' )n++; else return;
  954. n2=0;
  955. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  956. if ( windStr[n]==':' )n++; else return;
  957. varname[n2]='\0';
  958.  
  959. n2=0;
  960. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  961. if ( windStr[n]==':' )n++; else return;
  962. text[n2]='\0';
  963.  
  964. n2=0;
  965. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  966. buf[n2]='\0';
  967. x=atoi(buf);
  968. if ( windStr[n]==':' )n++; else return;
  969. n2=0;
  970. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  971. buf[n2]='\0';
  972. y=atoi(buf);
  973. if ( windStr[n]==':' )n++; else return;
  974. n2=0;
  975. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  976. buf[n2]='\0';
  977. xmax=atoi(buf);
  978. if ( windStr[n]==':' )n++; else return;
  979. n2=0;
  980. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  981. buf[n2]='\0';
  982. ymax=atoi(buf);
  983. n++;
  984.  
  985. blocked=windStr[n]; n++, n++;
  986. updateSemaph=windStr[n]; n++, n++;
  987.  
  988. if ( ignore==0)
  989. {
  990. unsigned long xmaxabs, ymaxabs;
  991.  
  992. xmaxabs=xmax, ymaxabs=ymax;
  993.  
  994. framestack[framedepth].x=framestack[framedepth-1].x+x;
  995. framestack[framedepth].y=framestack[framedepth-1].y+y;
  996. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax+x < xmax ?
  997. framestack[framedepth-1].xmax+x : xmax );
  998.  
  999. framestack[framedepth].ymax=( framestack[framedepth-1].ymax+y < ymax ?
  1000. framestack[framedepth-1].ymax+y : ymax );
  1001.  
  1002. framestack[framedepth].seqstart=entry_p;
  1003. framestack[framedepth].firstheap=n;
  1004.  
  1005. xabs=x, yabs=y;
  1006.  
  1007. x=framestack[framedepth].x;
  1008. y=framestack[framedepth].y;
  1009. // max irrelevant?
  1010.  
  1011. framedepth++;
  1012.  
  1013.  
  1014. unsigned int drawX, drawY;
  1015.  
  1016. if ( layer <= ident_len && framedepth-1 <= ident_len&& framedepth-2==layer)
  1017. if ( strcmp(identifiers[layer],varname)==0 )
  1018. {
  1019. // windStr[n-2]='1'; //Semaphore gesetzt
  1020.  
  1021. status->type='t';
  1022. strcpy ( status->text, text), strcpy( status->varname, varname);
  1023. status->x=x, status->y=y,
  1024. status->xmax=xmax, status->ymax=ymax,
  1025. status->xmaxabs=xmaxabs, status->ymaxabs=ymaxabs;
  1026.  
  1027. status->blocked=blocked-0x30, status->command=updateSemaph-0x30;
  1028.  
  1029. //printf("Button geklickt"), getch();
  1030. framepos=framedepth-1;
  1031. layer=framedepth-1;
  1032. weisdown=1;
  1033. }
  1034.  
  1035. }
  1036.  
  1037. }
  1038.  
  1039. }
  1040.  
  1041.  
  1042.  
  1043.  
  1044. // windStr[n-3]='1';
  1045.  
  1046. //framestack[framedepth].seqend=n;
  1047.  
  1048.  
  1049. if ( weisdown==0 ) return 1;
  1050. if ( layer!=ident_len) return 1;
  1051.  
  1052. return 0;
  1053.  
  1054.  
  1055.  
  1056. }
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062. int putinfront(char *identifier, signed int layers) // wenn -1, voll
  1063. {
  1064.  
  1065.  
  1066. unsigned int type;
  1067. unsigned char text[32];
  1068. unsigned char varname[32];
  1069. unsigned int n2=0;
  1070. unsigned int x,y,xmax,ymax;
  1071. unsigned int blocked;
  1072. unsigned int updateSemaph;
  1073. unsigned char buf[5];
  1074. unsigned int entry_p, exit_p;
  1075. int weisdown, layer;
  1076. int n=0;
  1077. weisdown=0;
  1078.  
  1079. signed int framepos;
  1080. unsigned char identifiers[10][255];
  1081. unsigned int ident_len=0;
  1082. n=0;
  1083.  
  1084. identifiers[0][0]='\0';
  1085. while ( identifier[n2]!='\0')
  1086. {
  1087. identifiers[ident_len][n]=identifier[n2];
  1088. n2++ ,n++;
  1089. if (identifier[n2]==':' || identifier[n2]=='\0')
  1090. {
  1091. identifiers[ident_len][n]='\0';
  1092. ident_len++;
  1093. if ( identifier[n2]=='\0') break; else n2++;
  1094. n=0;
  1095. }
  1096.  
  1097. }
  1098.  
  1099. n2=0;
  1100.  
  1101. framepos=-1;
  1102.  
  1103. n=1;
  1104. framestack[0].firstheap=0;
  1105.  
  1106. while ( n < 20)
  1107. {
  1108.  
  1109. framestack[n].firstheap=-1;
  1110. n++;
  1111. }
  1112.  
  1113. unsigned int ignore;
  1114. ignore=0;
  1115. layer=0;
  1116. n=0;
  1117.  
  1118. // printf("Gehe in putinfront()'s Hauptschleife"), getch();
  1119.  
  1120. while ( 1 )
  1121. {
  1122. type=windStr[n];
  1123.  
  1124. if ( type=='e')
  1125. {
  1126. framedepth--;
  1127.  
  1128. n++;
  1129. exit_p=n;
  1130. framestack[framedepth].seqend=exit_p;
  1131.  
  1132.  
  1133. if ( weisdown==1&& framedepth <= layer
  1134. && layer==ident_len) ignore=1;
  1135. if ( framedepth==0) break;
  1136.  
  1137. }
  1138. //else weisdown=0;
  1139.  
  1140. if ( type=='w' )
  1141. {
  1142. entry_p=n;
  1143. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  1144. n++;
  1145. if ( windStr[n]==':' )n++; else return;
  1146. n2=0;
  1147. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  1148. if ( windStr[n]==':' )n++; else return;
  1149. varname[n2]='\0';
  1150. n2=0;
  1151. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  1152. if ( windStr[n]==':' )n++; else return;
  1153. text[n2]='\0';
  1154.  
  1155. n2=0;
  1156. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1157. buf[n2]='\0';
  1158. x=atoi(buf);
  1159. if ( windStr[n]==':' )n++; else return;
  1160. n2=0;
  1161. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1162. buf[n2]='\0';
  1163. y=atoi(buf);
  1164. if ( windStr[n]==':' )n++; else return;
  1165. n2=0;
  1166. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1167. buf[n2]='\0';
  1168. xmax=atoi(buf);
  1169. if ( windStr[n]==':' )n++; else return;
  1170. n2=0;
  1171. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1172. buf[n2]='\0';
  1173. ymax=atoi(buf);
  1174. n++;
  1175.  
  1176. blocked=windStr[n]; n++, n++;
  1177. updateSemaph=windStr[n]; n++, n++;
  1178.  
  1179. if ( ignore==0)
  1180. {
  1181. framestack[framedepth].x=framestack[framedepth-1].x+x;
  1182. framestack[framedepth].y=framestack[framedepth-1].y+y;
  1183. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax < xmax ?
  1184. framestack[framedepth-1].xmax : xmax );
  1185.  
  1186. framestack[framedepth].ymax=( framestack[framedepth-1].ymax < ymax ?
  1187. framestack[framedepth-1].ymax : ymax );
  1188.  
  1189. framestack[framedepth].seqstart=entry_p;
  1190. framestack[framedepth].firstheap=n;
  1191.  
  1192. x=framestack[framedepth].x;
  1193. y=framestack[framedepth].y;
  1194. // max irrelevant?
  1195. framedepth++;
  1196.  
  1197.  
  1198. unsigned int drawX, drawY;
  1199.  
  1200. drawX=x;
  1201.  
  1202.  
  1203. if ( layer <= ident_len && framedepth-1 <= ident_len&& framedepth-2==layer)
  1204. if ( strcmp(identifiers[layer],varname)==0 )
  1205. {
  1206. //windStr[n-2]='1'; //Semaphore gesetzt
  1207.  
  1208. // printf(">>%s geklickt<<", varname), getch();
  1209.  
  1210. weisdown=1;
  1211. layer=framedepth-1;
  1212. framepos=framedepth-1;
  1213.  
  1214. }
  1215.  
  1216. }
  1217. //else
  1218. //framedepth--;
  1219. // printf("%s %d %d %d %d %d\n",varname, x,y,xmax,ymax, weisdown), getch();
  1220.  
  1221.  
  1222. }
  1223.  
  1224.  
  1225. if ( type=='b' )
  1226. {
  1227. entry_p=n;
  1228. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  1229. n++;
  1230. if ( windStr[n]==':' )n++; else return;
  1231. n2=0;
  1232. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  1233. if ( windStr[n]==':' )n++; else return;
  1234. varname[n2]='\0';
  1235.  
  1236. n2=0;
  1237. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  1238. if ( windStr[n]==':' )n++; else return;
  1239. text[n2]='\0';
  1240.  
  1241. n2=0;
  1242. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1243. buf[n2]='\0';
  1244. x=atoi(buf);
  1245. if ( windStr[n]==':' )n++; else return;
  1246. n2=0;
  1247. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1248. buf[n2]='\0';
  1249. y=atoi(buf);
  1250. if ( windStr[n]==':' )n++; else return;
  1251. n2=0;
  1252. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1253. buf[n2]='\0';
  1254. xmax=atoi(buf);
  1255. if ( windStr[n]==':' )n++; else return;
  1256. n2=0;
  1257. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1258. buf[n2]='\0';
  1259. ymax=atoi(buf);
  1260. n++;
  1261.  
  1262. blocked=windStr[n]; n++, n++;
  1263. updateSemaph=windStr[n]; n++, n++;
  1264.  
  1265. if ( ignore==0)
  1266. {
  1267. framestack[framedepth].x=framestack[framedepth-1].x+x;
  1268. framestack[framedepth].y=framestack[framedepth-1].y+y;
  1269. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax+x < xmax ?
  1270. framestack[framedepth-1].xmax+x : xmax );
  1271.  
  1272. framestack[framedepth].ymax=( framestack[framedepth-1].ymax+y < ymax ?
  1273. framestack[framedepth-1].ymax+y : ymax );
  1274.  
  1275. framestack[framedepth].seqstart=entry_p;
  1276. framestack[framedepth].firstheap=n;
  1277.  
  1278.  
  1279. x=framestack[framedepth].x;
  1280. y=framestack[framedepth].y;
  1281. // max irrelevant?
  1282.  
  1283. framedepth++;
  1284.  
  1285.  
  1286. unsigned int drawX, drawY;
  1287.  
  1288. if ( layer <= ident_len && framedepth-1 <= ident_len&& framedepth-2==layer)
  1289. if ( strcmp(identifiers[layer],varname)==0 )
  1290. {
  1291. // windStr[n-2]='1'; //Semaphore gesetzt
  1292.  
  1293.  
  1294. // printf("Button geklickt"), getch();
  1295. framepos=framedepth-1;
  1296. layer=framedepth-1;
  1297. weisdown=1;
  1298. }
  1299. //else
  1300. //framedepth--;
  1301.  
  1302. }
  1303.  
  1304.  
  1305. }
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311. if ( type=='t' )
  1312. {
  1313. entry_p=n;
  1314. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  1315. n++;
  1316. if ( windStr[n]==':' )n++; else return;
  1317. n2=0;
  1318. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  1319. if ( windStr[n]==':' )n++; else return;
  1320. varname[n2]='\0';
  1321.  
  1322. n2=0;
  1323. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  1324. if ( windStr[n]==':' )n++; else return;
  1325. text[n2]='\0';
  1326.  
  1327. n2=0;
  1328. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1329. buf[n2]='\0';
  1330. x=atoi(buf);
  1331. if ( windStr[n]==':' )n++; else return;
  1332. n2=0;
  1333. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1334. buf[n2]='\0';
  1335. y=atoi(buf);
  1336. if ( windStr[n]==':' )n++; else return;
  1337. n2=0;
  1338. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1339. buf[n2]='\0';
  1340. xmax=atoi(buf);
  1341. if ( windStr[n]==':' )n++; else return;
  1342. n2=0;
  1343. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1344. buf[n2]='\0';
  1345. ymax=atoi(buf);
  1346. n++;
  1347.  
  1348. blocked=windStr[n]; n++, n++;
  1349. updateSemaph=windStr[n]; n++, n++;
  1350.  
  1351. if ( ignore==0)
  1352. {
  1353. framestack[framedepth].x=framestack[framedepth-1].x+x;
  1354. framestack[framedepth].y=framestack[framedepth-1].y+y;
  1355. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax+x < xmax ?
  1356. framestack[framedepth-1].xmax+x : xmax );
  1357.  
  1358. framestack[framedepth].ymax=( framestack[framedepth-1].ymax+y < ymax ?
  1359. framestack[framedepth-1].ymax+y : ymax );
  1360.  
  1361. framestack[framedepth].seqstart=entry_p;
  1362. framestack[framedepth].firstheap=n;
  1363.  
  1364.  
  1365. x=framestack[framedepth].x;
  1366. y=framestack[framedepth].y;
  1367. // max irrelevant?
  1368.  
  1369. framedepth++;
  1370.  
  1371.  
  1372. unsigned int drawX, drawY;
  1373.  
  1374. if ( layer <= ident_len && framedepth-1 <= ident_len&& framedepth-2==layer)
  1375. if ( strcmp(identifiers[layer],varname)==0 )
  1376. {
  1377. // windStr[n-2]='1'; //Semaphore gesetzt
  1378.  
  1379.  
  1380. // printf("Button geklickt"), getch();
  1381. framepos=framedepth-1;
  1382. layer=framedepth-1;
  1383. weisdown=1;
  1384. }
  1385. //else
  1386. //framedepth--;
  1387.  
  1388. }
  1389.  
  1390.  
  1391. }
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397. }
  1398.  
  1399.  
  1400.  
  1401.  
  1402. // windStr[n-3]='1';
  1403.  
  1404. //framestack[framedepth].seqend=n;
  1405.  
  1406.  
  1407. if ( weisdown==0 ) return 1;
  1408. if ( layer!=ident_len) return 1;
  1409.  
  1410.  
  1411. framedepth=framepos;
  1412. unsigned char copied[1024];
  1413.  
  1414.  
  1415. unsigned int length;
  1416.  
  1417. while ( framedepth > 0)
  1418. {
  1419.  
  1420.  
  1421. if ( framestack[framedepth].seqend-framestack[framedepth].seqstart >= 0 )
  1422. {
  1423. strncpy(copied,windStr+framestack[framedepth].seqstart,framestack[framedepth].seqend-framestack[framedepth].seqstart);
  1424. copied[framestack[framedepth].seqend-framestack[framedepth].seqstart]='\0';
  1425. }
  1426. else copied[0]='\0';
  1427.  
  1428. length=strlen(windStr);
  1429. strcpy(windStr+framestack[framedepth].seqstart, windStr+framestack[framedepth].seqend);
  1430. memcpy(windStr+framestack[framedepth-1].firstheap+strlen(copied), windStr+framestack[framedepth-1].firstheap, length);
  1431. memcpy(windStr+framestack[framedepth-1].firstheap, copied, strlen(copied));
  1432.  
  1433.  
  1434. // printf("app:%s\ncopied:%s" , windStr,copied ), getch();
  1435.  
  1436.  
  1437.  
  1438.  
  1439. framedepth--;
  1440. }
  1441.  
  1442. return 0;
  1443. }
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452. #define CHANGE 0
  1453. #define INSERT 1
  1454. #define DELETE 2
  1455.  
  1456. int update(unsigned char *identifier, obj_state *status, int chinode)
  1457. {
  1458. unsigned int type;
  1459. unsigned char text[32];
  1460. unsigned char varname[32];
  1461. unsigned int n2=0;
  1462. unsigned long int x,y,xmax,ymax;
  1463. unsigned int blocked;
  1464. unsigned int updateSemaph;
  1465. unsigned char buf[5];
  1466. unsigned int entry_p, exit_p;
  1467. int weisdown, layer;
  1468. unsigned int xabs, yabs;
  1469.  
  1470. int n=0;
  1471. weisdown=0;
  1472.  
  1473. signed int framepos;
  1474. unsigned char identifiers[10][255];
  1475. unsigned int ident_len=0;
  1476. n=0;
  1477.  
  1478. identifiers[0][0]='\0';
  1479. while ( identifier[n2]!='\0')
  1480. {
  1481. identifiers[ident_len][n]=identifier[n2];
  1482. n2++ ,n++;
  1483. if (identifier[n2]==':' || identifier[n2]=='\0')
  1484. {
  1485. identifiers[ident_len][n]='\0';
  1486. ident_len++;
  1487. if ( identifier[n2]=='\0') break; else n2++;
  1488. n=0;
  1489. }
  1490.  
  1491. }
  1492.  
  1493. n2=0;
  1494.  
  1495. framepos=-1;
  1496.  
  1497. n=1;
  1498. framestack[0].firstheap=0;
  1499.  
  1500. while ( n < 20)
  1501. {
  1502.  
  1503. framestack[n].firstheap=-1;
  1504. n++;
  1505. }
  1506.  
  1507. unsigned int ignore;
  1508. ignore=0;
  1509. layer=0;
  1510. n=0;
  1511.  
  1512. while ( 1 )
  1513. {
  1514. type=windStr[n];
  1515.  
  1516. if ( type=='e')
  1517. {
  1518. framedepth--;
  1519.  
  1520. n++;
  1521. exit_p=n;
  1522. framestack[framedepth].seqend=exit_p;
  1523.  
  1524.  
  1525. if ( weisdown==1&& framedepth <= layer &&
  1526. layer==ident_len ) ignore=1;
  1527. if ( framedepth==0) break;
  1528.  
  1529. }
  1530. //else weisdown=0;
  1531.  
  1532. if ( type=='w' )
  1533. {
  1534. entry_p=n;
  1535. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  1536. n++;
  1537. if ( windStr[n]==':' )n++; else return;
  1538. n2=0;
  1539. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  1540. if ( windStr[n]==':' )n++; else return;
  1541. varname[n2]='\0';
  1542. n2=0;
  1543. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  1544. if ( windStr[n]==':' )n++; else return;
  1545. text[n2]='\0';
  1546.  
  1547. n2=0;
  1548. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1549. buf[n2]='\0';
  1550. x=atoi(buf);
  1551. if ( windStr[n]==':' )n++; else return;
  1552. n2=0;
  1553. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1554. buf[n2]='\0';
  1555. y=atoi(buf);
  1556. if ( windStr[n]==':' )n++; else return;
  1557. n2=0;
  1558. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1559. buf[n2]='\0';
  1560. xmax=atoi(buf);
  1561. if ( windStr[n]==':' )n++; else return;
  1562. n2=0;
  1563. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1564. buf[n2]='\0';
  1565. ymax=atoi(buf);
  1566. n++;
  1567.  
  1568. blocked=windStr[n]; n++, n++;
  1569. updateSemaph=windStr[n]; n++, n++;
  1570.  
  1571. if ( ignore==0)
  1572. {
  1573.  
  1574. unsigned int xmaxabs, ymaxabs;
  1575. xabs=x, yabs=y;
  1576. xmaxabs=xmax, ymaxabs=ymax;
  1577.  
  1578. framestack[framedepth].x=framestack[framedepth-1].x+x;
  1579. framestack[framedepth].y=framestack[framedepth-1].y+y;
  1580. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax < xmax ?
  1581. framestack[framedepth-1].xmax : xmax );
  1582.  
  1583. framestack[framedepth].ymax=( framestack[framedepth-1].ymax < ymax ?
  1584. framestack[framedepth-1].ymax : ymax );
  1585.  
  1586. framestack[framedepth].seqstart=entry_p;
  1587. framestack[framedepth].firstheap=n;
  1588.  
  1589.  
  1590. x=framestack[framedepth].x;
  1591. y=framestack[framedepth].y;
  1592. // max irrelevant?
  1593. framedepth++;
  1594.  
  1595.  
  1596. unsigned int drawX, drawY;
  1597.  
  1598. drawX=x;
  1599.  
  1600.  
  1601. if ( layer <= ident_len && framedepth-1 <= ident_len&& framedepth-2==layer)
  1602. if ( strcmp(identifiers[layer],varname)==0 )
  1603. {
  1604. //windStr[n-2]='1'; //Semaphore gesetzt
  1605. if ( chinode!= CHANGE && chinode!=INSERT)
  1606. {
  1607. status->type='w';
  1608. strcpy ( status->text, text), strcpy( status->varname, varname);
  1609. status->x=x, status->y=y,
  1610. status->xmax=xmaxabs, status->ymax=ymaxabs,
  1611. status->xabs=xabs, status->yabs=yabs;
  1612.  
  1613. status->blocked=blocked, status->command=updateSemaph;
  1614. }
  1615.  
  1616. // printf(">>%s geklickt<<", varname), getch();
  1617.  
  1618. weisdown=1;
  1619. layer=framedepth-1;
  1620. framepos=framedepth-1;
  1621.  
  1622. }
  1623.  
  1624. }
  1625. //else
  1626. //framedepth--;
  1627. // printf("%s %d %d %d %d %d\n",varname, x,y,xmax,ymax, weisdown), getch();
  1628.  
  1629.  
  1630. }
  1631.  
  1632.  
  1633. if ( type=='b' )
  1634. {
  1635. entry_p=n;
  1636. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  1637. n++;
  1638. if ( windStr[n]==':' )n++; else return;
  1639. n2=0;
  1640. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  1641. if ( windStr[n]==':' )n++; else return;
  1642. varname[n2]='\0';
  1643.  
  1644. n2=0;
  1645. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  1646. if ( windStr[n]==':' )n++; else return;
  1647. text[n2]='\0';
  1648.  
  1649. n2=0;
  1650. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1651. buf[n2]='\0';
  1652. x=atoi(buf);
  1653. if ( windStr[n]==':' )n++; else return;
  1654. n2=0;
  1655. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1656. buf[n2]='\0';
  1657. y=atoi(buf);
  1658. if ( windStr[n]==':' )n++; else return;
  1659. n2=0;
  1660. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1661. buf[n2]='\0';
  1662. xmax=atoi(buf);
  1663. if ( windStr[n]==':' )n++; else return;
  1664. n2=0;
  1665. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1666. buf[n2]='\0';
  1667. ymax=atoi(buf);
  1668. n++;
  1669.  
  1670. blocked=windStr[n]; n++, n++;
  1671. updateSemaph=windStr[n]; n++, n++;
  1672.  
  1673. if ( ignore==0)
  1674. {
  1675.  
  1676. unsigned int xmaxabs, ymaxabs;
  1677. xabs=x, yabs=y;
  1678. xmaxabs=xmax, ymaxabs=ymax;
  1679.  
  1680. framestack[framedepth].x=framestack[framedepth-1].x+x;
  1681. framestack[framedepth].y=framestack[framedepth-1].y+y;
  1682. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax+x < xmax ?
  1683. framestack[framedepth-1].xmax+x : xmax );
  1684.  
  1685. framestack[framedepth].ymax=( framestack[framedepth-1].ymax+y < ymax ?
  1686. framestack[framedepth-1].ymax+y : ymax );
  1687.  
  1688. framestack[framedepth].seqstart=entry_p;
  1689. framestack[framedepth].firstheap=n;
  1690.  
  1691.  
  1692. x=framestack[framedepth].x;
  1693. y=framestack[framedepth].y;
  1694. // max irrelevant?
  1695.  
  1696. framedepth++;
  1697.  
  1698.  
  1699. unsigned int drawX, drawY;
  1700.  
  1701. if ( layer <= ident_len && framedepth-1 <= ident_len&& framedepth-2==layer)
  1702. if ( strcmp(identifiers[layer],varname)==0 )
  1703. {
  1704. // windStr[n-2]='1'; //Semaphore gesetzt
  1705.  
  1706. if ( chinode!= CHANGE && chinode != INSERT)
  1707. {
  1708.  
  1709. status->type='b';
  1710.  
  1711. strcpy ( status->text, text), strcpy( status->varname, varname);
  1712. status->x=x, status->y=y,
  1713. status->xmax=xmaxabs, status->ymax=ymaxabs,
  1714. status->xabs=xabs, status->yabs=yabs;
  1715.  
  1716. status->blocked=blocked, status->command=updateSemaph;
  1717. }
  1718.  
  1719. // printf("Button geklickt"), getch();
  1720. framepos=framedepth-1;
  1721. layer=framedepth-1;
  1722. weisdown=1;
  1723. }
  1724. //else
  1725. //framedepth--;
  1726.  
  1727. }
  1728.  
  1729.  
  1730. }
  1731.  
  1732.  
  1733.  
  1734. if ( type=='t' )
  1735. {
  1736. entry_p=n;
  1737. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  1738. n++;
  1739. if ( windStr[n]==':' )n++; else return;
  1740. n2=0;
  1741. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  1742. if ( windStr[n]==':' )n++; else return;
  1743. varname[n2]='\0';
  1744.  
  1745. n2=0;
  1746. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  1747. if ( windStr[n]==':' )n++; else return;
  1748. text[n2]='\0';
  1749.  
  1750. n2=0;
  1751. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1752. buf[n2]='\0';
  1753. x=atoi(buf);
  1754. if ( windStr[n]==':' )n++; else return;
  1755. n2=0;
  1756. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1757. buf[n2]='\0';
  1758. y=atoi(buf);
  1759. if ( windStr[n]==':' )n++; else return;
  1760. n2=0;
  1761. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1762. buf[n2]='\0';
  1763. xmax=atoi(buf);
  1764. if ( windStr[n]==':' )n++; else return;
  1765. n2=0;
  1766. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  1767. buf[n2]='\0';
  1768. ymax=atoi(buf);
  1769. n++;
  1770.  
  1771. blocked=windStr[n]; n++, n++;
  1772. updateSemaph=windStr[n]; n++, n++;
  1773.  
  1774. if ( ignore==0)
  1775. {
  1776.  
  1777. unsigned long int xmaxabs, ymaxabs;
  1778. xabs=x, yabs=y;
  1779. xmaxabs=xmax, ymaxabs=ymax;
  1780.  
  1781. framestack[framedepth].x=framestack[framedepth-1].x+x;
  1782. framestack[framedepth].y=framestack[framedepth-1].y+y;
  1783. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax+x < xmax ?
  1784. framestack[framedepth-1].xmax+x : xmax );
  1785.  
  1786. framestack[framedepth].ymax=ymax; //( framestack[framedepth-1].ymax+y < ymax ?
  1787. // framestack[framedepth-1].ymax+y : ymax );
  1788.  
  1789. framestack[framedepth].seqstart=entry_p;
  1790. framestack[framedepth].firstheap=n;
  1791.  
  1792.  
  1793. x=framestack[framedepth].x;
  1794. y=framestack[framedepth].y;
  1795. // max irrelevant?
  1796.  
  1797. framedepth++;
  1798.  
  1799.  
  1800. unsigned int drawX, drawY;
  1801.  
  1802. if ( layer <= ident_len && framedepth-1 <= ident_len&& framedepth-2==layer)
  1803. if ( strcmp(identifiers[layer],varname)==0 )
  1804. {
  1805. // windStr[n-2]='1'; //Semaphore gesetzt
  1806.  
  1807. if ( chinode!= CHANGE && chinode != INSERT)
  1808. {
  1809.  
  1810. status->type='t';
  1811.  
  1812. strcpy ( status->text, text), strcpy( status->varname, varname);
  1813. status->x=x, status->y=y,
  1814. status->xmax=xmaxabs, status->ymax=ymaxabs,
  1815. status->xabs=xabs, status->yabs=yabs;
  1816.  
  1817. status->blocked=blocked, status->command=updateSemaph;
  1818. }
  1819.  
  1820. // printf("Button geklickt"), getch();
  1821. framepos=framedepth-1;
  1822. layer=framedepth-1;
  1823. weisdown=1;
  1824. }
  1825. //else
  1826. //framedepth--;
  1827.  
  1828. }
  1829.  
  1830.  
  1831. }
  1832.  
  1833.  
  1834.  
  1835.  
  1836. }
  1837.  
  1838.  
  1839. if ( weisdown==0 ) return 1;
  1840. if ( layer!=ident_len) return 1;
  1841.  
  1842.  
  1843. framedepth=framepos;
  1844. unsigned char copied[1024];
  1845.  
  1846.  
  1847. unsigned char converted[255];
  1848.  
  1849. copied[0]='\0';
  1850.  
  1851. if ( chinode==CHANGE|| chinode==INSERT)
  1852. {
  1853. buildstring(copied, status);
  1854.  
  1855.  
  1856. // schauen, ob noch eine Aufwerfung folgt!!
  1857. }
  1858.  
  1859. unsigned char windBak[1024];
  1860.  
  1861. if ( chinode==DELETE)
  1862. {
  1863.  
  1864. strcpy ( windBak,windStr+framestack[layer].seqend);
  1865.  
  1866.  
  1867.  
  1868. strcpy(windStr+framestack[layer].seqstart, copied);
  1869. strcat(windStr, windBak );
  1870.  
  1871. }
  1872. else
  1873. if ( chinode== INSERT )
  1874. {
  1875. strcat(copied,"e"); // das muss nicht sein, da nicht zwingend vorne!
  1876. strcpy ( windBak,windStr+framestack[layer].firstheap);
  1877. strcpy(windStr+framestack[layer].firstheap, copied);
  1878. strcat(windStr, windBak );
  1879.  
  1880. }
  1881. else
  1882. if ( chinode== CHANGE )
  1883. {
  1884. strcpy ( windBak,windStr+framestack[layer].firstheap);
  1885. strcpy(windStr+framestack[layer].seqstart, copied);
  1886. strcat(windStr, windBak );
  1887.  
  1888. }
  1889.  
  1890.  
  1891. // printf("app:%s\ncopied:%s" , windStr,copied ), getch();
  1892.  
  1893.  
  1894. return 0;
  1895.  
  1896.  
  1897.  
  1898.  
  1899. // windStr[n-3]='1';
  1900.  
  1901. //framestack[framedepth].seqend=n;
  1902.  
  1903.  
  1904.  
  1905. }
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915. void get_input(void)
  1916. {
  1917.  
  1918. unsigned int cmd=0;
  1919. obj_state obj_input;
  1920. unsigned char c;
  1921.  
  1922.  
  1923. if ( kbhit())
  1924. switch ( (c=getch()) )
  1925. {
  1926. case 'u': if ( cursor[1]> 0) cursor[1]--; break;
  1927. case 'j': if ( cursor[1]< 80) cursor[1]++; break;
  1928. case 'h': if ( cursor[0]> 0) cursor[0]--; break;
  1929. case 'k': if ( cursor[0]< 160) cursor[0]++; break;
  1930. case 'l': cmd=1;
  1931. default: if ( c >='A' && c <= 'Z') cmd=2; break;
  1932.  
  1933. }
  1934.  
  1935. if ( cmd==1||cmd==2)
  1936. {
  1937.  
  1938.  
  1939.  
  1940. unsigned int type;
  1941. unsigned char text[32];
  1942. unsigned char varname[32];
  1943. unsigned int n2=0;
  1944. unsigned int x,y,xmax,ymax;
  1945. unsigned int blocked;
  1946. unsigned int updateSemaph;
  1947. unsigned char buf[5];
  1948. unsigned int entry_p, exit_p;
  1949. int weisdown, layer;
  1950. int n=0;
  1951. weisdown=0;
  1952.  
  1953. signed int framepos;
  1954.  
  1955. framepos=-1;
  1956.  
  1957. n=1;
  1958. framestack[0].firstheap=0;
  1959.  
  1960. while ( n < 20)
  1961. {
  1962.  
  1963. framestack[n].firstheap=-1;
  1964. n++;
  1965. }
  1966.  
  1967. unsigned int ignore;
  1968. ignore=0;
  1969. layer=0;
  1970. n=0;
  1971.  
  1972. while ( 1 )
  1973. {
  1974. type=windStr[n];
  1975.  
  1976. if ( type=='e')
  1977. {
  1978. framedepth--;
  1979.  
  1980. n++;
  1981. exit_p=n;
  1982. framestack[framedepth].seqend=exit_p;
  1983.  
  1984.  
  1985. if ( weisdown==1&& framedepth < layer) ignore=1;
  1986. if ( framedepth==0) break;
  1987.  
  1988. }
  1989. //else weisdown=0;
  1990.  
  1991. if ( type=='w' )
  1992. {
  1993. entry_p=n;
  1994. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  1995. n++;
  1996. if ( windStr[n]==':' )n++; else return;
  1997. n2=0;
  1998. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  1999. if ( windStr[n]==':' )n++; else return;
  2000. varname[n2]='\0';
  2001. n2=0;
  2002. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  2003. if ( windStr[n]==':' )n++; else return;
  2004. text[n2]='\0';
  2005.  
  2006. n2=0;
  2007. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  2008. buf[n2]='\0';
  2009. x=atoi(buf);
  2010. if ( windStr[n]==':' )n++; else return;
  2011. n2=0;
  2012. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  2013. buf[n2]='\0';
  2014. y=atoi(buf);
  2015. if ( windStr[n]==':' )n++; else return;
  2016. n2=0;
  2017. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  2018. buf[n2]='\0';
  2019. xmax=atoi(buf);
  2020. if ( windStr[n]==':' )n++; else return;
  2021. n2=0;
  2022. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  2023. buf[n2]='\0';
  2024. ymax=atoi(buf);
  2025. n++;
  2026.  
  2027. blocked=windStr[n]; n++, n++;
  2028. updateSemaph=windStr[n]; n++, n++;
  2029.  
  2030. if ( ignore==0)
  2031. {
  2032. unsigned int xabs, yabs, xmaxabs, ymaxabs;
  2033. xabs=x, yabs=y, xmaxabs=xmax, ymaxabs=ymax;
  2034.  
  2035.  
  2036. framestack[framedepth].x=framestack[framedepth-1].x+x;
  2037. framestack[framedepth].y=framestack[framedepth-1].y+y;
  2038.  
  2039. x=framestack[framedepth].x;
  2040. y=framestack[framedepth].y;
  2041.  
  2042. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax < xmax+x ?
  2043. framestack[framedepth-1].xmax : xmax+x );
  2044.  
  2045. framestack[framedepth].ymax=( framestack[framedepth-1].ymax < ymax+y ?
  2046. framestack[framedepth-1].ymax : ymax+y );
  2047.  
  2048. framestack[framedepth].seqstart=entry_p;
  2049. framestack[framedepth].firstheap=n;
  2050.  
  2051.  
  2052. xmax=framestack[framedepth].xmax;
  2053. ymax=framestack[framedepth].ymax;
  2054.  
  2055. // max irrelevant?
  2056. framedepth++;
  2057.  
  2058.  
  2059. unsigned int drawX, drawY;
  2060.  
  2061. drawX=x;
  2062.  
  2063. if ( cursor[0] >= x && cursor[0] <= xmax &&
  2064. cursor[1] >= y && cursor[1] <= ymax+1 && blocked=='0' )
  2065. {
  2066. //windStr[n-2]='1'; //Semaphore gesetzt
  2067.  
  2068.  
  2069. obj_input.type='w';
  2070. if ( cursor[1]!=y)
  2071. obj_input.command=1;
  2072. else
  2073. {
  2074. if ( updateSemaph!='3')obj_input.command=3;
  2075. else obj_input.command=4;
  2076. }
  2077.  
  2078. strcpy(obj_input.varname, varname);
  2079. strcpy(obj_input.text,text);
  2080. obj_input.param=0,
  2081. obj_input.xabs=xabs,
  2082. obj_input.yabs=yabs,
  2083. obj_input.xmaxabs=xmaxabs,
  2084. obj_input.ymaxabs=ymaxabs,
  2085. obj_input.blocked=0;
  2086.  
  2087. // printf("\a");
  2088. // printf(">>%s geklickt<<", varname), getch();
  2089.  
  2090. weisdown=1;
  2091. layer=framedepth;
  2092. framepos=framedepth-1;
  2093.  
  2094. }
  2095. else if ( cmd==2)
  2096. {
  2097. obj_input.type='w',
  2098.  
  2099. strcpy(obj_input.varname, varname);
  2100. strcpy(obj_input.text,text);
  2101. obj_input.command=0; // kein Signal
  2102. obj_input.param=0,
  2103. obj_input.xabs=xabs,
  2104. obj_input.yabs=yabs,
  2105. obj_input.xmaxabs=xmaxabs,
  2106. obj_input.ymaxabs=ymaxabs,
  2107. obj_input.blocked=0;
  2108.  
  2109. framepos=framedepth-1;
  2110. layer=framedepth-1;
  2111. weisdown=1;
  2112. }
  2113.  
  2114. }
  2115. //else
  2116. //framedepth--;
  2117. // printf("%s %d %d %d %d %d\n",varname, x,y,xmax,ymax, weisdown), getch();
  2118.  
  2119.  
  2120. }
  2121.  
  2122.  
  2123. if ( type=='b' )
  2124. {
  2125. entry_p=n;
  2126. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  2127. n++;
  2128. if ( windStr[n]==':' )n++; else return;
  2129. n2=0;
  2130. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  2131. if ( windStr[n]==':' )n++; else return;
  2132. varname[n2]='\0';
  2133. n2=0;
  2134. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  2135. if ( windStr[n]==':' )n++; else return;
  2136. text[n2]='\0';
  2137.  
  2138. n2=0;
  2139. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  2140. buf[n2]='\0';
  2141. x=atoi(buf);
  2142. if ( windStr[n]==':' )n++; else return;
  2143. n2=0;
  2144. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  2145. buf[n2]='\0';
  2146. y=atoi(buf);
  2147. if ( windStr[n]==':' )n++; else return;
  2148. n2=0;
  2149. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  2150. buf[n2]='\0';
  2151. xmax=atoi(buf);
  2152. if ( windStr[n]==':' )n++; else return;
  2153. n2=0;
  2154. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  2155. buf[n2]='\0';
  2156. ymax=atoi(buf);
  2157. n++;
  2158.  
  2159. blocked=windStr[n]; n++, n++;
  2160. updateSemaph=windStr[n]; n++, n++;
  2161.  
  2162. if ( ignore==0)
  2163. {
  2164.  
  2165. unsigned int xabs, yabs, xmaxabs, ymaxabs;
  2166. xabs=x, yabs=y, xmaxabs=xmax, ymaxabs=ymax;
  2167.  
  2168. framestack[framedepth].x=framestack[framedepth-1].x+x;
  2169. framestack[framedepth].y=framestack[framedepth-1].y+y;
  2170.  
  2171. x=framestack[framedepth].x;
  2172. y=framestack[framedepth].y;
  2173.  
  2174. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax < xmax+x ?
  2175. framestack[framedepth-1].xmax : xmax+x );
  2176.  
  2177. framestack[framedepth].ymax=( framestack[framedepth-1].ymax < ymax+y ?
  2178. framestack[framedepth-1].ymax : ymax+y );
  2179.  
  2180. framestack[framedepth].seqstart=entry_p;
  2181. framestack[framedepth].firstheap=n;
  2182.  
  2183.  
  2184. xmax=framestack[framedepth].xmax;
  2185. ymax=framestack[framedepth].ymax;
  2186. // max irrelevant?
  2187.  
  2188. framedepth++;
  2189.  
  2190.  
  2191. unsigned int drawX, drawY;
  2192. if ( cursor[0] >= x && cursor[0] <= x+xmax &&
  2193. cursor[1] >= y && cursor[1] <= y+ymax&& blocked=='0' )
  2194. {
  2195.  
  2196. obj_input.type='b',
  2197. strcpy(obj_input.varname, varname);
  2198. strcpy(obj_input.text,text);
  2199. obj_input.command=1,
  2200. obj_input.param=0,
  2201. obj_input.xabs=xabs,
  2202. obj_input.yabs=yabs,
  2203. obj_input.xmaxabs=xmaxabs,
  2204. obj_input.ymaxabs=ymaxabs,
  2205. obj_input.blocked=0;
  2206.  
  2207. // windStr[n-2]='1'; //Semaphore gesetzt
  2208. printf("Button geklickt"), getch();
  2209. framepos=framedepth-1;
  2210. layer=framedepth;
  2211. weisdown=1;
  2212. }
  2213. else if ( cmd==2)
  2214. {
  2215. strcpy(obj_input.varname, varname);
  2216. strcpy(obj_input.text,text);
  2217. obj_input.command=0, // Signal ignorieren
  2218. obj_input.param=0,
  2219. obj_input.xabs=xabs,
  2220. obj_input.yabs=yabs,
  2221. obj_input.xmaxabs=xmaxabs,
  2222. obj_input.ymaxabs=ymaxabs,
  2223. obj_input.blocked=0;
  2224.  
  2225.  
  2226. framepos=framedepth-1;
  2227. layer=framedepth;
  2228. weisdown=1;
  2229.  
  2230. }
  2231. //else
  2232. //framedepth--;
  2233.  
  2234. }
  2235.  
  2236. }
  2237.  
  2238.  
  2239.  
  2240.  
  2241. if ( type=='t' )
  2242. {
  2243. entry_p=n;
  2244. // type:'varname':'text':x:y:xsize:ysize:blocked:update
  2245. n++;
  2246. if ( windStr[n]==':' )n++; else return;
  2247. n2=0;
  2248. while ( windStr[n]!=':' ) varname[n2]=windStr[n], n++, n2++;
  2249. if ( windStr[n]==':' )n++; else return;
  2250. varname[n2]='\0';
  2251. n2=0;
  2252. while ( windStr[n]!=':' ) text[n2]=windStr[n], n++, n2++;
  2253. if ( windStr[n]==':' )n++; else return;
  2254. text[n2]='\0';
  2255.  
  2256. n2=0;
  2257. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  2258. buf[n2]='\0';
  2259. x=atoi(buf);
  2260. if ( windStr[n]==':' )n++; else return;
  2261. n2=0;
  2262. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  2263. buf[n2]='\0';
  2264. y=atoi(buf);
  2265. if ( windStr[n]==':' )n++; else return;
  2266. n2=0;
  2267. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  2268. buf[n2]='\0';
  2269. xmax=atoi(buf);
  2270. if ( windStr[n]==':' )n++; else return;
  2271. n2=0;
  2272. while ( windStr[n]!=':' ) buf[n2]=windStr[n], n++, n2++;
  2273. buf[n2]='\0';
  2274. ymax=atoi(buf);
  2275. n++;
  2276.  
  2277. blocked=windStr[n]; n++, n++;
  2278. updateSemaph=windStr[n]; n++, n++;
  2279.  
  2280. if ( ignore==0)
  2281. {
  2282.  
  2283. unsigned long int xabs, yabs, xmaxabs, ymaxabs;
  2284. xabs=x, yabs=y, xmaxabs=xmax, ymaxabs=ymax;
  2285.  
  2286. framestack[framedepth].x=framestack[framedepth-1].x+x;
  2287. framestack[framedepth].y=framestack[framedepth-1].y+y;
  2288.  
  2289. x=framestack[framedepth].x;
  2290. y=framestack[framedepth].y;
  2291.  
  2292. framestack[framedepth].xmax= ( framestack[framedepth-1].xmax < xmax+x ?
  2293. framestack[framedepth-1].xmax : xmax+x );
  2294.  
  2295. framestack[framedepth].ymax=( framestack[framedepth-1].y < xmax+1 ?
  2296. framestack[framedepth-1].y : xmax+1 );
  2297.  
  2298.  
  2299. framestack[framedepth].seqstart=entry_p;
  2300. framestack[framedepth].firstheap=n;
  2301.  
  2302. xmax=framestack[framedepth].xmax;
  2303. ymax=framestack[framedepth].ymax;
  2304. // max irrelevant?
  2305.  
  2306. framedepth++;
  2307.  
  2308. //printf("Binda\a"), getch();
  2309.  
  2310.  
  2311. obj_state objbuf;
  2312.  
  2313. objbuf.x=x, objbuf.y=y;
  2314. objbuf.xmax=xmax+x, objbuf.ymax=ymax;
  2315.  
  2316. unsigned int drawX, drawY;
  2317.  
  2318. if (framestack[framedepth-1].ymax > framestack[framedepth-1].y)
  2319. {
  2320. if ( cmd==1 &&
  2321. (text[1]=get_edit_pos(&objbuf,cursor[0],cursor[1])) != 'F' )
  2322. {
  2323.  
  2324. obj_input.type='t',
  2325. strcpy(obj_input.varname, varname);
  2326. strcpy(obj_input.text,text);
  2327. obj_input.command=cmd,
  2328. obj_input.xabs=xabs,
  2329. obj_input.yabs=yabs,
  2330. obj_input.xmaxabs=xmaxabs,
  2331. obj_input.ymaxabs=ymaxabs,
  2332. obj_input.blocked=0;
  2333.  
  2334. // windStr[n-2]='1'; //Semaphore gesetzt
  2335. printf("Editierfeld angeklickt"), getch();
  2336. framepos=framedepth-1;
  2337. layer=framedepth;
  2338. weisdown=1;
  2339. }
  2340. else if ( cmd==2)
  2341. {
  2342.  
  2343. obj_input.type='t',
  2344.  
  2345.  
  2346.  
  2347. strcpy(obj_input.varname, varname);
  2348. strcpy(obj_input.text,text);
  2349. obj_input.command=cmd,
  2350. obj_input.xabs=xabs,
  2351. obj_input.yabs=yabs,
  2352. obj_input.xmaxabs=xmaxabs,
  2353. obj_input.ymaxabs=ymaxabs,
  2354. obj_input.blocked=0;
  2355.  
  2356.  
  2357.  
  2358.  
  2359. obj_input.command=cmd,
  2360. obj_input.text[0]=c;
  2361.  
  2362. printf("\a");
  2363.  
  2364. framepos=framedepth-1;
  2365. layer=framedepth;
  2366. weisdown=1;
  2367.  
  2368. }
  2369.  
  2370. }
  2371. //else
  2372. //framedepth--;
  2373.  
  2374. }
  2375.  
  2376.  
  2377. }
  2378.  
  2379.  
  2380.  
  2381. }
  2382.  
  2383. if ( weisdown==1)
  2384. {
  2385. unsigned char strconstr[255];
  2386. unsigned char copied[1024];
  2387. buildstring(strconstr, &obj_input);
  2388.  
  2389.  
  2390. // printf(">>>>>>%s<<<<", strconstr), getch();
  2391. strncpy(copied,windStr+framestack[layer-1].firstheap,strlen(windStr)-framestack[layer-1].firstheap);
  2392. copied[strlen(windStr)-framestack[layer-1].firstheap]='\0';
  2393. memcpy(windStr+framestack[layer-1].seqstart, strconstr, strlen(strconstr)+1);
  2394. strcat(windStr,copied);
  2395.  
  2396. }
  2397.  
  2398. }
  2399. }
  2400.  
  2401.  
  2402.  
  2403.  
  2404. void displayScreen(void)
  2405. {
  2406. system("cls\n");
  2407. int x=0, y=0;
  2408. unsigned char screenz[160][120];
  2409.  
  2410. y=0;
  2411. while ( y < 120)
  2412. {
  2413. x=0;
  2414. while ( x < 160)
  2415. {
  2416. screenz[x][y]=0;
  2417. x++;
  2418. }
  2419. y++;
  2420. }
  2421. x=0,y=0;
  2422. unsigned int n=0;
  2423. while ( n < pixcount)
  2424. {
  2425. //if (screenz[pixelbuf[pixcount][0]][pixelbuf[pixcount][1]] <= pixelbuf[pixcount][3])
  2426. screen[pixelbuf[n][0]][pixelbuf[n][1]]=pixelbuf[n][2] ; // ,
  2427. n++;
  2428. //screenz[pixelbuf[pixcount][0]][pixelbuf[pixcount][1]]=pixelbuf[pixcount][3];
  2429.  
  2430. }
  2431. while ( y < 80 )
  2432. {
  2433. x=0;
  2434. while ( x < 158 )
  2435. {
  2436. printf("%c%c%c%c%c%c%c%c", screen[x][y], screen[x+1][y], screen[x+2][y], screen[x+3][y],
  2437. screen[x+4][y], screen[x+5][y], screen[x+6][y], screen[x+7][y]);
  2438. x+=8;
  2439. }
  2440. printf("\n");
  2441.  
  2442. y++;
  2443. }
  2444. }
  2445.  
  2446.  
  2447.  
  2448.  
  2449.  
  2450. int main(void)
  2451. {
  2452.  
  2453. clock_t delay;
  2454.  
  2455. framestack[0].x=0, framestack[0].y=0,
  2456. framestack[0].xmax=100, framestack[0].ymax=80;
  2457. framestack[0].blocked=0;
  2458. framestack[0].seqstart=0, framestack[0].seqend=strlen(windStr);
  2459.  
  2460. cursor[0]=0, cursor[1]=0;
  2461.  
  2462. obj_state teststat;
  2463. unsigned char text[255];
  2464. unsigned char textptr[30];
  2465.  
  2466. strcpy(text,"Werte");
  2467.  
  2468. itoa((long int)text,textptr,10);
  2469.  
  2470. strcpy(windStr,"w:testfenster:Hello:20:20:30:30:0:0:w:xbutton:XBUTTON:1:1:10:10:0:0:eb:testbutton:OK:5:5:4:3:0:0:eew:test2:Bla:25:27:50:50:0:0:" );
  2471. strcat(windStr,"t:text:Texten:10:10:7:"),
  2472. strcat(windStr,textptr),
  2473. strcat(windStr,":0:0:eee");
  2474.  
  2475. // printf("%s", (unsigned char *)atoi(textptr)), getch();
  2476. //printf("%s", (unsigned char *)(long int)(text)), getch();
  2477.  
  2478. printf("%s",windStr), getch();
  2479. /*
  2480. while (1 )
  2481. {
  2482.  
  2483. delay=clock()+100;
  2484. clearScreen();
  2485. framedepth=1;
  2486.  
  2487.  
  2488. printf(" %d ", strlen(windStr));
  2489. */
  2490. framedepth=1;
  2491.  
  2492.  
  2493. framestack[0].x=0, framestack[0].y=0,
  2494. framestack[0].xmax=100, framestack[0].ymax=80;
  2495. framestack[0].blocked=0;
  2496. framestack[0].seqstart=0, framestack[0].seqend=strlen(windStr);
  2497.  
  2498.  
  2499. printf("%s",windStr), getch();
  2500. readback("test2:text",&teststat);
  2501. framedepth=1;
  2502.  
  2503.  
  2504. framestack[0].x=0, framestack[0].y=0,
  2505. framestack[0].xmax=100, framestack[0].ymax=80;
  2506. framestack[0].blocked=0;
  2507. framestack[0].seqstart=0, framestack[0].seqend=strlen(windStr);
  2508.  
  2509. //printf("Ueberlebt...");
  2510. teststat.x=1;
  2511. teststat.xabs=5;
  2512. teststat.yabs=5;
  2513. teststat.xmaxabs=10;
  2514. teststat.ymaxabs=10;
  2515.  
  2516.  
  2517. strcpy(teststat.varname,"INSERTED");
  2518. strcpy(teststat.text,"IMINSERTED");
  2519. teststat.type='w';
  2520. printf("%d", teststat.ymax);
  2521. update("testfenster:xbutton",&teststat,INSERT);
  2522.  
  2523.  
  2524. framedepth=1;
  2525. framestack[0].x=0, framestack[0].y=0,
  2526. framestack[0].xmax=100, framestack[0].ymax=80;
  2527. framestack[0].blocked=0;
  2528. framestack[0].seqstart=0, framestack[0].seqend=strlen(windStr);
  2529.  
  2530.  
  2531. disp_elements();
  2532. displayScreen();
  2533.  
  2534. printf("\n%s\n", windStr);
  2535.  
  2536. /*
  2537.  
  2538. framestack[0].x=0, framestack[0].y=0,
  2539. framestack[0].xmax=100, framestack[0].ymax=80;
  2540. framestack[0].blocked=0;
  2541. framestack[0].seqstart=0, framestack[0].seqend=strlen(windStr);
  2542.  
  2543.  
  2544. pixcount=0;
  2545. printf("vor disp_elements()");
  2546. disp_elements();
  2547.  
  2548.  
  2549. framedepth=1;
  2550.  
  2551.  
  2552. framestack[0].x=0, framestack[0].y=0,
  2553. framestack[0].xmax=100, framestack[0].ymax=80;
  2554. framestack[0].blocked=0;
  2555. framestack[0].seqstart=0, framestack[0].seqend=strlen(windStr);
  2556.  
  2557.  
  2558. readback("test2:text",&teststat);
  2559. framedepth=1;
  2560.  
  2561.  
  2562. framestack[0].x=0, framestack[0].y=0,
  2563. framestack[0].xmax=100, framestack[0].ymax=80;
  2564. framestack[0].blocked=0;
  2565. framestack[0].seqstart=0, framestack[0].seqend=strlen(windStr);
  2566.  
  2567. if ( teststat.command=='1') putinfront("test2:text",-1);
  2568.  
  2569. framedepth=1;
  2570.  
  2571.  
  2572. framestack[0].x=0, framestack[0].y=0,
  2573. framestack[0].xmax=100, framestack[0].ymax=80;
  2574. framestack[0].blocked=0;
  2575. framestack[0].seqstart=0, framestack[0].seqend=strlen(windStr);
  2576.  
  2577. printf("vor get_input()");
  2578. get_input();
  2579. displayScreen();
  2580. printf("\n%s",windStr);
  2581.  
  2582.  
  2583. //readback("testfenster:testbutton",&teststat);
  2584.  
  2585. //printf("Hallo%s", teststat.text );
  2586.  
  2587.  
  2588. while ( delay > clock());
  2589. }
  2590. */
  2591.  
  2592. }
  2593.  
  2594. ```
  2595.  
  2596. ```
  2597.  
  2598.  
  2599. Das Schönste war, daß ich nach 20 Jahren endlich in der Lage war, ein funktionierendes Grafikadventure im Lucas-Arts-Stil zu schreiben. Ist zwar immer noch eine Schlamperei, aber theoretisch sind wohl alle Probleme gelöst.
  2600.  
  2601. ```cpp
  2602. /*
  2603. Added the path search algorithm from the Miracle C distribution.
  2604. I hope that's it.
  2605.  
  2606. */
  2607.  
  2608.  
  2609.  
  2610. #include <stdio.h>
  2611. #include <time.h>
  2612. #include <fcntl.h>
  2613.  
  2614. #define NUM_SCRIPTS 7 // Number of individual scripts, they're all running simultaneously, give them a semaphore waiting loop to pause them
  2615. #define NUM_OBJECTS 6 // Number of game objects, including actors
  2616. #define GLOBAL_STATES 16 // Number of global state values
  2617.  
  2618.  
  2619. signed int data[1024*NUM_SCRIPTS+GLOBAL_STATES+NUM_OBJECTS*9]; // The shared working memory for the VM scripts
  2620.  
  2621.  
  2622. unsigned int cursor[2]; // Cursor X and Y coordinate
  2623.  
  2624.  
  2625. #define NUM_SENTENCES 3 // Strings to be displayed when something is being 'said', -1 means none
  2626. #define NUM_ROOMS 1 // Number of individual rooms
  2627.  
  2628.  
  2629. unsigned char objnames[NUM_OBJECTS][32]; // Identifier strings for objects
  2630. unsigned char sentences[NUM_SENTENCES][255]; // Sentences data array
  2631.  
  2632.  
  2633. #define OBJ_NUM(n) (1024*NUM_SCRIPTS+GLOBAL_STATES+n*9)
  2634.  
  2635. #define X_SCROLL 1024*NUM_SCRIPTS // X room scrolling
  2636. #define Y_SCROLL 1024*NUM_SCRIPTS+1 // still not implemented
  2637. #define TIMERTICK 1024*NUM_SCRIPTS+2 // When the timer function delivers a new value, it is set to 1, a certain script has to set it to 0 and deliver it
  2638. #define TOUCHING 1024*NUM_SCRIPTS+3
  2639. #define ROOM 1024*NUM_SCRIPTS+4 // Inventory is 1, empty room is 0
  2640. #define ITEM_A 1024*NUM_SCRIPTS+5 // First item ID to be combined in a sentence
  2641. #define ITEM_B 1024*NUM_SCRIPTS+6 // second one
  2642. #define VERB 1024*NUM_SCRIPTS+7 // Verb to be used in a sentence
  2643. #define ACTION_CODE 1024*NUM_SCRIPTS+8 // User command state resulting from the sequence of the clicked stuff
  2644. #define SAY_SENTENCE 1024*NUM_SCRIPTS+9 // Script selection of sentence to be said
  2645. #define PATHSTARTOBJ 1024*NUM_SCRIPTS+10 // Object from which the path search starts
  2646.  
  2647.  
  2648. #define NOACTION 0
  2649. #define LOOK 1
  2650. #define PICK 2
  2651. #define COMBINE 3
  2652. #define PREP_LOOK 4
  2653. #define PREP_PICK 5
  2654. #define PREP_COMBI 6
  2655. #define PREP_COMBI_B 7
  2656. #define WALKTOXY 8
  2657.  
  2658.  
  2659.  
  2660. unsigned char sprite[400*7]; // Sprite patterns, raw 20x20 tiles with 8 bit color depth, linear greyscale, above 240 somewhere means transparency
  2661. unsigned char screen[160][90]; // Screen Buffer
  2662. signed int screenz[160][50]; // Z depth of each coordinate on the screen buffer
  2663.  
  2664. unsigned char *roompatt; // arrays often crash, but today we have OS automatic dynamic memory allocation
  2665. unsigned char *roomz; // The Z depth for room coordinates itself, however, sprites may be put in front of this
  2666.  
  2667.  
  2668. signed int walkmask[32][2][10][NUM_ROOMS]; // X, Y and Z coordinates of walkable coordinates of a room, still needs to be upscaled by a correcting routine
  2669.  
  2670.  
  2671. // just for the path search test
  2672. unsigned char walklayer1[320]={0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,
  2673. 0,0,0,1,1,1,0,0,1,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,
  2674. 0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,
  2675. 0,0,0,1,0,1,0,0,1,0,0,1,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,
  2676. 0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,1,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,
  2677. 0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,
  2678. 0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  2679. 0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  2680. 0,0,0,1,0,1,0,0,1,1,1,1,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  2681. 0,0,0,1,0,1,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  2682.  
  2683.  
  2684.  
  2685. // initialize the walk mask
  2686. void initwalklayer(void)
  2687. {
  2688. int x=0,z=0;
  2689.  
  2690. while ( z < 10)
  2691. {
  2692. x=0;
  2693. while ( x < 32)
  2694. {
  2695. walkmask[x][1][z][0]=walklayer1[x+z*32];
  2696. walkmask[x][0][z][0]=1;
  2697. if (walklayer1[x+z*32]==1) roompatt[x*10+(z/4+30)*320]=0;
  2698.  
  2699. x++;
  2700.  
  2701. }
  2702. z++;
  2703.  
  2704. }
  2705.  
  2706. }
  2707.  
  2708.  
  2709. signed int passedbox[32][2][10]; // so the path search knows where it was and where it can spread
  2710.  
  2711.  
  2712.  
  2713. // That algorithm assigns each coordinate the shortest cross-formed way from the starting coordinate, afterwards you can trace the way back from the goal
  2714. // by seeking by-one-decremented neighbour points
  2715.  
  2716. signed int shortest;
  2717.  
  2718. int path_recurse(int x, int y, int z, int xg, int yg, int zg, int depth)
  2719. {
  2720.  
  2721.  
  2722. //printf("%d %d %d\n",x,y,z);
  2723. if ( depth > 1999) return;
  2724. if ( x==xg && y == yg && z == zg){ if ( depth-1 < shortest )shortest=depth-1; }
  2725.  
  2726.  
  2727.  
  2728. passedbox[x][y][z]=depth-1;
  2729.  
  2730. signed int buf;
  2731.  
  2732. if ( x > 0 )if (passedbox[x-1][y][z]>depth||passedbox[x-1][y][z]==-3) path_recurse(x-1,y,z,xg,yg,zg,depth+1);
  2733. if ( x < 31) if (passedbox[x+1][y][z]>depth||passedbox[x+1][y][z]==-3)path_recurse(x+1,y,z,xg,yg,zg,depth+1);
  2734. if ( y > 0 ) if (passedbox[x][y-1][z]>depth||passedbox[x][y-1][z]==-3) path_recurse(x,y-1,z,xg,yg,zg,depth+1);
  2735. if ( y < 1 ) if (passedbox[x][y+1][z]>depth||passedbox[x][y+1][z]==-3) path_recurse(x,y+1,z,xg,yg,zg,depth+1);
  2736. if ( z > 0 ) if (passedbox[x][y][z-1]>depth||passedbox[x][y][z-1]==-3) path_recurse(x,y,z-1,xg,yg,zg,depth+1);
  2737. if ( z < 9 ) if (passedbox[x][y][z+1]>depth||passedbox[x][y][z+1]==-3) path_recurse(x,y,z+1,xg,yg,zg,depth+1);
  2738.  
  2739. //printf("%d\n",depth);
  2740. return shortest;
  2741.  
  2742.  
  2743. }
  2744.  
  2745.  
  2746.  
  2747. void markback(int x, int y, int z, int len)
  2748. {
  2749. if ( len ==0 ) passedbox[x][y][z]=-4;
  2750.  
  2751. if ( x > 0 ) if ( passedbox[x-1][y][z]==len-1)markback(x-1,y,z,len-1);
  2752. if ( x < 31 ) if ( passedbox[x+1][y][z]==len-1)markback(x+1,y,z,len-1);
  2753. if ( y > 0 ) if ( passedbox[x][y-1][z]==len-1)markback(x,y-1,z,len-1);
  2754. if ( y < 1 ) if ( passedbox[x][y+1][z]==len-1)markback(x,y+1,z,len-1);
  2755. if ( z < 9 ) if ( passedbox[x][y][z+1]==len-1)markback(x,y,z+1,len-1);
  2756. if ( z > 0 ) if (passedbox[x][y][z-1]==len-1)markback(x,y,z-1,len-1);
  2757.  
  2758. }
  2759.  
  2760.  
  2761. // The thing is, there are just two Y heights, what you would think is Y is actually taken from the Z mask of the clicked coordinate.
  2762. // It still cannot select sprites, however, you can assume that they were transferred with there Z value on the Z mask there before
  2763. // Overlapping of several sprites shall not happen anyway
  2764. // Max could walk through Sam. There was no necessity to implement details like walking around him. Just imagine he did with a time leap.
  2765. // Consider the problems that could cause also.
  2766.  
  2767. void find_path(int obj, int x_, int y_)
  2768. {
  2769.  
  2770. signed int x=data[OBJ_NUM(obj)+0]/10,y=data[OBJ_NUM(obj)+1]/20, z=data[OBJ_NUM(obj)+8]/10;
  2771. x_/=10, y_/=30;
  2772.  
  2773.  
  2774. signed int z_=screenz[x_*10-data[X_SCROLL]][y_*20]/26;
  2775. // pay attention: if sprite was moved in front, coordinates behind cannot be accessed anymore
  2776.  
  2777.  
  2778. //data[OBJ_NUM(obj)+1]=3;
  2779. //y=1; // Z-Maskenfehlenpfusch
  2780. y_=1;
  2781. //printf("Suche den Pfad von %d %d %d nach %d %d %d\n",x,y,z, x_,y_,z_);
  2782. //getch();
  2783.  
  2784. unsigned int c1,c2,c3;
  2785.  
  2786. c3=0;
  2787. while ( c3 < 10)
  2788. {
  2789. c1=0;
  2790. while ( c1 < 32)
  2791. {
  2792. c2=0;
  2793. while ( c2 < 2)
  2794. {
  2795. passedbox[c1][c2][c3]=walkmask[c1][c2][c3][data[ROOM]-2]== 0 ? -3 : -2 ;
  2796. c2++;
  2797. }
  2798. c1++;
  2799. }
  2800. c3++;
  2801. }
  2802.  
  2803.  
  2804.  
  2805. //passedbox[x_][y_][z_]=-3;
  2806.  
  2807. shortest=2000;
  2808.  
  2809. path_recurse(x,y,z,x_,y_,z_,0);
  2810. if ( shortest!=2000)markback(x_,y_,z_,shortest);
  2811. data[OBJ_NUM(obj)+7]=1;
  2812.  
  2813. data[OBJ_NUM(obj)+4]=x*10, data[OBJ_NUM(obj)+5]=y*20, data[OBJ_NUM(obj)+6]=z*10;
  2814.  
  2815.  
  2816. // There's a semaphore to be marked when a path was found.
  2817. // I'm still not sure how to calculate the runtime of the path search, but probably it cannot exceed 1999
  2818. if ( shortest!= 2000)
  2819. {
  2820. //printf("Pfad gefunden.");
  2821. if ( x-1 >= 0) if ( passedbox[x-1][y][z] ==-4 ) shortest= passedbox[x-1][y][z], data[OBJ_NUM(obj)+4]=x*10-10, data[OBJ_NUM(obj)+5]=y*20, data[OBJ_NUM(obj)+6]=z*10;
  2822. if ( x+1 < 32) if ( passedbox[x+1][y][z] ==-4 ) shortest= passedbox[x+1][y][z], data[OBJ_NUM(obj)+4]=x*10+10, data[OBJ_NUM(obj)+5]=y*20, data[OBJ_NUM(obj)+6]=z*10;
  2823. if ( y-1 >= 0) if ( passedbox[x][y-1][z] ==-4 ) shortest= passedbox[x][y-1][z], data[OBJ_NUM(obj)+4]=x*10, data[OBJ_NUM(obj)+5]=y*20-20, data[OBJ_NUM(obj)+6]=z*10;
  2824. if ( y+1 < 2) if ( passedbox[x][y+1][z] ==-4 ) shortest= passedbox[x][y+1][z], data[OBJ_NUM(obj)+4]=x*10, data[OBJ_NUM(obj)+5]=y*20+20, data[OBJ_NUM(obj)+6]=z*10;
  2825. if ( z-1 >= 0) if ( passedbox[x][y][z-1] ==-4 ) shortest= passedbox[x][y][z-1], data[OBJ_NUM(obj)+4]=x*10, data[OBJ_NUM(obj)+5]=y*20, data[OBJ_NUM(obj)+6]=z*10-10;
  2826. if ( z+1 < 10) if ( passedbox[x][y][z+1] ==-4 ) shortest= passedbox[x][y][z+1], data[OBJ_NUM(obj)+4]=x*10, data[OBJ_NUM(obj)+5]=y*20, data[OBJ_NUM(obj)+6]=z*10+10;
  2827.  
  2828. }
  2829. else data[OBJ_NUM(obj)+7]=3; // We found no path
  2830. //printf("Durchgelaufen");
  2831. /*
  2832. printf("%d\n",passedbox[x-1][y][z] );
  2833. printf("%d\n",passedbox[x+1][y][z] );
  2834. printf("%d\n",passedbox[x][y+1][z] );
  2835. printf("%d\n",passedbox[x][y-1][z] );
  2836. printf("%d\n",passedbox[x][y][z+1] );
  2837. printf("%d\n",passedbox[x][y][z-1] );
  2838. */
  2839. //printf("%d\n", shortest);
  2840. //printf("Resultat: %d %d %d",data[OBJ_NUM(obj)+4],data[OBJ_NUM(obj)+5],data[OBJ_NUM(obj)+6]);
  2841. //getch();
  2842.  
  2843. }
  2844.  
  2845.  
  2846.  
  2847.  
  2848.  
  2849.  
  2850.  
  2851. // Draw the level and afterwards draw the sprites
  2852. void drawlevel(void)
  2853. {
  2854. int x,y;
  2855. int room=data[ROOM]-2; // remember: 0 and 1 are special rooms
  2856.  
  2857. y=0;
  2858. while ( y < 50)
  2859. {
  2860. x=0;
  2861. while ( x < 160)
  2862. {
  2863. screenz[x][y]=roomz[x+data[X_SCROLL] +y*320 +room*320*50];
  2864. x++;
  2865. }
  2866. y++;
  2867. }
  2868.  
  2869.  
  2870. y=0;
  2871. while ( y < 50)
  2872. {
  2873. x=0;
  2874. while ( x < 160)
  2875. {
  2876. int c;
  2877. c= roompatt[x+data[X_SCROLL]+y*320+room*320*50];
  2878.  
  2879. if ( c < 64) c=' '; // ASCII can be just like greyscale, it's very ugly having only 4 greyscale values, however, it's still only a test
  2880. else
  2881. if ( c < 96) c=176;
  2882. else
  2883. if ( c < 128) c= 177;
  2884. else
  2885. if ( c < 196) c= '@';
  2886. else c=219;
  2887. screen[x][y]=c ;
  2888. x++;
  2889. }
  2890. y++;
  2891. }
  2892.  
  2893. int n;
  2894. n=0;
  2895. while ( n < NUM_OBJECTS)
  2896. {
  2897. if ( data[OBJ_NUM(n)+3]==room+2 || (data[OBJ_NUM(n)+3]==1 ) ) // first determine if it's in the current room or in the inventory below, subtract the scrolling value...
  2898. put_sprite( data[OBJ_NUM(n)+3] != 1 ? data[OBJ_NUM(n)+0]-data[X_SCROLL] : data[OBJ_NUM(n)+0],data[OBJ_NUM(n)+1],data[OBJ_NUM(n)+2],-96, data[OBJ_NUM(n)+8] );
  2899.  
  2900. n++;
  2901. }
  2902.  
  2903. }
  2904.  
  2905.  
  2906. // Sometimes we need to know whether a certain object is at a certain mouse cursor position.
  2907. // The Y and Z confusion may still be causing trouble... however, we're always clicking objects and not room pattern parts,
  2908. // what can be selected always needs to be placed, use a completely empty and transparent pattern for all of them
  2909.  
  2910. signed int getobjfromcoord( int x, int y )
  2911. {
  2912. int n=0;
  2913.  
  2914. while ( n < NUM_OBJECTS)
  2915. {
  2916. if ( data[OBJ_NUM(n)+3]!=1)
  2917. {
  2918. if ( data[OBJ_NUM(n)+3]==data[ROOM] &&
  2919. fabs ( x - ( data[OBJ_NUM(n)+0]-data[X_SCROLL]+10 ) ) < 15 &&
  2920. fabs ( y - ( data[OBJ_NUM(n)+1]-data[Y_SCROLL]+10 ) ) < 15 ) return n;
  2921. }
  2922. else
  2923. {
  2924. if ( data[OBJ_NUM(n)+3]==1 &&
  2925. fabs ( x - ( data[OBJ_NUM(n)+0] +10 ) ) < 10 &&
  2926. fabs ( y - ( data[OBJ_NUM(n)+1] +10 ) ) < 10 ) return n;
  2927.  
  2928.  
  2929. }
  2930.  
  2931. n++;
  2932. }
  2933.  
  2934. return -1;
  2935. }
  2936.  
  2937.  
  2938. // Is a _certain_ object there?
  2939. signed int getobjNfromcoord( int x, int y, int n )
  2940. {
  2941.  
  2942. if ( data[OBJ_NUM(n)+3]!=1)
  2943. {
  2944. if ( data[OBJ_NUM(n)+3]==data[ROOM] &&
  2945. fabs ( x - ( data[OBJ_NUM(n)+0]-data[X_SCROLL]+10 ) ) < 15 &&
  2946. fabs ( y - ( data[OBJ_NUM(n)+1]-data[Y_SCROLL]+10 ) ) < 55 ) return n;
  2947. }
  2948.  
  2949.  
  2950. return -1;
  2951. }
  2952.  
  2953.  
  2954.  
  2955. // draw the sprite and change the Z mask, there's still the possibility for brightness scaling
  2956.  
  2957. void put_sprite(int xstart,int ystart, int n, int luma, int z)
  2958. {
  2959. int x=0;
  2960. int y=0;
  2961. signed int scroll;
  2962. scroll=0;
  2963.  
  2964. if ( ystart < 50)ystart+=z/4; // Here you can see that i don't know what i'm doing. From a certain aspect, Z could about look like an increased Y
  2965.  
  2966. // printf("Setze es an Position %d %d",xstart-scroll, ystart);
  2967.  
  2968. //printf("%d\n",z);
  2969.  
  2970. while ( y < 20 )
  2971. {
  2972. x=0;
  2973. while ( x < 20 )
  2974. {
  2975. if ( screenz[x+xstart][y+ystart]/50<= z || ystart > 50)
  2976. if ( xstart+x-scroll > 0 && xstart+x-scroll < 160 &&
  2977. ystart+y > 0 && ystart+y < 90 )
  2978. {
  2979. if ( sprite[n*400+x+y*20]<220 ) // eigentlich 255 der Transparenzwert
  2980. {
  2981. if ( sprite[n*400+x+y*20]+luma< 64 )
  2982. screen[xstart+x-scroll][y+ystart]=176;
  2983. else
  2984. if ( sprite[n*400+x+y*20]+luma< 128 )
  2985. screen[xstart+x-scroll][y+ystart]=177;
  2986. else
  2987. if ( sprite[n*400+x+y*20]+luma< 196 )
  2988. screen[xstart+x-scroll][y+ystart]='@';
  2989. else
  2990. //if ( sprite[n*400+x+y*20]+luma< 255 )
  2991. screen[xstart+x-scroll][y+ystart]=219;
  2992.  
  2993. screenz[x][y]=z;
  2994.  
  2995. }
  2996.  
  2997. }
  2998. x++;
  2999. }
  3000. y++;
  3001.  
  3002. }
  3003.  
  3004. }
  3005.  
  3006.  
  3007.  
  3008.  
  3009. /*
  3010. 0 von Beginn: X-Koordinate eines Sprites
  3011. 1 von Beginn: Y-Koordinate eines Sprites
  3012. 2 : Sprite-Phase
  3013. 3: Raum ( 0 kein, 1 Inventory )
  3014. 4: Pfadsuche X
  3015. 5: Pfadsuche Y
  3016. 6: Pfadsuche Z
  3017. 7: Pfadsuche hat Daten 2 Aufruf 1 Abholen
  3018. 8: Z-Daten
  3019. der Rest ist frei
  3020. */
  3021.  
  3022. // A data object needs x, y and z coordinates, for getobjfromcoord() we still ignored z, however, with two lines of code it should be about ok
  3023. // You can assign each data object a sprite tile number, you also assign it a room. The path search will enter it's next coordinates somewhere there,
  3024. // but you can catch the next coordinates only when the value at offset 7 is 1. You have to call the path search again for every animation step.
  3025. // But this is only logical because some things in the room might change while walking
  3026. // Maybe implement the possibility to find an object with a script over, again, a call semaphore, and then you could take it's coordinates from the result
  3027. // Comparing direct coordinates with the touch instruction could also have advantages?
  3028.  
  3029.  
  3030.  
  3031. // each script has it's own instruction memory ( not to confuse with the random-access 'data segment' thing )
  3032. // Each instruction can have two operands
  3033. // and when a script is locked, the VM will continue executing it until it is unlocked and therefore also the core will hang
  3034. struct
  3035. {
  3036. signed int instruction[1024][3];
  3037. signed int instr_ptr;
  3038. unsigned int locked;
  3039. } script[NUM_SCRIPTS];
  3040.  
  3041.  
  3042.  
  3043. #define ADD 0 // some basic mathematical operations, would be practical to extend the VM instruction set, however, multiplication and division are additions
  3044. #define SUB 1 // and subtraction in a loop, did you know that?
  3045. #define MOV 2 // move value from address of second operand to the address of the first operand
  3046. #define IFCMP 3 // when values on the addresses of both operands are equal, don't skip the next instruction, otherwise, add 2 to instr_ptr
  3047. #define JMP 4 // Jump to address of operand 1
  3048. #define LOCK 5 // Don't underestimate the possibility to prevent interruption of a certain script. Without this possibility, correct execution is never guaranteed
  3049. #define UNLOCK 6 // it will also lock the main loop, but our scripts shouldn't be a threat to the 'operating system' anyway
  3050. #define TOUCH 7 // when object of number of operand 1 is close enough to the object with the number of operand 2, set a certain value in script memory to 1,
  3051. // otherwise zero
  3052.  
  3053. // Virtual machine sounds very sophisticated, however, in it's basic form, it's cheap
  3054.  
  3055. void VM_Step(void)
  3056. {
  3057. int n=0;
  3058. while ( n < NUM_SCRIPTS )
  3059. {
  3060. if ( script[n].instruction[script[n].instr_ptr][0]==ADD )
  3061. {
  3062. data[script[n].instruction[script[n].instr_ptr][1]]+=
  3063. data[script[n].instruction[script[n].instr_ptr][2]];
  3064.  
  3065. script[n].instr_ptr++;
  3066. }
  3067. else
  3068. if ( script[n].instruction[script[n].instr_ptr][0]==SUB )
  3069. {
  3070. data[script[n].instruction[script[n].instr_ptr][1]]-=
  3071. data[script[n].instruction[script[n].instr_ptr][2]];
  3072.  
  3073. script[n].instr_ptr++;
  3074.  
  3075. }
  3076. else
  3077. if ( script[n].instruction[script[n].instr_ptr][0]==MOV )
  3078. {
  3079. data[script[n].instruction[script[n].instr_ptr][1]]=
  3080. data[script[n].instruction[script[n].instr_ptr][2]];
  3081. script[n].instr_ptr++;
  3082.  
  3083. }
  3084. else
  3085. if ( script[n].instruction[script[n].instr_ptr][0]==IFCMP )
  3086. {
  3087. if ( data[script[n].instruction[script[n].instr_ptr][1]]==
  3088. data[script[n].instruction[script[n].instr_ptr][2]]);
  3089. else script[n].instr_ptr++;
  3090.  
  3091.  
  3092. script[n].instr_ptr++;
  3093.  
  3094. }
  3095. else
  3096. if ( script[n].instruction[script[n].instr_ptr][0]==JMP )
  3097. {
  3098. script[n].instr_ptr=script[n].instruction[script[n].instr_ptr][1];
  3099. }
  3100. else
  3101. if ( script[n].instruction[script[n].instr_ptr][0]==LOCK )
  3102. {
  3103. //int n2;
  3104. //n2=0;
  3105. //while ( n2< NUM_SCRIPTS ){
  3106. // if (!( n2==n) )
  3107.  
  3108. script[n].locked=1; //n2++; }
  3109. script[n].instr_ptr++;
  3110. }
  3111. else
  3112. if ( script[n].instruction[script[n].instr_ptr][0]==UNLOCK )
  3113. {
  3114. script[n].locked=0;
  3115. script[n].instr_ptr++;
  3116.  
  3117. }
  3118. else if ( script[n].instruction[script[n].instr_ptr][0]==TOUCH)
  3119. {
  3120. long int obj1, obj2;
  3121. obj1=script[n].instruction[script[n].instr_ptr][1];
  3122. obj2=script[n].instruction[script[n].instr_ptr][2];
  3123.  
  3124. if ( fabs(data[1024*NUM_SCRIPTS+GLOBAL_STATES+obj1*9+0]-
  3125. data[1024*NUM_SCRIPTS+GLOBAL_STATES+obj2*9+0] ) < 30 &&
  3126. fabs(data[1024*NUM_SCRIPTS+GLOBAL_STATES+obj1*9+1]-
  3127. data[1024*NUM_SCRIPTS+GLOBAL_STATES+obj2*9+1] ) < 30 &&
  3128. fabs(data[1024*NUM_SCRIPTS+GLOBAL_STATES+obj1*9+8]-
  3129. data[1024*NUM_SCRIPTS+GLOBAL_STATES+obj2*9+8] ) < 30 &&
  3130.  
  3131. data[1024+NUM_SCRIPTS+GLOBAL_STATES+obj1*9+3]==
  3132. data[1024+NUM_SCRIPTS+GLOBAL_STATES+obj2*9+3]
  3133. )
  3134. data[TOUCHING]=1;
  3135. else data[TOUCHING]=0;
  3136.  
  3137. script[n].instr_ptr++;
  3138.  
  3139.  
  3140.  
  3141. }
  3142.  
  3143. if ( script[n].locked==0)n++; else continue;
  3144. }
  3145.  
  3146. }
  3147.  
  3148.  
  3149.  
  3150.  
  3151. int main(void)
  3152. {
  3153. clock_t timertick;
  3154. int pathgoalx, pathgoaly;
  3155.  
  3156.  
  3157. // Load graphic patterns and stuff, the preprocessor is very useful to keep things overviewable
  3158.  
  3159. FILE *pattfile;
  3160.  
  3161. pattfile=fopen(".\\sprites","rb");
  3162.  
  3163. fread(sprite,20*20*6,sizeof(unsigned char),pattfile);
  3164. fclose(pattfile);
  3165.  
  3166.  
  3167. pattfile=fopen(".\\rooms","rb");
  3168.  
  3169. roompatt=malloc(320*50*NUM_ROOMS);
  3170. roomz=malloc(320*50*NUM_ROOMS);
  3171.  
  3172. fread(roompatt,320*50*NUM_ROOMS, sizeof(unsigned char), pattfile);
  3173. fread(roomz,320*50*NUM_ROOMS, sizeof(unsigned char), pattfile);
  3174.  
  3175. fclose(pattfile);
  3176.  
  3177. initwalklayer();
  3178.  
  3179.  
  3180. // One directive, and you already have an assembler.
  3181. // The first value is not exactly the 'code segment', but the script number
  3182.  
  3183. #define VMCODE(n,adress,opcode,op1,op2) script[n].instruction[adress][0]=(opcode),\
  3184. script[n].instruction[adress][1]=(op1),\
  3185. script[n].instruction[adress][2]=(op2),
  3186.  
  3187.  
  3188.  
  3189. // Here our assmbler coding experiments begin.
  3190. // What riddle could we take?
  3191. // We start with basic needs, hand to mouth...
  3192.  
  3193. /*
  3194. VMCODE(0,0,ADD,X_SCROLL,100)
  3195. VMCODE(0,1,JMP,0,0)
  3196.  
  3197.  
  3198.  
  3199. VMCODE(1,0,IFCMP,TIMERTICK,101)
  3200. VMCODE(1,1,MOV,X_SCROLL,0)
  3201. VMCODE(1,2,JMP,0,0)
  3202.  
  3203.  
  3204. VMCODE(1,0,LOCK,0,0)
  3205. VMCODE(1,1,IFCMP,TIMERTICK,101)
  3206. VMCODE(1,2,JMP,5,0)
  3207. VMCODE(1,3,UNLOCK,0,0)
  3208. VMCODE(1,4,JMP,0,0)
  3209. VMCODE(1,5,ADD,2,101)
  3210. VMCODE(1,6,MOV,TIMERTICK,102)
  3211. VMCODE(1,7,UNLOCK,0,0)
  3212. VMCODE(1,8,IFCMP,2,103)
  3213. VMCODE(1,9,MOV,2,0)
  3214. VMCODE(1,10,JMP,0,0)
  3215.  
  3216. VMCODE(2,0,JMP,0,0)
  3217.  
  3218. */
  3219.  
  3220. VMCODE(0,0,UNLOCK,0,0)
  3221. VMCODE(0,1,LOCK,0,0)
  3222. VMCODE(0,2,IFCMP,ACTION_CODE,101)
  3223. VMCODE(0,3,JMP,5,0)
  3224. VMCODE(0,4,JMP,0,0)
  3225. VMCODE(0,5,IFCMP,ITEM_A,105)
  3226. VMCODE(0,6,JMP,8,0)
  3227. VMCODE(0,7,JMP,0,0)
  3228. VMCODE(0,8,MOV,SAY_SENTENCE,102)
  3229. VMCODE(0,9,MOV,OBJ_NUM(1)+3,102)
  3230. VMCODE(0,10,MOV,OBJ_NUM(2)+3,105)
  3231. VMCODE(0,11,MOV,ACTION_CODE,NOACTION)
  3232. VMCODE(0,12,UNLOCK,0,0)
  3233. VMCODE(0,13,JMP,0,0)
  3234.  
  3235. //Pfadsuche
  3236.  
  3237. VMCODE(1,0,UNLOCK,0,0)
  3238. VMCODE(1,1,UNLOCK,0,0)
  3239. VMCODE(1,2,LOCK,0,0)
  3240. VMCODE(1,3,IFCMP,ACTION_CODE,104)
  3241. VMCODE(1,4,JMP,6,0)
  3242. VMCODE(1,5,JMP,0,0)
  3243. VMCODE(1,6,MOV,ACTION_CODE,0)
  3244. VMCODE(1,7,MOV,OBJ_NUM(0)+7,106)
  3245. VMCODE(1,8,JMP,0,0)
  3246.  
  3247.  
  3248. VMCODE(2,0,UNLOCK,0,0)
  3249. VMCODE(2,1,LOCK,0,0)
  3250. VMCODE(2,2,IFCMP,OBJ_NUM(0)+7,105)
  3251. VMCODE(2,3,JMP,5,0)
  3252. VMCODE(2,4,JMP,0,0)
  3253. VMCODE(2,5,MOV,OBJ_NUM(0),OBJ_NUM(0)+4)
  3254. VMCODE(2,6,MOV,OBJ_NUM(0)+1,OBJ_NUM(0)+5)
  3255. VMCODE(2,7,MOV,OBJ_NUM(0)+8,OBJ_NUM(0)+6)
  3256. VMCODE(2,8,MOV,OBJ_NUM(0)+7,102)
  3257. //VMCODE(2,9,MOV,X_SCROLL,OBJ_NUM(0))
  3258. VMCODE(2,9,LOCK,0,0)
  3259.  
  3260. VMCODE(2,10,MOV,OBJ_NUM(0)+7,102)
  3261. VMCODE(2,11,JMP,0,0)
  3262.  
  3263.  
  3264.  
  3265. VMCODE(3,0,IFCMP,OBJ_NUM(0),107)
  3266. VMCODE(3,1,JMP,3,0)
  3267. VMCODE(3,2,JMP,0,0)
  3268. VMCODE(3,3,MOV,X_SCROLL,108 )
  3269. VMCODE(3,4,JMP,0,0)
  3270.  
  3271. VMCODE(4,0,IFCMP,OBJ_NUM(0),108)
  3272. VMCODE(4,1,JMP,3,0)
  3273. VMCODE(4,2,JMP,0,0)
  3274. VMCODE(4,3,MOV,X_SCROLL,102)
  3275. VMCODE(4,4,JMP,0,0)
  3276.  
  3277.  
  3278.  
  3279.  
  3280. // Benutze Zigarettenautomat mit Cash Card
  3281.  
  3282.  
  3283. VMCODE(5,0,UNLOCK,0,0)
  3284. VMCODE(5,1,LOCK,0,0)
  3285. VMCODE(5,2,IFCMP,ACTION_CODE,109)
  3286. VMCODE(5,3,JMP,5,0)
  3287. VMCODE(5,4,JMP,0,0)
  3288. VMCODE(5,5,IFCMP,ITEM_A,110)
  3289. VMCODE(5,6,JMP,8,0)
  3290. VMCODE(5,7,JMP,0,0)
  3291.  
  3292. VMCODE(5,8,IFCMP,ITEM_B,111)
  3293. VMCODE(5,9,JMP,11,0)
  3294. VMCODE(5,10,JMP,0,0)
  3295. VMCODE(5,11,TOUCH,0,5)
  3296. VMCODE(5,12,IFCMP,TOUCHING,105)
  3297. VMCODE(5,13,JMP,15,0)
  3298. VMCODE(5,14,JMP,19,0)
  3299. VMCODE(5,15,MOV,OBJ_NUM(4)+3,105)
  3300. VMCODE(5,16,MOV,ACTION_CODE,NOACTION)
  3301. VMCODE(5,17,UNLOCK,0,0)
  3302. VMCODE(5,18,JMP,0,0)
  3303. VMCODE(5,19,MOV,SAY_SENTENCE,105)
  3304. VMCODE(5,20,JMP,0,0)
  3305.  
  3306.  
  3307. // Benutze Feuerzeug mit Plaquestar Light
  3308.  
  3309. VMCODE(6,0,UNLOCK,0,0)
  3310. VMCODE(6,1,LOCK,0,0)
  3311. VMCODE(6,2,IFCMP,ACTION_CODE,109)
  3312. VMCODE(6,3,JMP,5,0)
  3313. VMCODE(6,4,JMP,0,0)
  3314. VMCODE(6,5,IFCMP,ITEM_A,112)
  3315. VMCODE(6,6,JMP,8,0)
  3316. VMCODE(6,7,JMP,0,0)
  3317.  
  3318. VMCODE(6,8,IFCMP,ITEM_B,113)
  3319. VMCODE(6,9,JMP,11,0)
  3320. VMCODE(6,10,JMP,0,0)
  3321. VMCODE(6,11,MOV,SAY_SENTENCE,110)
  3322. VMCODE(6,12,JMP,0,0)
  3323.  
  3324.  
  3325.  
  3326. // Variablen
  3327.  
  3328. // In the data part, you have to put some values at certain addresses because the byte-code also doesn't support direct values and so on...
  3329. // It would probably also make sense to extend the VM with registers and a stack option, however, theoretically full functionality is provided i guess
  3330.  
  3331. data[101]=LOOK;
  3332. data[102]=0;
  3333. data[103]=10;
  3334. data[104]=WALKTOXY;
  3335. data[105]=1;
  3336. data[106]=2;
  3337. data[107]=140;
  3338. data[108]=130;
  3339. data[109]=COMBINE;
  3340. data[110]=2;
  3341. data[111]=5;
  3342. data[112]=3;
  3343. data[113]=4;
  3344.  
  3345.  
  3346.  
  3347. data[X_SCROLL]=0;
  3348. data[Y_SCROLL]=0;
  3349. data[TIMERTICK]=0;
  3350.  
  3351. data[PATHSTARTOBJ]=0;
  3352. data[ROOM]=2;
  3353. data[OBJ_NUM(0)+3]=2;
  3354. data[OBJ_NUM(0)+2]=0;
  3355. data[OBJ_NUM(0)+0]=0;
  3356. data[OBJ_NUM(0)+1]=20;
  3357. data[OBJ_NUM(0)+8]=50; // war 9
  3358.  
  3359.  
  3360.  
  3361. data[OBJ_NUM(1)+3]=1;
  3362. data[OBJ_NUM(1)+2]=1;
  3363. data[OBJ_NUM(1)+0]=120;
  3364. data[OBJ_NUM(1)+1]=52;
  3365. data[OBJ_NUM(1)+8]=0;
  3366.  
  3367.  
  3368. data[OBJ_NUM(2)+3]=0;
  3369. data[OBJ_NUM(2)+2]=2;
  3370. data[OBJ_NUM(2)+0]=120;
  3371. data[OBJ_NUM(2)+1]=52;
  3372. data[OBJ_NUM(2)+8]=0;
  3373.  
  3374. data[OBJ_NUM(3)+3]=1;
  3375. data[OBJ_NUM(3)+2]=3;
  3376. data[OBJ_NUM(3)+0]=95;
  3377. data[OBJ_NUM(3)+1]=52;
  3378. data[OBJ_NUM(3)+8]=0;
  3379.  
  3380.  
  3381.  
  3382. data[OBJ_NUM(4)+3]=0;
  3383. data[OBJ_NUM(4)+2]=4;
  3384. data[OBJ_NUM(4)+0]=70;
  3385. data[OBJ_NUM(4)+1]=52;
  3386. data[OBJ_NUM(4)+8]=0;
  3387.  
  3388.  
  3389. data[OBJ_NUM(5)+3]=2;
  3390. data[OBJ_NUM(5)+2]=5;
  3391. data[OBJ_NUM(5)+0]=230;
  3392. data[OBJ_NUM(5)+1]=15;
  3393. data[OBJ_NUM(5)+8]=5;
  3394.  
  3395.  
  3396.  
  3397. data[SAY_SENTENCE]=-1;
  3398. data[ACTION_CODE]=NOACTION;
  3399. strcpy(objnames[0],"Billy"); // each object needs a text string
  3400. strcpy(objnames[1],"Wallet");
  3401. strcpy(objnames[2],"Cash Card");
  3402. strcpy(objnames[3],"Cigarette Lighter");
  3403. strcpy(objnames[4],"Plaquestar Light"); // no similarity to real products intended
  3404. strcpy(objnames[5],"Cigarette Machine");
  3405.  
  3406. strcpy(sentences[0],"There's my cash card with a special chip.'");
  3407. strcpy(sentences[1],"I first have to walk to the vending machine.");
  3408. strcpy(sentences[2],"Now I have cancer."); // we're not gonna propagate anything. No irony intended.
  3409.  
  3410.  
  3411. cursor[0]=80, cursor[1]=40;
  3412. timertick=(long int)clock()/10000;
  3413. while (1 )
  3414. {
  3415. VM_Step();
  3416. if ( clock()/10000 != timertick ) data [TIMERTICK]=1, timertick=clock()/10000; // When the timer value goes a second higher or changes significantly,
  3417. // we still will have enough time to transfer the notification into the script memory
  3418.  
  3419. //else data[TIMERTICK]=0;
  3420. int x=0, y=0;
  3421. while ( y < 90)
  3422. {
  3423. x=0;
  3424. while ( x< 160)
  3425. {
  3426. screen[x][y]=' '; // erase the screen
  3427. x++;
  3428. }
  3429. y++;
  3430. }
  3431.  
  3432. unsigned char cmd;
  3433. cmd=0;
  3434. if ( kbhit()) // Keyboard press trigger
  3435. {
  3436.  
  3437.  
  3438. switch(getch())
  3439. {
  3440. case 'h' : if ( cursor[0] > 3 ) cursor[0]-=3; break;
  3441. case 'k' : if ( cursor[0] < 156 ) cursor[0]+=3; break;
  3442. case 'u' : if ( cursor[1] > 3 ) cursor[1]-=3; break;
  3443. case 'j' : if ( cursor[1] < 84 ) cursor[1]+=3; break;
  3444. case 'l' : cmd=1; break;
  3445.  
  3446. }
  3447. }
  3448.  
  3449. // We can only move the cursor with four keys and 'click' with another
  3450.  
  3451.  
  3452. drawlevel(); // It is necessary to also provide the Z information to some other program parts, so this has to be done before
  3453.  
  3454.  
  3455.  
  3456. screen[cursor[0]][cursor[1]]='*';
  3457.  
  3458. screen[20][70]='L',screen[21][70]='o',screen[22][70]='o',screen[23][70]='k', // Nice interface design
  3459. screen[40][70]='P',screen[41][70]='i',screen[42][70]='c',screen[43][70]='k',
  3460. screen[60][70]='U',screen[61][70]='s',screen[62][70]='e';
  3461.  
  3462.  
  3463. // Build the command instructions together when there was a 'click'
  3464. // It may look like a sentence, but internally it are only 3 IDs
  3465. if ( cmd==1 )
  3466. {
  3467.  
  3468. signed int itema;
  3469.  
  3470.  
  3471. if ( fabs ( cursor[0]-22 ) < 5 && fabs (cursor[1]-70 ) < 5 ) data[ACTION_CODE]=PREP_LOOK;
  3472. else
  3473. if ( fabs ( cursor[0]-42 ) < 5 && fabs (cursor[1]-70 ) < 5 ) data[ACTION_CODE]=PREP_PICK;
  3474. else
  3475. if ( fabs ( cursor[0]-61 ) < 5 && fabs (cursor[1]-70 ) < 5 )data[ACTION_CODE]=PREP_COMBI;
  3476. else
  3477. {
  3478. if ( data[ACTION_CODE]==PREP_LOOK)
  3479. {
  3480. if ( (itema=getobjfromcoord(cursor[0],cursor[1]))!= -1)
  3481. {
  3482. data[ACTION_CODE]=LOOK;
  3483. data[ITEM_A]=itema;
  3484. }
  3485.  
  3486. }
  3487. else
  3488. if ( data[ACTION_CODE]==PREP_PICK)
  3489. {
  3490. if ( (itema=getobjfromcoord(cursor[0],cursor[1]))!= -1)
  3491. {
  3492. data[ACTION_CODE]=PICK;
  3493. data[ITEM_A]=itema;
  3494. }
  3495.  
  3496. }
  3497. else
  3498. if ( data[ACTION_CODE]==PREP_COMBI)
  3499. {
  3500. if ( (itema=getobjfromcoord(cursor[0],cursor[1]))!= -1)
  3501. {
  3502. data[ACTION_CODE]=PREP_COMBI_B;
  3503. data[ITEM_A]=itema;
  3504. }
  3505.  
  3506.  
  3507. }
  3508. else
  3509. if ( data[ACTION_CODE]==PREP_COMBI_B)
  3510. {
  3511. signed int itemb;
  3512. if ( (itemb=getobjfromcoord(cursor[0],cursor[1]))!= -1)
  3513. {
  3514. data[ACTION_CODE]=COMBINE;
  3515. data[ITEM_B]=itemb;
  3516. }
  3517.  
  3518.  
  3519. }
  3520. else if ( cursor[1] < 50) data[ACTION_CODE]=WALKTOXY, pathgoalx=cursor[0], pathgoaly=cursor[1]; // buffer the cursor target coordinates
  3521.  
  3522.  
  3523.  
  3524. }
  3525.  
  3526.  
  3527. }
  3528.  
  3529.  
  3530. system("cls\n");
  3531. y=0;
  3532. while ( y < 85)
  3533. {
  3534. x=0;
  3535. while ( x< 160)
  3536. {
  3537. printf("%c%c%c%c%c%c%c%c",screen[x][y], screen[x+1][y], screen[x+2][y], screen[x+3][y],screen[x+4][y],screen[x+5][y],screen[x+6][y],screen[x+7][y]);
  3538. //printf("%c%c%c%c",screen[x][y], screen[x+1][y], screen[x+2][y], screen[x+3][y]);
  3539.  
  3540. x+=8;
  3541. }
  3542. printf("\n");
  3543. y++;
  3544. }
  3545.  
  3546. if ( data[OBJ_NUM(data[PATHSTARTOBJ])+7]==2) // When a script has requested it, run the path search
  3547. if ( getobjNfromcoord(pathgoalx,pathgoaly,data[PATHSTARTOBJ])!=data[PATHSTARTOBJ] )
  3548. find_path(data[PATHSTARTOBJ],pathgoalx+data[X_SCROLL],pathgoaly),data[ACTION_CODE]=WALKTOXY; else {
  3549. data[OBJ_NUM(data[PATHSTARTOBJ])+7]=0,data[ACTION_CODE]=NOACTION; }
  3550.  
  3551. //printf("%d %d", data[OBJ_NUM(0)+4],data[OBJ_NUM(0)+5]);
  3552.  
  3553. // Dump the command sentence
  3554. if ( data[ACTION_CODE]==PREP_LOOK) printf("Look at ");
  3555. if ( data[ACTION_CODE]==PREP_PICK) printf("Pick Up");
  3556. if ( data[ACTION_CODE]==PREP_COMBI) printf("Use");
  3557. if ( data[ACTION_CODE]==LOOK) printf("Look at "), printf("%s",objnames[data[ITEM_A]]);
  3558. if ( data[ACTION_CODE]==PICK) printf("Pick Up "), printf("%s",objnames[data[ITEM_A]]);
  3559. if ( data[ACTION_CODE]==PREP_COMBI_B) printf("Use "), printf("%s",objnames[data[ITEM_A]]);
  3560. if ( data[ACTION_CODE]==COMBINE) printf("Use "), printf("%s",objnames[data[ITEM_A]]), printf(" with "), printf("%s", objnames[data[ITEM_B]]);
  3561. if ( data[SAY_SENTENCE]!=-1) printf("\n%s",sentences[data[SAY_SENTENCE]]);
  3562.  
  3563.  
  3564. }
  3565.  
  3566.  
  3567.  
  3568. }
  3569.  
  3570. ```
  3571.  
  3572. Dann habe ich neulich nochmal die Bezugsverkettung von Crosspoint nachprogrammiert-- Verzeichnisdarstellung als Stack, so wie DosTree...
  3573. ```cpp
  3574. /*
  3575. Use md name to create a directory,
  3576. touch name to create an entry in that directory
  3577. cd name to change to a directory in the current directory
  3578. root xx to go back to the root directory
  3579. current xx to show the name of the current subdirectory
  3580. and finally
  3581. dir xx to visualize the directory tree in 160x90 console resolution
  3582. */
  3583.  
  3584.  
  3585. struct
  3586. {
  3587. signed int nextelem[255];
  3588. unsigned char elems[255][10];
  3589.  
  3590. } datei;
  3591.  
  3592.  
  3593. unsigned char screen[160][120];
  3594.  
  3595. int Xshift,Yshift;
  3596.  
  3597. unsigned int pushelem[255];
  3598. unsigned int pusholdx[255];
  3599. unsigned int pusholdy[255];
  3600.  
  3601. int Stackcount;
  3602.  
  3603.  
  3604.  
  3605. int main(void)
  3606. {
  3607.  
  3608. int x,y;
  3609. unsigned char cmd[255], name[255];
  3610.  
  3611.  
  3612. int n=0,n2=0,n3=0;
  3613. while (n < 255 ) datei.nextelem[n]=-1, n++;
  3614. n=0;
  3615. Stackcount=0;
  3616.  
  3617. int curdir=0;
  3618.  
  3619. datei.nextelem[curdir]=-2;
  3620. datei.elems[curdir][0]='-';
  3621.  
  3622. pushelem[0]=0;
  3623.  
  3624. while (1 )
  3625. {
  3626.  
  3627. scanf ("%s %s", cmd, name );
  3628.  
  3629. if ( strcmp ( cmd, "touch" ) == 0 )
  3630. {
  3631.  
  3632. n=curdir;
  3633. while ( datei.elems[n][0]!='-' ) n=datei.nextelem[n];
  3634. strcpy(datei.elems[n], name );
  3635. datei.nextelem[n]=-3; // Pfuschdihuschdi
  3636.  
  3637. n2=0;
  3638. while ( datei.nextelem[n2] != -1 ) n2++;
  3639. datei.nextelem[n]=(unsigned char)n2;
  3640. datei.elems[n2][0]='-';
  3641. datei.nextelem[n2]=-2; // zeigt es auf kein naechstes Element, ist es frei
  3642.  
  3643. }
  3644.  
  3645.  
  3646.  
  3647.  
  3648. if ( strcmp ( cmd, "md" ) == 0 )
  3649. {
  3650.  
  3651. n=curdir;
  3652. while ( datei.elems[n][0]!='-' ) n=datei.nextelem[n];
  3653. strcpy(datei.elems[n]+2, name );
  3654. datei.nextelem[n]=-3; // Pfuschdihuschdi
  3655. datei.elems[n][0]='~';
  3656. n3=n;
  3657.  
  3658.  
  3659. n2=0;
  3660. while ( datei.nextelem[n2] != -1 ) n2++;
  3661. datei.elems[n][1]=(unsigned char)n2;
  3662.  
  3663.  
  3664. int n4=0;
  3665. n4=n2;
  3666. datei.nextelem[n2]=-3; // Pfuschdihuschdi
  3667.  
  3668. //datei.nextelem[n2]=-2;
  3669.  
  3670.  
  3671. datei.elems[n2][0]='-';
  3672.  
  3673.  
  3674.  
  3675. n2=0;
  3676. while ( datei.nextelem[n2] != -1 ) n2++;
  3677. datei.nextelem[n2]=-2;
  3678. datei.elems[n2][0]='-';
  3679.  
  3680. datei.nextelem[n3]=(unsigned char)n2;
  3681.  
  3682. datei.nextelem[n4]=-2;
  3683.  
  3684.  
  3685. }
  3686.  
  3687. if ( strcmp(cmd,"current")==0)printf("%s>>",datei.elems[curdir]);
  3688.  
  3689. if ( strcmp (cmd,"root")==0 ) curdir=0;
  3690.  
  3691. if ( strcmp ( cmd, "cd" ) == 0 )
  3692. {
  3693.  
  3694. n=curdir;
  3695. while ( datei.elems[n][0]!='-' &&
  3696.  
  3697. (strcmp( datei.elems[ n/*datei.nextelem[n] */ ]+2,name)!=0 ||datei.elems[ n /* datei.nextelem[n] */ ][0]!='~' ) ) n=datei.nextelem[n];
  3698.  
  3699. if ( datei.elems[n][0]!='-') curdir=datei.elems[n][1];
  3700.  
  3701. }
  3702.  
  3703. if ( strcmp(cmd,"dir" ) == 0 )
  3704. {
  3705. y=0;
  3706. while ( y < 90 )
  3707. {
  3708. x=0;
  3709. while ( x < 160 )
  3710. {
  3711. screen[x][y]=' ';
  3712. x++;
  3713. }
  3714. y++;
  3715. }
  3716.  
  3717.  
  3718. Xshift=0, Yshift=0;
  3719. Stackcount=1;
  3720. n=0;
  3721.  
  3722. int Stackcount2=0;
  3723. Stackcount2=0;
  3724.  
  3725. pusholdx[Stackcount2]=0;
  3726. pusholdy[Stackcount2]=0;
  3727.  
  3728.  
  3729. do
  3730. {
  3731.  
  3732. if ( datei.elems[n][0]=='~' )
  3733. {
  3734.  
  3735.  
  3736. n2=2;
  3737.  
  3738. //printf("Verzeichnis: %s",datei.elems[n]), getch();
  3739.  
  3740. x=pusholdx[Stackcount2];
  3741. y=pusholdy[Stackcount2];
  3742.  
  3743. Xshift=x+10;
  3744. Yshift+=5;
  3745.  
  3746. while ( y< Yshift)
  3747. {
  3748. if ( y < Yshift) screen[x][y]==' ' ? screen[x][y]=219:0, y++;
  3749.  
  3750. }
  3751.  
  3752.  
  3753. while ( x< Xshift)
  3754. {
  3755. if ( x < Xshift) screen[x][y]= screen[x][y]==' ' ? screen[x][y]=219:0, x++;
  3756. }
  3757.  
  3758. while ( datei.elems[n][n2]!='\0' ) screen[Xshift+n2-2] [Yshift]=datei.elems[n][n2],n2++;
  3759.  
  3760.  
  3761. Stackcount2++;
  3762. pusholdx[Stackcount2]=Xshift;
  3763. pusholdy[Stackcount2]=Yshift;
  3764.  
  3765. pushelem[Stackcount]=datei.nextelem[n] ;
  3766. n= datei.elems[n][1];
  3767. //n=datei.nextelem[n];
  3768.  
  3769.  
  3770. //printf("%s",datei.elems[n]), getch();
  3771. Stackcount++;
  3772. }
  3773. else
  3774. if ( datei.elems[n][0]=='-' )
  3775. {
  3776. Stackcount--;
  3777. Stackcount2--;
  3778. n=pushelem[Stackcount];
  3779. }
  3780. else
  3781. {
  3782.  
  3783. x=pusholdx[Stackcount2];
  3784. y=pusholdy[Stackcount2];
  3785.  
  3786. Yshift+=5;
  3787. Xshift=x;
  3788.  
  3789. while ( y< Yshift)
  3790. {
  3791. if ( y < Yshift) screen[x][y]==' ' ? screen[x][y]=219:0, y++;
  3792.  
  3793. }
  3794.  
  3795.  
  3796. while ( x< Xshift)
  3797. {
  3798. if ( x < Xshift) screen[x][y]==' ' ? screen[x][y]=219:0, x++;
  3799. }
  3800.  
  3801. n2=0;
  3802. //printf("Flach: %s",datei.elems[n]),getch();
  3803. while ( datei.elems[n][n2]!='\0' ) screen[Xshift+n2] [Yshift]=datei.elems[n][n2],n2++;
  3804. n=datei.nextelem[n];
  3805.  
  3806. pusholdx[Stackcount2]=Xshift;
  3807. pusholdy[Stackcount2]=Yshift;
  3808.  
  3809.  
  3810. }
  3811.  
  3812.  
  3813. } while ( Stackcount > 0 /*|| datei.elems[n][0]!='-' */);
  3814.  
  3815.  
  3816.  
  3817. system("cls\n");
  3818. y=0;
  3819. while ( y < 80 )
  3820. {
  3821. x=0;
  3822. while ( x < 160 )
  3823. {
  3824. printf("%c",screen[x][y] );
  3825. x++;
  3826. }
  3827. printf("\n");
  3828. y++;
  3829. }
  3830.  
  3831.  
  3832. }
  3833.  
  3834. }
  3835. }
  3836.  
  3837. ```
  3838.  
  3839. Ich hoffe, daß die Quelltexte icht den Thread sprengen. Wie gesagt, im derzeitigen Zustand sind sie noch recht häßlich. Aber es dreht sich ja wohl darum, grundlegegende Probleme zu lösen. Und ich glaube, das habe ich dennoch "schön" gemacht.
  3840. Hier noch das Blockscrolling eines 2D-Jump N' Runs:
  3841. ```cpp
  3842. unsigned char level[600]=
  3843. {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3844. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3845. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3846. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3847. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3848. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3849. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3850. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3851. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3852. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3853. 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3854. 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3855. 0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3856. 0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  3857. 0,1,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1 };
  3858.  
  3859. unsigned char block[25]={219,219,'@',219,219,
  3860. 219,219,'@',219,219,
  3861. 219,'@','@','@',219,
  3862. 219,219,'@',219,219,
  3863. 219,219,'@',219,219 };
  3864.  
  3865.  
  3866. struct
  3867. {
  3868. int x, y;
  3869. int jump;
  3870.  
  3871. } maennle;
  3872.  
  3873. int main(void)
  3874. {
  3875. int c;
  3876. int scroll_x;
  3877. int block_n;
  3878. unsigned char screen[160][120];
  3879. long int runs=0;
  3880.  
  3881. scroll_x=0;
  3882.  
  3883. maennle.x=30, maennle.y=40;
  3884. maennle.jump=0;
  3885.  
  3886. while ( 1 )
  3887. {
  3888. maennle.y++;
  3889.  
  3890. if ( kbhit() )
  3891. {
  3892. c=getch();
  3893. if ( c=='l' )
  3894. {
  3895. if ( maennle.x/5 +1 < 200-160)
  3896. if (level[maennle.x/5+1+(maennle.y/5)*40]==0) maennle.x++;
  3897. }
  3898. else if ( c=='k' )
  3899. {
  3900. if ( maennle.x/5-1 > 0) if (level[maennle.x/5-1+(maennle.y/5)*40]==0) maennle.x--;
  3901. }
  3902. else if ( c=='o' && maennle.jump==0 )
  3903. {
  3904. if ( ((maennle.y+1)/5) < 15) if (level[maennle.x/5+((maennle.y+1)/5)*40]==1) maennle.jump=10;
  3905. }
  3906.  
  3907.  
  3908. }
  3909. int x,y;
  3910.  
  3911. scroll_x=maennle.x-40 > 0 ? maennle.x-40 : 0;
  3912. if ( scroll_x > 200-160) scroll_x=200-160;
  3913.  
  3914.  
  3915. if ( maennle.jump > 0 &&level[maennle.x/5+((maennle.y-1)/5)*40]==0) maennle.y-=2, maennle.jump--;
  3916. else if ( maennle.jump > 0) maennle.jump--;
  3917.  
  3918. if (level[maennle.x/5+((maennle.y+1)/5)*40]==1 ) maennle.y--;
  3919.  
  3920.  
  3921. if ( maennle.y/5==15) printf("\a");
  3922.  
  3923. x=0, y=0;
  3924. while ( y < 90 )
  3925. {
  3926. x=0;
  3927. while ( x < 160 )
  3928. {
  3929. screen[x][y]=' ';
  3930. x++;
  3931. }
  3932. y++;
  3933. }
  3934.  
  3935.  
  3936. int block_n_start;
  3937. block_n_start=scroll_x/5;
  3938. int offset;
  3939. int y_map;
  3940. offset=scroll_x%5;
  3941.  
  3942. block_n=1;
  3943. while ( block_n < 32 )
  3944. {
  3945. y_map=0;
  3946. while ( y_map < 15 )
  3947. {
  3948. if ( level[block_n_start+block_n+y_map*40]==1 )
  3949. {
  3950. y=0;
  3951.  
  3952. while ( y < 5 )
  3953. {
  3954. x=0;
  3955. while ( x < 5 )
  3956. {
  3957. screen[block_n*5+x-offset][y_map*5+y]=block[x+y*5];
  3958. x++;
  3959. }
  3960. y++;
  3961.  
  3962. }
  3963.  
  3964.  
  3965. }
  3966. y_map++;
  3967. }
  3968.  
  3969. block_n++;
  3970. }
  3971.  
  3972. screen[maennle.x-scroll_x][maennle.y-1]='o';
  3973. screen[maennle.x-scroll_x][maennle.y]='O';
  3974. screen[maennle.x-1-scroll_x][maennle.y]='/';
  3975. screen[maennle.x+1-scroll_x][maennle.y]='\\';
  3976. screen[maennle.x-scroll_x][maennle.y+1]='M';
  3977. screen[maennle.x-scroll_x][maennle.y+2]='|';
  3978. screen[maennle.x+1-scroll_x][maennle.y+2]='|';
  3979.  
  3980.  
  3981. if ( runs%3==0)
  3982. {
  3983. system("cls\n");
  3984.  
  3985. x=0, y=0;
  3986. while ( y < 90 )
  3987. {
  3988. x=0;
  3989. while ( x < 159 )
  3990. {
  3991. if ( x < 4 || x > 155) printf("||||"); else
  3992. printf("%c%c%c%c",screen[x][y],screen[x+1][y],screen[x+2][y],screen[x+3][y]);
  3993. x+=4;
  3994. }
  3995.  
  3996. printf("\n");
  3997. y++;
  3998. }
  3999.  
  4000.  
  4001.  
  4002.  
  4003. }
  4004.  
  4005. runs++;
  4006. }
  4007.  
  4008.  
  4009.  
  4010.  
  4011. }
  4012.  
  4013. ```
RAW Paste Data