Skip to content

Commit

Permalink
add Lua scripting stub
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Oct 20, 2011
1 parent ad4fa70 commit 3e700df
Show file tree
Hide file tree
Showing 21 changed files with 5,041 additions and 29 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ else ifeq ($(P),win)
NASM_FORMAT = win32
EXEEXT = .exe
SOEXT = .pyd
PLATOBJ = master/app.o master/conf.o master/dinp.o master/disp.o master/dsound.o master/emu.o master/frame.o master/input.o master/load.o master/loop.o master/main.o master/misc.o master/python.o master/render.o master/run.o master/shot.o master/state.o master/video.o master/zipfn.o master/keymap.o zlib/libz.a master/ramwatch.o master/ramsearch.o
PLATOBJ = master/app.o master/conf.o master/dinp.o master/disp.o master/dsound.o master/emu.o master/frame.o master/input.o master/load.o master/loop.o master/main.o master/misc.o master/python.o master/render.o master/run.o master/shot.o master/state.o master/video.o master/zipfn.o master/keymap.o zlib/libz.a master/ramwatch.o master/ramsearch.o master/luaconsole.o master/luasav.o master/luaengine.o
PLATPYOBJ =
PLATPYOBJCXX =
EXTRA_LIBS = -ldsound -ldinput -lddraw -ldxguid -lcomdlg32 -lcomctl32 -luser32 -lwinmm
EXTRA_LIBS = -ldsound -ldinput -lddraw -ldxguid -lcomdlg32 -lcomctl32 -luser32 -lwinmm -llua51 -lgdi32
DOZE_FIXUP =
ENCODER_OBJ = tools/wdegavi.o tools/degavirc.o
ENCODER_LIBS = libvfw/libvfw.a
Expand All @@ -94,11 +94,11 @@ else ifeq ($(P),win)
PYTHON_LDFLAGS = -L$(PYTHON_PREFIX)/libs -lpython27
endif

ALLOBJ = dega-s$(EXEEXT) mmvconv$(EXEEXT) degavi$(EXEEXT)
ALLOBJ = dega-s$(EXEEXT) # mmvconv$(EXEEXT) degavi$(EXEEXT)

ifneq ($(BITS),64)
ALLOBJ += pydega$(SOEXT)
endif
#ifneq ($(BITS),64)
#ALLOBJ += pydega$(SOEXT)
#endif

ifeq ($(P),unix)

Expand Down Expand Up @@ -191,7 +191,7 @@ clean:
rm -f $(Z80OBJ) $(DAMOBJ) $(MASTOBJ) $(PLATOBJ) $(PYOBJ) $(PYEMBOBJ) $(PLATPYOBJ) $(PLATPYOBJCXX) tools/avioutput.o tools/degavi.o tools/degavirc.o tools/mmvconv.o tools/wdegavi.o doze/dozea.asm* doze/dam doze/dam.exe dega dega.exe degavi degavi.exe mmvconv mmvconv.exe pydega.so pydega.dll pydega.pyd specs
make -Czlib clean
make -Clibmencoder clean
make -Clibvfw clean
# make -Clibvfw clean

distclean: clean
rm -f *~ */*~
1 change: 1 addition & 0 deletions libvfw/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
CC = gcc
CFLAGS = -O3 --std=c99

OBJS = libvfw.o
Expand Down
Binary file removed libvfw/example.exe
Binary file not shown.
4 changes: 2 additions & 2 deletions mast/emu2413.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
extern "C" {
#endif

#pragma warning (disable:4514) // Dave added
#pragma warning (disable:4710) // Dave added
//#pragma warning (disable:4514) // Dave added
//#pragma warning (disable:4710) // Dave added

#ifdef EMU2413_DLL_EXPORTS
#define EMU2413_API __declspec(dllexport)
Expand Down
4 changes: 2 additions & 2 deletions mast/mastint.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ extern "C" {
// Make the INLINE macro
#undef INLINE
#define INLINE inline
#pragma warning (disable:4514) //disable "unreferenced inline function removed" warning message
#pragma warning (disable:4710) //disable "function not inlined" warning message
//#pragma warning (disable:4514) //disable "unreferenced inline function removed" warning message
//#pragma warning (disable:4710) //disable "function not inlined" warning message

// Chip emulators ------------------------------------------------
// #define EMU_DOZE // Use my 'Doze' Assembler Z80 emulator
Expand Down
5 changes: 3 additions & 2 deletions mast/video.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "mastint.h"
#include "../master/luaengine.h"
#include <stdio.h>
#ifdef unix
#include <unistd.h>
Expand Down Expand Up @@ -304,7 +305,7 @@ static void MvidOldPostLoadState(int readonly) {

videoFile = fopen(videoFilename, "r+b");
Truncate(videoFile, newPosition);
currentMovie.rerecordCount++;
if(!DEGA_LuaRerecordCountSkip()) currentMovie.rerecordCount++;

fseek(videoFile, 0xc, SEEK_SET);
fwrite(&currentMovie.rerecordCount, 4, 1, videoFile);
Expand Down Expand Up @@ -359,7 +360,7 @@ void MvidPostLoadState(int readonly) {
ma.Len = frameCount*embPacketSize; ma.Data = data;
MastAcb(&ma);

currentMovie.rerecordCount++;
if(!DEGA_LuaRerecordCountSkip()) currentMovie.rerecordCount++;

currentMovie.vidFrameCount = frameCount;

Expand Down
21 changes: 21 additions & 0 deletions master/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@

#include "../mast/mast.h"
#include "resource.h"
#include "luaengine.h"
#include "luaconsole.h"

typedef char s8;
typedef short s16;
typedef long s32;
typedef long long s64;

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;
typedef unsigned long long u64;

typedef char INT8;
typedef short INT16;
typedef long long INT64;

typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned long long UINT64;

// Make the INLINE macro
#undef INLINE
Expand Down Expand Up @@ -175,6 +195,7 @@ extern char StateName[];
extern int AutoLoadSave;
extern int VideoReadOnly;
extern int SaveSlot;
char *MakeAutoName(int Battery, int Slot);
int StateLoad(int Meka);
int StateSave(int Meka);
int StateAuto(int Save);
Expand Down
22 changes: 22 additions & 0 deletions master/app.rc
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ BEGIN
END
POPUP "&Tools"
BEGIN
POPUP "Lua Scripting..."
BEGIN
MENUITEM "&New Lua Script Window...", ID_LUA_OPEN
MENUITEM "&Close All Script Windows", ID_LUA_CLOSE_ALL, GRAYED
END
MENUITEM SEPARATOR
MENUITEM "RAM Search", ID_RAM_SEARCH
MENUITEM "RAM Watch", ID_RAM_WATCH
END
Expand Down Expand Up @@ -486,6 +492,22 @@ BEGIN
LTEXT " ",IDC_PROMPT_TEXT,13,7,163,8
END

IDD_LUA DIALOGEX 0, 0, 270, 150
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Lua Script"
MENU LUAWINDOW_MENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
PUSHBUTTON "Browse...",IDC_BUTTON_LUABROWSE,7,31,48,16
PUSHBUTTON "Run",IDC_BUTTON_LUARUN,213,31,50,16
PUSHBUTTON "Stop",IDC_BUTTON_LUASTOP,160,31,50,16
EDITTEXT IDC_EDIT_LUAPATH,7,16,256,14,ES_AUTOHSCROLL
EDITTEXT IDC_LUACONSOLE,7,61,256,81,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL
LTEXT "Output Console",IDC_STATIC,7,51,51,8
LTEXT "Script File",IDC_STATIC,7,7,32,8
PUSHBUTTON "Edit",IDC_BUTTON_LUAEDIT,58,31,46,16
END

RAMWATCH_MENU MENU
BEGIN
POPUP "File"
Expand Down
2 changes: 1 addition & 1 deletion master/disp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ unsigned char *DispMem=NULL;
int DispMemPitch=0;
unsigned int DispFormat=0; // Either a FourCC code or a color depth
int DispBpp=0; // Bytes per pixel
int TryOverlay=2;
int TryOverlay=0;
static int OverlayColor=0;
static RECT LastOver={0,0,0,0}; // Last overlay rectangle

Expand Down
16 changes: 14 additions & 2 deletions master/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,27 @@ static LRESULT CALLBACK WindowProc(HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lPara
// if (Item==ID_PYTHON_LOAD) { MenuPython(0); return 0; }
// if (Item==ID_PYTHON_LOAD_THREAD) { MenuPython(1); return 0; }
// if (Item==ID_PYTHON_MEMORY) { MenuPythonFixed("memory.py", 1); return 0; }
if (Item==ID_RAM_SEARCH) {

if (Item==ID_LUA_OPEN) {
if(!LuaConsoleHWnd) {
LuaConsoleHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_LUA), NULL, (DLGPROC) DlgLuaScriptDialog);
}
else
SetForegroundWindow(LuaConsoleHWnd);
}
if (Item==ID_LUA_CLOSE_ALL) {
if(LuaConsoleHWnd)
PostMessage(LuaConsoleHWnd, WM_CLOSE, 0, 0);
}
if (Item==ID_RAM_SEARCH) {
if(!RamSearchHWnd) {
reset_address_info();
RamSearchHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_RAMSEARCH), NULL, (DLGPROC) RamSearchProc);
}
else
SetForegroundWindow(RamSearchHWnd);
}
if (Item==ID_RAM_WATCH) {
if (Item==ID_RAM_WATCH) {
if(!RamWatchHWnd) {
RamWatchHWnd = CreateDialog(hAppInst, MAKEINTRESOURCE(IDD_RAMWATCH), NULL, (DLGPROC) RamWatchProc);
}
Expand Down
1 change: 1 addition & 0 deletions master/loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static int MediaInit(int Level)
if (MastEx&MX_GG) { ScrnWidth=160; ScrnHeight=144; } // Game gear
else { ScrnWidth=256; ScrnHeight=192; } // Master System

CallRegisteredLuaFunctions(LUACALL_ONSTART);
}

if (Level<=30) // DirectDraw
Expand Down
Loading

0 comments on commit 3e700df

Please sign in to comment.