Skip to content

Commit

Permalink
closer to run Henne#1
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-zateryukin committed Nov 6, 2021
1 parent da8d9fb commit 3dedd03
Show file tree
Hide file tree
Showing 14 changed files with 516 additions and 520 deletions.
2 changes: 2 additions & 0 deletions include/custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ void custom_init(Section *sec);
/* prototypes for Execution operations */
void custom_init_prog(char *, Bit16u, Bit16u, Bit16u);
void custom_exit_prog(Bit8u);
void custom_init_entrypoint(char *, Bit16u);

/* prototypes for CPU operations */
int custom_callf(Bitu, Bitu);
Expand All @@ -38,6 +39,7 @@ static inline void custom_init(Section *sec) { }
/* prototypes for Execution operations */
static inline void
custom_init_prog(char *name, Bit16u relocate, Bit16u init_cs, Bit16u init_ip) { }
static inline void custom_init_entrypoint(char *, Bit16u) { }

static inline void custom_exit_prog(Bit8u exitcode) { }

Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ endif
dosbox_SOURCES = dosbox.cpp $(ico_stuff)
dosbox_LDADD = cpu/libcpu.a debug/libdebug.a dos/libdos.a fpu/libfpu.a hardware/libhardware.a gui/libgui.a \
ints/libints.a misc/libmisc.a shell/libshell.a hardware/mame/libmame.a \
hardware/serialport/libserial.a libs/gui_tk/libgui_tk.a custom/libcustom.a custom/schick/libschick.a custom/schick/rewrite_m302de/libschick_rewrite_m302de.a custom/schick/rewrite_g105de/libschick_rewrite_g105de.a custom/schweif/libschweif.a custom/schweif/rewrite_c102de/libschweif_rewrite_c102de.a
hardware/serialport/libserial.a libs/gui_tk/libgui_tk.a custom/libcustom.a custom/src/libsrc.a

EXTRA_DIST = winres.rc dosbox.ico

Expand Down
2 changes: 1 addition & 1 deletion src/custom/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AM_CPPFLAGS = -I$(top_srcdir)/include -Wall -pedantic -DDOSBOX -O0 -mno-ms-bitfields -Wno-multichar -Wno-address-of-packed-member -I/include/ncurses -I. -L. -ggdb3 -lSDL -std=c++11 -DDEBUG=3 -Wno-unused-variable -Wno-strict-aliasing
AM_CPPFLAGS = -I$(top_srcdir)/include -Wall -pedantic -DDOSBOX -O0 -mno-ms-bitfields -Wno-multichar -Wno-address-of-packed-member -I/include/ncurses -I. -L. -ggdb3 -lSDL -std=c++11 -DDEBUG=3 -Wno-unused-variable -Wno-strict-aliasing -I./src/

SUBDIRS = src # schick schweif

Expand Down
2 changes: 1 addition & 1 deletion src/custom/asm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ bool is_little_endian();
#define ORG(x)
#define XLATB XLAT

typedef unsigned short _offsets;
typedef dd _offsets;
/*
#ifndef __BORLANDC__
enum _offsets : int;
Expand Down
55 changes: 28 additions & 27 deletions src/custom/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
#include "custom_hooks.h"

#include "asm.h"
#include "init.h"

static Bit8u custom_runs;

static Bit8u schick_runs;
static Bit8u schweif_runs;
static Bit8u init_runs;
Bit16u custom_oldCS, custom_oldIP;
//static class custom_prog running_progs[2];

Expand All @@ -29,13 +30,9 @@ void custom_init_prog(char *name, Bit16u relocate, Bit16u init_cs, Bit16u init_i
*/

/* run all detectors */
if (init_schick(name, relocate, init_cs, init_ip)) {
custom_runs++;
schick_runs++;
}
if (schweif_init(name, relocate, init_cs, init_ip)) {
if (masm2c_init(name, relocate, init_cs, init_ip)) {
custom_runs++;
schweif_runs++;
init_runs++;
}
}

Expand All @@ -45,43 +42,37 @@ void custom_exit_prog(Bit8u exitcode)
return;

custom_runs--;
if (schick_runs) {
exit_schick(exitcode);
schick_runs--;
}
if (schweif_runs) {
schweif_exit(exitcode);
schweif_runs--;
if (init_runs) {
masm2c_exit(exitcode);
init_runs--;
}
}

int custom_calln(Bit16u IP)
{
return 0;
/*
custom_oldCS = SegValue(cs);
custom_oldIP = reg_ip;
if (!custom_runs)
return 0;
if (schick_runs)
return schick_calln16(IP);

if (schweif_runs)
return schweif_calln(IP);
if (init_runs)
return init_calln16(IP);
return 0;
*/
}

int custom_callf(Bitu CS, Bitu IP)
{
custom_oldCS = SegValue(cs);
custom_oldCS = cs; //SegValue(cs);
custom_oldIP = reg_ip;
if (!custom_runs)
return 0;

if (schick_runs)
return schick_callf(CS, IP);
if (schweif_runs)
return schweif_callf(CS, IP);
if (init_runs)
return init_callf(CS, IP);

return 0;
}
Expand All @@ -95,7 +86,7 @@ void custom_init(Section *sec)
{
// custom_prog *p_current = new custom_prog;
sec->AddDestroyFunction(&custom_exit);
fprintf(stderr, "Bright Eyes, build date %s\n", __DATE__);
fprintf(stderr, "Masm2c/DOSBOX lib, build date %s\n", __DATE__);

//struct _STATE* _state;
X86_REGREF
Expand All @@ -110,10 +101,20 @@ X86_REGREF
fprintf(stderr, "%d:%d:%d\n", ch,cl,dh);
R(MOV(ax,0x3000));
R(_INT(0x21));
fprintf(stderr, "DOS:%d\n", al);
fprintf(stderr, "DOS ver:%d\n", al);
R(MOV(ah,2));
R(MOV(dl,'R'));
R(_INT(0x21));
}

void custom_init_entrypoint(char *name, Bit16u relocate)
{
if (!custom_runs)
return;

if (init_runs) {
init_entrypoint(relocate);
}

}
#endif /* DOSBOX_CUSTOM */
37 changes: 5 additions & 32 deletions src/custom/custom_hooks.h
Original file line number Diff line number Diff line change
@@ -1,40 +1,13 @@
#define DOSBOX_SCHICK_H
#define DOSBOX_SCHWEIF_H
#define DOSBOX_masm2c_H

#ifdef DOSBOX_CUSTOM

#ifdef DOSBOX_SCHICK_H
/* prototypes for Execution operations */
bool init_schick(char *, unsigned short, unsigned short, unsigned short);
void exit_schick(unsigned char);
bool masm2c_init(char *, unsigned short, unsigned short, unsigned short);
void masm2c_exit(unsigned char);

/* prototypes for CPU operations */
int schick_callf(unsigned, unsigned);
int schick_calln16(unsigned);
#else /* DOSBOX_SCHICK_H */
/* prototypes for Execution operations */
inline bool init_schick(char *, unsigned short, unsigned short, unsigned short) { return false; };
inline void exit_schick(unsigned char) {};

/* prototypes for CPU operations */
inline int schick_callf(unsigned, unsigned) {return 0;};
inline int schick_calln16(unsigned) {return 0;};
#endif /* DOSBOX_SCHICK_H */


#ifdef DOSBOX_SCHWEIF_H
/* prototypes for Execution operations */
bool schweif_init(char *, unsigned short, unsigned short, unsigned short);
void schweif_exit(unsigned char);

/* prototypes for CPU operations */
int schweif_callf(unsigned, unsigned);
int schweif_calln(unsigned);
#else /* DOSBOX_SCHWEIF_H */
static inline bool schweif_init(char *, unsigned short, unsigned short, unsigned short) { return false; }
static inline void schweif_exit(unsigned char) {}
static inline int schweif_callf(unsigned, unsigned) {return 0;}
static inline int schweif_calln(unsigned) {return 0;}
#endif /* DOSBOX_SCHWEIF_H */
int masm2c_callf(unsigned, unsigned);
int masm2c_calln16(unsigned);

#endif /* DOSBOX_CUSTOM */
2 changes: 1 addition & 1 deletion src/custom/src/_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ struct Memory& m = mm;
db(& stack)[STACK_SIZE]=m.stack;
db(& heap)[HEAP_SIZE]=m.heap;
}
db (& dummy1)[65536] = m2c::m.dummy1;
db (& dummy1)[0x1dd0] = m2c::m.dummy1;
db (& data)[0] = m2c::m.data;
char (& msg)[28] = m2c::m.msg;
db& instructions = m2c::m.instructions;
Expand Down
4 changes: 2 additions & 2 deletions src/custom/src/_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#pragma pack(push, 1)
namespace m2c{
struct Memory{
db dummy1[65536];
db dummy1[0x1dd0];
db data[0];
char msg[28];
db instructions;
Expand Down Expand Up @@ -81,7 +81,7 @@ db dummy56;
db dummy57;
db dummy58;
db seg001[0];

db filll[1024*1024*16];
db stack[STACK_SIZE];
db heap[HEAP_SIZE];
};
Expand Down
10 changes: 9 additions & 1 deletion src/custom/src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool masm2c_init(char *name, unsigned short reloc, unsigned short _cs, unsigned

init_get_fname(fname, name);

//if (strcmp(fname, "snake.exe"))) return false;
if (strcmp(fname, "snake.exe")) return false;

/* Check CS:IP in the EXE-Header are 0:0
* and the first executed instruction is mov dx,i16 */
Expand Down Expand Up @@ -170,3 +170,11 @@ int init_calln16(unsigned offs) {

return ret;
}

//namespace m2c{ m2cf* _ENTRY_POINT_; }
void init_entrypoint(Bit16u relocate)
{
m2c::log_debug("Starting program\n");
m2c::Initializer();
(*m2c::_ENTRY_POINT_)(0,0);
}
1 change: 1 addition & 0 deletions src/custom/src/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ void BE_cleanup();

int init_callf(unsigned selector, unsigned offs);

void init_entrypoint(Bit16u relocate);
//void init_status_init();
void init_status_exit();
void init_status_enable();
Expand Down
Loading

0 comments on commit 3dedd03

Please sign in to comment.