Skip to content

Commit

Permalink
[What's New 1.0.2 - October 6, 2008]
Browse files Browse the repository at this point in the history
* New core! The core is now a custom combination of VBA-M and VBA 1.72
* Added DVD, SMB, ZIP, GameCube MC support
* Faster USB/SD speeds
* Screen alignment and flickering problems fixed
* 128K save support added
* Better emulation speeds. Should now be nearly full speed all the time
  for most games.
* Turbo speed feature. Mapped to right C-stick (classic controller & 
  Gamecube controller), and A+B for wiimote
* Controller mapping preferences bug fixed. Your preferences will reset
  automatically to correct any problems in your preferences file
* Many other tweaks behind the scenes
  • Loading branch information
dborth committed Oct 16, 2008
1 parent 2f2a1fd commit 69ec24c
Show file tree
Hide file tree
Showing 51 changed files with 1,457 additions and 4,705 deletions.
8 changes: 3 additions & 5 deletions Makefile.gc
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@ include $(DEVKITPPC)/gamecube_rules
TARGET := vbagx_gc
TARGETDIR := executables
BUILD := build_gc
SOURCES := source/vba source/vba/agb source/vba/dmg source/ngc source/sz
SOURCES := source/vba source/vba/agb source/vba/dmg source/ngc
INCLUDES := source/vba source/ngc

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------

CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) \
-DNGC -DUSE_VM -DWORDS_BIGENDIAN \
-DC_CORE -D__ppc__ -D__POWERPC__ -DFINAL_VERSION \
-DSDL -DNO_PNG -DHAVE_ZUTIL_H \
-D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ
-DNGC -DUSE_VM -DWORDS_BIGENDIAN -DC_CORE -DFINAL_VERSION \
-DSDL -DNO_PNG -DHAVE_ZUTIL_H
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map

Expand Down
8 changes: 3 additions & 5 deletions Makefile.wii
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@ include $(DEVKITPPC)/wii_rules
TARGET := vbagx_wii
TARGETDIR := executables
BUILD := build_wii
SOURCES := source/vba source/vba/agb source/vba/dmg source/ngc source/sz
SOURCES := source/vba source/vba/agb source/vba/dmg source/ngc
INCLUDES := source/vba source/ngc

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------

CFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) \
-DNGC -DWII_DVD -DWORDS_BIGENDIAN -DVIDEO_THREADING \
-DC_CORE -D__ppc__ -D__POWERPC__ -DFINAL_VERSION \
-DSDL -DNO_PNG -DHAVE_ZUTIL_H \
-D_SZ_ONE_DIRECTORY -D_LZMA_IN_CB -D_LZMA_OUT_READ
-DNGC -DWII_DVD -DWORDS_BIGENDIAN -DC_CORE -D__ppc__ -DFINAL_VERSION \
-DSDL -DNO_PNG -DHAVE_ZUTIL_H
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map -Wl,--cref

Expand Down
30 changes: 30 additions & 0 deletions compiling.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
�,���`���,��,���`���,�,���`���,��,���`���,�,���`���,��,���`���,�,���`���,��,��

- Visual Boy Advance GX -
(Under GPL License)

�,���`���,��,���`���,�,���`���,��,���`���,�,���`���,��,���`���,�,���`���,��,��

-=[ Compiling ]=-

This thing is a bugger to compile, at least for now. You can compile
everything using -Os, but gameplay will run slow. Compiling with -O2
using devkitppc 15 will crash on GBA.cpp. This must be due to some change in
gcc 4.x that sets a compiler flag that the assembly code in thumb.h can't
handle.

To get around this:

-use a precompiled GBA.o

OR

-compile a GBA.o and GBA.d using devkitpcc 13 (gcc 3.4.6)
-copy these precompiled files to the build dir, and compile everything else
with -O2 on devkitppc 15 (gcc 4.2.3)

It would be really nice to automate this messy build process, or preferably
to find out how to get gcc 4.x to play nice.


-- Tantric, September 2008
15 changes: 4 additions & 11 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
�,���`���,��,���`���,�,���`���,��,���`���,�,���`���,��,���`���,�,���`���,��,��

- Visual Boy Advance GX -
Version 1.0.3
http://code.google.com/p/vba-wii
Version 1.0.2
(Under GPL License)

�,���`���,��,���`���,�,���`���,��,���`���,�,���`���,��,���`���,�,���`���,��,��

-=[ Explanation ]=-

Visual Boy Advance GX is a modified port of VBA-M / VBA 1.7.2.
With it you can play GBA/Game Boy Color/Game Boy games on your Wii/GameCube.

Expand All @@ -15,22 +16,14 @@ With it you can play GBA/Game Boy Color/Game Boy games on your Wii/GameCube.
* Wiimote, Nunchuk, Classic, and Gamecube controller support
* SRAM and State saving
* Custom controller configurations
* SD, USB, DVD, SMB, GC Memory Card, Zip, and 7z support
* SD, USB, DVD, SMB, GC Memory Card, and Zip support
* GBA compatiblity based on VBA-M r750, GB compatibility based on VBA 1.7.2
* Turbo speed feature

ח����������� ������������������������������ �����������������������-����-���
|0O��o� UPDATE HISTORY �o��O0|
`������� ���������������� ��������������� �������������������� �������������'

[What's New 1.0.3 - October 15, 2008]
* New timing / frameskip algorithm - should (hopefully) work 100% better!
* Performance improvements - video threading, PPC core partly activated
* Video zooming option
* Unfiltered video option
* 7z support
* Loading progress bars added

[What's New 1.0.2 - October 6, 2008]
* New core! The core is now a custom combination of VBA-M and VBA 1.72
* Added DVD, SMB, ZIP, GameCube MC support
Expand Down
176 changes: 17 additions & 159 deletions source/ngc/dvd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>

#ifdef WII_DVD
extern "C" {
Expand All @@ -24,27 +23,28 @@ extern "C" {
#include "menudraw.h"
#include "gcunzip.h"
#include "filesel.h"
#include "vba.h"

u64 dvddir = 0; // offset of currently selected file or folder
int dvddirlength = 0; // length of currently selected file or folder
u64 dvdrootdir = 0; // offset of DVD root
u64 dvddir = 0;
u64 dvdrootdir = 0;
int dvddirlength = 0;
bool isWii = false;

#ifdef HW_DOL
/** DVD I/O Address base **/
volatile unsigned long *dvd = (volatile unsigned long *) 0xCC006000;
#endif

/** Due to lack of memory, we'll use this little 2k keyhole for all DVD operations **/
unsigned char DVDreadbuffer[2048] ATTRIBUTE_ALIGN (32);
unsigned char dvdbuffer[2048];


/****************************************************************************
* dvd_read
*
* Main DVD function, everything else uses this!
* The only DVD function we need - you gotta luv gc-linux self-boots!
* returns: 1 - ok ; 0 - error
***************************************************************************/
#define ALIGN_FORWARD(x,align) ((typeof(x))((((uint32_t)(x)) + (align) - 1) & (~(align-1))))
#define ALIGN_BACKWARD(x,align) ((typeof(x))(((uint32_t)(x)) & (~(align-1))))

int
dvd_read (void *dst, unsigned int len, u64 offset)
{
Expand All @@ -54,9 +54,7 @@ dvd_read (void *dst, unsigned int len, u64 offset)
// don't read past the end of the DVD (1.5 GB for GC DVD, 4.7 GB for DVD)
if((offset < 0x57057C00) || (isWii && (offset < 0x118244F00LL)))
{
u8 * buffer = (u8 *)memalign(32, 0x8000);
u32 off_size = 0;

unsigned char *buffer = (unsigned char *) (unsigned int) DVDreadbuffer;
DCInvalidateRange ((void *) buffer, len);

#ifdef HW_DOL
Expand All @@ -76,152 +74,17 @@ dvd_read (void *dst, unsigned int len, u64 offset)
if (dvd[0] & 0x4)
return 0;
#else
off_size = offset - ALIGN_BACKWARD(offset,0x800);
if (DI_ReadDVD(
buffer,
(ALIGN_FORWARD(offset + len,0x800) - ALIGN_BACKWARD(offset,0x800)) >> 11,
(u32)(ALIGN_BACKWARD(offset, 0x800) >> 11)
))
if (DI_ReadDVD(buffer, len >> 11, (u32)(offset >> 11)))
return 0;
#endif

memcpy (dst, buffer+off_size, len);
free(buffer);
memcpy (dst, buffer, len);
return 1;
}

return 0;
}

/****************************************************************************
* dvd_buffered_read
*
* the GC's dvd drive only supports offsets and length which are a multiple
* of 32 bytes additionally the max length of a read is 2048 bytes
* this function removes these limitations
* additionally the 7zip SDK does often read data in 1 byte parts from the
* DVD even when it could read 32 bytes. the dvdsf_buffer has been added to
* avoid having to read the same sector over and over again
***************************************************************************/

#define DVD_LENGTH_MULTIPLY 32
#define DVD_OFFSET_MULTIPLY 32
#define DVD_MAX_READ_LENGTH 2048
#define DVD_SECTOR_SIZE 2048

unsigned char dvdsf_buffer[DVD_SECTOR_SIZE];
u64 dvdsf_last_offset = 0;
u64 dvdsf_last_length = 0;

int dvd_buffered_read(void *dst, u32 len, u64 offset)
{
int ret = 0;

// only read data if the data inside dvdsf_buffer cannot be used
if(offset != dvdsf_last_offset || len > dvdsf_last_length)
{
memset(&dvdsf_buffer, '\0', DVD_SECTOR_SIZE);
ret = dvd_read(&dvdsf_buffer, len, offset);
dvdsf_last_offset = offset;
dvdsf_last_length = len;
}

memcpy(dst, &dvdsf_buffer, len);
return ret;
}

int dvd_safe_read(void *dst_v, u32 len, u64 offset)
{
unsigned char buffer[DVD_SECTOR_SIZE]; // buffer for one dvd sector

// if read size and length are a multiply of DVD_(OFFSET,LENGTH)_MULTIPLY and length < DVD_MAX_READ_LENGTH
// we don't need to fix anything
if(len % DVD_LENGTH_MULTIPLY == 0 && offset % DVD_OFFSET_MULTIPLY == 0 && len <= DVD_MAX_READ_LENGTH)
{
int ret = dvd_buffered_read(buffer, len, offset);
memcpy(dst_v, &buffer, len);
return ret;
}
else
{
// no errors yet -> ret = 0
// the return value of dvd_read will be OR'd with ret
// because dvd_read does return 1 on error and 0 on success and
// because 0 | 1 = 1 ret will also contain 1 if at least one error
// occured and 0 otherwise ;)
int ret = 0; // return value of dvd_read

// we might need to fix all 3 issues
unsigned char *dst = (unsigned char *)dst_v; // gcc will not allow to use var[num] on void* types
u64 bytesToRead; // the number of bytes we still need to read & copy to the output buffer
u64 currentOffset; // the current dvd offset
u64 bufferOffset; // the current buffer offset
u64 i, j, k; // temporary variables which might be used for different stuff
// unsigned char buffer[DVD_SECTOR_SIZE]; // buffer for one dvd sector

currentOffset = offset;
bytesToRead = len;
bufferOffset = 0;

// fix first issue (offset is not a multiply of 32)
if(offset % DVD_OFFSET_MULTIPLY)
{
// calculate offset of the prior 32 byte position
i = currentOffset - (currentOffset % DVD_OFFSET_MULTIPLY);

// calculate the offset from which the data of the dvd buffer will be copied
j = currentOffset % DVD_OFFSET_MULTIPLY;

// calculate the number of bytes needed to reach the next DVD_OFFSET_MULTIPLY byte mark
k = DVD_OFFSET_MULTIPLY - j;

// maybe we'll only need to copy a few bytes and we therefore don't even reach the next sector
if(k > len)
{
k = len;
}

// read 32 bytes from the last 32 byte position
ret |= dvd_buffered_read(buffer, DVD_OFFSET_MULTIPLY, i);

// copy the bytes to the output buffer and update currentOffset, bufferOffset and bytesToRead
memcpy(&dst[bufferOffset], &buffer[j], k);
currentOffset += k;
bufferOffset += k;
bytesToRead -= k;
}

// fix second issue (more than 2048 bytes are needed)
if(bytesToRead > DVD_MAX_READ_LENGTH)
{
// calculate the number of 2048 bytes sector needed to get all data
i = (bytesToRead - (bytesToRead % DVD_MAX_READ_LENGTH)) / DVD_MAX_READ_LENGTH;

// read data in 2048 byte sector
for(j = 0; j < i; j++)
{
ret |= dvd_buffered_read(buffer, DVD_MAX_READ_LENGTH, currentOffset); // read sector
memcpy(&dst[bufferOffset], buffer, DVD_MAX_READ_LENGTH); // copy to output buffer

// update currentOffset, bufferOffset and bytesToRead
currentOffset += DVD_MAX_READ_LENGTH;
bufferOffset += DVD_MAX_READ_LENGTH;
bytesToRead -= DVD_MAX_READ_LENGTH;
}
}

// fix third issue (length is not a multiply of 32)
if(bytesToRead)
{
ret |= dvd_buffered_read(buffer, DVD_MAX_READ_LENGTH, currentOffset); // read 32 byte from the dvd
memcpy(&dst[bufferOffset], buffer, bytesToRead); // copy bytes to output buffer
}

//free(tmp);
return ret;
}
}

/** Minimal ISO Directory Definition **/
#define RECLEN 0 /* Record length */
#define EXTENT 6 /* Extent */
Expand All @@ -245,7 +108,6 @@ getpvd ()
{
int sector = 16;
u32 rootdir32;
unsigned char dvdbuffer[2048];

dvddir = dvddirlength = 0;
IsJoliet = -1;
Expand Down Expand Up @@ -330,7 +192,7 @@ bool TestDVD()
***************************************************************************/
static int diroffset = 0;
static int
getentry (int entrycount, unsigned char dvdbuffer[])
getentry (int entrycount)
{
char fname[512]; /* Huge, but experience has determined this */
char *ptr;
Expand Down Expand Up @@ -450,7 +312,6 @@ ParseDVDdirectory ()
u64 rdoffset;
int len = 0;
int filecount = 0;
unsigned char dvdbuffer[2048];

// initialize selection
selection = offset = 0;
Expand All @@ -470,7 +331,7 @@ ParseDVDdirectory ()

diroffset = 0;

while (getentry (filecount, dvdbuffer))
while (getentry (filecount))
{
if(strlen(filelist[filecount].filename) > 0 && filecount < MAXFILES)
filecount++;
Expand Down Expand Up @@ -575,15 +436,13 @@ LoadDVDFile (unsigned char *buffer, int length)
u64 discoffset;
char readbuffer[2048];

dvddir = filelist[selection].offset;
dvddirlength = filelist[selection].length;

// How many 2k blocks to read
blocks = dvddirlength / 2048;
offset = 0;
discoffset = dvddir;
ShowAction ((char*) "Loading...");

if(length > 0 && length <= 2048) // do a partial read (eg: to check file header)
if(length > 0) // do a partial read (eg: to check file header)
{
dvd_read (buffer, length, discoffset);
}
Expand All @@ -599,7 +458,6 @@ LoadDVDFile (unsigned char *buffer, int length)
memcpy (buffer + offset, readbuffer, 2048);
offset += 2048;
discoffset += 2048;
ShowProgress ((char *)"Loading...", offset, length);
}

/*** And final cleanup ***/
Expand All @@ -612,7 +470,7 @@ LoadDVDFile (unsigned char *buffer, int length)
}
else
{
return UnZipBuffer (buffer, METHOD_DVD); // unzip from dvd
return UnZipFile (buffer, discoffset); // unzip from dvd
}
}
return dvddirlength;
Expand Down
Loading

0 comments on commit 69ec24c

Please sign in to comment.