Commit 4f2d38f7 authored by Donald Haase's avatar Donald Haase
Browse files

Initial commit from my backup sources.

`hugo 2.12 (with dreamcast).zip` from 15Oct2005
parents
/* This file is part of the Dreamcast function library.
* Please see libdream.c for further details.
*
* (c)2000 Dan Potter
* modify BERO
* modified by Lawrence Sebald <bluecrab2887@netscape.net>
*/
#include "aica.h"
#include <kos.h>
#include <dc/g2bus.h>
/* Some convienence macros */
#define SNDREGADDR(x) (0xa0700000 + (x))
#define CHNREGADDR(ch,x) SNDREGADDR(0x80*(ch)+(x))
#define CHNREG32(ch, x) (*(volatile unsigned long *)CHNREGADDR(ch,x))
#define G2_LOCK(OLD) \
do { \
if (!irq_inside_int()) \
OLD = irq_disable(); \
/*irq_enable_exc(); */\
/* suspend any G2 DMA here... */ \
while((*(volatile unsigned int *)0xa05f688c) & 0x20) \
; \
} while(0)
#define G2_UNLOCK(OLD) \
do { \
/* resume any G2 DMA here... */ \
if (!irq_inside_int()) \
irq_restore(OLD); \
} while(0)
/* For the moment this is going to have to suffice, until we really
figure out what these mean. */
#define AICA_PAN(x) ((x)==0x80?(0):((x)<0x80?(0x1f):(0x0f)))
static inline unsigned AICA_FREQ(unsigned freq) {
unsigned long freq_lo, freq_base = 5644800;
int freq_hi = 7;
/* Need to convert frequency to floating point format
(freq_hi is exponent, freq_lo is mantissa)
Formula is ferq = 44100*2^freq_hi*(1+freq_lo/1024) */
while (freq < freq_base && freq_hi > -8) {
freq_base >>= 1;
--freq_hi;
}
while (freq < freq_base && freq_hi > -8) {
freq_base >>= 1;
freq_hi--;
}
freq_lo = (freq<<10) / freq_base;
return (freq_hi << 11) | (freq_lo & 1023);
}
/* Sets up a sound channel completely. This is generally good if you want
a quick and dirty way to play notes. If you want a more comprehensive
set of routines (more like PC wavetable cards) see below.
ch is the channel to play on (0 - 63)
smpptr is the pointer to the sound data; if you're running off the
SH4, then this ought to be (ptr - 0xa0800000); otherwise it's just
ptr. Basically, it's an offset into sound ram.
mode is one of the mode constants (16 bit, 8 bit, ADPCM)
nsamp is the number of samples to play (not number of bytes!)
freq is the sampling rate of the sound
pan is a panning constant -- 0 is left, 128 is center, 255 is right.
This routine (and the similar ones) owe a lot to Marcus' sound example --
I hadn't gotten quite this far into dissecting the individual regs yet. */
void aica_play(int ch,int mode,unsigned long smpptr,int loopst,int loopend,int freq,int pan,int loopflag) {
int val;
int old;
/* Stop the channel (if it's already playing) */
aica_stop(ch);
g2_fifo_wait();
G2_LOCK(old);
/* Envelope setup. The first of these is the loop point,
e.g., where the sample starts over when it loops. The second
is the loop end. This is the full length of the sample when
you are not looping, or the loop end point when you are (though
storing more than that is a waste of memory if you're not doing
volume enveloping). */
CHNREG32(ch, 8) = loopst & 0xffff;
CHNREG32(ch, 12) = loopend & 0xffff;
/* Write resulting values */
CHNREG32(ch, 24) = AICA_FREQ(freq);
/* Set volume, pan, and some other things that we don't know what
they do =) */
CHNREG32(ch, 36) = AICA_PAN(pan) | (0xf<<8);
/* Convert the incoming volume and pan into hardware values */
/* Vol starts at zero so we can ramp */
CHNREG32(ch, 40) = 0x24 | 0;
/* Convert the incoming volume and pan into hardware values */
/* Vol starts at zero so we can ramp */
/* If we supported volume envelopes (which we don't yet) then
this value would set that up. The top 4 bits determine the
envelope speed. f is the fastest, 1 is the slowest, and 0
seems to be an invalid value and does weird things). The
default (below) sets it into normal mode (play and terminate/loop).
CHNREG32(ch, 16) = 0xf010;
*/
CHNREG32(ch, 16) = 0x1f; /* No volume envelope */
/* Set sample format, buffer address, and looping control. If
0x0200 mask is set on reg 0, the sample loops infinitely. If
it's not set, the sample plays once and terminates. We'll
also set the bits to start playback here. */
CHNREG32(ch, 4) = smpptr & 0xffff;
val = 0xc000 | 0x0000 | (mode<<7) | (smpptr >> 16);
if (loopflag) val|=0x200;
CHNREG32(ch, 0) = val;
G2_UNLOCK(old);
/* Enable playback */
/* CHNREG32(ch, 0) |= 0xc000; */
}
/* Stop the sound on a given channel */
void aica_stop(int ch) {
g2_fifo_wait();
g2_write_32(CHNREGADDR(ch, 0),(g2_read_32(CHNREGADDR(ch, 0)) & ~0x4000) | 0x8000);
}
/* Get channel position */
int aica_get_pos(void) {
/* Observe channel ch */
g2_fifo_wait();
g2_write_32(SNDREGADDR(0x280c),(g2_read_32(SNDREGADDR(0x280c))&0xffff00ff) | (0<<8));
g2_fifo_wait();
/* Update position counters */
return g2_read_32(SNDREGADDR(0x2814)) & 0xffff;
}
#ifndef _AICA_H_
#define _AICA_H_
#define SM_8BIT 1
#define SM_16BIT 0
#define SM_ADPCM 2
void aica_play(int ch,int mode,unsigned long smpptr,int looptst,int loopend,int freq,int pan,int loopflag);
void aica_stop(int ch);
int aica_get_pos(void);
#endif
/*
* akrip32.h - Copyright (C) 1999 Jay A. Key
*
* API for akrip32.dll
*
**********************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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
*
**********************************************************************
*
*/
#ifndef _AKRIP32_H_
#define _AKRIP32_H_
#include <windows.h>
#include "myaspi32.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __GNUC__
#define PACKED
#endif
#define TRACK_AUDIO 0x00
#define TRACK_DATA 0x01
#define MAXIDLEN 64
#define MAXCDLIST 8
/*
* TRACKBUF
*
* This structure should not be allocated directly. If a buffer containing
* 27 * 2353 bytes is desired, a buffer should be allocated containing
* the desired amount + 24 bytes. The allocated memory can then be
* typecast to a LPTRACKBUF. It is the program's responsibility to guard
* against reading/writing past the end of allocated memory.
*
* The following must always apply:
* (len + startOffset) <= (numFrames * 2352) <= maxLen
*/
typedef struct
{
DWORD startFrame; /* 00: starting frame number */
DWORD numFrames; /* 04: number of frames read */
DWORD maxLen; /* 08: length of buffer itself */
DWORD len; /* 0C: length of data actually in buf */
DWORD status; /* 10: status of last read operation */
int startOffset; /* 14: offset of valid data in buf */
BYTE buf[1024*1024]; /* 18: the data itself */
} *PTRACKBUF, FAR *LPTRACKBUF;
typedef struct
{
DWORD startFrame; /* 00: starting frame number */
DWORD numFrames; /* 04: number of frames read */
DWORD maxLen; /* 08: length of buffer itself */
DWORD len; /* 0C: length of data actually in buf */
DWORD status; /* 10: status of last read operation */
int startOffset; /* 14: offset of valid data in buf */
} TRACKBUFDUMMY;
#define TRACKBUFEXTRA sizeof(TRACKBUFDUMMY)
typedef struct
{
char vendor[9];
char prodId[17];
char rev[5];
char vendSpec[21];
} CDINFO, *PCDINFO, FAR *LPCDINFO;
typedef struct
{
BYTE ha;
BYTE tgt;
BYTE lun;
BYTE pad;
char id[MAXIDLEN + 1];
CDINFO info;
} CDREC, *PCDREC, FAR *LPCDREC;
typedef struct
{
BYTE max;
BYTE num;
CDREC cd[MAXCDLIST];
} CDLIST, *PCDLIST, FAR *LPCDLIST;
#ifndef __GNUC__
#pragma pack(1)
#endif
/*
* TOCTRACK and TOC must be byte-aligned. If you're not using Mingw32,
* CygWin, or some other compiler that understands the PACKED keyword,
* you need to ensure that these structures are byte aligned. Usually,
* this is done using a
* #pragma pack(1)
* See your compiler's documentation for details
*/
typedef struct
{
BYTE rsvd;
BYTE ADR;
BYTE trackNumber;
BYTE rsvd2;
BYTE addr[4];
} PACKED TOCTRACK;
typedef struct
{
WORD tocLen;
BYTE firstTrack;
BYTE lastTrack;
TOCTRACK tracks[100];
} PACKED TOC, *PTOC, FAR *LPTOC;
typedef struct
{
int trackNo;
DWORD startLBA;
DWORD trackLen;
BYTE type;
BYTE pad[3];
char name[256];
} PACKED TRACK, *PTRACK, FAR *LPTRACK;
#ifndef __GNUC__
#pragma pack()
#endif
typedef struct
{
BYTE sm;
BYTE ss;
BYTE sf;
BYTE em;
BYTE es;
BYTE ef;
} READMSF, *PREADMSF, FAR *LPREADMSF;
/*
* Error codes set by functions in ASPILIB.C
*/
#define ALERR_NOERROR 0
#define ALERR_NOWNASPI -1
#define ALERR_NOGETASPI32SUPP -2
#define ALERR_NOSENDASPICMD -3
#define ALERR_ASPI -4
#define ALERR_NOCDSELECTED -5
#define ALERR_BUFTOOSMALL -6
#define ALERR_INVHANDLE -7
#define ALERR_NOMOREHAND -8
#define ALERR_BUFPTR -9
#define ALERR_NOTACD -10
#define ALERR_LOCK -11
#define ALERR_DUPHAND -12
#define ALERR_INVPTR -13
#define ALERR_INVPARM -14
#define ALERR_JITTER -15
#define ALERR_NOADAPTERS -16
#define ALERR_NOCDFOUND -17
/*
* API codes
*/
#define APIC_NONE 0
#define APIC_ASPI 1
#define APIC_SCSIPT 2
/*
* constants used for queryCDParms()
*/
#define CDP_READCDR 0x0001 // can read CD-R
#define CDP_READCDE 0x0002 // can read CD-E
#define CDP_METHOD2 0x0003 // can read CD-R wriiten via method 2
#define CDP_WRITECDR 0x0004 // can write CD-R
#define CDP_WRITECDE 0x0005 // can write CD-E
#define CDP_AUDIOPLAY 0x0006 // can play audio
#define CDP_COMPOSITE 0x0007 // composite audio/video stream
#define CDP_DIGITAL1 0x0008 // digital output (IEC958) on port 1
#define CDP_DIGITAL2 0x0009 // digital output (IEC958) on port 2
#define CDP_M2FORM1 0x000A // reads Mode 2 Form 1 (XA) format
#define CDP_M2FORM2 0x000B // reads Mode 2 Form 2 format
#define CDP_MULTISES 0x000C // reads multi-session or Photo-CD
#define CDP_CDDA 0x000D // supports cd-da
#define CDP_STREAMACC 0x000E // supports "stream is accurate"
#define CDP_RW 0x000F // can return R-W info
#define CDP_RWCORR 0x0010 // returns R-W de-interleaved and err.
// corrected
#define CDP_C2SUPP 0x0011 // C2 error pointers
#define CDP_ISRC 0x0012 // can return the ISRC info
#define CDP_UPC 0x0013 // can return the Media Catalog Number
#define CDP_CANLOCK 0x0014 // prevent/allow cmd. can lock the media
#define CDP_LOCKED 0x0015 // current lock state (TRUE = LOCKED)
#define CDP_PREVJUMP 0x0016 // prevent/allow jumper state
#define CDP_CANEJECT 0x0017 // drive can eject disk
#define CDP_MECHTYPE 0x0018 // type of disk loading supported
#define CDP_SEPVOL 0x0019 // independent audio level for channels
#define CDP_SEPMUTE 0x001A // independent mute for channels
#define CDP_SDP 0x001B // supports disk present (SDP)
#define CDP_SSS 0x001C // Software Slot Selection
#define CDP_MAXSPEED 0x001D // maximum supported speed of drive
#define CDP_NUMVOL 0x001E // number of volume levels
#define CDP_BUFSIZE 0x001F // size of output buffer
#define CDP_CURRSPEED 0x0020 // current speed of drive
#define CDP_SPM 0x0021 // "S" units per "M" (MSF format)
#define CDP_FPS 0x0022 // "F" units per "S" (MSF format)
#define CDP_INACTMULT 0x0023 // inactivity multiplier ( x 125 ms)
#define CDP_MSF 0x0024 // use MSF format for READ TOC cmd
#define CDP_OVERLAP 0x0025 // number of overlap frames for jitter
#define CDP_JITTER 0x0026 // number of frames to check for jitter
#define CDP_READMODE 0x0027 // mode to attempt jitter corr.
/*
* defines for GETCDHAND readType
*
*/
#define CDR_ANY 0x00 // unknown
#define CDR_ATAPI1 0x01 // ATAPI per spec
#define CDR_ATAPI2 0x02 // alternate ATAPI
#define CDR_READ6 0x03 // using SCSI READ(6)
#define CDR_READ10 0x04 // using SCSI READ(10)
#define CDR_READ_D8 0x05 // using command 0xD8 (Plextor?)
#define CDR_READ_D4 0x06 // using command 0xD4 (NEC?)
#define CDR_READ_D4_1 0x07 // 0xD4 with a mode select
#define CDR_READ10_2 0x08 // different mode select w/ READ(10)
/*
* defines for the read mode (CDP_READMODE)
*/
#define CDRM_NOJITTER 0x00 // never jitter correct
#define CDRM_JITTER 0x01 // always jitter correct
#define CDRM_JITTERONERR 0x02 // jitter correct only after a read error
#ifndef __GNUC__
#pragma pack(1)
#endif
typedef HANDLE HCDROM;
typedef struct _GETCDHAND {
BYTE size; /* set to sizeof(GETCDHAND) */
BYTE ver; /* set to AKRIPVER */
BYTE ha; /* host adapter */
BYTE tgt; /* target id */
BYTE lun; /* LUN */
BYTE readType; /* read function to use */
BOOL jitterCorr; /* use built-in jitter correction? */
BYTE numJitter; /* number of frames to try to match */
BYTE numOverlap; /* number of frames to overlap */
} PACKED GETCDHAND, *PGETCDHAND, FAR *LPGETCDHAND;
#ifndef __GNUC__
#pragma pack()
#endif
// Used by InsertCDCacheItem
#define CDDB_NONE 0
#define CDDB_QUERY 1
#define CDDB_ENTRY 2
#define CDDB_OPT_SERVER 0
#define CDDB_OPT_PROXY 1
#define CDDB_OPT_USEPROXY 2
#define CDDB_OPT_AGENT 3
#define CDDB_OPT_USER 4
#define CDDB_OPT_PROXYPORT 5
#define CDDB_OPT_CGI 6
#define CDDB_OPT_HTTPPORT 7
#define CDDB_OPT_USECDPLAYERINI 8
#define CDDB_OPT_USEHTTP1_0 9
#define CDDB_OPT_SUBMITCGI 10
#define CDDB_OPT_USERAUTH 11
#define CDDB_OPT_PROTOLEVEL 12
int GetNumAdapters( void );
int GetCDList( LPCDLIST cd );
int GetAspiLibError( void );
BYTE GetAspiLibAspiError( void );
DWORD GetCDId( HCDROM hCD, char *buf, int maxBuf );
DWORD GetDriveInfo( BYTE ha, BYTE tgt, BYTE lun, LPCDREC cdrec );
DWORD ReadTOC( HCDROM hCD, LPTOC lpToc );
DWORD ReadCDAudioLBA( HCDROM hCD, LPTRACKBUF );
BOOL QueryCDParms( HCDROM hCD, int which, DWORD *pNum );
BOOL ModifyCDParms( HCDROM hCD, int which, DWORD val );
HCDROM GetCDHandle( LPGETCDHAND lpcd );
BOOL CloseCDHandle( HCDROM );
DWORD ReadCDAudioLBAEx( HCDROM hCD, LPTRACKBUF, LPTRACKBUF );
DWORD GetAKRipDllVersion( void );
/*
* CDDB support
*/
typedef struct {
char categ[12];
char cddbId[9];
BOOL bExact;
char artist[81];
char title[81];
} CDDBQUERYITEM, FAR *LPCDDBQUERYITEM;
typedef struct {
int num;
LPCDDBQUERYITEM q;
} CDDBQUERY, FAR *LPCDDBQUERY;
typedef struct {
char szServer[81];
BOOL bHTTP;
int iPort;
char szCGI[81];
char szNorth[16];
char szSouth[16];
char szLocation[81];
} CDDBSITE, FAR *LPCDDBSITE;
typedef struct {
int num;
LPCDDBSITE s;
} CDDBSITELIST, FAR *LPCDDBSITELIST;
DWORD GetCDDBDiskID( HCDROM hCD, DWORD *pID, int numEntries );
DWORD CDDBQuery( HCDROM hCD, LPCDDBQUERY lpq );
DWORD CDDBGetDiskInfo( LPCDDBQUERYITEM lpq, char *szCDDBEntry, int maxLen );
void CDDBSetOption( int what, char *szVal, int iVal );
DWORD CDDBGetOptionInt( int what, BOOL *bValid );
char *CDDBGetOptionText( int what, char *szBuf, int maxLen, BOOL *bValid );
DWORD CDDBGetServerList( LPCDDBSITELIST lpSiteList );
DWORD CDDBSubmit( DWORD dwDiscID, BOOL bTest, char *szEmail, char *szCategory,
char *szEntry );
/*
* CDDA
*/
DWORD PlayTrack( HCDROM hCD, DWORD track_index );
DWORD PlayAudioRange( HCDROM hCD, DWORD From, DWORD Length );
DWORD startStopUnit( HCDROM hCD, BOOL bLoEj, BOOL bStart );
DWORD pauseResumeCD( HCDROM hCD, BOOL bPause );
#ifdef __cplusplus
}
#endif
#endif /* _AKRIP32_H_ */
This diff is collapsed.
#ifndef INCLUDE_BIOS_H
#define INCLUDE_BIOS_H
void handle_bios(void);
/* Perform the bios hooking function */
#endif
/****************************************************************************/
/* */
/* Source file for handling Bp in core kernel */
/* */
/* For the user Bp, we just give the hand to the user */
/* For the GIVE_HAND_BP, we make it disappear and we give hand to user */
/* For the RESTORE_BP, we set again the User BP placed old_user_bp in the */
/* list then we make the current BP to disappear then set IP,... */
/* */
/* There are certainly a lot of improvement to do, If you got any idea : */
/* Zeograd@caramail.com */
/* */
/****************************************************************************/
#include "globals.h"
#include "debug.h"
#include "h6280.h"
int handle_bp(int nb_bp);
int handle_bp0()
{
return handle_bp(0);
}
int handle_bp1()
{
return handle_bp(1);
}
int handle_bp2()
{
return handle_bp(2);
}
int handle_bp3()
{
return handle_bp(3);
}
int handle_bp4()
{
return handle_bp(4);
}
int handle_bp5()
{
return handle_bp(5);
}
int handle_bp6()
{
return handle_bp(6);
}
int handle_bp7()
{
return handle_bp(7);
}
int handle_bp8()
{
return handle_bp(8);
}
int handle_bp9()
{
return handle_bp(9);
}
int handle_bp10()
{
return handle_bp(10);
}
int handle_bp11()
{
return handle_bp(11);
}
int handle_bp12()
{
return handle_bp(12);
}
int handle_bp13()
{
return handle_bp(13);
}
int handle_bp(int nb_bp)
{
#ifndef FINAL_RELEASE
if (reg_pc!=Bp_list[nb_bp].position)
fprintf(stderr,"there's a problem, the breakpoint hasn't been correctly hit\n");
else
fprintf(stderr,"The breakpoint %d has been correctly hit\n",nb_bp);
fprintf(stderr,"After Breakpoint, position is %X\n",reg_pc);
#endif
disass_menu(reg_pc);
// And call the disassembler
#ifndef FINAL_RELEASE
fprintf(stderr,"After the disassembly function, the position is %X\n",reg_pc);
#endif
if ((get_8bit_addr(reg_pc)&0x0F)==0x0B)
{ // We only look here for Bp since PC or bp status can have changed
#ifndef FINAL_RELEASE
fprintf(stderr,"run trick: a bp has been asked to be put at %X\n",reg_pc);
#endif
Wr6502(reg_pc,Bp_list[get_8bit_addr(reg_pc)>>4].original_op);
// Replace the opcode in the rom
Bp_list[get_8bit_addr(reg_pc)>>4].flag=NOT_USED;
// Temporary, the breakpoint disappears
// to be replaced by the restore_bp
Bp_pos_to_restore=reg_pc;
// We know we must restore a breakpoint at this point
set_bp_following(reg_pc,RESTORE_BP);
// since we call this after disassembly call, we handle correctly
// any changes in reg value e.g.
}
return 0;
}
int
handle_bp14()
{
// We must restore the Bp_to_restore Breakpoint
Wr6502(reg_pc,Bp_list[14].original_op);
// Replace the opcode in the rom
Bp_list[14].flag=NOT_USED;
// This BP is no more used
#ifndef FINAL_RELEASE
fprintf(stderr,"We're restoring bp at %X\n",Bp_pos_to_restore);
#endif
toggle_user_breakpoint(Bp_pos_to_restore);
// We set another Bp at the location we just left
return 0;
}
int
handle_bp15(){
// We must make it disappear and call the disassembler
Wr6502(reg_pc,Bp_list[15].original_op);
// Replace the opcode in the rom
Bp_list[15].flag=NOT_USED;
// This breakpoint is no more used
disass_menu(reg_pc);
return 0;
}
#ifndef INCLUDE_BP_H
#define INCLUDE_BP_H
int handle_bp0();
int handle_bp1();
int handle_bp2();
int handle_bp3();
int handle_bp4();
int handle_bp5();
int handle_bp6();
int handle_bp7();
int handle_bp8();
int handle_bp9();
int handle_bp10();
int handle_bp11();
int handle_bp12();
int handle_bp13();
int handle_bp14();
int handle_bp15();
#endif
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#include "gtk_main-server.h"
#include "callbacks-server.h"
#include "interface-server.h"
#include "support.h"
#include "hugod.h"
static global_option_type global_option; //!< Application global options
/*
global_option.server_port = DEFAULT_SERVER_PORT;
global_option.number_player = MAX_NUMBER_PLAYER;
global_option.type_server = LAN_PROTOCOL_TYPE;
*/
void
on_button_launch_clicked (GtkButton *button,
gpointer user_data)
{
GtkSpinButton* spin_button_players = NULL;
GtkSpinButton* spin_button_port = NULL;
GtkRadioButton* radio_button_mode = NULL;
GtkButton* button_launch = NULL;
GtkButton* button_stop = NULL;
spin_button_players = (GtkSpinButton*)lookup_widget(window_main, "spinbutton_players");
global_option.number_player = gtk_spin_button_get_value_as_int(spin_button_players);
spin_button_port = (GtkSpinButton*)lookup_widget(window_main, "spinbutton_port");
global_option.server_port = gtk_spin_button_get_value_as_int(spin_button_port);
radio_button_mode = (GtkRadioButton*)lookup_widget(window_main, "radiobutton_lan");
global_option.type_server = gtk_toggle_button_get_active((GtkToggleButton*)radio_button_mode) == TRUE ? LAN_PROTOCOL_TYPE : INTERNET_PROTOCOL_TYPE;
button_launch = (GtkButton*)lookup_widget(window_main, "button_launch");
gtk_widget_hide((GtkWidget*)button_launch);
button_stop = (GtkButton*)lookup_widget(window_main, "button_stop");
gtk_widget_show((GtkWidget*)button_stop);
serve_dispatch (&global_option);
}
void
on_button_help_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_show(window_help);
}
void
on_button_close_help_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_hide(window_help);
}
gboolean
on_window_help_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
gtk_widget_hide(window_help);
return TRUE;
}
void
on_button_stop_clicked (GtkButton *button,
gpointer user_data)
{
GtkButton* button_launch = NULL;
GtkButton* button_stop = NULL;
button_launch = (GtkButton*)lookup_widget(window_main, "button_launch");
gtk_widget_show((GtkWidget*)button_launch);
button_stop = (GtkButton*)lookup_widget(window_main, "button_stop");
gtk_widget_hide((GtkWidget*)button_stop);
gtk_stop_asked = TRUE;
}
#include <gtk/gtk.h>
void
on_button_launch_clicked (GtkButton *button,
gpointer user_data);
void
on_button_help_clicked (GtkButton *button,
gpointer user_data);
void
on_button_close_help_clicked (GtkButton *button,
gpointer user_data);
gboolean
on_window_help_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
void
on_button_stop_clicked (GtkButton *button,
gpointer user_data);
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
#include "gtk_main.h"
#include "pce.h"
#include "iniconfig.h"
static char tmp_buf[100];
void
on_open1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
get_directory_from_filename(initial_path);
gtk_file_selection_set_filename((GtkFileSelection*)fileselector_window, initial_path);
gtk_widget_show(fileselector_window);
}
void
on_save1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
savegame();
}
void
on_load1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
loadgame();
}
void
on_input_setting_1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
gtk_widget_show(input_settings_window);
}
void
on_hugo_manual1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
gtk_widget_show(manual_window);
}
void
on_about_1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
gtk_widget_show(about_window);
}
void
on_mainWindow_destroy (GtkObject *object,
gpointer user_data)
{
gtk_main_quit();
}
void
on_ok_button1_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_hide(fileselector_window);
CD_emulation = 0;
strcpy( cart_name, gtk_file_selection_get_filename((GtkFileSelection*)fileselector_window));
/*
* We need to flush any gtk events waiting to happen (like the widget hide
* from above) to avoid a deadlock when starting a game fullscreen (at least
* in linux).
*/
while (gtk_events_pending())
gtk_main_iteration();
play_game();
}
void
on_button1_clicked (GtkButton *button,
gpointer user_data)
{
on_open1_activate(NULL, NULL);
}
void
on_cancel_button1_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_hide(fileselector_window);
}
void
on_button_close_input_settings_window_clicked
(GtkButton *button,
gpointer user_data)
{
gtk_widget_hide(input_settings_window);
}
void
on_button2_clicked (GtkButton *button,
gpointer user_data)
{
if (NULL == search_possible_syscard())
{
GtkWidget* dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
"CD system card not found !\nDid you set \"CD system filename\" ?");
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
}
else
{
CD_emulation = 1;
play_game();
}
}
void
on_general_settings_1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
gtk_widget_show(general_settings_window);
}
void
on_button_close_about_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_hide(about_window);
}
void
on_button_browse_cd_system_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_show(fileselector_cd_system);
}
void
on_buttongeneral_config_close_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_hide(general_settings_window);
gtk_general_settings_grab();
}
void
on_button_general_config_save_clicked (GtkButton *button,
gpointer user_data)
{
gtk_general_settings_grab();
save_config();
}
void
on_button_general_config_cancel_clicked
(GtkButton *button,
gpointer user_data)
{
gtk_widget_hide(general_settings_window);
}
void
on_general_settings_window_show (GtkWidget *widget,
gpointer user_data)
{
gtk_general_settings_set();
}
void
on_ok_button_cd_system_clicked (GtkButton *button,
gpointer user_data)
{
GtkEntry* temp_entry;
gtk_widget_hide(fileselector_cd_system);
strncpy (cdsystem_path, gtk_file_selection_get_filename((GtkFileSelection*)fileselector_cd_system), PATH_MAX);
temp_entry = (GtkEntry*)lookup_widget(general_settings_window, "entry_cd_system_filename");
gtk_entry_set_text(temp_entry, cdsystem_path);
}
void
on_cancel_button_cd_system_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_hide(fileselector_cd_system);
}
void
on_ok_button_cd_path_clicked (GtkButton *button,
gpointer user_data)
{
GtkEntry* temp_entry;
gtk_widget_hide(fileselector_cd_path);
strcpy (ISO_filename, gtk_file_selection_get_filename((GtkFileSelection*)fileselector_cd_path));
temp_entry = (GtkEntry*)lookup_widget(general_settings_window, "entry_cd_path");
gtk_entry_set_text(temp_entry, ISO_filename);
}
void
on_cancel_button_cd_path_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_hide(fileselector_cd_path);
}
void
on_button_browse_rom_dirname_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_show(fileselector_rom_path);
}
void
on_button_browse_cd_path_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_show(fileselector_cd_path);
}
void
on_ok_button_rom_path_clicked (GtkButton *button,
gpointer user_data)
{
GtkEntry* temp_entry;
gtk_widget_hide(fileselector_rom_path);
strcpy (initial_path, gtk_file_selection_get_filename((GtkFileSelection*)fileselector_rom_path));
get_directory_from_filename(initial_path);
// if (strrchr(initial_path, '/') != NULL)
// *strrchr(initial_path, '/') = 0;
temp_entry = (GtkEntry*)lookup_widget(general_settings_window, "entry_rom_basedir");
gtk_entry_set_text(temp_entry, initial_path);
}
void
on_cancel_button_rom_path_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_hide(fileselector_rom_path);
}
void
on_button_manual_close_clicked (GtkButton *button,
gpointer user_data)
{
gtk_widget_hide(manual_window);
}
//void
//on_input_settings_window_show (GtkWidget *widget,
// gpointer user_data)
//{
// gtk_show_config(0);
//}
void
on_open_cd1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
}
void
on_save_settings1_activate (GtkMenuItem *menuitem,
gpointer user_data)
{
save_config();
}
void
on_option_config_number_changed (GtkOptionMenu *optionmenu,
gpointer user_data)
{
}
void
on_button_input_configuration_clicked (GtkButton *button,
gpointer user_data)
{
char* button_name = (char*) user_data;
int player_number = button_name[strlen(button_name) - 1] - '0';
int direction_index = 0;
if ((player_number < 0) || (player_number > 4))
{
Log("Abnormal player_number in %s at %s:%s\nAborting\n",
__FUNCTION__,
__FILE__,
__LINE__);
return;
}
for (; direction_index < J_MAX; direction_index ++)
{
if (!strncmp(joymap_reverse[direction_index],
button_name,
strlen(button_name) - 1))
{
break;
}
}
gtk_grab_control(direction_index, player_number);
}
void
on_spinbutton_configuration_value_changed
(GtkSpinButton *spinbutton,
gpointer user_data)
{
int index = gtk_spin_button_get_value_as_int((GtkSpinButton*) spinbutton);
set_gui_configuration_index(index);
}
void
on_window_input_settings_show (GtkWidget *widget,
gpointer user_data)
{
GtkSpinButton * spinbutton = (GtkSpinButton*)lookup_widget(widget, "spinbutton_configuration");
on_spinbutton_configuration_value_changed(spinbutton, (gpointer)NULL);
gtk_copy_current_configuration();
}
gboolean
on_window_input_settings_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
gtk_widget_hide(input_settings_window);
return TRUE;
}
void
on_button_input_ok_activate (GtkButton *button,
gpointer user_data)
{
gtk_confirm_configuration();
gtk_widget_hide(input_settings_window);
}
void
on_button_input_cancel_activate (GtkButton *button,
gpointer user_data)
{
gtk_widget_hide(input_settings_window);
}
void
on_spinbutton_joydev_value_changed (GtkSpinButton *spinbutton,
gpointer user_data)
{
GtkSpinButton* temp_spin_button = NULL;
int i = 0;
int player_number = -1;
for (i = 0; i < 5; i++)
{
sprintf(tmp_buf, "spinbutton_joydev%d", i);
if (spinbutton == (GtkSpinButton*)lookup_widget(input_settings_window, tmp_buf))
{
player_number = i;
break;
}
}
printf("Checked that joydev %d changed\n", player_number);
if (player_number != -1)
{
printf("Read value %d\n", gtk_spin_button_get_value_as_int(spinbutton));
set_gui_joydev(player_number, gtk_spin_button_get_value_as_int(spinbutton));
}
gtk_update_configuration(FALSE);
}
gboolean
on_general_settings_window_delete_event
(GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
gtk_widget_hide(general_settings_window);
return TRUE;
}
gboolean
on_fileselection_cd_system_delete_event
(GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
gtk_widget_hide(fileselector_cd_system);
return TRUE;
}
gboolean
on_fileselection_cd_path_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
gtk_widget_hide(fileselector_cd_path);
return TRUE;
}
gboolean
on_fileselection_rom_path_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
gtk_widget_hide(fileselector_rom_path);
return TRUE;
}
gboolean
on_fileselection1_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
gtk_widget_hide(fileselector_window);
return TRUE;
}
gboolean
on_window_about_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
gtk_widget_hide(about_window);
return TRUE;
}
#include <gtk/gtk.h>
void
on_open1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_save1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_load1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_input_setting_1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_hugo_manual1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_about_1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_mainWindow_destroy (GtkObject *object,
gpointer user_data);
void
on_button1_clicked (GtkButton *button,
gpointer user_data);
void
on_ok_button1_clicked (GtkButton *button,
gpointer user_data);
void
on_button1_clicked (GtkButton *button,
gpointer user_data);
void
on_cancel_button1_clicked (GtkButton *button,
gpointer user_data);
void
on_option_config_number_clicked (GtkButton *button,
gpointer user_data);
void
on_button_close_input_settings_window_clicked
(GtkButton *button,
gpointer user_data);
void
on_button2_clicked (GtkButton *button,
gpointer user_data);
void
on_general_settings_1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_button_close_about_clicked (GtkButton *button,
gpointer user_data);
void
on_button_browse_cd_system_clicked (GtkButton *button,
gpointer user_data);
void
on_buttongeneral_config_close_clicked (GtkButton *button,
gpointer user_data);
void
on_button_general_config_save_clicked (GtkButton *button,
gpointer user_data);
void
on_button_general_config_cancel_clicked
(GtkButton *button,
gpointer user_data);
void
on_general_settings_window_show (GtkWidget *widget,
gpointer user_data);
void
on_ok_button_cd_system_clicked (GtkButton *button,
gpointer user_data);
void
on_cancel_button_cd_system_clicked (GtkButton *button,
gpointer user_data);
void
on_ok_button_cd_path_clicked (GtkButton *button,
gpointer user_data);
void
on_cancel_button_cd_path_clicked (GtkButton *button,
gpointer user_data);
void
on_button_browse_rom_dirname_clicked (GtkButton *button,
gpointer user_data);
void
on_button_browse_cd_path_clicked (GtkButton *button,
gpointer user_data);
void
on_ok_button_rom_path_clicked (GtkButton *button,
gpointer user_data);
void
on_cancel_button_rom_path_clicked (GtkButton *button,
gpointer user_data);
void
on_button_manual_close_clicked (GtkButton *button,
gpointer user_data);
void
on_input_settings_window_show (GtkWidget *widget,
gpointer user_data);
void
on_open_cd1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_save_settings1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_open_cd1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_save_settings1_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_option_config_number_changed (GtkOptionMenu *optionmenu,
gpointer user_data);
void
on_button_input_configuration_clicked (GtkButton *button,
gpointer user_data);
void
on_button_input_configuration_clicked (GtkButton *button,
gpointer user_data);
void
on_spinbutton_configuration_value_changed
(GtkSpinButton *spinbutton,
gpointer user_data);
void
on_window_input_settings_show (GtkWidget *widget,
gpointer user_data);
gboolean
on_window_input_settings_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
void
on_button_input_ok_activate (GtkButton *button,
gpointer user_data);
void
on_button_input_cancel_activate (GtkButton *button,
gpointer user_data);
void
on_spinbutton_joydev_value_changed (GtkSpinButton *spinbutton,
gpointer user_data);
gboolean
on_general_settings_window_delete_event
(GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
gboolean
on_fileselection_cd_system_delete_event
(GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
gboolean
on_fileselection_cd_path_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
gboolean
on_fileselection_rom_path_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
gboolean
on_fileselection1_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
gboolean
on_window_about_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
#include "cd.h"
//---- Conversion functions --------------------------------------------------
unsigned
Time2Frame (int min, int sec, int frame)
{
return (unsigned)(min * 60 * 75 + sec * 75 + frame);
}
unsigned
Time2HSG (int min, int sec, int frame)
{
return Time2Frame (min, sec, frame) - 150;
}
unsigned
Time2Redbook (int min, int sec, int frame)
{
return (unsigned)((min << 16) | (sec << 8) | (frame));
}
void
Frame2Time (unsigned frame, int *Min, int *Sec, int *Fra)
{
*Min = (int)(frame / (60 * 75));
frame -= *Min * 60 * 75;
*Sec = (int)(frame / 75);
frame -= *Sec * 75;
*Fra = (int)frame;
}
void
Redbook2Time (unsigned redbook, int *Min, int *Sec, int *Fra)
{
*Fra = (int)(redbook & 0xff);
*Sec = (int)((redbook >> 8) & 0xff);
*Min = (int)((redbook >> 16) & 0xff);
}
void
HSG2Time (unsigned hsg, int *Min, int *Sec, int *Fra)
{
Frame2Time (hsg + 150, Min, Sec, Fra);
}
unsigned
Redbook2HSG (unsigned redbook)
{
int Min, Sec, Fra;
Redbook2Time (redbook, &Min, &Sec, &Fra);
return Time2HSG (Min, Sec, Fra);
}
unsigned
HSG2Redbook (unsigned HSG)
{
int Min, Sec, Fra;
HSG2Time (HSG, &Min, &Sec, &Fra);
return Time2Redbook (Min, Sec, Fra);
}
#ifndef _DJGPP_INCLUDE_CD_H
#define _DJGPP_INCLUDE_CD_H
#define COOKED 0
#define RAW 1
#define MSF 0
#define REDBOOK 1
// variables are quite self explanatory
extern int cdda_first_drive;
extern int cdda_nb_of_drives;
extern int cdda_current_drive;
extern int cdda_current_track;
extern int cdda_playing;
extern int cdda_min_track;
extern int cdda_max_track;
extern int cdda_disk_length;
extern char global_error[80];
int cdda_init();
// initialize the cd rom driver
int cdda_play(int track);
// play an audio track
void cdda_stop();
// stop the current playing
void cdda_shutdown();
// for now, just stop the playing
void cdda_loop_check();
// seems to must be called each seconde if you want audio tracks to be
// played again when finished
void cdda_track_info(unsigned char *result, int track);
// return info on the given track, result is 7-bytes long
void cdda_read_sector(unsigned char* p,unsigned long nb_sect,
unsigned char mode_read, unsigned char mode_addr);
void cdda_cooked_prefech_read_sector_redbook(unsigned long nb_sect);
void cdda_cooked_prefech_read_sector_msf(unsigned long nb_sect);
void cdda_dos_cooked_read_sector_lba(unsigned char* p, unsigned long nb_sect);
int cdda_play_sectors(int begin_sect, int length);
//-- Fonctions de conversion -------------------------------------------------
unsigned Time2Frame(int min, int sec, int frame);
unsigned Time2HSG(int min, int sec, int frame);
unsigned Time2Redbook(int min, int sec, int frame);
void Frame2Time(unsigned frame,
int *Min,
int *Sec,
int *Fra);
void Redbook2Time(unsigned redbook,
int* Min,
int* Sec,
int* Fra);
void HSG2Time(unsigned hsg,
int *Min,
int *Sec,
int *Fra);
unsigned Redbook2HSG(unsigned redbook);
unsigned HSG2Redbook(unsigned HSG);
#endif
/*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* 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.
*/
#include "cheat.h"
#if !defined(ALLEGRO)
long file_size (char* file_name)
{
FILE* f = fopen(file_name,"rb");
long position;
if (f == NULL)
return 0;
fseek(f,0,SEEK_END);
position = ftell(f);
fclose(f);
return position;
}
#endif
inline void fputw (UInt16 value, FILE* F)
{
fputc((int)(value & 0xFF), F);
fputc((int)(value >> 8), F);
}
inline UInt16 fgetw (FILE* F)
{
return (UInt16)(fgetc(F) + (fgetc(F) << 8));
}
freezed_value list_to_freeze[MAX_FREEZED_VALUE];
// List of all the value to freeze
unsigned char current_freezed_values;
// Current number of values to freeze
static UChar
bigindextobank (UInt32 index)
{
if (index<0x8000)
return 0;
if (index<0x18000)
return ((index-0x8000) >> 13) + 1;
if (index<0x48000)
return ((index-0x18000) >> 13) + 10;
// FIXME: what to return here?
}
UInt16
bigtosmallindex(UInt32 index)
{
if (index<0x8000)
return (UInt16)index;
return (UInt16)(index & 0x1FFF);
}
UChar
readindexedram (UInt32 index)
{
if (index<0x8000)
return RAM[index];
if (index<0x18000)
return cd_extra_mem[index-0x8000];
if (index<0x48000)
return cd_extra_super_mem[index-0x18000];
return 0;
}
void
writeindexedram (UInt32 index, UChar value)
{
if (index<0x8000)
RAM[index] = value;
else
if (index<0x18000)
cd_extra_mem[index-0x8000] = value;
else
if (index<0x48000)
cd_extra_super_mem[index-0x18000] = value;
}
/*****************************************************************************
Function: pokebyte
Description: set a value in the ram to a specified value
Parameters: none
Return: 0
*****************************************************************************/
char
pokebyte ()
{
char tmp_str[10], new_val;
unsigned char index = 0;
unsigned addr;
while (osd_keypressed())
/*@-retvalother*/
osd_readkey (); // Flushing keys
/*@=retvalother*/
while ((index < 10) && ((tmp_str[index++] = (char)(osd_readkey () & 0xFF)) != 13));
tmp_str[index - 1] = 0;
addr = (unsigned) atoi (tmp_str);
while (osd_keypressed ())
/*@-retvalother*/
osd_readkey (); // Flushing keys
/*@=retvalother*/
index = 0;
while ((index < 10) && ((tmp_str[index++] = (char)(osd_readkey () & 0xFF)) != 13));
tmp_str[index - 1] = 0;
new_val = atoi (tmp_str);
writeindexedram(addr, (UChar)new_val);
{
char *tmp_buf = (char *) malloc (100);
snprintf (tmp_buf, 100, MESSAGE[language][byte_set], addr, new_val);
osd_gfx_set_message (tmp_buf);
message_delay = 180;
free(tmp_buf);
}
return 0;
}
/*****************************************************************************
Function: searchbyte
Description: search the ram for a particuliar value
Parameters: none
Return: 1 on error
*****************************************************************************/
char
searchbyte ()
{
UInt32 MAX_INDEX;
char tmp_str[10];
UInt32 index = 0, tmp_word, last_index;
UChar bank;
char data_filename[80], old_filename[80];
char first_research = 1;
FILE *D, *O;
SInt16 to_search;
MAX_INDEX = (UInt16)( CD_emulation ? 0x48000 : 0x8000);
while (osd_keypressed ())
/*@-retvalother*/
osd_readkey (); // Flushing keys
/*@=retvalother*/
while ((index < 10) && ((tmp_str[index++] = (char)(osd_readkey () & 0xFF)) != 13));
tmp_str[index - 1] = 0;
to_search = atoi (tmp_str);
strcpy (old_filename, short_cart_name);
strcpy (data_filename, short_cart_name);
strcat (data_filename, "FP1");
O = fopen ((char *) strcat (old_filename, "FP0"), "rb");
if (O == NULL)
first_research = 1;
/*
if (exists ((char *) strcat (old_filename, "FP0")))
{
if (!(O = fopen (old_filename, "rb")))
return 1;
first_research = 0;
}
*/
if (!(D = fopen (data_filename, "wb")))
return 1;
tmp_str[9] = 0;
if ((tmp_str[0] != '-')
&&(tmp_str[0] != '+'))
{ /* non relative research */
for (index = 0; index < MAX_INDEX; index++)
{
if (readindexedram(index) == (UChar)to_search)
{
if (first_research)
{
fputc (readindexedram(index), D);
fputc (bigindextobank(index), D);
fputw (bigtosmallindex(index), D);
}
else
{
while (!(feof (O)))
{
fgetc (O);
bank = (UChar)fgetc(O);
tmp_word = fgetw(O);
if ((bank > bigindextobank(index))
||
((bank == bigindextobank(index)) && (tmp_word >= bigtosmallindex(index))))
{
fseek (O, -4, SEEK_CUR);
break;
}
}
if ((bigtosmallindex(index) == (UInt16)tmp_word) &&
(bigindextobank(index) == bank))
{
fputc (to_search, D);
fputc (bigindextobank(index), D);
fputw (bigtosmallindex(index), D);
last_index = index;
}
} //search for old occurences
}
}
}
else
{ /* relative research */
for (index = 0; index < MAX_INDEX; index++)
{
if (first_research)
{
fputc (readindexedram(index), D);
fputc (bigindextobank(index), D);
fputw (bigtosmallindex(index), D);
}
else
{
UChar old_value;
{
while (!(feof (O)))
{
fgetc (O);
bank = (UChar)fgetc(O);
tmp_word = fgetw(O);
if ((bank > bigindextobank(index))
||
((bank == bigindextobank(index)) && (tmp_word >= bigtosmallindex(index))))
{
fseek (O, -4, SEEK_CUR);
break;
}
}
if ((bigindextobank(index) == bank) &&
(bigtosmallindex(index) == (UInt16)tmp_word) &&
(readindexedram(index) == old_value + to_search))
{
fputc (readindexedram(index), D);
fputc (bigindextobank(index), D);
fputw (bigtosmallindex(index), D);
last_index = index;
}
} //search for old occurences
}
}
}
if (!first_research)
fclose (O);
fclose (D);
rename (data_filename, old_filename);
if (!file_size (old_filename))
{
osd_gfx_set_message (MESSAGE[language][search_failed]);
message_delay = 180;
unlink (old_filename);
return 1;
}
if (file_size (old_filename) == 4)
{
char *tmp_buf = (char *) malloc (100);
snprintf (tmp_buf, 100, MESSAGE[language][found_at], last_index);
osd_gfx_set_message (tmp_buf);
message_delay = 60 * 5;
free(tmp_buf);
}
else
{
osd_gfx_set_message (MESSAGE[language][still_need_search]);
message_delay = 60 * 3;
}
while (osd_keypressed ())
/*@-retvalother*/
osd_readkey (); // Flushing keys
/*@=retvalother*/
return 0;
}
/*****************************************************************************
Function: loadgame
Description: load a saved game using allegro packing functions
Parameters: none
Return: 1 on error, else 0
*****************************************************************************/
int
loadgame ()
{
#ifndef KERNEL_DS
/* TODO: add support for plain file when allegro isn't present */
#ifdef ALLEGRO
PACKFILE *fp;
UInt32 tmp = 0;
char *tmp_buf = (char *) alloca (100);
UChar version = 0;
if (!exists (sav_path))
return 1;
if (!(fp = pack_fopen (sav_path, F_READ_PACKED)))
return 1;
pack_fread (tmp_buf, 18, fp);
if (!strncmp (tmp_buf, "Hu-Go! state file", 17))
{
version = tmp_buf[17];
}
else
{
version = 0;
pack_fclose (fp);
if (!(fp = pack_fopen (sav_path, F_READ_PACKED)))
return 1;
}
pack_fread (RAM, 0x8000, fp);
pack_fread (VRAM, VRAMSIZE, fp);
pack_fread (SPRAM, 64 * 4 * sizeof (short), fp);
pack_fread (Pal, 512, fp);
pack_fread (&scanline, sizeof (int), fp);
if (version == 0x11)
pack_fread (&io, sizeof (IO), fp);
else
pack_fread (&io, 1420, fp);
pack_fread (&M, sizeof (M6502), fp);
if (populus)
pack_fread (PopRAM, PopRAMsize, fp);
if (CD_emulation)
{
pack_fread (cd_extra_mem, 0x10000, fp);
pack_fread (cd_extra_super_mem, 0x30000, fp);
pack_fread (cd_sector_buffer, 0x2000, fp);
pack_fread (&tmp, 2, fp);
if (tmp != 0xFFFF)
cd_read_buffer = cd_sector_buffer + tmp;
else
cd_read_buffer = 0;
}
for (tmp = 0; tmp < 8; tmp++)
bank_set (tmp, M.MPR[tmp]);
memset (vchange, 1, VRAMSIZE / 32);
memset (vchanges, 1, VRAMSIZE / 128);
CycleOld = (UInt32) M.User;
pack_fclose (fp);
#endif
#else // KERNEL_DS defined
#ifdef ALLEGRO
PACKFILE *fp;
UInt32 tmp = 0;
char *tmp_buf = (char *) alloca (100);
UChar version = 0;
if (!exists (sav_path))
return 1;
if (!(fp = pack_fopen (sav_path, F_READ_PACKED)))
return 1;
pack_fread (tmp_buf, 18, fp);
if (!strncmp (tmp_buf, "Hu-Go! state file", 17))
{
version = tmp_buf[17];
}
else
{
version = 0;
pack_fclose (fp);
if (!(fp = pack_fopen (sav_path, F_READ_PACKED)))
return 1;
}
pack_fread (RAM, 0x8000, fp);
pack_fread (VRAM, VRAMSIZE, fp);
pack_fread (SPRAM, 64 * 4 * sizeof (short), fp);
pack_fread (Pal, 512, fp);
pack_fread (&scanline, sizeof (int), fp);
if ((version == 0x11) || (version == 0x20))
pack_fread (&io, sizeof (IO), fp);
else
pack_fread (&io, 1420, fp);
{
pack_fread (mmr, sizeof(mmr[0])*8, fp);
pack_fread (&cyclecount, sizeof(cyclecount), fp);
pack_fread (&cyclecountold, sizeof(cyclecountold), fp);
// registers
pack_fread (&reg_pc, sizeof(reg_pc), fp);
pack_fread (&reg_a, sizeof(reg_a), fp);
pack_fread (&reg_x, sizeof(reg_x), fp);
pack_fread (&reg_y, sizeof(reg_y), fp);
pack_fread (&reg_p, sizeof(reg_p), fp);
pack_fread (&reg_s, sizeof(reg_s), fp);
pack_fread (&halt_flag, sizeof(halt_flag), fp);
pack_fread (&cycles, sizeof(cycles), fp);
}
if (populus)
pack_fread (PopRAM, PopRAMsize, fp);
if (CD_emulation)
{
pack_fread (cd_extra_mem, 0x10000, fp);
pack_fread (cd_extra_super_mem, 0x30000, fp);
pack_fread (cd_sector_buffer, 0x2000, fp);
pack_fread (&tmp, 2, fp);
if (tmp != 0xFFFF)
cd_read_buffer = cd_sector_buffer + tmp;
else
cd_read_buffer = 0;
pack_fread (&cd_port_1800, sizeof(cd_port_1800), fp);
pack_fread (&cd_port_1801, sizeof(cd_port_1801), fp);
pack_fread (&cd_port_1802, sizeof(cd_port_1802), fp);
pack_fread (&cd_port_1804, sizeof(cd_port_1804), fp);
pack_fread (&pce_cd_read_datacnt, sizeof(pce_cd_read_datacnt), fp);
pack_fread (&pce_cd_curcmd, sizeof(pce_cd_curcmd), fp);
}
for (tmp = 0; tmp < 8; tmp++)
bank_set (tmp, mmr[tmp]);
memset (vchange, 1, VRAMSIZE / 32);
memset (vchanges, 1, VRAMSIZE / 128);
// CycleOld = (UInt32) M.User;
zp_base = RAM;
sp_base = RAM + 0x100;
pack_fclose (fp);
#else
FILE* saved_file;
saved_file = fopen(sav_path, "rb");
if (saved_file == NULL)
return 1;
if (fread(hard_pce, 1, sizeof(struct_hard_pce), saved_file) != sizeof(struct_hard_pce))
{
fclose(saved_file);
return 1;
}
{
int mmr_index;
for (mmr_index = 0; mmr_index < 8; mmr_index++)
{
bank_set((UChar)mmr_index, mmr[mmr_index]);
printf("Setting bank %d to 0x%02x\n", mmr_index, mmr[mmr_index]);
}
}
fclose(saved_file);
#endif
#endif
return 0;
}
/*****************************************************************************
Function: savegame
Description: save a game using allegro packing functions
Parameters: none
Return: 1 on error, else 0
*****************************************************************************/
int
savegame ()
{
#ifndef KERNEL_DS
#ifdef ALLEGRO
PACKFILE *fp;
UInt32 tmp;
if (!(fp = pack_fopen (sav_path, F_WRITE_PACKED)))
return 1;
pack_fwrite ("Hu-Go! state file\21", 18, fp);
pack_fwrite (RAM, 0x8000, fp);
pack_fwrite (VRAM, VRAMSIZE, fp);
pack_fwrite (SPRAM, 64 * 4 * sizeof (short), fp);
pack_fwrite (Pal, 512, fp);
pack_fwrite (&scanline, sizeof (int), fp);
pack_fwrite (&io, sizeof (IO), fp);
pack_fwrite (&M, sizeof (M6502), fp);
if (populus)
pack_fwrite (PopRAM, PopRAMsize, fp);
if (CD_emulation)
{
pack_fwrite (cd_extra_mem, 0x10000, fp);
pack_fwrite (cd_extra_super_mem, 0x30000, fp);
pack_fwrite (cd_sector_buffer, 0x2000, fp);
if (cd_read_buffer)
{
tmp = cd_read_buffer - cd_sector_buffer;
pack_fwrite (&tmp, 2, fp);
}
else
{
tmp = 0xFFFF;
pack_fwrite (&tmp, 2, fp);
}
}
return pack_fclose (fp);
#else
return 0;
#endif
#else // KERNEL_DS defined
#ifdef ALLEGRO
PACKFILE *fp;
UInt32 tmp;
if (!(fp = pack_fopen (sav_path, F_WRITE_PACKED)))
return 1;
pack_fwrite ("Hu-Go! state file\40", 18, fp);
pack_fwrite (RAM, 0x8000, fp);
pack_fwrite (VRAM, VRAMSIZE, fp);
pack_fwrite (SPRAM, 64 * 4 * sizeof (short), fp);
pack_fwrite (Pal, 512, fp);
pack_fwrite (&scanline, sizeof (int), fp);
pack_fwrite (&io, sizeof (IO), fp);
// pack_fwrite (&M, sizeof (M6502), fp);
pack_fwrite (mmr, sizeof(mmr[0])*8, fp);
pack_fwrite (&cyclecount, sizeof(cyclecount), fp);
pack_fwrite (&cyclecountold, sizeof(cyclecountold), fp);
// registers
pack_fwrite (&reg_pc, sizeof(reg_pc), fp);
pack_fwrite (&reg_a, sizeof(reg_a), fp);
pack_fwrite (&reg_x, sizeof(reg_x), fp);
pack_fwrite (&reg_y, sizeof(reg_y), fp);
pack_fwrite (&reg_p, sizeof(reg_p), fp);
pack_fwrite (&reg_s, sizeof(reg_s), fp);
pack_fwrite (&halt_flag, sizeof(halt_flag), fp);
pack_fwrite (&cycles, sizeof(cycles), fp);
if (populus)
pack_fwrite (PopRAM, PopRAMsize, fp);
if (CD_emulation)
{
pack_fwrite (cd_extra_mem, 0x10000, fp);
pack_fwrite (cd_extra_super_mem, 0x30000, fp);
pack_fwrite (cd_sector_buffer, 0x2000, fp);
if (cd_read_buffer)
{
tmp = cd_read_buffer - cd_sector_buffer;
pack_fwrite (&tmp, 2, fp);
}
else
{
tmp = 0xFFFF;
pack_fwrite (&tmp, 2, fp);
}
pack_fwrite (&cd_port_1800, sizeof(cd_port_1800), fp);
pack_fwrite (&cd_port_1801, sizeof(cd_port_1801), fp);
pack_fwrite (&cd_port_1802, sizeof(cd_port_1802), fp);
pack_fwrite (&cd_port_1804, sizeof(cd_port_1804), fp);
pack_fwrite (&pce_cd_read_datacnt, sizeof(pce_cd_read_datacnt), fp);
pack_fwrite (&pce_cd_curcmd, sizeof(pce_cd_curcmd), fp);
}
return pack_fclose (fp);
#else // ALLEGRO not defined
FILE* saved_file;
saved_file = fopen(sav_path, "wb");
if (saved_file == NULL)
return 1;
if (fwrite(hard_pce, 1, sizeof(struct_hard_pce), saved_file) != sizeof(struct_hard_pce))
{
fclose(saved_file);
return 1;
}
fclose(saved_file);
#endif
#endif
return 0;
}
/*****************************************************************************
Function: freeze_value
Description: set or unset a value to freeze
Parameters:none
Return: 0 if unset an old freezed value or can't set a value anymore
1 if new was created,
may modify 'list_freezed_value'
*****************************************************************************/
int
freeze_value (void)
{
char tmp_str[10];
unsigned char index = 0;
unsigned where;
while (osd_keypressed ())
/*@-retvalother*/
osd_readkey (); // Flushing keys
/*@=retvalother*/
while ((index < 10) && ((tmp_str[index++] = (char)(osd_readkey () & 0xFF)) != 13));
tmp_str[index - 1] = 0;
where = (unsigned)atoi (tmp_str);
for (index = 0; index < current_freezed_values; index++)
if (list_to_freeze[index].position == (unsigned short)where)
{
// We entered an already freezed offset
memcpy (&list_to_freeze[index], &list_to_freeze[index + 1],
(current_freezed_values - index +
1) * sizeof (freezed_value));
// We erase the current struct letting no hole...
current_freezed_values--;
// And we got one less value
return 0;
}
if (current_freezed_values < MAX_FREEZED_VALUE)
{
list_to_freeze[current_freezed_values].position = (unsigned short)where;
while ((index < 10) && ((tmp_str[index++] = (char)(osd_readkey () & 0xFF)) != 13));
tmp_str[index - 1] = 0;
list_to_freeze[current_freezed_values++].value = (unsigned) atoi (tmp_str);
return 1;
}
else
return 0;
}
#ifndef _INCLUDE_CHEAT_H
#define _INCLUDE_CHEAT_H
#include <stdio.h>
#include "pce.h"
#include "lang.h"
char pokebyte();
/* Change the value of a byte in the memory */
char searchbyte();
/* Search for a byte in memory */
int loadgame();
/* Load the progression */
int savegame();
/* Save the progression */
#define MAX_FREEZED_VALUE 8
typedef struct {
unsigned short position;
unsigned char value;
} freezed_value;
extern freezed_value list_to_freeze[MAX_FREEZED_VALUE];
/* List of all the value to freeze */
extern unsigned char current_freezed_values;
/* Current number of values to freeze */
int freeze_value (void);
#endif
#ifndef _INCLUDE_CLEANTYP_H
#define _INCLUDE_CLEANTYP_H
#include "config.h"
#ifdef TRUE
#undef TRUE
#endif
#ifdef FALSE
#undef FALSE
#endif
typedef enum
{
FALSE,
TRUE
} boolean;
/* 8 Bits defines */
#if SIZEOF_CHAR == 1
/* Unsigned */
typedef unsigned char UChar;
#ifdef __AUDIO_H
typedef unsigned char BYTE;
#endif
/* Signed */
typedef signed char SChar;
typedef signed char Char;
#else
#error sizeof (char) is not 1. Pretty weird. Contact author
#endif // SIZEOF_CHAR == 1
/****************************************************************************/
/* 16 Bits defines */
#if SIZEOF_SHORT_INT == 2
/* Unsigned */
typedef unsigned short int UInt16;
#ifdef __AUDIO_H
typedef unsigned short int WORD;
#endif
/* Signed */
typedef signed short int SInt16;
typedef signed short int Int16;
#elif SIZEOF_INT == 2
/* Unsigned */
typedef unsigned int UInt16;
#ifdef __AUDIO_H
typedef unsigned short int WORD;
#endif
/* Signed */
typedef signed int SInt16;
typedef signed int Int16;
#else // neither int nor short are coded on 16 bits
#error neither short ints or ints are 16 bits long. Contact author.
#endif
/************************************************************************/
/* 32 Bits defines */
#if SIZEOF_INT == 4
/* Unsigned */
typedef unsigned int UInt32;
#ifdef __AUDIO_H
typedef unsigned int DWORD;
#endif
/* Signed */
typedef signed int SInt32;
typedef signed int Int32;
#elif SIZEOF_LONG_INT == 4
/* Unsigned */
typedef unsigned long int UInt32;
#ifdef __AUDIO_H
typedef unsigned long int DWORD;
#endif
/* Signed */
typedef signed long int SInt32;
typedef signed long int Int32;
#else
#error neither ints nor long ints are 32 bits long. Contact author.
#endif
#endif
#include "types.h"
unsigned long TAB_CONST[256] = {
0X0,
0X77073096,
0XEE0E612C,
0X990951BA,
0X76DC419,
0X706AF48F,
0XE963A535,
0X9E6495A3,
0XEDB8832,
0X79DCB8A4,
0XE0D5E91E,
0X97D2D988,
0X9B64C2B,
0X7EB17CBD,
0XE7B82D07,
0X90BF1D91,
0X1DB71064,
0X6AB020F2,
0XF3B97148,
0X84BE41DE,
0X1ADAD47D,
0X6DDDE4EB,
0XF4D4B551,
0X83D385C7,
0X136C9856,
0X646BA8C0,
0XFD62F97A,
0X8A65C9EC,
0X14015C4F,
0X63066CD9,
0XFA0F3D63,
0X8D080DF5,
0X3B6E20C8,
0X4C69105E,
0XD56041E4,
0XA2677172,
0X3C03E4D1,
0X4B04D447,
0XD20D85FD,
0XA50AB56B,
0X35B5A8FA,
0X42B2986C,
0XDBBBC9D6,
0XACBCF940,
0X32D86CE3,
0X45DF5C75,
0XDCD60DCF,
0XABD13D59,
0X26D930AC,
0X51DE003A,
0XC8D75180,
0XBFD06116,
0X21B4F4B5,
0X56B3C423,
0XCFBA9599,
0XB8BDA50F,
0X2802B89E,
0X5F058808,
0XC60CD9B2,
0XB10BE924,
0X2F6F7C87,
0X58684C11,
0XC1611DAB,
0XB6662D3D,
0X76DC4190,
0X1DB7106,
0X98D220BC,
0XEFD5102A,
0X71B18589,
0X6B6B51F,
0X9FBFE4A5,
0XE8B8D433,
0X7807C9A2,
0XF00F934,
0X9609A88E,
0XE10E9818,
0X7F6A0DBB,
0X86D3D2D,
0X91646C97,
0XE6635C01,
0X6B6B51F4,
0X1C6C6162,
0X856530D8,
0XF262004E,
0X6C0695ED,
0X1B01A57B,
0X8208F4C1,
0XF50FC457,
0X65B0D9C6,
0X12B7E950,
0X8BBEB8EA,
0XFCB9887C,
0X62DD1DDF,
0X15DA2D49,
0X8CD37CF3,
0XFBD44C65,
0X4DB26158,
0X3AB551CE,
0XA3BC0074,
0XD4BB30E2,
0X4ADFA541,
0X3DD895D7,
0XA4D1C46D,
0XD3D6F4FB,
0X4369E96A,
0X346ED9FC,
0XAD678846,
0XDA60B8D0,
0X44042D73,
0X33031DE5,
0XAA0A4C5F,
0XDD0D7CC9,
0X5005713C,
0X270241AA,
0XBE0B1010,
0XC90C2086,
0X5768B525,
0X206F85B3,
0XB966D409,
0XCE61E49F,
0X5EDEF90E,
0X29D9C998,
0XB0D09822,
0XC7D7A8B4,
0X59B33D17,
0X2EB40D81,
0XB7BD5C3B,
0XC0BA6CAD,
0XEDB88320,
0X9ABFB3B6,
0X3B6E20C,
0X74B1D29A,
0XEAD54739,
0X9DD277AF,
0X4DB2615,
0X73DC1683,
0XE3630B12,
0X94643B84,
0XD6D6A3E,
0X7A6A5AA8,
0XE40ECF0B,
0X9309FF9D,
0XA00AE27,
0X7D079EB1,
0XF00F9344,
0X8708A3D2,
0X1E01F268,
0X6906C2FE,
0XF762575D,
0X806567CB,
0X196C3671,
0X6E6B06E7,
0XFED41B76,
0X89D32BE0,
0X10DA7A5A,
0X67DD4ACC,
0XF9B9DF6F,
0X8EBEEFF9,
0X17B7BE43,
0X60B08ED5,
0XD6D6A3E8,
0XA1D1937E,
0X38D8C2C4,
0X4FDFF252,
0XD1BB67F1,
0XA6BC5767,
0X3FB506DD,
0X48B2364B,
0XD80D2BDA,
0XAF0A1B4C,
0X36034AF6,
0X41047A60,
0XDF60EFC3,
0XA867DF55,
0X316E8EEF,
0X4669BE79,
0XCB61B38C,
0XBC66831A,
0X256FD2A0,
0X5268E236,
0XCC0C7795,
0XBB0B4703,
0X220216B9,
0X5505262F,
0XC5BA3BBE,
0XB2BD0B28,
0X2BB45A92,
0X5CB36A04,
0XC2D7FFA7,
0XB5D0CF31,
0X2CD99E8B,
0X5BDEAE1D,
0X9B64C2B0,
0XEC63F226,
0X756AA39C,
0X26D930A,
0X9C0906A9,
0XEB0E363F,
0X72076785,
0X5005713,
0X95BF4A82,
0XE2B87A14,
0X7BB12BAE,
0XCB61B38,
0X92D28E9B,
0XE5D5BE0D,
0X7CDCEFB7,
0XBDBDF21,
0X86D3D2D4,
0XF1D4E242,
0X68DDB3F8,
0X1FDA836E,
0X81BE16CD,
0XF6B9265B,
0X6FB077E1,
0X18B74777,
0X88085AE6,
0XFF0F6A70,
0X66063BCA,
0X11010B5C,
0X8F659EFF,
0XF862AE69,
0X616BFFD3,
0X166CCF45,
0XA00AE278,
0XD70DD2EE,
0X4E048354,
0X3903B3C2,
0XA7672661,
0XD06016F7,
0X4969474D,
0X3E6E77DB,
0XAED16A4A,
0XD9D65ADC,
0X40DF0B66,
0X37D83BF0,
0XA9BCAE53,
0XDEBB9EC5,
0X47B2CF7F,
0X30B5FFE9,
0XBDBDF21C,
0XCABAC28A,
0X53B39330,
0X24B4A3A6,
0XBAD03605,
0XCDD70693,
0X54DE5729,
0X23D967BF,
0XB3667A2E,
0XC4614AB8,
0X5D681B02,
0X2A6F2B94,
0XB40BBE37,
0XC30C8EA1,
0X5A05DF1B,
0X2D02EF8D
};
/*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* 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.
*/
#include "dciniconfig.h"
#include "utils.h"
char* menu(void);
static int default_joy_mapping[J_MAX] = {0, 0, 0, 0,
0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1};
//! Filename of the cd system rom
char cdsystem_path[PATH_MAX];
char sCfgFileLine[BUFSIZ];
// line buffer for config reading
char temp_result[BUFSIZ];
// temporary return value for get_config_var function
char config_file[PATH_MAX], config_file_tmp[PATH_MAX];
// name of the config file
void
set_config_file (const char *filename)
{
strcpy (config_file_tmp, config_file);
strcpy (config_file, filename);
}
void
set_config_file_back (void)
{
strcpy (config_file, config_file_tmp);
}
int
get_config_int (char *section, char *keyword, int default_value)
{
return default_value;
}
char *
get_config_string (char *section, char *keyword, char *default_value)
{
return (default_value);
}
void
read_joy_mapping (void)
{
char tmp_str[10], tmp_str2[10], section_name[10];
unsigned char x, y, z;
unsigned short temp_val;
Log ("--[ JOYPAD MAPPING ]-------------------------------\n");
Log ("Loading default values\n");
memset (tmp_str, 0, 10);
strcpy (section_name, "CONFIG1");
for (z = 0; z < 16; z++)
{
if (z < 10)
section_name[6] = '0' + z;
else
section_name[6] = (z - 10) + 'a';
Log (" * Looking for section %s\n", section_name);
for (x = 0; x < 5; x++)
{ // for each player
config[z].individual_config[x].joydev = 0;
strcpy (tmp_str2, "joydev1");
tmp_str2[6] = '0' + x;
strncpy (tmp_str, get_config_string (section_name, tmp_str2, "0"),
10);
config[z].individual_config[x].joydev = atoi (tmp_str);
for (y = 0; y < J_MAX; y++)
{
strncpy (tmp_str, joymap_reverse[y], 10);
tmp_str[strlen (tmp_str) + 1] = 0;
tmp_str[strlen (tmp_str)] = '0' + x;
temp_val = get_config_int (section_name, tmp_str, 0xffff);
if (0xffff != temp_val)
{
config[z].individual_config[x].joy_mapping[y] = temp_val;
Log (" %s set to %d\n", joymap_reverse[y], temp_val);
}
}
}
}
Log ("End of joypad mapping\n\n");
}
void
parse_commandline (int argc, char **argv)
{
strcpy (cart_name, "/cd/");
strcat (cart_name,menu());
printf("%s\n", cart_name);
Log ("Setting card name to %s\n", cart_name);
parse_INIfile ();
Log ("End of parsing command line\n");
video_driver = 0;
}
void
parse_INIfile ()
{
Log ("--[ PARSING INI FILE ]------------------------------\n");
Log ("Looking in %s\n", config_file);
read_joy_mapping ();
strcpy (initial_path, get_config_string ("main", "rom_dir", "/cd"));
// rom_dir setting
Log ("Setting initial path to %s\n", initial_path);
current_config = get_config_int ("main", "config", 0);
// choose input config
Log ("Setting joypad config number to %d\n", current_config);
language = min (get_config_int ("main", "language", 0), NB_LANG - 1);
// language setting
Log ("Setting language to %d\n", language);
smode = get_config_int ("main", "smode", 3);
// sound mode setting
Log ("Setting sound mode to %d\n", smode);
use_eagle = get_config_int ("main", "eagle", 0);
// do we use EAGLE ?
Log ("Setting eagle mode to %d\n", use_eagle);
use_scanline = get_config_int ("main", "scanline", 0);
// do we use EAGLE ?
Log ("Setting scanline mode to %d\n", use_scanline);
option.want_snd_freq = get_config_int ("main", "snd_freq", 22050);
// frequency of the sound generator
Log ("Setting default frequency to %d\n", option.want_snd_freq);
sbuf_size = get_config_int ("main", "buffer_size", 512);
// size of the sound buffer
Log ("Setting sound buffer size to %d bytes\n", sbuf_size);
gamepad_driver = get_config_int ("main", "joy_type", -1);
Log ("Setting joy type to %d\n", gamepad_driver);
sound_driver = get_config_int ("main", "sound_driver", 3);
Log ("Setting sound driver to %d\n", sound_driver);
synchro = get_config_int ("main", "limit_fps", 60);
Log ("Setting fps limitation to %d\n", synchro);
option.want_fullscreen = get_config_int ("main", "start_fullscreen", 0);
Log ("Setting start in fullscreen mode to %d\n", option.want_fullscreen);
option.want_fullscreen_aspect =
get_config_int ("main", "use_fullscreen_aspect", 1);
Log ("Setting fullscreen aspect to %d\n", option.want_fullscreen_aspect);
option.want_hardware_scaling = get_config_int ("main", "use_overlay", 1);
Log ("Setting hardware scaling to %d\n", option.want_hardware_scaling);
option.want_stereo = get_config_int ("main", "stereo_sound", 1);
Log ("Setting stereo sound to %d\n", option.want_stereo);
option.window_size = get_config_int ("main", "window_size", 1);
Log ("Setting window size to %d\n", option.window_size);
option.fullscreen_width = get_config_int ("main", "fullscreen_width", 640);
Log ("Setting preferred fullscreen width to %d\n", option.fullscreen_width);
option.fullscreen_height =
get_config_int ("main", "fullscreen_height", 480);
Log ("Setting preferred fullscreen height to %d\n",
option.fullscreen_height);
option.wanted_hardware_format =
get_config_int ("main", "hardware_format", 0);
Log ("Setting wanted hardware format to %x\n",
option.wanted_hardware_format);
minimum_bios_hooking = get_config_int ("main", "minimum_bios_hooking", 0);
Log ("Minimum Bios hooking set to %d\n", minimum_bios_hooking);
strcpy (cdsystem_path, get_config_string ("main", "cdsystem_path", "/cd"));
Log ("CD system path set to %d\n", cdsystem_path);
strcpy (ISO_filename, get_config_string ("main", "cd_path", "/cd"));
Log ("CD path set to %s\n", ISO_filename);
option.want_arcade_card_emulation =
get_config_int ("main", "arcade_card", 0);
Log ("Arcade card emulation set to %d\n",
option.want_arcade_card_emulation);
option.want_supergraphx_emulation =
get_config_int ("main", "supergraphx", 1);
Log ("SuperGraphX emulation set to %d\n",
option.want_supergraphx_emulation);
option.want_television_size_emulation =
get_config_int ("main", "tv_size", 0);
Log ("Limiting graphics size to emulate tv output set to %d\n",
option.want_television_size_emulation);
Log ("End of parsing INI file\n\n");
}
char* menu(void){
bfont_draw_str(vram_s+(0)*640+(10), 640,480, "Menu - Use up/down to switch files.");
bfont_draw_str(vram_s+(24)*640+(10), 640,480, "A to select rom, B to refresh CD");
char files[256][256];
char filename1[1024];
char *ext;
file_t d;
dirent_t *de;
int i=0;
iso_reset();
d = fs_open("/cd/", O_RDONLY | O_DIR);
if (!d) {
printf("couldn't open the dir.\n");
return;
}
printf("opened the dir\n");
while( (de = fs_readdir(d)) && (i<1000) ) {
memcpy(filename1, de->name, 255);
filename1[1023] = 0;
ext = filename1 + strlen(filename1) - 4;
if (!strcmp(ext,".pce") || !strcmp(ext,".iso") ) {
// bfont_draw_str(vram_s + (112+i*24)*640 + 10, 640, 1, filename1);
strcpy(files[i], filename1);
i++;
}
}
fs_close(d);
printf("%d files found.\n", i);
cont_cond_t menu;
int regionloopend=1;
int j = 0;
int temp=0;
int temp2=0;
bfont_draw_str(vram_s+(90)*640+(200), 640,480, files[j]);
for(temp2=j;temp2-j<=10;temp2++){
if(temp2>i)
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2-i]);
else
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2]);
}
while(regionloopend){
usleep(100000);
cont_get_cond(maple_first_controller(), &menu);
if(!(menu.buttons & CONT_DPAD_UP)) {
j--;
if(j<0)
j=i-1;
vid_clear(0,0,0);
bfont_draw_str(vram_s+(90)*640+(200), 640,240, " ");
bfont_draw_str(vram_s+(90)*640+(200), 640,240, files[j]);
for(temp2=j;temp2-j<=10;temp2++){
if(temp2>i)
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2-i]);
else
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2]);
}
}
if(!(menu.buttons & CONT_DPAD_DOWN)) {
j++;
if(j>i-1)
j=0;
vid_clear(0,0,0);
bfont_draw_str(vram_s+(90)*640+(200), 640,240, " ");
bfont_draw_str(vram_s+(90)*640+(200), 640,240, files[j]);
for(temp2=j;temp2-j<=10;temp2++){
if(temp2>i)
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2-i]);
else
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2]);
}
}
if(!(menu.buttons & CONT_A)) {
printf("%s\n",files[j]);
regionloopend=0;
}
if(!(menu.buttons & CONT_B)) {
iso_reset();
d = fs_open("/cd/", O_RDONLY | O_DIR);
if (!d) {
printf("couldn't open the dir.\n");
return;
}
printf("opened the dir\n");
while( (de = fs_readdir(d)) && (i<1000) ) {
memcpy(filename1, de->name, 255);
filename1[1023] = 0;
ext = filename1 + strlen(filename1) - 4;
if (!strcmp(ext,".pce") || !strcmp(ext,".iso") ) {
// bfont_draw_str(vram_s + (112+i*24)*640 + 10, 640, 1, filename1);
strcpy(files[i], filename1);
i++;
}
}
fs_close(d);
printf("%d files found.\n", i);
bfont_draw_str(vram_s+(90)*640+(200), 640,240, " ");
bfont_draw_str(vram_s+(90)*640+(200), 640,240, files[j]);
for(temp2=j;temp2-j<=10;temp2++){
if(temp2>i)
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2-i]);
else
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2]);
}
}
if(!(menu.buttons & CONT_START)) exit(0);
bfont_draw_str(vram_s+(0)*640+(10), 640,480, "Menu - Use up/down to switch files.");
bfont_draw_str(vram_s+(24)*640+(10), 640,480, "A to select rom, B to refresh CD");
}
return files[j];
}
#ifndef _INCLUDE_CONFIG_H
#define _INCLUDE_CONFIG_H
#include "pce.h"
#include "debug.h"
#include <kos.h>
/*
#include "osd_keyboard.h"
#include "osd_cd.h"
*/
#include "interf.h"
#include "lang.h"
void set_config_file (const char *filename);
void set_config_file_back (void);
void parse_INIfile();
/* check the configuration file for options
also make some global initialisations */
void parse_commandline(int argc, char** argv);
/* check the command line for options */
extern unsigned char joy_mapping[5][16];
extern SInt32 smode,vmode;
extern char* bmdefault;
extern char cdsystem_path[PATH_MAX];
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment