Free Hero Mesh

Check-in [3f12058d2d]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Make some improvements to compile script, and start edit.c (just a stub so far)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3f12058d2de1220ca1410f418781f6116268cad9
User & Date: user on 2018-10-07 04:25:13
Other Links: manifest | tags
Context
2018-10-20
18:09
Begin implementing the editor; also start to implement execution of key binding commands check-in: 4d0fdefe0c user: user tags: trunk
2018-10-07
04:25
Make some improvements to compile script, and start edit.c (just a stub so far) check-in: 3f12058d2d user: user tags: trunk
2018-09-10
01:16
Implement INSERT/UPDATE/DELETE for OBJECTS virtual table (untested) check-in: ec1c70d3d1 user: user tags: trunk
Changes

Modified compile from [5fc19466c4] to [076c585a54].

1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26


27
28
29
#!/bin/bash --

test -f CFLAGS || echo xxx > CFLAGS
test "xx$CFLAGS" = "x`cat CFLAGS`" || rm bindings.o class.o picture.o function.o exec.o
echo "x$CFLAGS" > CFLAGS
test "x$EXE" = "x" && EXE=~/bin/heromesh
echo 'Flags: ' "$CFLAGS"
echo 'Target filename: ' "$EXE"
test instruc -nt instruc.h && node instruc.js > instruc.h
test instruc.js -nt instruc.h && node instruc.js > instruc.h
test names.js -nt names.h && node names.js > names.h
test quarks -nt quarks.h && node quarks.js > quarks.h
test quarks.js -nt quarks.h && node quarks.js > quarks.h
test heromesh.h -nt "$EXE" && rm bindings.o class.o picture.o function.o exec.o
test instruc.h -nt "$EXE" && rm class.o
test pcfont.h -nt "$EXE" && rm picture.o
test quarks.h -nt "$EXE" && rm bindings.o picture.o
echo '* bindings'
test bindings.c -nt bindings.o && bash bindings.c
echo '* class'
test class.c -nt class.o && bash class.c
echo '* function'
test function.c -nt function.o && bash function.c
echo '* picture'
test picture.c -nt picture.o && bash picture.c
echo '* exec'
test exec.c -nt exec.o && bash exec.c


echo '* main'
bash main.c
echo 'DONE'

>

|









|
|
|
|










>
>



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash --
set -e
test -f CFLAGS || echo xxx > CFLAGS
test "xx$CFLAGS" = "x`cat CFLAGS`" || rm bindings.o class.o picture.o function.o exec.o edit.o || true
echo "x$CFLAGS" > CFLAGS
test "x$EXE" = "x" && EXE=~/bin/heromesh
echo 'Flags: ' "$CFLAGS"
echo 'Target filename: ' "$EXE"
test instruc -nt instruc.h && node instruc.js > instruc.h
test instruc.js -nt instruc.h && node instruc.js > instruc.h
test names.js -nt names.h && node names.js > names.h
test quarks -nt quarks.h && node quarks.js > quarks.h
test quarks.js -nt quarks.h && node quarks.js > quarks.h
test heromesh.h -nt "$EXE" && rm bindings.o class.o picture.o function.o exec.o edit.o || true
test instruc.h -nt "$EXE" && rm class.o || true
test pcfont.h -nt "$EXE" && rm picture.o || true
test quarks.h -nt "$EXE" && rm bindings.o picture.o || true
echo '* bindings'
test bindings.c -nt bindings.o && bash bindings.c
echo '* class'
test class.c -nt class.o && bash class.c
echo '* function'
test function.c -nt function.o && bash function.c
echo '* picture'
test picture.c -nt picture.o && bash picture.c
echo '* exec'
test exec.c -nt exec.o && bash exec.c
echo '* edit'
test edit.c -nt edit.o && bash edit.c
echo '* main'
bash main.c
echo 'DONE'

Added edit.c version [240eb74098].

































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#if 0
gcc ${CFLAGS:--s -O2} -c edit.c `sdl-config --cflags`
exit
#endif

#include "SDL.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sqlite3.h"
#include "smallxrm.h"
#include "heromesh.h"

void run_editor(void) {
  fatal("[Editor not implemented yet]\n"); // so far just a stub
}

Modified exec.c from [b18753cc8b] to [c5ee33d3db].

107
108
109
110
111
112
113

114
115
116
117
118
119
120
  objects[n]=o;
  return n;
  bad:
  free(o);
  return VOIDLINK;
}


static void execute_program(Uint16*code,int ptr,Uint32 obj) {
  Object*o=objects[obj];
  if(StackProtection()) Throw("Call stack overflow");
  for(;;) switch(code[ptr++]) {
    case OP_GOTO: ptr=code[ptr]; break;
    case OP_CALLSUB: execute_program(code,code[ptr++],obj); break;
    case OP_RET: return;







>







107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
  objects[n]=o;
  return n;
  bad:
  free(o);
  return VOIDLINK;
}

// Here is where the execution of a Free Hero Mesh bytecode subroutine is executed.
static void execute_program(Uint16*code,int ptr,Uint32 obj) {
  Object*o=objects[obj];
  if(StackProtection()) Throw("Call stack overflow");
  for(;;) switch(code[ptr++]) {
    case OP_GOTO: ptr=code[ptr]; break;
    case OP_CALLSUB: execute_program(code,code[ptr++],obj); break;
    case OP_RET: return;

Modified heromesh.h from [bef1fa2bb9] to [6365c4e997].

188
189
190
191
192
193
194





extern Uint8 pfwidth,pfheight;

void pfunlink(Uint32 n);
void pflink(Uint32 n);
Uint32 objalloc(Uint16 c);
void annihilate(void);
const char*execute_turn(int key);












>
>
>
>
>
188
189
190
191
192
193
194
195
196
197
198
199
extern Uint8 pfwidth,pfheight;

void pfunlink(Uint32 n);
void pflink(Uint32 n);
Uint32 objalloc(Uint16 c);
void annihilate(void);
const char*execute_turn(int key);

// == edit ==

void run_editor(void);

Modified main.c from [3f8604fa56] to [281782dbc2].

1
2
3
4
5
6
7
8
9
#if 0
gcc ${CFLAGS:--s -O2} -o ${EXE:-~/bin/heromesh} main.c class.o picture.o bindings.o function.o exec.o smallxrm.o sqlite3.o `sdl-config --cflags --libs` -ldl -lpthread
exit
#endif

/*
  This program is part of Free Hero Mesh and is public domain.
*/


|







1
2
3
4
5
6
7
8
9
#if 0
gcc ${CFLAGS:--s -O2} -o ${EXE:-~/bin/heromesh} main.c class.o picture.o bindings.o function.o exec.o edit.o smallxrm.o sqlite3.o `sdl-config --cflags --libs` -ldl -lpthread
exit
#endif

/*
  This program is part of Free Hero Mesh and is public domain.
*/

724
725
726
727
728
729
730

731
732
733
734
735
736
737
    v=malloc(strtoll(v+1,0,0));
    fatal("%p %p :: %lld\n",v,stack_protect_mark,(long long)(((char*)stack_protect_mark)-v));
  }
  if(v[1]) stack_protect_mark=((char*)stack_protect_mark)+strtoll(v+1,0,0);
}
#endif


int main(int argc,char**argv) {
  int optind=1;
  while(argc>optind && argv[optind][0]=='-') {
    int i;
    const char*s=argv[optind++];
    if(s[1]=='-' && !s[2]) break;
    for(i=1;s[i];i++) main_options[s[i]&127]=1;







>







724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
    v=malloc(strtoll(v+1,0,0));
    fatal("%p %p :: %lld\n",v,stack_protect_mark,(long long)(((char*)stack_protect_mark)-v));
  }
  if(v[1]) stack_protect_mark=((char*)stack_protect_mark)+strtoll(v+1,0,0);
}
#endif

#define run_game() fatal("[Not implemented yet]\n")
int main(int argc,char**argv) {
  int optind=1;
  while(argc>optind && argv[optind][0]=='-') {
    int i;
    const char*s=argv[optind++];
    if(s[1]=='-' && !s[2]) break;
    for(i=1;s[i];i++) main_options[s[i]&127]=1;
774
775
776
777
778
779
780
781
782
  max_objects=strtoll(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"",0,0)?:0xFFFF0000L;
  annihilate();
  if(main_options['x']) {
    fprintf(stderr,"Ready for executing SQL statements.\n");
    do_sql_mode();
    return 0;
  }
  return 0; // for(;;) { if(main_options['e']) run_editor(); else run_game(); }
}







|

775
776
777
778
779
780
781
782
783
  max_objects=strtoll(xrm_get_resource(resourcedb,optionquery,optionquery,2)?:"",0,0)?:0xFFFF0000L;
  annihilate();
  if(main_options['x']) {
    fprintf(stderr,"Ready for executing SQL statements.\n");
    do_sql_mode();
    return 0;
  }
  for(;;) { if(main_options['e']) run_editor(); else run_game(); }
}