revision 26:ad258e3daaa5
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 26:ad258e3daaa5 |
parent | 25:fa2d21d57942 |
child | 27:1ef09a52cd1e |
author | nkeynes |
date | Sat Dec 24 08:02:18 2005 +0000 (18 years ago) |
More structure reorgs/fixes
src/Makefile.am | view | annotate | diff | log | ||
src/Makefile.in | view | annotate | diff | log | ||
src/bootstrap.c | view | annotate | diff | log | ||
src/bootstrap.h | view | annotate | diff | log | ||
src/dream.h | view | annotate | diff | log | ||
src/dreamcast.c | view | annotate | diff | log | ||
src/dreamcast.h | view | annotate | diff | log | ||
src/gui/callbacks.c | view | annotate | diff | log | ||
src/gui/debug_win.c | view | annotate | diff | log | ||
src/gui/gui.h | view | annotate | diff | log | ||
src/loader.c | view | annotate | diff | log | ||
src/loader.h | view | annotate | diff | log |
1.1 --- a/src/Makefile.am Sat Dec 24 03:33:08 2005 +00001.2 +++ b/src/Makefile.am Sat Dec 24 08:02:18 2005 +00001.3 @@ -27,7 +27,7 @@1.4 gui/callbacks.c gui/callbacks.h \1.5 gui/gui.c gui/gui.h gui/mmr_win.c \1.6 gui/debug_win.c gui/dump_win.c \1.7 - fileio.c ipbin.c util.c1.8 + loader.c bootstrap.c util.c1.10 dream_LDADD = @PACKAGE_LIBS@ $(INTLLIBS)
2.1 --- a/src/Makefile.in Sat Dec 24 03:33:08 2005 +00002.2 +++ b/src/Makefile.in Sat Dec 24 08:02:18 2005 +00002.3 @@ -154,7 +154,7 @@2.4 gui/callbacks.c gui/callbacks.h \2.5 gui/gui.c gui/gui.h gui/mmr_win.c \2.6 gui/debug_win.c gui/dump_win.c \2.7 - fileio.c ipbin.c util.c2.8 + loader.c bootstrap.c util.c2.11 dream_LDADD = @PACKAGE_LIBS@ $(INTLLIBS)2.12 @@ -177,7 +177,7 @@2.13 aica.$(OBJEXT) maple.$(OBJEXT) controller.$(OBJEXT) \2.14 support.$(OBJEXT) interface.$(OBJEXT) callbacks.$(OBJEXT) \2.15 gui.$(OBJEXT) mmr_win.$(OBJEXT) debug_win.$(OBJEXT) \2.16 - dump_win.$(OBJEXT) fileio.$(OBJEXT) ipbin.$(OBJEXT) \2.17 + dump_win.$(OBJEXT) loader.$(OBJEXT) bootstrap.$(OBJEXT) \2.18 util.$(OBJEXT)2.19 dream_OBJECTS = $(am_dream_OBJECTS)2.20 dream_DEPENDENCIES =2.21 @@ -188,12 +188,12 @@2.22 am__depfiles_maybe = depfiles2.23 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/aica.Po ./$(DEPDIR)/armcore.Po \2.24 @AMDEP_TRUE@ ./$(DEPDIR)/armdasm.Po ./$(DEPDIR)/armmem.Po \2.25 -@AMDEP_TRUE@ ./$(DEPDIR)/asic.Po ./$(DEPDIR)/callbacks.Po \2.26 -@AMDEP_TRUE@ ./$(DEPDIR)/controller.Po ./$(DEPDIR)/debug_win.Po \2.27 -@AMDEP_TRUE@ ./$(DEPDIR)/dreamcast.Po ./$(DEPDIR)/dump_win.Po \2.28 -@AMDEP_TRUE@ ./$(DEPDIR)/fileio.Po ./$(DEPDIR)/gui.Po \2.29 +@AMDEP_TRUE@ ./$(DEPDIR)/asic.Po ./$(DEPDIR)/bootstrap.Po \2.30 +@AMDEP_TRUE@ ./$(DEPDIR)/callbacks.Po ./$(DEPDIR)/controller.Po \2.31 +@AMDEP_TRUE@ ./$(DEPDIR)/debug_win.Po ./$(DEPDIR)/dreamcast.Po \2.32 +@AMDEP_TRUE@ ./$(DEPDIR)/dump_win.Po ./$(DEPDIR)/gui.Po \2.33 @AMDEP_TRUE@ ./$(DEPDIR)/ide.Po ./$(DEPDIR)/intc.Po \2.34 -@AMDEP_TRUE@ ./$(DEPDIR)/interface.Po ./$(DEPDIR)/ipbin.Po \2.35 +@AMDEP_TRUE@ ./$(DEPDIR)/interface.Po ./$(DEPDIR)/loader.Po \2.36 @AMDEP_TRUE@ ./$(DEPDIR)/main.Po ./$(DEPDIR)/maple.Po \2.37 @AMDEP_TRUE@ ./$(DEPDIR)/mem.Po ./$(DEPDIR)/mmr_win.Po \2.38 @AMDEP_TRUE@ ./$(DEPDIR)/pvr2.Po ./$(DEPDIR)/scif.Po \2.39 @@ -258,17 +258,17 @@2.40 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/armdasm.Po@am__quote@2.41 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/armmem.Po@am__quote@2.42 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asic.Po@am__quote@2.43 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bootstrap.Po@am__quote@2.44 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/callbacks.Po@am__quote@2.45 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/controller.Po@am__quote@2.46 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug_win.Po@am__quote@2.47 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dreamcast.Po@am__quote@2.48 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dump_win.Po@am__quote@2.49 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileio.Po@am__quote@2.50 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gui.Po@am__quote@2.51 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ide.Po@am__quote@2.52 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/intc.Po@am__quote@2.53 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interface.Po@am__quote@2.54 -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipbin.Po@am__quote@2.55 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loader.Po@am__quote@2.56 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@2.57 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/maple.Po@am__quote@2.58 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem.Po@am__quote@
3.1 --- a/src/bootstrap.c Sat Dec 24 03:33:08 2005 +00003.2 +++ b/src/bootstrap.c Sat Dec 24 08:02:18 2005 +00003.3 @@ -1,31 +1,43 @@3.4 -#include <stdlib.h>3.5 -#include <stdint.h>3.6 -#include <string.h>3.7 -#include <stdio.h>3.8 -#include <unistd.h>3.9 -#include <fcntl.h>3.10 -#include <errno.h>3.11 -#include <assert.h>3.12 -#include <sys/stat.h>3.13 -#include <sys/mman.h>3.14 -#include "ipbin.h"3.15 -#include "gui/gui.h"3.16 +/**3.17 + * $Id: bootstrap.c,v 1.4 2005-12-24 08:02:14 nkeynes Exp $3.18 + *3.19 + * CD Bootstrap header parsing. Mostly for informational purposes.3.20 + *3.21 + * Copyright (c) 2005 Nathan Keynes.3.22 + *3.23 + * This program is free software; you can redistribute it and/or modify3.24 + * it under the terms of the GNU General Public License as published by3.25 + * the Free Software Foundation; either version 2 of the License, or3.26 + * (at your option) any later version.3.27 + *3.28 + * This program is distributed in the hope that it will be useful,3.29 + * but WITHOUT ANY WARRANTY; without even the implied warranty of3.30 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3.31 + * GNU General Public License for more details.3.32 + */3.34 -static char *dc_peripherals[] = { "Uses WinCE", "Unknown (0x0000002)",3.35 - "Unknown (0x0000004)", "Unknown (0x0000008)",3.36 - "VGA Box", "Unknown (0x0000020)",3.37 - "Unknown (0x0000040)", "Unknown (0x0000080)",3.38 - "Other Expansions", "Puru Puru pack",3.39 - "Mike", "Memory card",3.40 - "Basic controller", "C button",3.41 - "D button", "X button",3.42 - "Y button", "Z button",3.43 - "Expanded direction buttons",3.44 - "Analog R trigger", "Analog L trigger",3.45 - "Analog horizontal", "Analog vertical",3.46 - "Expanded analog horizontal",3.47 - "Expanded analog vertical",3.48 - "Gun", "Keyboard", "Mouse" };3.49 +#include "dream.h"3.50 +#include "bootstrap.h"3.51 +3.52 +/**3.53 + * Bootstrap header structure3.54 + */3.55 +typedef struct dc_bootstrap_head {3.56 + char hardware_id[16]; /* must be "SEGA SEGAKATANA " */3.57 + char maker_id[16]; /* ditto, "SEGA ENTERPRISES" */3.58 + char crc[4];3.59 + char padding; /* normally ascii space */3.60 + char gdrom_id[6];3.61 + char disc_no[5];3.62 + char regions[8];3.63 + char peripherals[8];3.64 + char product_id[10];3.65 + char product_ver[6];3.66 + char product_date[16];3.67 + char boot_file[16];3.68 + char vendor_id[16];3.69 + char product_name[128];3.70 +} *dc_bootstrap_head_t;3.72 static uint32_t compute_crc16( dc_bootstrap_head_t h )3.73 {3.74 @@ -44,7 +56,55 @@3.75 return n & 0xffff;3.76 }3.78 -void parse_ipbin( char *data )3.79 +3.80 +static char *dc_peripherals[] = { "Uses WinCE", "Unknown (0x0000002)",3.81 + "Unknown (0x0000004)", "Unknown (0x0000008)",3.82 + "VGA Box", "Unknown (0x0000020)",3.83 + "Unknown (0x0000040)", "Unknown (0x0000080)",3.84 + "Other Expansions", "Puru Puru pack",3.85 + "Mike", "Memory card",3.86 + "Basic controller", "C button",3.87 + "D button", "X button",3.88 + "Y button", "Z button",3.89 + "Expanded direction buttons",3.90 + "Analog R trigger", "Analog L trigger",3.91 + "Analog horizontal", "Analog vertical",3.92 + "Expanded analog horizontal",3.93 + "Expanded analog vertical",3.94 + "Gun", "Keyboard", "Mouse" };3.95 +3.96 +3.97 +/* Expansion units */3.98 +#define DC_PERIPH_WINCE 0x00000013.99 +#define DC_PERIPH_VGABOX 0x00000103.100 +#define DC_PERIPH_OTHER 0x00001003.101 +#define DC_PERIPH_PURUPURU 0x00002003.102 +#define DC_PERIPH_MIKE 0x00004003.103 +#define DC_PERIPH_MEMCARD 0x00008003.104 +/* Basic requirements */3.105 +#define DC_PERIPH_BASIC 0x0001000 /* Basic controls - start, a, b, arrows */3.106 +#define DC_PERIPH_C_BUTTON 0x00020003.107 +#define DC_PERIPH_D_BUTTON 0x00040003.108 +#define DC_PERIPH_X_BUTTON 0x00080003.109 +#define DC_PERIPH_Y_BUTTON 0x00100003.110 +#define DC_PERIPH_Z_BUTTON 0x00200003.111 +#define DC_PERIPH_EXP_DIR 0x0040000 /* Expanded direction buttons */3.112 +#define DC_PERIPH_ANALOG_R 0x0080000 /* Analog R trigger */3.113 +#define DC_PERIPH_ANALOG_L 0x0100000 /* Analog L trigger */3.114 +#define DC_PERIPH_ANALOG_H 0x0200000 /* Analog horizontal controller */3.115 +#define DC_PERIPH_ANALOG_V 0x0400000 /* Analog vertical controller */3.116 +#define DC_PERIPH_EXP_AH 0x0800000 /* Expanded analog horizontal (?) */3.117 +#define DC_PERIPH_EXP_AV 0x1000000 /* Expanded analog vertical (?) */3.118 +/* Optional peripherals */3.119 +#define DC_PERIPH_GUN 0x20000003.120 +#define DC_PERIPH_KEYBOARD 0x40000003.121 +#define DC_PERIPH_MOUSE 0x80000003.122 +3.123 +/**3.124 + * Dump the bootstrap info to the output log for infomational/debugging3.125 + * purposes.3.126 + */3.127 +void bootstrap_dump( char *data )3.128 {3.129 struct dc_bootstrap_head *head;3.130 int i, got, periph, crc, hcrc;3.131 @@ -58,7 +118,7 @@3.132 for( i=127; i>0 && buf[i] == ' '; i-- );3.133 buf[i] = '\0';3.134 periph = strtol( head->peripherals, NULL, 16 );3.135 - INFO( "Bootstrap loaded, Name: %s Author: %-16.16s",3.136 + INFO( "Bootstrap Name: %s Author: %-16.16s",3.137 buf, head->vendor_id );3.138 sprintf( buf, "%4.4s", head->crc );3.139 crc = compute_crc16(head);
4.1 --- a/src/bootstrap.h Sat Dec 24 03:33:08 2005 +00004.2 +++ b/src/bootstrap.h Sat Dec 24 08:02:18 2005 +00004.3 @@ -1,67 +1,38 @@4.4 +/**4.5 + * $Id: bootstrap.h,v 1.2 2005-12-24 08:02:14 nkeynes Exp $4.6 + *4.7 + * CD Bootstrap header parsing. Mostly for informational purposes.4.8 + *4.9 + * Copyright (c) 2005 Nathan Keynes.4.10 + *4.11 + * This program is free software; you can redistribute it and/or modify4.12 + * it under the terms of the GNU General Public License as published by4.13 + * the Free Software Foundation; either version 2 of the License, or4.14 + * (at your option) any later version.4.15 + *4.16 + * This program is distributed in the hope that it will be useful,4.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of4.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4.19 + * GNU General Public License for more details.4.20 + */4.21 +4.22 /*4.23 * IP.BIN related code. Ref: http://mc.pp.se/dc/ip0000.bin.html4.24 */4.25 -#ifndef dc_ipbin_H4.26 -#define dc_ipbin_H 14.27 -4.28 -#include <sys/types.h>4.29 +#ifndef dream_bootstrap_H4.30 +#define dream_bootstrap_H 14.32 #ifdef __cplusplus4.33 extern "C" {4.34 -#if 04.35 -}4.36 -#endif4.37 #endif4.39 -#define BOOTSTRAP_LOAD_ADDR 0x8C0080004.40 -#define BOOTSTRAP_SIZE 327684.41 -4.42 -typedef struct dc_bootstrap_head {4.43 - char hardware_id[16]; /* must be "SEGA SEGAKATANA " */4.44 - char maker_id[16]; /* ditto, "SEGA ENTERPRISES" */4.45 - char crc[4];4.46 - char padding; /* normally ascii space */4.47 - char gdrom_id[6];4.48 - char disc_no[5];4.49 - char regions[8];4.50 - char peripherals[8];4.51 - char product_id[10];4.52 - char product_ver[6];4.53 - char product_date[16];4.54 - char boot_file[16];4.55 - char vendor_id[16];4.56 - char product_name[128];4.57 -} *dc_bootstrap_head_t;4.58 -4.59 -/* Expansion units */4.60 -#define DC_PERIPH_WINCE 0x00000014.61 -#define DC_PERIPH_VGABOX 0x00000104.62 -#define DC_PERIPH_OTHER 0x00001004.63 -#define DC_PERIPH_PURUPURU 0x00002004.64 -#define DC_PERIPH_MIKE 0x00004004.65 -#define DC_PERIPH_MEMCARD 0x00008004.66 -/* Basic requirements */4.67 -#define DC_PERIPH_BASIC 0x0001000 /* Basic controls - start, a, b, arrows */4.68 -#define DC_PERIPH_C_BUTTON 0x00020004.69 -#define DC_PERIPH_D_BUTTON 0x00040004.70 -#define DC_PERIPH_X_BUTTON 0x00080004.71 -#define DC_PERIPH_Y_BUTTON 0x00100004.72 -#define DC_PERIPH_Z_BUTTON 0x00200004.73 -#define DC_PERIPH_EXP_DIR 0x0040000 /* Expanded direction buttons */4.74 -#define DC_PERIPH_ANALOG_R 0x0080000 /* Analog R trigger */4.75 -#define DC_PERIPH_ANALOG_L 0x0100000 /* Analog L trigger */4.76 -#define DC_PERIPH_ANALOG_H 0x0200000 /* Analog horizontal controller */4.77 -#define DC_PERIPH_ANALOG_V 0x0400000 /* Analog vertical controller */4.78 -#define DC_PERIPH_EXP_AH 0x0800000 /* Expanded analog horizontal (?) */4.79 -#define DC_PERIPH_EXP_AV 0x1000000 /* Expanded analog vertical (?) */4.80 -/* Optional peripherals */4.81 -#define DC_PERIPH_GUN 0x20000004.82 -#define DC_PERIPH_KEYBOARD 0x40000004.83 -#define DC_PERIPH_MOUSE 0x80000004.84 -4.85 -void parse_ipbin(char *data);4.86 +/**4.87 + * Dump the bootstrap info to the output log for infomational/debugging4.88 + * purposes.4.89 + */4.90 +void bootstrap_dump(char *data);4.92 #ifdef __cplusplus4.93 }4.94 #endif4.95 -#endif4.96 +#endif /* !dream_bootstrap_H */
5.1 --- a/src/dream.h Sat Dec 24 03:33:08 2005 +00005.2 +++ b/src/dream.h Sat Dec 24 08:02:18 2005 +00005.3 @@ -26,7 +26,7 @@5.4 #define MODULE_ID 05.5 #endif5.7 -void emit( void *, int level, int source, char *msg, ... );5.8 +void emit( void *, int level, int source, const char *msg, ... );5.10 #define FATAL( ... ) emit( NULL, EMIT_FATAL, MODULE_ID, __VA_ARGS__ )5.11 #define ERROR( ... ) emit( NULL, EMIT_ERR, MODULE_ID, __VA_ARGS__ )
6.1 --- a/src/dreamcast.c Sat Dec 24 03:33:08 2005 +00006.2 +++ b/src/dreamcast.c Sat Dec 24 08:02:18 2005 +00006.3 @@ -1,3 +1,22 @@6.4 +/**6.5 + * $Id: dreamcast.c,v 1.9 2005-12-24 08:02:14 nkeynes Exp $6.6 + * Central switchboard for the system. This pulls all the individual modules6.7 + * together into some kind of coherent structure. This is also where you'd6.8 + * add Naomi support, if I ever get a board to play with...6.9 + *6.10 + * Copyright (c) 2005 Nathan Keynes.6.11 + *6.12 + * This program is free software; you can redistribute it and/or modify6.13 + * it under the terms of the GNU General Public License as published by6.14 + * the Free Software Foundation; either version 2 of the License, or6.15 + * (at your option) any later version.6.16 + *6.17 + * This program is distributed in the hope that it will be useful,6.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of6.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the6.20 + * GNU General Public License for more details.6.21 + */6.22 +6.23 #include <errno.h>6.24 #include "dream.h"6.25 #include "mem.h"6.26 @@ -8,26 +27,24 @@6.27 #include "maple/maple.h"6.28 #include "modules.h"6.30 -/* Central switchboard for the system */6.31 +/**6.32 + * Current state of the DC virtual machine6.33 + */6.34 +#define STATE_UNINIT 06.35 +#define STATE_RUNNING 16.36 +#define STATE_STOPPING 26.37 +#define STATE_STOPPED 36.38 +static volatile int dreamcast_state = STATE_UNINIT;6.39 +static uint32_t timeslice_length = DEFAULT_TIMESLICE_LENGTH;6.40 +static char *dreamcast_config = "DEFAULT";6.42 #define MAX_MODULES 326.43 static int num_modules = 0;6.44 -static int dreamcast_state = 0;6.45 -static char *dreamcast_config = "DEFAULT";6.46 dreamcast_module_t modules[MAX_MODULES];6.48 -struct save_state_header {6.49 - char magic[16];6.50 - uint32_t version;6.51 - uint32_t module_count;6.52 -};6.53 -6.54 -6.55 /**6.56 * This function is responsible for defining how all the pieces of the6.57 - * dreamcast actually fit together. Among other things, this lets us6.58 - * (reasonably) easily redefine the structure for eg various versions of the6.59 - * Naomi.6.60 + * dreamcast actually fit together.6.61 *6.62 * Note currently the locations of the various MMIO pages are hard coded in6.63 * the MMIO definitions - they should probably be moved here.6.64 @@ -96,7 +113,7 @@6.65 while( dreamcast_state == STATE_RUNNING ) {6.66 for( i=0; i<num_modules; i++ ) {6.67 if( modules[i]->run_time_slice != NULL )6.68 - modules[i]->run_time_slice( TIMESLICE_LENGTH );6.69 + modules[i]->run_time_slice( timeslice_length );6.70 }6.72 }6.73 @@ -115,6 +132,23 @@6.74 dreamcast_state = STATE_STOPPING;6.75 }6.77 +gboolean dreamcast_is_running( void )6.78 +{6.79 + return dreamcast_state == STATE_RUNNING;6.80 +}6.81 +6.82 +6.83 +/********************************* Save States *****************************/6.84 +6.85 +#define DREAMCAST_SAVE_MAGIC "%!-DreamOn!Save\0"6.86 +#define DREAMCAST_SAVE_VERSION 0x000100006.87 +6.88 +struct save_state_header {6.89 + char magic[16];6.90 + uint32_t version;6.91 + uint32_t module_count;6.92 +};6.93 +6.94 int dreamcast_load_state( const gchar *filename )6.95 {6.96 int i,j;
7.1 --- a/src/dreamcast.h Sat Dec 24 03:33:08 2005 +00007.2 +++ b/src/dreamcast.h Sat Dec 24 08:02:18 2005 +00007.3 @@ -1,8 +1,27 @@7.4 +/**7.5 + * $Id: dreamcast.h,v 1.7 2005-12-24 08:02:14 nkeynes Exp $7.6 + *7.7 + * Public interface for dreamcast.c -7.8 + * Central switchboard for the system. This pulls all the individual modules7.9 + * together into some kind of coherent structure. This is also where you'd7.10 + * add Naomi support, if I ever get a board to play with...7.11 + *7.12 + * Copyright (c) 2005 Nathan Keynes.7.13 + *7.14 + * This program is free software; you can redistribute it and/or modify7.15 + * it under the terms of the GNU General Public License as published by7.16 + * the Free Software Foundation; either version 2 of the License, or7.17 + * (at your option) any later version.7.18 + *7.19 + * This program is distributed in the hope that it will be useful,7.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of7.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7.22 + * GNU General Public License for more details.7.23 + */7.25 #ifndef dreamcast_H7.26 #define dreamcast_H 17.28 -#include <stdlib.h>7.29 #include <stdio.h>7.30 #include <glib/gtypes.h>7.32 @@ -10,14 +29,7 @@7.33 extern "C" {7.34 #endif7.36 -#define DREAMCAST_SAVE_MAGIC "%!-DreamOn!Save\0"7.37 -#define DREAMCAST_SAVE_VERSION 0x000100007.38 -7.39 -#define TIMESLICE_LENGTH 1000 /* microseconds */7.40 -7.41 -#define STATE_RUNNING 17.42 -#define STATE_STOPPING 27.43 -#define STATE_STOPPED 37.44 +#define DEFAULT_TIMESLICE_LENGTH 1000 /* microseconds */7.46 void dreamcast_init(void);7.47 void dreamcast_reset(void);7.48 @@ -27,11 +39,8 @@7.49 int dreamcast_save_state( const gchar *filename );7.50 int dreamcast_load_state( const gchar *filename );7.52 -int open_file( gchar *filename );7.53 -int load_bin_file( gchar *filename );7.54 -7.55 #ifdef __cplusplus7.56 }7.57 #endif7.59 -#endif /* !dream_machine_H */7.60 +#endif /* !dreamcast_H */
8.1 --- a/src/gui/callbacks.c Sat Dec 24 03:33:08 2005 +00008.2 +++ b/src/gui/callbacks.c Sat Dec 24 08:02:18 2005 +00008.3 @@ -1,15 +1,34 @@8.4 +/**8.5 + * $Id: callbacks.c,v 1.8 2005-12-24 08:02:18 nkeynes Exp $8.6 + *8.7 + * All GTK callbacks go here (stubs are autogenerated by Glade)8.8 + *8.9 + * Copyright (c) 2005 Nathan Keynes.8.10 + *8.11 + * This program is free software; you can redistribute it and/or modify8.12 + * it under the terms of the GNU General Public License as published by8.13 + * the Free Software Foundation; either version 2 of the License, or8.14 + * (at your option) any later version.8.15 + *8.16 + * This program is distributed in the hope that it will be useful,8.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of8.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8.19 + * GNU General Public License for more details.8.20 + */8.21 +8.22 #ifdef HAVE_CONFIG_H8.23 # include <config.h>8.24 #endif8.26 #include <gnome.h>8.28 -#include "callbacks.h"8.29 -#include "interface.h"8.30 -#include "gui.h"8.31 +#include "gui/callbacks.h"8.32 +#include "gui/interface.h"8.33 +#include "gui/gui.h"8.34 #include "sh4core.h"8.35 #include "asic.h"8.36 #include "dreamcast.h"8.37 +#include "loader.h"8.39 int selected_pc = -1;8.41 @@ -25,7 +44,7 @@8.42 on_open1_activate (GtkMenuItem *menuitem,8.43 gpointer user_data)8.44 {8.45 - open_file_dialog( "Open...", open_file, NULL, NULL );8.46 + open_file_dialog( "Open...", file_load_magic, NULL, NULL );8.47 }8.50 @@ -74,7 +93,7 @@8.51 on_load_btn_clicked (GtkButton *button,8.52 gpointer user_data)8.53 {8.54 - open_file_dialog( "Open...", load_bin_file, NULL, NULL );8.55 + open_file_dialog( "Open...", file_load_magic, NULL, NULL );8.56 }8.59 @@ -82,8 +101,7 @@8.60 on_reset_btn_clicked (GtkButton *button,8.61 gpointer user_data)8.62 {8.63 - sh4_reset();8.64 - mem_reset();8.65 + dreamcast_reset();8.66 update_gui();8.67 }8.69 @@ -92,9 +110,7 @@8.70 on_stop_btn_clicked (GtkButton *button,8.71 gpointer user_data)8.72 {8.73 - if( sh4_isrunning() ) {8.74 - sh4_stop();8.75 - }8.76 + dreamcast_stop();8.77 }8.80 @@ -111,7 +127,6 @@8.81 on_run_btn_clicked (GtkButton *button,8.82 gpointer user_data)8.83 {8.84 - debug_info_t data = get_debug_info(GTK_WIDGET(button));8.85 dreamcast_run();8.86 }8.88 @@ -120,7 +135,6 @@8.89 on_runto_btn_clicked (GtkButton *button,8.90 gpointer user_data)8.91 {8.92 - debug_info_t data = get_debug_info(GTK_WIDGET(button));8.93 if( selected_pc == -1 )8.94 WARN( "No address selected, so can't run to it", NULL );8.95 else {8.96 @@ -145,7 +159,7 @@8.97 gpointer user_data)8.98 {8.99 gtk_main_quit();8.100 - return FALSE;8.101 + return FALSE;8.102 }
9.1 --- a/src/gui/debug_win.c Sat Dec 24 03:33:08 2005 +00009.2 +++ b/src/gui/debug_win.c Sat Dec 24 08:02:18 2005 +00009.3 @@ -1,5 +1,5 @@9.4 /**9.5 - * $Id: debug_win.c,v 1.6 2005-12-12 10:37:36 nkeynes Exp $9.6 + * $Id: debug_win.c,v 1.7 2005-12-24 08:02:18 nkeynes Exp $9.7 * This file is responsible for the main debugger gui frame.9.8 *9.9 * Copyright (c) 2005 Nathan Keynes.9.10 @@ -203,7 +203,7 @@9.11 data->disasm_pc = pc;9.12 }9.14 -void set_disassembly_cpu( debug_info_t data, char *cpu )9.15 +void set_disassembly_cpu( debug_info_t data, const gchar *cpu )9.16 {9.17 int i;9.18 for( i=0; data->cpu_list[i] != NULL; i++ ) {9.19 @@ -229,7 +229,7 @@9.20 }9.23 -void emit( void *ptr, int level, int source, char *msg, ... )9.24 +void emit( void *ptr, int level, int source, const char *msg, ... )9.25 {9.26 char buf[20], addr[10] = "", *p;9.27 char *arr[3] = {buf, addr};
10.1 --- a/src/gui/gui.h Sat Dec 24 03:33:08 2005 +000010.2 +++ b/src/gui/gui.h Sat Dec 24 08:02:18 2005 +000010.3 @@ -35,7 +35,7 @@10.4 void dump_win_update_all();10.5 void set_disassembly_region( debug_info_t debug, unsigned int page );10.6 void set_disassembly_pc( debug_info_t debug, unsigned int pc, gboolean select );10.7 -void set_disassembly_cpu( debug_info_t debug, char *cpu_name );10.8 +void set_disassembly_cpu( debug_info_t debug, const gchar *cpu_name );10.9 void jump_to_disassembly( debug_info_t debug, unsigned int addr, gboolean select );10.10 void jump_to_pc( debug_info_t debug, gboolean select );10.11 uint32_t row_to_address( debug_info_t debug, int row );
11.1 --- a/src/loader.c Sat Dec 24 03:33:08 2005 +000011.2 +++ b/src/loader.c Sat Dec 24 08:02:18 2005 +000011.3 @@ -1,26 +1,48 @@11.4 -/*11.5 +/**11.6 + * $Id: loader.c,v 1.7 2005-12-24 08:02:14 nkeynes Exp $11.7 *11.8 + * File loading routines, mostly for loading demos without going through the11.9 + * whole procedure of making a CD image for them.11.10 + *11.11 + * Copyright (c) 2005 Nathan Keynes.11.12 + *11.13 + * This program is free software; you can redistribute it and/or modify11.14 + * it under the terms of the GNU General Public License as published by11.15 + * the Free Software Foundation; either version 2 of the License, or11.16 + * (at your option) any later version.11.17 + *11.18 + * This program is distributed in the hope that it will be useful,11.19 + * but WITHOUT ANY WARRANTY; without even the implied warranty of11.20 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11.21 + * GNU General Public License for more details.11.22 */11.24 #include <stdio.h>11.25 #include <fcntl.h>11.26 #include <sys/stat.h>11.27 -#include <sys/mman.h>11.28 #include <errno.h>11.29 #include <stdint.h>11.30 #include "gui/gui.h"11.31 -#include "ipbin.h"11.32 +#include "mem.h"11.33 #include "sh4core.h"11.34 -#include "pvr2.h"11.35 -#include "mem.h"11.36 +#include "bootstrap.h"11.38 -char ip_bin_magic[32] = "SEGA SEGAKATANA SEGA ENTERPRISES";11.39 +char bootstrap_magic[32] = "SEGA SEGAKATANA SEGA ENTERPRISES";11.40 char iso_magic[6] = "\001CD001";11.41 +char *file_loader_extensions[][2] = {11.42 + { "sbi", "Self Boot Inducer" },11.43 + { "bin", "SH4 Bin file" },11.44 + { NULL, NULL } };11.45 +11.46 +#define BOOTSTRAP_LOAD_ADDR 0x8C00800011.47 +#define BOOTSTRAP_SIZE 3276811.48 +11.49 +#define BINARY_LOAD_ADDR 0x8C01000011.51 #define CDI_V2 0x8000000411.52 #define CDI_V3 0x8000000511.54 -int open_file( const gchar *filename )11.55 +gboolean file_load_magic( const gchar *filename )11.56 {11.57 char buf[32];11.58 uint32_t tmpa[2];11.59 @@ -30,33 +52,29 @@11.60 if( fd == -1 ) {11.61 ERROR( "Unable to open file: '%s' (%s)", filename,11.62 strerror(errno) );11.63 - return;11.64 + return FALSE;11.65 }11.67 fstat( fd, &st );11.68 if( st.st_size < 32768 ) {11.69 ERROR( "File '%s' too small to be a dreamcast image", filename );11.70 close(fd);11.71 - return;11.72 + return FALSE;11.73 }11.75 /* begin magic */11.76 if( read( fd, buf, 32 ) != 32 ) {11.77 ERROR( "Unable to read from file '%s'", filename );11.78 close(fd);11.79 - return;11.80 + return FALSE;11.81 }11.82 - if( memcmp( buf, ip_bin_magic, 32 ) == 0 ) {11.83 + if( memcmp( buf, bootstrap_magic, 32 ) == 0 ) {11.84 /* we have a DC bootstrap */11.85 if( st.st_size == BOOTSTRAP_SIZE ) {11.86 char *load = mem_get_region( BOOTSTRAP_LOAD_ADDR );11.87 - /* Just the bootstrap, no image... */11.88 - WARN( "File '%s' contains bootstrap only, loading anyway",11.89 - filename );11.90 lseek( fd, 0, SEEK_SET );11.91 read( fd, load, BOOTSTRAP_SIZE );11.92 - parse_ipbin( load );11.93 - sh4_reset();11.94 + bootstrap_dump( load );11.95 sh4_set_pc( BOOTSTRAP_LOAD_ADDR + 0x300 );11.96 set_disassembly_region( main_debug, BOOTSTRAP_LOAD_ADDR );11.97 set_disassembly_pc( main_debug, sh4r.pc, TRUE );11.98 @@ -71,26 +89,21 @@11.99 filename );11.100 }11.101 }11.102 + } else if( memcmp( buf, "PK\x03\x04", 4 ) == 0 ) {11.103 + /* ZIP file, aka SBI file */11.104 + WARN( "SBI files not supported yet" );11.105 } else {11.106 - /* check if it's a CDI file: */11.107 - lseek( fd, -8, SEEK_END );11.108 - read( fd, &tmpa, 8 );11.109 - if( tmpa[0] == CDI_V2 || tmpa[0] == CDI_V3 ) {11.110 - /* Yup, it is */11.111 - INFO( "Loading CDI file '%s'", filename );11.112 - } else {11.113 - ERROR( "Don't know what to do with '%s'", filename );11.114 - }11.115 - }11.116 + /* Assume raw binary */11.117 + file_load_binary( filename );11.118 + }11.119 close(fd);11.120 - return 0;11.121 + return TRUE;11.122 }11.124 -int load_bin_file( const gchar *filename ) {11.125 - mem_load_block( filename, 0x8c010000, -1 );11.126 - sh4_set_pc( 0x8c010000 );11.127 - set_disassembly_region( main_debug, 0x8c010000 );11.128 +int file_load_binary( const gchar *filename ) {11.129 + mem_load_block( filename, BINARY_LOAD_ADDR, -1 );11.130 + sh4_set_pc( BINARY_LOAD_ADDR );11.131 + set_disassembly_region( main_debug, BINARY_LOAD_ADDR );11.132 set_disassembly_pc( main_debug, sh4r.pc, TRUE );11.133 - pvr2_set_base_address( 0x00025940 );11.134 update_gui();11.135 }
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +000012.2 +++ b/src/loader.h Sat Dec 24 08:02:18 2005 +000012.3 @@ -0,0 +1,72 @@12.4 +/**12.5 + * $Id: loader.h,v 1.1 2005-12-24 08:02:14 nkeynes Exp $12.6 + *12.7 + * Interface declarations for the binary loader routines (loader.c, elf.c)12.8 + *12.9 + * Copyright (c) 2005 Nathan Keynes.12.10 + *12.11 + * This program is free software; you can redistribute it and/or modify12.12 + * it under the terms of the GNU General Public License as published by12.13 + * the Free Software Foundation; either version 2 of the License, or12.14 + * (at your option) any later version.12.15 + *12.16 + * This program is distributed in the hope that it will be useful,12.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of12.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12.19 + * GNU General Public License for more details.12.20 + */12.21 +12.22 +#ifndef dreamcast_loader_H12.23 +#define dreamcast_loader_H 112.24 +12.25 +#include <stdio.h>12.26 +#include <glib/gtypes.h>12.27 +12.28 +#ifdef __cplusplus12.29 +extern "C" {12.30 +#endif12.31 +12.32 +/**12.33 + * NULL-terminated list of file extension/name pairs,12.34 + * supported by the loader12.35 + */12.36 +extern char *file_loader_extensions[][2];12.37 +12.38 +/**12.39 + * Load the CD bootstrap, aka IP.BIN. Identified by "SEGA SEGAKATANA" at12.40 + * start of file. IP.BIN is loaded as-is at 8C008000.12.41 + * This is mainly for testing as it's unlikely anyone would want to do this12.42 + * for any other reason.12.43 + * @return TRUE on success, otherwise FALSE and errno12.44 + */12.45 +gboolean file_load_bootstrap( gchar *filename );12.46 +12.47 +/**12.48 + * Load a miscellaneous .bin file, as commonly used in demos. No magic12.49 + * applies, file is loaded as is at 8C01000012.50 + */12.51 +gboolean file_load_binary( gchar *filename );12.52 +12.53 +/**12.54 + * Load a "Self Boot Inducer" .sbi file, also commonly used to package12.55 + * demos. (Actually a ZIP file with a predefined structure12.56 + */12.57 +gboolean file_load_sbi( gchar *filename );12.58 +12.59 +/**12.60 + * Load an ELF executable binary file. Origin is file-dependent.12.61 + */12.62 +gboolean file_load_elf( gchar *filename );12.63 +12.64 +/**12.65 + * Load any of the above file types, using the appropriate magic to determine12.66 + * which is actually applicable12.67 + */12.68 +gboolean file_load_magic( gchar *filename );12.69 +12.70 +#ifdef __cplusplus12.71 +}12.72 +#endif12.73 +12.74 +#endif /* !dream_loader_H */12.75 +
.