diff --git a/Makefile b/Makefile index 2fd363a3..c10b3119 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ SOURCES := source \ source/config \ source/data \ source/devicemounter \ - source/dml \ + source/gc \ source/gecko \ source/gui \ source/list \ @@ -46,7 +46,7 @@ INCLUDES := source \ source/cheats \ source/config \ source/devicemounter \ - source/dml \ + source/gc \ source/gecko \ source/gui \ source/list \ diff --git a/source/dml/dml.h b/source/dml/dml.h deleted file mode 100644 index 9efb333d..00000000 --- a/source/dml/dml.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - -#ifndef DML_H_ -#define DML_H_ -s32 setstreaming(); -void SRAM_PAL(); -void SRAM_NTSC(); -#endif //DML_H_ - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/source/dml/dvd_broadway.c b/source/dml/dvd_broadway.c deleted file mode 100644 index d60f9562..00000000 --- a/source/dml/dvd_broadway.c +++ /dev/null @@ -1,864 +0,0 @@ -/* - * Copyright (C) 2008 Nuke (wiinuke@gmail.com) - * - * this file is part of GeckoOS for USB Gecko - * http://www.usbgecko.com - * - * 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 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 -#include -#include -#include -#include -#include -#include -#include - -#include "dvd_broadway.h" - -#define DI_CMDCTX_CNT 4 - -#define DVD_DISKIDSIZE 0x20 -#define DVD_DRVINFSIZE 0x20 - -#define IOCTL_DI_INQUIRY 0x12 -#define IOCTL_DI_READID 0x70 -#define IOCTL_DI_READ 0x71 -#define IOCTL_DI_WAITCVRCLOSE 0x79 -#define IOCTL_DI_COVER 0x7A -#define IOCTL_DI_RESETNOTIFY 0x7E -#define IOCTL_DI_ClearCoverInterrupt 0x86 -#define IOCTL_DI_GetCoverStatus 0x88 -#define IOCTL_DI_RESET 0x8A -#define IOCTL_DI_OPENPART 0x8B -#define IOCTL_DI_CLOSEPART 0x8C -#define IOCTL_DI_UNENCREAD 0x8D -#define IOCTL_DI_ENABLE_DVD 0x8E -#define IOCTL_DI_REPORTKEY 0xA4 -#define IOCTL_DI_SEEK 0xAB -#define IOCTL_DI_READ_DVDVIDEO 0xD0 -#define IOCTL_DI_STOPLASER 0xD2 -#define IOCTL_DI_OFFSET 0xD9 -#define IOCTL_DI_REQERROR 0xE0 -#define IOCTL_DI_DVDLowAudioStatus 0xE2 -#define IOCTL_DI_STOPMOTOR 0xE3 -#define IOCTL_DI_DVDLowAudioBufferConfig 0xE4 -#define IOCTL_DI_SETOFFBASE 0xF0 -#define IOCTL_DI_GETOFFBASE 0xF1 -#define IOCTL_DI_SETCRYPTMODE 0xF2 -#define IOCTL_DI_GETCRYPTMODE 0xF3 -#define IOCTL_DI_SETDVDROMMODE 0xF4 -#define IOCTL_DI_GETDVDROMMODE 0xF5 -#define DI_SETWBFSMODE_IOS249 0xf4 -#define IOCTL_DI_DISCTYPE 0xF7 -//#define DI_SETWBFSMODE_IOS222 0xfe - -#define IOCTL_DI_SNEEK_READ_GAMEINFO 0x30 -#define IOCTL_DI_SNEEK_SELECT_GAME 0x23 -#define IOCTL_DI_SNEEK_GET_GAMECOUNT 0x24 - - - - - -#define _SHIFTL(v, s, w) \ - ((u32) (((u32)(v) & ((0x01 << (w)) - 1)) << (s))) -#define _SHIFTR(v, s, w) \ - ((u32)(((u32)(v) >> (s)) & ((0x01 << (w)) - 1))) - - -static u32 bufferin[0x20] __attribute__((aligned(32))); -static u32 bufferout[0x20] __attribute__((aligned(32))); - -struct dicommand -{ - u32 diReg[8]; -}; - -struct dicontext -{ - lwp_node node; - dvdcallbacklow cb; - struct dicommand *cmd; -}; - -static s32 __dvd_fd = -1; -static u32 __dvd_spinupval = 1; -static lwp_queue __di_contextq; -static u32 __dvd_readlength = 0; -static u32 __dvd_cbinprogress = 0; -static u32 __dvd_reqinprogress = 0; -static u32 __dvd_lowinitcalled = 0; -static struct dicommand *__di_commands = NULL; -static struct dicontext __di_contexts[DI_CMDCTX_CNT]; -static u32 __di_regbuffer[0x08] ATTRIBUTE_ALIGN(32); -static u32 __di_regvalcache[0x08] ATTRIBUTE_ALIGN(32); -static u32 __di_lastticketerror[0x08] ATTRIBUTE_ALIGN(32); -static ioctlv __di_iovector[0x08] ATTRIBUTE_ALIGN(32); -static char __di_fs[] ATTRIBUTE_ALIGN(32) = "/dev/di"; - -extern u32 __IPC_ClntInit(); - -static __inline__ lwp_node* __lwp_queue_head(lwp_queue *queue) -{ - return (lwp_node*)queue; -} - -static __inline__ lwp_node* __lwp_queue_tail(lwp_queue *queue) -{ - return (lwp_node*)&queue->perm_null; -} - - -static __inline__ void __lwp_queue_init_empty(lwp_queue *queue) -{ - queue->first = __lwp_queue_tail(queue); - queue->perm_null = NULL; - queue->last = __lwp_queue_head(queue); -} - -static struct dicontext* __dvd_getcontext(dvdcallbacklow cb) -{ - struct dicontext *ctx; - - ctx = (struct dicontext*)__lwp_queue_get(&__di_contextq); - if(ctx!=NULL) ctx->cb = cb; - - return ctx; -} - -static s32 __dvd_iostransactionCB(s32 result,void *usrdata) -{ - struct dicontext *ctx = (struct dicontext*)usrdata; - - __dvd_reqinprogress = 0; - - if(ctx->cb!=NULL) { - __dvd_cbinprogress = 1; - if(result!=0) __dvd_readlength = 0; - ctx->cb(result); - __dvd_cbinprogress = 0; - } - __lwp_queue_append(&__di_contextq,&ctx->node); - - return 0; -} - -static s32 __dvd_ioscoverregisterCB(s32 result,void *usrdata) -{ - struct dicontext *ctx = (struct dicontext*)usrdata; - - __dvd_reqinprogress = 0; - __di_regvalcache[1] = __di_regbuffer[0]; - - if(ctx->cb!=NULL) { - __dvd_cbinprogress = 1; - ctx->cb(result); - __dvd_cbinprogress = 0; - } - __lwp_queue_append(&__di_contextq,&ctx->node); - - return 0; -} - -static s32 __dvd_ioscovercloseCB(s32 result,void *usrdata) -{ - struct dicontext *ctx = (struct dicontext*)usrdata; - - __dvd_reqinprogress = 0; - - if(ctx->cb!=NULL) { - __dvd_cbinprogress = 1; - ctx->cb(result); - __dvd_cbinprogress = 0; - } - __lwp_queue_append(&__di_contextq,&ctx->node); - - return 0; -} - -s32 bwDVD_LowInit() -{ - s32 i,ret = 0; - u32 ipclo,ipchi; - lwp_queue inactives; - struct dicontext *ctx; - - if(__dvd_lowinitcalled==0) { - ret = __IPC_ClntInit(); - if(ret<0) return ret; - - ipclo = (((u32)IPC_GetBufferLo()+0x1f)&~0x1f); - ipchi = (u32)IPC_GetBufferHi(); - if(ipchi>=(ipclo+(sizeof(struct dicommand)*DI_CMDCTX_CNT))) { - __di_commands = (struct dicommand*)ipclo; - IPC_SetBufferLo((void*)(ipclo+(sizeof(struct dicommand)*DI_CMDCTX_CNT))); - - memset(__di_commands,0,(sizeof(struct dicommand)*DI_CMDCTX_CNT)); - - i = 0; - __lwp_queue_init_empty(&__di_contextq); - __lwp_queue_initialize(&inactives,__di_contexts,DI_CMDCTX_CNT,sizeof(struct dicontext)); - while((ctx=(struct dicontext*)__lwp_queue_get(&inactives))!=NULL) { - ctx->cmd = &__di_commands[i]; - ctx->cb = NULL; - __lwp_queue_append(&__di_contextq,&ctx->node); - - i++; - } - } - - ret = IOS_Open(__di_fs,0); - if(ret<0) return ret; - - __dvd_fd = ret; - //__dvd_lowinitcalled = 1; - - // printf("DVD_LowInit(%d)\n",ret); - } - return 0; -} - -s32 bwDVD_LowClose() -{ - IOS_Close(__dvd_fd); - return 0; -} - - -s32 bwDVD_LowInquiry(dvddrvinfo *info,dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_INQUIRY<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_INQUIRY,cmd->diReg,sizeof(struct dicommand),info,DVD_DRVINFSIZE,__dvd_iostransactionCB,ctx); - - return ret; -} - -s32 bwDVD_LowReadID(dvddiskid *diskID,dvdcallbacklow cb) -{ - s32 ret = 0; - struct dicontext *ctx; - struct dicommand *cmd; - -// printf("DVD_LowReadID()\n"); - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_READID<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_READID,cmd->diReg,sizeof(struct dicommand),diskID,DVD_DISKIDSIZE,__dvd_iostransactionCB,ctx); - -// printf("DVD_LowReadID(%d)\n",ret); - return ret; -} - - -s32 bwDVD_LowRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - if(buf==NULL || ((u32)buf%32)!=0) return -1; - - __dvd_reqinprogress = 1; - __dvd_readlength = len; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_READ<<24); - cmd->diReg[1] = len; - cmd->diReg[2] = offset; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_READ,cmd->diReg,sizeof(struct dicommand),buf,len,__dvd_iostransactionCB,ctx); - - return ret; -} - -// never got this function working, probably removed from wii -s32 bwDVD_LowReadVideo(void *buf,u32 len,u32 offset,dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - __dvd_readlength = len; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_READ_DVDVIDEO<<24); - cmd->diReg[1] = len; - cmd->diReg[2] = offset; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_READ_DVDVIDEO,cmd->diReg,sizeof(struct dicommand),buf,len,__dvd_iostransactionCB,ctx); - - return ret; -} - - - -s32 bwDVD_LowStopLaser(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_STOPLASER<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_STOPLASER,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; -} - -// never got this function working, probably removed from wii -s32 bwDVD_EnableVideo(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_ENABLE_DVD<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_ENABLE_DVD,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; -} - -s32 bwDVD_LowSeek(u32 offset,dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_SEEK<<24); - cmd->diReg[1] = offset; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_SEEK,cmd->diReg,sizeof(struct dicommand),NULL,0,__dvd_iostransactionCB,ctx); - - return ret; -} - -s32 bwDVD_LowOffset(u64 offset,dvdcallbacklow cb) -{ - s32 ret; - u32 *off = (u32*)(void*)(&offset); - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_OFFSET<<24); - cmd->diReg[1] = 0; - if (off[0]) cmd->diReg[1] = 1; - cmd->diReg[2] = off[1]; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_OFFSET,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; -} - -s32 bwDVD_LowPrepareCoverRegister(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_COVER<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_COVER,cmd->diReg,sizeof(struct dicommand),__di_regbuffer,0x20,__dvd_ioscoverregisterCB,ctx); - - return ret; -} - -s32 bwDVD_LowOpenPartition(u32 offset,void *eticket,u32 certin_len,void *certificate_in,void *certificate_out,dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - if(eticket!=NULL && ((u32)eticket%32)!=0) return -1; - if(certificate_in!=NULL && ((u32)certificate_in%32)!=0) return -1; - if(certificate_out!=NULL && ((u32)certificate_out%32)!=0) return -1; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_OPENPART<<24); - cmd->diReg[1] = offset; - - __di_iovector[0].data = cmd; - __di_iovector[0].len = sizeof(struct dicommand); - - __di_iovector[1].data = eticket; - if(eticket==NULL) __di_iovector[1].len = 0; - else __di_iovector[1].len = 676; - - __di_iovector[2].data = certificate_in; - if(certificate_in==NULL) __di_iovector[2].len = 0; - else __di_iovector[2].len = certin_len; - - __di_iovector[3].data = certificate_out; - __di_iovector[3].len = 18916; - __di_iovector[4].data = __di_lastticketerror; - __di_iovector[4].len = 0x20; - ret = IOS_IoctlvAsync(__dvd_fd,IOCTL_DI_OPENPART,3,2,__di_iovector,__dvd_iostransactionCB,ctx); - - return ret; -} - -s32 bwDVD_LowClosePartition(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_CLOSEPART<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_CLOSEPART,cmd->diReg,sizeof(struct dicommand),NULL,0,__dvd_iostransactionCB,ctx); - - return ret; -} - -s32 bwDVD_LowUnencryptedRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - __dvd_readlength = len; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_UNENCREAD<<24); - cmd->diReg[1] = len; - cmd->diReg[2] = offset; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_UNENCREAD,cmd->diReg,sizeof(struct dicommand),buf,len,__dvd_iostransactionCB,ctx); - - return ret; -} - -s32 bwDVD_LowWaitCoverClose(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_WAITCVRCLOSE<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_WAITCVRCLOSE,cmd->diReg,sizeof(struct dicommand),NULL,0,__dvd_ioscovercloseCB,ctx); - - return ret; -} - -s32 bwDVD_LowResetNotify() -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - if(__dvd_cbinprogress==1) return -1; - - ctx = __dvd_getcontext(NULL); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_RESETNOTIFY<<24); - ret = IOS_Ioctl(__dvd_fd,IOCTL_DI_RESETNOTIFY,cmd->diReg,sizeof(struct dicommand),NULL,0); - - return ret; -} - -s32 bwDVD_LowReset(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - -// printf("DVD_LowReset()\n"); - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_RESET<<24); - cmd->diReg[1] = __dvd_spinupval; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_RESET,cmd->diReg,sizeof(struct dicommand),NULL,0,__dvd_iostransactionCB,ctx); - -// printf("DVD_LowReset(%d)\n",ret); - return ret; -} - -s32 bwDVD_LowStopMotor(u8 stop1,u8 stop2) -{ - memset(bufferin, 0, 0x20 ); - memset(bufferout, 0, 0x20 ); - - bufferin[0] = IOCTL_DI_STOPMOTOR<<24; - bufferin[1] = stop1<<24; - bufferin[2] = stop2<<24; - - DCFlushRange(bufferin, 0x20); - - int ret = IOS_Ioctl( __dvd_fd, IOCTL_DI_STOPMOTOR, bufferin, 0x20, bufferout, 0x20); - - return ret; -} - -/* -s32 bwDVD_LowStopMotor(u8 stop1,u8 stop2,dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_STOPMOTOR<<24); - cmd->diReg[1] = (stop1<<24); - cmd->diReg[2] = (stop2<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_STOPMOTOR,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; - -}*/ - - -s32 bwDVD_LowRequestError( void ) -{ - memset(bufferin, 0, 0x20 ); - memset(bufferout, 0, 0x20 ); - - bufferin[0] = (IOCTL_DI_REQERROR << 24); - - DCFlushRange(bufferin, 0x20); - - int ret = IOS_Ioctl( __dvd_fd, IOCTL_DI_REQERROR, bufferin, 0x20, bufferout, 0x20); - - DCFlushRange(bufferout, 0x20); - - if( ret < 0 ) - return ret; - return bufferout[0]; -} - -s32 bwDVD_LowAudioStatus( void ) -{ - memset(bufferin, 0, 0x20 ); - memset(bufferout, 0, 0x20 ); - - bufferin[0] = (IOCTL_DI_DVDLowAudioStatus << 24); - - DCFlushRange(bufferin, 0x20); - - int ret = IOS_Ioctl( __dvd_fd, IOCTL_DI_DVDLowAudioStatus, bufferin, 0x20, bufferout, 0x20); - - DCFlushRange(bufferout, 0x20); - - if( ret < 0) - return ret; - return bufferout[0]; -} -/* - -s32 bwDVD_LowRequestError(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_REQERROR<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_REQERROR,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; -} -*/ - -s32 bwDVD_LowClearCoverInterrupt(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_ClearCoverInterrupt<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_ClearCoverInterrupt,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; -} - -s32 bwDVD_LowReportKey(dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_REPORTKEY<<24); - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_REPORTKEY,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; -} - - - -s32 bwDVD_SetDecryption(s32 mode, dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_SETCRYPTMODE<<24); - cmd->diReg[1] = mode; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_SETCRYPTMODE,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; - -} - -s32 bwDVD_SetOffset(u32 offset, dvdcallbacklow cb) -{ - s32 ret; - struct dicontext *ctx; - struct dicommand *cmd; - - __dvd_reqinprogress = 1; - - ctx = __dvd_getcontext(cb); - if(ctx==NULL) return IPC_ENOMEM; - - cmd = ctx->cmd; - cmd->diReg[0] = (IOCTL_DI_SETOFFBASE<<24); - cmd->diReg[1] = offset; - ret = IOS_IoctlAsync(__dvd_fd,IOCTL_DI_SETOFFBASE,cmd->diReg,sizeof(struct dicommand),__di_regvalcache,0x20,__dvd_iostransactionCB,ctx); - - return ret; -} - -s32 bwDVD_GetCoverStatus(u32 *status) -{ - memset(bufferin, 0, 0x20); - memset(bufferout, 0, 0x20); - - bufferin[0] = (IOCTL_DI_GetCoverStatus << 24); - DCFlushRange(bufferin, 0x20); - - int Ret = IOS_Ioctl(__dvd_fd, IOCTL_DI_GetCoverStatus, bufferin, 0x20, bufferout, 0x20); - - DCFlushRange(bufferout, 0x20); - *status = bufferout[0]; - - //return ((Ret == 1) ? 0 : -Ret); - return Ret; -} -/* -s32 bwDVD_SetDiscType(bool dvd5) -{ - memset(bufferin, 0, 0x20); - memset(bufferout, 0, 0x20); - - bufferin[0] = IOCTL_DI_DISCTYPE << 24; - - if (dvd5) - { - bufferin[1] = 0; - } else - { - bufferin[1] = 1; - } - - int Ret = IOS_Ioctl(__dvd_fd, IOCTL_DI_DISCTYPE, bufferin, 0x20, bufferout, 0x20); - - return ((Ret == 1) ? 0 : -Ret); -} -*/ -s32 SetWBFSMode(u8 device, void*discid) -{ - u8 ioctl; - ioctl = DI_SETWBFSMODE_IOS249; - - memset(bufferin, 0, 0x20); - memset(bufferout, 0, 0x20); - - bufferin[0] = (ioctl << 24); - bufferin[1] = device; - if (discid) - { - memcpy(&bufferin[2],discid,6); - } - DCFlushRange(bufferin, 0x20); - - int Ret = IOS_Ioctl(__dvd_fd, ioctl, bufferin, 0x20, bufferout, 0x20); - - return ((Ret == 1) ? 0 : -Ret); -} - -s32 setstreaming() -{ - u8 ioctl; - ioctl = IOCTL_DI_DVDLowAudioBufferConfig; - - memset(bufferin, 0, 0x20); - memset(bufferout, 0, 0x20); - - bufferin[0] = (ioctl << 24); - - if ( (*(u32*)0x80000008)>>24 ) - { - bufferin[1] = 1; - if( ((*(u32*)0x80000008)>>16) & 0xFF ) - { - bufferin[2] = 10; - } else - { - bufferin[2] = 0; - } - } - else - { - bufferin[1] = 0; - bufferin[2] = 0; - } - DCFlushRange(bufferin, 0x20); - - int Ret = IOS_Ioctl(__dvd_fd, ioctl, bufferin, 0x20, bufferout, 0x20); - - return ((Ret == 1) ? 0 : -Ret); -} - - -s32 Sneek_DVDReadGameInfo( u32 Offset, u32 Length, void *Data ) -{ - memset(bufferin, 0, 0x20); - - bufferin[0] = Offset; - bufferin[1] = Length; - bufferin[2] = MEM_VIRTUAL_TO_PHYSICAL((u32)Data); - - DCFlushRange(bufferin, 0x20); - DCInvalidateRange(Data, Length); - - s32 ret = IOS_Ioctl( __dvd_fd, IOCTL_DI_SNEEK_READ_GAMEINFO, bufferin, sizeof(u32) * 3, NULL, 0 ); - - DCFlushRange(Data, Length); - - return ret; -} - - -s32 Sneek_DVDSelectGame( u32 SlotID ) -{ - memset(bufferin, 0, 0x20); - - bufferin[0] = SlotID; - DCFlushRange(bufferin, 0x20); - - s32 ret = IOS_Ioctl(__dvd_fd, IOCTL_DI_SNEEK_SELECT_GAME, bufferin, sizeof(u32) * 1, NULL, 0 ); - - return ret; -} - -s32 Sneek_DVDGetGameCount( u32 *Count ) -{ - s32 ret = IOS_Ioctl( __dvd_fd, IOCTL_DI_SNEEK_GET_GAMECOUNT, NULL, 0, (u32 *)(MEM_VIRTUAL_TO_PHYSICAL(Count)), sizeof(u32) ); - return ret; -} - - - - diff --git a/source/dml/dvd_broadway.h b/source/dml/dvd_broadway.h deleted file mode 100644 index 5a50ef35..00000000 --- a/source/dml/dvd_broadway.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2008 Nuke (wiinuke@gmail.com) - * - * this file is part of GeckoOS for USB Gecko - * http://www.usbgecko.com - * - * 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 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 - */ - -#ifndef __DVD_BROADWAY_H__ -#define __DVD_BROADWAY_H__ - -#include -#include -#include - -#ifdef __cplusplus - extern "C" { -#endif /* __cplusplus */ - -typedef void (*dvdcallbacklow)(s32 result); - -s32 bwDVD_LowInit(); -s32 bwDVD_LowClose(); -s32 bwDVD_LowInquiry(dvddrvinfo *info,dvdcallbacklow cb); -s32 bwDVD_LowReadID(dvddiskid *diskID,dvdcallbacklow cb); -s32 bwDVD_LowClosePartition(dvdcallbacklow cb); -s32 bwDVD_LowOpenPartition(u32 offset,void *eticket,u32 certin_len,void *certificate_in,void *certificate_out,dvdcallbacklow cb); -s32 bwDVD_LowUnencryptedRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb); -s32 bwDVD_LowReset(dvdcallbacklow cb); -s32 bwDVD_LowWaitCoverClose(dvdcallbacklow cb); -s32 bwDVD_LowRead(void *buf,u32 len,u32 offset,dvdcallbacklow cb); -s32 bwDVD_EnableVideo(dvdcallbacklow cb); -s32 bwDVD_LowReadVideo(void *buf,u32 len,u32 offset,dvdcallbacklow cb); -s32 bwDVD_SetDecryption(s32 mode, dvdcallbacklow cb); -s32 bwDVD_SetOffset(u32 offset, dvdcallbacklow cb); -s32 bwDVD_LowStopMotor(u8 stop1,u8 stop2); -s32 bwDVD_GetCoverStatus(u32 *status); -s32 bwDVD_LowRequestError( void ); -s32 bwDVD_LowAudioStatus( void ); -s32 bwDVD_LowClearCoverInterrupt(dvdcallbacklow cb); -s32 bwDVD_LowReportKey(dvdcallbacklow cb); -//s32 bwDVD_SetDiscType(bool dvd5); -s32 SetWBFSMode(u8 device, void*discid); -s32 setstreaming(); - -s32 Sneek_DVDReadGameInfo( u32 Offset, u32 Length, void *Data ); -s32 Sneek_DVDSelectGame( u32 SlotID ); -s32 Sneek_DVDGetGameCount( u32 *Count ); - -#ifdef __cplusplus - } -#endif /* __cplusplus */ - -#endif diff --git a/source/dml/dml.c b/source/gc/gc.c similarity index 54% rename from source/dml/dml.c rename to source/gc/gc.c index 8ce1c1cf..fc2f7f8f 100644 --- a/source/dml/dml.c +++ b/source/gc/gc.c @@ -11,7 +11,7 @@ #include #include #include -#include "dml.h" +#include "gc.h" #define SEP 0xFF #define BC 0x0000000100000100ULL @@ -19,7 +19,6 @@ /** Base address for video registers. */ #define MEM_VIDEO_BASE (0xCC002000) -#define IOCTL_DI_DVDLowAudioBufferConfig 0xE4 #define VIDEO_MODE_NTSC 0 #define VIDEO_MODE_PAL 1 @@ -31,20 +30,32 @@ syssram* __SYS_LockSram(); u32 __SYS_UnlockSram(u32 write); u32 __SYS_SyncSram(void); -void SRAM_PAL() +void set_video_mode(int i) { syssram *sram; sram = __SYS_LockSram(); - sram->flags = sram->flags | (1 << 0); // Set bit 0 to set the video mode to PAL + void *m_frameBuf; + static GXRModeObj *rmode; + if (i == 0) + { + rmode = &TVNtsc480IntDf; + sram->flags = sram->flags & ~(1 << 0); // Clear bit 0 to set the video mode to NTSC + } + else + { + rmode = &TVPal528IntDf; + sram->flags = sram->flags | (1 << 0); // Set bit 0 to set the video mode to PAL + } + __SYS_UnlockSram(1); // 1 -> write changes while(!__SYS_SyncSram()); -} -void SRAM_NTSC() -{ - syssram *sram; - sram = __SYS_LockSram(); - sram->flags = sram->flags & ~(1 << 0); // Clear bit 0 to set the video mode to NTSC - __SYS_UnlockSram(1); // 1 -> write changes - while(!__SYS_SyncSram()); -} + /* Set video mode to PAL or NTSC */ + *(u32*)0x800000CC = i; + + VIDEO_Configure(rmode); + m_frameBuf = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); + + VIDEO_ClearFrameBuffer(rmode, m_frameBuf, COLOR_BLACK); + VIDEO_SetNextFramebuffer(m_frameBuf); +} \ No newline at end of file diff --git a/source/gc/gc.h b/source/gc/gc.h new file mode 100644 index 00000000..2b5f105e --- /dev/null +++ b/source/gc/gc.h @@ -0,0 +1,13 @@ +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifndef GC_H_ +#define GC_H_ +void set_video_mode(int i); +#endif //GC_H_ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/source/loader/disc.c b/source/loader/disc.c index 06395241..7d774491 100644 --- a/source/loader/disc.c +++ b/source/loader/disc.c @@ -253,7 +253,12 @@ s32 Disc_Open(void) memset(diskid, 0, 32); /* Read disc ID */ - return WDVD_ReadDiskId(diskid); + ret = WDVD_ReadDiskId(diskid); + + /* Directly set Audio Streaming for GC */ + WDVD_setstreaming(); + + return ret; } s32 Disc_Wait(void) diff --git a/source/loader/wdvd.c b/source/loader/wdvd.c index 258660fd..6c662da8 100644 --- a/source/loader/wdvd.c +++ b/source/loader/wdvd.c @@ -19,6 +19,7 @@ #define IOCTL_DI_DISC_BCA 0xDA #define IOCTL_DI_STOPMOTOR 0xE3 #define IOCTL_DI_SETWBFSMODE 0xF4 +#define IOCTL_DI_DVDLowAudioBufferConfig 0xE4 #define IOCTL_DI_SETFRAG 0xF9 #define IOCTL_DI_GETMODE 0xFA @@ -31,6 +32,38 @@ static u32 outbuf[8] ATTRIBUTE_ALIGN(32); static const char di_fs[] ATTRIBUTE_ALIGN(32) = "/dev/di"; static s32 di_fd = -1; +s32 WDVD_setstreaming() +{ + u8 ioctl; + ioctl = IOCTL_DI_DVDLowAudioBufferConfig; + + memset(inbuf, 0, 0x20); + memset(outbuf, 0, 0x20); + + inbuf[0] = (ioctl << 24); + + if ( (*(u32*)0x80000008)>>24 ) + { + inbuf[1] = 1; + if( ((*(u32*)0x80000008)>>16) & 0xFF ) + { + inbuf[2] = 10; + } else + { + inbuf[2] = 0; + } + } + else + { + inbuf[1] = 0; + inbuf[2] = 0; + } + DCFlushRange(inbuf, 0x20); + + int Ret = IOS_Ioctl(di_fd, ioctl, inbuf, 0x20, outbuf, 0x20); + + return ((Ret == 1) ? 0 : -Ret); +} s32 WDVD_Init(void) { diff --git a/source/loader/wdvd.h b/source/loader/wdvd.h index e08de9f5..5ed3615a 100644 --- a/source/loader/wdvd.h +++ b/source/loader/wdvd.h @@ -25,6 +25,7 @@ s32 WDVD_SetUSBMode(u32, const u8 *, s32); s32 WDVD_Eject(void); s32 WDVD_Read_Disc_BCA(void *); s32 WDVD_SetFragList(int device, void *fraglist, int size); +s32 WDVD_setstreaming(); #ifdef __cplusplus } diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 850f8108..c1506106 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -28,9 +28,7 @@ #include "gecko.h" #include "homebrew.h" #include "defines.h" - -#include "dml/dml.h" -#include "dml/dvd_broadway.h" +#include "gc/gc.h" using namespace std; @@ -47,15 +45,6 @@ extern const u8 favoritesoffs_png[]; extern const u8 delete_png[]; extern const u8 deletes_png[]; - -static dvddiskid *g_diskID = (dvddiskid*)0x80000000; -static vu32 dvddone = 0; - -static void __dvd_readidcb(s32 result) -{ - dvddone = result; -} - extern u32 sector_size; extern int mainIOS; static u64 sm_title_id[8] ATTRIBUTE_ALIGN(32); @@ -571,48 +560,22 @@ void CMenu::_launchGC(const char *id, bool DML) USBStorage_Deinit(); cleanup(); - memcpy((char *)0x80000000, id, 6); - // Tell DML to boot the game from sd card *(u32 *)0x80001800 = 0xB002D105; DCFlushRange((void *)(0x80001800), 4); ICInvalidateRange((void *)(0x80001800), 4); } - setstreaming(); + memcpy((char *)0x80000000, id, 6); VIDEO_SetBlack(TRUE); if (((id[3] == 'P') && (DMLvideoMode == 0)) || (DMLvideoMode == 1)) { - SRAM_PAL(); - - void *m_frameBuf; - static GXRModeObj *rmode = &TVPal528IntDf; - - /* Set video mode to PAL */ - *(u32*)0x800000CC = 1; - - VIDEO_Configure(rmode); - m_frameBuf = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); - - VIDEO_ClearFrameBuffer(rmode, m_frameBuf, COLOR_BLACK); - VIDEO_SetNextFramebuffer(m_frameBuf); + set_video_mode(1); } if (((id[3] != 'P') && (DMLvideoMode == 0)) || (DMLvideoMode == 2)) { - SRAM_NTSC(); - - void *m_frameBuf; - static GXRModeObj *rmode = &TVNtsc480IntDf; - - /* Set video mode to NTSC */ - *(u32*)0x800000CC = 0; - - VIDEO_Configure(rmode); - m_frameBuf = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode)); - - VIDEO_ClearFrameBuffer(rmode, m_frameBuf, COLOR_BLACK); - VIDEO_SetNextFramebuffer(m_frameBuf); + set_video_mode(0); } VIDEO_Flush(); VIDEO_WaitVSync(); @@ -864,7 +827,8 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) { error(L"Cannot Read DVD."); if (BTN_B_PRESSED) return; - } + } + /* Check disc */ if (Disc_IsWii() < 0) { @@ -876,6 +840,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) else gc = true; } + /* Read header */ struct discHdr *header = (struct discHdr *)MEM2_alloc(sizeof(struct discHdr)); Disc_ReadHeader(header); @@ -1081,9 +1046,6 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) if (gc) { - bwDVD_LowInit(); - bwDVD_LowReset(__dvd_readidcb); - bwDVD_LowReadID(g_diskID,__dvd_readidcb); _launchGC(id.c_str(),false); } else diff --git a/wiiflow.pnproj b/wiiflow.pnproj index e89aadba..21269391 100644 --- a/wiiflow.pnproj +++ b/wiiflow.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wiiflow.pnps b/wiiflow.pnps index d3cbefa3..c628f4bd 100644 --- a/wiiflow.pnps +++ b/wiiflow.pnps @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file