Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MegaZeux 2.80b release.

  • Loading branch information...
commit 75617b7e04d7c3b0c8a6b0363b99ea4e6f6b78dc 1 parent f9d5114
@ajs1984 authored
View
14 COPYING.DOC
@@ -2,7 +2,8 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -279,7 +280,7 @@ POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
- How to Apply These Terms to Your New Programs
+ Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
@@ -291,7 +292,7 @@ convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
+ Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -305,15 +306,14 @@ the "copyright" line and a pointer to where the full notice is found.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
- Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
@@ -338,5 +338,3 @@ proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
-
-
View
2  Makefile
@@ -10,7 +10,7 @@ OBJS = main.o graphics.o window.o hexchar.o event.o \
PREFIX = /usr
-BIN = mzx280.exe
+BIN = mzx280b.exe
CC = gcc
CPP = g++
View
2  Makefile.linux
@@ -10,7 +10,7 @@ OBJS = main.o graphics.o window.o hexchar.o event.o \
PREFIX = /usr
-BIN = mzx280
+BIN = mzx280b
CC = gcc
CPP = g++
View
34 audio.cpp
@@ -24,6 +24,7 @@
#include <math.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/stat.h>
#include "audio.h"
@@ -70,8 +71,9 @@ void audio_callback(void *userdata, Uint8 *stream, int len)
{
// Reset position
audio.current_mod->mSoundFile.SetCurrentPos(0);
- // Zero out remainder bytes
- memset(audio.mod_buffer + read_len, 0, len - read_len);
+ // Read anew remaining bytes
+ ModPlug_Read(audio.current_mod, audio.mod_buffer + read_len,
+ len - read_len);
}
}
else
@@ -311,11 +313,7 @@ void play_sample(int freq, char *filename)
// FIXME - destroy least recently used?
if(audio.num_samples_playing >= MAX_SAMS)
- {
- // Out of samples, so destroy a random existing one.
- int r = rand() % 16;
- end_individual_sample(r);
- }
+ return;
if((extension_pos >= 0) && !strcasecmp(filename + extension_pos, ".sam"))
{
@@ -346,11 +344,32 @@ void play_sample(int freq, char *filename)
if(sample_loaded)
{
+ int sample_length = sample_loaded->mSoundFile.Ins[1].nLength;
+
// A little hack to modify the pitch
sample_loaded->mSoundFile.Ins[1].nC4Speed = (freq_conversion / freq) / 2;
sample_loaded->mSoundFile.Ins[2].nC4Speed = (freq_conversion / freq) / 2;
sample_loaded->mSoundFile.Ins[1].nVolume = (256 * sound_gvol) / 8;
sample_loaded->mSoundFile.Ins[2].nVolume = (256 * sound_gvol) / 8;
+
+ // This number is pretty much obtained via experimentation. It can probably
+ // stand to be a little higher.
+ sample_length /= 110;
+
+ if(sample_length < 256)
+ {
+ sample_loaded->mSoundFile.Patterns[0][0].param = sample_length;
+ sample_loaded->mSoundFile.Patterns[0][2].command = CMD_PATTERNBREAK;
+ }
+ else
+ {
+ int row_duration = sample_length / 255;
+ sample_loaded->mSoundFile.Patterns[0][0].param = 255;
+ if(row_duration < 62)
+ sample_loaded->mSoundFile.Patterns[0][2 + row_duration].command =
+ CMD_PATTERNBREAK;
+ }
+
// Find a free position to put it
for(i = 0; i < 16; i++)
{
@@ -365,6 +384,7 @@ void play_sample(int freq, char *filename)
}
free(input_buffer);
+ fclose(input_file);
}
}
View
7 block.cpp
@@ -206,25 +206,24 @@ char col2ansi[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
char exdi_types[3] = { DE_RADIO, DE_BUTTON, DE_BUTTON };
char exdi_xs[3] = { 2, 5, 15 };
-char exdi_ys[3] = { 3, 9, 9 };
+char exdi_ys[3] = { 3, 8, 8 };
char *exdi_strs[3] =
{
"Board file (MZB)\n"
"Character set (CHR)\n"
- "Text file (TXT)\n"
"Palette (PAL)\n"
"Sound effects (SFX)",
"OK", "Cancel"
};
-int exdi_p1s[3] = { 5, 0, -1 };
+int exdi_p1s[3] = { 4, 0, -1 };
int exdi_p2s[1] = { 19 };
void *exdi_storage[1] = { NULL };
dialog exdi =
{
- 26, 4, 53, 15, "Export as:", 3, exdi_types, exdi_xs, exdi_ys,
+ 26, 5, 53, 15, "Export as:", 3, exdi_types, exdi_xs, exdi_ys,
exdi_strs, exdi_p1s, exdi_p2s, exdi_storage, 0
};
View
32 board.cpp
@@ -62,6 +62,12 @@ Board *load_board_allocate(FILE *fp, int savegame)
Board *cur_board = (Board *)malloc(sizeof(Board));
load_board(cur_board, fp, savegame);
+ if(!cur_board->board_width)
+ {
+ free(cur_board);
+ return NULL;
+ }
+
return cur_board;
}
@@ -79,6 +85,7 @@ Board *load_board_allocate_direct(FILE *fp, int savegame)
void load_board(Board *cur_board, FILE *fp, int savegame)
{
int board_size = fgetd(fp);
+
if(board_size)
{
int board_location, last_location;
@@ -92,7 +99,7 @@ void load_board(Board *cur_board, FILE *fp, int savegame)
}
else
{
- memset(cur_board, 0, sizeof(Board));
+ cur_board->board_width = 0;
// And skip board location
fseek(fp, 4, SEEK_CUR);
}
@@ -108,24 +115,35 @@ void load_board_direct(Board *cur_board, FILE *fp, int savegame)
Scroll *cur_scroll;
Sensor *cur_sensor;
+ char *test_buffer;
+
board_mode = fgetc(fp);
overlay_mode = fgetc(fp);
if(!overlay_mode)
{
+ int overlay_width;
+ int overlay_height;
+
overlay_mode = fgetc(fp);
- int overlay_width = fgetw(fp);
- int overlay_height = fgetw(fp);
+ overlay_width = fgetw(fp);
+ overlay_height = fgetw(fp);
+
size = overlay_width * overlay_height;
cur_board->overlay = (char *)malloc(size);
cur_board->overlay_color = (char *)malloc(size);
load_RLE2_plane(cur_board->overlay, fp, size);
+ test_buffer = (char *)malloc(1024);
+ free(test_buffer);
+
// Skip sizes
fseek(fp, 4, SEEK_CUR);
- load_RLE2_plane(cur_board->overlay_color, fp, size);
+ load_RLE2_plane(cur_board->overlay_color, fp, size);
+ test_buffer = (char *)malloc(1024);
+ free(test_buffer);
}
else
{
@@ -579,12 +597,14 @@ void save_RLE2_plane(char *plane, FILE *fp, int size)
{
current_char = plane[i];
runsize = 1;
+
while((plane[i + 1] == current_char) && (runsize < 127) &&
- (i < size))
+ (i < (size - 1)))
{
i++;
runsize++;
}
+
// Put the runsize if necessary
if((runsize > 1) || current_char & 0x80)
{
@@ -617,7 +637,7 @@ void clear_board(Board *cur_board)
free(cur_board->level_under_id);
free(cur_board->level_under_param);
free(cur_board->level_under_color);
-
+
if(cur_board->overlay_mode)
{
free(cur_board->overlay);
View
66 changelog.txt
@@ -0,0 +1,66 @@
+August 11, 2004 - MZX 2.80b
+
++ Made it possible for robots to move through teleporters
++ Fixed bug with pressing shift in text entry boxes
++ Made it so alt + tab does not switch draw modes in editor
++ Fixed a disassembly error for color intensity N percent command
++ Fixed problem with looping on mods that do not loop explicitely
++ Fixed alt + dir scrolling in the char editor
++ Fixed not being able to click the rightmost char in the char editor
++ Readded unmark (alt + u) to robot editor (mysteriously disappeared??)
++ Fixed key label so it returns proper unicode values
++ The player and pushable robots can now be pushed by the push command
++ Fixed bug where you could clone the player by switching boards
++ Fixed bug where you could either turn off overlay or switch to boards
+ that don't have it while in overlay edit mode...
++ Fixed bug where remains of debug window would not be cleared in editor
+ if the board width is too small
++ Fixed bug where turning off the menu with a board too small would mess
+ things up
++ Fixed bug where run lengths were saved one too large... this could fix
+ stability problems in at least occasional cases (with saved worlds or
+ save games, at least)
++ Fixed placing solid things beneath robots (like bombs)
++ Added support for a keyboard plus in the char editors
++ Fixed previous button in SFX editor
++ Made robot name box disappear when robot char box comes up...
++ Fixed bug where mods restart after pressing P if they're the same mod
+ as what was playing before
++ Fixed problem with changing params (with P) in the editor.
++ Fixed bug where null boards were not being pruned from old worlds upon
+ load
++ Made file name saving box larger (for saving games and worlds)
++ Fixed bug where default (100%) palette intensity values would not be
+ applied to the palette a game loads with
++ Fixed bug where exporting char sets that are full size caused a 0
+ byte charset to be exported (8bit wraparound)
+- Removed export text in the board editor. Don't think anyone wanted it...
++ Added support for forms such as :line
++ Fixed sporadic incompletion of strings without trailing quotes at the
+ end of the line
++ Fixed bug where clearing/cutting the last line of a robot crashed MZX
++ F4 in robot editor now works more generally
++ Made line numbers in robot editor error report start at 1
++ Added ctrl + G to go to a line in the robot editor (ala nano)
++ Made it possible to change a robot's color in the editor
++ Fixed bug where spitfire, seekers, and missiles didn't hurt something
+ immediate adjacent to whatever shot it
++ Fixed editing of spitfires
++ Made default speed 4 again (5, bleh)
++ Readded quicksave/quickload
++ Readded F8 clear (always works - be careful)
++ Fixed autorepeat problems for spacepressed/delpressed.
++ Wrapped around sprite values so LogiCow's bad code would work (HTMCIAB)
++ Cleared block commands inbetween board changing and other things like
+ that
++ Fixed bug where MZX would crash if put dir player overwrote the robot
+ doing it
++ Fixed bug where playing SAMs would eventually crash MZX
++ Fixed some mod * problems (hopefully?)
++ Fixed bug where pasting blocks over the edge of the board in the editor
+ would cause MZX to crash
++ Uses new GDM2S3M source that fixes some bugs. If your converted GDM's
+ have problems, delete the S3M's it generated.
+
+August 9, 2004 - First release, MZX 2.80 BETA
+
View
16 char_ed.cpp
@@ -165,7 +165,7 @@ int char_editor(World *mzx_world)
}
else
- if(((mouse_x > 43) && (mouse_x < 64)) &&
+ if(((mouse_x > 43) && (mouse_x < 65)) &&
(mouse_y == 5))
{
current_char += mouse_x - 53;
@@ -190,6 +190,7 @@ int char_editor(World *mzx_world)
if(wrap_bit)
matrix[i] |= 1;
}
+ ec_change_char(current_char, matrix);
}
else
{
@@ -214,6 +215,7 @@ int char_editor(World *mzx_world)
if(wrap_bit)
matrix[i] |= 0x80;
}
+ ec_change_char(current_char, matrix);
}
else
{
@@ -236,6 +238,7 @@ int char_editor(World *mzx_world)
matrix[i] = matrix[i + 1];
}
matrix[13] = wrap_row;
+ ec_change_char(current_char, matrix);
}
else
{
@@ -258,6 +261,7 @@ int char_editor(World *mzx_world)
matrix[i] = matrix[i - 1];
}
matrix[0] = wrap_row;
+ ec_change_char(current_char, matrix);
}
else
{
@@ -279,6 +283,7 @@ int char_editor(World *mzx_world)
case SDLK_KP_PLUS:
case SDLK_EQUALS:
+ case SDLK_PLUS:
{
current_char++;
ec_read_char(current_char, matrix);
@@ -570,7 +575,7 @@ int smzx_char_editor(World *mzx_world)
}
else
- if(((mouse_x > 43) && (mouse_x < 64)) &&
+ if(((mouse_x > 43) && (mouse_x < 65)) &&
(mouse_y == 5))
{
current_char += mouse_x - 53;
@@ -590,10 +595,11 @@ int smzx_char_editor(World *mzx_world)
for(i = 0; i < 14; i++)
{
- wrap_section = matrix[i] & 0xC0;
+ wrap_section = (matrix[i] & 0xC0) >> 6;
matrix[i] <<= 2;
matrix[i] |= wrap_section;
}
+ ec_change_char(current_char, matrix);
}
else
{
@@ -617,6 +623,7 @@ int smzx_char_editor(World *mzx_world)
matrix[i] >>= 2;
matrix[i] |= (wrap_section << 6);
}
+ ec_change_char(current_char, matrix);
}
else
{
@@ -639,6 +646,7 @@ int smzx_char_editor(World *mzx_world)
matrix[i] = matrix[i + 1];
}
matrix[13] = wrap_row;
+ ec_change_char(current_char, matrix);
}
else
{
@@ -661,6 +669,7 @@ int smzx_char_editor(World *mzx_world)
matrix[i] = matrix[i - 1];
}
matrix[0] = wrap_row;
+ ec_change_char(current_char, matrix);
}
else
{
@@ -680,6 +689,7 @@ int smzx_char_editor(World *mzx_world)
break;
}
+ case SDLK_PLUS:
case SDLK_KP_PLUS:
case SDLK_EQUALS:
{
View
2  config.txt
@@ -72,7 +72,7 @@
#save_file = saved.sav
# Speed MZX should start at (1 through 9)
-#mzx_speed = 5
+#mzx_speed = 4
### Robot editor options ###
View
2  configure.cpp
@@ -336,7 +336,7 @@ config_info default_options =
// Game options
"caverns.mzx",
"saved.sav",
- 5,
+ 4,
// Robot editor options
{ 11, 10, 10, 14, 255, 3, 11, 2, 14, 0, 15, 11, 7, 15, 1, 2, 3 },
View
64 counter.cpp
@@ -513,77 +513,79 @@ int spr_num_read(World *mzx_world, Function_counter *counter,
int spr_cx_read(World *mzx_world, Function_counter *counter,
char *name, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
return (mzx_world->sprite_list[spr_num])->col_x;
}
int spr_cy_read(World *mzx_world, Function_counter *counter,
char *name, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
return (mzx_world->sprite_list[spr_num])->col_y;
}
int spr_width_read(World *mzx_world, Function_counter *counter,
char *name, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
return (mzx_world->sprite_list[spr_num])->width;
}
int spr_height_read(World *mzx_world, Function_counter *counter,
char *name, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
return (mzx_world->sprite_list[spr_num])->height;
}
int spr_refx_read(World *mzx_world, Function_counter *counter,
char *name, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
return (mzx_world->sprite_list[spr_num])->ref_x;
}
int spr_refy_read(World *mzx_world, Function_counter *counter,
char *name, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
return (mzx_world->sprite_list[spr_num])->ref_y;
}
int spr_x_read(World *mzx_world, Function_counter *counter,
char *name, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
return (mzx_world->sprite_list[spr_num])->x;
}
int spr_y_read(World *mzx_world, Function_counter *counter,
char *name, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
return (mzx_world->sprite_list[spr_num])->y;
}
int spr_cwidth_read(World *mzx_world, Function_counter *counter,
char *name, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
return (mzx_world->sprite_list[spr_num])->col_width;
}
int spr_cheight_read(World *mzx_world, Function_counter *counter,
char *name, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
return (mzx_world->sprite_list[spr_num])->col_height;
}
void spr_num_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- mzx_world->sprite_num = value;
+ value &= 0xFF;
+
+ mzx_world->sprite_num = (unsigned int)value;
}
void spr_yorder_write(World *mzx_world, Function_counter *counter,
@@ -595,7 +597,7 @@ void spr_yorder_write(World *mzx_world, Function_counter *counter,
void spr_ccheck_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
Sprite *cur_sprite = mzx_world->sprite_list[spr_num];
value %= 3;
@@ -624,7 +626,7 @@ void spr_ccheck_write(World *mzx_world, Function_counter *counter,
void spr_clist_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
Sprite *cur_sprite = mzx_world->sprite_list[spr_num];
sprite_colliding_xy(mzx_world, cur_sprite, cur_sprite->x,
cur_sprite->y);
@@ -633,63 +635,63 @@ void spr_clist_write(World *mzx_world, Function_counter *counter,
void spr_cx_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
(mzx_world->sprite_list[spr_num])->col_x = value;
}
void spr_cy_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
(mzx_world->sprite_list[spr_num])->col_y = value;
}
void spr_height_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
(mzx_world->sprite_list[spr_num])->height = value;
}
void spr_width_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
(mzx_world->sprite_list[spr_num])->width = value;
}
void spr_refx_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
(mzx_world->sprite_list[spr_num])->ref_x = value;
}
void spr_refy_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
(mzx_world->sprite_list[spr_num])->ref_y = value;
}
void spr_x_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
(mzx_world->sprite_list[spr_num])->x = value;
}
void spr_y_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
(mzx_world->sprite_list[spr_num])->y = value;
}
void spr_vlayer_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
if(value)
(mzx_world->sprite_list[spr_num])->flags |= SPRITE_VLAYER;
else
@@ -699,7 +701,7 @@ void spr_vlayer_write(World *mzx_world, Function_counter *counter,
void spr_static_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
if(value)
(mzx_world->sprite_list[spr_num])->flags |= SPRITE_STATIC;
else
@@ -709,7 +711,7 @@ void spr_static_write(World *mzx_world, Function_counter *counter,
void spr_overlaid_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
if(value)
(mzx_world->sprite_list[spr_num])->flags |= SPRITE_OVER_OVERLAY;
else
@@ -719,14 +721,14 @@ void spr_overlaid_write(World *mzx_world, Function_counter *counter,
void spr_off_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
(mzx_world->sprite_list[spr_num])->flags &= ~SPRITE_INITIALIZED;
}
void spr_swap_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
Sprite *src = mzx_world->sprite_list[spr_num];
Sprite *dest = mzx_world->sprite_list[value];
mzx_world->sprite_list[value] = src;
@@ -736,14 +738,14 @@ void spr_swap_write(World *mzx_world, Function_counter *counter,
void spr_cwidth_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
(mzx_world->sprite_list[spr_num])->col_width = value;
}
void spr_cheight_write(World *mzx_world, Function_counter *counter,
char *name, int value, int id)
{
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
(mzx_world->sprite_list[spr_num])->col_height = value;
}
@@ -752,7 +754,7 @@ void spr_setview_write(World *mzx_world, Function_counter *counter,
{
Board *src_board = mzx_world->current_board;
int n_scroll_x, n_scroll_y;
- int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1);
+ int spr_num = strtol(name + 3, NULL, 10) & (MAX_SPRITES - 1) & 0xFF;
Sprite *cur_sprite = mzx_world->sprite_list[spr_num];
src_board->scroll_x = 0;
src_board->scroll_y = 0;
@@ -1512,6 +1514,7 @@ void str_num_write(World *mzx_world, Function_counter *counter,
int next;
name[dot_position] = 0;
+
if(strlen(name) > 14)
name[14] = 0;
@@ -2424,7 +2427,7 @@ char *set_function_string(World *mzx_world, char *name, int id, char *buffer)
else
{
char terminate_char = '*';
- char current_char = 0;
+ char current_char;
int read_pos = 0;
do
@@ -2544,6 +2547,7 @@ void inc_string(World *mzx_world, char *name, char *value, int id)
int next;
value[63] = 0;
+
if(strlen(name) > 14)
name[14] = 0;
View
151 edit.cpp
@@ -121,7 +121,8 @@ Backspace: Delete (move left one in text)
level_color = src_board->level_color; \
overlay = src_board->overlay; \
overlay_color = src_board->overlay_color; \
- clear_screen_no_update(177, 1) \
+ clear_screen_no_update(177, 1); \
+ draw_mode = 0 \
#define fix_scroll() \
if(cursor_board_x >= board_width) \
@@ -429,6 +430,7 @@ int place_current_at_xy(World *mzx_world, int id, int color, int param,
{
int old_param = src_board->level_param[offset];
replace_robot(src_board, copy_robot, old_param);
+ src_board->level_color[offset] = color;
return old_param;
}
@@ -448,6 +450,7 @@ int place_current_at_xy(World *mzx_world, int id, int color, int param,
{
int old_param = src_board->level_param[offset];
replace_scroll(src_board, copy_scroll, old_param);
+ src_board->level_color[offset] = color;
return old_param;
}
@@ -463,6 +466,7 @@ int place_current_at_xy(World *mzx_world, int id, int color, int param,
{
int old_param = src_board->level_param[offset];
replace_sensor(src_board, copy_sensor, old_param);
+ src_board->level_color[offset] = color;
return old_param;
}
@@ -1077,7 +1081,10 @@ void edit_world(World *mzx_world)
}
if((cursor_board_x - scroll_x) < (debug_x + 25))
+ {
debug_x = 60;
+ clear_screen_no_update(177, 1);
+ }
break;
}
@@ -1113,7 +1120,10 @@ void edit_world(World *mzx_world)
}
if((cursor_board_x - scroll_x) > (debug_x - 5))
+ {
debug_x = 0;
+ clear_screen_no_update(177, 1);
+ }
break;
}
@@ -1183,17 +1193,20 @@ void edit_world(World *mzx_world)
case SDLK_TAB:
{
- if(draw_mode)
- {
- draw_mode = 0;
- }
- else
+ if(!get_alt_status(keycode_SDL))
{
- draw_mode = 1;
- current_param = place_current_at_xy(mzx_world, current_id,
- current_color, current_param, cursor_board_x, cursor_board_y,
- &copy_robot, &copy_scroll, &copy_sensor, overlay_edit);
- modified = 1;
+ if(draw_mode)
+ {
+ draw_mode = 0;
+ }
+ else
+ {
+ draw_mode = 1;
+ current_param = place_current_at_xy(mzx_world, current_id,
+ current_color, current_param, cursor_board_x, cursor_board_y,
+ &copy_robot, &copy_scroll, &copy_sensor, overlay_edit);
+ modified = 1;
+ }
}
break;
@@ -1251,8 +1264,15 @@ void edit_world(World *mzx_world)
}
else
{
- draw_mode = 2;
- text_start_x = cursor_board_x;
+ if(draw_mode != 2)
+ {
+ draw_mode = 2;
+ text_start_x = cursor_board_x;
+ }
+ else
+ {
+ draw_mode = 0;
+ }
}
break;
}
@@ -1328,6 +1348,12 @@ void edit_world(World *mzx_world)
// Transport
case SDLK_F7:
{
+ if(get_shift_status(keycode_SDL))
+ {
+ set_screen_mode(get_screen_mode() + 1);
+ }
+ else
+
if(!overlay_edit)
{
thing_menu(mzx_world, 4, &current_id, &current_color, &current_param,
@@ -1542,6 +1568,11 @@ void edit_world(World *mzx_world)
fix_mod();
}
+ find_player(mzx_world);
+
+ if(!src_board->overlay_mode)
+ overlay_edit = 0;
+
fix_scroll();
modified = 1;
}
@@ -1584,6 +1615,11 @@ void edit_world(World *mzx_world)
synchronize_board_values();
fix_mod();
fix_scroll();
+
+ find_player(mzx_world);
+ if(!src_board->overlay_mode)
+ overlay_edit = 0;
+
modified = 0;
}
cursor_solid();
@@ -1709,6 +1745,9 @@ void edit_world(World *mzx_world)
if(mzx_world->current_board_id == 0)
strcpy(mzx_world->name, src_board->board_name);
+ if(!src_board->overlay_mode)
+ overlay_edit = 0;
+
modified = 1;
cursor_solid();
}
@@ -1759,12 +1798,12 @@ void edit_world(World *mzx_world)
{
int offset = cursor_board_x + (cursor_board_y * board_width);
int d_id = level_id[offset];
+
if(d_id < 122)
{
int d_param = level_param[offset];
d_param = change_param(mzx_world, d_id, d_param, NULL, NULL, NULL);
- place_current_at_xy(mzx_world, current_id, current_color,
- d_param, cursor_board_x, cursor_board_y, NULL, NULL, NULL, 0);
+ level_param[offset] = d_param;
modified = 1;
}
cursor_solid();
@@ -1818,42 +1857,6 @@ void edit_world(World *mzx_world)
case 2:
{
- // Text file
-
- if(!save_file_dialog(mzx_world, "Export", "Save as: ", export_name))
- {
- FILE *txt_file;
- int x, y, offset = scroll_x + (scroll_y * board_width);
- int width = 80, height = 25;
- int skip;
-
- if(board_width < (scroll_x + 80))
- width = board_width - scroll_x;
-
- if(board_height < (scroll_y + 25))
- height = board_height - scroll_y;
-
- skip = board_width - width;
-
- add_ext(export_name, ".txt");
- txt_file = fopen(export_name, "wb");
-
- for(y = 0; y < height; y++)
- {
- for(x = 0; x < width; x++, offset++)
- {
- fputc(get_id_char(src_board, offset), txt_file);
- }
- fputc('\n', txt_file);
- offset += skip;
- }
- fclose(txt_file);
- }
- break;
- }
-
- case 3:
- {
// Palette
if(!save_file_dialog(mzx_world, "Export", "Save as: ", export_name))
{
@@ -1864,7 +1867,7 @@ void edit_world(World *mzx_world)
break;
}
- case 4:
+ case 3:
{
// Sound effects
if(!save_file_dialog(mzx_world, "Export", "Save as: ", export_name))
@@ -2293,6 +2296,12 @@ void edit_world(World *mzx_world)
{
block_height = block_dest_y - block_y + 1;
}
+
+ if((dest_x + block_width) > board_width)
+ block_width = board_width - dest_x;
+
+ if((dest_y + block_height) > board_height)
+ block_height = board_height - dest_y;
draw_mode = 0;
@@ -2404,6 +2413,12 @@ void edit_world(World *mzx_world)
block_height = block_dest_y - block_y + 1;
}
+ if((dest_x + block_width) > board_width)
+ block_width = board_width - dest_x;
+
+ if((dest_y + block_height) > board_height)
+ block_height = board_height - dest_y;
+
draw_mode = 0;
switch(block_command)
@@ -2789,17 +2804,20 @@ void edit_world(World *mzx_world)
if(mzx_world->board_list[i] == NULL)
break;
}
- if(add_board(mzx_world, i) >= 0)
- {
- fix_board(i);
- synchronize_board_values();
- fix_mod();
- fix_scroll();
-
- modified = 1;
- }
- cursor_solid();
+ if(i < MAX_BOARDS)
+ {
+ if(add_board(mzx_world, i) >= 0)
+ {
+ fix_board(i);
+ synchronize_board_values();
+ fix_mod();
+ fix_scroll();
+
+ modified = 1;
+ }
+ cursor_solid();
+ }
}
else
{
@@ -2844,6 +2862,10 @@ void edit_world(World *mzx_world)
fix_mod();
}
fix_scroll();
+
+ find_player(mzx_world);
+ if(!src_board->overlay_mode)
+ overlay_edit = 0;
}
else
{
@@ -3024,8 +3046,13 @@ void edit_world(World *mzx_world)
if(edit_screen_height == 19)
{
edit_screen_height = 25;
+ clear_screen_no_update(177, 1);
+
if((scroll_y + 25) > board_height)
scroll_y = board_height - 25;
+
+ if(scroll_y < 0)
+ scroll_y = 0;
}
else
{
View
322 game.cpp
@@ -424,8 +424,12 @@ void title_screen(World *mzx_world)
{
if(mzx_world->active)
{
+ char old_mod_playing[128];
+ strcpy(old_mod_playing, mzx_world->real_mod_playing);
+
// Play
// Only from swap?
+
if(mzx_world->only_from_swap)
{
m_show();
@@ -433,9 +437,11 @@ void title_screen(World *mzx_world)
0, 24, 0x3101);
break;
}
+
// Load world curr_file
// Don't end mod- We want to have smooth transition for that.
// Clear screen
+
clear_screen(32, 7);
// Palette
default_palette();
@@ -449,8 +455,13 @@ void title_screen(World *mzx_world)
send_robot_def(mzx_world, 0, 11);
send_robot_def(mzx_world, 0, 10);
- load_mod(src_board->mod_playing);
- strcpy(mzx_world->real_mod_playing, src_board->mod_playing);
+
+ if(strcmp(src_board->mod_playing, "*") &&
+ strcmp(src_board->mod_playing, old_mod_playing))
+ load_mod(src_board->mod_playing);
+
+ strcpy(mzx_world->real_mod_playing, src_board->mod_playing);
+
set_counter(mzx_world, "TIME", src_board->time_limit, 0);
clear_sfx_queue();
@@ -503,31 +514,77 @@ void title_screen(World *mzx_world)
break;
}
-/* case SDLK_F10: //F10
- // Quickload
- if(curr_sav[0] == 0) break;
+ // Quick load
+ case SDLK_F10: // F4
+ {
+ int fade_status = get_fade_status();
+
+ // Restore
m_show();
- // Swap out current board...
- // Load game
- fadein = 0;
- if(load_world(mzx_world, curr_sav, 0, 1, &fadein))
+ if(fade_status)
{
+ clear_screen(32, 7);
+ insta_fadein();
+ }
+
+ // Swap out current board...
+ clear_sfx_queue();
+ // Load game
+ fadein = 0;
+
+ if(reload_savegame(mzx_world, curr_sav, &fadein))
+ {
+ vquick_fadeout();
+ }
+ else
+ {
+ src_board = mzx_world->current_board;
+ // Swap in starting board
+ load_mod(src_board->mod_playing);
+ strcpy(mzx_world->real_mod_playing, src_board->mod_playing);
+
+ send_robot_def(mzx_world, 0, 10);
+ dead = 0;
+ fadein ^= 1;
+
+ send_robot_def(mzx_world, 0, 11);
+ send_robot_def(mzx_world, 0, 10);
+ set_counter(mzx_world, "TIME", src_board->time_limit, 0);
+
+ find_player(mzx_world);
+ mzx_world->player_restart_x = mzx_world->player_x;
+ mzx_world->player_restart_y = mzx_world->player_y;
+ vquick_fadeout();
+
+ play_game(mzx_world, 1);
+
+ // Done playing- load world again
+ // Already faded out from play_game()
+ end_mod();
+ // Clear screen
+ clear_screen(32, 7);
+ // Palette
+ default_palette();
+ insta_fadein();
+ // Reload original file
+ if(!stat(curr_file, &file_info))
+ {
+ reload_world(mzx_world, curr_file, &fade);
+ src_board = mzx_world->current_board;
+ load_mod(src_board->mod_playing);
+ strcpy(mzx_world->real_mod_playing, src_board->mod_playing);
+ set_counter(mzx_world, "TIME", src_board->time_limit, 0);
+ }
+ else
+ {
+ clear_world(mzx_world);
+ }
vquick_fadeout();
fadein = 1;
- break;
+ dead = 0;
}
- // Swap in starting board
- if(board_offsets[curr_board] != NULL)
- select_current(curr_board);
- else select_current(0);
- strcpy(temp2, mod_playing);
- load_mod(temp2);
-
- send_robot_def(0,10);
- dead = 0;
- vquick_fadeout();
- fadein ^= 1;
- goto gameplay; */
+ break;
+ }
}
update_event_status();
}
@@ -1137,9 +1194,13 @@ void play_game(World *mzx_world, int fadein)
if(key)
{
- keylbl[3] = key;
+ int key_char = get_key(keycode_unicode);
- send_robot_all(mzx_world, keylbl);
+ if(key_char)
+ {
+ keylbl[3] = key_char;
+ send_robot_all(mzx_world, keylbl);
+ }
switch(key)
{
@@ -1363,125 +1424,124 @@ void play_game(World *mzx_world, int fadein)
int i;
// Cheat #1- Give all
- if(cheats_active)
- {
- set_counter(mzx_world, "GEMS", 32767, 1);
- set_counter(mzx_world, "AMMO", 32767, 1);
- set_counter(mzx_world, "HEALTH", 32767, 1);
- set_counter(mzx_world, "COINS", 32767, 1);
- set_counter(mzx_world, "LIVES", 32767, 1);
- set_counter(mzx_world, "TIME", src_board->time_limit, 1);
- set_counter(mzx_world, "LOBOMBS", 32767, 1);
- set_counter(mzx_world, "HIBOMBS", 32767, 1);
-
- mzx_world->score = 0;
-
- for(i = 0; i < 16; i++)
- mzx_world->keys[i] = i;
- dead = 0; // :)
- src_board->player_ns_locked = 0;
- src_board->player_ew_locked = 0;
- src_board->player_attack_locked = 0;
- }
+ set_counter(mzx_world, "GEMS", 32767, 1);
+ set_counter(mzx_world, "AMMO", 32767, 1);
+ set_counter(mzx_world, "HEALTH", 32767, 1);
+ set_counter(mzx_world, "COINS", 32767, 1);
+ set_counter(mzx_world, "LIVES", 32767, 1);
+ set_counter(mzx_world, "TIME", src_board->time_limit, 1);
+ set_counter(mzx_world, "LOBOMBS", 32767, 1);
+ set_counter(mzx_world, "HIBOMBS", 32767, 1);
+
+ mzx_world->score = 0;
+
+ for(i = 0; i < 16; i++)
+ {
+ mzx_world->keys[i] = i;
+ }
+
+ dead = 0; // :)
+ src_board->player_ns_locked = 0;
+ src_board->player_ew_locked = 0;
+ src_board->player_attack_locked = 0;
+
break;
}
- // FIXME - readd? Maybe.
- /*
- case SDLK_F8: // F8
- // Cheat #2- Zap surrounding
- if((cheats_active) && (!dead))
+ case SDLK_F8:
+ {
+ int player_x = mzx_world->player_x;
+ int player_y = mzx_world->player_y;
+ int board_width = src_board->board_width;
+ int board_height = src_board->board_height;
+
+ if(player_x > 0)
{
- if(player_x > 0)
- {
- id_clear(player_x - 1, player_y);
- if(player_y > 0) id_clear(player_x - 1, player_y - 1);
- if(player_y < (board_ysiz - 1))
- id_clear(player_x - 1, player_y + 1);
- }
- if(player_x < (board_xsiz - 1))
- {
- id_clear(player_x + 1, player_y);
- if(player_y > 0) id_clear(player_x + 1,player_y - 1);
- if(player_y < (board_ysiz - 1))
- id_clear(player_x + 1, player_y + 1);
- }
- if(player_y > 0) id_clear(player_x, player_y - 1);
- if(player_y < (board_ysiz - 1))
- id_clear(player_x, player_y + 1);
+ place_at_xy(mzx_world, 0, 7, 0, player_x - 1, player_y);
+ if(player_y > 0)
+ place_at_xy(mzx_world, 0, 7, 0, player_x - 1, player_y - 1);
+
+ if(player_y < (board_height - 1))
+ place_at_xy(mzx_world, 0, 7, 0, player_x - 1, player_y + 1);
}
- break;
- */
-
- // FIXME - game loading
- /*
- case SDLK_F9://F9
- // Quicksave
- if(cheats_active > 1) break;
- if(curr_sav[0] == 0) break;
- if(!dead)
+
+ if(player_x < (board_width - 1))
{
- // Can we?
- if(save_mode == CANT_SAVE) break;
- if(save_mode == CAN_SAVE_ON_SENSOR)
- if(level_under_id[player_x + max_bxsiz * player_y] != 122) break;
- m_show();
- // If faded...
- t1 = get_fade_status();
- if(t1)
- {
- clear_screen(32, 7);
- insta_fadein();
- }
- // Store current
- store_current();
- // Save entire game
- save_world(curr_sav, 1, t1);
- // Reload current
- select_current(curr_board);
- if(t1) insta_fadeout();
+ place_at_xy(mzx_world, 0, 7, 0, player_x + 1, player_y);
+
+ if(player_y > 0)
+ place_at_xy(mzx_world, 0, 7, 0, player_x + 1, player_y - 1);
+
+ if(player_y < (board_height - 1))
+ place_at_xy(mzx_world, 0, 7, 0, player_x + 1, player_y + 1);
}
- break;
- */
- case SDLK_F11: // F11
- {
- // SMZX Mode
- set_screen_mode(get_screen_mode() + 1);
+ if(player_y > 0)
+ place_at_xy(mzx_world, 0, 7, 0, player_x, player_y - 1);
+
+ if(player_y < (board_height - 1))
+ place_at_xy(mzx_world, 0, 7, 0, player_x, player_y + 1);
+
break;
}
- // FIXME - game loading
- /*
- case SDLK_F10: // F10
- // Quickload
- if(cheats_active > 1) break;
- if(curr_sav[0] == 0) break;
- m_show();
- // Swap out current board...
- store_current();
- clear_current();
- // Load game
- fadein = 0;
- if(load_world(curr_sav, 0, 1, &fadein))
+ // Quick save
+ case SDLK_F9:
+ {
+ if(!dead)
{
- vquick_fadeout();
- return;
- }
- // Swap in starting board
- if(board_offsets[curr_board] != NULL)
- select_current(curr_board);
- else select_current(0);
+ // Can we?
+ if((cheats_active <= 1) && (src_board->save_mode != CANT_SAVE) &&
+ ((src_board->save_mode != CAN_SAVE_ON_SENSOR) ||
+ (src_board->level_under_id[mzx_world->player_x +
+ (src_board->board_width * mzx_world->player_y)] == 122)))
+ {
+ int fade_status;
- strcpy(temp2, mod_playing);
- load_mod(temp2);
+ // Save entire game
+ save_world(mzx_world, curr_sav, 1, fade_status);
- send_robot_def(0, 10);
- dead = 0;
- vquick_fadeout();
- fadein ^= 1;
- break;
- */
+ if(fade_status)
+ insta_fadeout();
+ }
+ }
+ break;
+ }
+
+ // Quick load
+ case SDLK_F10:
+ {
+ struct stat file_info;
+
+ if(!stat(curr_sav, &file_info))
+ {
+ // Load game
+ fadein = 0;
+ if(reload_savegame(mzx_world, curr_sav, &fadein))
+ {
+ vquick_fadeout();
+ return;
+ }
+
+ // Reset this
+ src_board = mzx_world->current_board;
+ // Swap in starting board
+ load_mod(src_board->mod_playing);
+ strcpy(mzx_world->real_mod_playing, src_board->mod_playing);
+
+ send_robot_def(mzx_world, 0, 10);
+ dead = 0;
+ fadein ^= 1;
+ }
+ break;
+ }
+
+ case SDLK_F11: // F11
+ {
+ // SMZX Mode
+ set_screen_mode(get_screen_mode() + 1);
+ break;
+ }
}
}
} while(key != SDLK_ESCAPE);
@@ -2872,8 +2932,8 @@ int update(World *mzx_world, int game, int *fadein)
if(death_board != DEATH_SAME_POS)
{
if(death_board == NO_DEATH_BOARD)
- {
- int player_restart_x = mzx_world->player_restart_x;
+ {
+ int player_restart_x = mzx_world->player_restart_x;
int player_restart_y = mzx_world->player_restart_y;
// Return to entry x/y
id_remove_top(mzx_world, mzx_world->player_x, mzx_world->player_y);
View
10 game2.cpp
@@ -2409,7 +2409,7 @@ void shoot_fire(World *mzx_world, int x, int y, int dir)
else
// Did it hit a robot?
- if((d_param == 123) || (d_param == 124))
+ if((d_id == 123) || (d_id == 124))
{
// Send the spitfire label
send_robot_def(mzx_world, d_param, 9);
@@ -2417,7 +2417,7 @@ void shoot_fire(World *mzx_world, int x, int y, int dir)
else
// Did it hit the player?
- if(d_param == 127)
+ if(d_id == 127)
{
hurt_player_id(mzx_world, 78);
}
@@ -2449,7 +2449,7 @@ void shoot_seeker(World *mzx_world, int x, int y, int dir)
else
// Did it hit the player?
- if(d_param == 127)
+ if(d_id == 127)
{
hurt_player_id(mzx_world, 79);
}
@@ -2482,7 +2482,7 @@ void shoot_missile(World *mzx_world, int x, int y, int dir)
else
// Did it hit the player?
- if(d_param == 127)
+ if(d_id == 127)
{
hurt_player_id(mzx_world, 62);
}
@@ -2594,7 +2594,7 @@ int move(World *mzx_world, int x, int y, int dir, int move_flags)
can_push = 1;
// If it can transport, do it
- if(!transport(mzx_world, x, y, dir, p_id, p_param, p_color, can_push))
+ if(!transport(mzx_world, dx, dy, dir, p_id, p_param, p_color, can_push))
{
id_remove_top(mzx_world, x, y);
return 0;
View
2  graphics.cpp
@@ -849,7 +849,7 @@ void ec_save_set(char *name)
fclose(fp);
}
-void ec_save_set_var(char *name, Uint8 offset, Uint8 size)
+void ec_save_set_var(char *name, Uint8 offset, Uint32 size)
{
FILE *fp = fopen(name, "wb");
View
2  graphics.h
@@ -105,7 +105,7 @@ Sint32 ec_load_set_var(char *name, Uint8 pos);
void ec_mem_load_set(Uint8 *chars);
void ec_mem_save_set(Uint8 *chars);
void ec_save_set(char *name);
-void ec_save_set_var(char *name, Uint8 offset, Uint8 size);
+void ec_save_set_var(char *name, Uint8 offset, Uint32 size);
void ec_load_mzx(void);
void ec_load_smzx(void);
void ec_load_blank(void);
View
85 help.doc
@@ -1,6 +1,6 @@
@1
@1 ~fM ~bE G ~3A Z ~bE U ~fX
- @1 ~e2.80
+ @1 ~e2.80b
@1
:072: ~eTable of Contents
@@ -34,11 +34,11 @@
>#ERRORMES.HLP:1st:Error Messages
>#MEGAZEUX.HLP:1st:MegaZeux Limitations
>#IFYOUFIN.HLP:1st:If You Find a Bug...
->#NEWINVER.HLP:1st:NEW in Version 2.80!
+>#NEWINVER.HLP:1st:NEW in Version 2.80b!
$** Credits and Acknowledgments **
-$Mzx 2.80 Thanks & Beta testers:
+$Mzx 2.80b Thanks & Beta testers:
$Wervyn
$Exophase
$Quasar84
@@ -95,7 +95,7 @@ $~EWelcome to MegaZeux! Use the arrow keys to Scroll
$~Ethis text, and ESC when you are done reading.
$~BPress END to learn about the NEW FEATURES in
-$~BMegaZeux 2.80!
+$~BMegaZeux 2.80b!
As you may already know, MegaZeux is a game system which
allows you to play almost limitless worlds in dated yet
@@ -133,7 +133,7 @@ the game.
>#CONTROLS.HLP:091:Controls
>#THEWORLD.HLP:1st:The World Editor
->#NEWINVER.HLP:1st:WHAT'S NEW in version 2.80!
+>#NEWINVER.HLP:1st:WHAT'S NEW in version 2.80b!
#CONTROLS.HLP
:091:Controls
@@ -6374,7 +6374,80 @@ the target character set.
>#MAIN.HLP:072:Table of Contents
#NEWINVER.HLP
-:1st:NEW in Version 2.80!
+:1st:NEW in Version 2.80b!
+
+August 11, 2004 - MZX 2.80b
+
++ Made it possible for robots to move through teleporters
++ Fixed bug with pressing shift in text entry boxes
++ Made it so alt + tab does not switch draw modes in editor
++ Fixed a disassembly error for color intensity N percent
+ command
++ Fixed problem with looping on mods that do not loop
+ explicitly
++ Fixed alt + dir scrolling in the char editor
++ Fixed not being able to click the rightmost char in the char
+ editor
++ Readded unmark (alt + u) to robot editor (mysteriously
+ disappeared??)
++ Fixed key label so it returns proper unicode values
++ The player and pushable robots can now be pushed by the push
+ command
++ Fixed bug where you could clone the player by switching
+ boards
++ Fixed bug where you could either turn off overlay or switch
+ to boards that don't have it while in overlay edit mode...
++ Fixed bug where remains of debug window would not be cleared
+ in editor if the board width is too small
++ Fixed bug where turning off the menu with a board too small
+ would mess things up
++ Fixed bug where run lengths were saved one too large... this
+ could fix stability problems in at least occasional cases
+ (with saved worlds or save games, at least)
++ Fixed placing solid things beneath robots (like bombs)
++ Added support for a keyboard plus in the char editors
++ Fixed previous button in SFX editor
++ Made robot name box disappear when robot char box comes up...
++ Fixed bug where mods restart after pressing P if they're the
+ same mod as what was playing before
++ Fixed problem with changing params (with P) in the editor.
++ Fixed bug where null boards were not being pruned from old
+ worlds upon load
++ Made file name saving box larger (for saving games and worlds)
++ Fixed bug where default (100%) palette intensity values would
+ not be applied to the palette a game loads with
++ Fixed bug where exporting char sets that are full size caused
+ a 0 byte charset to be exported (8bit wraparound)
+- Removed export text in the board editor. Don't think anyone
+ wanted it...
++ Added support for forms such as :line
++ Fixed sporadic incompletion of strings without trailing
+ quotes at the end of the line
++ Fixed bug where clearing/cutting the last line of a robot
+ crashed MZX
++ F4 in robot editor now works more generally
++ Made line numbers in robot editor error report start at 1
++ Added ctrl + G to go to a line in the robot editor (ala nano)
++ Made it possible to change a robot's color in the editor
++ Fixed bug where spitfire, seekers, and missiles didn't hurt
+ something immediate adjacent to whatever shot it
++ Fixed editing of spitfires
++ Made default speed 4 again (5, bleh)
++ Readded quicksave/quickload
++ Readded F8 clear (always works - be careful)
++ Fixed autorepeat problems for spacepressed/delpressed.
++ Wrapped around sprite values so LogiCow's bad code would work
+ (HTMCIAB)
++ Cleared block commands inbetween board changing and other
+ things like that
++ Fixed bug where MZX would crash if put dir player overwrote
+ the robot doing it
++ Fixed bug where playing SAMs would eventually crash MZX
++ Fixed some mod * problems (hopefully?)
++ Fixed bug where pasting blocks over the edge of the board in
+ the editor would cause MZX to crash
++ Uses new GDM2S3M source that fixes some bugs. If your
+ converted GDM's have problems, delete the S3M's it generated.
August 9, 2004 - First release, MZX 2.80 BETA
View
14 intake.cpp
@@ -450,7 +450,8 @@ int intake(char *string, int max_len, char x, char y,
break;
}
- case SDLK_u:
+ case SDLK_l:
+ case SDLK_g:
case SDLK_d:
{
if(get_ctrl_status(keycode_SDL) && robo_intk)
@@ -478,6 +479,7 @@ int intake(char *string, int max_len, char x, char y,
break;
}
+ case SDLK_u:
case SDLK_o:
case SDLK_x:
case SDLK_b:
@@ -497,6 +499,8 @@ int intake(char *string, int max_len, char x, char y,
break;
}
+ case SDLK_LSHIFT:
+ case SDLK_RSHIFT:
case 0:
{
place = 0;
@@ -506,7 +510,7 @@ int intake(char *string, int max_len, char x, char y,
default:
{
// Place the char
- place = 1;
+ place = 1;
break;
}
}
@@ -523,12 +527,14 @@ int intake(char *string, int max_len, char x, char y,
// Keycode.. Filter.
if(filter_type & 1)
{
- if((cur_char >= 'a') && (cur_char <= 'z')) cur_char -= 32;
+ if((cur_char >= 'a') && (cur_char <= 'z'))
+ cur_char -= 32;
}
if(filter_type & 2)
{
- if((cur_char >= 'A') && (cur_char <= 'Z')) cur_char += 32;
+ if((cur_char >= 'A') && (cur_char <= 'Z'))
+ cur_char += 32;
}
// Block numbers
View
4 param.cpp
@@ -171,7 +171,7 @@ int edit_param(World *mzx_world, int id, int param)
case 78: // Shooting fire
{
- param = pe_pusher(mzx_world, param) << 1;
+ param = pe_pusher(mzx_world, param >> 1) << 1;
break;
}
@@ -1280,6 +1280,8 @@ int edit_robot(World *mzx_world, Robot *cur_robot)
if(intake(cur_robot->robot_name, 14, 34, 13, 15, 1, 0) != SDLK_ESCAPE)
{
+ restore_screen();
+ save_screen();
// ...and character.
new_char = char_selection(cur_robot->robot_char);
if(new_char < 0)
View
62 rasm.cpp
@@ -218,7 +218,7 @@ int cm206[] = { CMD_CHAR, CHARACTER | STRING | IMM_U16, DIR };
int cm207[] = { CMD_CHAR, CHARACTER | STRING | IMM_U16,
IGNORE_TO, CHARACTER | STRING | IMM_U16 };
int cm211[] = { CMD_SFX, IMM_U16 | STRING, IGNORE_TO, STRING };
-int cm212[] = { CMD_INTENSITY, IMM_U16 | STRING, IGNORE_IS, IGNORE_AT,
+int cm212[] = { CMD_INTENSITY, IGNORE_IS, IGNORE_AT, IMM_U16 | STRING,
CMD_PERCENT };
int cm213[] = { CMD_INTENSITY, IMM_U16 | STRING, IGNORE_IS, IGNORE_AT,
IMM_U16 | STRING, CMD_PERCENT };
@@ -776,6 +776,30 @@ char *command_fragments[69] =
"no"
};
+/*
+ 0 1 2 3 4 5 6 7 8 9 A B C D E F
+*/
+
+char special_first_char[256] =
+{
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00-0x0F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10-0x1F
+ 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, // 0x20-0x2F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, // 0x30-0x3F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x40-0x4F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, // 0x50-0x5F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60-0x6F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x70-0x7F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80-0x8F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x90-0x9F
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xA0-0xAF
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xB0-0xBF
+ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, // 0xC0-0xCF
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xD0-0xDF
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xE0-0xEF
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // 0xF0-0xFF
+};
+
char *ignore_list[21] =
{
",", ";", "a", "an", "and", "as", "at", "by", "else", "for", "from",
@@ -801,13 +825,16 @@ int parse_argument(char *cmd_line, char **next, int *arg_translated, int *error,
cmd_line++;
current = *cmd_line;
if((current == '\\') && (cmd_line[1] == '"'))
- {
cmd_line++;
- }
+
} while((current != '"') && current);
*arg_translated = 0;
- *next = cmd_line + 1;
+ if(current)
+ *next = cmd_line + 1;
+ else
+ *next = cmd_line;
+
*arg_short = S_STRING;
return STRING;
}
@@ -1420,7 +1447,32 @@ int assemble_line(char *cpos, char *output_buffer, char *error_buffer,
arg_count = 0;
}
else
- {
+
+ if(special_first_char[cpos[0]] && (cpos[1] != ' '))
+ {
+ int str_size;
+
+ current_command.name[0] = cpos[0];
+ current_command.name[1] = 0;
+ current_command.parameters = 1;
+
+ str_size = strlen(cpos + 1) + 1;
+ param_list[0] = (void *)malloc(str_size);
+ memcpy((char *)param_list[0], cpos + 1, str_size);
+ current_command.param_types[0] = STRING;
+
+ arg_count = 1;
+
+ if(param_listing)
+ {
+ param_listing[0] = S_STRING;
+ words = 1;
+ }
+
+ translated_command = match_command(&current_command, error_buffer);
+ }
+ else
+ {
current_line_position = cpos;
get_word(current_command.name, current_line_position, ' ');
View
129 robo_ed.cpp
@@ -35,6 +35,7 @@
#include "param.h"
#include "char_ed.h"
#include "helpsys.h"
+#include "edit.h"
#define combine_colors(a, b) \
(a) | (b << 4) \
@@ -130,6 +131,7 @@ void robot_editor(World *mzx_world, Robot *cur_robot)
int mark_start;
int mark_end;
int mark_current_line;
+ int show_line_numbers = 0;
robot_line *mark_start_rline;
robot_line *mark_end_rline;
char *ccodes = mzx_world->conf.color_codes;
@@ -263,9 +265,8 @@ void robot_editor(World *mzx_world, Robot *cur_robot)
for(i = first_line_draw_position; (i < 21) && draw_rline; i++)
{
if(i != 11)
- {
- display_robot_line(draw_rline, i, color_code, ccodes);
- }
+ display_robot_line(draw_rline, i, color_code, ccodes);
+
draw_rline = draw_rline->next;
}
@@ -320,13 +321,13 @@ void robot_editor(World *mzx_world, Robot *cur_robot)
{
draw_char(bg_char, mark_color, 1, 11);
key = intake(command_buffer, 240, 2, 11, mark_color, 2, 0, 0,
- &current_x, 1, active_macro);
+ &current_x, 1, active_macro);
}
else
{
draw_char(bg_char, bg_color_solid, 1, 11);
- key = intake(command_buffer, 240, 2, 11, current_line_color,
- 2, 0, 0, &current_x, 1, active_macro);
+ key = intake(command_buffer, 240, 2, 11, current_line_color, 2,
+ 0, 0, &current_x, 1, active_macro);
}
active_macro = NULL;
@@ -542,6 +543,12 @@ void robot_editor(World *mzx_world, Robot *cur_robot)
char *next;
char temp_char = command_buffer[current_x];
+ if(!command_buffer[start_x])
+ start_x--;
+
+ while(start_x && (command_buffer[start_x] == ' '))
+ start_x--;
+
while(start_x && (command_buffer[start_x] != ' '))
start_x--;
@@ -771,6 +778,66 @@ void robot_editor(World *mzx_world, Robot *cur_robot)
break;
}
+ case SDLK_g:
+ {
+ if(get_ctrl_status(keycode_SDL))
+ {
+ char line_number[16];
+
+ line_number[0] = 0;
+
+ save_screen();
+ draw_window_box(18, 12, 47, 14, EC_DEBUG_BOX, EC_DEBUG_BOX_DARK,
+ EC_DEBUG_BOX_CORNER, 1, 1);
+ write_string("Goto line number:", 20, 13, EC_DEBUG_LABEL, 0);
+
+ if(intake(line_number, 7, 38, 13, 15, 1, 0) != SDLK_ESCAPE)
+ {
+ int line = strtol(line_number, NULL, 10);
+ int num_lines;
+
+ if(line > total_lines)
+ line = total_lines;
+
+ if(line < 0)
+ line = 0;
+
+ if(line < current_line)
+ {
+ num_lines = current_line - line;
+
+ for(i = 0; i < num_lines; i++)
+ {
+ current_rline = current_rline->previous;
+ current_line--;
+ }
+ }
+ else
+ {
+ num_lines = line - current_line;
+
+ for(i = 0; i < num_lines; i++)
+ {
+ current_rline = current_rline->next;
+ current_line++;
+ }
+ }
+
+ strcpy(command_buffer, current_rline->line_text);
+ }
+ restore_screen();
+ }
+ break;
+ }
+
+ case SDLK_l:
+ {
+ if(get_ctrl_status(keycode_SDL))
+ show_line_numbers ^= 1;
+
+ break;
+ }
+
case SDLK_d:
{
if(current_rline->validity_status != valid)
@@ -918,6 +985,15 @@ void robot_editor(World *mzx_world, Robot *cur_robot)
break;
}
+
+ // Unmark
+ case SDLK_u:
+ {
+ if(get_alt_status(keycode_SDL))
+ mark_mode = 0;
+
+ break;
+ }
}
} while(key != SDLK_ESCAPE);
@@ -1056,12 +1132,12 @@ void display_robot_line(robot_line *current_rline, int y,
{
temp_char = current_rline->line_text[76];
current_rline->line_text[76] = 0;
- write_string(current_rline->line_text, 2, y, current_color, 0);
+ write_string(current_rline->line_text, x, y, current_color, 0);
current_rline->line_text[76] = temp_char;
}
else
{
- write_string(current_rline->line_text, 2, y, current_color, 0);
+ write_string(current_rline->line_text, x, y, current_color, 0);
}
}
else
@@ -1079,11 +1155,12 @@ void display_robot_line(robot_line *current_rline, int y,
get_word(temp_buffer, line_pos, ' ');
arg_length = strlen(temp_buffer) + 1;
+
+ write_string(temp_buffer, x, y, current_color, 0);
+
line_pos += arg_length;
x += arg_length;
- write_string(temp_buffer, 2, y, current_color, 0);
-
for(i = 0; i < current_rline->num_args; i++)
{
current_arg = current_rline->arg_types[i];
@@ -1362,7 +1439,7 @@ int validate_lines(World *mzx_world, robot_line *current_rline,
if(current_rline->validity_status != valid)
{
memset(error_messages[num_errors], ' ', 64);
- sprintf(error_messages[num_errors], "%05d: ", line_number);
+ sprintf(error_messages[num_errors], "%05d: ", line_number + 1);
assemble_line(current_rline->line_text, null_buffer,
error_messages[num_errors] + 7, NULL, NULL);
error_messages[num_errors][strlen(error_messages[num_errors])] = ' ';
@@ -1699,6 +1776,16 @@ robot_line *clear_block(int first_line, robot_line *first_rline,
current_rline = next_line;
}
+ if(*total_lines == 0)
+ {
+ // Add a new line
+ if(add_blank_line(NULL, previous, size))
+ *total_lines = 1;
+
+ cursor_rline = previous->next;
+ }
+ else
+
if(n_current_line >= first_line)
{
if(n_current_line > (first_line + num_lines))
@@ -1708,17 +1795,17 @@ robot_line *clear_block(int first_line, robot_line *first_rline,
else
{
*current_line = first_line;
- cursor_rline = current_rline;
- }
- }
- if(*total_lines == 0)
- {
- // Add a new line
- if(add_blank_line(NULL, previous, size))
- *total_lines = 1;
-
- cursor_rline = previous->next;
+ if(current_rline)
+ {
+ cursor_rline = current_rline;
+ }
+ else
+ {
+ cursor_rline = previous;
+ *current_line = first_line - 1;
+ }
+ }
}
return cursor_rline;
View
2  robot.h
@@ -203,7 +203,7 @@ void clear_robot_contents(Robot *cur_robot);
void clear_scroll_contents(Scroll *cur_scroll);
// These are part of runrobo2.cpp
-static void magic_load_mod(char *filename);
+void magic_load_mod(World *mzx_world, char *filename);
void save_player_position(World *mzx_world, int pos);
void restore_player_position(World *mzx_world, int pos);
void calculate_blocked(World *mzx_world, int x, int y, int id, int bl[4]);
View
82 runrobo2.cpp
@@ -70,21 +70,27 @@ char *item_to_counter[9] =
"COINS"
};
-// side-effects: mangles the input string
-// bleah; this is so unreadable; just a very quick dirty hack
-static void magic_load_mod(char *filename)
+void magic_load_mod(World *mzx_world, char *filename)
{
+ Board *src_board = mzx_world->current_board;
int mod_name_size = strlen(filename);
if((mod_name_size > 1) && (filename[mod_name_size - 1] == '*'))
{
- filename[mod_name_size - 1] = '\000';
- load_mod(filename);
- load_mod("*");
+ filename[mod_name_size - 1] = 0;
+ if(strcmp(src_board->mod_playing, filename))
+ load_mod(filename);
+
+ src_board->mod_playing[0] = '*';
}
else
{
- load_mod(filename);
+ if(filename[0] != '*')
+ load_mod(filename);
+
+ strcpy(src_board->mod_playing, filename);
}
+
+ strcpy(mzx_world->real_mod_playing, filename);
}
void save_player_position(World *mzx_world, int pos)
@@ -195,27 +201,19 @@ int place_under_xy(Board *src_board, int id, int color, int param, int x,
char *level_under_color = src_board->level_under_color;
char *level_under_param = src_board->level_under_param;
- // This is kinda a new addition, maybe not necessary
- // Dest must be underable, and the source must not be
- if(flags[id] & A_UNDER)
- {
- int offset = x + (y * board_width);
- if(param == 256)
- param = level_under_param[offset];
-
- color = fix_color(color, level_under_color[offset]);
- if(level_under_id[offset] == 122)
- clear_sensor_id(src_board, level_under_param[offset]);
+ int offset = x + (y * board_width);
+ if(param == 256)
+ param = level_under_param[offset];
- // Put it now.
- level_under_id[offset] = id;
- level_under_color[offset] = color;
- level_under_param[offset] = param;
+ color = fix_color(color, level_under_color[offset]);
+ if(level_under_id[offset] == 122)
+ clear_sensor_id(src_board, level_under_param[offset]);
- return 1;
- }
+ level_under_id[offset] = id;
+ level_under_color[offset] = color;
+ level_under_param[offset] = param;
- return 0;
+ return 1;
}
int place_dir_xy(World *mzx_world, int id, int color, int param, int x, int y,
@@ -1668,13 +1666,13 @@ void run_robot(World *mzx_world, int id, int x, int y)
case 14: // sppressed
{
- success = get_key_status(keycode_SDL, SDLK_SPACE);
+ success = get_key_status(keycode_SDL, SDLK_SPACE) > 0;
break;
}
case 15: // delpressed
{
- success = get_key_status(keycode_SDL, SDLK_DELETE);
+ success = get_key_status(keycode_SDL, SDLK_DELETE) > 0;
break;
}
@@ -1832,6 +1830,7 @@ void run_robot(World *mzx_world, int id, int x, int y)
if(check_param == 256)
{
int i;
+
for(i = check_color; i < MAX_SPRITES; i++)
{
if(sprite_at_xy(mzx_world->sprite_list[i], check_x,
@@ -1901,11 +1900,11 @@ void run_robot(World *mzx_world, int id, int x, int y)
if(check_at_xy(src_board, check_id, fg, bg, check_param,
offset))
{
-
char *p6 = next_param_pos(p5);
gotoed = send_self_label_tr(mzx_world, p6 + 1, id);
}
}
+
break;
}