Viper GC Dev API

All your homebrew software needs & discussion
Post Reply
User avatar
webhdx
Posts: 105
Joined: Sun Jul 03, 2011 10:40 am

Viper GC Dev API

Post by webhdx » Sun Jan 26, 2020 6:17 pm

Hello
I've recently started looking into developing homebrew stuff for GameCube. I really like it even though it's tough to get into C programming when you are used to writting in modern languages. Anyway, straight to the point - I'd like to write a simple software to dump ViperGC (standard one, not Extreme) flash memory.

You can find Viper GC Dev package which provides nice API to play with the chip. Sadly I can't get it to work. I can't do even simple stuff as reading LID status or reading Flash chip manufacturer ID. It simply returns incorrect data. I've checked all essentials like VGC headers it requires (it stated in the README.txt) and my flashed Cobra 2.1 is okay in that regard.

Have any of you played with it and can help?

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <ogcsys.h>
#include <gccore.h>
#include <viper.h>

static void *xfb = NULL;
static GXRModeObj *rmode = NULL;

void *Initialise();


int main(int argc, char **argv) {

	xfb = Initialise();
	ViperInit();

	printf("\nViperGC API test\n");
	printf("\nA => read next byte\n");
	printf("\nB => clear framebuffer\n");

	unsigned char manufacturerID = ViperGetFlashManufacturerID();
	printf("\nFlash Manufacturer ID: %X\n", manufacturerID);

	unsigned char byte;
	unsigned long i = 0;
	while(1) {

		VIDEO_WaitVSync();
		PAD_ScanPads();

		int buttonsDown = PAD_ButtonsDown(0);
		
		if( buttonsDown & PAD_BUTTON_A ) {

		    ViperWriteFlashDOW(0,0,1);
		    ViperWriteFlashAD(i++,0);
		    byte = ViperReadFlash();

			printf("\nReading next byte from ViperGC... %c\n", byte);
		}

		if (buttonsDown & PAD_BUTTON_B) {
			VIDEO_ClearFrameBuffer(rmode, xfb, COLOR_BLACK);
		}

		if (buttonsDown & PAD_BUTTON_START) {
			exit(0);
		}
	}

	return 0;
}

EDIT: Maybe it should be moved to Software category, sorry my bad.
User avatar
emu_kidid
Site Admin
Posts: 4927
Joined: Mon Mar 29, 2010 10:06 am
Location: Australia
Contact:

Re: Viper GC Dev API

Post by emu_kidid » Mon Jan 27, 2020 7:52 am

I never managed to get the API to work with libOGC, it potentially does too much at init/startup and the ViperGC shuts itself off from the world to protect itself. Back when I was working on GCOS I'd managed to use their API but it's very temperamental because of the way the ViperGC communicates with the hardware is quite obscure (remember it only uses 4 pins) and as a result the communication to it must be very specific and basically nothing else should try to use that bus.

Try to write something without libOGC and see how you go, I feel like you're wasting your time though unless if you really have a soft spot for the ViperGC and want to really delve deeper into how it works.
Image
Post Reply