home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 18
/
aminetcdnumber181997.iso
/
Aminet
/
misc
/
emu
/
gbuk.lha
/
src
/
amiga
/
AMIGA1.C
next >
Wrap
C/C++ Source or Header
|
1996-11-06
|
4KB
|
177 lines
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include "gfxfunc.h"
#include "prefs.h"
#include "GB.h"
#include "system.h"
#include "method1.h"
#define SOUND 0
byte SourceColor1(int n)
{
if(n<4){
return BPal[n];
}else if(n<8){
return BPal[n-4]+4;
}else if(n<12){
return SPal0[n-8]+8;
}else{
return SPal1[n-12]+12;
}
}
int InitMachine1(void)
{
SetupMethod2();
#if SOUND
if(!SetupSound())GXQuitCode("Couldnt set up sound\n");
#endif
return 1;
}
void TrashMachine1(void)
{
FreeMethod2();
}
void RefreshScreen1(void)
{
int j;
static byte BPal_old[4]={0,0,0,0}; /* Background palette */
static byte SPal0_old[4]={0,0,0,0};
static byte SPal1_old[4]={0,0,0,0}; /* Sprite palettes */
byte *from;
GXPALETTE palette[16],*to;
RefreshScreenMethod2();
#if SOUND
UpdateSound();
#endif
// Update the palette
if( *((long *)BPal) != *((long *)BPal_old) )goto changed;
if( *((long *)SPal0) != *((long *)SPal0_old) )goto changed;
if( *((long *)SPal1) != *((long *)SPal1_old) )goto changed;
return;
changed:
GXPrintf("Changing palette!!!\n");
*((long *)BPal_old) = *((long *)BPal);
*((long *)SPal0_old) = *((long *)SPal0);
*((long *)SPal1_old) = *((long *)SPal1);
to=palette;
from=BPal;
for(j=0; j<4; j++)*to++=GameBoyPalette[*from++];
from=BPal;
for(j=0; j<4; j++)*to++=GameBoyPalette[(*from++) + 4];
from=SPal0;
for(j=0; j<4; j++)*to++=GameBoyPalette[(*from++) + 8];
from=SPal1;
for(j=0; j<4; j++)*to++=GameBoyPalette[(*from++) + 12];
GXSetPaletteRange(palette, 16, 16);
}
typedef struct{
void *mac_ChrGen; //
void *mac_WndTab; //
void *mac_RAM; //
void *mac_BgdTab; //
short mac_Y;
short mac_SCROLLX; //
short mac_SCROLLY; //
short mac_WNDPOSX; //
short mac_WNDPOSY; //
byte mac_LCDCONT; //
}MYMACHINEDATA;
void RefreshLine1(byte Y)
{
MYMACHINEDATA m;
if( BackgroundOn|| WindowOn){
m.mac_ChrGen=ChrGen;
m.mac_WndTab=WndTab;
m.mac_RAM=RAM;
m.mac_BgdTab=BgdTab;
m.mac_Y=Y;
m.mac_SCROLLY=SCROLLY;
m.mac_SCROLLX=SCROLLX;
m.mac_WNDPOSX=WNDPOSX;
m.mac_WNDPOSY=WNDPOSY;
m.mac_LCDCONT=LCDCONT;
RefreshLineMethod2(&m);
}
}
void RefreshSprites1(void)
{
if(SpritesOn){
RefreshSpritesMethod2(RAM);
}
}
typedef struct{
long Frequency;
}SOUNDDATA;
SOUNDDATA SoundData[5];
void Sound1(byte R,byte V)
{
#if SOUND
SOUNDDATA *snd;
{
static int flag=1;
if(flag){
flag=0;
memset(SoundData, 0, sizeof(SoundData));
}
}
switch(R){
/*
case 0x02:
snd=&SoundData[0];
snd->Frequency=(snd->Frequency&0xff00)|V;
// GXPrintf("Channel 0: Frequency %d ** %x\n",snd->Frequency,snd->Frequency);
break;
case 0x03:
snd=&SoundData[0];
snd->Frequency=(snd->Frequency&0x00ff)|( (V&7) << 8);
GXPrintf("Channel 0: Frequency %d ** %x\n",snd->Frequency,snd->Frequency);
break;
*/
case 0x08:
snd=&SoundData[1];
snd->Frequency=(snd->Frequency&0xff00)|V;
// GXPrintf("Channel 1: Frequency %d ** %x\n",snd->Frequency,snd->Frequency);
break;
case 0x09:
snd=&SoundData[1];
snd->Frequency=(snd->Frequency&0x00ff)|( (V&7) << 8);
GXPrintf("Channel 1: Frequency %d ** %x\n",snd->Frequency,snd->Frequency);
break;
case 0x0d:
snd=&SoundData[2];
snd->Frequency=(snd->Frequency&0xff00)|V;
// GXPrintf("Channel 2: Frequency %d ** %x\n",snd->Frequency,snd->Frequency);
break;
case 0x0e:
snd=&SoundData[2];
snd->Frequency=(snd->Frequency&0x00ff)|( (V&7) << 8);
GXPrintf("Channel 2: Frequency %d ** %x\n",snd->Frequency,snd->Frequency);
break;
default:
break;
}
LowLevelSound(R,V);
#endif
}
byte SIOSend1(byte V){return 0;}
byte SIOReceive1(byte *V){return 0;}