/* * 240p Test Suite for the Sega 32X * Port by Dasutin (Dustin Dembrosky) * Copyright (C)2011-2026 Artemio Urbina * * This file is part of the 240p Test Suite * * The 240p Test Suite 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. * * The 240p Test Suite 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 240p Test Suite; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _HW_32X_H_ #define _HW_32X_H_ #define MD_PAL_0 0x0100 #define MD_PAL_1 0x0200 #define MD_PAL_2 0x0300 #define MD_PAL_3 0x0400 #define MD_COLOR_PAL_GRAY 0x0100 #define MD_COLOR_PAL_RED 0x0200 #define MD_COLOR_PAL_GREEN 0x0300 #define MD_COLOR_PAL_BLUE 0x0400 #define PSG_ENVELOPE_MIN 15 #define PSG_ENVELOPE_MAX 0 #define PSG_NOISE_TYPE_PERIODIC 0 #define PSG_NOISE_TYPE_WHITE 1 #define PSG_NOISE_FREQ_CLOCK2 0 #define PSG_NOISE_FREQ_CLOCK4 1 #define PSG_NOISE_FREQ_CLOCK8 2 #define PSG_NOISE_FREQ_TONE3 3 #define HW32X_ATTR_DATA_ALIGNED __attribute__((section(".data"), aligned(16))) #define MARS_SEC_CMD_SDRAM_PARK 9 #define MARS_SEC_CMD_SDRAM_RESUME 10 #define MARS_SEC_CMD_PWM_TEST_START 11 #define MARS_SEC_CMD_PWM_TEST_STOP 12 #define MARS_SEC_CMD_PWM_TEST_SILENCE 13 #define MARS_SEC_SDRAM_PARKED 0x5350 #define MD_CONTROLLER_COUNT 8 #define MD_CONTROLLER_TYPE_PAD3 0x0000 #define MD_CONTROLLER_TYPE_PAD6 0x0001 #define MD_CONTROLLER_TYPE_UNKNOWN 0x000F #define MD_CONTROLLER_PORT_UNKNOWN 0x000F #define MD_CONTROLLER_PORT_EA4WAYPLAY 0x0010 #define MD_CONTROLLER_SUPPORT_OFF 0x0000 #define MD_CONTROLLER_SUPPORT_6BTN 0x0002 #define MD_CONTROLLER_SUPPORT_TEAMPLAYER 0x0005 #define MD_CONTROLLER_SUPPORT_EA4WAYPLAY 0x0006 extern int Hw32xDetectPAL(); extern void Hw32xSetFGColor(int s, int r, int g, int b); extern void Hw32xSetBGColor(int s, int r, int g, int b); extern void Hw32xSetFGOverlayPriorityBit(int priority); extern void Hw32xSetBGOverlayPriorityBit(int priority); extern void Hw32xSetPalettePriorityAliases(int destination, int source, int count, int priority); extern void Hw32xSetPaletteColor(int index, int r, int g, int b); extern void Hw32xSetPalette(const uint8_t *palette) HW32X_ATTR_DATA_ALIGNED; extern void Hw32xEnableTextPalette(void) HW32X_ATTR_DATA_ALIGNED; extern int Hw32xPauseTextPalette(void); extern void Hw32xResumeTextPalette(int wasEnabled); extern void Hw32xInit(int vmode, int lineskip); extern int Hw32xScreenGetX(); extern int Hw32xScreenGetY(); extern void Hw32xScreenSetXY(int x, int y); extern void Hw32xScreenClear(); extern void Hw32xScreenPutChar(int x, int y, unsigned char ch); extern void Hw32xScreenClearLine(int Y); extern int Hw32xScreenPrintData(const char *buff, int size); extern int Hw32xScreenPuts(const char *str); extern void Hw32xScreenPrintf(const char *format, ...); extern void Hw32xDelay(int ticks); extern void Hw32xScreenFlip(int wait); extern void Hw32xFlipWait(); extern unsigned long Hw32xGetTime(void); extern void Hw32xSleep(int s); extern unsigned short HwMdReadPad(int port); extern void HwMdControllerEnable(void); extern void HwMdControllerDisable(void); extern void HwMdControllerReset(void); extern void HwMdControllerReadSnapshot(unsigned short *states, unsigned short *types, unsigned short *portTypes, unsigned short *portSupports); extern void HwMdControllerReadPortInfo(unsigned short *portTypes, unsigned short *portSupports); extern unsigned short HwMdControllerReadState(int controller); extern unsigned short HwMdControllerReadType(int controller); extern unsigned short HwMdControllerReadPortType(int port); extern unsigned short HwMdControllerReadPortSupport(int port); extern unsigned char HwMdReadSram(unsigned short offset); extern void HwMdWriteSram(unsigned char byte, unsigned short offset); extern int HwMdReadMouse(int port); extern void HwMdClearScreen(void); extern void HwMdSetOffset(unsigned short offset); extern void HwMdSetNTable(unsigned short word); extern void HwMdSetVram(unsigned short word); extern void HwMdPuts(const char *str, int color, int x, int y); extern void HwMdPutc(char chr, int color, int x, int y); extern void HwMdScreenPrintf(int color, int x, int y, const char *format, ...); extern void HwMdSetPal(unsigned short pal); extern void HwMdSetColor(unsigned short color); extern void HwMdSetColorPal(unsigned short pal, unsigned short color); extern void HwMdPSGSetChannel(unsigned short word); extern void HwMdPSGSetVolume(unsigned short word); extern void HwMdPSGSetChandVol(unsigned short channel, unsigned short vol); extern void HwMdPSGSendTone(unsigned short value, unsigned short value2); extern void HwMdPSGSendNoise(unsigned short word); extern void HwMdPSGSendEnvelope(unsigned short word); extern void HwMdPSGSetFrequency(u8 channel, u16 value); extern void HwMdPSGSetTone(u8 channel, u16 value); extern void HwMdPSGSetNoise(u8 type, u8 frequency); extern void HwMdPSGSetEnvelope(u8 channel, u8 value); extern void HwMdSetPlaneBitmap(char plane, void *data); extern void HwMdClearPlanes(void); extern void HwMdReloadFont(void); extern void HwMdHScrollPlane(char plane, int hscroll); extern void HwMdVScrollPlane(char plane, int vscroll); extern void HwMdSetPlaneScrolls(int hscroll_a, int vscroll_a, int hscroll_b, int vscroll_b); extern void HwMdSetVideoHeight(unsigned short height); void Hw32xUpdateLineTable(int hscroll, int vscroll, int lineskip) HW32X_ATTR_DATA_ALIGNED; static inline void Mars_R_SecWait(void) { while (MARS_SYS_COMM4 != 0); } static inline void Mars_InitSoundDMA(void) { Mars_R_SecWait(); MARS_SYS_COMM4 = 6; Mars_R_SecWait(); } static inline void Mars_StopSoundMixer(void) { Mars_R_SecWait(); MARS_SYS_COMM4 = 7; Mars_R_SecWait(); } static inline void Mars_StartSoundMixer(void) { Mars_R_SecWait(); MARS_SYS_COMM4 = 8; Mars_R_SecWait(); } extern void Hw32xSecWait(void); extern int Hw32xInitSoundDMA(void); extern void Hw32xSecondaryBIOS(void); extern unsigned long Hw32xTestSdramAddressLines(void); extern unsigned long Hw32xTestSdramPattern(unsigned short pattern); extern void Hw32xSecondaryPark(void); static inline void Mars_ParkSecondaryForSdramTest(void) { Mars_R_SecWait(); MARS_SYS_COMM4 = MARS_SEC_CMD_SDRAM_PARK; while (MARS_SYS_COMM4 != MARS_SEC_SDRAM_PARKED); } static inline void Mars_ResumeSecondaryAfterSdramTest(void) { MARS_SYS_COMM4 = MARS_SEC_CMD_SDRAM_RESUME; Mars_R_SecWait(); } void pri_vbi_handler(void) HW32X_ATTR_DATA_ALIGNED; void pri_dma1_handler(void) HW32X_ATTR_DATA_ALIGNED; unsigned Hw32xGetTicks(void) HW32X_ATTR_DATA_ALIGNED; int secondary_task(int cmd) HW32X_ATTR_DATA_ALIGNED; void secondary(void) HW32X_ATTR_DATA_ALIGNED; #endif /* _HW_32X_H_ */