You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(296) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(90) |
Aug
(9) |
Sep
|
Oct
|
Nov
|
Dec
(3) |
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(5) |
From: Paul P. <ppr...@us...> - 2005-12-22 23:22:22
|
Update of /cvsroot/squidfighter/swordoffargoal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21431 Modified Files: fargoal.dsp Log Message: - added pegw0's graphics set Index: fargoal.dsp =================================================================== RCS file: /cvsroot/squidfighter/swordoffargoal/fargoal.dsp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** fargoal.dsp 31 Jul 2003 02:20:54 -0000 1.2 --- fargoal.dsp 22 Dec 2005 23:22:07 -0000 1.3 *************** *** 44,48 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c ! # ADD CPP /nologo /MD /W3 /GX /O2 /I "src" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "ALLEGRO_STATICLINK" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 --- 44,48 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c ! # ADD CPP /nologo /MD /W3 /GX /O2 /I "src" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "ALLEGRO_STATICLINK" /FR /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 |
From: Paul P. <ppr...@us...> - 2005-12-22 23:22:21
|
Update of /cvsroot/squidfighter/swordoffargoal/gfx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21431/gfx Added Files: da_chars.bmp da_layout.bmp da_tiles.bmp Log Message: - added pegw0's graphics set --- NEW FILE: da_tiles.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: da_chars.bmp --- (This appears to be a binary file; contents omitted.) --- NEW FILE: da_layout.bmp --- (This appears to be a binary file; contents omitted.) |
From: Paul P. <ppr...@us...> - 2005-12-22 23:22:21
|
Update of /cvsroot/squidfighter/swordoffargoal/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21431/data Modified Files: sof.cfg Log Message: - added pegw0's graphics set Index: sof.cfg =================================================================== RCS file: /cvsroot/squidfighter/swordoffargoal/data/sof.cfg,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** sof.cfg 28 Jul 2003 18:51:40 -0000 1.11 --- sof.cfg 22 Dec 2005 23:22:07 -0000 1.12 *************** *** 158,159 **** --- 158,200 ---- color_time = #840603 color_blink = #840603 + + [scheme4] + name = Darrison's Adventure + tileset = gfx/da_tiles.bmp + sprites = gfx/da_chars.bmp + author = pegw0 + + layout = gfx/da_layout.bmp + + color_title = #ffffff + color_menu = #909090 + color_highlight = #00ffff + color_selected = #ff0000 + + color_message = #ffffff + color_help = #ffffff + + color_gold = #aaaaaa + + color_healthy = #00ff00 + color_health = #ffff00 + color_hurt = #ff0000 + + color_stats = #aaaaaa + color_info = #aaaaaa + color_dungeon = #aaaaaa + + color_empty = #aaaaaa + color_beacons = #aaaaaa + color_beacon = #aaaaaa + color_sacks = #aaaaaa + color_potions = #aaaaaa + color_nopotions = #ff0000 + + color_nospell = #000000 + color_spell = #aaaaaa + color_cast = #00ffff + + color_time = #aaaaaa + color_blink = #ff0000 + |
From: Elias P. <el...@us...> - 2005-12-04 12:02:43
|
Update of /cvsroot/squidfighter/swordoffargoal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv492 Modified Files: main.c Log Message: made mouse appear for dialog Index: main.c =================================================================== RCS file: /cvsroot/squidfighter/swordoffargoal/main.c,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** main.c 4 Dec 2005 11:59:41 -0000 1.38 --- main.c 4 Dec 2005 12:02:33 -0000 1.39 *************** *** 511,514 **** --- 511,515 ---- 0, 0, 0, 0, 0, 0, NULL, NULL, NULL} }; + install_mouse(); font = allegro_font; set_dialog_color (d, makecol (0, 0, 0), makecol (250, 240, 190)); *************** *** 525,529 **** d[1].dp = goodbye; ! a = do_dialog (d, 2); free (goodbye); --- 526,530 ---- d[1].dp = goodbye; ! a = do_dialog (d, 3); free (goodbye); |
From: Elias P. <el...@us...> - 2005-12-04 11:59:53
|
Update of /cvsroot/squidfighter/swordoffargoal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31917 Modified Files: agreement.txt credits.c main.c menu.c menu.h save.c Added Files: goodbye.txt Log Message: added exit dialog Index: save.c =================================================================== RCS file: /cvsroot/squidfighter/swordoffargoal/save.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** save.c 30 Jul 2003 16:36:10 -0000 1.10 --- save.c 4 Dec 2005 11:59:41 -0000 1.11 *************** *** 70,74 **** #define load(var) \ ! ass_get (#var, &var); --- 70,74 ---- #define load(var) \ ! ass_get (#var, (int *)&var); --- NEW FILE: goodbye.txt --- Thank you for playing Sword of Fargoal. We hope you enjoyed it. Your continued support is greatly appreciated. Please visit "www.fargoal.com" and follow the PayPal link. You may donate $4.50 (or more) to help us continue to develop future Sword of Fargoal (TM) versions. Are you sure you want to leave? Index: credits.c =================================================================== RCS file: /cvsroot/squidfighter/swordoffargoal/credits.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** credits.c 30 Jul 2003 06:46:03 -0000 1.7 --- credits.c 4 Dec 2005 11:59:41 -0000 1.8 *************** *** 9,12 **** --- 9,13 ---- { "", + "Latest \"Sword of Fargoal\" news at www.fargoal.com", "Check out the 'Game Settings' menu to experience either Classic...", "...or Enhanced play options for Sword of Fargoal!", Index: agreement.txt =================================================================== RCS file: /cvsroot/squidfighter/swordoffargoal/agreement.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** agreement.txt 29 Jun 2004 19:46:46 -0000 1.1 --- agreement.txt 4 Dec 2005 11:59:41 -0000 1.2 *************** *** 1,13 **** ! "Sword of Fargoal(TM)" is a registered trademark of Jeff ! McCord, dba Freelancelot®. The Sword of Fargoal(TM) game ! elements, including game play, background "quest" story, ! music, sound effects and graphic design are the intellectual ! property of Jeff McCord, protected by United States and ! applicable treaty, copyright, trademark, and other ! proprietary laws. This official remake version of Sword of ! Fargoal® is an authorized and licensed remake with ! enhancements and programming by Paul Pridham and Elias ! Pschernig. Game elements of this official remake version are ! protected by United States and applicable treaty, copyright, ! trademark, and other laws, and are the intellectual property ! of Jeff McCord and/or Paul Pridham and/or Elias Pschernig. --- 1,3 ---- ! "Sword of Fargoal(TM)" is a registered trademark of Jeff McCord, dba Freelancelot®. The Sword of Fargoal(TM) game elements, including game play, background "quest" story, music, sound effects and graphic design are the intellectual property of Jeff McCord, protected by United States and applicable treaty, copyright, trademark, and other proprietary laws. This official remake version of Sword of Fargoal® is an authorized and licensed remake with enhancements and programming by Paul Pridham and Elias Pschernig. Game elements of this official remake version are protected by United States and applicable treaty, copyright, trademark, and other laws, and are the intellectual property of Jeff McCord and/or Paul Pridham and/or Elias Pschernig. ! ! Please check the official "Sword of Fargoal" website for the latest "Sword of Fargoal" news at www.fargoal.com. Index: menu.h =================================================================== RCS file: /cvsroot/squidfighter/swordoffargoal/menu.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** menu.h 30 Jul 2003 23:02:27 -0000 1.2 --- menu.h 4 Dec 2005 11:59:41 -0000 1.3 *************** *** 7,8 **** --- 7,10 ---- void menu_render (void); void menu_exit (void); + + void menu_redraw(void); Index: main.c =================================================================== RCS file: /cvsroot/squidfighter/swordoffargoal/main.c,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** main.c 29 Jun 2004 19:46:47 -0000 1.37 --- main.c 4 Dec 2005 11:59:41 -0000 1.38 *************** *** 32,35 **** --- 32,37 ---- int USE_DRS = 1; + FONT *allegro_font; + static int quit = 0; *************** *** 138,141 **** --- 140,144 ---- { DATAFILE *fontdata = load_datafile ("gfx/sword.dat"); + allegro_font = font; if (!fontdata) *************** *** 404,408 **** char *agreement; int w = SCREEN_W / 2; ! int h = 2 * SCREEN_H / 3; int a; DIALOG d[] = --- 407,411 ---- char *agreement; int w = SCREEN_W / 2; ! int h = 400; int a; DIALOG d[] = *************** *** 450,453 **** --- 453,457 ---- } + start: framecounter = 0; framecounttime = ticks; *************** *** 488,495 **** --- 492,548 ---- } + { + FONT *temp = font; + char *goodbye; + int w = SCREEN_W / 2; + int h = 400; + int a; + DIALOG d[] = + { + {d_shadow_box_proc, 0, 0, w - 20, h - 20, + 0, 0, 0, 0, 0, 0, NULL, NULL, NULL}, + {d_textbox_proc, 10, 10, w - 40, h - 80, + 0, 0, 0, 0, 0, 0, NULL, NULL, NULL}, + {d_button_proc, 10, h - 40, 80, 12, + 0, 0, 27, D_EXIT, 0, 0, (void *)"Back", NULL, NULL}, + {d_button_proc, w - 30 - 80, h - 40, 80, 12, + 0, 0, 13, D_EXIT, 0, 0, (void *)"Exit", NULL, NULL}, + {NULL, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, NULL, NULL, NULL} + }; + font = allegro_font; + set_dialog_color (d, makecol (0, 0, 0), makecol (250, 240, 190)); + d[0].bg = makecol (200, 190, 180); + centre_dialog (d); + + { + int s = file_size ("goodbye.txt"); + PACKFILE *file = pack_fopen ("goodbye.txt", "r"); + goodbye = calloc (1 + s, 1); + pack_fread (goodbye, s, file); + pack_fclose (file); + } + d[1].dp = goodbye; + + a = do_dialog (d, 2); + + free (goodbye); + + if (a == 2) + { + quit = 0; + menu_redraw(); + font = temp; + goto start; + } + + } + remove ("data/last.log"); save_settings (); + run_exit (); + return 0; } Index: menu.c =================================================================== RCS file: /cvsroot/squidfighter/swordoffargoal/menu.c,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** menu.c 26 May 2005 18:23:05 -0000 1.59 --- menu.c 4 Dec 2005 11:59:41 -0000 1.60 *************** *** 649,652 **** --- 649,660 ---- void + menu_redraw(void) + { + update_top = 1; + update_main = 1; + update_bottom = 1; + } + + void menu_init (void) { *************** *** 744,748 **** --- 752,759 ---- messages_update (); if (credits_scroll ()) + { update_top = 1; + update_bottom = 1; + } } *************** *** 886,890 **** blit (title, page, 0, SCREEN_H - 90, 0, SCREEN_H - 90, SCREEN_W, 90); textprintf_right (page, font, SCREEN_W - 5, SCREEN_H - 5 - 8, ! layout_color (LC_HELP), "remakes.org"); } --- 897,902 ---- blit (title, page, 0, SCREEN_H - 90, 0, SCREEN_H - 90, SCREEN_W, 90); textprintf_right (page, font, SCREEN_W - 5, SCREEN_H - 5 - 8, ! layout_color (LC_HELP), (frames / (FPS * 4) & 1) ? ! "www.fargoal.com" : "www.remakes.org"); } |
From: Paul P. <ppr...@us...> - 2005-05-26 18:23:20
|
Update of /cvsroot/squidfighter/swordoffargoal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22219 Modified Files: menu.c player.c Log Message: - added numpad input Index: player.c =================================================================== RCS file: /cvsroot/squidfighter/swordoffargoal/player.c,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -d -r1.105 -r1.106 *** player.c 30 Jul 2003 16:36:10 -0000 1.105 --- player.c 26 May 2005 18:23:05 -0000 1.106 *************** *** 46,50 **** { int rate, multiplier; ! if (list[id].fighting || list[id].hit < 0 || paused) return; --- 46,50 ---- { int rate, multiplier; ! if(list[id].fighting || list[id].hit < 0 || paused) return; [...1073 lines suppressed...] *** 1270,1278 **** } case SPOT_TEMPLE: ! if (list[id].gold) { message (FPS, sacrifice, "Sacrifice of gold!"); list[id].exp += list[id].gold; ! if (extensions_balance) { { --- 1327,1335 ---- } case SPOT_TEMPLE: ! if(list[id].gold) { message (FPS, sacrifice, "Sacrifice of gold!"); list[id].exp += list[id].gold; ! if(extensions_balance) { { Index: menu.c =================================================================== RCS file: /cvsroot/squidfighter/swordoffargoal/menu.c,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** menu.c 1 Aug 2003 20:27:22 -0000 1.58 --- menu.c 26 May 2005 18:23:05 -0000 1.59 *************** *** 722,742 **** menu_run (void) { ! if (check_key (KEY_ENTER) || check_key (KEY_LCONTROL)) { menu (0); } ! if (check_key (KEY_LEFT)) { menu (-2); } ! if (check_key (KEY_RIGHT)) { menu (2); } ! if (check_key (KEY_DOWN)) { menu (1); } ! if (check_key (KEY_UP)) { menu (-1); --- 722,742 ---- menu_run (void) { ! if (check_key(KEY_ENTER)||check_key(KEY_LCONTROL)||check_key(KEY_ENTER_PAD)) { menu (0); } ! if (check_key(KEY_LEFT)||check_key(KEY_4_PAD)) { menu (-2); } ! if (check_key(KEY_RIGHT)||check_key(KEY_6_PAD)) { menu (2); } ! if (check_key(KEY_DOWN)||check_key(KEY_2_PAD)) { menu (1); } ! if (check_key(KEY_UP)||check_key(KEY_8_PAD)) { menu (-1); |
From: Elias P. <el...@us...> - 2004-12-08 17:22:12
|
Update of /cvsroot/squidfighter/deathfist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv724 Modified Files: main.c Log Message: made it not use 100% CPU all the time Index: main.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/main.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** main.c 29 Jul 2004 06:22:42 -0000 1.10 --- main.c 8 Dec 2004 17:22:00 -0000 1.11 *************** *** 165,169 **** } else ! yield_timeslice (); } } --- 165,169 ---- } else ! rest (1); } } |
From: Paul P. <ppr...@us...> - 2004-12-06 03:52:35
|
Update of /cvsroot/squidfighter/deathfist/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30338 Modified Files: boot.f root.f Log Message: - synced with latest Forthy - improved Forth file loading - added more primitives - pruned some obsolete code Index: root.f =================================================================== RCS file: /cvsroot/squidfighter/deathfist/data/root.f,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** root.f 22 Aug 2004 01:21:02 -0000 1.4 --- root.f 6 Dec 2004 03:52:25 -0000 1.5 *************** *** 1,2 **** --- 1,4 ---- + anew root.f + -1 constant true 0 constant false *************** *** 6,9 **** --- 8,14 ---- false constant no + 32 constant bl + + : next! postpone next ; immediate : repeat! postpone repeat ; immediate *************** *** 70,71 **** --- 75,178 ---- : until postpone yield postpone until ; immediate : again postpone yield postpone again ; immediate + + : abort "ERROR: " type type (abort) ; + + : abort" + char " + parse + compile? + if + postpone literal + postpone abort + else + abort + then + ; immediate + + : ?params + depth 1- over < + if + "need " swap $cat " parameters, have " $cat depth 1- + $cat abort + then + drop + ; + + : ?only + depth 1- over <> + if + "expect only " swap $cat " parameters, have " $cat depth 1- + $cat abort + then + drop + ; + + : ['] ' postpone literal ; immediate + : (is) >body ! ; + + : is + compile? + if + ' postpone literal postpone (is) + else + ' (is) + then + ; immediate + + : to postpone is ; immediate + + : in? in.len in.off > if true else false then ; + : parse.line in? if 0x d parse else "" then ; + + \ block comment + : (* ( -- ) + begin + in? if token "*)" $= else -1 then + until + ; immediate + + + \ remove trailing spaces + : -trailing ( "string " -- "string" ) + dup $len dup + for + over i 1- $asc bl = + if + 1- + else + break + then + next + $left + ; + + + : -leading ( "string " -- "string2" ) + dup $len dup -rot 0 swap + for + 2dup $asc bl = + if + 1+ + else + break + then + next + rot swap - $right + ; + + + : +! dup @ rot + swap ! ; + : >< dup 255 and 8 << swap 8 >> 255 and or ; \ byteswap + + : space 32 emit ; + : spaces for 32 emit next ; + : ?dup dup if dup then ; + + : enum{ ( n -- n+1 ) + begin + token dup "}" $= 0= + while + " constant " swap $cat over swap $cat evaluate 1+ + repeat + 2drop + ; Index: boot.f =================================================================== RCS file: /cvsroot/squidfighter/deathfist/data/boot.f,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** boot.f 6 Aug 2004 05:31:52 -0000 1.2 --- boot.f 6 Dec 2004 03:52:25 -0000 1.3 *************** *** 1,2 **** ! "data/root.f" load ! zardoz --- 1,4 ---- ! anew boot.f ! ! load data/root.f ! load zardoz |
From: Paul P. <ppr...@us...> - 2004-12-06 03:52:28
|
Update of /cvsroot/squidfighter/deathfist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30293 Modified Files: forth.c forth.h main_forth.c util.c util.h Log Message: - synced with latest Forthy - improved Forth file loading - added more primitives - pruned some obsolete code Index: util.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/util.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** util.h 21 Jul 2004 04:42:00 -0000 1.4 --- util.h 6 Dec 2004 03:52:16 -0000 1.5 *************** *** 17,21 **** void util_keypoll(void); ! char *util_load_text(char *filename); #endif --- 17,21 ---- void util_keypoll(void); ! int util_filesize(char *filename); #endif Index: forth.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/forth.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** forth.h 6 Aug 2004 05:31:43 -0000 1.3 --- forth.h 6 Dec 2004 03:52:16 -0000 1.4 *************** *** 6,11 **** enum{FS_YIELD=FS_USER_RESULT}; ! #define FS_TRUE -1 ! #define FS_FALSE 0 typedef struct FORTH --- 6,11 ---- enum{FS_YIELD=FS_USER_RESULT}; ! #define FORTH_TRUE -1 ! #define FORTH_FALSE 0 typedef struct FORTH *************** *** 16,19 **** --- 16,20 ---- etc. */ + char *cwd; }FORTH; Index: main_forth.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/main_forth.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** main_forth.c 22 Aug 2004 01:20:45 -0000 1.11 --- main_forth.c 6 Dec 2004 03:52:16 -0000 1.12 *************** *** 5,8 **** --- 5,9 ---- */ + #include <stdio.h> #include "main.h" #include "forth.h" *************** *** 16,38 **** FORTH *forth=&_forth; - static char *tempfile=NULL; - - static int load_script(FSYSTEM *sys, char *filename) - { - int ret; - - tempfile=util_load_text(filename); - - if(!tempfile) - return FS_ERROR; - - ret=fs_load_input(sys, tempfile); - free(tempfile); - tempfile=NULL; - - return ret; - } - - static void show_stack(FSYSTEM *sys, int tag) { --- 17,20 ---- *************** *** 112,122 **** static void word_dot(FSYSTEM *sys) { char *str; ! str=fs_get_string(sys, -1); - if(!str) - str="???"; - print(con, TAG_SYSTEM, "%s ", str); fs_pop(sys); } --- 94,126 ---- static void word_dot(FSYSTEM *sys) { + FORTH *me=(FORTH*)sys; + + switch(fs_get_type(sys, -1)) + { + case FS_INT: + case FS_STRING: + case FS_FLOAT: + { + print(con, TAG_SYSTEM, "%s ", fs_get_string(sys, -1)); + } + break; + + default: + print(con, TAG_SYSTEM, "%s", "??? "); + } + + fs_pop(sys); + } + + + static void word_type(FSYSTEM *sys) + { char *str; ! FORTH *me=(FORTH*)sys; ! str=fs_get_string(sys, -1); fs_pop(sys); + + print(con, TAG_SYSTEM, "%s", str); } *************** *** 142,145 **** --- 146,156 ---- + static void word_line_comment(FSYSTEM *sys) + { + fs_scan_text(sys, NULL, "\n"); + fs_pop(sys); + } + + static void word_fetch(FSYSTEM *sys) { *************** *** 205,219 **** - static void word_load(FSYSTEM *sys) - { - char *str; - - str=fs_get_string(sys, -1); - fs_pop(sys); - print(con, TAG_WARNING, "Loading %s...\n", str); - fs_throw(sys, load_script(sys, str)); - } - - static void word_cr(FSYSTEM *sys) { --- 216,219 ---- *************** *** 359,363 **** ! static void word_type(FSYSTEM *sys) { fs_push_int(sys, fs_get_type(sys, -1)); --- 359,363 ---- ! static void word_totype(FSYSTEM *sys) { fs_push_int(sys, fs_get_type(sys, -1)); *************** *** 539,549 **** static void word_tick(FSYSTEM *sys) { char *str; ! fs_push_int(sys, 32); ! ! word_word(sys); str=fs_get_string(sys, -1); --- 539,553 ---- + static void word_token(FSYSTEM *sys) + { + fs_scan_word(sys); + } + + static void word_tick(FSYSTEM *sys) { char *str; ! word_token(sys); str=fs_get_string(sys, -1); *************** *** 582,594 **** if(ret<FS_OK) { ! print(con, TAG_ERROR, "Line %d, ERROR at '%s': ", ! lin, fs_get_last_token(sys)); ! ! print(con, TAG_ERROR, "%s", fs_get_result_string(sys, ret)); ! ! if(depth) { ! print(con, TAG_WARNING, ". Stack was "); ! show_stack(sys, TAG_ERROR); } --- 586,599 ---- if(ret<FS_OK) { ! if(ret!=FS_USER_ERR) { ! print(con, TAG_ERROR, "ERROR: %s at ", fs_get_result_string(sys, ret)); ! print(con, TAG_ERROR, "'%s', line %d", fs_get_last_token(sys), lin); ! ! if(depth) ! { ! print(con, TAG_WARNING, ". Stack was "); ! show_stack(sys, TAG_ERROR); ! } } *************** *** 602,609 **** else if(ret!=FS_YIELD) { ! print(con, TAG_WARNING, "Line %d, RESULT at '%s': ", ! lin, fs_get_last_token(sys)); ! ! print(con, TAG_WARNING, "%s", fs_get_result_string(sys, ret)); if(depth) --- 607,612 ---- else if(ret!=FS_YIELD) { ! print(con, TAG_ERROR, "RESULT: %s at ", fs_get_result_string(sys, ret)); ! print(con, TAG_ERROR, "'%s', line %d", fs_get_last_token(sys), lin); if(depth) *************** *** 665,673 **** if(flags|FS_IMMEDIATE) { ! fs_push_int(sys, FS_TRUE); } else { ! fs_push_int(sys, FS_FALSE); } } --- 668,676 ---- if(flags|FS_IMMEDIATE) { ! fs_push_int(sys, FORTH_TRUE); } else { ! fs_push_int(sys, FORTH_FALSE); } } *************** *** 680,684 **** ! static void word_cat(FSYSTEM *sys) { char *temp, *temp2; --- 683,687 ---- ! static void word_strcat(FSYSTEM *sys) { char *temp, *temp2; *************** *** 688,699 **** // if we OVERFLOW if(fs_depth(sys)<2) ! fs_throw(sys, FS_UNDERFLOW); - // Validate types for above same reason - if(!(size=fs_strlen(sys, -1, NULL))) - fs_throw(sys, FS_BAD_TYPE); - if(!(size2=fs_strlen(sys, -2, &temp2))) - fs_throw(sys, FS_BAD_TYPE); - size+=size2+1; temp=malloc(size); --- 691,701 ---- // if we OVERFLOW if(fs_depth(sys)<2) ! { ! fs_remove(sys, 2); ! } ! ! size=fs_strlen(sys, -1, NULL); ! size2=fs_strlen(sys, -2, &temp2); size+=size2+1; temp=malloc(size); *************** *** 710,714 **** ! static void word_len(FSYSTEM *sys) { int len; --- 712,716 ---- ! static void word_strlen(FSYSTEM *sys) { int len; *************** *** 721,725 **** // ( string count -- string ) ! static void word_left(FSYSTEM *sys) { int len, want_len; --- 723,727 ---- // ( string count -- string ) ! static void word_strleft(FSYSTEM *sys) { int len, want_len; *************** *** 728,732 **** len=fs_strlen(sys, -2, &str); want_len=fs_get_int(sys, -1); ! if(want_len>len||want_len<1) { fs_throw(sys, FS_OUT_OF_BOUNDS); --- 730,734 ---- len=fs_strlen(sys, -2, &str); want_len=fs_get_int(sys, -1); ! if(want_len>len||want_len<0) { fs_throw(sys, FS_OUT_OF_BOUNDS); *************** *** 739,743 **** // ( string count -- string ) ! static void word_right(FSYSTEM *sys) { int len, want_len; --- 741,745 ---- // ( string count -- string ) ! static void word_strright(FSYSTEM *sys) { int len, want_len; *************** *** 746,750 **** len=fs_strlen(sys, -2, &str); want_len=fs_get_int(sys, -1); ! if(want_len>len||want_len<1) { fs_throw(sys, FS_OUT_OF_BOUNDS); --- 748,752 ---- len=fs_strlen(sys, -2, &str); want_len=fs_get_int(sys, -1); ! if(want_len>len||want_len<0) { fs_throw(sys, FS_OUT_OF_BOUNDS); *************** *** 757,761 **** // ( string start count -- string ) ! static void word_mid(FSYSTEM *sys) { int len, start, want_len; --- 759,763 ---- // ( string start count -- string ) ! static void word_strmid(FSYSTEM *sys) { int len, start, want_len; *************** *** 766,770 **** want_len=fs_get_int(sys, -1); ! if(start+want_len>len||start+want_len<=0||start<0) { fs_throw(sys, FS_OUT_OF_BOUNDS); --- 768,772 ---- want_len=fs_get_int(sys, -1); ! if(start+want_len>len||start+want_len<0||start<0) { fs_throw(sys, FS_OUT_OF_BOUNDS); *************** *** 776,808 **** ! // ( value -- "char" ) ! static void word_asc(FSYSTEM *sys) ! { ! char character[2]; ! ! character[0]=fs_get_int(sys, -1); ! character[1]=0; ! fs_pop(sys); ! fs_push_string(sys, character); ! } ! ! ! // ( "string" index -- value ) ! static void word_chr(FSYSTEM *sys) { - int i; char *str; ! i=fs_get_int(sys, -1); fs_pop(sys); str=fs_get_string(sys, -1); fs_pop(sys); ! if(i<0||i>(int)strlen(str)) { fs_throw(sys, FS_OUT_OF_BOUNDS); } ! fs_push_int(sys, (int)str[i]); } --- 778,811 ---- ! // ( "string" offset -- ascii-value ) ! static void word_strasc(FSYSTEM *sys) { char *str; + int offset; ! offset=fs_get_int(sys, -1); fs_pop(sys); + str=fs_get_string(sys, -1); fs_pop(sys); ! if(offset<0||offset>(int)(strlen(str)-1)) { fs_throw(sys, FS_OUT_OF_BOUNDS); } ! fs_push_int(sys, (int)str[offset]); ! } ! ! ! // ( value -- "c" ) ! static void word_strchr(FSYSTEM *sys) ! { ! char ch; ! ! ch=(char)fs_get_int(sys, -1); ! fs_pop(sys); ! ! fs_push_string_span(sys, &ch, 1); } *************** *** 1005,1011 **** ! /* Non word functions */ static int forth_load(FORTH *me, char *filename) { --- 1008,1436 ---- ! static char *make_file_path(FSYSTEM *sys) ! { ! if(((FORTH*)sys)->cwd) ! { ! fs_push_string(sys, ((FORTH*)sys)->cwd); ! word_swap(sys); ! word_strcat(sys); ! } ! ! return fs_get_string(sys, -1); ! } ! ! ! static void check_filename(FSYSTEM *sys, char *filename) ! { ! if(!(filename&&strlen(filename))) ! { ! fs_throw(sys, FS_BAD_PARAMETER); ! } ! } ! ! ! static void word_file_size(FSYSTEM *sys) ! { ! char *filename; ! int filesize; ! ! filename=make_file_path(sys); ! ! fs_pop(sys); ! ! check_filename(sys, filename); ! ! filesize=util_filesize(filename); ! ! fs_push_int(sys, filesize); ! } ! ! ! static void handle_file_error(FSYSTEM *sys, char *filename) ! { ! FORTH *me=(FORTH*)sys; ! ! print(con, TAG_WARNING, "ERROR: file '%s', %s", filename, strerror(errno)); ! ! fs_throw(sys, FS_USER_ERR); ! } ! ! ! static void word_file_read(FSYSTEM *sys) ! { ! FILE *fp; ! char *filename; ! int filesize; ! char *filedata; ! FORTH *me=(FORTH*)sys; ! ! filename=make_file_path(sys); ! ! fs_pop(sys); ! ! check_filename(sys, filename); ! ! filesize=file_size(filename); ! ! fp=fopen(filename, "rb"); ! if(filesize<0||!fp) ! { ! handle_file_error(sys, filename); ! } ! ! filedata=(char*)malloc(filesize+1); ! ! fread(filedata, filesize, 1, fp); ! fclose(fp); ! ! filedata[filesize]=0; ! ! fs_push_string(sys, filedata); ! free(filedata); ! } ! ! ! static void word_strload(FSYSTEM *sys) ! { ! char *filename; ! ! filename=fs_get_string(sys, -1); ! ! print(con, TAG_WARNING, "Loading %s...\n", filename); ! word_file_read(sys); ! word_evaluate(sys); ! } ! ! ! static void word_load(FSYSTEM *sys) ! { ! fs_scan_word(sys); ! word_strload(sys); ! } ! ! ! static void word_abort_(FSYSTEM *sys) ! { ! fs_throw(sys, FS_USER_ERR); ! } ! ! ! static void word_anew(FSYSTEM *sys) ! { ! char *str; ! ! fs_scan_word(sys); ! ! str=fs_get_string(sys, -1); ! fs_pop(sys); ! ! // If it's there, forget it and everything after it ! if(fs_is_push_word(sys, str, TRUE)) ! { ! fs_forget(sys, -1); ! fs_pop(sys); ! } ! ! // Stick a variable in the dictionary as a marker ! fs_register_var(sys, str, FS_DEFAULT); ! } ! ! ! static void word_needs(FSYSTEM *sys) ! { ! char *str; ! ! fs_scan_word(sys); ! ! word_dup(sys); ! str=fs_get_string(sys, -1); ! ! // If it's already there, don't load ! if(fs_is_push_word(sys, str, FALSE)) ! { ! fs_remove(sys, 2); ! return; ! } ! ! word_strload(sys); ! ! str=fs_get_string(sys, -1); ! fs_pop(sys); ! ! // Stick a variable in the dictionary as a marker ! fs_register_var(sys, str, FS_DEFAULT); ! } ! ! ! static void word_inlen(FSYSTEM *sys) ! { ! fs_push_int(sys, fs_input_length(sys)); ! } ! ! ! static void word_inoff(FSYSTEM *sys) ! { ! fs_push_int(sys, fs_input_offset(sys)); ! } ! ! ! static void word_char(FSYSTEM *sys) ! { ! char *ch; ! ! fs_scan_word(sys); ! ch=fs_get_string(sys, -1); ! fs_pop(sys); ! fs_push_int(sys, (int)ch[0]); ! ! if(fs_is_compiling(sys)) ! word_literal(sys); ! } ! ! ! static void word_0x(FSYSTEM *sys) ! { ! char *str; ! int value; ! ! fs_scan_word(sys); ! str=fs_get_string(sys, -1); ! sscanf(str, "%x", &value); ! fs_pop(sys); ! fs_push_int(sys, value); ! ! if(fs_is_compiling(sys)) ! word_literal(sys); ! } ! ! ! static void word_cwd_store(FSYSTEM *sys) ! { ! char *str; ! int len; ! FORTH *me=(FORTH*)sys; ! ! str=fs_get_string(sys, -1); ! fs_pop(sys); ! ! if(me->cwd) ! { ! free(me->cwd); ! } ! ! len=strlen(str); ! ! me->cwd=(char*)malloc(len+1); ! strcpy(me->cwd, str); ! me->cwd[len]=0; ! } ! ! ! static void word_cwd_fetch(FSYSTEM *sys) ! { ! if(((FORTH*)sys)->cwd) ! { ! fs_push_string(sys, ((FORTH*)sys)->cwd); ! } ! else ! { ! fs_push_string(sys, ""); ! } ! } ! ! ! static void word_parse(FSYSTEM *sys) ! { ! char delimit[2]; ! int value; ! ! value=fs_get_int(sys, -1); ! ! fs_pop(sys); ! ! delimit[0]=(char)value; ! delimit[1]=0; ! ! fs_scan_text(sys, NULL, delimit); ! } ! ! ! static void word_exits(FSYSTEM *sys) ! { ! int i; ! ! i=fs_get_int(sys, -1); ! fs_pop(sys); ! ! while(i--) ! { ! fs_exit(sys); ! } ! } ! ! ! static void word_rdepth(FSYSTEM *sys) ! { ! fs_push_int(sys, stack_depth(sys->rstack)); ! } ! ! ! static void word_1add(FSYSTEM *sys) ! { ! int result; ! ! result=fs_get_int(sys, -1)+1; ! fs_pop(sys); ! ! fs_push_int(sys, result); ! } ! ! ! static void word_1sub(FSYSTEM *sys) ! { ! int result; ! ! result=fs_get_int(sys, -1)-1; ! fs_pop(sys); ! ! fs_push_int(sys, result); ! } ! ! ! static void word_streq(FSYSTEM *sys) ! { ! int equal; ! char *str, *temp; ! ! if(fs_depth(sys)<2) ! { ! fs_remove(sys, 2); ! } ! ! temp=strdup(fs_get_string(sys, -1)); ! fs_pop(sys); ! str=fs_get_string(sys, -1); ! fs_pop(sys); ! ! equal=(strcmp(str, temp)?FORTH_FALSE:FORTH_TRUE); ! free(temp); ! ! fs_push_int(sys, equal); ! } ! ! ! static void word_2dup(FSYSTEM *sys) ! { ! fs_pick(sys, -2); ! fs_pick(sys, -2); ! } ! ! ! static void word_2drop(FSYSTEM *sys) ! { ! fs_remove(sys, 2); ! } ! ! ! static void word_pick(FSYSTEM *sys) ! { ! int get_at; ! ! get_at=fs_get_int(sys, -1); ! ! fs_pop(sys); ! ! fs_pick(sys, TO_OFFSET(get_at)); ! } ! ! ! static void word_nip(FSYSTEM *sys) ! { ! fs_swap(sys, -1, -2); ! fs_pop(sys); ! } ! ! ! static void word_and(FSYSTEM *sys) ! { ! int result; ! ! result=fs_get_int(sys, -1)&fs_get_int(sys, -2); ! fs_remove(sys, 2); ! fs_push_int(sys, result); ! } ! ! ! static void word_or(FSYSTEM *sys) ! { ! int result; ! ! result=fs_get_int(sys, -1)|fs_get_int(sys, -2); ! fs_remove(sys, 2); ! fs_push_int(sys, result); ! } + static void word_xor(FSYSTEM *sys) + { + int result; + + result=fs_get_int(sys, -1)^fs_get_int(sys, -2); + fs_remove(sys, 2); + fs_push_int(sys, result); + } + + + static void word_not(FSYSTEM *sys) + { + int result; + + result=~fs_get_int(sys, -1); + fs_pop(sys); + fs_push_int(sys, result); + } + + + static void word_lshift(FSYSTEM *sys) + { + unsigned int bits; + + bits=fs_get_int(sys, -1); + bits=fs_get_int(sys, -2)<<bits; + + fs_remove(sys, 2); + + fs_push_int(sys, bits); + } + + + static void word_rshift(FSYSTEM *sys) + { + unsigned int bits; + + bits=fs_get_int(sys, -1); + bits=fs_get_int(sys, -2)>>bits; + + fs_remove(sys, 2); + + fs_push_int(sys, bits); + } + + + static void word_zeq(FSYSTEM *sys) + { + int result; + + result=(fs_get_float(sys, -1)==0? + FORTH_TRUE:FORTH_FALSE); + + fs_pop(sys); + + fs_push_int(sys, result); + } + + + /* Non word functions */ + static int forth_load(FORTH *me, char *filename) { *************** *** 1013,1017 **** FSYSTEM *sys=(FSYSTEM*)me; ! load_script(sys, filename); ret=fs_run(sys); handle_result(sys, ret); --- 1438,1443 ---- FSYSTEM *sys=(FSYSTEM*)me; ! fs_push_string(sys, filename); ! fs_load_input(sys, "$load"); ret=fs_run(sys); handle_result(sys, ret); *************** *** 1074,1077 **** --- 1500,1504 ---- fs_register_func(sys, "constant", word_constant, FS_DEFAULT); fs_register_func(sys, "(", word_paren, FS_IMMEDIATE); + fs_register_func(sys, "\\", word_line_comment, FS_IMMEDIATE); fs_register_func(sys, "words", word_words, FS_DEFAULT); fs_register_func(sys, "words.like", word_words_like, FS_DEFAULT); *************** *** 1079,1082 **** --- 1506,1510 ---- fs_register_func(sys, ".s", word_show_stack, FS_DEFAULT); fs_register_func(sys, ".", word_dot, FS_DEFAULT); + fs_register_func(sys, "type", word_type, FS_DEFAULT); fs_register_func(sys, "emit", word_emit, FS_DEFAULT); fs_register_func(sys, "load", word_load, FS_DEFAULT); *************** *** 1120,1124 **** fs_register_func(sys, "*", word_mul, FS_DEFAULT); fs_register_func(sys, "/", word_div, FS_DEFAULT); ! fs_register_func(sys, "%", word_mod, FS_DEFAULT); fs_register_func(sys, ">", word_gt, FS_DEFAULT); fs_register_func(sys, ">=", word_gte, FS_DEFAULT); --- 1548,1552 ---- fs_register_func(sys, "*", word_mul, FS_DEFAULT); fs_register_func(sys, "/", word_div, FS_DEFAULT); ! fs_register_func(sys, "mod", word_mod, FS_DEFAULT); fs_register_func(sys, ">", word_gt, FS_DEFAULT); fs_register_func(sys, ">=", word_gte, FS_DEFAULT); *************** *** 1141,1145 **** fs_register_func(sys, "ahead", fs_ahead, FS_IMMEDIATE); fs_register_func(sys, "break", fs_break, FS_IMMEDIATE); ! fs_register_func(sys, "exit", fs_exit, FS_IMMEDIATE); fs_register_func(sys, "bye", word_bye, FS_DEFAULT); fs_register_func(sys, "'", word_tick, FS_DEFAULT); --- 1569,1574 ---- fs_register_func(sys, "ahead", fs_ahead, FS_IMMEDIATE); fs_register_func(sys, "break", fs_break, FS_IMMEDIATE); ! fs_register_func(sys, "exit", fs_exit, FS_DEFAULT); ! fs_register_func(sys, "exits", word_exits, FS_DEFAULT); fs_register_func(sys, "bye", word_bye, FS_DEFAULT); fs_register_func(sys, "'", word_tick, FS_DEFAULT); *************** *** 1153,1164 **** fs_register_func(sys, "'forget", word_xtforget, FS_DEFAULT); fs_register_func(sys, "forget", word_forget, FS_DEFAULT); ! fs_register_func(sys, "$cat", word_cat, FS_DEFAULT); ! fs_register_func(sys, "$len", word_len, FS_DEFAULT); ! fs_register_func(sys, "$right", word_right, FS_DEFAULT); ! fs_register_func(sys, "$left", word_left, FS_DEFAULT); ! fs_register_func(sys, "$mid", word_mid, FS_DEFAULT); ! fs_register_func(sys, "$asc", word_asc, FS_DEFAULT); ! fs_register_func(sys, "$chr", word_chr, FS_DEFAULT); fs_register_func(sys, "$create", word_strcreate, FS_DEFAULT); // Load boot script --- 1582,1621 ---- fs_register_func(sys, "'forget", word_xtforget, FS_DEFAULT); fs_register_func(sys, "forget", word_forget, FS_DEFAULT); ! fs_register_func(sys, "$cat", word_strcat, FS_DEFAULT); ! fs_register_func(sys, "$len", word_strlen, FS_DEFAULT); ! fs_register_func(sys, "$right", word_strright, FS_DEFAULT); ! fs_register_func(sys, "$left", word_strleft, FS_DEFAULT); ! fs_register_func(sys, "$mid", word_strmid, FS_DEFAULT); ! fs_register_func(sys, "$asc", word_strasc, FS_DEFAULT); ! fs_register_func(sys, "$chr", word_strchr, FS_DEFAULT); fs_register_func(sys, "$create", word_strcreate, FS_DEFAULT); + fs_register_func(sys, "$load", word_strload, FS_DEFAULT); + fs_register_func(sys, "$=", word_streq, FS_DEFAULT); + fs_register_func(sys, "(abort)", word_abort_, FS_DEFAULT); + fs_register_func(sys, "anew", word_anew, FS_DEFAULT); + fs_register_func(sys, "needs", word_needs, FS_DEFAULT); + fs_register_func(sys, "token", word_token, FS_DEFAULT); + fs_register_func(sys, "in.len", word_inlen, FS_DEFAULT); + fs_register_func(sys, "in.off", word_inoff, FS_DEFAULT); + fs_register_func(sys, "char", word_char, FS_IMMEDIATE); + fs_register_func(sys, "0x", word_0x, FS_IMMEDIATE); + fs_register_func(sys, "cwd@", word_cwd_fetch, FS_DEFAULT); + fs_register_func(sys, "cwd!", word_cwd_store, FS_DEFAULT); + fs_register_func(sys, "parse", word_parse, FS_DEFAULT); + fs_register_func(sys, "exits", word_exits, FS_DEFAULT); + fs_register_func(sys, "rdepth", word_rdepth, FS_DEFAULT); + fs_register_func(sys, "1+", word_1add, FS_DEFAULT); + fs_register_func(sys, "1-", word_1sub, FS_DEFAULT); + fs_register_func(sys, "2dup", word_2dup, FS_DEFAULT); + fs_register_func(sys, "2drop", word_2drop, FS_DEFAULT); + fs_register_func(sys, "pick", word_pick, FS_DEFAULT); + fs_register_func(sys, "nip", word_nip, FS_DEFAULT); + fs_register_func(sys, "and", word_and, FS_DEFAULT); + fs_register_func(sys, "or", word_or, FS_DEFAULT); + fs_register_func(sys, "xor", word_xor, FS_DEFAULT); + fs_register_func(sys, "not", word_not, FS_DEFAULT); + fs_register_func(sys, "<<", word_lshift, FS_DEFAULT); + fs_register_func(sys, ">>", word_rshift, FS_DEFAULT); + fs_register_func(sys, "0=", word_zeq, FS_DEFAULT); // Load boot script *************** *** 1186,1192 **** void main_forth_exit(FORTH *me) { - if(tempfile) - free(tempfile); - forth_exit(me); } --- 1643,1646 ---- Index: util.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/util.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** util.c 21 Jul 2004 04:42:00 -0000 1.3 --- util.c 6 Dec 2004 03:52:16 -0000 1.4 *************** *** 143,176 **** ! char *util_load_text(char *filename) { FILE *fp; ! char *text; ! int size; fp=fopen(filename, "rb"); if(!fp) - return NULL; - - /* - if(!fp) { ! console_write(console, TAG_ERROR, "Text file '%s' load failed\n", filename); ! return NULL; } - */ fseek(fp, 0, SEEK_END); ! size=ftell(fp); fseek(fp, 0, SEEK_SET); - text=malloc(size+1); - - fread(text, size, 1, fp); fclose(fp); ! text[size]=0; ! ! return text; } --- 143,164 ---- ! int util_filesize(char *filename) { FILE *fp; ! int filesize; fp=fopen(filename, "rb"); if(!fp) { ! return -1; } fseek(fp, 0, SEEK_END); ! filesize=ftell(fp); fseek(fp, 0, SEEK_SET); fclose(fp); ! return filesize; } Index: forth.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/forth.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** forth.c 6 Aug 2004 05:31:43 -0000 1.2 --- forth.c 6 Dec 2004 03:52:16 -0000 1.3 *************** *** 12,15 **** --- 12,16 ---- int forth_init(FORTH *sys, int dstack, int rstack) { + sys->cwd=NULL; return fs_sys_init((FSYSTEM*)sys, dstack, rstack); } *************** *** 31,35 **** void forth_exit(FORTH *sys) { ! fs_sys_exit((FSYSTEM*)sys); } --- 32,41 ---- void forth_exit(FORTH *sys) { ! if(sys->cwd) ! { ! free(sys->cwd); ! } ! ! fs_sys_exit((FSYSTEM*)sys); } |
From: Paul P. <ppr...@us...> - 2004-08-31 00:05:59
|
Update of /cvsroot/squidfighter/deathfist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26244 Added Files: console_words.c Log Message: - oops --- NEW FILE: console_words.c --- #include "main_forth.h" #include "console_handler.h" static void word_show(FSYSTEM *sys) { console_show(TRUE); } static void word_hide(FSYSTEM *sys) { console_show(FALSE); } static void word_stat(FSYSTEM *sys) { print(con, TAG_SYSTEM, "Console using %d lines of %d total\n", console_get_lines(con), console_get_count(con)); } void console_words_init(FORTH *me) { FSYSTEM *sys=(FSYSTEM*)me; forth_do(me, "console definitions"); fs_register_func(sys, "show", word_show, FS_DEFAULT); fs_register_func(sys, "hide", word_hide, FS_DEFAULT); fs_register_func(sys, "stat", word_stat, FS_DEFAULT); } |
From: Paul P. <ppr...@us...> - 2004-08-22 01:21:22
|
Update of /cvsroot/squidfighter/deathfist/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18528 Modified Files: root.f Log Message: - I honestly don't remember, been animating for three weeks Index: root.f =================================================================== RCS file: /cvsroot/squidfighter/deathfist/data/root.f,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** root.f 6 Aug 2004 05:31:52 -0000 1.3 --- root.f 22 Aug 2004 01:21:02 -0000 1.4 *************** *** 3,8 **** true constant on false constant off ! true constant show ! false constant hide : next! postpone next ; immediate --- 3,8 ---- true constant on false constant off ! true constant yes ! false constant no : next! postpone next ; immediate *************** *** 12,15 **** --- 12,16 ---- : root voc.clear ; + : forth root ; immediate : also *************** *** 22,29 **** : vocabulary ! variable last last >body ! does> voc.depth if voc.pop drop then ! @ voc.push ; vocabulary tileset immediate vocabulary world immediate --- 23,31 ---- : vocabulary ! variable last last >body ! does> voc.depth if voc.pop drop ! then @ voc.push ; + ( Make them immediate so we can used them in definitions ) vocabulary tileset immediate vocabulary world immediate *************** *** 31,38 **** vocabulary parallax immediate vocabulary layer immediate : order ! "CONTEXT: " . voc.depth dup for dup i - voc.pick >name . next cr ! "CURRENT: " . current@ dup >type if >name . else drop then cr drop ; --- 33,43 ---- vocabulary parallax immediate vocabulary layer immediate + vocabulary console immediate : order ! "CONTEXT: " . voc.depth dup for dup i - voc.pick >name . ! next cr ! "CURRENT: " . current@ dup >type if >name . else drop then ! cr drop ; |
From: Paul P. <ppr...@us...> - 2004-08-22 01:21:01
|
Update of /cvsroot/squidfighter/deathfist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18406 Modified Files: Deathfist.dsp console.h console_handler.c console_handler.h edit_state.c layer_words.c layer_words.h main_forth.c map.c map.h parallax_words.c parallax_words.h tileset.c tileset.h world.c world.h Log Message: - I honestly don't remember, been animating for three weeks Index: world.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/world.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** world.h 2 Aug 2004 18:51:59 -0000 1.9 --- world.h 22 Aug 2004 01:20:45 -0000 1.10 *************** *** 35,39 **** void world_destroy_parallax(WORLD *me, char const *name); ! void world_forth_init(FORTH *me); --- 35,39 ---- void world_destroy_parallax(WORLD *me, char const *name); ! void world_words_init(FORTH *me); Index: parallax_words.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/parallax_words.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** parallax_words.h 2 Aug 2004 18:56:45 -0000 1.1 --- parallax_words.h 22 Aug 2004 01:20:45 -0000 1.2 *************** *** 5,9 **** #include "parallax.h" ! void parallax_words_forth_init(FORTH *me); #endif --- 5,9 ---- #include "parallax.h" ! void parallax_words_init(FORTH *me); #endif Index: Deathfist.dsp =================================================================== RCS file: /cvsroot/squidfighter/deathfist/Deathfist.dsp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Deathfist.dsp 29 Jul 2004 06:22:42 -0000 1.10 --- Deathfist.dsp 22 Aug 2004 01:20:45 -0000 1.11 *************** *** 70,74 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c ! # ADD CPP /nologo /W3 /WX /Gm /GX /ZI /Od /I "../forthy" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 --- 70,74 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c ! # ADD CPP /nologo /W3 /WX /Gm /GX /ZI /Od /I "../forthy" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FR /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 *************** *** 113,116 **** --- 113,120 ---- # Begin Source File + SOURCE=.\console_words.c + # End Source File + # Begin Source File + SOURCE=.\data.c # End Source File *************** *** 125,128 **** --- 129,148 ---- # Begin Source File + SOURCE=.\layer.c + # End Source File + # Begin Source File + + SOURCE=.\layer.h + # End Source File + # Begin Source File + + SOURCE=.\layer_words.c + # End Source File + # Begin Source File + + SOURCE=.\layer_words.h + # End Source File + # Begin Source File + SOURCE=.\list.c # End Source File *************** *** 153,156 **** --- 173,184 ---- # Begin Source File + SOURCE=.\parallax_words.c + # End Source File + # Begin Source File + + SOURCE=.\parallax_words.h + # End Source File + # Begin Source File + SOURCE=.\sprite_load.c # End Source File Index: tileset.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/tileset.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tileset.h 29 Jul 2004 06:22:42 -0000 1.9 --- tileset.h 22 Aug 2004 01:20:45 -0000 1.10 *************** *** 46,50 **** TILE_SET *tileset_create(BITMAP *bmp); ! void tileset_forth_init(FORTH *me); #endif --- 46,50 ---- TILE_SET *tileset_create(BITMAP *bmp); ! void tileset_words_init(FORTH *me); #endif Index: tileset.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/tileset.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** tileset.c 31 Jul 2004 23:02:05 -0000 1.13 --- tileset.c 22 Aug 2004 01:20:45 -0000 1.14 *************** *** 305,309 **** ! void tileset_forth_init(FORTH *me) { FSYSTEM *sys=(FSYSTEM*)me; --- 305,309 ---- ! void tileset_words_init(FORTH *me) { FSYSTEM *sys=(FSYSTEM*)me; Index: layer_words.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/layer_words.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** layer_words.h 2 Aug 2004 18:56:45 -0000 1.1 --- layer_words.h 22 Aug 2004 01:20:45 -0000 1.2 *************** *** 4,8 **** #include "main_forth.h" ! void layer_words_forth_init(FORTH *me); #endif --- 4,8 ---- #include "main_forth.h" ! void layer_words_init(FORTH *me); #endif Index: edit_state.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/edit_state.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** edit_state.c 2 Aug 2004 18:51:59 -0000 1.22 --- edit_state.c 22 Aug 2004 01:20:45 -0000 1.23 *************** *** 216,220 **** { int th = text_height (font); ! textprintf_centre(back_buffer, font, SCREEN_W/2, 16 + th, SYS_RED, "%i parallax layers", map_current->parallax_count); } --- 216,220 ---- { int th = text_height (font); ! textprintf_centre(back_buffer, font, SCREEN_W/2, 16 + th*2, SYS_RED, "%i parallax layers", map_current->parallax_count); } Index: layer_words.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/layer_words.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** layer_words.c 6 Aug 2004 05:31:43 -0000 1.2 --- layer_words.c 22 Aug 2004 01:20:45 -0000 1.3 *************** *** 18,21 **** --- 18,22 ---- } + static void word_list(FSYSTEM *sys) { *************** *** 36,39 **** --- 37,44 ---- } + + /* + edit ( layer -- ) + */ static void word_edit(FSYSTEM *sys) { *************** *** 54,58 **** } ! void layer_words_forth_init(FORTH *me) { FSYSTEM *sys=(FSYSTEM*)me; --- 59,64 ---- } ! ! void layer_words_init(FORTH *me) { FSYSTEM *sys=(FSYSTEM*)me; Index: parallax_words.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/parallax_words.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** parallax_words.c 6 Aug 2004 05:31:43 -0000 1.2 --- parallax_words.c 22 Aug 2004 01:20:45 -0000 1.3 *************** *** 55,59 **** } ! void parallax_words_forth_init(FORTH *me) { FSYSTEM *sys=(FSYSTEM*)me; --- 55,59 ---- } ! void parallax_words_init(FORTH *me) { FSYSTEM *sys=(FSYSTEM*)me; Index: console.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/console.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** console.h 6 Aug 2004 05:31:43 -0000 1.4 --- console.h 22 Aug 2004 01:20:45 -0000 1.5 *************** *** 2,5 **** --- 2,7 ---- #define __CONSOLE_H__ + #include <stddef.h> + #ifndef TRUE #define TRUE -1 Index: map.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/map.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** map.h 2 Aug 2004 18:51:59 -0000 1.11 --- map.h 22 Aug 2004 01:20:45 -0000 1.12 *************** *** 82,86 **** int map_load(MAP *me, PACKFILE *file); ! void map_forth_init(FORTH *sys); #endif --- 82,86 ---- int map_load(MAP *me, PACKFILE *file); ! void map_words_init(FORTH *sys); #endif Index: main_forth.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/main_forth.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** main_forth.c 6 Aug 2004 05:31:43 -0000 1.10 --- main_forth.c 22 Aug 2004 01:20:45 -0000 1.11 *************** *** 122,132 **** - static void word_con_stat(FSYSTEM *sys) - { - print(con, TAG_SYSTEM, "Console using %d lines of %d total\n", - console_get_lines(con), console_get_count(con)); - } - - static void word_colon(FSYSTEM *sys) { --- 122,125 ---- *************** *** 632,636 **** ! void word_forget(FSYSTEM *sys) { char *str; --- 625,629 ---- ! static void word_forget(FSYSTEM *sys) { char *str; *************** *** 647,651 **** ! void word_postpone(FSYSTEM *sys) { word_tick(sys); --- 640,644 ---- ! static void word_postpone(FSYSTEM *sys) { word_tick(sys); *************** *** 656,660 **** ! void word_iscompile(FSYSTEM *sys) { fs_push_int(sys, fs_is_compiling(sys)); --- 649,653 ---- ! static void word_iscompile(FSYSTEM *sys) { fs_push_int(sys, fs_is_compiling(sys)); *************** *** 662,666 **** ! void word_isimmediate(FSYSTEM *sys) { int flags; --- 655,659 ---- ! static void word_isimmediate(FSYSTEM *sys) { int flags; *************** *** 681,685 **** ! void word_yield(FSYSTEM *sys) { fs_throw(sys, FS_YIELD); --- 674,678 ---- ! static void word_yield(FSYSTEM *sys) { fs_throw(sys, FS_YIELD); *************** *** 783,786 **** --- 776,811 ---- + // ( value -- "char" ) + static void word_asc(FSYSTEM *sys) + { + char character[2]; + + character[0]=fs_get_int(sys, -1); + character[1]=0; + fs_pop(sys); + fs_push_string(sys, character); + } + + + // ( "string" index -- value ) + static void word_chr(FSYSTEM *sys) + { + int i; + char *str; + + i=fs_get_int(sys, -1); + fs_pop(sys); + str=fs_get_string(sys, -1); + fs_pop(sys); + + if(i<0||i>(int)strlen(str)) + { + fs_throw(sys, FS_OUT_OF_BOUNDS); + } + + fs_push_int(sys, (int)str[i]); + } + + void word_strcreate(FSYSTEM *sys) { *************** *** 856,859 **** --- 881,895 ---- + static void word_lte(FSYSTEM *sys) + { + int result; + + result=(fs_get_float(sys, -2)<=fs_get_float(sys, -1)?-1:0); + fs_remove(sys, 2); + + fs_push_int(sys, result); + } + + static void word_gt(FSYSTEM *sys) { *************** *** 867,870 **** --- 903,917 ---- + static void word_gte(FSYSTEM *sys) + { + int result; + + result=(fs_get_float(sys, -2)>=fs_get_float(sys, -1)?-1:0); + fs_remove(sys, 2); + + fs_push_int(sys, result); + } + + static void word_neq(FSYSTEM *sys) { *************** *** 878,882 **** ! void word_mod(FSYSTEM *sys) { int value; --- 925,929 ---- ! static void word_mod(FSYSTEM *sys) { int value; *************** *** 895,899 **** ! void word_rand(FSYSTEM *sys) { fs_push_int(sys, rand()); --- 942,946 ---- ! static void word_rand(FSYSTEM *sys) { fs_push_int(sys, rand()); *************** *** 901,905 **** ! void word_randomize(FSYSTEM *sys) { srand(fs_get_int(sys, -1)); --- 948,952 ---- ! static void word_randomize(FSYSTEM *sys) { srand(fs_get_int(sys, -1)); *************** *** 908,912 **** ! void word_time(FSYSTEM *sys) { fs_push_int(sys, time(NULL)); --- 955,959 ---- ! static void word_time(FSYSTEM *sys) { fs_push_int(sys, time(NULL)); *************** *** 914,928 **** ! void word_tostring(FSYSTEM *sys) ! { ! char *str; ! ! str=fs_get_string(sys, -1); ! fs_pop(sys); ! fs_push_string(sys, str); ! } ! ! ! void word_tointeger(FSYSTEM *sys) { int val; --- 961,965 ---- ! static void word_tointeger(FSYSTEM *sys) { int val; *************** *** 934,938 **** ! void word_tofloat(FSYSTEM *sys) { double val; --- 971,975 ---- ! static void word_tofloat(FSYSTEM *sys) { double val; *************** *** 944,950 **** ! void word_console(FSYSTEM *sys) { ! console_show(fs_get_int(sys, -1)); fs_pop(sys); } --- 981,1004 ---- ! static void word_evaluate(FSYSTEM *sys) { ! char *str; ! ! str=fs_get_string(sys, -1); ! fs_load_input(sys, str); ! fs_pop(sys); ! } ! ! ! static void word_emit(FSYSTEM *sys) ! { ! print(con, TAG_SYSTEM, "%c", (char)fs_get_int(sys, -1)); ! fs_pop(sys); ! } ! ! ! static void word_literal(FSYSTEM *sys) ! { ! fs_literal(sys, -1); fs_pop(sys); } *************** *** 1025,1028 **** --- 1079,1083 ---- fs_register_func(sys, ".s", word_show_stack, FS_DEFAULT); fs_register_func(sys, ".", word_dot, FS_DEFAULT); + fs_register_func(sys, "emit", word_emit, FS_DEFAULT); fs_register_func(sys, "load", word_load, FS_DEFAULT); fs_register_func(sys, "cr", word_cr, FS_DEFAULT); *************** *** 1033,1037 **** fs_register_func(sys, "then", word_then, FS_IMMEDIATE); fs_register_func(sys, "recurse", fs_recurse, FS_IMMEDIATE); ! fs_register_func(sys, "literal", fs_literal, FS_IMMEDIATE); fs_register_func(sys, "[", fs_compile_pause, FS_IMMEDIATE); fs_register_func(sys, "]", fs_compile_resume, FS_IMMEDIATE); --- 1088,1092 ---- fs_register_func(sys, "then", word_then, FS_IMMEDIATE); fs_register_func(sys, "recurse", fs_recurse, FS_IMMEDIATE); ! fs_register_func(sys, "literal", word_literal, FS_IMMEDIATE); fs_register_func(sys, "[", fs_compile_pause, FS_IMMEDIATE); fs_register_func(sys, "]", fs_compile_resume, FS_IMMEDIATE); *************** *** 1067,1073 **** fs_register_func(sys, "%", word_mod, FS_DEFAULT); fs_register_func(sys, ">", word_gt, FS_DEFAULT); fs_register_func(sys, "<", word_lt, FS_DEFAULT); fs_register_func(sys, "<>", word_neq, FS_DEFAULT); - fs_register_func(sys, ">string", word_tostring, FS_DEFAULT); fs_register_func(sys, ">float", word_tofloat, FS_DEFAULT); fs_register_func(sys, ">integer", word_tointeger, FS_DEFAULT); --- 1122,1130 ---- fs_register_func(sys, "%", word_mod, FS_DEFAULT); fs_register_func(sys, ">", word_gt, FS_DEFAULT); + fs_register_func(sys, ">=", word_gte, FS_DEFAULT); fs_register_func(sys, "<", word_lt, FS_DEFAULT); + fs_register_func(sys, "<=", word_lte, FS_DEFAULT); + fs_register_func(sys, "=", word_eq, FS_DEFAULT); fs_register_func(sys, "<>", word_neq, FS_DEFAULT); fs_register_func(sys, ">float", word_tofloat, FS_DEFAULT); fs_register_func(sys, ">integer", word_tointeger, FS_DEFAULT); *************** *** 1085,1089 **** fs_register_func(sys, "break", fs_break, FS_IMMEDIATE); fs_register_func(sys, "exit", fs_exit, FS_IMMEDIATE); - fs_register_func(sys, "constat", word_con_stat, FS_DEFAULT); fs_register_func(sys, "bye", word_bye, FS_DEFAULT); fs_register_func(sys, "'", word_tick, FS_DEFAULT); --- 1142,1145 ---- *************** *** 1094,1097 **** --- 1150,1154 ---- fs_register_func(sys, "compile?", word_iscompile, FS_DEFAULT); fs_register_func(sys, "yield", word_yield, FS_DEFAULT); + fs_register_func(sys, "evaluate", word_evaluate, FS_DEFAULT); fs_register_func(sys, "'forget", word_xtforget, FS_DEFAULT); fs_register_func(sys, "forget", word_forget, FS_DEFAULT); *************** *** 1101,1106 **** fs_register_func(sys, "$left", word_left, FS_DEFAULT); fs_register_func(sys, "$mid", word_mid, FS_DEFAULT); fs_register_func(sys, "$create", word_strcreate, FS_DEFAULT); - fs_register_func(sys, "console", word_console, FS_DEFAULT); // Load boot script --- 1158,1164 ---- fs_register_func(sys, "$left", word_left, FS_DEFAULT); fs_register_func(sys, "$mid", word_mid, FS_DEFAULT); + fs_register_func(sys, "$asc", word_asc, FS_DEFAULT); + fs_register_func(sys, "$chr", word_chr, FS_DEFAULT); fs_register_func(sys, "$create", word_strcreate, FS_DEFAULT); // Load boot script *************** *** 1108,1116 **** // Register other forth modules ! world_forth_init(&root); ! tileset_forth_init(&root); ! map_forth_init(&root); ! parallax_words_forth_init(&root); ! layer_words_forth_init(&root); // Protect the dictionary by attatching and exiting --- 1166,1175 ---- // Register other forth modules ! world_words_init(&root); ! tileset_words_init(&root); ! map_words_init(&root); ! parallax_words_init(&root); ! layer_words_init(&root); ! console_words_init(&root); // Protect the dictionary by attatching and exiting Index: console_handler.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/console_handler.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** console_handler.c 6 Aug 2004 05:31:43 -0000 1.9 --- console_handler.c 22 Aug 2004 01:20:45 -0000 1.10 *************** *** 41,44 **** --- 41,45 ---- static int console_ret=FS_OK; + void log_result(int result, char *text) { Index: world.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/world.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** world.c 2 Aug 2004 18:51:59 -0000 1.11 --- world.c 22 Aug 2004 01:20:45 -0000 1.12 *************** *** 114,118 **** ! void world_forth_init(FORTH *me) { FSYSTEM *sys=(FSYSTEM*)me; --- 114,118 ---- ! void world_words_init(FORTH *me) { FSYSTEM *sys=(FSYSTEM*)me; Index: map.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/map.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** map.c 6 Aug 2004 05:31:43 -0000 1.16 --- map.c 22 Aug 2004 01:20:45 -0000 1.17 *************** *** 610,614 **** ! void map_forth_init(FORTH *me) { FSYSTEM *sys=(FSYSTEM*)me; --- 610,614 ---- ! void map_words_init(FORTH *me) { FSYSTEM *sys=(FSYSTEM*)me; Index: console_handler.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/console_handler.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** console_handler.h 27 Jul 2004 18:39:32 -0000 1.5 --- console_handler.h 22 Aug 2004 01:20:45 -0000 1.6 *************** *** 4,7 **** --- 4,8 ---- #include "console.h" #include "palette.h" + #include "forth.h" #define BLINK 0x80000000 *************** *** 22,25 **** --- 23,27 ---- int console_start(void); void console_end(void); + void console_words_init(FORTH *me); void log_result(int result, char *text); |
From: Paul P. <ppr...@us...> - 2004-08-06 05:32:01
|
Update of /cvsroot/squidfighter/deathfist/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26040 Modified Files: boot.f root.f Log Message: - added a bunch of words - support for updated Forthy, with yielding scripts etc. - tweaks to console - don't ASSERT inside a word, just throw a Forthy exception. :P Index: root.f =================================================================== RCS file: /cvsroot/squidfighter/deathfist/data/root.f,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** root.f 2 Aug 2004 18:51:59 -0000 1.2 --- root.f 6 Aug 2004 05:31:52 -0000 1.3 *************** *** 1,7 **** ! : root voc.clear ; ! : forget ! ' 'forget ! ; : also --- 1,15 ---- ! -1 constant true ! 0 constant false ! true constant on ! false constant off ! true constant show ! false constant hide ! : next! postpone next ; immediate ! : repeat! postpone repeat ; immediate ! : again! postpone again ; immediate ! : until! postpone until ; immediate ! ! : root voc.clear ; : also *************** *** 18,21 **** --- 26,35 ---- ; + vocabulary tileset immediate + vocabulary world immediate + vocabulary map immediate + vocabulary parallax immediate + vocabulary layer immediate + : order "CONTEXT: " . voc.depth dup for dup i - voc.pick >name . next cr *************** *** 46,52 **** ; immediate ! vocabulary tileset ! vocabulary world ! vocabulary map ! vocabulary parallax ! vocabulary layer --- 60,66 ---- ; immediate ! ( words for non-stalling loops ) ! : next postpone yield postpone next ; immediate ! : repeat postpone yield postpone repeat ; immediate ! : until postpone yield postpone until ; immediate ! : again postpone yield postpone again ; immediate Index: boot.f =================================================================== RCS file: /cvsroot/squidfighter/deathfist/data/boot.f,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** boot.f 31 Jul 2004 21:02:00 -0000 1.1 --- boot.f 6 Aug 2004 05:31:52 -0000 1.2 *************** *** 1,2 **** ! load: data/root.f zardoz --- 1,2 ---- ! "data/root.f" load zardoz |
Update of /cvsroot/squidfighter/deathfist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26011 Modified Files: console.h console_handler.c data.h forth.c forth.h layer_words.c main_forth.c main_forth.h map.c parallax_words.c Log Message: - added a bunch of words - support for updated Forthy, with yielding scripts etc. - tweaks to console - don't ASSERT inside a word, just throw a Forthy exception. :P Index: forth.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/forth.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** forth.h 23 Jul 2004 15:56:08 -0000 1.2 --- forth.h 6 Aug 2004 05:31:43 -0000 1.3 *************** *** 4,7 **** --- 4,12 ---- #include "fsystem.h" + enum{FS_YIELD=FS_USER_RESULT}; + + #define FS_TRUE -1 + #define FS_FALSE 0 + typedef struct FORTH { Index: main_forth.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/main_forth.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** main_forth.h 23 Jul 2004 15:56:08 -0000 1.2 --- main_forth.h 6 Aug 2004 05:31:43 -0000 1.3 *************** *** 5,8 **** --- 5,11 ---- int forth_do(FORTH *me, char *text); + int forth_load_input(FORTH *me, char *text); + int forth_run(FORTH *me); + int main_forth_init(FORTH *me); Index: console.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/console.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** console.h 27 Jul 2004 18:39:32 -0000 1.3 --- console.h 6 Aug 2004 05:31:43 -0000 1.4 *************** *** 62,64 **** --- 62,66 ---- int console_get_err(CONSOLE_SYS *console); + void console_show(int visible); + #endif Index: parallax_words.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/parallax_words.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** parallax_words.c 2 Aug 2004 18:56:45 -0000 1.1 --- parallax_words.c 6 Aug 2004 05:31:43 -0000 1.2 *************** *** 3,6 **** --- 3,8 ---- #include "console_handler.h" + #define CHECK_PARALLAX() {if(!parallax_current){fs_throw(sys, FS_NULL);}} + /* define ( "name" -- ) *************** *** 27,30 **** --- 29,35 ---- { int w, h; + + CHECK_PARALLAX(); + h=fs_get_int(sys, -1); w=fs_get_int(sys, -2); *************** *** 35,38 **** --- 40,44 ---- } + static int list_callback(NODE *node, void *data) { *************** *** 43,46 **** --- 49,53 ---- } + static void word_list(FSYSTEM *sys) { Index: layer_words.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/layer_words.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** layer_words.c 2 Aug 2004 18:56:45 -0000 1.1 --- layer_words.c 6 Aug 2004 05:31:43 -0000 1.2 *************** *** 12,17 **** static void word_add(FSYSTEM *sys) { layer_current = layer_create (parallax_current); - map_add_parallax_layer (map_current, layer_current); } --- 12,18 ---- static void word_add(FSYSTEM *sys) { + CHECK_MAP(); + layer_current = layer_create (parallax_current); map_add_parallax_layer (map_current, layer_current); } *************** *** 20,23 **** --- 21,27 ---- { int i; + + CHECK_MAP(); + for (i = 0; i < map_current->parallax_count; i++) { *************** *** 35,41 **** { int n; n = fs_get_int(sys, -1); ! ASSERT (n < map_current->parallax_count); fs_pop(sys); --- 39,51 ---- { int n; + + CHECK_MAP(); + n = fs_get_int(sys, -1); ! if(n < map_current->parallax_count||n<0) ! { ! fs_throw(sys, FS_OUT_OF_BOUNDS); ! } fs_pop(sys); Index: console_handler.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/console_handler.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** console_handler.c 27 Jul 2004 18:39:32 -0000 1.8 --- console_handler.c 6 Aug 2004 05:31:43 -0000 1.9 *************** *** 38,41 **** --- 38,43 ---- static int is_user_keys=FALSE; + // Console forth + static int console_ret=FS_OK; void log_result(int result, char *text) *************** *** 191,195 **** { int tag=TAG_USER; - int ret; if(fs_is_compiling((FSYSTEM*)forth)) --- 193,196 ---- *************** *** 204,209 **** add_history(input_buf); ! ret=forth_do(forth, input_buf); ! if(ret==FS_OK) { int i, depth; --- 205,210 ---- add_history(input_buf); ! console_ret=forth_do(forth, input_buf); ! if(console_ret==FS_OK) { int i, depth; *************** *** 271,275 **** { int code=util_keycodehit(TRUE); ! if(code) { --- 272,279 ---- { int code=util_keycodehit(TRUE); ! ! if(console_ret==FS_YIELD) ! console_ret=forth_run(forth); ! if(code) { *************** *** 279,284 **** if(code==KEY_TILDE || code == KEY_F1) { ! is_console=!is_console; ! change_console_colour=TRUE; // TODO: Console-specific enabling/disabling --- 283,287 ---- if(code==KEY_TILDE || code == KEY_F1) { ! console_show(!is_console); // TODO: Console-specific enabling/disabling *************** *** 342,356 **** } - case KEY_T: - { - static int temp=0; - - if(util_keyshift(KB_CTRL_FLAG, TRUE)) - { - console_write(con, TAG_SYSTEM|BLINK, "%d TEST\n", temp++); - break; - } - } - default: handle_input(code, ch); --- 345,348 ---- *************** *** 370,373 **** --- 362,367 ---- if(is_console) { + int colour=CON_WHITE; + screen_line=CONSOLE_SCREEN_Y; *************** *** 379,386 **** sprintf(text, ">%s%s", input_buf, (main_timer_sec<30)?"_":"\0"); textprintf (back_buffer, font, CONSOLE_FONT_X+2, CONSOLE_INPUT_Y+2, ! CON_BLACK, text); textprintf (back_buffer, font, CONSOLE_FONT_X, CONSOLE_INPUT_Y, ! CON_WHITE, text); lines=console_get_lines(con); --- 373,389 ---- sprintf(text, ">%s%s", input_buf, (main_timer_sec<30)?"_":"\0"); + if(console_ret==FS_YIELD) + { + colour=CON_BLUE; + } + else if(fs_is_compiling(&forth->sys)) + { + colour=CON_MAUVE; + } + textprintf (back_buffer, font, CONSOLE_FONT_X+2, CONSOLE_INPUT_Y+2, ! CON_BLACK, "%s", text); textprintf (back_buffer, font, CONSOLE_FONT_X, CONSOLE_INPUT_Y, ! colour, "%s", text); lines=console_get_lines(con); *************** *** 437,443 **** { textprintf(back_buffer, font, CONSOLE_FONT_X+2, screen_line+2, ! CON_BLACK, text); textprintf(back_buffer, font, CONSOLE_FONT_X, screen_line, ! tag&0xff, text); } --- 440,446 ---- { textprintf(back_buffer, font, CONSOLE_FONT_X+2, screen_line+2, ! CON_BLACK, "%s", text); textprintf(back_buffer, font, CONSOLE_FONT_X, screen_line, ! tag&0xff, "%s", text); } *************** *** 465,466 **** --- 468,478 ---- console_exit(con); } + + + void console_show(int visible) + { + is_console=visible; + change_console_colour=TRUE; + } + + Index: main_forth.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/main_forth.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** main_forth.c 2 Aug 2004 18:51:59 -0000 1.9 --- main_forth.c 6 Aug 2004 05:31:43 -0000 1.10 *************** *** 122,138 **** - char *forth_scan_word(FSYSTEM *sys) - { - char *str; - - fs_scan_word(sys); - - str=fs_get_string(sys, -1); - fs_pop(sys); - - return str; - } - - static void word_con_stat(FSYSTEM *sys) { --- 122,125 ---- *************** *** 229,233 **** char *str; ! str=forth_scan_word(sys); print(con, TAG_WARNING, "Loading %s...\n", str); fs_throw(sys, load_script(sys, str)); --- 216,221 ---- char *str; ! str=fs_get_string(sys, -1); ! fs_pop(sys); print(con, TAG_WARNING, "Loading %s...\n", str); fs_throw(sys, load_script(sys, str)); *************** *** 363,376 **** - static void word_sub(FSYSTEM *sys) - { - double result; - - result=fs_get_float(sys, -2)-fs_get_float(sys, -1); - fs_remove(sys, 2); - fs_push_float(sys, result); - } - - static void word_name(FSYSTEM *sys) { --- 351,354 ---- *************** *** 466,470 **** { - i++; str=fs_get_word_name(sys, -1); --- 444,447 ---- *************** *** 624,633 **** print(con, TAG_ERROR, "\n"); fs_remove(sys, fs_depth(sys)); ! fs_clear_input(sys); ! fs_voc_clear(sys); ! fs_voc_clear_compile(sys); } ! else { print(con, TAG_WARNING, "Line %d, RESULT at '%s': ", --- 601,611 ---- print(con, TAG_ERROR, "\n"); + + // Reset, but without clearing vocabulary state + fs_reset_ex(sys); fs_remove(sys, fs_depth(sys)); ! // fs_reset(sys); } ! else if(ret!=FS_YIELD) { print(con, TAG_WARNING, "Line %d, RESULT at '%s': ", *************** *** 647,682 **** ! static int forth_load(FORTH *me, char *filename) { ! int ret; ! FSYSTEM *sys=(FSYSTEM*)me; - load_script(sys, filename); - ret=fs_run(sys); ! handle_result(sys, ret); ! return ret; } ! int forth_do(FORTH *me, char *text) { ! int ret; ! FSYSTEM *sys=(FSYSTEM*)me; ! fs_load_input(sys, text); ! ret=fs_run(sys); - handle_result(sys, ret); ! return ret; } ! static void word_xtforget(FSYSTEM *sys) { ! fs_forget(sys, -1); fs_pop(sys); } --- 625,687 ---- ! static void word_xtforget(FSYSTEM *sys) { ! fs_forget(sys, -1); ! fs_pop(sys); ! } ! void word_forget(FSYSTEM *sys) ! { ! char *str; ! fs_scan_word(sys); ! ! str=fs_get_string(sys, -1); ! fs_pop(sys); ! fs_push_word(sys, str); ! ! fs_forget(sys, -1); ! fs_pop(sys); } ! void word_postpone(FSYSTEM *sys) { ! word_tick(sys); ! fs_postpone(sys, -1); ! fs_pop(sys); ! } ! void word_iscompile(FSYSTEM *sys) ! { ! fs_push_int(sys, fs_is_compiling(sys)); } ! void word_isimmediate(FSYSTEM *sys) { ! int flags; ! ! flags=fs_get_word_flags(sys, -1); ! fs_pop(sys); + + if(flags|FS_IMMEDIATE) + { + fs_push_int(sys, FS_TRUE); + } + else + { + fs_push_int(sys, FS_FALSE); + } + } + + + void word_yield(FSYSTEM *sys) + { + fs_throw(sys, FS_YIELD); } *************** *** 789,792 **** --- 794,1007 ---- + static void word_add(FSYSTEM *sys) + { + double result; + + result=fs_get_float(sys, -2)+fs_get_float(sys, -1); + fs_remove(sys, 2); + fs_push_float(sys, result); + } + + + static void word_mul(FSYSTEM *sys) + { + double result; + + result=fs_get_float(sys, -2)*fs_get_float(sys, -1); + fs_remove(sys, 2); + fs_push_float(sys, result); + } + + + static void word_sub(FSYSTEM *sys) + { + double result; + + result=fs_get_float(sys, -2)-fs_get_float(sys, -1); + fs_remove(sys, 2); + fs_push_float(sys, result); + } + + + static void word_div(FSYSTEM *sys) + { + double result; + + result=fs_get_float(sys, -2)/fs_get_float(sys, -1); + fs_remove(sys, 2); + fs_push_float(sys, result); + } + + + static void word_eq(FSYSTEM *sys) + { + int result; + + result=(fs_get_float(sys, -1)==fs_get_float(sys, -2)?-1:0); + fs_remove(sys, 2); + + fs_push_int(sys, result); + } + + + static void word_lt(FSYSTEM *sys) + { + int result; + + result=(fs_get_float(sys, -2)<fs_get_float(sys, -1)?-1:0); + fs_remove(sys, 2); + + fs_push_int(sys, result); + } + + + static void word_gt(FSYSTEM *sys) + { + int result; + + result=(fs_get_float(sys, -2)>fs_get_float(sys, -1)?-1:0); + fs_remove(sys, 2); + + fs_push_int(sys, result); + } + + + static void word_neq(FSYSTEM *sys) + { + int result; + + result=(fs_get_float(sys, -1)==fs_get_float(sys, -2)?0:-1); + fs_remove(sys, 2); + + fs_push_int(sys, result); + } + + + void word_mod(FSYSTEM *sys) + { + int value; + + value=fs_get_int(sys, -1); + + if(!value) + value=1; + + value=fs_get_int(sys, -2)%value; + + fs_remove(sys, 2); + + fs_push_int(sys, value); + } + + + void word_rand(FSYSTEM *sys) + { + fs_push_int(sys, rand()); + } + + + void word_randomize(FSYSTEM *sys) + { + srand(fs_get_int(sys, -1)); + fs_pop(sys); + } + + + void word_time(FSYSTEM *sys) + { + fs_push_int(sys, time(NULL)); + } + + + void word_tostring(FSYSTEM *sys) + { + char *str; + + str=fs_get_string(sys, -1); + fs_pop(sys); + fs_push_string(sys, str); + } + + + void word_tointeger(FSYSTEM *sys) + { + int val; + + val=fs_get_int(sys, -1); + fs_pop(sys); + fs_push_int(sys, val); + } + + + void word_tofloat(FSYSTEM *sys) + { + double val; + + val=fs_get_float(sys, -1); + fs_pop(sys); + fs_push_float(sys, val); + } + + + void word_console(FSYSTEM *sys) + { + console_show(fs_get_int(sys, -1)); + fs_pop(sys); + } + + + /* Non word functions */ + + + static int forth_load(FORTH *me, char *filename) + { + int ret; + FSYSTEM *sys=(FSYSTEM*)me; + + load_script(sys, filename); + ret=fs_run(sys); + handle_result(sys, ret); + + return ret; + } + + + int forth_do(FORTH *me, char *text) + { + int ret; + FSYSTEM *sys=(FSYSTEM*)me; + + fs_load_input(sys, text); + ret=fs_run(sys); + handle_result(sys, ret); + + return ret; + } + + + int forth_load_input(FORTH *me, char *text) + { + int ret; + FSYSTEM *sys=(FSYSTEM*)me; + + ret=fs_load_input(sys, text); + handle_result(sys, ret); + + return ret; + } + + + int forth_run(FORTH *me) + { + int ret; + FSYSTEM *sys=(FSYSTEM*)me; + + ret=fs_run(sys); + handle_result(sys, ret); + + return ret; + } + + int main_forth_init(FORTH *me) { *************** *** 810,814 **** fs_register_func(sys, ".s", word_show_stack, FS_DEFAULT); fs_register_func(sys, ".", word_dot, FS_DEFAULT); ! fs_register_func(sys, "load:", word_load, FS_DEFAULT); fs_register_func(sys, "cr", word_cr, FS_DEFAULT); fs_register_func(sys, "does>", fs_does, FS_IMMEDIATE); --- 1025,1029 ---- fs_register_func(sys, ".s", word_show_stack, FS_DEFAULT); fs_register_func(sys, ".", word_dot, FS_DEFAULT); ! fs_register_func(sys, "load", word_load, FS_DEFAULT); fs_register_func(sys, "cr", word_cr, FS_DEFAULT); fs_register_func(sys, "does>", fs_does, FS_IMMEDIATE); *************** *** 846,850 **** --- 1061,1078 ---- fs_register_func(sys, "j", word_j, FS_DEFAULT); fs_register_func(sys, "k", word_k, FS_DEFAULT); + fs_register_func(sys, "+", word_add, FS_DEFAULT); fs_register_func(sys, "-", word_sub, FS_DEFAULT); + fs_register_func(sys, "*", word_mul, FS_DEFAULT); + fs_register_func(sys, "/", word_div, FS_DEFAULT); + fs_register_func(sys, "%", word_mod, FS_DEFAULT); + fs_register_func(sys, ">", word_gt, FS_DEFAULT); + fs_register_func(sys, "<", word_lt, FS_DEFAULT); + fs_register_func(sys, "<>", word_neq, FS_DEFAULT); + fs_register_func(sys, ">string", word_tostring, FS_DEFAULT); + fs_register_func(sys, ">float", word_tofloat, FS_DEFAULT); + fs_register_func(sys, ">integer", word_tointeger, FS_DEFAULT); + fs_register_func(sys, "randomize", word_randomize, FS_DEFAULT); + fs_register_func(sys, "rand", word_rand, FS_DEFAULT); + fs_register_func(sys, "time", word_time, FS_DEFAULT); fs_register_func(sys, ">name", word_name, FS_DEFAULT); fs_register_func(sys, ">type", word_type, FS_DEFAULT); *************** *** 855,864 **** fs_register_func(sys, "again", fs_again, FS_IMMEDIATE); fs_register_func(sys, "ahead", fs_ahead, FS_IMMEDIATE); ! fs_register_func(sys, "con.stat", word_con_stat, FS_DEFAULT); fs_register_func(sys, "bye", word_bye, FS_DEFAULT); fs_register_func(sys, "'", word_tick, FS_DEFAULT); fs_register_func(sys, "word", word_word, FS_DEFAULT); fs_register_func(sys, "immediate", word_immediate, FS_DEFAULT); fs_register_func(sys, "'forget", word_xtforget, FS_DEFAULT); fs_register_func(sys, "$cat", word_cat, FS_DEFAULT); fs_register_func(sys, "$len", word_len, FS_DEFAULT); --- 1083,1099 ---- fs_register_func(sys, "again", fs_again, FS_IMMEDIATE); fs_register_func(sys, "ahead", fs_ahead, FS_IMMEDIATE); ! fs_register_func(sys, "break", fs_break, FS_IMMEDIATE); ! fs_register_func(sys, "exit", fs_exit, FS_IMMEDIATE); ! fs_register_func(sys, "constat", word_con_stat, FS_DEFAULT); fs_register_func(sys, "bye", word_bye, FS_DEFAULT); fs_register_func(sys, "'", word_tick, FS_DEFAULT); fs_register_func(sys, "word", word_word, FS_DEFAULT); fs_register_func(sys, "immediate", word_immediate, FS_DEFAULT); + fs_register_func(sys, "immediate?", word_isimmediate, FS_DEFAULT); + fs_register_func(sys, "postpone", word_postpone, FS_IMMEDIATE); + fs_register_func(sys, "compile?", word_iscompile, FS_DEFAULT); + fs_register_func(sys, "yield", word_yield, FS_DEFAULT); fs_register_func(sys, "'forget", word_xtforget, FS_DEFAULT); + fs_register_func(sys, "forget", word_forget, FS_DEFAULT); fs_register_func(sys, "$cat", word_cat, FS_DEFAULT); fs_register_func(sys, "$len", word_len, FS_DEFAULT); *************** *** 867,870 **** --- 1102,1106 ---- fs_register_func(sys, "$mid", word_mid, FS_DEFAULT); fs_register_func(sys, "$create", word_strcreate, FS_DEFAULT); + fs_register_func(sys, "console", word_console, FS_DEFAULT); // Load boot script *************** *** 896,897 **** --- 1132,1135 ---- forth_exit(me); } + + Index: forth.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/forth.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** forth.c 23 Jul 2004 06:07:55 -0000 1.1 --- forth.c 6 Aug 2004 05:31:43 -0000 1.2 *************** *** 16,19 **** --- 16,32 ---- + char *forth_scan_word(FSYSTEM *sys) + { + char *str; + + fs_scan_word(sys); + + str=fs_get_string(sys, -1); + fs_pop(sys); + + return str; + } + + void forth_exit(FORTH *sys) { Index: data.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/data.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** data.h 2 Aug 2004 18:51:59 -0000 1.5 --- data.h 6 Aug 2004 05:31:43 -0000 1.6 *************** *** 5,8 **** --- 5,11 ---- #include "map.h" + // TODO: Move to a better header + #define CHECK_MAP() {if(!map_current){fs_throw(sys, FS_NULL);}} + /* Shared by all states. */ extern WORLD *world; Index: map.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/map.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** map.c 2 Aug 2004 18:51:59 -0000 1.15 --- map.c 6 Aug 2004 05:31:43 -0000 1.16 *************** *** 19,23 **** #include "tile.h" - #define CHECK_MAP() {if(!map_current){fs_throw(sys, FS_NULL);}} /* Map from pixel coordinates to room and tile coordinates. */ --- 19,22 ---- |
From: Elias P. <el...@us...> - 2004-08-02 18:56:54
|
Update of /cvsroot/squidfighter/deathfist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6525 Added Files: layer.c layer.h layer_words.c layer_words.h parallax_words.c parallax_words.h Log Message: added parallax layer words files --- NEW FILE: layer_words.c --- #include "layer_words.h" #include "parallax_words.h" #include "layer.h" #include "data.h" #include "console_handler.h" #include "world.h" /* add ( -- ) - adds a new layer to the current map to the top of the layers stack */ static void word_add(FSYSTEM *sys) { layer_current = layer_create (parallax_current); map_add_parallax_layer (map_current, layer_current); } static void word_list(FSYSTEM *sys) { int i; for (i = 0; i < map_current->parallax_count; i++) { print(con, TAG_SYSTEM, "%i: %.1f/%.1f %.1f/%.1f %.1f/%.1f", i, map_current->parallax_layers[i]->x, map_current->parallax_layers[i]->y, map_current->parallax_layers[i]->scroll_x, map_current->parallax_layers[i]->scroll_y, map_current->parallax_layers[i]->auto_scroll_x, map_current->parallax_layers[i]->auto_scroll_y); } } static void word_edit(FSYSTEM *sys) { int n; n = fs_get_int(sys, -1); ASSERT (n < map_current->parallax_count); fs_pop(sys); layer_current = map_current->parallax_layers[n]; } void layer_words_forth_init(FORTH *me) { FSYSTEM *sys=(FSYSTEM*)me; forth_do(me, "layer definitions"); fs_register_func(sys, "add", word_add, FS_DEFAULT); fs_register_func(sys, "list", word_list, FS_DEFAULT); fs_register_func(sys, "edit", word_edit, FS_DEFAULT); } --- NEW FILE: parallax_words.h --- #ifndef __PARALLAX_WORDS_H__ #define __PARALLAX_WORDS_H__ #include "main_forth.h" #include "parallax.h" void parallax_words_forth_init(FORTH *me); #endif --- NEW FILE: layer_words.h --- #ifndef __LAYER_WORDS_H__ #define __LAYER_WORDS_H__ #include "main_forth.h" void layer_words_forth_init(FORTH *me); #endif --- NEW FILE: parallax_words.c --- #include "parallax_words.h" #include "data.h" #include "console_handler.h" /* define ( "name" -- ) - creates or redefines a layer */ static void word_define(FSYSTEM *sys) { char *str; str=fs_get_string(sys, -1); fs_pop(sys); parallax_current = world_get_parallax(world, str); if(!parallax_current) { parallax_current = parallax_create(); world_add_parallax(world, parallax_current, str); } } static void word_size(FSYSTEM *sys) { int w, h; h=fs_get_int(sys, -1); w=fs_get_int(sys, -2); fs_remove(sys, 2); parallax_resize(parallax_current, w, h); } static int list_callback(NODE *node, void *data) { PARALLAX *parallax = node->data; print(con, TAG_SYSTEM, "%-54s%-3dx%-3d tiles\n", node->name, parallax->w, parallax->h); return FALSE; } static void word_list(FSYSTEM *sys) { list_for_each(world->parallaxes, list_callback, NULL); } void parallax_words_forth_init(FORTH *me) { FSYSTEM *sys=(FSYSTEM*)me; forth_do(me, "parallax definitions"); fs_register_func(sys, "define", word_define, FS_DEFAULT); fs_register_func(sys, "list", word_list, FS_DEFAULT); } --- NEW FILE: layer.h --- #ifndef __LAYER_H__ #define __LAYER_H__ typedef struct LAYER LAYER; #include "parallax.h" /* The PARALLAX struct just contains the tile information * for a layer, so it can be re-used easly. The LAYER struct * actually defines its position and other parameters * specific to the use inside a map as parallax layer. */ struct LAYER { /* The actual parallax layer tiles. Maybe we can use ROOM * or MAP for this at some point, in case we want to unify * all the layers code. */ PARALLAX *parallax; /* Pixel position of origin. If the main map is displayed * with its upper left pixel at the upper left window corner, * the parallax layer will be displayed with its upper * left corner at the specified position. */ float x, y; /* Given the above fixed position, this is the speed with * with the layer scrolls compared to the main map. 1 would * mean, it scrolls with the main map. 0.5 would mean, if * the main map scrolls 10 pixels, this layer will only * have scrolled 5. */ float scroll_x, scroll_y; /* This will cause the layer to automatically scroll, even * when the main map is not moving. E.g. for a layer * containing clouds floating by. */ float auto_scroll_x, auto_scroll_y; /* Flags to decide what to do when outside of the tilemap. If * it is on, the layer wraps around. Else there will be * emptyness. (The backmost layer either should wrap, or be * big enough to span all the visible area.) */ int wrap_x, wrap_y; }; LAYER *layer_create(PARALLAX *parallax); void layer_destroy(LAYER *me); void layer_draw (LAYER *me, VIEW *view, TILE_CALLBACK func); void layer_update(LAYER *me); TILE *layer_tile (LAYER *me, int x, int y); #endif --- NEW FILE: layer.c --- #include "layer.h" #include "map.h" LAYER *layer_create(PARALLAX *parallax) { LAYER *me = calloc (1, sizeof *me); me->parallax = parallax; me->scroll_x = 1.0; me->scroll_y = 1.0; return me; } /* The global parallax layer pointed to by this layer will * *not* be destroyed. */ void layer_destroy(LAYER *me) { free (me); } static int pixel_to_tile (int pixel) { if (pixel > 0) return pixel / TILE_SIZE; return (1 + pixel - TILE_SIZE) / TILE_SIZE; } static int tile_to_pixel (int tile) { return tile * TILE_SIZE; } static int wrap_pos (int x, int w) { x = x % w; if (x < 0) x += w; return x; } /* Returns a pointer to a single tile id in the parallax layer. */ TILE *layer_tile (LAYER *me, int x, int y) { ASSERT (me); ASSERT (me->parallax); if (me->wrap_y) y = wrap_pos (y, me->parallax->h); else if (y < 0 || y >= me->parallax->h) return NULL; if (me->wrap_x) x = wrap_pos (x, me->parallax->w); else if (x < 0 || x >= me->parallax->w) return NULL; return me->parallax->tiles + y * me->parallax->w + x; } /* Draws a single parallax layer, with the given view of the main map. */ void layer_draw (LAYER *me, VIEW *view, TILE_CALLBACK func) { int camera_x, camera_y; int tile_x, tile_y; int pixel_x, pixel_y; ASSERT (me); ASSERT (me->parallax); if (!me->parallax->tileset) return; camera_x = (view->camera_x - me->x) * me->scroll_x; camera_y = (view->camera_y - me->y) * me->scroll_y; tile_y = pixel_to_tile (camera_y); pixel_y = view->y + tile_to_pixel (tile_y) - camera_y; if (me->wrap_y) tile_y = wrap_pos (tile_y, me->parallax->h); /* TODO: calculate proper starting offset for partially outside * layer, and detect completely outside layer. */ for (; pixel_y < view->y + view->h; tile_y++, pixel_y += TILE_SIZE) { if (tile_y < 0) continue; if (tile_y >= me->parallax->h) { if (me->wrap_y) tile_y -= me->parallax->h; else break; } tile_x = pixel_to_tile (camera_x); pixel_x = view->x + tile_to_pixel (tile_x) - camera_x; if (me->wrap_x) tile_x = wrap_pos (tile_x, me->parallax->w); for (; pixel_x < view->x + view->w; tile_x++, pixel_x += TILE_SIZE) { TILE *t; if (tile_x < 0) continue; if (tile_x >= me->parallax->w) { if (me->wrap_x) tile_x -= me->parallax->w; else break; } t = me->parallax->tiles + tile_y * me->parallax->w + tile_x; if (t->bg) func(&me->parallax->tileset->id[t->bg], pixel_x, pixel_y); if (t->id) func(&me->parallax->tileset->id[t->id], pixel_x, pixel_y); if (t->fg) func(&me->parallax->tileset->id[t->fg], pixel_x, pixel_y); } } } void layer_update(LAYER *me) { me->x += me->auto_scroll_x; me->y += me->auto_scroll_y; } |
From: Elias P. <el...@us...> - 2004-08-02 18:52:13
|
Update of /cvsroot/squidfighter/deathfist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5165 Modified Files: adventure.c data.h edit_state.c main_forth.c map.c map.h parallax.c parallax.h view.c widget_tileset.c world.c world.h world_view_state.c Log Message: added parallax/layer words Index: world.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/world.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** world.h 29 Jul 2004 06:22:42 -0000 1.8 --- world.h 2 Aug 2004 18:51:59 -0000 1.9 *************** *** 7,10 **** --- 7,11 ---- #include "list.h" #include "tileset.h" + #include "parallax.h" #include "forth.h" *************** *** 15,18 **** --- 16,20 ---- LIST *maps; LIST *tilesets; + LIST *parallaxes; }; *************** *** 29,32 **** --- 31,38 ---- void world_destroy_tileset(WORLD *me, char const *name); + NODE *world_add_parallax(WORLD *me, PARALLAX *tileset, char const *name); + PARALLAX *world_get_parallax(WORLD *me, char const *name); + void world_destroy_parallax(WORLD *me, char const *name); + void world_forth_init(FORTH *me); Index: parallax.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/parallax.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** parallax.c 27 Jul 2004 18:56:36 -0000 1.7 --- parallax.c 2 Aug 2004 18:51:59 -0000 1.8 *************** *** 2,12 **** #include "map.h" ! PARALLAX *parallax_create(int w, int h) { PARALLAX *me = calloc (1, sizeof *me); ! me->w = w; ! me->h = h; ! me->scroll_x = 1.0; ! me->scroll_y = 1.0; me->tiles = calloc (me->w * me->h, sizeof *me->tiles); return me; --- 2,10 ---- #include "map.h" ! PARALLAX *parallax_create(void) { PARALLAX *me = calloc (1, sizeof *me); ! me->w = 1; ! me->h = 1; me->tiles = calloc (me->w * me->h, sizeof *me->tiles); return me; *************** *** 14,128 **** ! void parallax_destroy(PARALLAX *me) { free (me->tiles); ! free (me); } ! static int pixel_to_tile (int pixel) ! { ! if (pixel > 0) ! return pixel / TILE_SIZE; ! return (1 + pixel - TILE_SIZE) / TILE_SIZE; ! } ! ! static int tile_to_pixel (int tile) { ! return tile * TILE_SIZE; } - static int wrap_pos (int x, int w) - { - x = x % w; - if (x < 0) - x += w; - return x; - } ! /* Returns a pointer to a single tile id in the parallax layer. */ ! TILE *parallax_tile (PARALLAX *me, int x, int y) { ! if (me->wrap_y) ! y = wrap_pos (y, me->h); ! else ! if (y < 0 || y >= me->h) ! return NULL; ! ! if (me->wrap_x) ! x = wrap_pos (x, me->w); ! else ! if (x < 0 || x >= me->w) ! return NULL; ! ! return me->tiles + y * me->w + x; } - /* Draws a single parallax layer, with the given view of the main map. */ - void parallax_draw (PARALLAX *me, VIEW *view, TILE_CALLBACK func) - { - int camera_x, camera_y; - int tile_x, tile_y; - int pixel_x, pixel_y; - - if (!me->tileset) - return; - - camera_x = (view->camera_x - me->x) * me->scroll_x; - camera_y = (view->camera_y - me->y) * me->scroll_y; - - tile_y = pixel_to_tile (camera_y); - pixel_y = view->y + tile_to_pixel (tile_y) - camera_y; - if (me->wrap_y) - tile_y = wrap_pos (tile_y, me->h); - - /* TODO: calculate proper starting offset for partially outside - * layer, and detect completely outside layer. */ - - for (; pixel_y < view->y + view->h; tile_y++, pixel_y += TILE_SIZE) - { - if (tile_y < 0) - continue; - if (tile_y >= me->h) - { - if (me->wrap_y) - tile_y -= me->h; - else - break; - } - - tile_x = pixel_to_tile (camera_x); - pixel_x = view->x + tile_to_pixel (tile_x) - camera_x; - if (me->wrap_x) - tile_x = wrap_pos (tile_x, me->w); - - for (; pixel_x < view->x + view->w; tile_x++, pixel_x += TILE_SIZE) - { - TILE *t; - if (tile_x < 0) - continue; - if (tile_x >= me->w) - { - if (me->wrap_x) - tile_x -= me->w; - else - break; - } - - t = me->tiles + tile_y * me->w + tile_x; - - if (t->bg) - func(&me->tileset->id[t->bg], pixel_x, pixel_y); - if (t->id) - func(&me->tileset->id[t->id], pixel_x, pixel_y); - if (t->fg) - func(&me->tileset->id[t->fg], pixel_x, pixel_y); - } - } - } ! void parallax_update(PARALLAX *me) { ! me->x += me->auto_scroll_x; ! me->y += me->auto_scroll_y; ! } --- 12,40 ---- ! void parallax_resize(PARALLAX *me, int w, int h) { + /* TODO: non-destructively resize. */ free (me->tiles); ! me->w = w; ! me->h = h; ! me->tiles = calloc (me->w * me->h, sizeof *me->tiles); } ! void parallax_destroy(PARALLAX *me) { ! free (me->tiles); ! free (me); } ! static void destroy(void *data) { ! parallax_destroy((PARALLAX *)data); } ! LIST_INTERFACE parallax_list_interface= { ! destroy ! }; Index: adventure.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/adventure.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** adventure.c 29 Jul 2004 06:22:42 -0000 1.19 --- adventure.c 2 Aug 2004 18:51:59 -0000 1.20 *************** *** 3,7 **** #include "game_states.h" #include "map.h" ! #include "parallax.h" // TODO: will be done by view/map code! /* Abusing this state as a testing state for now :) */ --- 3,7 ---- #include "game_states.h" #include "map.h" ! #include "layer.h" // TODO: will be done by view/map code! /* Abusing this state as a testing state for now :) */ *************** *** 75,86 **** } ! static void layer_clear (PARALLAX *me, int id) { int x, y; ! for (y = 0; y < me->h; y++) { ! for (x = 0; x < me->w; x++) { ! parallax_tile (me, x, y)->id = id; } } --- 75,86 ---- } ! static void layer_clear (LAYER *me, int id) { int x, y; ! for (y = 0; y < me->parallax->h; y++) { ! for (x = 0; x < me->parallax->w; x++) { ! layer_tile (me, x, y)->id = id; } } *************** *** 89,93 **** static int enter(void) { ! PARALLAX *layer; int x, y; int i, j; --- 89,94 ---- static int enter(void) { ! PARALLAX *parallax; ! LAYER *layer; int x, y; int i, j; *************** *** 112,118 **** } testview = view_create(testmap, 20, 20, SCREEN_W - 40, SCREEN_H - 40); ! // TODO: map_add_parallax (...) ! layer = parallax_create(100, 100); ! layer->tileset = testset; layer->scroll_x = 0; layer->scroll_y = 0; --- 113,121 ---- } testview = view_create(testmap, 20, 20, SCREEN_W - 40, SCREEN_H - 40); ! ! parallax = parallax_create(); ! parallax_resize (parallax, 10, 10); ! parallax->tileset = testset; ! layer = layer_create(parallax); layer->scroll_x = 0; layer->scroll_y = 0; *************** *** 120,125 **** layer_clear (layer, 2); ! layer = parallax_create(100, 100); ! layer->tileset = testset; layer->scroll_x = 0.25; layer->scroll_y = 0.25; --- 123,130 ---- layer_clear (layer, 2); ! parallax = parallax_create(); ! parallax_resize (parallax, 10, 10); ! parallax->tileset = testset; ! layer = layer_create(parallax); layer->scroll_x = 0.25; layer->scroll_y = 0.25; *************** *** 127,132 **** layer_clear (layer, 3); ! layer = parallax_create(100, 100); ! layer->tileset = testset; layer->scroll_x = 0.5; layer->scroll_y = 0.5; --- 132,139 ---- layer_clear (layer, 3); ! parallax = parallax_create(); ! parallax_resize (parallax, 10, 10); ! parallax->tileset = testset; ! layer = layer_create(parallax); layer->scroll_x = 0.5; layer->scroll_y = 0.5; *************** *** 134,139 **** layer_clear (layer, 4); ! layer = parallax_create(1, 1); ! layer->tileset = testset; layer->scroll_x = 0.5; layer->scroll_y = 0.5; --- 141,147 ---- layer_clear (layer, 4); ! parallax = parallax_create(); ! parallax->tileset = testset; ! layer = layer_create(parallax); layer->scroll_x = 0.5; layer->scroll_y = 0.5; *************** *** 178,182 **** /* TODO: do this differently if we need it at all. */ ! parallax_update (testmap->parallax_layers[3]); } --- 186,190 ---- /* TODO: do this differently if we need it at all. */ ! layer_update (testmap->parallax_layers[3]); } Index: parallax.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/parallax.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** parallax.h 27 Jul 2004 18:39:32 -0000 1.8 --- parallax.h 2 Aug 2004 18:51:59 -0000 1.9 *************** *** 11,42 **** struct PARALLAX { - /* Pixel position of origin. If the main map is displayed - * with its upper left pixel at the upper left window corner, - * the parallax layer will be displayed with its upper - * left corner at the specified position. - */ - float x, y; - - /* Given the above fixed position, this is the speed with - * with the layer scrolls compared to the main map. 1 would - * mean, it scrolls with the main map. 0.5 would mean, if - * the main map scrolls 10 pixels, this layer will only - * have scrolled 5. - */ - float scroll_x, scroll_y; - - /* This will cause the layer to automatically scroll, even - * when the main map is not moving. E.g. for a layer - * containing clouds floating by. - */ - float auto_scroll_x, auto_scroll_y; - - /* Flags to decide what to do when outside of the tilemap. If - * it is on, the layer wraps around. Else there will be - * emptyness. (The backmost layer either should wrap, or be - * big enough to span all the visible area.) - */ - int wrap_x, wrap_y; - /* The sizes in tiles of the layer. */ int w, h; --- 11,14 ---- *************** *** 48,56 **** }; ! PARALLAX *parallax_create(int w, int h); void parallax_destroy(PARALLAX *me); - void parallax_draw (PARALLAX *me, VIEW *view, TILE_CALLBACK func); - void parallax_update(PARALLAX *me); - TILE *parallax_tile (PARALLAX *me, int x, int y); #endif --- 20,28 ---- }; ! extern LIST_INTERFACE parallax_list_interface; ! ! PARALLAX *parallax_create(void); ! void parallax_resize(PARALLAX *me, int w, int h); void parallax_destroy(PARALLAX *me); #endif Index: main_forth.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/main_forth.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** main_forth.c 31 Jul 2004 15:19:04 -0000 1.8 --- main_forth.c 2 Aug 2004 18:51:59 -0000 1.9 *************** *** 7,10 **** --- 7,12 ---- #include "main.h" #include "forth.h" + #include "parallax_words.h" + #include "layer_words.h" #define TO_OFFSET(offset) ((-1-offset)<0?-1-offset:0) *************** *** 873,876 **** --- 875,880 ---- tileset_forth_init(&root); map_forth_init(&root); + parallax_words_forth_init(&root); + layer_words_forth_init(&root); // Protect the dictionary by attatching and exiting Index: edit_state.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/edit_state.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** edit_state.c 31 Jul 2004 21:52:22 -0000 1.21 --- edit_state.c 2 Aug 2004 18:51:59 -0000 1.22 *************** *** 128,133 **** TILE_SET *tileset = NULL; ! if (parallax_editing && parallax_current) ! tileset = parallax_current->tileset; else tileset = map_current->tileset; --- 128,133 ---- TILE_SET *tileset = NULL; ! if (parallax_editing && layer_current) ! tileset = layer_current->parallax->tileset; else tileset = map_current->tileset; *************** *** 315,327 **** if (parallax_editing) { ! if (!parallax_current) { ! // TODO: This should be done by console commands! ! parallax_current = parallax_create( ! map_current->w * ROOM_TILES_W, ! map_current->h * ROOM_TILES_H); ! map_add_parallax_layer (map_current, parallax_current); } ! tile = parallax_tile(parallax_current, map_x / TILE_SIZE, map_y / TILE_SIZE); } --- 315,324 ---- if (parallax_editing) { ! if (!layer_current) { ! layer_current = layer_create(parallax_current); ! map_add_parallax_layer (map_current, layer_current); } ! tile = layer_tile(layer_current, map_x / TILE_SIZE, map_y / TILE_SIZE); } Index: world_view_state.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/world_view_state.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** world_view_state.c 29 Jul 2004 06:22:42 -0000 1.17 --- world_view_state.c 2 Aug 2004 18:51:59 -0000 1.18 *************** *** 5,8 **** --- 5,9 ---- MAP *map_current = NULL; + LAYER *layer_current = NULL; PARALLAX *parallax_current = NULL; Index: widget_tileset.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/widget_tileset.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** widget_tileset.c 29 Jul 2004 06:22:42 -0000 1.4 --- widget_tileset.c 2 Aug 2004 18:51:59 -0000 1.5 *************** *** 55,60 **** if (parallax_editing) { ! if (parallax_current) ! parallax_current->tileset = node->data; } else --- 55,60 ---- if (parallax_editing) { ! if (layer_current) ! layer_current->parallax->tileset = node->data; } else Index: map.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/map.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** map.h 31 Jul 2004 15:19:04 -0000 1.10 --- map.h 2 Aug 2004 18:51:59 -0000 1.11 *************** *** 7,11 **** #include "tileset.h" #include "tile.h" ! #include "parallax.h" #define ROOM_TILES_W 5 --- 7,11 ---- #include "tileset.h" #include "tile.h" ! #include "layer.h" #define ROOM_TILES_W 5 *************** *** 45,49 **** int parallax_count; ! PARALLAX **parallax_layers; }; --- 45,49 ---- int parallax_count; ! LAYER **parallax_layers; }; *************** *** 76,81 **** // Parallax layer ! void map_add_parallax_layer (MAP *me, PARALLAX *layer); ! void map_remove_parallax_layer (MAP *me, PARALLAX *layer); int map_save(MAP *me, PACKFILE *file); --- 76,81 ---- // Parallax layer ! void map_add_parallax_layer (MAP *me, LAYER *layer); ! void map_remove_parallax_layer (MAP *me, LAYER *layer); int map_save(MAP *me, PACKFILE *file); Index: view.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/view.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** view.c 31 Jul 2004 21:52:22 -0000 1.8 --- view.c 2 Aug 2004 18:51:59 -0000 1.9 *************** *** 192,195 **** /* Draw parallax layers (if any). */ for (i = 0; i < map->parallax_count; i++) ! parallax_draw (map->parallax_layers[i], view, func); } --- 192,195 ---- /* Draw parallax layers (if any). */ for (i = 0; i < map->parallax_count; i++) ! layer_draw (map->parallax_layers[i], view, func); } Index: data.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/data.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** data.h 29 Jul 2004 06:22:42 -0000 1.4 --- data.h 2 Aug 2004 18:51:59 -0000 1.5 *************** *** 8,11 **** --- 8,12 ---- extern WORLD *world; extern MAP *map_current; + extern LAYER *layer_current; extern PARALLAX *parallax_current; Index: world.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/world.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** world.c 31 Jul 2004 21:52:22 -0000 1.10 --- world.c 2 Aug 2004 18:51:59 -0000 1.11 *************** *** 8,11 **** --- 8,12 ---- me->maps = list_create (&map_list_interface, "maps"); me->tilesets = list_create (&tileset_list_interface, "tilesets"); + me->parallaxes = list_create (¶llax_list_interface, "parallaxes"); return me; } *************** *** 87,90 **** --- 88,111 ---- + /* Add a named parallax layer to the world. */ + NODE *world_add_parallax(WORLD *me, PARALLAX *parallax, char const *name) + { + return list_add(me->parallaxes, name, parallax); + } + + + /* Remove and destroy a named tileset. */ + void world_destroy_parallax(WORLD *me, char const *name) + { + list_destroy_node(me->parallaxes, name); + } + + + PARALLAX *world_get_parallax(WORLD *me, char const *name) + { + return list_find(me->parallaxes, name); + } + + static void word_edit(FSYSTEM *sys) { Index: map.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/map.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** map.c 31 Jul 2004 20:43:00 -0000 1.14 --- map.c 2 Aug 2004 18:51:59 -0000 1.15 *************** *** 349,353 **** ! void map_add_parallax_layer(MAP *me, PARALLAX *layer) { int i = me->parallax_count++; --- 349,353 ---- ! void map_add_parallax_layer(MAP *me, LAYER *layer) { int i = me->parallax_count++; *************** *** 359,363 **** /* The layer is removed from the map, but not destroyed. */ ! void map_remove_parallax_layer (MAP *me, PARALLAX *layer) { int i, found = 0; --- 359,363 ---- /* The layer is removed from the map, but not destroyed. */ ! void map_remove_parallax_layer (MAP *me, LAYER *layer) { int i, found = 0; |
From: Elias P. <el...@us...> - 2004-08-02 18:52:13
|
Update of /cvsroot/squidfighter/deathfist/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5165/data Modified Files: root.f Log Message: added parallax/layer words Index: root.f =================================================================== RCS file: /cvsroot/squidfighter/deathfist/data/root.f,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** root.f 31 Jul 2004 21:02:00 -0000 1.1 --- root.f 2 Aug 2004 18:51:59 -0000 1.2 *************** *** 48,50 **** vocabulary tileset vocabulary world ! vocabulary map \ No newline at end of file --- 48,52 ---- vocabulary tileset vocabulary world ! vocabulary map ! vocabulary parallax ! vocabulary layer |
From: Paul P. <ppr...@us...> - 2004-08-01 05:18:08
|
Update of /cvsroot/squidfighter/deathfist/deathfist/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21322/data Removed Files: boot.f root.f Log Message: - trying to fix weirded up directory structure --- root.f DELETED --- --- boot.f DELETED --- |
From: Paul P. <ppr...@us...> - 2004-07-31 23:02:14
|
Update of /cvsroot/squidfighter/deathfist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8141 Modified Files: tileset.c Log Message: - fixed null strdup in tile.c - LIST word added to tileset Index: tileset.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/tileset.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** tileset.c 31 Jul 2004 21:52:22 -0000 1.12 --- tileset.c 31 Jul 2004 23:02:05 -0000 1.13 *************** *** 91,95 **** free(tileset->imagename); ! me->imagename=strdup(name); return TRUE; --- 91,98 ---- free(tileset->imagename); ! if(name) ! me->imagename=strdup(name); ! else ! me->imagename=strdup("<noname>"); return TRUE; *************** *** 288,291 **** --- 291,308 ---- + static int list_callback(NODE *node, void *data) + { + print(con, TAG_SYSTEM, "%-54s%-3d tiles\n", node->name, + ((TILE_SET*)node->data)->count); + return FALSE; + } + + + static void word_list(FSYSTEM *sys) + { + list_for_each(world->tilesets, list_callback, NULL); + } + + void tileset_forth_init(FORTH *me) { *************** *** 303,308 **** fs_register_func(sys, "barrier", word_breakable, FS_DEFAULT); fs_register_func(sys, "stat", word_stat, FS_DEFAULT); - fs_register_func(sys, "view", word_view, FS_DEFAULT); fs_register_func(sys, "edit", word_view, FS_DEFAULT); } --- 320,325 ---- fs_register_func(sys, "barrier", word_breakable, FS_DEFAULT); fs_register_func(sys, "stat", word_stat, FS_DEFAULT); fs_register_func(sys, "edit", word_view, FS_DEFAULT); + fs_register_func(sys, "list", word_list, FS_DEFAULT); } |
From: Paul P. <ppr...@us...> - 2004-07-31 21:52:31
|
Update of /cvsroot/squidfighter/deathfist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29688 Modified Files: edit_state.c tileset.c view.c world.c Log Message: - fixed gcc warning in tileset - crash-proofing for null tilesets in map editor, rendering, etc. Index: view.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/view.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** view.c 27 Jul 2004 18:39:32 -0000 1.7 --- view.c 31 Jul 2004 21:52:22 -0000 1.8 *************** *** 120,124 **** room_y = camera_y / map->room_h; ! if(!map->room) return; --- 120,124 ---- room_y = camera_y / map->room_h; ! if(!map->room||!map->tileset) return; Index: world.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/world.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** world.c 31 Jul 2004 20:43:00 -0000 1.9 --- world.c 31 Jul 2004 21:52:22 -0000 1.10 *************** *** 76,86 **** NODE *world_add_tileset(WORLD *me, TILE_SET *tileset, char const *name) { ! return list_add (me->tilesets, name, tileset); } /* Remove and destroy a named tileset. */ void world_destroy_tileset(WORLD *me, char const *name) { ! list_destroy_node (me->tilesets, name); } --- 76,87 ---- NODE *world_add_tileset(WORLD *me, TILE_SET *tileset, char const *name) { ! return list_add(me->tilesets, name, tileset); } + /* Remove and destroy a named tileset. */ void world_destroy_tileset(WORLD *me, char const *name) { ! list_destroy_node(me->tilesets, name); } *************** *** 99,104 **** /* - fs_register_func(sys, "add", word_add, FS_DEFAULT); - fs_register_func(sys, "delete", word_delete, FS_DEFAULT); fs_register_func(sys, "stat", word_stat, FS_DEFAULT); */ --- 100,103 ---- Index: edit_state.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/edit_state.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** edit_state.c 31 Jul 2004 15:19:04 -0000 1.20 --- edit_state.c 31 Jul 2004 21:52:22 -0000 1.21 *************** *** 343,347 **** } } ! else { map_to_room_tile(view->map, map_x, map_y, &room_x, &room_y, --- 343,347 ---- } } ! else if(view->map->tileset) { map_to_room_tile(view->map, map_x, map_y, &room_x, &room_y, *************** *** 365,373 **** event->type == WIDGET_EVENT_RMOUSE_HOLD) { ! if(tile) ! copy_tile=*tile; ! else { ! copy_tile=blank_tile; } } --- 365,376 ---- event->type == WIDGET_EVENT_RMOUSE_HOLD) { ! if(view->map->tileset) { ! if(tile) ! copy_tile=*tile; ! else ! { ! copy_tile=blank_tile; ! } } } *************** *** 390,393 **** --- 393,399 ---- static int enter(void) { + if(!map_current) + return FALSE; + view = view_create(map_current, 0, 0, SCREEN_W, SCREEN_H); Index: tileset.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/tileset.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** tileset.c 31 Jul 2004 20:43:00 -0000 1.11 --- tileset.c 31 Jul 2004 21:52:22 -0000 1.12 *************** *** 172,176 **** fs_pop(sys); ! if(!(0>=entry<tileset->count)) { fs_throw(sys, FS_OUT_OF_BOUNDS); --- 172,176 ---- fs_pop(sys); ! if(!(entry>=0&&entry<tileset->count)) { fs_throw(sys, FS_OUT_OF_BOUNDS); |
From: Elias P. <el...@us...> - 2004-07-31 21:02:08
|
Update of /cvsroot/squidfighter/deathfist/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22808/data Added Files: boot.f root.f Log Message: moving directory --- NEW FILE: root.f --- : root voc.clear ; : forget ' 'forget ; : also 0 voc.pick voc.push ; : definitions voc.depth if 0 voc.pick current! else current.clear then ; : vocabulary variable last last >body ! does> voc.depth if voc.pop drop then @ voc.push ; : order "CONTEXT: " . voc.depth dup for dup i - voc.pick >name . next cr "CURRENT: " . current@ dup >type if >name . else drop then cr drop ; : voc.path ( word -- ) "/" begin over >voc >type while ( word str ) over >voc >name swap $cat ( word str ) swap >voc swap "/" swap $cat ( word str ) repeat swap drop ; : which ' dup voc.path swap >name $cat . ; : namespace 32 word "{" $cat $create last last >body ! immediate does> @ dup voc.push current! ; : } voc.pop drop voc.depth if voc.pop dup current! voc.push else current.clear then ; immediate vocabulary tileset vocabulary world vocabulary map --- NEW FILE: boot.f --- load: data/root.f zardoz |
From: Elias P. <el...@us...> - 2004-07-31 21:01:40
|
Update of /cvsroot/squidfighter/deathfist/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22706/data Log Message: Directory /cvsroot/squidfighter/deathfist/data added to the repository |
From: Paul P. <ppr...@us...> - 2004-07-31 20:43:09
|
Update of /cvsroot/squidfighter/deathfist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19864 Modified Files: map.c tileset.c world.c Log Message: - tweaks Index: world.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/world.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** world.c 29 Jul 2004 06:22:42 -0000 1.8 --- world.c 31 Jul 2004 20:43:00 -0000 1.9 *************** *** 86,90 **** ! static void word_view(FSYSTEM *sys) { state_switch(&world_view); --- 86,90 ---- ! static void word_edit(FSYSTEM *sys) { state_switch(&world_view); *************** *** 103,106 **** fs_register_func(sys, "stat", word_stat, FS_DEFAULT); */ ! fs_register_func(sys, "view", word_view, FS_DEFAULT); } --- 103,106 ---- fs_register_func(sys, "stat", word_stat, FS_DEFAULT); */ ! fs_register_func(sys, "edit", word_edit, FS_DEFAULT); } Index: tileset.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/tileset.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** tileset.c 29 Jul 2004 06:22:42 -0000 1.10 --- tileset.c 31 Jul 2004 20:43:00 -0000 1.11 *************** *** 304,307 **** --- 304,308 ---- fs_register_func(sys, "stat", word_stat, FS_DEFAULT); fs_register_func(sys, "view", word_view, FS_DEFAULT); + fs_register_func(sys, "edit", word_view, FS_DEFAULT); } Index: map.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/map.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** map.c 31 Jul 2004 15:19:04 -0000 1.13 --- map.c 31 Jul 2004 20:43:00 -0000 1.14 *************** *** 514,518 **** ! static void word_view(FSYSTEM *sys) { CHECK_MAP(); --- 514,518 ---- ! static void word_edit(FSYSTEM *sys) { CHECK_MAP(); *************** *** 617,621 **** forth_do(me, "map definitions"); ! fs_register_func(sys, "view", word_view, FS_DEFAULT); fs_register_func(sys, "define", word_define, FS_DEFAULT); fs_register_func(sys, "size", word_size, FS_DEFAULT); --- 617,621 ---- forth_do(me, "map definitions"); ! fs_register_func(sys, "edit", word_edit, FS_DEFAULT); fs_register_func(sys, "define", word_define, FS_DEFAULT); fs_register_func(sys, "size", word_size, FS_DEFAULT); |
From: Paul P. <ppr...@us...> - 2004-07-31 15:19:13
|
Update of /cvsroot/squidfighter/deathfist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5948 Modified Files: edit_state.c main_forth.c map.c map.h Log Message: - map resizing, with forth words Index: main_forth.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/main_forth.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** main_forth.c 29 Jul 2004 06:22:42 -0000 1.7 --- main_forth.c 31 Jul 2004 15:19:04 -0000 1.8 *************** *** 712,717 **** static void word_len(FSYSTEM *sys) { ! fs_push_int(sys, fs_strlen(sys, -1, NULL)); fs_pop(sys); } --- 712,720 ---- static void word_len(FSYSTEM *sys) { ! int len; ! ! len=fs_strlen(sys, -1, NULL); fs_pop(sys); + fs_push_int(sys, len); } *************** *** 856,864 **** fs_register_func(sys, "immediate", word_immediate, FS_DEFAULT); fs_register_func(sys, "'forget", word_xtforget, FS_DEFAULT); ! fs_register_func(sys, "cat$", word_cat, FS_DEFAULT); ! fs_register_func(sys, "len$", word_len, FS_DEFAULT); ! fs_register_func(sys, "right$", word_right, FS_DEFAULT); ! fs_register_func(sys, "left$", word_left, FS_DEFAULT); ! fs_register_func(sys, "mid$", word_mid, FS_DEFAULT); fs_register_func(sys, "$create", word_strcreate, FS_DEFAULT); --- 859,867 ---- fs_register_func(sys, "immediate", word_immediate, FS_DEFAULT); fs_register_func(sys, "'forget", word_xtforget, FS_DEFAULT); ! fs_register_func(sys, "$cat", word_cat, FS_DEFAULT); ! fs_register_func(sys, "$len", word_len, FS_DEFAULT); ! fs_register_func(sys, "$right", word_right, FS_DEFAULT); ! fs_register_func(sys, "$left", word_left, FS_DEFAULT); ! fs_register_func(sys, "$mid", word_mid, FS_DEFAULT); fs_register_func(sys, "$create", word_strcreate, FS_DEFAULT); *************** *** 869,873 **** --- 872,878 ---- world_forth_init(&root); tileset_forth_init(&root); + map_forth_init(&root); + // Protect the dictionary by attatching and exiting forth_init(me, 32, 32); fs_voc_new(FSYS(me), 8); Index: edit_state.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/edit_state.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** edit_state.c 29 Jul 2004 06:22:42 -0000 1.19 --- edit_state.c 31 Jul 2004 15:19:04 -0000 1.20 *************** *** 232,251 **** MAP *map=view->map; ! if(util_key(KEY_LEFT, FALSE)&&cursor_x>TILE_SIZE>>1) ! { cursor_x-=CURSOR_SPEED; ! } ! if(util_key(KEY_RIGHT, FALSE)&&cursor_x<map->w*map->room_w-(TILE_SIZE>>1)) ! { cursor_x+=CURSOR_SPEED; ! } ! if(util_key(KEY_UP, FALSE)&&cursor_y>TILE_SIZE>>1) ! { cursor_y-=CURSOR_SPEED; ! } ! if(util_key(KEY_DOWN, FALSE)&&cursor_y<map->h*map->room_h-(TILE_SIZE>>1)) ! { cursor_y+=CURSOR_SPEED; ! } /* Handle mouse clicks in there. */ --- 232,260 ---- MAP *map=view->map; ! // Movement ! if(util_key(KEY_LEFT, FALSE)) cursor_x-=CURSOR_SPEED; ! ! if(util_key(KEY_RIGHT, FALSE)) cursor_x+=CURSOR_SPEED; ! ! if(util_key(KEY_UP, FALSE)) cursor_y-=CURSOR_SPEED; ! ! if(util_key(KEY_DOWN, FALSE)) cursor_y+=CURSOR_SPEED; ! ! // Bounds checking ! if(cursor_x<TILE_SIZE>>1) ! cursor_x=TILE_SIZE>>1; ! ! if(cursor_x>map->w*map->room_w-(TILE_SIZE>>1)) ! cursor_x=map->w*map->room_w-(TILE_SIZE>>1); ! ! if(cursor_y<TILE_SIZE>>1) ! cursor_y=TILE_SIZE>>1; ! ! if(cursor_y>map->h*map->room_h-(TILE_SIZE>>1)) ! cursor_y=map->h*map->room_h-(TILE_SIZE>>1); /* Handle mouse clicks in there. */ Index: map.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/map.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** map.h 19 Jul 2004 18:30:36 -0000 1.9 --- map.h 31 Jul 2004 15:19:04 -0000 1.10 *************** *** 82,84 **** --- 82,86 ---- int map_load(MAP *me, PACKFILE *file); + void map_forth_init(FORTH *sys); + #endif Index: map.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/map.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** map.c 29 Jul 2004 06:22:42 -0000 1.12 --- map.c 31 Jul 2004 15:19:04 -0000 1.13 *************** *** 19,22 **** --- 19,24 ---- #include "tile.h" + #define CHECK_MAP() {if(!map_current){fs_throw(sys, FS_NULL);}} + /* Map from pixel coordinates to room and tile coordinates. */ void map_to_room_tile(MAP *me, int map_x, int map_y, int *room_x, int *room_y, *************** *** 61,64 **** --- 63,67 ---- } + MAP *map_create(int w, int h) { *************** *** 103,110 **** --- 106,115 ---- for(x=0; x<w; x++) + { for(y=0; y<h; y++) { me->room[x][y]=NULL; } + } me->w=w; *************** *** 114,117 **** --- 119,123 ---- } + MAP *map_create_with_rooms(int w, int h) { *************** *** 145,148 **** --- 151,250 ---- + static int map_realloc(MAP *me, int w, int h) + { + int x, y; + + if(!me) + return FALSE; + + if(!w||!h) + return FALSE; + + me->room = realloc(me->room, sizeof(ROOM*) * w); + + for(x = 0; x < w; x++) + { + if(x<me->w) + { + // Resize existing columns + me->room[x] = realloc(me->room[x], sizeof (ROOM*) * h); + } + else + { + // Create new columns + me->room[x] = malloc(sizeof(ROOM*) * h); + } + + for(y = me->h-1; y < h; y++) + { + me->room[x][y] = NULL; + } + } + + for(x=me->w; x<w; x++) + { + for(y = 0; y < h; y++) + { + me->room[x][y] = NULL; + } + } + + me->w = w; + me->h = h; + + return TRUE; + } + + + static int map_resize(MAP *me, int w, int h) + { + int x, y; + int change_w, change_h; + + if(!me) + return FALSE; + + // How much each map shrinks + change_w=me->w-w; + change_h=me->h-h; + + if(!change_w&&!change_h) + return FALSE; + + // Destroy columns + for(x=0; x<change_w; x++) + { + for(y=0; y<me->h; y++) + { + map_destroy_room(me, x+me->w-1, y); + } + } + + // Destroy rows + for(y=0; y<change_h; y++) + { + for(x=0; x<me->w; x++) + { + map_destroy_room(me, x, y+me->h-1); + } + } + + change_w=-change_w; + change_h=-change_h; + + // If map hasn't grown + if(change_w<=0&&change_h<=0) + { + me->w=w; + me->h=h; + return TRUE; + } + + map_realloc(me, me->w+change_w, me->h+change_h); + + return TRUE; + } + + int map_is_room(MAP *me, int x, int y) { *************** *** 247,251 **** ! void map_add_parallax_layer (MAP *me, PARALLAX *layer) { int i = me->parallax_count++; --- 349,353 ---- ! void map_add_parallax_layer(MAP *me, PARALLAX *layer) { int i = me->parallax_count++; *************** *** 255,258 **** --- 357,361 ---- } + /* The layer is removed from the map, but not destroyed. */ void map_remove_parallax_layer (MAP *me, PARALLAX *layer) *************** *** 276,280 **** } ! /* The worls script or something like that will create the map. * This function only fills in rooms. Rooms not in the map * are not touched, set them to NULL before yourself. --- 379,383 ---- } ! /* The world script or something like that will create the map. * This function only fills in rooms. Rooms not in the map * are not touched, set them to NULL before yourself. *************** *** 411,414 **** --- 514,631 ---- + static void word_view(FSYSTEM *sys) + { + CHECK_MAP(); + + state_switch(&editor); + } + + + /* + define ( "name" -- ) + - creates or redefines a tileset + */ + static void word_define(FSYSTEM *sys) + { + char *str; + + str=fs_get_string(sys, -1); + fs_pop(sys); + + map_current=world_get_map(world, str); + + if(!map_current) + { + map_current=map_create(1, 1); + world_add_map(world, map_current, str); + } + } + + + static void word_x(FSYSTEM *sys) + { + CHECK_MAP(); + + map_current->x=fs_get_int(sys, -1); + fs_pop(sys); + } + + + static void word_y(FSYSTEM *sys) + { + CHECK_MAP(); + + map_current->y=fs_get_int(sys, -1); + fs_pop(sys); + } + + + static void word_pos(FSYSTEM *sys) + { + CHECK_MAP(); + + map_current->x=fs_get_int(sys, -2); + map_current->y=fs_get_int(sys, -1); + fs_remove(sys, 2); + } + + + static void word_w(FSYSTEM *sys) + { + int w; + CHECK_MAP(); + + w=fs_get_int(sys, -1); + + fs_pop(sys); + + map_resize(map_current, w, map_current->h); + } + + + static void word_h(FSYSTEM *sys) + { + int h; + CHECK_MAP(); + + h=fs_get_int(sys, -1); + + fs_pop(sys); + + map_resize(map_current, map_current->w, h); + } + + + static void word_size(FSYSTEM *sys) + { + int w, h; + CHECK_MAP(); + + h=fs_get_int(sys, -1); + w=fs_get_int(sys, -2); + + fs_remove(sys, 2); + + map_resize(map_current, w, h); + } + + + void map_forth_init(FORTH *me) + { + FSYSTEM *sys=(FSYSTEM*)me; + + forth_do(me, "map definitions"); + + fs_register_func(sys, "view", word_view, FS_DEFAULT); + fs_register_func(sys, "define", word_define, FS_DEFAULT); + fs_register_func(sys, "size", word_size, FS_DEFAULT); + fs_register_func(sys, "x", word_x, FS_DEFAULT); + fs_register_func(sys, "y", word_y, FS_DEFAULT); + fs_register_func(sys, "pos", word_pos, FS_DEFAULT); + fs_register_func(sys, "w", word_w, FS_DEFAULT); + fs_register_func(sys, "h", word_h, FS_DEFAULT); + } + + static void destroy(void *data) { |
From: Paul P. <ppr...@us...> - 2004-07-29 06:23:07
|
Update of /cvsroot/squidfighter/deathfist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7305 Modified Files: Deathfist.dsp adventure.c data.c data.h edit_state.c main.c main_forth.c map.c tileset.c tileset.h widget_layer.c widget_tile.c widget_tiles.c widget_tileset.c world.c world.h world_view_state.c Log Message: - renamed/refactored some stuff - finally added most of the tileset words Index: world.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/world.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** world.h 22 Jul 2004 15:25:48 -0000 1.7 --- world.h 29 Jul 2004 06:22:42 -0000 1.8 *************** *** 7,10 **** --- 7,11 ---- #include "list.h" #include "tileset.h" + #include "forth.h" #define WORLD_TILE_SIZE 8 *************** *** 25,29 **** --- 26,34 ---- NODE *world_add_tileset(WORLD *me, TILE_SET *tileset, char const *name); + TILE_SET *world_get_tileset(WORLD *me, char const *name); void world_destroy_tileset(WORLD *me, char const *name); + void world_forth_init(FORTH *me); + + #endif Index: Deathfist.dsp =================================================================== RCS file: /cvsroot/squidfighter/deathfist/Deathfist.dsp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Deathfist.dsp 24 Jul 2004 07:46:16 -0000 1.9 --- Deathfist.dsp 29 Jul 2004 06:22:42 -0000 1.10 *************** *** 44,48 **** # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c ! # ADD CPP /nologo /W3 /GX /O2 /I "../forthy" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 --- 44,48 ---- # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c ! # ADD CPP /nologo /MD /W3 /GX /O2 /I "../forthy" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "ALLEGRO_STATICLINK" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 *************** *** 153,156 **** --- 153,160 ---- # Begin Source File + SOURCE=.\sprite_load.c + # End Source File + # Begin Source File + SOURCE=.\state.c # End Source File *************** *** 265,268 **** --- 269,276 ---- # Begin Source File + SOURCE=.\sprite_load.h + # End Source File + # Begin Source File + SOURCE=.\state.h # End Source File Index: adventure.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/adventure.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** adventure.c 27 Jul 2004 18:39:32 -0000 1.18 --- adventure.c 29 Jul 2004 06:22:42 -0000 1.19 *************** *** 92,96 **** int x, y; int i, j; ! testset = tileset_create (); for (i = 0; i < TILE_TEMPLATE_SIZE; i++) testset->id[i].tile_type = i; --- 92,98 ---- int x, y; int i, j; ! ! testset = tileset_create(NULL); ! for (i = 0; i < TILE_TEMPLATE_SIZE; i++) testset->id[i].tile_type = i; *************** *** 98,101 **** --- 100,104 ---- testmap->tileset = testset; x = 0; + for (i = 0; i < ROOM_TILES_W * 2; i++) { Index: tileset.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/tileset.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tileset.h 28 Jul 2004 05:17:16 -0000 1.8 --- tileset.h 29 Jul 2004 06:22:42 -0000 1.9 *************** *** 24,28 **** char data_value; int flags; ! char *info; BITMAP *image; --- 24,28 ---- char data_value; int flags; ! char *text; BITMAP *image; *************** *** 37,40 **** --- 37,41 ---- { int count; + char *imagename; TILE_TEMPLATE id[TILE_TEMPLATE_SIZE]; }TILE_SET; *************** *** 42,51 **** extern LIST_INTERFACE tileset_list_interface; - TILE_SET *tileset_create(void); void tileset_destroy(TILE_SET *me); ! TILE_SET *tileset_create_from_bitmap(BITMAP *bmp); ! int tileset_load(char *filename, TILE_SET *set); ! void tileset_forth_register(FORTH *me); #endif --- 43,50 ---- extern LIST_INTERFACE tileset_list_interface; void tileset_destroy(TILE_SET *me); ! TILE_SET *tileset_create(BITMAP *bmp); ! void tileset_forth_init(FORTH *me); #endif Index: widget_layer.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/widget_layer.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** widget_layer.c 23 Jul 2004 15:37:22 -0000 1.1 --- widget_layer.c 29 Jul 2004 06:22:42 -0000 1.2 *************** *** 24,28 **** { int layer = i == 0 ? tile->bg : i == 1 ? tile->id : tile->fg; ! entry = map_get_tile_template (current_map, layer); if (i == active_layer) --- 24,28 ---- { int layer = i == 0 ? tile->bg : i == 1 ? tile->id : tile->fg; ! entry = map_get_tile_template (map_current, layer); if (i == active_layer) Index: main_forth.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/main_forth.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** main_forth.c 28 Jul 2004 05:17:16 -0000 1.6 --- main_forth.c 29 Jul 2004 06:22:42 -0000 1.7 *************** *** 867,871 **** // Register other forth modules ! tileset_forth_register(&root); forth_init(me, 32, 32); --- 867,872 ---- // Register other forth modules ! world_forth_init(&root); ! tileset_forth_init(&root); forth_init(me, 32, 32); Index: edit_state.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/edit_state.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** edit_state.c 27 Jul 2004 18:56:36 -0000 1.18 --- edit_state.c 29 Jul 2004 06:22:42 -0000 1.19 *************** *** 43,47 **** for (j = 0; j < BRUSH_H; j++) { ! brush[i][j] = *map_get_tile(current_map, x, y); y += TILE_SIZE; } --- 43,47 ---- for (j = 0; j < BRUSH_H; j++) { ! brush[i][j] = *map_get_tile(map_current, x, y); y += TILE_SIZE; } *************** *** 63,72 **** for (j = 0; j < BRUSH_H; j++) { ! TILE *t = map_get_tile(current_map, x, y); TILE tile; if (!t) { ! map_create_room(current_map, x, y); ! t = map_get_tile(current_map, x, y); } tile = *t; --- 63,72 ---- for (j = 0; j < BRUSH_H; j++) { ! TILE *t = map_get_tile(map_current, x, y); TILE tile; if (!t) { ! map_create_room(map_current, x, y); ! t = map_get_tile(map_current, x, y); } tile = *t; *************** *** 77,81 **** if (brush[i][j].bg) tile.id = brush[i][j].bg; ! *map_get_tile(current_map, x, y) = tile; y += TILE_SIZE; } --- 77,81 ---- if (brush[i][j].bg) tile.id = brush[i][j].bg; ! *map_get_tile(map_current, x, y) = tile; y += TILE_SIZE; } *************** *** 120,124 **** MAP *edit_get_map(void) { ! return current_map; } --- 120,124 ---- MAP *edit_get_map(void) { ! return map_current; } *************** *** 128,135 **** TILE_SET *tileset = NULL; ! if (parallax_editing && current_parallax) ! tileset = current_parallax->tileset; else ! tileset = current_map->tileset; if (!tileset) --- 128,135 ---- TILE_SET *tileset = NULL; ! if (parallax_editing && parallax_current) ! tileset = parallax_current->tileset; else ! tileset = map_current->tileset; if (!tileset) *************** *** 217,221 **** int th = text_height (font); textprintf_centre(back_buffer, font, SCREEN_W/2, 16 + th, SYS_RED, ! "%i parallax layers", current_map->parallax_count); } --- 217,221 ---- int th = text_height (font); textprintf_centre(back_buffer, font, SCREEN_W/2, 16 + th, SYS_RED, ! "%i parallax layers", map_current->parallax_count); } *************** *** 280,284 **** static void leave(void) { ! last_map=current_map; view_destroy(view); } --- 280,284 ---- static void leave(void) { ! last_map=map_current; view_destroy(view); } *************** *** 306,318 **** if (parallax_editing) { ! if (!current_parallax) { // TODO: This should be done by console commands! ! current_parallax = parallax_create( ! current_map->w * ROOM_TILES_W, ! current_map->h * ROOM_TILES_H); ! map_add_parallax_layer (current_map, current_parallax); } ! tile = parallax_tile(current_parallax, map_x / TILE_SIZE, map_y / TILE_SIZE); } --- 306,318 ---- if (parallax_editing) { ! if (!parallax_current) { // TODO: This should be done by console commands! ! parallax_current = parallax_create( ! map_current->w * ROOM_TILES_W, ! map_current->h * ROOM_TILES_H); ! map_add_parallax_layer (map_current, parallax_current); } ! tile = parallax_tile(parallax_current, map_x / TILE_SIZE, map_y / TILE_SIZE); } *************** *** 381,387 **** static int enter(void) { ! view = view_create(current_map, 0, 0, SCREEN_W, SCREEN_H); ! if(last_map!=current_map) { cursor_x=TILE_SIZE>>1; --- 381,387 ---- static int enter(void) { ! view = view_create(map_current, 0, 0, SCREEN_W, SCREEN_H); ! if(last_map!=map_current) { cursor_x=TILE_SIZE>>1; Index: tileset.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/tileset.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** tileset.c 28 Jul 2004 05:17:16 -0000 1.9 --- tileset.c 29 Jul 2004 06:22:42 -0000 1.10 *************** *** 21,55 **** #include "map.h" #include "list.h" #include "tileset.h" #define TILE_TYPE(type) tileset->id[entry].tile_type=(type) #define DATA_TYPE(type) tileset->id[entry].data_type=(type) ! static int entry; ! ! TILE_SET *tileset_create(void) ! { ! TILE_SET *me = calloc (1, sizeof *me); ! return me; ! } void tileset_destroy(TILE_SET *me) { ! free (me); } ! TILE_SET *tileset_create_from_bitmap(BITMAP *bmp) { ! TILE_SET *me = tileset_create (); ! int x, y; ! if (bmp) { for (y = 0; y < bmp->h; y += TILE_SIZE) { for (x = 0; x < bmp->w; x += TILE_SIZE) { me->id[1 + me->count].image = create_bitmap (TILE_SIZE, TILE_SIZE); blit (bmp, me->id[1 + me->count].image, x, y, 0, 0, TILE_SIZE, TILE_SIZE); --- 21,84 ---- #include "map.h" #include "list.h" + #include "game_states.h" #include "tileset.h" + #define TILE_TYPE(type) tileset->id[entry].tile_type=(type) #define DATA_TYPE(type) tileset->id[entry].data_type=(type) ! // Currently selected tileset ! static TILE_SET *tileset=NULL; ! static NODE *node=NULL; ! static int entry=0; ! #define CHECK_TILESET() {if(!tileset){fs_throw(sys, FS_NULL);}} void tileset_destroy(TILE_SET *me) { ! int i; ! ! for (i = 0; i < me->count; i++) ! { ! destroy_bitmap(me->id[i].image); ! if(me->id[i].text) ! free(me->id[i].text); ! } ! ! if(me->imagename) ! free(me->imagename); ! ! free(me); } ! int tileset_set_image(TILE_SET *me, BITMAP *bmp, char const *name) { ! int i, x, y; ! ! if(!me) ! return FALSE; ! ! for(i=0; i<me->count; i++) ! { ! if(me->id[i].image) ! destroy_bitmap(me->id[i].image); ! ! me->id[i].image=NULL; ! } ! ! if(bmp) { + // does the image divide evenly into tiles? + if(bmp->w%TILE_SIZE||bmp->h%TILE_SIZE) + return FALSE; + for (y = 0; y < bmp->h; y += TILE_SIZE) { for (x = 0; x < bmp->w; x += TILE_SIZE) { + BITMAP *image=me->id[1 + me->count].image; + me->id[1 + me->count].image = create_bitmap (TILE_SIZE, TILE_SIZE); blit (bmp, me->id[1 + me->count].image, x, y, 0, 0, TILE_SIZE, TILE_SIZE); *************** *** 58,79 **** } } ! return me; } ! static void destroy(void *data) { } ! // Currently selected tileset ! static TILE_SET *tileset=NULL; ! static LIST *tileset_list=NULL; /* ! create ( "name" -- ) */ ! static void word_create(FSYSTEM *sys) { char *str; --- 87,124 ---- } } ! ! if(me->imagename) ! free(tileset->imagename); ! ! me->imagename=strdup(name); ! ! return TRUE; } ! TILE_SET *tileset_create(BITMAP *bmp) { + TILE_SET *me=calloc (1, sizeof *me); + + if(me) + { + tileset_set_image(me, bmp, NULL); + } + return me; } ! static void destroy(void *data) ! { ! tileset_destroy((TILE_SET*)data); ! } ! /* ! define ( "name" -- ) ! - creates or redefines a tileset */ ! static void word_define(FSYSTEM *sys) { char *str; *************** *** 81,97 **** str=fs_get_string(sys, -1); fs_pop(sys); } - //static LIST *tileset_list; /* ! sheet ( "filename" -- ) */ ! static void word_sheet(FSYSTEM *sys) { char *str; ! str=fs_get_string(sys, -1); fs_pop(sys); } --- 126,163 ---- str=fs_get_string(sys, -1); fs_pop(sys); + + tileset=world_get_tileset(world, str); + + if(!tileset) + { + tileset=tileset_create(NULL); + world_add_tileset(world, tileset, str); + } } /* ! image ( "filename" -- ) */ ! static void word_image(FSYSTEM *sys) { char *str; ! BITMAP *bmp; ! ! CHECK_TILESET(); ! str=fs_get_string(sys, -1); fs_pop(sys); + + bmp=load_bitmap(str, NULL); + + if(!bmp) + { + fs_throw(sys, FS_ERROR); + } + + tileset_set_image(tileset, bmp, str); + + destroy_bitmap(bmp); } *************** *** 102,112 **** static void word_tile(FSYSTEM *sys) { entry=(char)fs_get_int(sys, -1); fs_pop(sys); } ! static void word_tilenext(FSYSTEM *sys) { } --- 168,195 ---- static void word_tile(FSYSTEM *sys) { + CHECK_TILESET(); entry=(char)fs_get_int(sys, -1); fs_pop(sys); + + if(!(0>=entry<tileset->count)) + { + fs_throw(sys, FS_OUT_OF_BOUNDS); + } } ! /* ! ( -- ) ! */ ! static void word_tile_next(FSYSTEM *sys) { + CHECK_TILESET(); + + entry++; + + if(entry>=tileset->count) + { + fs_throw(sys, FS_OUT_OF_BOUNDS); + } } *************** *** 115,122 **** ( string -- ) */ ! static void word_info(FSYSTEM *sys) { ! fs_get_string(sys, -1); fs_pop(sys); } --- 198,213 ---- ( string -- ) */ ! static void word_text(FSYSTEM *sys) { ! char *str; ! CHECK_TILESET(); ! ! str=fs_get_string(sys, -1); fs_pop(sys); + + if(tileset->id[entry].text) + free(tileset->id[entry].text); + + tileset->id[entry].text=strdup(str); } *************** *** 129,132 **** --- 220,224 ---- static void word_ladder(FSYSTEM *sys) { + CHECK_TILESET(); TILE_TYPE(TILE_LADDER); } *************** *** 138,141 **** --- 230,234 ---- static void word_solid(FSYSTEM *sys) { + CHECK_TILESET(); TILE_TYPE(TILE_SOLID); } *************** *** 149,152 **** --- 242,246 ---- static void word_breakable(FSYSTEM *sys) { + CHECK_TILESET(); DATA_TYPE(TILE_DATA_BREAKABLE); } *************** *** 158,161 **** --- 252,257 ---- static void word_data(FSYSTEM *sys) { + CHECK_TILESET(); + tileset->id[entry].data_value=(char)fs_get_int(sys, -1); fs_pop(sys); *************** *** 163,194 **** ! void tileset_forth_register(FORTH *me) { ! FSYSTEM *sys=(FSYSTEM*)me; ! ! forth_do(me, "vocabulary tileset tileset definitions"); - fs_register_func(sys, "create", word_create, FS_DEFAULT); - fs_register_func(sys, "sheet ", word_sheet, FS_DEFAULT); - fs_register_func(sys, "tile", word_tile, FS_DEFAULT); - fs_register_func(sys, "info", word_info, FS_DEFAULT); - fs_register_func(sys, "ladder", word_ladder, FS_DEFAULT); - fs_register_func(sys, "solid", word_solid, FS_DEFAULT); - fs_register_func(sys, "barrier", word_breakable, FS_DEFAULT); } /* ! int tileset_init() { ! return TRUE; } ! void tileset_exit() { ! } ! */ LIST_INTERFACE tileset_list_interface= --- 259,309 ---- ! /* ! stat ( -- ) ! - TODO: print out status of the selected tileset ! - tileset name ! - image name ! - list all tile ID, text, type, data type, data value ! */ ! static void word_stat(FSYSTEM *sys) { ! CHECK_TILESET(); } /* ! view ( -- ) ! - views the tileset state ! */ ! static void word_view(FSYSTEM *sys) { ! if(!map_current) ! { ! fs_throw(sys, FS_NULL); ! } ! ! state_switch(&tile_select); } ! void tileset_forth_init(FORTH *me) { ! FSYSTEM *sys=(FSYSTEM*)me; ! ! forth_do(me, "tileset definitions"); ! ! fs_register_func(sys, "define", word_define, FS_DEFAULT); ! fs_register_func(sys, "image", word_image, FS_DEFAULT); ! fs_register_func(sys, "tile", word_tile, FS_DEFAULT); ! fs_register_func(sys, "tile,", word_tile_next, FS_DEFAULT); ! fs_register_func(sys, "text", word_text, FS_DEFAULT); ! fs_register_func(sys, "ladder", word_ladder, FS_DEFAULT); ! fs_register_func(sys, "solid", word_solid, FS_DEFAULT); ! fs_register_func(sys, "barrier", word_breakable, FS_DEFAULT); ! fs_register_func(sys, "stat", word_stat, FS_DEFAULT); ! fs_register_func(sys, "view", word_view, FS_DEFAULT); } ! LIST_INTERFACE tileset_list_interface= Index: data.h =================================================================== RCS file: /cvsroot/squidfighter/deathfist/data.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** data.h 27 Jul 2004 18:39:32 -0000 1.3 --- data.h 29 Jul 2004 06:22:42 -0000 1.4 *************** *** 7,12 **** /* Shared by all states. */ extern WORLD *world; ! extern MAP *current_map; ! extern PARALLAX *current_parallax; int data_init(void); --- 7,12 ---- /* Shared by all states. */ extern WORLD *world; ! extern MAP *map_current; ! extern PARALLAX *parallax_current; int data_init(void); Index: world_view_state.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/world_view_state.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** world_view_state.c 27 Jul 2004 18:39:32 -0000 1.16 --- world_view_state.c 29 Jul 2004 06:22:42 -0000 1.17 *************** *** 4,9 **** #include "game_states.h" ! MAP *current_map = NULL; ! PARALLAX *current_parallax = NULL; enum {CURSOR_NORMAL, CURSOR_DRAG}; --- 4,9 ---- #include "game_states.h" ! MAP *map_current = NULL; ! PARALLAX *parallax_current = NULL; enum {CURSOR_NORMAL, CURSOR_DRAG}; *************** *** 27,31 **** (void) data; ! if (map == current_map) { c1 = SYS_RED; --- 27,31 ---- (void) data; ! if (map == map_current) { c1 = SYS_RED; *************** *** 65,69 **** { char ch; ! MAP *map = current_map; int leftmouse; /* mouse_* vars are asynchronous. So read them all at once. */ --- 65,69 ---- { char ch; ! MAP *map = map_current; int leftmouse; /* mouse_* vars are asynchronous. So read them all at once. */ *************** *** 101,105 **** case ' ': case 'e': ! if(current_map) state_switch(&editor); return; --- 101,105 ---- case ' ': case 'e': ! if(map_current) state_switch(&editor); return; *************** *** 113,123 **** room_count++; mapnode = world_add_map (world, map, name); ! current_map = mapnode->data; break; } case 'd': // TODO: DEL key { ! world_destroy_map (world, current_map); ! current_map = NULL; break; } --- 113,123 ---- room_count++; mapnode = world_add_map (world, map, name); ! map_current = mapnode->data; break; } case 'd': // TODO: DEL key { ! world_destroy_map (world, map_current); ! map_current = NULL; break; } *************** *** 129,133 **** NODE *mapnode = world_get_map_xy (world, mx, my); if (mapnode) ! map = current_map = mapnode->data; if (leftmouse == MOUSE_CLICKED) --- 129,133 ---- NODE *mapnode = world_get_map_xy (world, mx, my); if (mapnode) ! map = map_current = mapnode->data; if (leftmouse == MOUSE_CLICKED) *************** *** 138,142 **** drag_x = mx - map->x; drag_y = my - map->y; ! current_map = map; } } --- 138,142 ---- drag_x = mx - map->x; drag_y = my - map->y; ! map_current = map; } } *************** *** 145,149 **** if (map) { ! current_map = map; state_switch(&editor); return; --- 145,149 ---- if (map) { ! map_current = map; state_switch(&editor); return; *************** *** 171,197 **** static int enter(void) { - if (!world) - { - BITMAP *tileset1_bmp; - BITMAP *tileset2_bmp; - set_color_conversion (COLORCONV_TOTAL | COLORCONV_KEEP_TRANS); - - tileset1_bmp = load_bitmap ("tileset1.bmp", NULL); - tileset2_bmp = load_bitmap ("tileset2.bmp", NULL); - - world = world_create(); - - world_add_tileset (world, tileset_create_from_bitmap (tileset1_bmp), "jungle"); - world_add_tileset (world, tileset_create_from_bitmap (tileset2_bmp), "sky back"); - world_add_tileset (world, tileset_create (), "cave"); - world_add_tileset (world, tileset_create (), "water"); - world_add_tileset (world, tileset_create (), "jungle back"); - world_add_tileset (world, tileset_create (), "desert back"); - world_add_tileset (world, tileset_create (), "misc"); - world_add_tileset (world, tileset_create (), "special"); - world_add_tileset (world, tileset_create (), "whatever"); - - } - return TRUE; } --- 171,174 ---- Index: widget_tileset.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/widget_tileset.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** widget_tileset.c 27 Jul 2004 18:56:36 -0000 1.3 --- widget_tileset.c 29 Jul 2004 06:22:42 -0000 1.4 *************** *** 18,22 **** int th = text_height (font); ! if (node->data == current_map->tileset) rectfill (back_buffer, wd->draw_x, wd->draw_y, wd->draw_x + tw, wd->draw_y + th, c2); --- 18,22 ---- int th = text_height (font); ! if (node->data == map_current->tileset) rectfill (back_buffer, wd->draw_x, wd->draw_y, wd->draw_x + tw, wd->draw_y + th, c2); *************** *** 55,63 **** if (parallax_editing) { ! if (current_parallax) ! current_parallax->tileset = node->data; } else ! current_map->tileset = node->data; } } --- 55,63 ---- if (parallax_editing) { ! if (parallax_current) ! parallax_current->tileset = node->data; } else ! map_current->tileset = node->data; } } Index: widget_tiles.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/widget_tiles.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** widget_tiles.c 23 Jul 2004 15:56:08 -0000 1.5 --- widget_tiles.c 29 Jul 2004 06:22:42 -0000 1.6 *************** *** 38,42 **** id = tile->fg; ! entry = map_get_tile_template (current_map, i); if (tile && id == i) --- 38,42 ---- id = tile->fg; ! entry = map_get_tile_template (map_current, i); if (tile && id == i) Index: data.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/data.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** data.c 19 Jul 2004 18:30:36 -0000 1.2 --- data.c 29 Jul 2004 06:22:42 -0000 1.3 *************** *** 10,13 **** --- 10,14 ---- int data_init() { + world = world_create(); return TRUE; } *************** *** 16,18 **** --- 17,20 ---- void data_exit() { + world_destroy(world); } Index: widget_tile.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/widget_tile.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** widget_tile.c 23 Jul 2004 15:56:08 -0000 1.2 --- widget_tile.c 29 Jul 2004 06:22:42 -0000 1.3 *************** *** 22,26 **** widget_border (me); ! entry = map_get_tile_template(current_map, id); x = me->l + 3; --- 22,26 ---- widget_border (me); ! entry = map_get_tile_template(map_current, id); x = me->l + 3; Index: main.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/main.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** main.c 27 Jul 2004 04:54:18 -0000 1.9 --- main.c 29 Jul 2004 06:22:42 -0000 1.10 *************** *** 57,60 **** --- 57,62 ---- } + set_color_conversion (COLORCONV_TOTAL | COLORCONV_KEEP_TRANS); + is_video_buffer=try_video_create(); *************** *** 86,89 **** --- 88,93 ---- main_forth_init(forth); + data_init(); + main_exeunt=FALSE; *************** *** 129,132 **** --- 133,137 ---- { console_end(); + data_exit(); main_forth_exit(forth); Index: world.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/world.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** world.c 22 Jul 2004 15:25:48 -0000 1.7 --- world.c 29 Jul 2004 06:22:42 -0000 1.8 *************** *** 2,5 **** --- 2,6 ---- #include "world.h" + WORLD *world_create (void) { *************** *** 10,13 **** --- 11,15 ---- } + void world_destroy (WORLD *me) { *************** *** 16,19 **** --- 18,22 ---- } + NODE *world_add_map(WORLD *me, MAP *map, char const *name) { *************** *** 21,24 **** --- 24,28 ---- } + MAP *world_get_map(WORLD *me, char const *name) { *************** *** 26,29 **** --- 30,40 ---- } + + TILE_SET *world_get_tileset(WORLD *me, char const *name) + { + return list_find(me->tilesets, name); + } + + /* Helper callback for world_get_map_xy. */ static int check_map_xy (NODE *node, void *data) *************** *** 46,50 **** } ! void world_destroy_map (WORLD *me, MAP *map) { // TOOD: using a named list with the name only in --- 57,61 ---- } ! void world_destroy_map(WORLD *me, MAP *map) { // TOOD: using a named list with the name only in *************** *** 73,74 **** --- 84,106 ---- list_destroy_node (me->tilesets, name); } + + + static void word_view(FSYSTEM *sys) + { + state_switch(&world_view); + } + + + void world_forth_init(FORTH *me) + { + FSYSTEM *sys=(FSYSTEM*)me; + + forth_do(me, "world definitions"); + + /* + fs_register_func(sys, "add", word_add, FS_DEFAULT); + fs_register_func(sys, "delete", word_delete, FS_DEFAULT); + fs_register_func(sys, "stat", word_stat, FS_DEFAULT); + */ + fs_register_func(sys, "view", word_view, FS_DEFAULT); + } Index: map.c =================================================================== RCS file: /cvsroot/squidfighter/deathfist/map.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** map.c 26 Jul 2004 16:47:17 -0000 1.11 --- map.c 29 Jul 2004 06:22:42 -0000 1.12 *************** *** 383,416 **** - /* - int map_init() - { - int i; - - if(is_init) - return FALSE; - - memset(&map, 0, sizeof(MAP)); - - if(!tileset_load("data/tileset.fy", &me->tileset)) - { - // TODO: handle bad load - return FALSE; - } - - for(i=0; i<TILE_TEMPLATE_SIZE; i++) - { - if(i>=data_tiles.count) - break; - - me->tileset.id[i].image=data_tiles.list[i]; - } - - is_init=TRUE; - - return TRUE; - } - */ - void map_destroy(MAP *me) { --- 383,386 ---- |