Commit 408a80ef authored by Donald Haase's avatar Donald Haase
Browse files

Fixes required for the main body update and for KOS upport.

First working commit. Runs at ... 50% speed? and sound is
still broken.
parent e2617c9b
Showing with 152 additions and 262 deletions
+152 -262
......@@ -15,6 +15,7 @@
*/
#include "dciniconfig.h"
#include "utils.h"
#include <dirent.h>
char* menu(void);
......@@ -129,7 +130,7 @@ parse_commandline (int argc, char **argv)
{
strcpy (cart_name, "/cd/");
strcpy (cart_name, tmp_basepath);
strcat (cart_name,menu());
printf("%s\n", cart_name);
Log ("Setting card name to %s\n", cart_name);
......@@ -151,7 +152,7 @@ parse_INIfile ()
read_joy_mapping ();
strcpy (initial_path, get_config_string ("main", "rom_dir", "/cd"));
strcpy (initial_path, get_config_string ("main", "rom_dir", tmp_basepath));
// rom_dir setting
......@@ -245,11 +246,11 @@ parse_INIfile ()
Log ("Minimum Bios hooking set to %d\n", minimum_bios_hooking);
strcpy (cdsystem_path, get_config_string ("main", "cdsystem_path", "/cd"));
strcpy (cdsystem_path, get_config_string ("main", "cdsystem_path", tmp_basepath));
Log ("CD system path set to %d\n", cdsystem_path);
strcpy (ISO_filename, get_config_string ("main", "cd_path", "/cd"));
strcpy (ISO_filename, get_config_string ("main", "cd_path", tmp_basepath));
Log ("CD path set to %s\n", ISO_filename);
......@@ -274,74 +275,80 @@ parse_INIfile ()
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");
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 *files[256] = {0};
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++;
}
}
int count = 0;
int rescan_dir = 1;
DIR *d;
struct dirent *entry;
cont_state_t *menu_cont;
int regionloopend=1;
int j = 0;
int temp=0;
int temp2=0;
while(regionloopend){
if(rescan_dir) {
iso_reset();
for(count = 0; count < sizeof(files)/sizeof(files[0]); count++)
free(files[count]);
count = 0;
/* Open the directory */
if (!(d = opendir(tmp_basepath))) {
printf("browse_directory: opendir failed for %s\n", tmp_basepath);
return 0;
}
/* Read all the filenames in the directory */
while((entry = readdir(d)) && count < sizeof(files)) {
if(entry->d_type == DT_DIR) continue;
//if (!strcmp(ext,".pce") || !strcmp(ext,".iso") ) {
printf("Found file: %s\n", entry->d_name);
files[count] = calloc(1,strlen(entry->d_name) + 1);
strncpy(files[count], entry->d_name, strlen(entry->d_name));
count++;
}
/* Close directory */
closedir(d);
printf("%d files found.\n", count);
bfont_draw_str(vram_s+(90)*640+(200), 640,480, files[j]);
for(temp2=j;temp2-j<=10;temp2++){
if(temp2>count)
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2-count]);
else
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2]);
}
rescan_dir = 0;
}
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);
menu_cont = (cont_state_t *)maple_dev_status(maple_enum_type(0, MAPLE_FUNC_CONTROLLER));
if(!(menu.buttons & CONT_DPAD_UP)) {
j--;
if(j<0)
j=i-1;
if(menu_cont->dpad_up) {
j--;
if(j<0) {j=count-1;}
vid_clear(0,0,0);
......@@ -350,16 +357,16 @@ while(regionloopend){
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]);
if(temp2>count)
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2-count]);
else
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2]);
}
}
if(!(menu.buttons & CONT_DPAD_DOWN)) {
if(menu_cont->dpad_down) {
j++;
if(j>i-1)
if(j>count-1)
j=0;
vid_clear(0,0,0);
......@@ -367,8 +374,8 @@ while(regionloopend){
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]);
if(temp2>count)
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2-count]);
else
bfont_draw_str(vram_s + (112+(temp2-j)*24)*640 + 10, 640, 1, files[temp2]);
}
......@@ -378,58 +385,19 @@ while(regionloopend){
if(!(menu.buttons & CONT_A)) {
if(menu_cont->a) {
printf("%s\n",files[j]);
regionloopend=0;
}
if(!(menu.buttons & CONT_B)) {
if(menu_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]);
}
rescan_dir = 1;
}
if(!(menu.buttons & CONT_START)) exit(0);
if(menu_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");
......
#Hugo
INC =-DFASTCALL= -I. -DDREAMCAST -Dlocal= -DINLINE=__inline__ -DPATH_MAX=255 -DMAX_INPUT=32 -DLOWERCASEFILES -DLSB_FIRST -DSIZEOF_CHAR=1 -DSIZEOF_SHORT_INT=2 -DSIZEOF_INT=4 -DBYTEORD_LSBFIRST -DKERNEL_DS -DBSD_CD_HARDWARE_SUPPORT -DNEW_GFX_ENGINE
INC =-DTHD_KERNEL_STACK_SIZE=409600 -I. -DDREAMCAST -Dlocal= -DPATH_MAX=255 -DMAX_INPUT=32 \
-DLSB_FIRST -DSIZEOF_CHAR=1 -DSIZEOF_SHORT_INT=2 -DSIZEOF_LONG_INT=4 -DBYTEORD_LSBFIRST -DKERNEL_DS -DBSD_CD_HARDWARE_SUPPORT -DNEW_GFX_ENGINE
NAME = Hugo
TARGET = $(NAME).elf
OBJS = bios.o bp.o cd.o dis.o pce.o debug.o followop.o format.o gfx.o h6280.o hard_pce.o hcd.o hugo.o lang.o list_rom.o \
OBJS = h6280.o bios.o bp.o cd.o dis.o pce.o debug.o followop.o format.o gfx.o hard_pce.o hcd.o hugo.o lang.o list_rom.o \
lsmp3.o mix.o optable.o osd_dreamcast_machine.o osd_dreamcast_music.o \
osd_dreamcast_snd.o osd_dreamcast_gfx.o pcecd.o sound.o sprite.o subs_eagle.o trans_fx.o \
unzip.o utils.o view_inf.o view_zp.o miniunz.o osd_dreamcast_cd.o dciniconfig.o osd_dreamcast_keyboard.o cheat.o aica.o
unzip.o utils.o view_inf.o view_zp.o miniunz.o osd_dreamcast_cd.o dciniconfig.o osd_dreamcast_keyboard.o cheat.o aica.o romdisk.o
KOS_ROMDISK_DIR = romdisk
all: Hugo.bin rm-elf $(TARGET)
clean:
-rm -f $(TARGET) $(OBJS) romdisk.*
all: $(NAME).bin rm-elf $(TARGET)
include $(KOS_BASE)/Makefile.rules
OPT1= -O3
KOS_CFLAGS = $(INC) -ml -m4-single-only -D_arch_dreamcast -D_arch_sub_pristine $(OPT1) \
-I$(KOS_BASE)/../kos-ports/include -I$(KOS_BASE)/include -I$(KOS_BASE)/kernel/arch/dreamcast/include -I$(KOS_BASE)/addons/include \
-I$(KOS_BASE)/../kos-ports/include/zlib
clean: rm-elf
-rm -f $(OBJS) romdisk.*
rm-elf:
-rm -f $(TARGET) romdisk.*
-rm -f $(TARGET)
$(TARGET): $(OBJS) romdisk.o
$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \
$(OBJS) romdisk.o $(OBJEXTRA) -L$(KOS_BASE)/lib -lgcc -lm -lz $(KOS_LIBS)
KOS_CFLAGS += $(INC) -I$(KOS_BASE)/../kos-ports/include/zlib
romdisk.img:
$(KOS_GENROMFS) -f romdisk.img -d romdisk -v
romdisk.o: romdisk.img
$(KOS_BASE)/utils/bin2o/bin2o romdisk.img romdisk romdisk.o
$(TARGET): $(OBJS)
kos-cc -o $(TARGET) $(OBJS) -lz
$(NAME).bin: $(NAME).elf
$(KOS_OBJCOPY) -O binary -R .stack Hugo.elf $(NAME).bin
$(KOS_BASE)/utils/scramble/scramble $(NAME).bin 1ST_READ.bin
run: $(TARGET)
$(KOS_LOADER) $(TARGET)
run:
arp -s 192.168.1.99 00-d0-f1-02-a5-a6
dc-tool -t 192.168.1.99 -x $(NAME).bin
runCD:
arp -s 192.168.1.99 00-d0-f1-02-a5-a6
dc-tool -t 192.168.1.99 -i DC.iso -x $(NAME).bin
......
#ifndef DREAMCAST
#include <sys/types.h>
#include <unistd.h>
#include <string.h>
#endif
#include "osd_dreamcast_cd.h"
#include "utils.h"
#include "hard_pce.h"
#include <kos.h>
static int cdda_min_track;
static int cdda_max_track;
static int cdda_disk_length;
static int cdda_track_start;
static int cdda_track_end;
static int cdda_loop_counter;
int cdda_min_track;
int cdda_max_track;
int cdda_disk_length;
int cdda_track_start;
int cdda_track_end;
int cdda_loop_counter;
//static SDL_CD *cdrom;
static CDROM_TOC *cdrom;
......
......@@ -38,6 +38,7 @@ int osd_gfx_init(void)
SetPalette();
vid_empty();
// vid_buf = (unsigned short *)memalign(32,DST_WIDTH*DST_HEIGHT*2);
return 1;
}
void osd_gfx_set_color(UChar index, UChar r, UChar g, UChar b)
......@@ -67,51 +68,31 @@ void line_copy(uint8 *src, uint16 *dst, int count)
}
void line_copy_sq(uint8 *src, uint16 *dst, int count)
{
unsigned int *d = (unsigned int *)(void *)
(0xe0000000 | (((unsigned long)dst) & 0x03ffffe0));
/* Set store queue memory area as desired */
QACR0 = ((((unsigned int)dst)>>26)<<2)&0x1c;
QACR1 = ((((unsigned int)dst)>>26)<<2)&0x1c;
{
/* Set store queue memory area as desired */
UInt32 *d = sq_lock(dst);
/* fill/write queues as many times necessary */
count >>= 4;
while(count--) {
int v;
v = palette[*src++];
v|= palette[*src++]<<16;
d[0] = v;
v = palette[*src++];
v|= palette[*src++]<<16;
d[1] = v;
v = palette[*src++];
v|= palette[*src++]<<16;
d[2] = v;
v = palette[*src++];
v|= palette[*src++]<<16;
d[3] = v;
v = palette[*src++];
v|= palette[*src++]<<16;
d[4] = v;
v = palette[*src++];
v|= palette[*src++]<<16;
d[5] = v;
v = palette[*src++];
v|= palette[*src++]<<16;
d[6] = v;
v = palette[*src++];
v|= palette[*src++]<<16;
d[7] = v;
asm("pref @%0" : : "r" (d));
d[0] = palette[*src++] | palette[*src++]<<16;
d[1] = palette[*src++] | palette[*src++]<<16;
d[2] = palette[*src++] | palette[*src++]<<16;
d[3] = palette[*src++] | palette[*src++]<<16;
d[4] = palette[*src++] | palette[*src++]<<16;
d[5] = palette[*src++] | palette[*src++]<<16;
d[6] = palette[*src++] | palette[*src++]<<16;
d[7] = palette[*src++] | palette[*src++]<<16;
sq_flush(d);
d += 8;
}
/* Wait for both store queues to complete */
d = (unsigned int *)0xe0000000;
d[0] = d[8] = 0;
sq_wait();
sq_unlock();
}
......
......@@ -3,8 +3,6 @@
#include "sound.h"
int read_input (int port);
cont_cond_t controller[4];
short *key;
///Int16 joy[J_MAX];
......@@ -36,34 +34,34 @@ static int sound = 1;
int read_input (int port)
{
static char autoI_delay = 0, autoII_delay = 0;
int tmp;
int tmp = 0;
tmp = 0;
cont_get_cond(maple_first_controller(), &controller[port]);
cont_state_t *cont = (cont_state_t *)maple_dev_status(maple_enum_type(port, MAPLE_FUNC_CONTROLLER));
if(!cont) return 0;
if(!(controller[port].buttons & CONT_DPAD_UP))
if(cont->dpad_up)
tmp |=JOY_UP;
else if(!(controller[port].buttons & CONT_DPAD_DOWN))
else if(cont->dpad_down)
tmp |=JOY_DOWN;
if(!(controller[port].buttons & CONT_DPAD_LEFT))
if(cont->dpad_left)
tmp |=JOY_LEFT;
else if(!(controller[port].buttons & CONT_DPAD_RIGHT))
else if(cont->dpad_right)
tmp |=JOY_RIGHT;
if(!(controller[port].buttons & CONT_A))
if(cont->a)
tmp |=JOY_A;
if(!(controller[port].buttons & CONT_B))
if(cont->b)
tmp |=JOY_B;
if(!(controller[port].buttons & CONT_X))
if(cont->x)
tmp |=JOY_RUN;
if(!(controller[port].buttons & CONT_Y))
if(cont->y)
tmp |=JOY_SELECT;
if(!(controller[port].buttons & CONT_START)){
if(cont->start){
// SDL_PauseAudio(sound);
sound^=1;
}
if(!(controller[port].buttons & CONT_START) && !(controller[port].buttons & CONT_A)) exit(0);
if((cont->start) && (cont->a)) exit(0);
return tmp;
}
......
......@@ -2,6 +2,10 @@
#include "osd_dreamcast_machine.h"
#include "osd_dreamcast_music.h"
#include "pce.h"
#include <dc/vblank.h>
int vbl_hnd;
int netplay_mode;
char initial_path[PATH_MAX] = "";
......@@ -33,10 +37,11 @@ int *fd[4];
//UInt32 interrupt_60hz(UInt32, void*);
// declaration of the actual callback to call 60 times a second
void dcinterrupt_60hz(irq_t source, irq_context_t *context){
void dcinterrupt_60hz(long unsigned int, void *){
interrupt_60hz(0,0);
//printf("Timer is working");
}
int osd_init_machine(void)
{
......@@ -62,16 +67,13 @@ int osd_init_machine(void)
///timerId = SDL_AddTimer(1000 / 60, interrupt_60hz, NULL);
timer_prime (TMU2, 60, 1);
irq_set_handler (EXC_TMU2_TUNI2, dcinterrupt_60hz);
timer_start (TMU2);
printf("Timer initialised\n");
vbl_hnd = vblank_handler_add(dcinterrupt_60hz, NULL);
printf("Timer initialised\n");
host.sound.stereo = 1;
host.sound.freq = 22050;
host.sound.sample_size = BUFFER_LEN/2;
host.sound.signed_sound = 0;
host.sound.stereo = 1;
host.sound.freq = 22050;
host.sound.sample_size = BUFFER_LEN/2;
host.sound.signed_sound = 0;
Log ("End of initialisation of the machine\n");
......@@ -98,7 +100,7 @@ osd_shut_machine (void)
if (sound_driver == 1)
osd_snd_set_volume (0);
timer_stop(TMU2);
vblank_handler_remove(vbl_hnd);
if (dump_snd)
fclose(out_snd);
......@@ -118,10 +120,8 @@ osd_shut_machine (void)
*****************************************************************************/
SChar osd_keypressed(void)
{
#warning implement keypressed with sdl
}
return (SChar)0;
}
/*****************************************************************************
......@@ -134,8 +134,8 @@ SChar osd_keypressed(void)
*****************************************************************************/
UInt16 osd_readkey(void)
{
}
return 0;
}
/*****************************************************************************
......@@ -160,8 +160,7 @@ void osd_fix_filename_slashes(char* s)
Return: nothing
*****************************************************************************/
void
osd_init_paths(int argc, char* argv[])
void osd_init_paths(int argc, char* argv[])
{
strcpy(tmp_basepath,"/pc");
strcpy(tmp_basepath,"/rd/");
}
......@@ -3,16 +3,10 @@
#include "mix.h"
#define SPU_RAM_BASE 0xa0800000
#define SPU_POS 0x10000
#define BUFFER_LEN 512*2
Sint16 tmp;
int len;
Uint8 *stream;
boolean Callback_Stop;
boolean USE_S16;
extern Uint8 *stream;
#define MAX_SONGS 100 // there cannot be more tracks...
......
......@@ -21,21 +21,7 @@ int osd_snd_init_sound(void)
Uint16 format;
int numopened,frequency,channels;
if (HCD_last_track>1)
{
for (i=1;i<=HCD_last_track;i++)
{
if ((CD_track[i].type==0) && (CD_track[i].source_type==HCD_SOURCE_REGULAR_FILE))
{
}
USE_S16 = 1;
}
}else{
USE_S16 = 0;
}
stream = memalign(32, BUFFER_LEN*2);
stream = memalign(32, BUFFER_LEN*2);
spu_init();
spu_memset(SPU_POS, 0x00, BUFFER_LEN*2);
aica_play(1,1,SPU_POS+BUFFER_LEN,0,BUFFER_LEN/2,22050,255 ,1);
......@@ -52,7 +38,7 @@ void osd_snd_trash_sound(void)
UChar chan;
//needed to stop properly...
Callback_Stop=TRUE;
//Callback_Stop=TRUE;
//SDL_Delay(1000);
Mix_CloseAudio();
......
......@@ -30,25 +30,6 @@ typedef signed long int int32;
#undef __sh__
#endif
// compiler specific
/////////////////////
#ifndef INLINE
#ifdef __x86__
#define INLINE __inline
#else
#define INLINE __inline
#endif
#endif
#ifndef FASTCALL
#ifdef __x86__
#define FASTCALL __fastcall
#else
#define FASTCALL
#endif
#endif
// types definitions
/////////////////////
......
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