[Lapetus-cvs] lapetus/tests/regtest smpc.c, NONE, 1.1 smpc.h, NONE, 1.1
Status: Inactive
Brought to you by:
cyberwarriorx
From: Theo B. <cyb...@us...> - 2008-02-17 00:36:31
|
Update of /cvsroot/lapetus/lapetus/tests/regtest In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26667 Added Files: smpc.c smpc.h Log Message: -Initial add --- NEW FILE: smpc.c --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus 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. Lapetus 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 Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <lapetus.h> #include <stdio.h> #include "intfac.h" #include "tests.h" #include "smpc.h" ////////////////////////////////////////////////////////////////////////////// void smpctest() { int choice; MENUITEMSTRUCT smpcmenu[] = { { "SMPC commands" , &smpcmdtest, }, { "SMPC command timing", &smpccmdtimingtest, }, // { "Keyboard test" , &kbdtest, }, // { "Mouse target test" , &mousetest, }, // { "Stunner target test" , &stunnertest, }, { "Peripheral test" , &pertest, }, // { "Misc" , &miscsmpctest, }, { "Go back to main menu", NULL }, { "\0", NULL } }; for (;;) { choice = DoMenu(smpcmenu, 8, 14, "SMPC Tests"); ClearScr(); if (choice == ((sizeof(smpcmenu) / sizeof(MENUITEMSTRUCT)) - 2)) break; } } ////////////////////////////////////////////////////////////////////////////// void smpcmdtest() { } ////////////////////////////////////////////////////////////////////////////// void smpccmdtimingtest() { } ////////////////////////////////////////////////////////////////////////////// void padtest() { } ////////////////////////////////////////////////////////////////////////////// void kbdtest() { } ////////////////////////////////////////////////////////////////////////////// void mousetest() { } ////////////////////////////////////////////////////////////////////////////// void analogtest() { } ////////////////////////////////////////////////////////////////////////////// void stunnertest() { } ////////////////////////////////////////////////////////////////////////////// typedef struct { u8 id; char *name; // u8 (*func)(int xoffset, int yoffset); } perinfo_struct; perinfo_struct perinfo[] = { { 0x02, "Standard Pad", }, { 0x13, "Racing Wheel", }, { 0x15, "Analog Pad", }, { 0x23, "Saturn Mouse", }, { 0x25, "Gun", }, { 0x34, "Keyboard", }, { 0xE1, "Megadrive 3 button", }, { 0xE2, "Megadrive 6 button", }, { 0xE3, "Shuttle Mouse", }, { 0xFF, "Nothing", } }; u8 perparse(char *portname, int yoffset, u8 oregcounter) { int i; u8 perid = SMPC_REG_OREG(oregcounter); oregcounter++; for (i = 0; i < (sizeof(perinfo) / sizeof(perinfo_struct)); i++) { if (perid == perinfo[i].id) { VdpPrintf(&testdispfont, 0 * 8, yoffset, 0xF, "Port %s: %s ", portname, perinfo[i].name); // parse button presses here if (perid == 0xFF) return oregcounter; return (oregcounter+(perid & 0xF)); } } VdpPrintf(&testdispfont, 0 * 8, yoffset, 0xF, "Port %s: Unknown", portname); return oregcounter; } ////////////////////////////////////////////////////////////////////////////// void pertest() { InterruptSetLevelMask(0xF); InitLapetus(RES_320x224); VdpRBG0Init(&testdispsettings); VdpSetDefaultPalette(); // Display On VdpDispOn(); // Disable Lapetus's peripheral handler BIOS_ChangeSCUInterruptMask(0xFFFFFFF, MASK_VBLANKOUT | MASK_SYSTEMMANAGER); testdispfont.transparent = 0; VdpPrintf(&testdispfont, 0 * 8, 1 * 8, 0xF, "Multitap test"); VdpPrintf(&testdispfont, 0 * 8, 2 * 8, 0xF, "(to exit, press A+B+C on first pad)"); for (;;) { unsigned char oregcounter=0; unsigned char portcon; int i, i2; VdpVsync(); // Issue intback command SmpcWaitTillReady(); SMPC_REG_IREG(0) = 0x00; // no intback status SMPC_REG_IREG(1) = 0x0A; // 15-byte mode, peripheral data returned, time optimized SMPC_REG_IREG(2) = 0xF0; // ??? SmpcIssueCommand(SMPC_CMD_INTBACK); // Wait till command is finished while(SMPC_REG_SF & 0x1) {} // Grab oreg's for (i = 0; i < 2; i++) { portcon = SMPC_REG_OREG(oregcounter); oregcounter++; if (portcon != 0x16) { VdpPrintf(&testdispfont, 0 * 8, (4+(8*i)) * 8, 0xF, "Port %d: Multi-tap not connected", i+1); for (i2 = 0; i2 < 6; i2++) VdpPrintf(&testdispfont, 0 * 8, (4+(8*i)+1+i2) * 8, 0xF, " "); } else { VdpPrintf(&testdispfont, 0 * 8, (4+(8*i)) * 8, 0xF, "Port %d: Multi-tap connected ", i+1); for (i2 = 0; i2 < (portcon & 0x0F); i2++) { char text[3]; sprintf(text, "%d%c", i+1, 'A' + (char)i2); oregcounter = perparse(text, (4+(8*i)+1+i2) * 8, oregcounter); } } } } testdispfont.transparent = 1; } ////////////////////////////////////////////////////////////////////////////// void miscsmpctest() { } ////////////////////////////////////////////////////////////////////////////// --- NEW FILE: smpc.h --- /* Copyright 2008 Theo Berkau This file is part of Lapetus. Lapetus 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. Lapetus 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 Lapetus; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef SMPCH #define SMPCH void smpctest(); void smpcmdtest(); void smpccmdtimingtest(); void padtest(); void kbdtest(); void mousetest(); void analogtest(); void stunnertest(); void pertest(); void miscsmpctest(); #endif |