Skip to content

Commit

Permalink
MegaZeux 2.62 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
adelva1984 committed Aug 11, 2008
1 parent 560212b commit 70292ce
Show file tree
Hide file tree
Showing 10 changed files with 7,205 additions and 6,963 deletions.
Binary file modified MZX_CMOD.FIL
Binary file not shown.
110 changes: 53 additions & 57 deletions counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@

#include "counter.h"

#include "bwsb.h"
#include "egacode.h"
#include "admath.h"
#include "blink.h"
#include "const.h"
#include "cursor.h"
#include "data.h"
#include "egacode.h"
#include "game.h"
#include "game2.h"
#include "graphics.h"
Expand All @@ -52,6 +52,8 @@
#include "struct.h"
#include "conio.h"

long offset;
char fileio;

// I took away the mzxakversion stuff. So you no longer
// have to set "mzxakversion" to 1. -Koji
Expand All @@ -63,23 +65,17 @@ int dir,dirx,diry,loc;
struct time t;
struct date d;

//File stuff
FILE *inputfile;
FILE *outputfile;
long offset;
char fileio;

void set_built_in_messages(int param);

int player_restart_x=0,player_restart_y=0,gridxsize=1,gridysize=1;
int myscrolledx=0,myscrolledy=0;
//int MZXAKWENDEVERSION = 0;
//Some added variables to speed up pixel editing -Koji
unsigned char pixel_x = 0, pixel_y = 0;
//if (inputfile != NULL)
// fclose(inputfile);
//if (outputfile != NULL)
// fclose(outputfile);
//if (input_file != NULL)
// fclose(input_file);
//if (output_file != NULL)
// fclose(output_file);

char was_zapped=0;
extern char mid_prefix;
Expand Down Expand Up @@ -133,78 +129,74 @@ int get_counter(char far *name,unsigned char id) {
//Read binary positions of "INT" ("bit_place" = 0-15) - Koji
if(!str_cmp(name,"INT2BIN"))
{
unsigned int integer;
int bin_mask, place;
place = ((get_counter("BIT_PLACE") % 16) * -1) + 15;
integer = get_counter("INT") + 32768;
bin_mask = (32768 >> place);
return (integer & bin_mask) >> (15 - place);
int place = (get_counter("BIT_PLACE") & 15);
return (get_counter("INT") & (1 << place)) >> place;
}

//Open inputfile! -Koji
//Open input_file! -Koji
if(!str_cmp(name,"FREAD_OPEN"))
{
fileio = 1;
return 0;
}

//opens outputfile as normal. -Koji
//opens output_file as normal. -Koji
if(!str_cmp(name,"FWRITE_OPEN"))
{
fileio = 2;
return 0;
}

//Opens outputfile as APPEND. -Koji
//Opens output_file as APPEND. -Koji
if(!str_cmp(name,"FWRITE_APPEND"))
{
fileio = 3;
return 0;
}

//Reads from inputfile. -Koji
//Reads from input_file. -Koji
if(!str_cmp(name,"FREAD"))
{
if(inputfile == NULL) return -1;
return fgetc(inputfile);
if(input_file == NULL) return -1;
return fgetc(input_file);
}

//Ok, ok. I did steal the "pos" within "page" idea from Akwende.
//It is a great idea to be able to read more than 32767 bytes.
// -Koji
if(!str_cmp(name,"FREAD_POS"))
{
if(inputfile == NULL) return -1;
return (ftell(inputfile) % 32767);
if(input_file == NULL) return -1;
return (ftell(input_file) % 32767);
}

if(!str_cmp(name,"FREAD_PAGE"))
{
if(inputfile == NULL) return -1;
return (ftell(inputfile) / 32767);
if(input_file == NULL) return -1;
return (ftell(input_file) / 32767);
}

if(!str_cmp(name,"FWRITE_POS"))
{
if(outputfile == NULL) return -1;
return (ftell(outputfile) % 32767);
if(output_file == NULL) return -1;
return (ftell(output_file) % 32767);
}

if(!str_cmp(name,"FWRITE_PAGE"))
{
if(outputfile == NULL) return -1;
return (ftell(outputfile) / 32767);
if(output_file == NULL) return -1;
return (ftell(output_file) / 32767);
}
if(!str_cmp(name,"FREAD_LENGTH"))
{
if(inputfile == NULL) return -1;
return filelength(fileno(inputfile));
if(input_file == NULL) return -1;
return filelength(fileno(input_file));
}

if(!str_cmp(name,"FWRITE_LENGTH"))
{
if(outputfile == NULL) return -1;
return filelength(fileno(outputfile));
if(output_file == NULL) return -1;
return filelength(fileno(output_file));
}


Expand Down Expand Up @@ -401,6 +393,10 @@ int get_counter(char far *name,unsigned char id) {

if(!str_cmp(name,"THIS_COLOR"))
return level_color[robots[id].ypos * board_xsiz + robots[id].xpos];

if(!str_cmp(name, "MOD_ORDER"))
return MusicOrder(0xFF);

/*
if(!str_cmp(name,"GET_TARGET_ID"))
{
Expand Down Expand Up @@ -484,25 +480,25 @@ void set_counter(char far *name,int value,unsigned char id) {
if(fileio == 1)
{
//read
if(inputfile != NULL)
fclose(inputfile);
inputfile = fopen(name,"rb");
if(input_file != NULL)
fclose(input_file);
input_file = fopen(name,"rb");
}

if(fileio == 2)
{
//write
if(outputfile != NULL)
fclose(outputfile);
outputfile = fopen(name,"wb");
if(output_file != NULL)
fclose(output_file);
output_file = fopen(name,"wb");
}

if(fileio == 3)
{
//Append
if(outputfile != NULL)
fclose(outputfile);
outputfile = fopen(name,"ab");
if(output_file != NULL)
fclose(output_file);
output_file = fopen(name,"ab");
}

fileio = 0;
Expand All @@ -516,44 +512,44 @@ void set_counter(char far *name,int value,unsigned char id) {
// -Koji
if(!str_cmp(name,"FREAD_POS"))
{
if(inputfile == NULL)
if(input_file == NULL)
return;
offset = 32767 * get_counter("FREAD_PAGE") + value;
fseek(inputfile,offset,0);
fseek(input_file,offset,0);
}

if(!str_cmp(name,"FREAD_PAGE"))
{
value %= 256;
if(inputfile == NULL)
if(input_file == NULL)
return;
offset = 32767 * value + get_counter("FREAD_POS");
fseek(inputfile,offset,0);
fseek(input_file,offset,0);
}

if(!str_cmp(name,"FWRITE_POS"))
{
if(outputfile == NULL)
if(output_file == NULL)
return;
offset = 32767 * get_counter("FWRITE_PAGE") + value;
fseek(outputfile,offset,0);
fseek(output_file,offset,0);
}

if(!str_cmp(name,"FWRITE_PAGE"))
{
value %= 256;
if(outputfile == NULL)
if(output_file == NULL)
return;
offset = 32767 * value + get_counter("FWRITE_POS");
fseek(outputfile,offset,0);
fseek(output_file,offset,0);
}

//Writes to the outputfile. -Koji
//Writes to the output_file. -Koji
if(!str_cmp(name,"FWRITE"))
{
if(outputfile == NULL)
if(output_file == NULL)
return;
fputc(value % 256,outputfile);
fputc(value % 256,output_file);
return;
}

Expand Down Expand Up @@ -713,7 +709,7 @@ void set_counter(char far *name,int value,unsigned char id) {
return;
}
/* //Silly Akwende we already have a variable that does
//This. It's called "bulltettype" -Koji
//This. It's called "bullettype" -Koji
if(!str_cmp(name,"BULLET_TYPE"))
{
robots[id].bullet_type=value;
Expand Down Expand Up @@ -744,7 +740,7 @@ void set_counter(char far *name,int value,unsigned char id) {
overall_speed=value;
return;
}
//Took out the Number contraints. -Koji
//Took out the Number constraints. -Koji
if(!str_cmp(name,"BULLETTYPE")) {
robots[id].bullet_type=value;
return;
Expand Down
7 changes: 5 additions & 2 deletions counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
#ifndef __COUNTER_H
#define __COUNTER_H

#include <stdio.h>

extern FILE *input_file;
extern FILE *output_file;
extern int player_restart_x;
extern int player_restart_y;
extern char was_zapped;


#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -50,4 +53,4 @@ char give_key(char color);
}
#endif

#endif
#endif
1 change: 1 addition & 0 deletions data.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "const.h"
#include "struct.h"
#include <stdio.h>

/* This first section is from IDPUT.ASM */
extern unsigned char id_chars[455];
Expand Down
4 changes: 3 additions & 1 deletion data2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "const.h"
#include "struct.h"

extern FILE *output_file = NULL;
extern FILE *input_file = NULL;
Robot far *robots=NULL;//NUM_ROBOTS in size
Scroll far *scrolls=NULL;//NUM_SCROLLS in size
Counter far *counters=NULL;//NUM_COUNTERS in size
Expand Down Expand Up @@ -175,4 +177,4 @@ char far *thing_names[128]={
"Robot",
"Sign",
"Scroll",
"Player" };
"Player" };
Loading

0 comments on commit 70292ce

Please sign in to comment.