Commit 8aeb1aac authored by Florian Schulze's avatar Florian Schulze

Fixes for SDL and VisualC.

parent f3895b36
# Microsoft Developer Studio Project File - Name="jumpnbump" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** NICHT BEARBEITEN **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=jumpnbump - Win32 Debug
!MESSAGE Dies ist kein gltiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und fhren Sie den Befehl
!MESSAGE
!MESSAGE NMAKE /f "jumpnbump.mak".
!MESSAGE
!MESSAGE Sie knnen beim Ausfhren von NMAKE eine Konfiguration angeben
!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
!MESSAGE
!MESSAGE NMAKE /f "jumpnbump.mak" CFG="jumpnbump - Win32 Debug"
!MESSAGE
!MESSAGE Fr die Konfiguration stehen zur Auswahl:
!MESSAGE
!MESSAGE "jumpnbump - Win32 Release" (basierend auf "Win32 (x86) Application")
!MESSAGE "jumpnbump - Win32 Debug" (basierend auf "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "jumpnbump - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# 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 "../" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "USE_SDL" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x407 /d "NDEBUG"
# ADD RSC /l 0x407 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDLmain.lib SDL.lib SDL_mixer.lib /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "jumpnbump - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# 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 /MDd /W3 /Gm /GX /ZI /Od /I "../" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "USE_SDL" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x407 /d "_DEBUG"
# ADD RSC /l 0x407 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib SDLmain.lib SDL.lib SDL_mixer.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "jumpnbump - Win32 Release"
# Name "jumpnbump - Win32 Debug"
# Begin Group "Quellcodedateien"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\sdl\gfx.c
# End Source File
# Begin Source File
SOURCE=..\sdl\interrpt.c
# End Source File
# Begin Source File
SOURCE=..\main.c
# End Source File
# Begin Source File
SOURCE=..\menu.c
# End Source File
# Begin Source File
SOURCE=..\sdl\sound.c
# End Source File
# End Group
# Begin Group "Header-Dateien"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\config.h
# End Source File
# Begin Source File
SOURCE=..\dj.h
# End Source File
# Begin Source File
SOURCE=..\globals.h
# End Source File
# End Group
# Begin Group "Ressourcendateien"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELSCHT WERDEN!
###############################################################################
Project: "jumpnbump"=.\jumpnbump.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
#ifndef __CONFIG_H
#define __CONFIG_H
#undef DOS
#ifndef DOS
# define LINUX
#endif
#ifdef LINUX
# define NOSOUND
#ifdef USE_SDL
# define JNB_WIDTH 400
# define JNB_HEIGHT 256
#endif
......
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#ifdef DOS
#include <pc.h>
#include <dpmi.h>
#include <go32.h>
#include <sys/nearptr.h>
#endif
#define DJ_SD_TYPE_NOSOUND 0
#define DJ_SD_TYPE_SBLASTER 1
......
......@@ -132,17 +132,17 @@ void put_text(char page, int x, int y, char *text, char align)
image = t1 - 49;
else if (t1 == '~')
image = 74;
else if (t1 == '')
else if (t1 == 0x84)
image = 75;
else if (t1 == '')
else if (t1 == 0x86)
image = 76;
else if (t1 == '')
else if (t1 == 0x8e)
image = 77;
else if (t1 == '')
else if (t1 == 0x8f)
image = 78;
else if (t1 == '')
else if (t1 == 0x94)
image = 79;
else if (t1 == '')
else if (t1 == 0x99)
image = 80;
else
continue;
......
......@@ -6,7 +6,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef _MSC_VER
#include <strings.h>
#endif
#include <time.h>
#include <math.h>
#include <dj.h>
......@@ -18,10 +20,17 @@
# include <pc.h>
#endif
#ifdef USE_SDL
#ifdef _MSC_VER
# include <sys/stat.h>
# include <SDL/SDL.h>
# include <SDL/SDL_mixer.h>
# include <io.h>
# include <SDL.h>
# include <SDL_mixer.h>
#else
# ifdef USE_SDL
# include <sys/stat.h>
# include <SDL/SDL.h>
# include <SDL/SDL_mixer.h>
# endif
#endif
#ifndef USE_SDL
......@@ -164,7 +173,7 @@ void position_player(short player_num);
void fireworks(void);
void add_object(char type, short x, short y, long x_add, long y_add, short anim, short frame);
void update_objects(void);
char add_pob(char page, short x, short y, short image, char *pob_data);
char add_pob(int page, short x, short y, short image, char *pob_data);
void draw_pobs(int page);
void redraw_pob_backgrounds(int page);
char add_leftovers(int page, short x, short y, short image, char *pob_data);
......@@ -212,13 +221,16 @@ char read_pcx(FILE * handle, char *buffer, long buf_len, char *pal);
void get_block(char page, long x, long y, long width, long height, char *buffer);
void put_block(char page, long x, long y, long width, long height, char *buffer);
#ifdef LINUX
#ifdef USE_SDL
#ifndef _MSC_VER
long filelength(int handle);
#endif
void setpalette(int index, int count, char *palette);
void fillpalette(int red, int green, int blue);
void flippage(long page);
void fs_toggle();
char *get_vgaptr(long, long, long);
char intr_sysupdate();
#endif
/* interrpt.c */
......@@ -229,18 +241,9 @@ char hook_keyb_handler(void);
void remove_keyb_handler(void);
char key_pressed(unsigned char key);
#ifdef LINUX
char intr_sysupdate();
#endif
/* sound-linux.c */
#ifdef LINUX
void load_song(FILE *, signed int);
void play_song();
void update_song();
void initsound();
void songquit();
#endif
......
indent -kr -i8 -l1000 -lps -nhnl
......@@ -5,6 +5,10 @@
__dpmi_regs regs;
#endif
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
char *object_gobs;
char *number_gobs;
......@@ -811,7 +815,7 @@ void steer_players(void)
if ((c1 == 0 && ((key_pressed(KEY_PL1_LEFT) == 1 && key_pressed(KEY_PL1_RIGHT) == 1))) || (c1 == 1 && ((key_pressed(KEY_PL2_LEFT) == 1 && key_pressed(KEY_PL2_RIGHT) == 1))) || (c1 == 2 && ((key_pressed(KEY_PL3_LEFT) == 1 && key_pressed(KEY_PL3_RIGHT) == 1))) || (c1 == 3 && ((key_pressed(KEY_PL4_LEFT) == 1 && key_pressed(KEY_PL4_RIGHT) == 1)))) {
if (player[c1].direction == 0) {
if ((c1 == 0 && key_pressed(KEY_PL1_RIGHT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_RIGHT) == 1) || (c1 == 2 && key_pressed(KEY_PL3_RIGHT) == 1) || (c1 == 3 && key_pressed(KEY_PL4_RIGHT) == 1 mouse.but2 == 1)) {
if ((c1 == 0 && key_pressed(KEY_PL1_RIGHT) == 1) || (c1 == 1 && key_pressed(KEY_PL2_RIGHT) == 1) || (c1 == 2 && key_pressed(KEY_PL3_RIGHT) == 1) || (c1 == 3 && key_pressed(KEY_PL4_RIGHT) == 1)) {
s1 = (player[c1].x >> 16);
s2 = (player[c1].y >> 16);
if (ban_map[(s2 + 16) >> 4][(s1 + 8) >> 4] == 3) {
......@@ -2008,6 +2012,7 @@ char init_program(int argc, char *argv[])
int c1 = 0, c2 = 0;
char load_flag = 0;
char force2, force3;
sfx_data fly;
int player_anim_data[] = {
1, 0, 0, 0x7fff, 0, 0, 0, 0, 0, 0,
4, 0, 0, 4, 1, 4, 2, 4, 3, 4,
......@@ -2404,9 +2409,6 @@ void deinit_program(void)
#ifdef DOS
regs.x.ax = 0x3;
__dpmi_int(0x10, &regs);
#else
songquit();
SDL_Quit();
#endif
if (main_info.error_str[0] != 0) {
......
......@@ -450,8 +450,9 @@ char menu(void)
outportw(0x3c4, 0x0f02);
memset((char *) (0xa0000 + 220 * 100 + __djgpp_conventional_base), 0, 2000);
memset((char *) (0xa0000 + 32768 + 220 * 100 + __djgpp_conventional_base), 0, 2000);
/* clear 5 lines at x=0,y=220 in front and backbuffer */
*/memset((void *) get_vgaptr(0, 0, 220), 0, 8000);
// clear 20 lines at x=0,y=220 in front and backbuffer
*/
memset((void *) get_vgaptr(0, 0, 220), 0, 8000);
cur_message++;
if (cur_message >= NUM_MESSAGES)
......@@ -486,7 +487,7 @@ char menu(void)
main_info.draw_page ^= 1;
main_info.view_page ^= 1;
#ifndef LINUX
#ifdef DOS
outportw(0x3d4, (main_info.view_page << 23) + 0x0d);
outportw(0x3d4, ((main_info.view_page << 15) & 0xff00) + 0x0c);
#else
......
This diff is collapsed.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#ifndef _MSC_VER
#include <unistd.h>
#endif
#include "globals.h"
struct {
char enabled;
} keyb_handler_info;
volatile char keyb[256];
char last_keys[50];
unsigned char scancode2ascii[256] = {
0, 0, 49, 50, 51, 52, 53, 54, 55, 56, /* 0-9 */
57, 48, 45, 0, 0, 0, 113, 119, 101, 114, /* 10-19 */
116, 121, 117, 105, 111, 112, 0, 0, 0, 0, /* 20-29 */
97, 115, 100, 102, 103, 104, 106, 107, 108, 0, /* 30-39 */
0, 0, 0, 0, 122, 120, 99, 118, 98, 110, /* 40-49 */
109, 44, 46, 47, 0, 0, 0, 32, 0, 0, /* 50-59 */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};
#ifndef USE_SDL
_go32_dpmi_seginfo old_keyb_handler_seginfo, new_keyb_handler_seginfo;
#endif
void keyb_handler()
{
unsigned char key;
static char extended;
int c1;
key = 0;
#ifndef USE_SDL
key = inportb(0x60);
#endif
if (key == 0xe0)
extended = 1;
else {
if (extended == 0) {
if ((key & 0x80) == 0) {
keyb[key & 0x7f] = 1;
for (c1 = 48; c1 > 0; c1--)
last_keys[c1] = last_keys[c1 - 1];
last_keys[0] = scancode2ascii[key & 0x7f];
} else
keyb[key & 0x7f] = 0;
} else {
if ((key & 0x80) == 0) {
keyb[(key & 0x7f) + 0x80] = 1;
for (c1 = 48; c1 > 0; c1--)
last_keys[c1] = last_keys[c1 - 1];
last_keys[0] = scancode2ascii[(key & 0x7f) + 0x80];
} else
keyb[(key & 0x7f) + 0x80] = 0;
}
if (extended == 1)
extended = 0;
}
#ifndef USE_SDL
outportb(0x20, 0x20);
#endif
}
void keyb_handler_end()
{
}
char hook_keyb_handler(void)
{
#ifndef USE_SDL
if (keyb_handler_info.enabled == 0) {
_go32_dpmi_lock_data((char *) &keyb, sizeof(keyb));
_go32_dpmi_lock_code(keyb_handler, (unsigned long) keyb_handler_end - (unsigned long) keyb_handler);
_go32_dpmi_get_protected_mode_interrupt_vector(9, &old_keyb_handler_seginfo);
new_keyb_handler_seginfo.pm_offset = (int) keyb_handler;
if (_go32_dpmi_allocate_iret_wrapper(&new_keyb_handler_seginfo) != 0)
return 1;
if (_go32_dpmi_set_protected_mode_interrupt_vector(9, &new_keyb_handler_seginfo) != 0) {
_go32_dpmi_free_iret_wrapper(&new_keyb_handler_seginfo);
return 1;
}
keyb_handler_info.enabled = 1;
memset(last_keys, 0, sizeof(last_keys));
}
#endif
SDL_EnableUNICODE(1);
memset((void *) last_keys, 0, sizeof(last_keys));
return 0;
}
void remove_keyb_handler(void)
{
#ifndef USE_SDL
if (keyb_handler_info.enabled == 1) {
_go32_dpmi_set_protected_mode_interrupt_vector(9, &old_keyb_handler_seginfo);
_go32_dpmi_free_iret_wrapper(&new_keyb_handler_seginfo);
keyb_handler_info.enabled = 0;
}
#endif
}
char key_pressed(unsigned char key)
{
return keyb[(unsigned char) key];
}
int addkey(unsigned int key)
{
int c1;
if (!(key & 0x8000)) {
keyb[key & 0x7fff] = 1;
for (c1 = 48; c1 > 0; c1--)
last_keys[c1] = last_keys[c1 - 1];
last_keys[0] = key & 0x7fff;
} else
keyb[key & 0x7fff] = 0;
return 0;
}
char intr_sysupdate()
{
SDL_Event e;
int i = 0;
static Uint32 now, then = 0;
while (SDL_PollEvent(&e)) {
switch (e.type) {
case SDL_MOUSEBUTTONDOWN:
break;
case SDL_KEYDOWN:
case SDL_KEYUP:
switch (e.key.keysym.sym) {
case SDLK_F12:
if (e.type == SDL_KEYDOWN) {
SDL_Quit();
exit(1);
}
break;
case SDLK_F10:
if (e.type == SDL_KEYDOWN) {
fs_toggle();
}
break;
case SDLK_ESCAPE:
if (e.type == SDL_KEYUP)
addkey(1 | 0x8000);
else
addkey(1 & 0x7f);
break;
default:
e.key.keysym.sym &= 0x7f;
if (e.type == SDL_KEYUP)
e.key.keysym.sym |= 0x8000;
addkey(e.key.keysym.sym);
break;
}
break;
default:
break;
}
i++;
}
//SDL_Delay(4);
now = SDL_GetTicks();
if (!then)
SDL_Delay(1);
else {
then = (1000 / 60) - (now - then);
if (then > 0 && then < 1000)
SDL_Delay(then);
}
then = now;
return i;
}
#include "globals.h"
static Mix_Music *current_music = (Mix_Music *) NULL;
static struct {
int id;
Mix_Chunk *chunk;
int used;
int loop;
} soundsamples[128];
/* misc handling */
char dj_init(void)
{
int audio_rate = 22050;
Uint16 audio_format = AUDIO_U16;
int audio_channels = 2;
int audio_buffers = 4096;
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
return 0;
}
Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
printf("Opened audio at %dHz %dbit %s, %d bytes audio buffer\n", audio_rate, (audio_format & 0xFF), (audio_channels > 1) ? "stereo" : "mono", audio_buffers);
Mix_SetMusicCMD(getenv("MUSIC_CMD"));
memset(soundsamples, 0, sizeof(soundsamples));
return 0;
}
void dj_deinit(void)
{
// int i;
Mix_FadeOutMusic(1500);
SDL_Delay(1500);
Mix_HaltMusic();
if (current_music)
Mix_FreeMusic(current_music);
current_music = NULL;
/* for(i = 0; i < 128; i++) {
if(soundsamples[i].used && soundsamples[i].chunk)
Mix_FreeChunk(soundsamples[i].chunk);
}*/
Mix_CloseAudio();
SDL_Quit();
}
void dj_start(void)
{
}
void dj_stop(void)
{
}
char dj_autodetect_sd(void)
{
return 0;
}
char dj_set_stereo(char flag)
{
return 0;
}
void dj_set_auto_mix(char flag)
{
}
unsigned short dj_set_mixing_freq(unsigned short freq)
{
return freq;
}
void dj_set_dma_time(unsigned short time)
{
}
void dj_set_nosound(char flag)
{
}
/* mix handling */
void dj_mix(void)
{
}
/* sfx handling */
char dj_set_num_sfx_channels(char num_channels)
{
return num_channels;
}
void dj_set_sfx_volume(char volume)
{
}
void dj_play_sfx(unsigned char sfx_num, unsigned short freq, char volume, char panning, unsigned short delay, char channel)
{
int i;
int used_channel;
for (i = 0; i < 128; i++) {
if (soundsamples[i].id == sfx_num)
break;
}
if (i == 128)
return;
else if (!soundsamples[i].used)
return;
else if (!soundsamples[i].chunk)
return;
used_channel = Mix_PlayChannel(channel, soundsamples[i].chunk, soundsamples[i].loop);
Mix_Volume(used_channel, volume * 2);
}
char dj_get_sfx_settings(unsigned char sfx_num, sfx_data * data)
{
int i;
data->priority = 0;
data->default_freq = 0;
data->default_volume = 0;
data->length = 0;
data->loop = 0;
data->loop_start = 0;
data->loop_length = 0;
data->buf = 0;
for (i = 0; i < 128; i++) {
if (soundsamples[i].id == sfx_num)
break;
}
if (i == 128)
return 1;
else if (!soundsamples[i].used)
return 1;
else if (!soundsamples[i].chunk)
return 1;
data->loop = soundsamples[i].loop;
return 0;
}
char dj_set_sfx_settings(unsigned char sfx_num, sfx_data * data)
{
int i;
for (i = 0; i < 128; i++) {
if (soundsamples[i].id == sfx_num)
break;
}
if (i == 128)
return 1;
else if (!soundsamples[i].used)
return 1;
else if (!soundsamples[i].chunk)
return 1;
soundsamples[i].loop = (data->loop) ? (-1) : (0);
return 0;
}
void dj_set_sfx_channel_volume(char channel_num, char volume)
{
Mix_Volume(channel_num, volume * 2);
}
void dj_stop_sfx_channel(char channel_num)
{
Mix_HaltChannel(channel_num);
}