diff --git a/engine/client/in_morphos.c b/engine/client/in_morphos.c new file mode 100644 index 000000000..f70ab9930 --- /dev/null +++ b/engine/client/in_morphos.c @@ -0,0 +1,589 @@ +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "quakedef.h" +#include "input.h" + +#include "in_morphos.h" + +cvar_t in_xflip = {"in_xflip", "0"}; + +struct InputEvent imsgs[MAXIMSGS]; +extern struct IntuitionBase *IntuitionBase; +extern struct Window *window; +extern struct Screen *screen; + +int imsglow = 0; +int imsghigh = 0; + +extern qboolean mouse_active; + +static struct Interrupt InputHandler; + +static struct Interrupt InputHandler; +static struct MsgPort *inputport = 0; +static struct IOStdReq *inputreq = 0; +static BYTE inputret = -1; + +cvar_t m_filter = {"m_filter", "1", CVAR_ARCHIVE}; + +extern cvar_t _windowed_mouse; + +float mouse_x, mouse_y; +float old_mouse_x, old_mouse_y; + +#define DEBUGRING(x) + +void IN_Shutdown(void) +{ + if (inputret == 0) + { + inputreq->io_Data = (void *)&InputHandler; + inputreq->io_Command = IND_REMHANDLER; + DoIO((struct IORequest *)inputreq); + + CloseDevice((struct IORequest *)inputreq); + + inputret = -1; + } + + if (inputreq) + { + DeleteStdIO(inputreq); + + inputreq = 0; + } + + if (inputport) + { + DeletePort(inputport); + + inputport = 0; + } + +} + +void IN_Init() +{ +/* Cvar_Register (&m_filter, "input controls");*/ + + Cvar_Register (&in_xflip, "input controls"); + + inputport = CreatePort(0, 0); + if (inputport == 0) + { + IN_Shutdown(); + Sys_Error("Unable to create message port"); + } + + inputreq = CreateStdIO(inputport); + if (inputreq == 0) + { + IN_Shutdown(); + Sys_Error("Unable to create IO request"); + } + + inputret = OpenDevice("input.device", 0, (struct IORequest *)inputreq, 0); + if (inputret != 0) + { + IN_Shutdown(); + Sys_Error("Unable to open input.device"); + } + + InputHandler.is_Node.ln_Type = NT_INTERRUPT; + InputHandler.is_Node.ln_Pri = 100; + InputHandler.is_Node.ln_Name = "Fuhquake input handler"; + InputHandler.is_Data = 0; + InputHandler.is_Code = (void(*)())&myinputhandler; + inputreq->io_Data = (void *)&InputHandler; + inputreq->io_Command = IND_ADDHANDLER; + DoIO((struct IORequest *)inputreq); + +} + +static void ExpireRingBuffer() +{ + int i = 0; + + while(imsgs[imsglow].ie_Class == IECLASS_NULL && imsglow != imsghigh) + { + imsglow++; + i++; + imsglow%= MAXIMSGS; + } + + DEBUGRING(dprintf("Expired %d messages\n", i)); +} + +void IN_Commands(void) +{ + int a; + char key; + int i; + int down; + struct InputEvent ie; + + for(i = imsglow;i != imsghigh;i++, i%= MAXIMSGS) + { + DEBUGRING(dprintf("%d %d\n", i, imsghigh)); + if ((window->Flags & WFLG_WINDOWACTIVE)) + { + if (imsgs[i].ie_Class == IECLASS_NEWMOUSE) + { + key = 0; + + if (imsgs[i].ie_Code == NM_WHEEL_UP) + key = K_MWHEELUP; + else if (imsgs[i].ie_Code == NM_WHEEL_DOWN) + key = K_MWHEELDOWN; + + if (imsgs[i].ie_Code == NM_BUTTON_FOURTH) + { + Key_Event(K_MOUSE4, true); + } + else if (imsgs[i].ie_Code == (NM_BUTTON_FOURTH|IECODE_UP_PREFIX)) + { + Key_Event(K_MOUSE4, false); + } + + if (key) + { + Key_Event(key, 1); + Key_Event(key, 0); + } + + } + else if (imsgs[i].ie_Class == IECLASS_RAWKEY) + { + down = !(imsgs[i].ie_Code&IECODE_UP_PREFIX); + imsgs[i].ie_Code&=~IECODE_UP_PREFIX; + + memcpy(&ie, &imsgs[i], sizeof(ie)); + + key = 0; + if (imsgs[i].ie_Code <= 255) + key = keyconv[imsgs[i].ie_Code]; + + if (key) + Key_Event(key, down); + else + { + if (developer.value) + Con_Printf("Unknown key %d\n", imsgs[i].ie_Code); + } + } + + else if (imsgs[i].ie_Class == IECLASS_RAWMOUSE) + { + if (imsgs[i].ie_Code == IECODE_LBUTTON) + Key_Event(K_MOUSE1, true); + else if (imsgs[i].ie_Code == (IECODE_LBUTTON|IECODE_UP_PREFIX)) + Key_Event(K_MOUSE1, false); + else if (imsgs[i].ie_Code == IECODE_RBUTTON) + Key_Event(K_MOUSE2, true); + else if (imsgs[i].ie_Code == (IECODE_RBUTTON|IECODE_UP_PREFIX)) + Key_Event(K_MOUSE2, false); + else if (imsgs[i].ie_Code == IECODE_MBUTTON) + Key_Event(K_MOUSE3, true); + else if (imsgs[i].ie_Code == (IECODE_MBUTTON|IECODE_UP_PREFIX)) + Key_Event(K_MOUSE3, false); + + mouse_x+= imsgs[i].ie_position.ie_xy.ie_x; + mouse_y+= imsgs[i].ie_position.ie_xy.ie_y; + } + + } + + imsgs[i].ie_Class = IECLASS_NULL; + + } + + ExpireRingBuffer(); + +} + +void IN_Move (usercmd_t *cmd, int pnum) +{ + if (pnum != 0) + return; //we're lazy today. + + if (m_filter.value) { + mouse_x = (mouse_x + old_mouse_x) * 0.5; + mouse_y = (mouse_y + old_mouse_y) * 0.5; + } + + old_mouse_x = mouse_x; + old_mouse_y = mouse_y; + + mouse_x *= sensitivity.value; + mouse_y *= sensitivity.value; + +#ifdef IN_XFLIP + if(in_xflip.value) mouse_x *= -1; +#endif + + if ( (in_strafe.state[pnum] & 1) || (lookstrafe.value && (in_mlook.state[pnum] & 1) )) + { + if (cmd) + cmd->sidemove += m_side.value * mouse_x; + } + else + { + cl.viewangles[pnum][YAW] -= m_yaw.value * mouse_x; + } + if (in_mlook.state[pnum] & 1) + V_StopPitchDrift (pnum); + + if ( (in_mlook.state[pnum] & 1) && !(in_strafe.state[pnum] & 1)) { + cl.viewangles[pnum][PITCH] += m_pitch.value * mouse_y; + CL_ClampPitch(pnum); + } else { + if (cmd) + { + if ((in_strafe.state[pnum] & 1) && noclip_anglehack) + cmd->upmove -= m_forward.value * mouse_y; + else + cmd->forwardmove -= m_forward.value * mouse_y; + } + } + mouse_x = mouse_y = 0.0; +} + +char keyconv[] = +{ + '`', /* 0 */ + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + '0', /* 10 */ + '-', + '=', + 0, + 0, + K_INS, + 'q', + 'w', + 'e', + 'r', + 't', /* 20 */ + 'y', + 'u', + 'i', + 'o', + 'p', + '[', + ']', + 0, + K_KP_END, + K_KP_DOWNARROW, /* 30 */ + K_KP_PGDN, + 'a', + 's', + 'd', + 'f', + 'g', + 'h', + 'j', + 'k', + 'l', /* 40 */ + ';', + '\'', + '\\', + 0, + K_KP_LEFTARROW, + K_KP_5, + K_KP_RIGHTARROW, + '<', + 'z', + 'x', /* 50 */ + 'c', + 'v', + 'b', + 'n', + 'm', + ',', + '.', + '/', + 0, + K_KP_DEL, /* 60 */ + K_KP_HOME, + K_KP_UPARROW, + K_KP_PGUP, + ' ', + K_BACKSPACE, + K_TAB, + K_KP_ENTER, + K_ENTER, + K_ESCAPE, + K_DEL, /* 70 */ + K_INS, + K_PGUP, + K_PGDN, + K_KP_MINUS, + K_F11, + K_UPARROW, + K_DOWNARROW, + K_RIGHTARROW, + K_LEFTARROW, + K_F1, /* 80 */ + K_F2, + K_F3, + K_F4, + K_F5, + K_F6, + K_F7, + K_F8, + K_F9, + K_F10, + 0, /* 90 */ + 0, + K_KP_SLASH, + 0, + K_KP_PLUS, + 0, + K_SHIFT, + K_SHIFT, + 0, + K_CTRL, + K_ALT, /* 100 */ + K_ALT, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + K_PAUSE, /* 110 */ + K_F12, + K_HOME, + K_END, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 120 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 130 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 140 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 150 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 160 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 170 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 180 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 190 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 200 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 210 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 220 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 230 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 240 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, /* 250 */ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 +}; + +struct InputEvent *myinputhandler_real(void); + +struct EmulLibEntry myinputhandler = +{ + TRAP_LIB, 0, (void(*)(void))myinputhandler_real +}; + +struct InputEvent *myinputhandler_real() +{ + struct InputEvent *moo = (struct InputEvent *)REG_A0; + + struct InputEvent *coin; + + int screeninfront; + + coin = moo; + + if (screen) + { +#if 0 + if (IntuitionBase->LibNode.lib_Version > 50 || (IntuitionBase == 50 && IntuitionBase->LibNode.lib_Revision >= 56)) + GetAttr(screen, SA_Displayed, &screeninfront); + else +#endif + screeninfront = screen==IntuitionBase->FirstScreen; + } + else + screeninfront = 1; + + do + { + if (coin->ie_Class == IECLASS_RAWMOUSE || coin->ie_Class == IECLASS_RAWKEY || coin->ie_Class == IECLASS_NEWMOUSE) + { +/* kprintf("Mouse\n");*/ + + if ((imsghigh > imsglow && !(imsghigh == MAXIMSGS-1 && imsglow == 0)) || (imsghigh < imsglow && imsghigh != imsglow-1) || imsglow == imsghigh) + { + memcpy(&imsgs[imsghigh], coin, sizeof(imsgs[0])); + imsghigh++; + imsghigh%= MAXIMSGS; + } + else + { + DEBUGRING(kprintf("FTE: message dropped, imsglow = %d, imsghigh = %d\n", imsglow, imsghigh)); + } + + if (/*mouse_active && */(window->Flags & WFLG_WINDOWACTIVE) && coin->ie_Class == IECLASS_RAWMOUSE && screeninfront && window->MouseX > 0 && window->MouseY > 0) + { + if (_windowed_mouse.value) + { +#if 0 + coin->ie_Class = IECLASS_NULL; +#else + coin->ie_position.ie_xy.ie_x = 0; + coin->ie_position.ie_xy.ie_y = 0; +#endif + } + } + } + + coin = coin->ie_NextEvent; + } while(coin); + + return moo; +} + diff --git a/engine/client/in_morphos.h b/engine/client/in_morphos.h new file mode 100644 index 000000000..1018a77f1 --- /dev/null +++ b/engine/client/in_morphos.h @@ -0,0 +1,4 @@ +#define MAXIMSGS 32 + +extern char keyconv[]; +extern struct EmulLibEntry myinputhandler; diff --git a/engine/client/snd_morphos.c b/engine/client/snd_morphos.c new file mode 100644 index 000000000..8f33ea55d --- /dev/null +++ b/engine/client/snd_morphos.c @@ -0,0 +1,248 @@ +#include +#include +#include +#define USE_INLINE_STDARG +#include + +#include "quakedef.h" + +#warning Remove this once Spike fixes the sound input code. +void S_UpdateCapture(void) +{ +} + +struct AHIChannelInfo +{ + struct AHIEffChannelInfo aeci; + ULONG offset; +}; + +struct AHIdata +{ + struct MsgPort *msgport; + struct AHIRequest *ahireq; + int ahiopen; + struct AHIAudioCtrl *audioctrl; + void *samplebuffer; + struct Hook EffectHook; + struct AHIChannelInfo aci; + unsigned int readpos; +}; + +ULONG EffectFunc() +{ + struct Hook *hook = (struct Hook *)REG_A0; + struct AHIEffChannelInfo *aeci = (struct AHIEffChannelInfo *)REG_A1; + + struct AHIdata *ad; + + ad = hook->h_Data; + + ad->readpos = aeci->ahieci_Offset[0]; + + return 0; +} + +static struct EmulLibEntry EffectFunc_Gate = +{ + TRAP_LIB, 0, (void (*)(void))EffectFunc +}; + +static void AHI_Shutdown(soundcardinfo_t *sc) +{ + struct AHIdata *ad; + + struct Library *AHIBase; + + ad = sc->handle; + + AHIBase = (struct Library *)ad->ahireq->ahir_Std.io_Device; + + ad->aci.aeci.ahie_Effect = AHIET_CHANNELINFO|AHIET_CANCEL; + AHI_SetEffect(&ad->aci.aeci, ad->audioctrl); + AHI_ControlAudio(ad->audioctrl, + AHIC_Play, FALSE, + TAG_END); + + AHI_FreeAudio(ad->audioctrl); + FreeVec(ad->samplebuffer); + CloseDevice((struct IORequest *)ad->ahireq); + DeleteIORequest((struct IORequest *)ad->ahireq); + DeleteMsgPort(ad->msgport); + FreeVec(ad); +} + +static unsigned int AHI_GetDMAPos(soundcardinfo_t *sc) +{ + struct AHIdata *ad; + + ad = sc->handle; + + sc->sn.samplepos = ad->readpos*sc->sn.numchannels; + + return sc->sn.samplepos; +} + +static void AHI_UnlockBuffer(soundcardinfo_t *sc, void *buffer) +{ +} + +static void *AHI_LockBuffer(soundcardinfo_t *sc) +{ + return sc->sn.buffer; +} + +static void AHI_SetUnderWater(soundcardinfo_t *sc, qboolean uw) +{ +} + +static void AHI_Submit(soundcardinfo_t *sc) +{ +} + +static int AHI_InitCard(soundcardinfo_t *sc, int cardnum) +{ + struct AHIdata *ad; + + ULONG channels; + ULONG speed; + ULONG bits; + + ULONG r; + + struct Library *AHIBase; + + struct AHISampleInfo sample; + + if (cardnum) + return 2; /* Which means "no more cards" */ + + ad = AllocVec(sizeof(*ad), MEMF_ANY); + if (ad) + { + ad->msgport = CreateMsgPort(); + if (ad->msgport) + { + ad->ahireq = (struct AHIRequest *)CreateIORequest(ad->msgport, sizeof(struct AHIRequest)); + if (ad->ahireq) + { + ad->ahiopen = !OpenDevice("ahi.device", AHI_NO_UNIT, (struct IORequest *)ad->ahireq, 0); + if (ad->ahiopen) + { + AHIBase = (struct Library *)ad->ahireq->ahir_Std.io_Device; + + ad->audioctrl = AHI_AllocAudio(AHIA_AudioID, AHI_DEFAULT_ID, + AHIA_MixFreq, sc->sn.speed, + AHIA_Channels, 1, + AHIA_Sounds, 1, + TAG_END); + + if (ad->audioctrl) + { + AHI_GetAudioAttrs(AHI_INVALID_ID, ad->audioctrl, + AHIDB_BufferLen, sizeof(sc->name), + AHIDB_Name, (ULONG)sc->name, + AHIDB_MaxChannels, (ULONG)&channels, + AHIDB_Bits, (ULONG)&bits, + TAG_END); + + AHI_ControlAudio(ad->audioctrl, + AHIC_MixFreq_Query, (ULONG)&speed, + TAG_END); + + if (bits == 8 || bits == 16) + { + if (channels > 2) + channels = 2; + + sc->sn.speed = speed; + sc->sn.samplebits = bits; + sc->sn.numchannels = channels; + sc->sn.samples = speed*channels; + + ad->samplebuffer = AllocVec(speed*(bits/8)*channels, MEMF_ANY); + if (ad->samplebuffer) + { + sc->sn.buffer = ad->samplebuffer; + + if (channels == 1) + { + if (bits == 8) + sample.ahisi_Type = AHIST_M8S; + else + sample.ahisi_Type = AHIST_M16S; + } + else + { + if (bits == 8) + sample.ahisi_Type = AHIST_S8S; + else + sample.ahisi_Type = AHIST_S16S; + } + + sample.ahisi_Address = ad->samplebuffer; + sample.ahisi_Length = (speed*(bits/8)*channels)/AHI_SampleFrameSize(sample.ahisi_Type); + + r = AHI_LoadSound(0, AHIST_DYNAMICSAMPLE, &sample, ad->audioctrl); + if (r == 0) + { + r = AHI_ControlAudio(ad->audioctrl, + AHIC_Play, TRUE, + TAG_END); + + if (r == 0) + { + AHI_Play(ad->audioctrl, + AHIP_BeginChannel, 0, + AHIP_Freq, speed, + AHIP_Vol, 0x10000, + AHIP_Pan, 0x8000, + AHIP_Sound, 0, + AHIP_EndChannel, NULL, + TAG_END); + + ad->aci.aeci.ahie_Effect = AHIET_CHANNELINFO; + ad->aci.aeci.ahieci_Func = &ad->EffectHook; + ad->aci.aeci.ahieci_Channels = 1; + + ad->EffectHook.h_Entry = (void *)&EffectFunc_Gate; + ad->EffectHook.h_Data = ad; + + AHI_SetEffect(&ad->aci, ad->audioctrl); + + sc->handle = ad; + + sc->Lock = AHI_LockBuffer; + sc->Unlock = AHI_UnlockBuffer; + sc->SetWaterDistortion = AHI_SetUnderWater; + sc->Submit = AHI_Submit; + sc->Shutdown = AHI_Shutdown; + sc->GetDMAPos = AHI_GetDMAPos; + + Con_Printf("Using AHI mode \"%s\" for audio output\n", sc->name); + Con_Printf("Channels: %d bits: %d frequency: %d\n", channels, bits, speed); + + return 1; + } + } + } + FreeVec(ad->samplebuffer); + } + AHI_FreeAudio(ad->audioctrl); + } + else + Con_Printf("Failed to allocate AHI audio\n"); + + CloseDevice((struct IORequest *)ad->ahireq); + } + DeleteIORequest((struct IORequest *)ad->ahireq); + } + DeleteMsgPort(ad->msgport); + } + FreeVec(ad); + } + + return 0; +} + +sounddriver pAHI_InitCard = &AHI_InitCard; diff --git a/engine/client/sys_morphos.c b/engine/client/sys_morphos.c new file mode 100755 index 000000000..397e73848 --- /dev/null +++ b/engine/client/sys_morphos.c @@ -0,0 +1,285 @@ +#include +#include +#include +#include + +#include +#include + +#include "quakedef.h" + +#warning Find a better stack size + +int __stack = 4*1024*1024; + +struct Library *DynLoadBase; + +#ifndef CLIENTONLY +qboolean isDedicated; +#endif + +static void Sys_Shutdown() +{ + if(DynLoadBase) + { + CloseLibrary(DynLoadBase); + DynLoadBase = 0; + } +} + +void Sys_Quit (void) +{ + Host_Shutdown(); + + Sys_Shutdown(); + + exit(0); +} + +static void ftevprintf(const char *fmt, va_list arg) +{ + char buf[4096]; + unsigned char *p; + + vsnprintf(buf, sizeof(buf), fmt, arg); + + for (p = (unsigned char *)buf; *p; p++) + if ((*p > 128 || *p < 32) && *p != 10 && *p != 13 && *p != 9) + printf("[%02x]", *p); + else + putc(*p, stdout); +} + +void Sys_Printf(char *fmt, ...) +{ + va_list arg; + + va_start(arg, fmt); + ftevprintf(fmt, arg); + va_end(arg); +} + +void Sys_Error(const char *error, ...) +{ + va_list arg; + + printf("Error: "); + va_start(arg, error); + ftevprintf(error, arg); + va_end(arg); + + Host_Shutdown (); + exit (1); +} + +void Sys_Warn(char *warning, ...) +{ + va_list arg; + + printf("Warning: "); + va_start(arg, warning); + ftevprintf(warning, arg); + va_end(arg); +} + +int Sys_DebugLog(char *file, char *fmt, ...) +{ + va_list arg; + char buf[4096]; + BPTR fh; + + fh = Open(file, MODE_READWRITE); + if (fh) + { + Seek(fh, OFFSET_END, 0); + + va_start(arg, fmt); + vsnprintf(buf, sizeof(buf), fmt, arg); + va_end(arg); + + Write(fh, buf, strlen(buf)); + + Close(fh); + + return true; + } + + return false; +} + +int secbase; +unsigned int Sys_Milliseconds(void) +{ + struct timeval tp; + struct timezone tzp; + + gettimeofday(&tp, &tzp); + + if (!secbase) + { + secbase = tp.tv_sec; + return tp.tv_usec/1000; + } + + return (tp.tv_sec - secbase)*1000 + tp.tv_usec/1000; +} + +double Sys_DoubleTime(void) +{ + struct timeval tp; + struct timezone tzp; + + gettimeofday(&tp, &tzp); + + if (!secbase) + { + secbase = tp.tv_sec; + return tp.tv_usec/1000000.0; + } + + return (tp.tv_sec - secbase) + tp.tv_usec/1000000.0; +} + +/* FS stuff */ + +int Sys_FileTime(char *path) +{ + BPTR lock; + struct FileInfoBlock fib; + int ret = -1; + + if (path[0] == '.' && path[1] == '/') + path+= 2; + + lock = Lock(path, ACCESS_READ); + if (lock) + { + if (Examine(lock, &fib)) + { + ret = ((fib.fib_Date.ds_Days+2922)*1440+fib.fib_Date.ds_Minute)*60+fib.fib_Date.ds_Tick/TICKS_PER_SECOND; + } + + UnLock(lock); + } + else + dprintf("Unable to find file %s\n", path); + + return ret; +} + +int Sys_EnumerateFiles(char *gpath, char *match, int (*func)(char *, int, void *), void *parm) +{ + return true; +} + +void Sys_mkdir(char *path) +{ + BPTR lock; + + if (path[0] == '.' && path[1] == '/') + path+= 2; + + lock = CreateDir(path); + if (lock) + { + UnLock(lock); + } +} + +qboolean Sys_remove(char *path) +{ + if (path[0] == '.' && path[1] == '/') + path+= 2; + + return DeleteFile(path); +} + +/* Quake 2 stuff */ +void Sys_UnloadGame (void) +{ +} + +void *Sys_GetGameAPI (void *parms) +{ + return NULL; +} + +int main(int argc, char **argv) +{ + double oldtime, newtime; + quakeparms_t parms; + int i; + + COM_InitArgv(argc, argv); + TL_InitLanguages(); + + i = COM_CheckParm("-mem"); + if (i && i < com_argc) + parms.memsize = atoi(com_argv[i+1])*1024*1024; + else + parms.memsize = 16*1024*1024; + + parms.basedir = ""; + parms.argc = argc; + parms.argv = argv; + parms.membase = malloc(parms.memsize); + + if (parms.membase == 0) + Sys_Error("Can't allocated %d bytes\n", parms.memsize); + + DynLoadBase = OpenLibrary("dynload.library", 0); + + Host_Init(&parms); + + oldtime = Sys_DoubleTime (); + while (1) + { + newtime = Sys_DoubleTime (); + Host_Frame(newtime - oldtime); + oldtime = newtime; + } +} + +void Sys_Init() +{ +} + +char *Sys_GetClipboard(void) +{ + return 0; +} + +void Sys_CloseClipboard(char *buf) +{ +} + +void Sys_SaveClipboard(char *text) +{ +} + +qboolean Sys_InitTerminal() +{ + return false; +} +void Sys_CloseTerminal() +{ +} + +char *Sys_ConsoleInput() +{ + return 0; +} + +void Sys_ServerActivity(void) +{ +} + +/* x86 crap */ +void Sys_HighFPPrecision (void) +{ +} + +void Sys_LowFPPrecision (void) +{ +} + diff --git a/engine/gl/gl_vidmorphos.c b/engine/gl/gl_vidmorphos.c new file mode 100644 index 000000000..5d9bf37ce --- /dev/null +++ b/engine/gl/gl_vidmorphos.c @@ -0,0 +1,655 @@ +#include +#define SYSTEM_PRIVATE +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include "quakedef.h" +#include "glquake.h" + +#include "gl_vidtinyglstubs.c" + +#define WARP_WIDTH 320 +#define WARP_HEIGHT 200 + +extern qboolean gammaworks; +extern unsigned short ramps[3][256]; + +struct Library *TinyGLBase = 0; +GLContext *__tglContext; +static int glctx = 0; + +float vid_gamma = 1.0; + +unsigned char *mosgammatable; + +struct Window *window; +struct Screen *screen; + +static void *pointermem; + +static int real_width, real_height; + +static void *TinyGL_GetSymbol(char *name) +{ + void *ret = 0; + + if (strcmp(name, "glAlphaFunc") == 0) + ret = stub_glAlphaFunc; + + else if (strcmp(name, "glBegin") == 0) + ret = stub_glBegin; + + else if (strcmp(name, "glBlendFunc") == 0) + ret = stub_glBlendFunc; + + else if (strcmp(name, "glBindTexture") == 0) + ret = stub_glBindTexture; + + else if (strcmp(name, "glClear") == 0) + ret = stub_glClear; + + else if (strcmp(name, "glClearColor") == 0) + ret = stub_glClearColor; + + else if (strcmp(name, "glClearDepth") == 0) + ret = stub_glClearDepth; + + else if (strcmp(name, "glClearStencil") == 0) + ret = stub_glClearStencil; + + else if (strcmp(name, "glColor3f") == 0) + ret = stub_glColor3f; + + else if (strcmp(name, "glColor3ub") == 0) + ret = stub_glColor3ub; + + else if (strcmp(name, "glColor4f") == 0) + ret = stub_glColor4f; + + else if (strcmp(name, "glColor4fv") == 0) + ret = stub_glColor4fv; + + else if (strcmp(name, "glColor4ub") == 0) + ret = stub_glColor4ub; + + else if (strcmp(name, "glColor4ubv") == 0) + ret = stub_glColor4ubv; + + else if (strcmp(name, "glColorMask") == 0) + ret = stub_glColorMask; + + else if (strcmp(name, "glCopyTexImage2D") == 0) + ret = stub_glCopyTexImage2D; + + else if (strcmp(name, "glCullFace") == 0) + ret = stub_glCullFace; + + else if (strcmp(name, "glDepthFunc") == 0) + ret = stub_glDepthFunc; + + else if (strcmp(name, "glDepthMask") == 0) + ret = stub_glDepthMask; + + else if (strcmp(name, "glDepthRange") == 0) + ret = stub_glDepthRange; + + else if (strcmp(name, "glDisable") == 0) + ret = stub_glDisable; + + else if (strcmp(name, "glDrawBuffer") == 0) + ret = stub_glDrawBuffer; + + else if (strcmp(name, "glDrawPixels") == 0) + ret = stub_glDrawPixels; + + else if (strcmp(name, "glEnable") == 0) + ret = stub_glEnable; + + else if (strcmp(name, "glEnd") == 0) + ret = stub_glEnd; + + else if (strcmp(name, "glFinish") == 0) + ret = stub_glFinish; + + else if (strcmp(name, "glFlush") == 0) + ret = stub_glFlush; + + else if (strcmp(name, "glFrustum") == 0) + ret = stub_glFrustum; + + else if (strcmp(name, "glGetFloatv") == 0) + ret = stub_glGetFloatv; + + else if (strcmp(name, "glGetIntegerv") == 0) + ret = stub_glGetIntegerv; + + else if (strcmp(name, "glGetString") == 0) + ret = stub_glGetString; + + else if (strcmp(name, "glGetTexLevelParameteriv") == 0) + ret = stub_glGetTexLevelParameteriv; + + else if (strcmp(name, "glHint") == 0) + ret = stub_glHint; + + else if (strcmp(name, "glLoadIdentity") == 0) + ret = stub_glLoadIdentity; + + else if (strcmp(name, "glLoadMatrixf") == 0) + ret = stub_glLoadMatrixf; + + else if (strcmp(name, "glNormal3f") == 0) + ret = stub_glNormal3f; + + else if (strcmp(name, "glNormal3fv") == 0) + ret = stub_glNormal3fv; + + else if (strcmp(name, "glMatrixMode") == 0) + ret = stub_glMatrixMode; + + else if (strcmp(name, "glMultMatrixf") == 0) + ret = stub_glMultMatrixf; + + else if (strcmp(name, "glOrtho") == 0) + ret = stub_glOrtho; + + else if (strcmp(name, "glPolygonMode") == 0) + ret = stub_glPolygonMode; + + else if (strcmp(name, "glPopMatrix") == 0) + ret = stub_glPopMatrix; + + else if (strcmp(name, "glPushMatrix") == 0) + ret = stub_glPushMatrix; + + else if (strcmp(name, "glReadBuffer") == 0) + ret = stub_glReadBuffer; + + else if (strcmp(name, "glReadPixels") == 0) + ret = stub_glReadPixels; + + else if (strcmp(name, "glRotatef") == 0) + ret = stub_glRotatef; + + else if (strcmp(name, "glScalef") == 0) + ret = stub_glScalef; + + else if (strcmp(name, "glShadeModel") == 0) + ret = stub_glShadeModel; + + else if (strcmp(name, "glTexCoord1f") == 0) + ret = stub_glTexCoord1f; + + else if (strcmp(name, "glTexCoord2f") == 0) + ret = stub_glTexCoord2f; + + else if (strcmp(name, "glTexCoord2fv") == 0) + ret = stub_glTexCoord2fv; + + else if (strcmp(name, "glTexEnvf") == 0) + ret = stub_glTexEnvf; + + else if (strcmp(name, "glTexEnvfv") == 0) + ret = stub_glTexEnvfv; + + else if (strcmp(name, "glTexEnvi") == 0) + ret = stub_glTexEnvi; + + else if (strcmp(name, "glTexGeni") == 0) + ret = stub_glTexGeni; + + else if (strcmp(name, "glTexImage2D") == 0) + ret = stub_glTexImage2D; + + else if (strcmp(name, "glTexParameteri") == 0) + ret = stub_glTexParameteri; + + else if (strcmp(name, "glTexParameterf") == 0) + ret = stub_glTexParameterf; + + else if (strcmp(name, "glTexSubImage2D") == 0) + ret = stub_glTexSubImage2D; + + else if (strcmp(name, "glTranslatef") == 0) + ret = stub_glTranslatef; + + else if (strcmp(name, "glVertex2f") == 0) + ret = stub_glVertex2f; + + else if (strcmp(name, "glVertex3f") == 0) + ret = stub_glVertex3f; + + else if (strcmp(name, "glVertex3fv") == 0) + ret = stub_glVertex3fv; + + else if (strcmp(name, "glViewport") == 0) + ret = stub_glViewport; + + else if (strcmp(name, "glGetError") == 0) + ret = stub_glGetError; + + else if (strcmp(name, "glDrawElements") == 0) + ret = stub_glDrawElements; + + else if (strcmp(name, "glArrayElement") == 0) + ret = stub_glArrayElement; + + else if (strcmp(name, "glVertexPointer") == 0) + ret = stub_glVertexPointer; + + else if (strcmp(name, "glNormalPointer") == 0) + ret = stub_glNormalPointer; + + else if (strcmp(name, "glTexCoordPointer") == 0) + ret = stub_glTexCoordPointer; + + else if (strcmp(name, "glColorPointer") == 0) + ret = stub_glColorPointer; + + else if (strcmp(name, "glDrawArrays") == 0) + ret = stub_glDrawArrays; + + else if (strcmp(name, "glEnableClientState") == 0) + ret = stub_glEnableClientState; + + else if (strcmp(name, "glDisableClientState") == 0) + ret = stub_glDisableClientState; + + else if (strcmp(name, "glStencilOp") == 0) + ret = stub_glStencilOp; + + else if (strcmp(name, "glStencilFunc") == 0) + ret = stub_glStencilFunc; + + else if (strcmp(name, "glPushAttrib") == 0) + ret = stub_glPushAttrib; + + else if (strcmp(name, "glPopAttrib") == 0) + ret = stub_glPopAttrib; + + else if (strcmp(name, "glScissor") == 0) + ret = stub_glScissor; + + else if (strcmp(name, "glMultiTexCoord2fARB") == 0) + ret = stub_glMultiTexCoord2fARB; + + else if (strcmp(name, "glMultiTexCoord3fARB") == 0) + ret = stub_glMultiTexCoord3fARB; + + else if (strcmp(name, "glActiveTextureARB") == 0) + ret = stub_glActiveTextureARB; + + else if (strcmp(name, "glClientActiveTextureARB") == 0) + ret = stub_glClientActiveTextureARB; + + else + printf("Function \"%s\" not found\n", name); + + return ret; +} + +qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette) +{ + int argnum; + + int r; + + int i; + + int depth = 24; + + struct TagItem tgltags[] = + { + { 0, 0 }, + { TGL_CONTEXT_STENCIL, TRUE }, + { TAG_DONE } + }; + + if (IntuitionBase->LibNode.lib_Version > 50 || (IntuitionBase->LibNode.lib_Version == 50 && IntuitionBase->LibNode.lib_Revision >= 74)) + { + mosgammatable = AllocVec(256*3, MEMF_ANY); + if (mosgammatable) + gammaworks = 1; + } + + vid.width = info->width; + vid.height = info->height; + vid.maxwarpwidth = WARP_WIDTH; + vid.maxwarpheight = WARP_HEIGHT; + vid.numpages = 3; + vid.colormap = host_colormap; + + if (vid.width <= 640) + { + vid.conwidth = vid.width; + vid.conheight = vid.height; + } + else + { + vid.conwidth = vid.width/2; + vid.conheight = vid.height/2; + } + + if ((i = COM_CheckParm("-conwidth")) && i + 1 < com_argc) + { + vid.conwidth = Q_atoi(com_argv[i + 1]); + + // pick a conheight that matches with correct aspect + vid.conheight = vid.conwidth * 3 / 4; + } + + vid.conwidth &= 0xfff8; // make it a multiple of eight + + if ((i = COM_CheckParm("-conheight")) && i + 1 < com_argc) + vid.conheight = Q_atoi(com_argv[i + 1]); + + if (vid.conwidth < 320) + vid.conwidth = 320; + + if (vid.conheight < 200) + vid.conheight = 200; + + TinyGLBase = OpenLibrary("tinygl.library", 0); + if (TinyGLBase) + { + if (TinyGLBase->lib_Version > 50 || (TinyGLBase->lib_Version == 50 && TinyGLBase->lib_Revision >= 9)) + { + vid.rowbytes = vid.width; + vid.direct = 0; /* Isn't used anywhere, but whatever. */ + vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0); + + if (info->fullscreen) + { + screen = OpenScreenTags(0, + SA_Width, vid.width, + SA_Height, vid.height, + SA_Depth, depth, + SA_Quiet, TRUE, + SA_GammaControl, TRUE, + SA_3DSupport, TRUE, + TAG_DONE); + } + + window = OpenWindowTags(0, + WA_InnerWidth, vid.width, + WA_InnerHeight, vid.height, + WA_Title, "FTEQuake", + WA_DragBar, screen?FALSE:TRUE, + WA_DepthGadget, screen?FALSE:TRUE, + WA_Borderless, screen?TRUE:FALSE, + WA_RMBTrap, TRUE, + screen?WA_PubScreen:TAG_IGNORE, (ULONG)screen, + WA_Activate, TRUE, + TAG_DONE); + + if (window) + { + if (screen == 0) + gammaworks = 0; + + __tglContext = GLInit(); + if (__tglContext) + { + if (screen) + { + tgltags[0].ti_Tag = TGL_CONTEXT_SCREEN; + tgltags[0].ti_Data = screen; + } + else + { + tgltags[0].ti_Tag = TGL_CONTEXT_WINDOW; + tgltags[0].ti_Data = window; + } + + r = GLAInitializeContext(__tglContext, tgltags); + + if (r) + { + glctx = 1; + + gl_canstencil = 8; + + pointermem = AllocVec(256, MEMF_ANY|MEMF_CLEAR); + if (pointermem) + { + SetPointer(window, pointermem, 16, 16, 0, 0); + +#if 0 + lastwindowedmouse = 1; +#endif + + real_width = vid.width; + real_height = vid.height; + + if (vid.conheight > vid.height) + vid.conheight = vid.height; + if (vid.conwidth > vid.width) + vid.conwidth = vid.width; + + vid.width = vid.conwidth; + vid.height = vid.conheight; + + GL_Init(&TinyGL_GetSymbol); + + VID_SetPalette(palette); + + vid.recalc_refdef = 1; + + return true; + } + else + { + Con_Printf("Unable to allocate memory for mouse pointer"); + } + + if (screen && !(TinyGLBase->lib_Version == 0 && TinyGLBase->lib_Revision < 4)) + { + glADestroyContextScreen(); + } + else + { + glADestroyContextWindowed(); + } + + glctx = 0; + } + else + { + Con_Printf("Unable to initialize GL context"); + } + + GLClose(__tglContext); + __tglContext = 0; + } + else + { + Con_Printf("Unable to create GL context"); + } + + if (screen) + { + CloseScreen(screen); + screen = 0; + } + + CloseWindow(window); + window = 0; + } + else + { + Con_Printf("Unable to open window"); + } + + } + + CloseLibrary(TinyGLBase); + TinyGLBase = 0; + } + else + { + Con_Printf("Couldn't open tinygl.library"); + } + + return false; +} + +void GLVID_DeInit() +{ + printf("1\n"); + if (glctx) + { + if (screen && !(TinyGLBase->lib_Version == 0 && TinyGLBase->lib_Revision < 4)) + { + glADestroyContextScreen(); + } + else + { + glADestroyContextWindowed(); + } + + glctx = 0; + } + + printf("2\n"); + if (__tglContext) + { + GLClose(__tglContext); + __tglContext = 0; + } + + if (window) + { + CloseWindow(window); + window = 0; + } + + if (pointermem) + { + FreeVec(pointermem); + pointermem = 0; + } + + if (screen) + { + CloseScreen(screen); + screen = 0; + } + + if (TinyGLBase) + { + CloseLibrary(TinyGLBase); + TinyGLBase = 0; + } + + if (mosgammatable) + { + FreeVec(mosgammatable); + mosgammatable = 0; + } +} + +void GL_BeginRendering (int *x, int *y, int *width, int *height) +{ + *x = *y = 0; + *width = real_width; + *height = real_height; +} + +void GL_EndRendering (void) +{ + glASwapBuffers(); +} + +void GL_DoSwap(void) +{ +} + +void GLVID_SetPalette (unsigned char *palette) +{ + qbyte *pal; + unsigned int r,g,b; + int i; + unsigned *table1; + unsigned *table2; + extern qbyte gammatable[256]; + + Con_Printf("Converting 8to24\n"); + + pal = palette; + table1 = d_8to24rgbtable; + table2 = d_8to24bgrtable; + for (i=0 ; i<256 ; i++) + { + r = gammatable[pal[0]]; + g = gammatable[pal[1]]; + b = gammatable[pal[2]]; + pal += 3; + + *table1++ = LittleLong((255<<24) + (r<<0) + (g<<8) + (b<<16)); + *table2++ = LittleLong((255<<24) + (r<<16) + (g<<8) + (b<<0)); + } + d_8to24bgrtable[255] &= LittleLong(0xffffff); // 255 is transparent + d_8to24rgbtable[255] &= LittleLong(0xffffff); // 255 is transparent +} + +void GLVID_ShiftPalette (unsigned char *palette) +{ + int i; + + if (gammaworks) + { + for(i=0;i<768;i++) + { + mosgammatable[i] = ramps[0][i]>>8; + } + + SetAttrs(screen, + SA_GammaRed, mosgammatable, + SA_GammaGreen, mosgammatable+256, + SA_GammaBlue, mosgammatable+512, + TAG_DONE); + } +} + +void GLD_BeginDirectRect (int x, int y, qbyte *pbitmap, int width, int height) +{ +} + +void GLD_EndDirectRect (int x, int y, int width, int height) +{ +} + +void GLVID_UnlockBuffer() +{ +} + +void GLVID_LockBuffer() +{ +} + +int GLVID_ForceUnlockedAndReturnState (void) +{ + return 0; +} + +void GLVID_ForceLockState (int lk) +{ +} + +void GLVID_HandlePause (qboolean pause) +{ +} + +void Sys_SendKeyEvents(void) +{ +} diff --git a/engine/gl/gl_vidtinyglstubs.c b/engine/gl/gl_vidtinyglstubs.c new file mode 100644 index 000000000..7a098f188 --- /dev/null +++ b/engine/gl/gl_vidtinyglstubs.c @@ -0,0 +1,423 @@ +void stub_glAlphaFunc(GLenum func, GLclampf ref) +{ + glAlphaFunc(func, ref); +} + +void stub_glBegin(GLenum mode) +{ + glBegin(mode); +} + +void stub_glBlendFunc(GLenum sfactor, GLenum dfactor) +{ + glBlendFunc(sfactor, dfactor); +} + +void stub_glBindTexture(GLenum target, GLuint texture) +{ + glBindTexture(target, texture); +} + +void stub_glClear(GLbitfield mask) +{ + glClear(mask); +} + +void stub_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + glClearColor(red, green, blue, alpha); +} + +void stub_glClearDepth(GLclampd depth) +{ + glClearDepth(depth); +} + +void stub_glClearStencil(GLint s) +{ + glClearStencil(s); +} + +void stub_glColor3f(GLfloat red, GLfloat green, GLfloat blue) +{ + glColor3f(red, green, blue); +} + +void stub_glColor3ub(GLubyte red, GLubyte green, GLubyte blue) +{ + glColor3ub(red, green, blue); +} + +void stub_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) +{ + glColor4f(red, green, blue, alpha); +} + +void stub_glColor4fv(const GLfloat *v) +{ + glColor4fv(v); +} + +void stub_glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) +{ + glColor4ub(red, green, blue, alpha); +} + +void stub_glColor4ubv(const GLubyte *v) +{ + glColor4ubv(v); +} + +void stub_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ + glColorMask(red, green, blue, alpha); +} + +void stub_glCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ +#warning Not implemented +#if 0 + glCopyTexImage2D(target, level, internalFormat, x, y, width, height, border); +#endif +} + +void stub_glCullFace(GLenum mode) +{ + glCullFace(mode); +} + +void stub_glDepthFunc(GLenum func) +{ + glDepthFunc(func); +} + +void stub_glDepthMask(GLboolean flag) +{ + glDepthMask(flag); +} + +void stub_glDepthRange(GLclampd zNear, GLclampd zFar) +{ + glDepthRange(zNear, zFar); +} + +void stub_glDisable(GLenum cap) +{ + glDisable(cap); +} + +void stub_glDrawBuffer(GLenum mode) +{ +#warning Not implemented +#if 0 + glDrawBuffer(mode); +#endif +} + +void stub_glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) +{ +#warning Not implemented +#if 0 + glDrawPixels(width, height, format, type, pixels); +#endif +} + +void stub_glEnable(GLenum cap) +{ + glEnable(cap); +} + +void stub_glEnd(void) +{ + glEnd(); +} + +void stub_glFinish(void) +{ + glFinish(); +} + +void stub_glFlush(void) +{ + glFlush(); +} + +void stub_glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) +{ + glFrustum(left, right, bottom, top, zNear, zFar); +} + +void stub_glGetFloatv(GLenum pname, GLfloat *params) +{ + glGetFloatv(pname, params); +} + +void stub_glGetIntegerv(GLenum pname, GLint *params) +{ + glGetIntegerv(pname, params); +} + +const GLubyte *stub_glGetString(GLenum name) +{ + return glGetString(name); +} + +void stub_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params) +{ + glGetTexLevelParameteriv(target, level, pname, params); +} + +void stub_glHint(GLenum target, GLenum mode) +{ + glHint(target, mode); +} + +void stub_glLoadIdentity(void) +{ + glLoadIdentity(); +} + +void stub_glLoadMatrixf(const GLfloat *m) +{ + glLoadMatrixf(m); +} + +void stub_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz) +{ + glNormal3f(nx, ny, nz); +} + +void stub_glNormal3fv(const GLfloat *v) +{ + glNormal3fv(v); +} + +void stub_glMatrixMode(GLenum mode) +{ + glMatrixMode(mode); +} + +void stub_glMultMatrixf(const GLfloat *m) +{ + glMultMatrixf(m); +} + +void stub_glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) +{ + glOrtho(left, right, bottom, top, zNear, zFar); +} + +void stub_glPolygonMode(GLenum face, GLenum mode) +{ + glPolygonMode(face, mode); +} + +void stub_glPopMatrix(void) +{ + glPopMatrix(); +} + +void stub_glPushMatrix(void) +{ + glPushMatrix(); +} + +void stub_glReadBuffer(GLenum mode) +{ + glReadBuffer(mode); +} + +void stub_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) +{ + glReadPixels(x, y, width, height, format, type, pixels); +} + +void stub_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) +{ + glRotatef(angle, x, y, z); +} + +void stub_glScalef(GLfloat x, GLfloat y, GLfloat z) +{ + glScalef(x, y, z); +} + +void stub_glShadeModel(GLenum mode) +{ + glShadeModel(mode); +} + +void stub_glTexCoord1f(GLfloat s) +{ + glTexCoord1f(s); +} + +void stub_glTexCoord2f(GLfloat s, GLfloat t) +{ + glTexCoord2f(s, t); +} + +void stub_glTexCoord2fv(const GLfloat *v) +{ + glTexCoord2fv(v); +} + +void stub_glTexEnvf(GLenum target, GLenum pname, GLfloat param) +{ + glTexEnvf(target, pname, param); +} + +void stub_glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params) +{ + glTexEnvfv(target, pname, params); +} + +void stub_glTexEnvi(GLenum target, GLenum pname, GLint param) +{ + glTexEnvi(target, pname, param); +} + +void stub_glTexGeni(GLenum coord, GLenum pname, GLint param) +{ + glTexGeni(coord, pname, param); +} + +void stub_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) +{ + glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); +} + +void stub_glTexParameteri(GLenum target, GLenum pname, GLint param) +{ + glTexParameteri(target, pname, param); +} + +void stub_glTexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + glTexParameterf(target, pname, param); +} + +void stub_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) +{ + glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); +} + +void stub_glTranslatef(GLfloat x, GLfloat y, GLfloat z) +{ + glTranslatef(x, y, z); +} + +void stub_glVertex2f(GLfloat x, GLfloat y) +{ + glVertex2f(x, y); +} + +void stub_glVertex3f(GLfloat x, GLfloat y, GLfloat z) +{ + glVertex3f(x, y, z); +} + +void stub_glVertex3fv(const GLfloat *v) +{ + glVertex3fv(v); +} + +void stub_glViewport(GLint x, GLint y, GLsizei width, GLsizei height) +{ + glViewport(x, y, width, height); +} + +GLenum stub_glGetError(void) +{ + return glGetError(); +} + +void stub_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) +{ + glDrawElements(mode, count, type, indices); +} + +void stub_glArrayElement(GLint i) +{ + glArrayElement(i); +} + +void stub_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ + glVertexPointer(size, type, stride, pointer); +} + +void stub_glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer) +{ + glNormalPointer(type, stride, pointer); +} + +void stub_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ + glTexCoordPointer(size, type, stride, pointer); +} + +void stub_glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) +{ + glColorPointer(size, type, stride, pointer); +} + +void stub_glDrawArrays(GLenum mode, GLint first, GLsizei count) +{ + glDrawArrays(mode, first, count); +} + +void stub_glEnableClientState(GLenum array) +{ + glEnableClientState(array); +} + +void stub_glDisableClientState(GLenum array) +{ + glDisableClientState(array); +} + +void stub_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass) +{ + glStencilOp(fail, zfail, zpass); +} + +void stub_glStencilFunc(GLenum func, GLint ref, GLuint mask) +{ + glStencilFunc(func, ref, mask); +} + +void stub_glPushAttrib(GLbitfield mask) +{ + glPushAttrib(mask); +} + +void stub_glPopAttrib(void) +{ + glPopAttrib(); +} + +void stub_glScissor(GLint x, GLint y, GLsizei width, GLsizei height) +{ + glScissor(x, y, width, height); +} + +void stub_glMultiTexCoord2fARB(GLenum unit, GLfloat s, GLfloat t) +{ + glMultiTexCoord2fARB(unit, s, t); +} + +void stub_glMultiTexCoord3fARB(GLenum unit, GLfloat s, GLfloat t, GLfloat r) +{ + glMultiTexCoord3fARB(unit, s, t, r); +} + +void stub_glActiveTextureARB(GLenum unit) +{ + glActiveTextureARB(unit); +} + +void stub_glClientActiveTextureARB(GLenum unit) +{ + glClientActiveTextureARB(unit); +} diff --git a/engine/sw/vid_morphos.c b/engine/sw/vid_morphos.c new file mode 100644 index 000000000..ceab9b4cf --- /dev/null +++ b/engine/sw/vid_morphos.c @@ -0,0 +1,249 @@ +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "quakedef.h" +#include "d_local.h" + +qbyte vid_curpal[768]; +static unsigned char pal[1024]; + +struct Window *window; +struct Screen *screen; + +static void *pointermem; + +static void *displaybuffer; + +void ResetFrameBuffers(void) +{ + int vid_surfcachesize; + void *vid_surfcache; + int buffersize; + + if (d_pzbuffer) + { + D_FlushCaches(); + free(d_pzbuffer); + d_pzbuffer = NULL; + } + buffersize = vid.width * vid.height * sizeof(*d_pzbuffer); + vid_surfcachesize = D_SurfaceCacheForRes (vid.width, vid.height, 0); + buffersize += vid_surfcachesize; + + d_pzbuffer = malloc(buffersize); + vid_surfcache = (qbyte *) d_pzbuffer + vid.width * vid.height * sizeof(*d_pzbuffer); + + D_InitCaches(vid_surfcache, vid_surfcachesize); +} + +qboolean SWVID_Init (rendererstate_t *info, unsigned char *palette) +{ + printf("SWVID_Init\n"); + + printf("Trying to open a %dx%dx%d screen\n", info->width, info->height, info->bpp); + + vid.conwidth = vid.width = info->width; + vid.conheight = vid.height = info->height; + vid.aspect = ((float)vid.height / (float)vid.width) * (320.0 / 240.0); + + vid.direct = 0; /* We never have direct access to the currently displayed buffer */ + + vid.numpages = 1; + + vid.colormap = host_colormap; + + r_pixbytes = info->bpp/8; + + redshift = 16; + greenshift = 8; + blueshift = 0; + + redbits = 8; + greenbits = 8; + bluebits = 8; + + + displaybuffer = AllocVec(info->width*info->height*info->bpp/8, MEMF_ANY); + if (displaybuffer) + { + memset(displaybuffer, -1, info->width*info->height*info->bpp/8); + vid.conbuffer = vid.buffer = displaybuffer; + vid.conrowbytes = vid.rowbytes = info->width*info->bpp/8; + + if (info->fullscreen) + { + screen = OpenScreenTags(0, + SA_Width, vid.width, + SA_Height, vid.height, + SA_Depth, info->bpp, + SA_Quiet, TRUE, + TAG_DONE); + } + + window = OpenWindowTags(0, + WA_InnerWidth, info->width, + WA_InnerHeight, info->height, + WA_Title, "FTEQuake", + WA_DragBar, screen?FALSE:TRUE, + WA_DepthGadget, screen?FALSE:TRUE, + WA_Borderless, screen?TRUE:FALSE, + WA_RMBTrap, TRUE, + screen?WA_PubScreen:TAG_IGNORE, (ULONG)screen, + WA_Activate, TRUE, + WA_ReportMouse, TRUE, + TAG_DONE); + + if (window) + { + pointermem = AllocVec(256, MEMF_ANY|MEMF_CLEAR); + if (pointermem) + { + SetPointer(window, pointermem, 16, 16, 0, 0); + + ResetFrameBuffers(); + + return true; + } + } + + if (screen) + { + CloseScreen(screen); + screen = 0; + } + + FreeVec(displaybuffer); + + displaybuffer = 0; + } + + return false; +} + +void SWVID_Shutdown (void) +{ + if (window) + { + CloseWindow(window); + window = 0; + } + + if (screen) + { + CloseScreen(screen); + screen = 0; + } + + if (pointermem) + { + FreeVec(pointermem); + pointermem = 0; + } + + if (displaybuffer) + { + FreeVec(displaybuffer); + displaybuffer = 0; + } + + printf("SWVID_Shutdown\n"); +} + +void SWVID_ShiftPalette(unsigned char *p) +{ + SWVID_SetPalette(p); +} + +void SWVID_SetPalette(unsigned char *palette) +{ + int i; + + ULONG spal[1+(256*3)+1]; + + if (screen) + { + spal[0] = 256<<16; + + for(i=0;i<256;i++) + { + spal[1+(i*3)] = ((unsigned int)palette[i*3])<<24; + spal[2+(i*3)] = ((unsigned int)palette[i*3+1])<<24; + spal[3+(i*3)] = ((unsigned int)palette[i*3+2])<<24; + } + + spal[1+(3*256)] = 0; + + LoadRGB32(&screen->ViewPort, spal); + } + + memcpy(vid_curpal, palette, sizeof(vid_curpal)); + + for(i=0;i<256;i++) + { + pal[i*4] = 0; + pal[i*4+1] = palette[i*3+0]; + pal[i*4+2] = palette[i*3+1]; + pal[i*4+3] = palette[i*3+2]; + } +} + +void SWVID_Update(vrect_t *rects) +{ +#if 1 + while(rects) + { + if (r_pixbytes == 1) + { + if (screen) + WritePixelArray(displaybuffer, rects->x, rects->y, vid.rowbytes, window->RPort, rects->x, rects->y, rects->width, rects->height, RECTFMT_LUT8); + else + WriteLUTPixelArray(displaybuffer, rects->x, rects->y, vid.rowbytes, window->RPort, pal, window->BorderLeft+rects->x, window->BorderTop+rects->y, rects->width, rects->height, CTABFMT_XRGB8); + } + else +#endif + WritePixelArray(displaybuffer, 0, 0, vid.rowbytes*4, window->RPort, window->BorderLeft, window->BorderTop, vid.width, vid.height, RECTFMT_ARGB); + + rects = rects->pnext; + } +} + +void SWVID_HandlePause (qboolean pause) +{ +} + +void SWVID_LockBuffer (void) +{ +} + +void SWVID_UnlockBuffer (void) +{ +} + +void SWVID_ForceLockState (int lk) +{ +} + +int SWVID_ForceUnlockedAndReturnState (void) +{ + return 0; +} + +void SWD_BeginDirectRect (int x, int y, qbyte *pbitmap, int width, int height) +{ +} + +void SWD_EndDirectRect (int x, int y, int width, int height) +{ +} + +void Sys_SendKeyEvents(void) +{ +} +