├── .gitignore ├── README.rst ├── doc └── instructions.txt ├── examples ├── TicTacToe │ ├── C++ │ │ ├── 32X │ │ │ ├── 32x.h │ │ │ ├── Makefile │ │ │ ├── crtstuff.c │ │ │ ├── font.c │ │ │ ├── hw_32x.c │ │ │ ├── hw_32x.h │ │ │ ├── m68k_crt0.s │ │ │ ├── m68k_crt1.s │ │ │ ├── main.cpp │ │ │ └── sh2_crt0.s │ │ └── MD │ │ │ ├── Makefile │ │ │ ├── crt0.s │ │ │ ├── crtstuff.c │ │ │ ├── font.c │ │ │ ├── hw_md.h │ │ │ ├── hw_md.s │ │ │ └── main.cpp │ └── C │ │ ├── 32X │ │ ├── 32x.h │ │ ├── Makefile │ │ ├── font.c │ │ ├── hw_32x.c │ │ ├── hw_32x.h │ │ ├── m68k_crt0.s │ │ ├── m68k_crt1.s │ │ ├── main.c │ │ └── sh2_crt0.s │ │ └── MD │ │ ├── Makefile │ │ ├── crt0.s │ │ ├── font.c │ │ ├── hw_md.h │ │ ├── hw_md.s │ │ └── main.c └── Yeti3D-GPL │ ├── GNU.TXT │ ├── editor │ ├── ToolBox.cpp │ ├── ToolBox.h │ ├── UnitMain.cpp │ ├── UnitMain.dfm │ ├── UnitMain.h │ ├── UnitPreview.cpp │ ├── UnitPreview.dfm │ ├── UnitPreview.h │ ├── YetiEditor.bpr │ ├── YetiEditor.cpp │ ├── default.y3d │ ├── readme.txt │ ├── test0.y3d │ ├── test1.y3d │ ├── test2.y3d │ └── test3.y3d │ ├── platform │ ├── 32X │ │ ├── 32x.h │ │ ├── Makefile │ │ ├── files-psyg.s │ │ ├── files.h │ │ ├── font.c │ │ ├── hw_32x.c │ │ ├── hw_32x.h │ │ ├── m68k_crt0.s │ │ ├── m68k_crt1.s │ │ ├── main.c │ │ ├── module.c │ │ ├── module.h │ │ ├── music │ │ │ ├── SOTBeast2_2.MOD │ │ │ ├── SOTBeast2_4.MOD │ │ │ └── SOTBeast2_5.MOD │ │ ├── sh2_crt0.s │ │ ├── sound.h │ │ ├── sound.s │ │ └── sounds │ │ │ ├── en-atk.raw │ │ │ ├── en-dth.raw │ │ │ ├── en-near.raw │ │ │ ├── en-pain.raw │ │ │ ├── pl-dth.raw │ │ │ ├── pl-oof.raw │ │ │ ├── pl-pain.raw │ │ │ └── pl-sht.raw │ ├── ddraw │ │ ├── main.cpp │ │ ├── yeti3d.lk1 │ │ ├── yeti3d.mk │ │ ├── yeti3d.mk1 │ │ ├── yeti3d.tgt │ │ └── yeti3d.wpj │ ├── gba │ │ ├── gba.h │ │ ├── main.c │ │ └── make.bat │ ├── opengl │ │ ├── main.c │ │ ├── yeti3d.lk1 │ │ ├── yeti3d.mk │ │ ├── yeti3d.mk1 │ │ ├── yeti3d.tgt │ │ └── yeti3d.wpj │ └── win32 │ │ ├── yeti3dwin32.c │ │ └── yeti3dwin32.h │ ├── readme.txt │ └── src │ ├── data.c │ ├── data.h │ ├── draw.c │ ├── extra.c │ ├── extra.h │ ├── font.c │ ├── font.h │ ├── game.c │ ├── game.h │ ├── maps.c │ ├── maps │ └── e1m1.c │ ├── model.c │ ├── model.h │ ├── sprites.c │ ├── sprites.h │ ├── viewports.h │ ├── yeti.c │ └── yeti.h ├── ldscripts ├── makefile-gen ├── mars-myth-sdram.ld ├── mars.ld ├── md-myth-psram.ld ├── md-myth-wram.ld ├── md-split-ram.ld └── md.ld ├── sourceme.sh └── toolchain.sh /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | download 3 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ======================= 2 | Megadrive GCC Toolchain 3 | ======================= 4 | 5 | About 6 | ===== 7 | Build scripts for a GCC 8.2.0 toolchain for Sega Megadrive / Genesis and 32X. 8 | 9 | Usage 10 | ===== 11 | * Install depdendencies including gcc and texinfo (makeinfo). ( debian/ubuntu: apt-get install build-essential texinfo ) 12 | * Run toolchain.sh which will download and build gcc for sega megadrive / genesis and x32. It'll probably take a good 30 minutes to finish. 13 | * After that you can use source /opt/toolchains/sega/sourceme.sh to set up the environment and start compiling the examples. 14 | 15 | Authors 16 | ======= 17 | This is all based on a forum post by Chilly Willy on SpritesMind.Net, check it out at 18 | 19 | http://gendev.spritesmind.net/forum/viewtopic.php?p=12798 20 | 21 | There is also a pre-built windows version of the toolchain in that thread. 22 | 23 | githubized by noname@nurd.se 24 | 25 | Updated mars.ld from https://github.com/mic-/lusid-dreams . 26 | 27 | Updated md.ld from //github.com/kubilus1/gendev . 28 | 29 | See also 30 | ======== 31 | This is just a plain toolchain with a few helper libs provided by Chilly Willy. If you want a more complete SDK take a look at SGDK. 32 | 33 | Windows: https://github.com/Stephane-D/SGDK 34 | 35 | Linux port: https://github.com/kubilus1/gendev 36 | -------------------------------------------------------------------------------- /doc/instructions.txt: -------------------------------------------------------------------------------- 1 | YOU DON'T HAVE TO FOLLOW THIS GUIDE 2 | THE TOOLCHAIN SCRIPT DOES ALLL THIS FOR YOU 3 | 4 | This is a mirror of the original forum post at gendev.spritmind.net. 5 | from: http://gendev.spritesmind.net/forum/viewtopic.php?p=12798 6 | -------------------------------------------------------------------- 7 | 8 | Building a new Genesis/32X toolchain 9 | 10 | 1 - Go here and download the following: 11 | 12 | gcc-core-4.5.2.tar.bz2 13 | gcc-g++-4.5.2.tar.bz2 14 | gcc-objc-4.5.2.tar.bz2 15 | 16 | Decompress them all in the same folder; you should end up with one folder called gcc-4.5.2. 17 | 18 | 2.1 - Go here and download mpfr-2.4.2.tar.bz2. 19 | 2.2 - Go here and download mpc-0.8.2.tar.gz. 20 | 2.3 - Go here and download gmp-5.0.1.tar.bz2. 21 | 22 | Decompress them all in the same folder. You should have three folders called mpfr-2.4.2, mpc-0.8.2, and gmp-5.0.1. Rename them to get rid of the version numbers, leaving you with mpfr, mpc, and gmp. Copy them into the gcc-4.5.2 folder. 23 | 24 | 3 - Go here and download binutils-2.21.tar.bz2. 25 | 26 | Decompress it in the same folder as the gcc folder so that you have two folders - gcc-4.5.2 and binutils-2.21. 27 | 28 | 4 - Go here and download newlib-1.19.0.tar.gz. 29 | 30 | Decompress it in the same folder as gcc and binutils, leaving you with three folders - gcc-4.5.2, binutils-2.21, and newlib-1.19.0. 31 | 32 | 5 - Download this archive containing a makefile and several linker scripts. 33 | 34 | Decompress it to the same folder as the others above. 35 | 36 | 6 - If you wish to leave the makefile with the default path of /opt/toolchains/gen, make sure you have permission to write to /opt or the toolchain will fail to install to the path. Since there's nothing critical in /opt, it's easiest just to do "sudo chmod 777 -R /opt" which allows anyone to do anything they want in /opt. 37 | 38 | 7 - Run "make -f makefile-gen" - depending on the speed of your computer, you should now have two toolchains in /opt/toolchains/gen: m68k-elf and sh-elf. Make another folder in /opt/toolchains/gen called ldscripts and copy the linker scripts from the archive into that folder. 39 | 40 | You now have the latest gcc, binutils, and newlib for both the 68000 and the SH2. The compilers include C, C++, Objective-C, and Objective-C++ for both the 68000 and the SH2. 41 | 42 | 8 - Make a bin folder in /opt/toolchains/gen. Copy whatever misc tools you use into it, like sixpack or bin2c. 43 | 44 | 9 - You'll need the proper exports to use the toolchains, and assuming you left the path to /opt, they would be: 45 | 46 | For the 68000: 47 | export GENDEV=/opt/toolchains/gen 48 | export PATH=$GENDEV/m68k-elf/bin:$GENDEV/bin:$PATH 49 | 50 | For the 32X: 51 | export GENDEV=/opt/toolchains/gen 52 | export PATH=$GENDEV/sh-elf/bin:$GENDEV/m68k-elf/bin:$GENDEV/bin:$PATH 53 | 54 | Here is an archive with example code - it includes Tic-Tac-Toe in both C and C++ for both the MD and the 32X, as well as my 32X version of Yeti3D with Module playing and sound effects. Also included are the latest linker scripts to be copied to /opt/toolchains/gen/ldscripts/. 55 | 56 | MD_32X_Examples.7z 57 | 58 | Last edited by Chilly Willy on Thu Mar 24, 2011 11:28 pm; edited 4 times in total 59 | -------------------------------------------------------------------------------- /examples/TicTacToe/C++/32X/32x.h: -------------------------------------------------------------------------------- 1 | #ifndef __32X_H__ 2 | #define __32X_H__ 3 | 4 | /* Create a 5:5:5 RGB color */ 5 | #define COLOR(r,g,b) (((r)&0x1F)|((g)&0x1F)<<5|((b)&0x1F)<<10) 6 | 7 | #define MARS_CRAM (*(volatile unsigned short *)0x20004200) 8 | #define MARS_FRAMEBUFFER (*(volatile unsigned short *)0x24000000) 9 | #define MARS_OVERWRITE_IMG (*(volatile unsigned short *)0x24020000) 10 | #define MARS_SDRAM (*(volatile unsigned short *)0x26000000) 11 | 12 | #define MARS_SYS_INTMSK (*(volatile unsigned short *)0x20004000) 13 | #define MARS_SYS_DMACTR (*(volatile unsigned short *)0x20004006) 14 | #define MARS_SYS_DMASAR (*(volatile unsigned long *)0x20004008) 15 | #define MARS_SYS_DMADAR (*(volatile unsigned long *)0x2000400C) 16 | #define MARS_SYS_DMALEN (*(volatile unsigned short *)0x20004010) 17 | #define MARS_SYS_DMAFIFO (*(volatile unsigned short *)0x20004012) 18 | #define MARS_SYS_VRESI_CLR (*(volatile unsigned short *)0x20004014) 19 | #define MARS_SYS_VINT_CLR (*(volatile unsigned short *)0x20004016) 20 | #define MARS_SYS_HINT_CLR (*(volatile unsigned short *)0x20004018) 21 | #define MARS_SYS_CMDI_CLR (*(volatile unsigned short *)0x2000401A) 22 | #define MARS_SYS_PWMI_CLR (*(volatile unsigned short *)0x2000401C) 23 | #define MARS_SYS_COMM0 (*(volatile unsigned short *)0x20004020) /* Master SH2 communication */ 24 | #define MARS_SYS_COMM2 (*(volatile unsigned short *)0x20004022) 25 | #define MARS_SYS_COMM4 (*(volatile unsigned short *)0x20004024) /* Slave SH2 communication */ 26 | #define MARS_SYS_COMM6 (*(volatile unsigned short *)0x20004026) 27 | #define MARS_SYS_COMM8 (*(volatile unsigned short *)0x20004028) /* controller 1 current value */ 28 | #define MARS_SYS_COMM10 (*(volatile unsigned short *)0x2000402A) /* controller 2 current value */ 29 | #define MARS_SYS_COMM12 (*(volatile unsigned long *)0x2000402C) /* vcount current value */ 30 | 31 | #define MARS_PWM_CTRL (*(volatile unsigned short *)0x20004030) 32 | #define MARS_PWM_CYCLE (*(volatile unsigned short *)0x20004032) 33 | #define MARS_PWM_LEFT (*(volatile unsigned short *)0x20004034) 34 | #define MARS_PWM_RIGHT (*(volatile unsigned short *)0x20004036) 35 | #define MARS_PWM_MONO (*(volatile unsigned short *)0x20004038) 36 | 37 | #define MARS_VDP_DISPMODE (*(volatile unsigned short *)0x20004100) 38 | #define MARS_VDP_FILLEN (*(volatile unsigned short *)0x20004104) 39 | #define MARS_VDP_FILADR (*(volatile unsigned short *)0x20004106) 40 | #define MARS_VDP_FILDAT (*(volatile unsigned short *)0x20004108) 41 | #define MARS_VDP_FBCTL (*(volatile unsigned short *)0x2000410A) 42 | 43 | #define MARS_SH2_ACCESS_VDP 0x8000 44 | #define MARS_68K_ACCESS_VDP 0x0000 45 | 46 | #define MARS_PAL_FORMAT 0x0000 47 | #define MARS_NTSC_FORMAT 0x8000 48 | 49 | #define MARS_VDP_PRIO_68K 0x0000 50 | #define MARS_VDP_PRIO_32X 0x0080 51 | 52 | #define MARS_224_LINES 0x0000 53 | #define MARS_240_LINES 0x0040 54 | 55 | #define MARS_VDP_MODE_OFF 0x0000 56 | #define MARS_VDP_MODE_256 0x0001 57 | #define MARS_VDP_MODE_32K 0x0002 58 | #define MARS_VDP_MODE_RLE 0x0003 59 | 60 | #define MARS_VDP_VBLK 0x8000 61 | #define MARS_VDP_HBLK 0x4000 62 | #define MARS_VDP_PEN 0x2000 63 | #define MARS_VDP_FEN 0x0002 64 | #define MARS_VDP_FS 0x0001 65 | 66 | #define SH2_CCTL_CP 0x10 67 | #define SH2_CCTL_TW 0x08 68 | #define SH2_CCTL_CE 0x01 69 | 70 | #define SH2_FRT_TIER (*(volatile unsigned char *)0xFFFFFE10) 71 | #define SH2_FRT_FTCSR (*(volatile unsigned char *)0xFFFFFE11) 72 | #define SH2_FRT_FRCH (*(volatile unsigned char *)0xFFFFFE12) 73 | #define SH2_FRT_FRCL (*(volatile unsigned char *)0xFFFFFE13) 74 | #define SH2_FRT_OCRH (*(volatile unsigned char *)0xFFFFFE14) 75 | #define SH2_FRT_OCRL (*(volatile unsigned char *)0xFFFFFE15) 76 | #define SH2_FRT_TCR (*(volatile unsigned char *)0xFFFFFE16) 77 | #define SH2_FRT_TOCR (*(volatile unsigned char *)0xFFFFFE17) 78 | #define SH2_FRT_ICRH (*(volatile unsigned char *)0xFFFFFE18) 79 | #define SH2_FRT_ICRL (*(volatile unsigned char *)0xFFFFFE19) 80 | 81 | #define SH2_DMA_SAR0 (*(volatile unsigned long *)0xFFFFFF80) 82 | #define SH2_DMA_DAR0 (*(volatile unsigned long *)0xFFFFFF84) 83 | #define SH2_DMA_TCR0 (*(volatile unsigned long *)0xFFFFFF88) 84 | #define SH2_DMA_CHCR0 (*(volatile unsigned long *)0xFFFFFF8C) 85 | #define SH2_DMA_VCR0 (*(volatile unsigned long *)0xFFFFFFA0) 86 | #define SH2_DMA_DRCR0 (*(volatile unsigned char *)0xFFFFFE71) 87 | 88 | #define SH2_DMA_SAR1 (*(volatile unsigned long *)0xFFFFFF90) 89 | #define SH2_DMA_DAR1 (*(volatile unsigned long *)0xFFFFFF94) 90 | #define SH2_DMA_TCR1 (*(volatile unsigned long *)0xFFFFFF98) 91 | #define SH2_DMA_CHCR1 (*(volatile unsigned long *)0xFFFFFF9C) 92 | #define SH2_DMA_VCR1 (*(volatile unsigned long *)0xFFFFFFA8) 93 | #define SH2_DMA_DRCR1 (*(volatile unsigned char *)0xFFFFFE72) 94 | 95 | #define SH2_DMA_DMAOR (*(volatile unsigned long *)0xFFFFFFB0) 96 | 97 | #define SH2_INT_IPRA (*(volatile unsigned short *)0xFFFFFEE2) 98 | 99 | #define SEGA_CTRL_UP 0x0001 100 | #define SEGA_CTRL_DOWN 0x0002 101 | #define SEGA_CTRL_LEFT 0x0004 102 | #define SEGA_CTRL_RIGHT 0x0008 103 | #define SEGA_CTRL_B 0x0010 104 | #define SEGA_CTRL_C 0x0020 105 | #define SEGA_CTRL_A 0x0040 106 | #define SEGA_CTRL_START 0x0080 107 | #define SEGA_CTRL_Z 0x0100 108 | #define SEGA_CTRL_Y 0x0200 109 | #define SEGA_CTRL_X 0x0400 110 | #define SEGA_CTRL_MODE 0x0800 111 | 112 | #define SEGA_CTRL_TYPE 0xF000 113 | #define SEGA_CTRL_THREE 0x0000 114 | #define SEGA_CTRL_SIX 0x1000 115 | #define SEGA_CTRL_NONE 0xF000 116 | 117 | #ifdef __cplusplus 118 | extern "C" { 119 | #endif 120 | 121 | /* global functions in sh2_crt0.s */ 122 | extern void fast_memcpy(void *dst, void *src, int len); 123 | extern void CacheControl(int mode); 124 | extern void CacheClearLine(void* ptr); 125 | extern void ScreenStretch(int src, int width, int height, int interp); 126 | 127 | #ifdef __cplusplus 128 | } 129 | #endif 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /examples/TicTacToe/C++/32X/Makefile: -------------------------------------------------------------------------------- 1 | MDLD = m68k-elf-ld 2 | MDAS = m68k-elf-as 3 | SHLD = sh-elf-ld 4 | SHCPP = sh-elf-g++ 5 | SHCC = sh-elf-gcc 6 | SHAS = sh-elf-as 7 | SHOBJC = sh-elf-objcopy 8 | RM = rm -f 9 | 10 | CPPFLAGS = -m2 -mb -O3 -Wall -c -fno-exceptions -nostartfiles -ffreestanding -fno-rtti 11 | CCFLAGS = -m2 -mb -O3 -Wall -c -fomit-frame-pointer 12 | HWCCFLAGS = -m2 -mb -O1 -Wall -c -fomit-frame-pointer 13 | LINKFLAGS = -T $(GENDEV)/ldscripts/mars.ld -Wl,-Map=output.map -nostdlib -ffreestanding -fno-rtti 14 | 15 | INCS = -I. -I$(GENDEV)/sh-elf/include -I$(GENDEV)/sh-elf/sh-elf/include 16 | 17 | LIBS = -L$(GENDEV)/sh-elf/sh-elf/lib -L$(GENDEV)/sh-elf/lib/gcc/sh-elf/$(GENDEV_GCC_VERSION) -lstdc++ -lc -lgcc -lgcc-Os-4-200 -lnosys 18 | 19 | OBJS = sh2_crt0.o crtstuff.o main.o hw_32x.o font.o 20 | 21 | all: m68k_crt0.bin m68k_crt1.bin TicTacToe32X.bin 22 | 23 | TicTacToe32X.bin: TicTacToe.elf 24 | $(SHOBJC) -O binary $< temp.bin 25 | dd if=temp.bin of=$@ bs=512K conv=sync 26 | 27 | TicTacToe.elf: $(OBJS) 28 | $(SHCPP) $(LINKFLAGS) $(OBJS) $(LIBS) -o TicTacToe.elf 29 | 30 | m68k_crt0.bin: m68k_crt0.s 31 | $(MDAS) -m68000 --register-prefix-optional -o m68k_crt0.o m68k_crt0.s 32 | $(MDLD) -T $(GENDEV)/ldscripts/md.ld --oformat binary -o m68k_crt0.bin m68k_crt0.o 33 | 34 | m68k_crt1.bin: m68k_crt1.s 35 | $(MDAS) -m68000 --register-prefix-optional -o m68k_crt1.o m68k_crt1.s 36 | $(MDLD) -T $(GENDEV)/ldscripts/md.ld --oformat binary -o m68k_crt1.bin m68k_crt1.o 37 | 38 | hw_32x.o: hw_32x.c 39 | $(SHCC) $(HWCCFLAGS) $< -o $@ 40 | 41 | %.o: %.cpp 42 | $(SHCPP) $(CPPFLAGS) $< -o $@ 43 | 44 | %.o: %.c 45 | $(SHCC) $(CCFLAGS) $< -o $@ 46 | 47 | %.o: %.s 48 | $(SHAS) --small -o $@ $< 49 | 50 | clean: 51 | $(RM) *.o *.bin *.elf *.map 52 | -------------------------------------------------------------------------------- /examples/TicTacToe/C++/32X/crtstuff.c: -------------------------------------------------------------------------------- 1 | /* C++ CTOR / DTOR handling */ 2 | 3 | #include 4 | 5 | 6 | /* Used by exit procs */ 7 | void *__dso_handle = 0; 8 | extern void __call_exitprocs (int code, void *ptr); 9 | 10 | typedef void (*func_ptr) (void); 11 | 12 | extern func_ptr __CTOR_LIST__[]; 13 | extern func_ptr __DTOR_LIST__[]; 14 | 15 | /* Do all constructors. */ 16 | static void __attribute__((used)) __do_global_ctors (void) 17 | { 18 | do 19 | { 20 | unsigned int i, n = (unsigned int) __CTOR_LIST__[0]; 21 | for (i = n; i >= 1; i--) 22 | __CTOR_LIST__[i] (); 23 | } while (0); 24 | } 25 | 26 | /* Do all destructors. */ 27 | static void __attribute__((used)) __do_global_dtors (void) 28 | { 29 | do 30 | { 31 | unsigned int i, n = (unsigned int) __DTOR_LIST__[0]; 32 | for (i = 0; i < n; i++) 33 | __DTOR_LIST__[i + 1] (); 34 | } while (0); 35 | } 36 | 37 | /* Add function to .init section. */ 38 | static void __attribute__((used, section (".init"))) __std_startup (void) 39 | { 40 | atexit (__do_global_dtors); /* First added, last called. */ 41 | __do_global_ctors (); /* Do all constructors. */ 42 | } 43 | 44 | /* Add function to .fini section. */ 45 | static void __attribute__((used, section (".fini"))) __std_cleanup (void) 46 | { 47 | __call_exitprocs (0, NULL); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /examples/TicTacToe/C++/32X/hw_32x.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_32X_H 2 | #define HW_32X_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | extern void Hw32xSetFGColor(int s, int r, int g, int b); 13 | extern void Hw32xSetBGColor(int s, int r, int g, int b); 14 | extern void Hw32xInit(int vmode, int lineskip); 15 | extern int Hw32xScreenGetX(); 16 | extern int Hw32xScreenGetY(); 17 | extern void Hw32xScreenSetXY(int x, int y); 18 | extern void Hw32xScreenClear(); 19 | extern void Hw32xScreenPutChar(int x, int y, unsigned char ch); 20 | extern void Hw32xScreenClearLine(int Y); 21 | extern int Hw32xScreenPrintData(const char *buff, int size); 22 | extern int Hw32xScreenPuts(const char *str); 23 | extern void Hw32xScreenPrintf(const char *format, ...); 24 | extern void Hw32xDelay(int ticks); 25 | extern void Hw32xScreenFlip(int wait); 26 | extern void Hw32xFlipWait(); 27 | 28 | extern unsigned short HwMdReadPad(int port); 29 | extern unsigned char HwMdReadSram(unsigned short offset); 30 | extern void HwMdWriteSram(unsigned char byte, unsigned short offset); 31 | extern int HwMdReadMouse(int port); 32 | extern void HwMdClearScreen(void); 33 | extern void HwMdSetOffset(unsigned short offset); 34 | extern void HwMdSetNTable(unsigned short word); 35 | extern void HwMdSetVram(unsigned short word); 36 | extern void HwMdPuts(char *str, int color, int x, int y); 37 | extern void HwMdPutc(char chr, int color, int x, int y); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /examples/TicTacToe/C++/32X/m68k_crt0.s: -------------------------------------------------------------------------------- 1 | | SEGA 32X support code for the 68000 2 | | by Chilly Willy 3 | | First part of rom header 4 | 5 | .text 6 | 7 | | Initial exception vectors. When the console is first turned on, it is 8 | | in MegaDrive mode. All vectors just point to the code to start up the 9 | | Mars adapter. After the adapter is enabled, none of these vectors will 10 | | appear as the adapter uses its own vector table to route exceptions to 11 | | the jump table. 0x3F0 is where the 68000 starts at for the 32X. 12 | 13 | .long 0x01000000,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 14 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 15 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 16 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 17 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 18 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 19 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 20 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 21 | 22 | | Standard MegaDrive ROM header at 0x100 23 | 24 | .ascii "SEGA 32X Example" /* SEGA must be the first four chars for TMSS */ 25 | .ascii "(C)2011 " 26 | .ascii "Example startup " /* export name */ 27 | .ascii "code for 32X " 28 | .ascii " " 29 | .ascii "Example startup " /* domestic (Japanese) name */ 30 | .ascii "code for 32X " 31 | .ascii " " 32 | .ascii "GM MK-0000 -00" 33 | .word 0x0000 /* checksum - not needed */ 34 | .ascii "J6 " 35 | .long 0x00000000,0x0007FFFF /* ROM start, end */ 36 | .long 0x00FF0000,0x00FFFFFF /* RAM start, end */ 37 | 38 | .ifdef HAS_SAVE_RAM 39 | .ascii "RA" /* External RAM */ 40 | .byte 0xF8 /* don't clear + odd bytes */ 41 | .byte 0x20 /* SRAM */ 42 | .long 0x00200001,0x0020FFFF /* SRAM start, end */ 43 | .else 44 | .ascii " " /* no SRAM */ 45 | .endif 46 | 47 | .ascii " " 48 | .ascii " " 49 | 50 | .ifdef MYTH_HOMEBREW 51 | .ascii "MYTH3900" /* memo indicates Myth native executable */ 52 | .else 53 | .ascii " " /* memo */ 54 | .endif 55 | 56 | .ascii " " 57 | .ascii " " 58 | .ascii "F " /* enable any hardware configuration */ 59 | 60 | | Mars exception vector jump table at 0x200 61 | 62 | jmp 0x880800.l /* reset = hot start */ 63 | jsr 0x880806.l /* EX_BusError */ 64 | jsr 0x880806.l /* EX_AddrError */ 65 | jsr 0x880806.l /* EX_IllInstr */ 66 | jsr 0x880806.l /* EX_DivByZero */ 67 | jsr 0x880806.l /* EX_CHK */ 68 | jsr 0x880806.l /* EX_TrapV */ 69 | jsr 0x880806.l /* EX_Priviledge */ 70 | jsr 0x880806.l /* EX_Trace */ 71 | jsr 0x880806.l /* EX_LineA */ 72 | jsr 0x880806.l /* EX_LineF */ 73 | .space 72 /* reserved */ 74 | jsr 0x880806.l /* EX_Spurious */ 75 | jsr 0x880806.l /* EX_Level1 */ 76 | jsr 0x880806.l /* EX_Level2 */ 77 | jsr 0x880806.l /* EX_Level3 */ 78 | jmp 0x88080C.l /* EX_Level4 HBlank */ 79 | jsr 0x880806.l /* EX_Level5 */ 80 | jmp 0x880812.l /* EX_Level6 VBlank */ 81 | jsr 0x880806.l /* EX_Level7 */ 82 | jsr 0x880806.l /* EX_Trap0 */ 83 | jsr 0x880806.l /* EX_Trap1 */ 84 | jsr 0x880806.l /* EX_Trap2 */ 85 | jsr 0x880806.l /* EX_Trap3 */ 86 | jsr 0x880806.l /* EX_Trap4 */ 87 | jsr 0x880806.l /* EX_Trap5 */ 88 | jsr 0x880806.l /* EX_Trap6 */ 89 | jsr 0x880806.l /* EX_Trap7 */ 90 | jsr 0x880806.l /* EX_Trap8 */ 91 | jsr 0x880806.l /* EX_Trap9 */ 92 | jsr 0x880806.l /* EX_TrapA */ 93 | jsr 0x880806.l /* EX_TrapB */ 94 | jsr 0x880806.l /* EX_TrapC */ 95 | jsr 0x880806.l /* EX_TrapD */ 96 | jsr 0x880806.l /* EX_TrapE */ 97 | jsr 0x880806.l /* EX_TrapF */ 98 | .space 166 /* reserved */ 99 | -------------------------------------------------------------------------------- /examples/TicTacToe/C++/MD/Makefile: -------------------------------------------------------------------------------- 1 | CPP = m68k-elf-g++ 2 | CC = m68k-elf-gcc 3 | AS = m68k-elf-as 4 | OBJC = m68k-elf-objcopy 5 | RM = rm -f 6 | ASMZ80 = zasm 7 | BINTOC = bin2c 8 | 9 | OPTION = 10 | INCS = -I. -I$(GENDEV)/m68k-elf/include -I$(GENDEV)/m68k-elf/m68k-elf/include 11 | CPPFLAGS = $(OPTION) -m68000 -Wall -O2 -c -fno-exceptions -nostartfiles -ffreestanding -fno-rtti 12 | CCFLAGS = $(OPTION) -m68000 -Wall -O2 -c -fomit-frame-pointer 13 | HWCCFLAGS = $(OPTION) -m68000 -Wall -O1 -c -fomit-frame-pointer 14 | Z80FLAGS = -vb2 15 | ASFLAGS = -m68000 --register-prefix-optional 16 | LIBS = -L$(GENDEV)/m68k-elf/lib -L$(GENDEV)/m68k-elf/m68k-elf/lib -lstdc++ -lc -lgcc -lnosys 17 | LINKFLAGS = -T $(GENDEV)/ldscripts/md.ld -Wl,-Map=output.map -nostdlib -ffreestanding -fno-rtti 18 | 19 | OBJS = crt0.o crtstuff.o main.o hw_md.o font.o 20 | 21 | all: TicTacToe.bin 22 | 23 | TicTacToe.bin: TicTacToe.elf 24 | $(OBJC) -O binary $< temp.bin 25 | dd if=temp.bin of=$@ bs=512K conv=sync 26 | 27 | TicTacToe.elf: $(OBJS) 28 | $(CPP) $(LINKFLAGS) $(OBJS) $(LIBS) -o TicTacToe.elf 29 | 30 | %.o80: %.s80 31 | $(ASMZ80) $(Z80FLAGS) -o $@ $< 32 | 33 | %.c: %.o80 34 | $(BINTOC) $< 35 | 36 | %.o: %.cpp 37 | $(CPP) $(CPPFLAGS) $(INCLUDE) -c $< -o $@ 38 | 39 | %.o: %.c 40 | $(CC) $(CCFLAGS) $(INCLUDE) -c $< -o $@ 41 | 42 | %.o: %.s 43 | $(AS) $(ASFLAGS) $< -o $@ 44 | 45 | clean: 46 | $(RM) *.o *.bin *.elf *.map 47 | -------------------------------------------------------------------------------- /examples/TicTacToe/C++/MD/crt0.s: -------------------------------------------------------------------------------- 1 | | SEGA MegaDrive support code 2 | | by Chilly Willy 3 | 4 | .text 5 | 6 | | Initial exception vectors 7 | 8 | .long 0x01000000,initialize,exception,exception,exception,exception,exception,exception 9 | .long exception,exception,exception,exception,exception,exception,exception,exception 10 | .long exception,exception,exception,exception,exception,exception,exception,exception 11 | .long exception,exception,exception,exception,hblank,exception,vblank,exception 12 | .long exception,exception,exception,exception,exception,exception,exception,exception 13 | .long exception,exception,exception,exception,exception,exception,exception,exception 14 | .long exception,exception,exception,exception,exception,exception,exception,exception 15 | .long exception,exception,exception,exception,exception,exception,exception,exception 16 | 17 | | Standard MegaDrive ROM header at 0x100 18 | 19 | .ascii "SEGA MD Example " /* SEGA must be the first four chars for TMSS */ 20 | .ascii "(C)2011 " 21 | .ascii "Example startup " /* export name */ 22 | .ascii "code for MD " 23 | .ascii " " 24 | .ascii "Example startup " /* domestic (Japanese) name */ 25 | .ascii "code for MD " 26 | .ascii " " 27 | .ascii "GM MK-0000 -00" 28 | .word 0x0000 /* checksum - not needed */ 29 | .ascii "J6 " 30 | .long 0x00000000,0x0007FFFF /* ROM start, end */ 31 | .long 0x00FF0000,0x00FFFFFF /* RAM start, end */ 32 | 33 | .ifdef HAS_SAVE_RAM 34 | .ascii "RA" /* External RAM */ 35 | .byte 0xF8 /* don't clear + odd bytes */ 36 | .byte 0x20 /* SRAM */ 37 | .long 0x00200001,0x0020FFFF /* SRAM start, end */ 38 | .else 39 | .ascii " " /* no SRAM */ 40 | .endif 41 | 42 | .ascii " " 43 | .ascii " " 44 | 45 | .ifdef MYTH_HOMEBREW 46 | .ascii "MYTH3900" /* memo indicates Myth native executable */ 47 | .else 48 | .ascii " " /* memo */ 49 | .endif 50 | 51 | .ascii " " 52 | .ascii " " 53 | .ascii "F " /* enable any hardware configuration */ 54 | 55 | 56 | | Standard MegaDrive startup at 0x200 57 | 58 | initialize: 59 | move #0x2700,sr /* disable interrupts */ 60 | 61 | tst.l 0xA10008 /* check CTRL1 and CTRL2 setup */ 62 | bne.b 1f 63 | tst.w 0xA1000C /* check CTRL3 setup */ 64 | 1: 65 | bne.b skip_tmss /* if any controller control port is setup, skip TMSS handling */ 66 | 67 | | Check Hardware Version Number 68 | move.b 0xA10001,d0 69 | andi.b #0x0F,d0 /* VERS */ 70 | beq 2f /* 0 = original hardware, TMSS not present */ 71 | move.l #0x53454741,0xA14000 /* Store Sega Security Code "SEGA" to TMSS */ 72 | 2: 73 | move.w 0xC00004,d0 /* read VDP Status reg */ 74 | 75 | skip_tmss: 76 | move.w #0x8104,0xC00004 /* display off, vblank disabled */ 77 | move.w 0xC00004,d0 /* read VDP Status reg */ 78 | 79 | | Clear Work RAM 80 | lea 0xFF0000,a0 81 | moveq #0,d0 82 | move.w #0x3FFF,d1 83 | 1: 84 | move.l d0,(a0)+ 85 | dbra d1,1b 86 | 87 | | Copy initialized variables from ROM to Work RAM 88 | lea _stext,a0 89 | lea 0xFF0000,a1 90 | move.l #_sdata,d0 91 | lsr.l #1,d0 92 | subq.w #1,d0 93 | 2: 94 | move.w (a0)+,(a1)+ 95 | dbra d0,2b 96 | 97 | lea 0x01000000,a0 98 | movea.l a0,sp /* set stack pointer to top of Work RAM */ 99 | link.w a6,#-8 /* set up initial stack frame */ 100 | 101 | jsr init_hardware /* initialize the console hardware */ 102 | 103 | jsr __INIT_SECTION__ /* do all program initializers */ 104 | jsr main /* call program main() */ 105 | jsr __FINI_SECTION__ /* do all program finishers */ 106 | 3: 107 | bra.b 3b 108 | 109 | 110 | | put redirection vectors and gTicks at start of Work RAM 111 | 112 | .data 113 | 114 | .global exception_vector 115 | exception_vector: 116 | .long 0 117 | .global exception_vector 118 | hblank_vector: 119 | .long 0 120 | .global exception_vector 121 | vblank_vector: 122 | .long 0 123 | .global gTicks 124 | gTicks: 125 | .long 0 126 | 127 | | Exception handlers 128 | 129 | exception: 130 | move.l exception_vector,-(sp) 131 | beq.b 1f 132 | rts 133 | 1: 134 | addq.l #4,sp 135 | rte 136 | 137 | hblank: 138 | move.l hblank_vector,-(sp) 139 | beq.b 1f 140 | rts 141 | 1: 142 | addq.l #4,sp 143 | rte 144 | 145 | vblank: 146 | move.l vblank_vector,-(sp) 147 | beq.b 1f 148 | rts 149 | 1: 150 | addq.l #1,gTicks 151 | addq.l #4,sp 152 | rte 153 | 154 | 155 | .text 156 | 157 | -------------------------------------------------------------------------------- /examples/TicTacToe/C++/MD/crtstuff.c: -------------------------------------------------------------------------------- 1 | /* C++ CTOR / DTOR handling */ 2 | 3 | #include 4 | 5 | 6 | /* Used by exit procs */ 7 | void *__dso_handle = 0; 8 | extern void __call_exitprocs (int code, void *ptr); 9 | 10 | typedef void (*func_ptr) (void); 11 | 12 | extern func_ptr __CTOR_LIST__[]; 13 | extern func_ptr __DTOR_LIST__[]; 14 | 15 | /* Do all constructors. */ 16 | static void __attribute__((used)) __do_global_ctors (void) 17 | { 18 | do 19 | { 20 | unsigned int i, n = (unsigned int) __CTOR_LIST__[0]; 21 | for (i = n; i >= 1; i--) 22 | __CTOR_LIST__[i] (); 23 | } while (0); 24 | } 25 | 26 | /* Do all destructors. */ 27 | static void __attribute__((used)) __do_global_dtors (void) 28 | { 29 | do 30 | { 31 | unsigned int i, n = (unsigned int) __DTOR_LIST__[0]; 32 | for (i = 0; i < n; i++) 33 | __DTOR_LIST__[i + 1] (); 34 | } while (0); 35 | } 36 | 37 | /* Add function to .init section. */ 38 | static void __attribute__((used, section (".init"))) __std_startup (void) 39 | { 40 | atexit (__do_global_dtors); /* First added, last called. */ 41 | __do_global_ctors (); /* Do all constructors. */ 42 | } 43 | 44 | /* Add function to .fini section. */ 45 | static void __attribute__((used, section (".fini"))) __std_cleanup (void) 46 | { 47 | __call_exitprocs (0, NULL); 48 | } 49 | 50 | -------------------------------------------------------------------------------- /examples/TicTacToe/C++/MD/hw_md.h: -------------------------------------------------------------------------------- 1 | #ifndef _HW_MD_H 2 | #define _HW_MD_H 3 | 4 | #define SEGA_CTRL_BUTTONS 0x0FFF 5 | #define SEGA_CTRL_UP 0x0001 6 | #define SEGA_CTRL_DOWN 0x0002 7 | #define SEGA_CTRL_LEFT 0x0004 8 | #define SEGA_CTRL_RIGHT 0x0008 9 | #define SEGA_CTRL_B 0x0010 10 | #define SEGA_CTRL_C 0x0020 11 | #define SEGA_CTRL_A 0x0040 12 | #define SEGA_CTRL_START 0x0080 13 | #define SEGA_CTRL_Z 0x0100 14 | #define SEGA_CTRL_Y 0x0200 15 | #define SEGA_CTRL_X 0x0400 16 | #define SEGA_CTRL_MODE 0x0800 17 | 18 | #define SEGA_CTRL_TYPE 0xF000 19 | #define SEGA_CTRL_THREE 0x0000 20 | #define SEGA_CTRL_SIX 0x1000 21 | #define SEGA_CTRL_NONE 0xF000 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | extern short set_sr(short new_sr); 28 | extern short get_pad(short pad); 29 | extern void clear_screen(void); 30 | extern void put_str(char *str, int color, int x, int y); 31 | extern void put_chr(char chr, int color, int x, int y); 32 | extern void delay(int count); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /examples/TicTacToe/C/32X/32x.h: -------------------------------------------------------------------------------- 1 | #ifndef __32X_H__ 2 | #define __32X_H__ 3 | 4 | /* Create a 5:5:5 RGB color */ 5 | #define COLOR(r,g,b) (((r)&0x1F)|((g)&0x1F)<<5|((b)&0x1F)<<10) 6 | 7 | #define MARS_CRAM (*(volatile unsigned short *)0x20004200) 8 | #define MARS_FRAMEBUFFER (*(volatile unsigned short *)0x24000000) 9 | #define MARS_OVERWRITE_IMG (*(volatile unsigned short *)0x24020000) 10 | #define MARS_SDRAM (*(volatile unsigned short *)0x26000000) 11 | 12 | #define MARS_SYS_INTMSK (*(volatile unsigned short *)0x20004000) 13 | #define MARS_SYS_DMACTR (*(volatile unsigned short *)0x20004006) 14 | #define MARS_SYS_DMASAR (*(volatile unsigned long *)0x20004008) 15 | #define MARS_SYS_DMADAR (*(volatile unsigned long *)0x2000400C) 16 | #define MARS_SYS_DMALEN (*(volatile unsigned short *)0x20004010) 17 | #define MARS_SYS_DMAFIFO (*(volatile unsigned short *)0x20004012) 18 | #define MARS_SYS_VRESI_CLR (*(volatile unsigned short *)0x20004014) 19 | #define MARS_SYS_VINT_CLR (*(volatile unsigned short *)0x20004016) 20 | #define MARS_SYS_HINT_CLR (*(volatile unsigned short *)0x20004018) 21 | #define MARS_SYS_CMDI_CLR (*(volatile unsigned short *)0x2000401A) 22 | #define MARS_SYS_PWMI_CLR (*(volatile unsigned short *)0x2000401C) 23 | #define MARS_SYS_COMM0 (*(volatile unsigned short *)0x20004020) /* Master SH2 communication */ 24 | #define MARS_SYS_COMM2 (*(volatile unsigned short *)0x20004022) 25 | #define MARS_SYS_COMM4 (*(volatile unsigned short *)0x20004024) /* Slave SH2 communication */ 26 | #define MARS_SYS_COMM6 (*(volatile unsigned short *)0x20004026) 27 | #define MARS_SYS_COMM8 (*(volatile unsigned short *)0x20004028) /* controller 1 current value */ 28 | #define MARS_SYS_COMM10 (*(volatile unsigned short *)0x2000402A) /* controller 2 current value */ 29 | #define MARS_SYS_COMM12 (*(volatile unsigned long *)0x2000402C) /* vcount current value */ 30 | 31 | #define MARS_PWM_CTRL (*(volatile unsigned short *)0x20004030) 32 | #define MARS_PWM_CYCLE (*(volatile unsigned short *)0x20004032) 33 | #define MARS_PWM_LEFT (*(volatile unsigned short *)0x20004034) 34 | #define MARS_PWM_RIGHT (*(volatile unsigned short *)0x20004036) 35 | #define MARS_PWM_MONO (*(volatile unsigned short *)0x20004038) 36 | 37 | #define MARS_VDP_DISPMODE (*(volatile unsigned short *)0x20004100) 38 | #define MARS_VDP_FILLEN (*(volatile unsigned short *)0x20004104) 39 | #define MARS_VDP_FILADR (*(volatile unsigned short *)0x20004106) 40 | #define MARS_VDP_FILDAT (*(volatile unsigned short *)0x20004108) 41 | #define MARS_VDP_FBCTL (*(volatile unsigned short *)0x2000410A) 42 | 43 | #define MARS_SH2_ACCESS_VDP 0x8000 44 | #define MARS_68K_ACCESS_VDP 0x0000 45 | 46 | #define MARS_PAL_FORMAT 0x0000 47 | #define MARS_NTSC_FORMAT 0x8000 48 | 49 | #define MARS_VDP_PRIO_68K 0x0000 50 | #define MARS_VDP_PRIO_32X 0x0080 51 | 52 | #define MARS_224_LINES 0x0000 53 | #define MARS_240_LINES 0x0040 54 | 55 | #define MARS_VDP_MODE_OFF 0x0000 56 | #define MARS_VDP_MODE_256 0x0001 57 | #define MARS_VDP_MODE_32K 0x0002 58 | #define MARS_VDP_MODE_RLE 0x0003 59 | 60 | #define MARS_VDP_VBLK 0x8000 61 | #define MARS_VDP_HBLK 0x4000 62 | #define MARS_VDP_PEN 0x2000 63 | #define MARS_VDP_FEN 0x0002 64 | #define MARS_VDP_FS 0x0001 65 | 66 | #define SH2_CCTL_CP 0x10 67 | #define SH2_CCTL_TW 0x08 68 | #define SH2_CCTL_CE 0x01 69 | 70 | #define SH2_FRT_TIER (*(volatile unsigned char *)0xFFFFFE10) 71 | #define SH2_FRT_FTCSR (*(volatile unsigned char *)0xFFFFFE11) 72 | #define SH2_FRT_FRCH (*(volatile unsigned char *)0xFFFFFE12) 73 | #define SH2_FRT_FRCL (*(volatile unsigned char *)0xFFFFFE13) 74 | #define SH2_FRT_OCRH (*(volatile unsigned char *)0xFFFFFE14) 75 | #define SH2_FRT_OCRL (*(volatile unsigned char *)0xFFFFFE15) 76 | #define SH2_FRT_TCR (*(volatile unsigned char *)0xFFFFFE16) 77 | #define SH2_FRT_TOCR (*(volatile unsigned char *)0xFFFFFE17) 78 | #define SH2_FRT_ICRH (*(volatile unsigned char *)0xFFFFFE18) 79 | #define SH2_FRT_ICRL (*(volatile unsigned char *)0xFFFFFE19) 80 | 81 | #define SH2_DMA_SAR0 (*(volatile unsigned long *)0xFFFFFF80) 82 | #define SH2_DMA_DAR0 (*(volatile unsigned long *)0xFFFFFF84) 83 | #define SH2_DMA_TCR0 (*(volatile unsigned long *)0xFFFFFF88) 84 | #define SH2_DMA_CHCR0 (*(volatile unsigned long *)0xFFFFFF8C) 85 | #define SH2_DMA_VCR0 (*(volatile unsigned long *)0xFFFFFFA0) 86 | #define SH2_DMA_DRCR0 (*(volatile unsigned char *)0xFFFFFE71) 87 | 88 | #define SH2_DMA_SAR1 (*(volatile unsigned long *)0xFFFFFF90) 89 | #define SH2_DMA_DAR1 (*(volatile unsigned long *)0xFFFFFF94) 90 | #define SH2_DMA_TCR1 (*(volatile unsigned long *)0xFFFFFF98) 91 | #define SH2_DMA_CHCR1 (*(volatile unsigned long *)0xFFFFFF9C) 92 | #define SH2_DMA_VCR1 (*(volatile unsigned long *)0xFFFFFFA8) 93 | #define SH2_DMA_DRCR1 (*(volatile unsigned char *)0xFFFFFE72) 94 | 95 | #define SH2_DMA_DMAOR (*(volatile unsigned long *)0xFFFFFFB0) 96 | 97 | #define SH2_INT_IPRA (*(volatile unsigned short *)0xFFFFFEE2) 98 | 99 | #define SEGA_CTRL_UP 0x0001 100 | #define SEGA_CTRL_DOWN 0x0002 101 | #define SEGA_CTRL_LEFT 0x0004 102 | #define SEGA_CTRL_RIGHT 0x0008 103 | #define SEGA_CTRL_B 0x0010 104 | #define SEGA_CTRL_C 0x0020 105 | #define SEGA_CTRL_A 0x0040 106 | #define SEGA_CTRL_START 0x0080 107 | #define SEGA_CTRL_Z 0x0100 108 | #define SEGA_CTRL_Y 0x0200 109 | #define SEGA_CTRL_X 0x0400 110 | #define SEGA_CTRL_MODE 0x0800 111 | 112 | #define SEGA_CTRL_TYPE 0xF000 113 | #define SEGA_CTRL_THREE 0x0000 114 | #define SEGA_CTRL_SIX 0x1000 115 | #define SEGA_CTRL_NONE 0xF000 116 | 117 | #ifdef __cplusplus 118 | extern "C" { 119 | #endif 120 | 121 | /* global functions in sh2_crt0.s */ 122 | extern void fast_memcpy(void *dst, void *src, int len); 123 | extern void CacheControl(int mode); 124 | extern void CacheClearLine(void* ptr); 125 | extern void ScreenStretch(int src, int width, int height, int interp); 126 | 127 | #ifdef __cplusplus 128 | } 129 | #endif 130 | 131 | #endif 132 | -------------------------------------------------------------------------------- /examples/TicTacToe/C/32X/Makefile: -------------------------------------------------------------------------------- 1 | MDLD = m68k-elf-ld 2 | MDAS = m68k-elf-as 3 | SHLD = sh-elf-ld 4 | SHCC = sh-elf-gcc 5 | SHAS = sh-elf-as 6 | SHOBJC = sh-elf-objcopy 7 | RM = rm -f 8 | 9 | CCFLAGS = -m2 -mb -O3 -Wall -c -fomit-frame-pointer 10 | HWCCFLAGS = -m2 -mb -O1 -Wall -c -fomit-frame-pointer 11 | LINKFLAGS = -T $(GENDEV)/ldscripts/mars.ld -Wl,-Map=output.map -nostdlib 12 | 13 | INCS = -I. -I$(GENDEV)/sh-elf/include -I$(GENDEV)/sh-elf/sh-elf/include 14 | 15 | LIBS = -L$(GENDEV)/sh-elf/sh-elf/lib -L$(GENDEV)/sh-elf/lib/gcc/sh-elf/$(GENDEV_GCC_VERSION) -lc -lgcc -lgcc-Os-4-200 -lnosys 16 | 17 | OBJS = sh2_crt0.o main.o hw_32x.o font.o 18 | 19 | all: m68k_crt0.bin m68k_crt1.bin TicTacToe32X.bin 20 | 21 | TicTacToe32X.bin: TicTacToe.elf 22 | $(SHOBJC) -O binary $< temp.bin 23 | dd if=temp.bin of=$@ bs=64K conv=sync 24 | 25 | TicTacToe.elf: $(OBJS) 26 | $(SHCC) $(LINKFLAGS) $(OBJS) $(LIBS) -o TicTacToe.elf 27 | 28 | m68k_crt0.bin: m68k_crt0.s 29 | $(MDAS) -m68000 --register-prefix-optional -o m68k_crt0.o m68k_crt0.s 30 | $(MDLD) -T $(GENDEV)/ldscripts/md.ld --oformat binary -o m68k_crt0.bin m68k_crt0.o 31 | 32 | m68k_crt1.bin: m68k_crt1.s 33 | $(MDAS) -m68000 --register-prefix-optional -o m68k_crt1.o m68k_crt1.s 34 | $(MDLD) -T $(GENDEV)/ldscripts/md.ld --oformat binary -o m68k_crt1.bin m68k_crt1.o 35 | 36 | hw_32x.o: hw_32x.c 37 | $(SHCC) $(HWCCFLAGS) $< -o $@ 38 | 39 | %.o: %.c 40 | $(SHCC) $(CCFLAGS) $< -o $@ 41 | 42 | %.o: %.s 43 | $(SHAS) --small -o $@ $< 44 | 45 | clean: 46 | $(RM) *.o *.bin *.elf *.map 47 | -------------------------------------------------------------------------------- /examples/TicTacToe/C/32X/hw_32x.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_32X_H 2 | #define HW_32X_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | extern void Hw32xSetFGColor(int s, int r, int g, int b); 13 | extern void Hw32xSetBGColor(int s, int r, int g, int b); 14 | extern void Hw32xInit(int vmode, int lineskip); 15 | extern int Hw32xScreenGetX(); 16 | extern int Hw32xScreenGetY(); 17 | extern void Hw32xScreenSetXY(int x, int y); 18 | extern void Hw32xScreenClear(); 19 | extern void Hw32xScreenPutChar(int x, int y, unsigned char ch); 20 | extern void Hw32xScreenClearLine(int Y); 21 | extern int Hw32xScreenPrintData(const char *buff, int size); 22 | extern int Hw32xScreenPuts(const char *str); 23 | extern void Hw32xScreenPrintf(const char *format, ...); 24 | extern void Hw32xDelay(int ticks); 25 | extern void Hw32xScreenFlip(int wait); 26 | extern void Hw32xFlipWait(); 27 | 28 | extern unsigned short HwMdReadPad(int port); 29 | extern unsigned char HwMdReadSram(unsigned short offset); 30 | extern void HwMdWriteSram(unsigned char byte, unsigned short offset); 31 | extern int HwMdReadMouse(int port); 32 | extern void HwMdClearScreen(void); 33 | extern void HwMdSetOffset(unsigned short offset); 34 | extern void HwMdSetNTable(unsigned short word); 35 | extern void HwMdSetVram(unsigned short word); 36 | extern void HwMdPuts(char *str, int color, int x, int y); 37 | extern void HwMdPutc(char chr, int color, int x, int y); 38 | 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /examples/TicTacToe/C/32X/m68k_crt0.s: -------------------------------------------------------------------------------- 1 | | SEGA 32X support code for the 68000 2 | | by Chilly Willy 3 | | First part of rom header 4 | 5 | .text 6 | 7 | | Initial exception vectors. When the console is first turned on, it is 8 | | in MegaDrive mode. All vectors just point to the code to start up the 9 | | Mars adapter. After the adapter is enabled, none of these vectors will 10 | | appear as the adapter uses its own vector table to route exceptions to 11 | | the jump table. 0x3F0 is where the 68000 starts at for the 32X. 12 | 13 | .long 0x01000000,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 14 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 15 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 16 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 17 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 18 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 19 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 20 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 21 | 22 | | Standard MegaDrive ROM header at 0x100 23 | 24 | .ascii "SEGA 32X Example" /* SEGA must be the first four chars for TMSS */ 25 | .ascii "(C)2011 " 26 | .ascii "Example startup " /* export name */ 27 | .ascii "code for 32X " 28 | .ascii " " 29 | .ascii "Example startup " /* domestic (Japanese) name */ 30 | .ascii "code for 32X " 31 | .ascii " " 32 | .ascii "GM MK-0000 -00" 33 | .word 0x0000 /* checksum - not needed */ 34 | .ascii "J6 " 35 | .long 0x00000000,0x0007FFFF /* ROM start, end */ 36 | .long 0x00FF0000,0x00FFFFFF /* RAM start, end */ 37 | 38 | .ifdef HAS_SAVE_RAM 39 | .ascii "RA" /* External RAM */ 40 | .byte 0xF8 /* don't clear + odd bytes */ 41 | .byte 0x20 /* SRAM */ 42 | .long 0x00200001,0x0020FFFF /* SRAM start, end */ 43 | .else 44 | .ascii " " /* no SRAM */ 45 | .endif 46 | 47 | .ascii " " 48 | .ascii " " 49 | 50 | .ifdef MYTH_HOMEBREW 51 | .ascii "MYTH3900" /* memo indicates Myth native executable */ 52 | .else 53 | .ascii " " /* memo */ 54 | .endif 55 | 56 | .ascii " " 57 | .ascii " " 58 | .ascii "F " /* enable any hardware configuration */ 59 | 60 | | Mars exception vector jump table at 0x200 61 | 62 | jmp 0x880800.l /* reset = hot start */ 63 | jsr 0x880806.l /* EX_BusError */ 64 | jsr 0x880806.l /* EX_AddrError */ 65 | jsr 0x880806.l /* EX_IllInstr */ 66 | jsr 0x880806.l /* EX_DivByZero */ 67 | jsr 0x880806.l /* EX_CHK */ 68 | jsr 0x880806.l /* EX_TrapV */ 69 | jsr 0x880806.l /* EX_Priviledge */ 70 | jsr 0x880806.l /* EX_Trace */ 71 | jsr 0x880806.l /* EX_LineA */ 72 | jsr 0x880806.l /* EX_LineF */ 73 | .space 72 /* reserved */ 74 | jsr 0x880806.l /* EX_Spurious */ 75 | jsr 0x880806.l /* EX_Level1 */ 76 | jsr 0x880806.l /* EX_Level2 */ 77 | jsr 0x880806.l /* EX_Level3 */ 78 | jmp 0x88080C.l /* EX_Level4 HBlank */ 79 | jsr 0x880806.l /* EX_Level5 */ 80 | jmp 0x880812.l /* EX_Level6 VBlank */ 81 | jsr 0x880806.l /* EX_Level7 */ 82 | jsr 0x880806.l /* EX_Trap0 */ 83 | jsr 0x880806.l /* EX_Trap1 */ 84 | jsr 0x880806.l /* EX_Trap2 */ 85 | jsr 0x880806.l /* EX_Trap3 */ 86 | jsr 0x880806.l /* EX_Trap4 */ 87 | jsr 0x880806.l /* EX_Trap5 */ 88 | jsr 0x880806.l /* EX_Trap6 */ 89 | jsr 0x880806.l /* EX_Trap7 */ 90 | jsr 0x880806.l /* EX_Trap8 */ 91 | jsr 0x880806.l /* EX_Trap9 */ 92 | jsr 0x880806.l /* EX_TrapA */ 93 | jsr 0x880806.l /* EX_TrapB */ 94 | jsr 0x880806.l /* EX_TrapC */ 95 | jsr 0x880806.l /* EX_TrapD */ 96 | jsr 0x880806.l /* EX_TrapE */ 97 | jsr 0x880806.l /* EX_TrapF */ 98 | .space 166 /* reserved */ 99 | -------------------------------------------------------------------------------- /examples/TicTacToe/C/MD/Makefile: -------------------------------------------------------------------------------- 1 | CC = m68k-elf-gcc 2 | AS = m68k-elf-as 3 | OBJC = m68k-elf-objcopy 4 | RM = rm -f 5 | ASMZ80 = zasm 6 | BINTOC = bin2c 7 | 8 | OPTION = 9 | INCS = -I. -I$(GENDEV)/m68k-elf/include -I$(GENDEV)/m68k-elf/m68k-elf/include 10 | CCFLAGS = $(OPTION) -m68000 -Wall -O2 -c -fomit-frame-pointer 11 | HWCCFLAGS = $(OPTION) -m68000 -Wall -O1 -c -fomit-frame-pointer 12 | Z80FLAGS = -vb2 13 | ASFLAGS = -m68000 --register-prefix-optional 14 | LIBS = -L$(GENDEV)/m68k-elf/lib -L$(GENDEV)/m68k-elf/m68k-elf/lib -lc -lgcc -lnosys 15 | LINKFLAGS = -T $(GENDEV)/ldscripts/md.ld -Wl,-Map=output.map -nostdlib 16 | 17 | OBJS = crt0.o main.o hw_md.o font.o 18 | 19 | all: TicTacToe.bin 20 | 21 | TicTacToe.bin: TicTacToe.elf 22 | $(OBJC) -O binary $< temp.bin 23 | dd if=temp.bin of=$@ bs=8K conv=sync 24 | 25 | TicTacToe.elf: $(OBJS) 26 | $(CC) $(LINKFLAGS) $(OBJS) $(LIBS) -o TicTacToe.elf 27 | 28 | %.o80: %.s80 29 | $(ASMZ80) $(Z80FLAGS) -o $@ $< 30 | 31 | %.c: %.o80 32 | $(BINTOC) $< 33 | 34 | %.o: %.c 35 | $(CC) $(CCFLAGS) $(INCLUDE) -c $< -o $@ 36 | 37 | %.o: %.s 38 | $(AS) $(ASFLAGS) $< -o $@ 39 | 40 | clean: 41 | $(RM) *.o *.bin *.elf *.map 42 | -------------------------------------------------------------------------------- /examples/TicTacToe/C/MD/crt0.s: -------------------------------------------------------------------------------- 1 | | SEGA MegaDrive support code 2 | | by Chilly Willy 3 | 4 | .text 5 | 6 | | Initial exception vectors 7 | 8 | .long 0x01000000,initialize,exception,exception,exception,exception,exception,exception 9 | .long exception,exception,exception,exception,exception,exception,exception,exception 10 | .long exception,exception,exception,exception,exception,exception,exception,exception 11 | .long exception,exception,exception,exception,hblank,exception,vblank,exception 12 | .long exception,exception,exception,exception,exception,exception,exception,exception 13 | .long exception,exception,exception,exception,exception,exception,exception,exception 14 | .long exception,exception,exception,exception,exception,exception,exception,exception 15 | .long exception,exception,exception,exception,exception,exception,exception,exception 16 | 17 | | Standard MegaDrive ROM header at 0x100 18 | 19 | .ascii "SEGA MD Example " /* SEGA must be the first four chars for TMSS */ 20 | .ascii "(C)2011 " 21 | .ascii "Example startup " /* export name */ 22 | .ascii "code for MD " 23 | .ascii " " 24 | .ascii "Example startup " /* domestic (Japanese) name */ 25 | .ascii "code for MD " 26 | .ascii " " 27 | .ascii "GM MK-0000 -00" 28 | .word 0x0000 /* checksum - not needed */ 29 | .ascii "J6 " 30 | .long 0x00000000,0x0007FFFF /* ROM start, end */ 31 | .long 0x00FF0000,0x00FFFFFF /* RAM start, end */ 32 | 33 | .ifdef HAS_SAVE_RAM 34 | .ascii "RA" /* External RAM */ 35 | .byte 0xF8 /* don't clear + odd bytes */ 36 | .byte 0x20 /* SRAM */ 37 | .long 0x00200001,0x0020FFFF /* SRAM start, end */ 38 | .else 39 | .ascii " " /* no SRAM */ 40 | .endif 41 | 42 | .ascii " " 43 | .ascii " " 44 | 45 | .ifdef MYTH_HOMEBREW 46 | .ascii "MYTH3900" /* memo indicates Myth native executable */ 47 | .else 48 | .ascii " " /* memo */ 49 | .endif 50 | 51 | .ascii " " 52 | .ascii " " 53 | .ascii "F " /* enable any hardware configuration */ 54 | 55 | 56 | | Standard MegaDrive startup at 0x200 57 | 58 | initialize: 59 | move #0x2700,sr /* disable interrupts */ 60 | 61 | tst.l 0xA10008 /* check CTRL1 and CTRL2 setup */ 62 | bne.b 1f 63 | tst.w 0xA1000C /* check CTRL3 setup */ 64 | 1: 65 | bne.b skip_tmss /* if any controller control port is setup, skip TMSS handling */ 66 | 67 | | Check Hardware Version Number 68 | move.b 0xA10001,d0 69 | andi.b #0x0F,d0 /* VERS */ 70 | beq 2f /* 0 = original hardware, TMSS not present */ 71 | move.l #0x53454741,0xA14000 /* Store Sega Security Code "SEGA" to TMSS */ 72 | 2: 73 | move.w 0xC00004,d0 /* read VDP Status reg */ 74 | 75 | skip_tmss: 76 | move.w #0x8104,0xC00004 /* display off, vblank disabled */ 77 | move.w 0xC00004,d0 /* read VDP Status reg */ 78 | 79 | | Clear Work RAM 80 | lea 0xFF0000,a0 81 | moveq #0,d0 82 | move.w #0x3FFF,d1 83 | 1: 84 | move.l d0,(a0)+ 85 | dbra d1,1b 86 | 87 | | Copy initialized variables from ROM to Work RAM 88 | lea _stext,a0 89 | lea 0xFF0000,a1 90 | move.l #_sdata,d0 91 | lsr.l #1,d0 92 | subq.w #1,d0 93 | 2: 94 | move.w (a0)+,(a1)+ 95 | dbra d0,2b 96 | 97 | lea 0x01000000,a0 98 | movea.l a0,sp /* set stack pointer to top of Work RAM */ 99 | link.w a6,#-8 /* set up initial stack frame */ 100 | 101 | jsr init_hardware /* initialize the console hardware */ 102 | 103 | jsr __INIT_SECTION__ /* do all program initializers */ 104 | jsr main /* call program main() */ 105 | jsr __FINI_SECTION__ /* do all program finishers */ 106 | 3: 107 | bra.b 3b 108 | 109 | 110 | | put redirection vectors and gTicks at start of Work RAM 111 | 112 | .data 113 | 114 | .global exception_vector 115 | exception_vector: 116 | .long 0 117 | .global exception_vector 118 | hblank_vector: 119 | .long 0 120 | .global exception_vector 121 | vblank_vector: 122 | .long 0 123 | .global gTicks 124 | gTicks: 125 | .long 0 126 | 127 | | Exception handlers 128 | 129 | exception: 130 | move.l exception_vector,-(sp) 131 | beq.b 1f 132 | rts 133 | 1: 134 | addq.l #4,sp 135 | rte 136 | 137 | hblank: 138 | move.l hblank_vector,-(sp) 139 | beq.b 1f 140 | rts 141 | 1: 142 | addq.l #4,sp 143 | rte 144 | 145 | vblank: 146 | move.l vblank_vector,-(sp) 147 | beq.b 1f 148 | rts 149 | 1: 150 | addq.l #1,gTicks 151 | addq.l #4,sp 152 | rte 153 | 154 | 155 | .text 156 | 157 | -------------------------------------------------------------------------------- /examples/TicTacToe/C/MD/hw_md.h: -------------------------------------------------------------------------------- 1 | #ifndef _HW_MD_H 2 | #define _HW_MD_H 3 | 4 | #define SEGA_CTRL_BUTTONS 0x0FFF 5 | #define SEGA_CTRL_UP 0x0001 6 | #define SEGA_CTRL_DOWN 0x0002 7 | #define SEGA_CTRL_LEFT 0x0004 8 | #define SEGA_CTRL_RIGHT 0x0008 9 | #define SEGA_CTRL_B 0x0010 10 | #define SEGA_CTRL_C 0x0020 11 | #define SEGA_CTRL_A 0x0040 12 | #define SEGA_CTRL_START 0x0080 13 | #define SEGA_CTRL_Z 0x0100 14 | #define SEGA_CTRL_Y 0x0200 15 | #define SEGA_CTRL_X 0x0400 16 | #define SEGA_CTRL_MODE 0x0800 17 | 18 | #define SEGA_CTRL_TYPE 0xF000 19 | #define SEGA_CTRL_THREE 0x0000 20 | #define SEGA_CTRL_SIX 0x1000 21 | #define SEGA_CTRL_NONE 0xF000 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | extern short set_sr(short new_sr); 28 | extern short get_pad(short pad); 29 | extern void clear_screen(void); 30 | extern void put_str(char *str, int color, int x, int y); 31 | extern void put_chr(char chr, int color, int x, int y); 32 | extern void delay(int count); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /examples/TicTacToe/C/MD/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "hw_md.h" 4 | 5 | static int row; 6 | static int column; 7 | static int player; 8 | static int board[3][3]; 9 | static char display_board[3][3]; 10 | 11 | 12 | void TicTacToe(void) 13 | { 14 | int i, j; 15 | 16 | row = 0; 17 | column = 0; 18 | player = 1; 19 | for (i = 0; i < 3; i++) 20 | { 21 | for (j = 0; j < 3; j++) 22 | { 23 | board[i][j] = 0; 24 | display_board[i][j] = ' '; 25 | } 26 | } 27 | } 28 | 29 | int Pick_Player(void) 30 | { 31 | return player; 32 | } 33 | 34 | int Pick_Row(void) 35 | { 36 | return row; 37 | } 38 | 39 | int Pick_Column(void) 40 | { 41 | return column; 42 | } 43 | 44 | void Choice_by_Player(int a) 45 | { 46 | player = a; 47 | } 48 | 49 | void Choice_of_Row(int b) 50 | { 51 | row = b; 52 | } 53 | 54 | void Choice_of_Column(int c) 55 | { 56 | column = c; 57 | } 58 | 59 | int Check_Move(int row, int column) 60 | { 61 | if ( board[row][column] != 0 ) 62 | { 63 | put_str("Space occupied - Try Again", 0x4000, 20-13, 3); 64 | delay(120); 65 | put_str(" ", 0x4000, 20-13, 3); 66 | return 0; 67 | } 68 | else 69 | { 70 | board[row][column] = player; 71 | return 1; 72 | } 73 | } // end of Check_Move 74 | 75 | int Check_Board(void) 76 | { 77 | int i = 0; 78 | 79 | // check for tie 80 | for (i = 0; i < 9; i++) 81 | { 82 | if (board[i/3][i%3] == 0) 83 | break; 84 | } // end of for loop 85 | if ( i == 9 ) 86 | return 3; // tie game! 87 | 88 | // check rows 89 | if (( (board[0][0] == player) && (board[0][1] == player) && (board[0][2] == player) ) || 90 | ( (board[1][0] == player) && (board[1][1] == player) && (board[1][2] == player) ) || 91 | ( (board[2][0] == player) && (board[2][1] == player) && (board[2][2] == player) )) 92 | return player; 93 | 94 | // check columns 95 | if (( (board[0][0] == player) && (board[1][0] == player) && (board[2][0] == player) ) || 96 | ( (board[0][1] == player) && (board[1][1] == player) && (board[2][1] == player) ) || 97 | ( (board[0][2] == player) && (board[1][2] == player) && (board[2][2] == player) )) 98 | return player; 99 | 100 | // check diagonals 101 | if (( (board[0][0] == player) && (board[1][1] == player) && (board[2][2] == player) ) || 102 | ( (board[0][2] == player) && (board[1][1] == player) && (board[2][0] == player) )) 103 | return player; 104 | 105 | return 0; 106 | } // end of Check_Board 107 | 108 | void Clear_Board(void) 109 | { 110 | int i, j; 111 | 112 | row = 0; 113 | column = 0; 114 | player = 1; 115 | for (i = 0; i < 3; i++) 116 | { 117 | for (j = 0; j < 3; j++) 118 | { 119 | board[i][j] = 0; 120 | display_board[i][j] = ' '; 121 | } 122 | } 123 | } 124 | 125 | void Tic_Tac_Toe_Board(void) 126 | { 127 | int row, column; 128 | 129 | put_str("\x80\x82\x82\x82\x88\x82\x82\x82\x88\x82\x82\x82\x85", 0x2000, 20-6, 6); 130 | put_str("\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C", 0x2000, 20-6, 7); 131 | put_str("\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C", 0x2000, 20-6, 8); 132 | put_str("\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C", 0x2000, 20-6, 9); 133 | put_str("\x81\x82\x82\x82\x87\x82\x82\x82\x87\x82\x82\x82\x84", 0x2000, 20-6, 10); 134 | put_str("\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C", 0x2000, 20-6, 11); 135 | put_str("\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C", 0x2000, 20-6, 12); 136 | put_str("\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C", 0x2000, 20-6, 13); 137 | put_str("\x81\x82\x82\x82\x87\x82\x82\x82\x87\x82\x82\x82\x84", 0x2000, 20-6, 14); 138 | put_str("\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C", 0x2000, 20-6, 15); 139 | put_str("\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C", 0x2000, 20-6, 16); 140 | put_str("\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C\x20\x20\x20\x7C", 0x2000, 20-6, 17); 141 | put_str("\x86\x82\x82\x82\x89\x82\x82\x82\x89\x82\x82\x82\x83", 0x2000, 20-6, 18); 142 | 143 | put_str("Current Player: ", 0x2000, 20-8, 21); 144 | put_chr((player == 1) ? 'X' : 'O', 0x0000, 20+8, 21); 145 | 146 | for ( row = 0; row < 3; row ++) 147 | { 148 | for ( column = 0; column < 3; column++) 149 | { 150 | if ( board[row][column] == 0) 151 | { 152 | display_board[row][column] = ' '; 153 | } 154 | if ( board[row][column] == 1) 155 | { 156 | display_board[row][column] = 'X'; 157 | } 158 | if ( board[row][column] == 2) 159 | { 160 | display_board[row][column] = 'O'; 161 | } 162 | put_chr(display_board[row][column], 0x0000, 20-6+2 + column*4, 6+2 + row*4); 163 | } // end of inner for loop 164 | } // end of outer for loop 165 | 166 | } // end of Tic_Tac_Toe_Board 167 | 168 | 169 | int main(void) 170 | { 171 | int test; 172 | int more = 1; 173 | int row = 0; 174 | int column= 0; 175 | int player; 176 | int check = 0; 177 | short buttons = 0; 178 | 179 | TicTacToe(); 180 | 181 | while ( more ) 182 | { 183 | Tic_Tac_Toe_Board(); 184 | player = Pick_Player(); 185 | 186 | put_str("Choose a square", 0x2000, 20-7, 3); 187 | while ( !(buttons & SEGA_CTRL_A) ) 188 | { 189 | delay(2); 190 | buttons = get_pad(0); 191 | if ( buttons & SEGA_CTRL_C ) 192 | { 193 | more = 0; 194 | break; 195 | } 196 | } 197 | while ( get_pad(0) & SEGA_CTRL_A ) ; 198 | put_str(" ", 0x2000, 20-7, 3); 199 | delay(30); 200 | 201 | if ( !more ) 202 | break; 203 | 204 | switch ( buttons & 0x000F ) 205 | { 206 | case SEGA_CTRL_UP: 207 | row = 0; 208 | column = 1; 209 | break; 210 | case SEGA_CTRL_DOWN: 211 | row = 2; 212 | column = 1; 213 | break; 214 | case SEGA_CTRL_LEFT: 215 | row = 1; 216 | column = 0; 217 | break; 218 | case SEGA_CTRL_UP+SEGA_CTRL_LEFT: 219 | row = 0; 220 | column = 0; 221 | break; 222 | case SEGA_CTRL_DOWN+SEGA_CTRL_LEFT: 223 | row = 2; 224 | column = 0; 225 | break; 226 | case SEGA_CTRL_RIGHT: 227 | row = 1; 228 | column = 2; 229 | break; 230 | case SEGA_CTRL_UP+SEGA_CTRL_RIGHT: 231 | row = 0; 232 | column = 2; 233 | break; 234 | case SEGA_CTRL_DOWN+SEGA_CTRL_RIGHT: 235 | row = 2; 236 | column = 2; 237 | break; 238 | default: 239 | row = 1; 240 | column = 1; 241 | break; 242 | } 243 | buttons = 0; 244 | 245 | Choice_of_Row(row); 246 | Choice_of_Column(column); 247 | 248 | test = Check_Move( Pick_Row(), Pick_Column()); 249 | if (test == 0) 250 | { 251 | // invalid move 252 | continue; 253 | } 254 | Tic_Tac_Toe_Board(); 255 | 256 | check = Check_Board(); 257 | if ( (check == 1) || (check == 2) ) 258 | { 259 | put_chr((check == 1) ? 'X' : 'O', 0x0000, 20-4, 3); 260 | put_str(" wins!", 0x0000, 20-3, 3); 261 | delay(240); 262 | put_str(" ", 0x0000, 20-4, 3); 263 | // reset the board 264 | Clear_Board(); 265 | } 266 | else if ( check == 3 ) 267 | { 268 | put_str("The game is tied", 0x0000, 20-8, 3); 269 | delay(240); 270 | put_str(" ", 0x0000, 20-8, 3); 271 | // reset the board 272 | Clear_Board(); 273 | } 274 | 275 | if ( player == 1) 276 | { 277 | player = 2; 278 | } 279 | else 280 | { 281 | player = 1; 282 | } 283 | Choice_by_Player(player); 284 | 285 | } // end of outer while loop 286 | 287 | clear_screen (); 288 | return 0; 289 | } // end of main function 290 | 291 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/ToolBox.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | 26 | #pragma hdrstop 27 | 28 | #include "ToolBox.h" 29 | 30 | //--------------------------------------------------------------------------- 31 | 32 | #pragma package(smart_init) 33 | 34 | TRect RectNormalize(TRect* ARect) 35 | { 36 | return Rect( 37 | Min((int)ARect->Left, ARect->Right), 38 | Min((int)ARect->Top , ARect->Bottom), 39 | Max((int)ARect->Left, ARect->Right), 40 | Max((int)ARect->Top , ARect->Bottom) 41 | ); 42 | } 43 | 44 | TRect RectInflate(TRect* ARect, int X, int Y) 45 | { 46 | return Rect( 47 | ARect->Left - X, 48 | ARect->Top - Y, 49 | ARect->Right + X, 50 | ARect->Bottom + Y 51 | ); 52 | } 53 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/ToolBox.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | #ifndef ToolBoxH 26 | #define ToolBoxH 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | TRect RectNormalize(TRect* ARect); 33 | TRect RectInflate(TRect* ARect, int X, int Y); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/UnitMain.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #ifndef UnitMainH 40 | #define UnitMainH 41 | //--------------------------------------------------------------------------- 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include "../src/game.h" 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | //--------------------------------------------------------------------------- 54 | class TFormMain : public TForm 55 | { 56 | __published: // IDE-managed Components 57 | TStatusBar *StatusBar; 58 | TToolBar *ToolBar; 59 | TPanel *PanelClient; 60 | TScrollBox *ScrollBox; 61 | TMainMenu *MainMenu; 62 | TMenuItem *MIFile; 63 | TMenuItem *MINew; 64 | TMenuItem *MIOpen; 65 | TMenuItem *N1; 66 | TMenuItem *MISave; 67 | TMenuItem *MISaveAs; 68 | TMenuItem *N2; 69 | TMenuItem *MIExit; 70 | TMenuItem *MIEdit; 71 | TMenuItem *MIHelp; 72 | TToolButton *TBNew; 73 | TToolButton *TBOpen; 74 | TToolButton *TBSave; 75 | TToolButton *ToolButton4; 76 | TToolButton *TBCut; 77 | TToolButton *TBCopy; 78 | TToolButton *TBPaste; 79 | TToolButton *TBDelete; 80 | TToolButton *ToolButton9; 81 | TToolButton *TBArrow; 82 | TToolButton *TBDraw; 83 | TPanel *PanelScene; 84 | TPaintBox *PaintBox; 85 | TMenuItem *MIAbout; 86 | TImageList *ImageList; 87 | TSaveDialog *ExportDialog; 88 | TMenuItem *N3; 89 | TMenuItem *ExportCFile; 90 | TSaveDialog *SaveDialog; 91 | TOpenDialog *OpenDialog; 92 | TPanel *PanelCamera; 93 | TMenuItem *MIUndo; 94 | TMenuItem *MIRedo; 95 | TMenuItem *N4; 96 | TMenuItem *MICut; 97 | TMenuItem *MICopy; 98 | TMenuItem *MIPaste; 99 | TMenuItem *MIDelete; 100 | TMenuItem *N5; 101 | TMenuItem *MISelectAll; 102 | TPageControl *PageControl; 103 | TTabSheet *TSTextures; 104 | TSplitter *Splitter; 105 | TListView *ListView; 106 | TImageList *ILTextures; 107 | TToolButton *ToolButton1; 108 | TToolButton *ToolButton2; 109 | TToolButton *ToolButton3; 110 | void __fastcall FormCreate(TObject *Sender); 111 | void __fastcall FormPaint(TObject *Sender); 112 | void __fastcall PaintBoxPaint(TObject *Sender); 113 | void __fastcall ScrollBoxResize(TObject *Sender); 114 | void __fastcall MIExitClick(TObject *Sender); 115 | void __fastcall PaintBoxMouseMove(TObject *Sender, TShiftState Shift, 116 | int X, int Y); 117 | void __fastcall PaintBoxMouseDown(TObject *Sender, TMouseButton Button, 118 | TShiftState Shift, int X, int Y); 119 | void __fastcall PaintBoxMouseUp(TObject *Sender, TMouseButton Button, 120 | TShiftState Shift, int X, int Y); 121 | void __fastcall FormKeyDown(TObject *Sender, WORD &Key, 122 | TShiftState Shift); 123 | void __fastcall FormKeyUp(TObject *Sender, WORD &Key, TShiftState Shift); 124 | void __fastcall ExportCFileClick(TObject *Sender); 125 | void __fastcall MISaveAsClick(TObject *Sender); 126 | void __fastcall MIOpenClick(TObject *Sender); 127 | void __fastcall MINewClick(TObject *Sender); 128 | void __fastcall TBNewClick(TObject *Sender); 129 | void __fastcall TBOpenClick(TObject *Sender); 130 | void __fastcall TBSaveClick(TObject *Sender); 131 | void __fastcall MISaveClick(TObject *Sender); 132 | void __fastcall MIAboutClick(TObject *Sender); 133 | void __fastcall FormCloseQuery(TObject *Sender, bool &CanClose); 134 | void __fastcall ToolButton2Click(TObject *Sender); 135 | void __fastcall ToolButton3Click(TObject *Sender); 136 | void __fastcall ListViewChange(TObject *Sender, TListItem *Item, 137 | TItemChange Change); 138 | private: // User declarations 139 | public: // User declarations 140 | __fastcall TFormMain(TComponent* Owner); 141 | 142 | bool tc; 143 | bool Modified; 144 | String FileName; 145 | rom_map_t rommap; 146 | yeti_t* yeti; 147 | bool LButton; 148 | bool RButton; 149 | int Zoom; 150 | TRect Selection; 151 | void SetZoom(int AZoom); 152 | TRect CellRect(int x, int y); 153 | void CellDraw(int x, int y); 154 | void SetFileName(String AFileName); 155 | void SaveToFile(String AFileName); 156 | void LoadFromFile(String AFileName); 157 | }; 158 | //--------------------------------------------------------------------------- 159 | extern PACKAGE TFormMain *FormMain; 160 | //--------------------------------------------------------------------------- 161 | #endif 162 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/UnitPreview.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #include 40 | #pragma hdrstop 41 | 42 | #include "UnitPreview.h" 43 | #include "UnitMain.h" 44 | //--------------------------------------------------------------------------- 45 | #pragma package(smart_init) 46 | #pragma resource "*.dfm" 47 | TFormPreview *FormPreview; 48 | //--------------------------------------------------------------------------- 49 | __fastcall TFormPreview::TFormPreview(TComponent* Owner): TForm(Owner){} 50 | //--------------------------------------------------------------------------- 51 | void __fastcall TFormPreview::FormCreate(TObject *Sender) 52 | { 53 | Timer->Interval = YETI_VIEWPORT_INTERVAL; 54 | 55 | Bitmap = new Graphics::TBitmap; 56 | 57 | Bitmap->PixelFormat = pf16bit; 58 | Bitmap->Width = YETI_VIEWPORT_WIDTH; 59 | Bitmap->Height = YETI_VIEWPORT_HEIGHT; 60 | 61 | ClientWidth = Bitmap->Width; 62 | ClientHeight = Bitmap->Height; 63 | 64 | SetBounds( 65 | Screen->DesktopWidth - Width - 16, 66 | Screen->DesktopHeight - Height - 16, 67 | Width, Height); 68 | 69 | yeti_init(&yeti, &framebuffer, &framebuffer, textures, palette, lua); 70 | game_init(&yeti); 71 | yeti_default_lighting(&yeti); 72 | 73 | FormMain->yeti = &yeti; 74 | } 75 | //--------------------------------------------------------------------------- 76 | void __fastcall TFormPreview::TimerTimer(TObject *Sender) 77 | { 78 | memset(&framebuffer, 0, sizeof(framebuffer)); 79 | game_loop(&yeti); 80 | viewport_to_video( 81 | (u16*) Bitmap->ScanLine[0], 82 | (int) Bitmap->ScanLine[1] - (int) Bitmap->ScanLine[0], 83 | &yeti.viewport, 84 | 31 << 11, 31 << 6, 31 << 0); 85 | FormPaint(this); 86 | FormMain->PanelCamera->SetBounds( 87 | f2fl(yeti.camera->x) * FormMain->Zoom - 2, 88 | (YETI_MAP_HEIGHT - f2fl(yeti.camera->y) - 0) * FormMain->Zoom - 2, 89 | 5, 5); 90 | 91 | FormMain->ScrollBox->ScrollInView(FormMain->PanelCamera); 92 | } 93 | //--------------------------------------------------------------------------- 94 | void __fastcall TFormPreview::FormPaint(TObject *Sender) 95 | { 96 | Canvas->Draw(0, 0, Bitmap); 97 | } 98 | //--------------------------------------------------------------------------- 99 | void __fastcall TFormPreview::FormKeyDown(TObject *Sender, WORD &Key, TShiftState Shift) 100 | { 101 | FormMain->OnKeyDown(FormMain, Key, Shift); 102 | } 103 | //--------------------------------------------------------------------------- 104 | 105 | void __fastcall TFormPreview::FormKeyUp(TObject *Sender, WORD &Key, TShiftState Shift) 106 | { 107 | FormMain->OnKeyUp(FormMain, Key, Shift); 108 | } 109 | //--------------------------------------------------------------------------- 110 | 111 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/UnitPreview.dfm: -------------------------------------------------------------------------------- 1 | object FormPreview: TFormPreview 2 | Left = 795 3 | Top = 451 4 | BorderIcons = [] 5 | BorderStyle = bsToolWindow 6 | Caption = 'Yeti3D Preview Window' 7 | ClientHeight = 172 8 | ClientWidth = 221 9 | Color = clBlack 10 | Font.Charset = DEFAULT_CHARSET 11 | Font.Color = clWindowText 12 | Font.Height = -11 13 | Font.Name = 'MS Sans Serif' 14 | Font.Style = [] 15 | FormStyle = fsStayOnTop 16 | KeyPreview = True 17 | OldCreateOrder = False 18 | Visible = True 19 | OnCreate = FormCreate 20 | OnKeyDown = FormKeyDown 21 | OnKeyUp = FormKeyUp 22 | OnPaint = FormPaint 23 | PixelsPerInch = 96 24 | TextHeight = 13 25 | object Timer: TTimer 26 | OnTimer = TimerTimer 27 | Left = 8 28 | Top = 8 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/UnitPreview.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #ifndef UnitPreviewH 40 | #define UnitPreviewH 41 | //--------------------------------------------------------------------------- 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include "../src/game.h" 48 | //--------------------------------------------------------------------------- 49 | class TFormPreview : public TForm 50 | { 51 | __published: // IDE-managed Components 52 | TTimer *Timer; 53 | void __fastcall TimerTimer(TObject *Sender); 54 | void __fastcall FormPaint(TObject *Sender); 55 | void __fastcall FormCreate(TObject *Sender); 56 | void __fastcall FormKeyDown(TObject *Sender, WORD &Key, 57 | TShiftState Shift); 58 | void __fastcall FormKeyUp(TObject *Sender, WORD &Key, TShiftState Shift); 59 | private: // User declarations 60 | public: // User declarations 61 | framebuffer_t framebuffer; 62 | yeti_t yeti; 63 | Graphics::TBitmap* Bitmap; 64 | __fastcall TFormPreview(TComponent* Owner); 65 | }; 66 | //--------------------------------------------------------------------------- 67 | extern PACKAGE TFormPreview *FormPreview; 68 | //--------------------------------------------------------------------------- 69 | #endif 70 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/YetiEditor.bpr: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | [Version Info] 66 | IncludeVerInfo=0 67 | AutoIncBuild=0 68 | MajorVer=1 69 | MinorVer=0 70 | Release=0 71 | Build=0 72 | Debug=0 73 | PreRelease=0 74 | Special=0 75 | Private=0 76 | DLL=0 77 | Locale=1033 78 | CodePage=1252 79 | 80 | [Version Info Keys] 81 | CompanyName= 82 | FileDescription= 83 | FileVersion=1.0.0.0 84 | InternalName= 85 | LegalCopyright= 86 | LegalTrademarks= 87 | OriginalFilename= 88 | ProductName= 89 | ProductVersion=1.0.0.0 90 | Comments= 91 | 92 | [HistoryLists\hlIncludePath] 93 | Count=2 94 | Item0=..\src;$(BCB)\include;$(BCB)\include\vcl 95 | Item1=$(BCB)\include;$(BCB)\include\vcl 96 | 97 | [HistoryLists\hlLibraryPath] 98 | Count=2 99 | Item0=..\src;$(BCB)\lib\obj;$(BCB)\lib 100 | Item1=$(BCB)\lib\obj;$(BCB)\lib 101 | 102 | [HistoryLists\hlDebugSourcePath] 103 | Count=1 104 | Item0=$(BCB)\source\vcl 105 | 106 | [HistoryLists\hlConditionals] 107 | Count=4 108 | Item0=__YETI_EDITOR__ 109 | Item1=__YETI_EDITOR__;_DEBUG 110 | Item2=_DEBUG;__YETI_EDITOR__ 111 | Item3=_DEBUG 112 | 113 | [Debugging] 114 | DebugSourceDirs=$(BCB)\source\vcl 115 | 116 | [Parameters] 117 | RunParams= 118 | Launcher= 119 | UseLauncher=0 120 | DebugCWD= 121 | HostApplication= 122 | RemoteHost= 123 | RemotePath= 124 | RemoteLauncher= 125 | RemoteCWD= 126 | RemoteDebug=0 127 | 128 | [Compiler] 129 | ShowInfoMsgs=0 130 | LinkDebugVcl=0 131 | 132 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/YetiEditor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | #include 26 | #pragma hdrstop 27 | //--------------------------------------------------------------------------- 28 | USEFORM("UnitMain.cpp", FormMain); 29 | USEFORM("UnitPreview.cpp", FormPreview); 30 | //--------------------------------------------------------------------------- 31 | WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) 32 | { 33 | try 34 | { 35 | Application->Initialize(); 36 | Application->Title = "Yeti3D Editor"; 37 | Application->CreateForm(__classid(TFormMain), &FormMain); 38 | Application->CreateForm(__classid(TFormPreview), &FormPreview); 39 | Application->Run(); 40 | } 41 | catch (Exception &exception) 42 | { 43 | Application->ShowException(&exception); 44 | } 45 | catch (...) 46 | { 47 | try 48 | { 49 | throw Exception(""); 50 | } 51 | catch (Exception &exception) 52 | { 53 | Application->ShowException(&exception); 54 | } 55 | } 56 | return 0; 57 | } 58 | //--------------------------------------------------------------------------- 59 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/default.y3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/editor/default.y3d -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/readme.txt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | YETI3D EDITOR 26 | ============= 27 | 28 | This is the first version of the Yeti3D Editor. Its very ruff, but usable. The 29 | editing keys are the same as the CUBE world editor. 30 | 31 | There are two editing modes. Selection and Wall Drawing. (Swap modes using the toolbar buttons). 32 | 33 | Wall Drawing is used to get a ruff wall layout using the mouse. Left button draws a wall, 34 | right button deletes a wall. 35 | 36 | Selection allows you to select a range of cells for editing using the keys below. 37 | 38 | O = Move Ceiling down 39 | P = Move Ceiling up 40 | [ = Move Floor down 41 | ] = Move Floor up 42 | 43 | INSERT = Floor texture id incease. 44 | DELETE = Floor texture id decrease. 45 | HOME = Wall texture id increase. 46 | END = Wall texture id decrease. 47 | PAGE UP = Ceiling texture id increase. 48 | PAGE DN = Ceiling texture id decrease. 49 | 50 | L = Toggle the light switch for the selected cells. 51 | F = Fill the selected cells with walls. 52 | G = Clear the selected cells. 53 | E = Insert entity id. Enter the entity id from 0..255. 0 = no entity. Entities show up as 54 | little green circles in cells. 55 | 56 | ARROWS = Camera movement. 57 | SPACE = Camera Jump. 58 | CTRL = Shoot. 59 | 60 | Loading and saving are avaliable from the menu. You will need to export maps to C files so 61 | they can be reloaded. NOTE: You can not load exported C files. You must save maps as y3d files. 62 | 63 | DESIGN TIPS 64 | =========== 65 | 66 | Start a new map using the NEW command from the menu. Switch to WALL drawing mode using the toolbar 67 | button. 68 | 69 | Sketch a ruff layout of your map plan. ie: Major & minor rooms/locations. Outside/Inside locations 70 | & hallways/passages linking the player to each. You dont need to use up the entire map, as empty 71 | spaces can later be used for hidden rooms/extra bonus levels. 72 | 73 | Give the player a sence of direction & add multiple paths so a player can skip areas that may be 74 | difficult to pass. 75 | 76 | Add lighting. I tend to find lighing door ways the best idea since it allows the player to see 77 | were to go without lighting the entire world. Placing lights 2 cells away from walls gives nicer 78 | spots on the floor. Group lights together to increase the brightness of a light. 79 | 80 | WARNINGS! 81 | 82 | >>>> MAKE SURE YOU SAVE YOUR MAPS & BACKUP! 83 | >>>> FOR NOW, DONT EDIT THE EDGES OF THE MAP. LIGHT RAYS WILL SHOOT OUT INTO NOWHERE. 84 | 85 | This is a very ruff copy of the editor, so play it safe. Organsize map names from the start. 86 | ie: E2M1.y3d E1M5.y3d 87 | 88 | Mmm, thats about it. This version only has ~30 textures and they are Quake's, so they need to be 89 | changed. 90 | 91 | Regards 92 | Derek Evans 93 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/test0.y3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/editor/test0.y3d -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/test1.y3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/editor/test1.y3d -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/test2.y3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/editor/test2.y3d -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/editor/test3.y3d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/editor/test3.y3d -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/32x.h: -------------------------------------------------------------------------------- 1 | #ifndef __32X_H__ 2 | #define __32X_H__ 3 | 4 | /* Create a 5:5:5 RGB color with the MSB set */ 5 | #define COLOR(r,g,b) (((r)&0x1F)|((g)&0x1F)<<5|((b)&0x1F)<<10|0x8000) 6 | 7 | #define MARS_CRAM (*(volatile unsigned short *)0x20004200) 8 | #define MARS_FRAMEBUFFER (*(volatile unsigned short *)0x24000000) 9 | #define MARS_OVERWRITE_IMG (*(volatile unsigned short *)0x24020000) 10 | #define MARS_SDRAM (*(volatile unsigned short *)0x26000000) 11 | 12 | #define MARS_SYS_INTMSK (*(volatile unsigned short *)0x20004000) 13 | #define MARS_SYS_DMACTR (*(volatile unsigned short *)0x20004006) 14 | #define MARS_SYS_DMASAR (*(volatile unsigned long *)0x20004008) 15 | #define MARS_SYS_DMADAR (*(volatile unsigned long *)0x2000400C) 16 | #define MARS_SYS_DMALEN (*(volatile unsigned short *)0x20004010) 17 | #define MARS_SYS_DMAFIFO (*(volatile unsigned short *)0x20004012) 18 | #define MARS_SYS_VRESI_CLR (*(volatile unsigned short *)0x20004014) 19 | #define MARS_SYS_VINT_CLR (*(volatile unsigned short *)0x20004016) 20 | #define MARS_SYS_HINT_CLR (*(volatile unsigned short *)0x20004018) 21 | #define MARS_SYS_CMDI_CLR (*(volatile unsigned short *)0x2000401A) 22 | #define MARS_SYS_PWMI_CLR (*(volatile unsigned short *)0x2000401C) 23 | #define MARS_SYS_COMM0 (*(volatile unsigned short *)0x20004020) /* Master SH2 communication */ 24 | #define MARS_SYS_COMM2 (*(volatile unsigned short *)0x20004022) 25 | #define MARS_SYS_COMM4 (*(volatile unsigned short *)0x20004024) /* Slave SH2 communication */ 26 | #define MARS_SYS_COMM6 (*(volatile unsigned short *)0x20004026) 27 | #define MARS_SYS_COMM8 (*(volatile unsigned short *)0x20004028) /* controller 1 current value */ 28 | #define MARS_SYS_COMM10 (*(volatile unsigned short *)0x2000402A) /* controller 2 current value */ 29 | #define MARS_SYS_COMM12 (*(volatile unsigned long *)0x2000402C) /* vcount current value */ 30 | 31 | #define MARS_PWM_CTRL (*(volatile unsigned short *)0x20004030) 32 | #define MARS_PWM_CYCLE (*(volatile unsigned short *)0x20004032) 33 | #define MARS_PWM_LEFT (*(volatile unsigned short *)0x20004034) 34 | #define MARS_PWM_RIGHT (*(volatile unsigned short *)0x20004036) 35 | #define MARS_PWM_MONO (*(volatile unsigned short *)0x20004038) 36 | 37 | #define MARS_VDP_DISPMODE (*(volatile unsigned short *)0x20004100) 38 | #define MARS_VDP_FILLEN (*(volatile unsigned short *)0x20004104) 39 | #define MARS_VDP_FILADR (*(volatile unsigned short *)0x20004106) 40 | #define MARS_VDP_FILDAT (*(volatile unsigned short *)0x20004108) 41 | #define MARS_VDP_FBCTL (*(volatile unsigned short *)0x2000410A) 42 | 43 | #define MARS_SH2_ACCESS_VDP 0x8000 44 | #define MARS_68K_ACCESS_VDP 0x0000 45 | 46 | #define MARS_PAL_FORMAT 0x0000 47 | #define MARS_NTSC_FORMAT 0x8000 48 | 49 | #define MARS_VDP_PRIO_68K 0x0000 50 | #define MARS_VDP_PRIO_32X 0x0080 51 | 52 | #define MARS_224_LINES 0x0000 53 | #define MARS_240_LINES 0x0040 54 | 55 | #define MARS_VDP_MODE_OFF 0x0000 56 | #define MARS_VDP_MODE_256 0x0001 57 | #define MARS_VDP_MODE_32K 0x0002 58 | #define MARS_VDP_MODE_RLE 0x0003 59 | 60 | #define MARS_VDP_VBLK 0x8000 61 | #define MARS_VDP_HBLK 0x4000 62 | #define MARS_VDP_PEN 0x2000 63 | #define MARS_VDP_FEN 0x0002 64 | #define MARS_VDP_FS 0x0001 65 | 66 | #define SH2_CCTL_CP 0x10 67 | #define SH2_CCTL_TW 0x08 68 | #define SH2_CCTL_CE 0x01 69 | 70 | #define SH2_FRT_TIER (*(volatile unsigned char *)0xFFFFFE10) 71 | #define SH2_FRT_FTCSR (*(volatile unsigned char *)0xFFFFFE11) 72 | #define SH2_FRT_FRCH (*(volatile unsigned char *)0xFFFFFE12) 73 | #define SH2_FRT_FRCL (*(volatile unsigned char *)0xFFFFFE13) 74 | #define SH2_FRT_OCRH (*(volatile unsigned char *)0xFFFFFE14) 75 | #define SH2_FRT_OCRL (*(volatile unsigned char *)0xFFFFFE15) 76 | #define SH2_FRT_TCR (*(volatile unsigned char *)0xFFFFFE16) 77 | #define SH2_FRT_TOCR (*(volatile unsigned char *)0xFFFFFE17) 78 | #define SH2_FRT_ICRH (*(volatile unsigned char *)0xFFFFFE18) 79 | #define SH2_FRT_ICRL (*(volatile unsigned char *)0xFFFFFE19) 80 | 81 | #define SH2_DMA_SAR0 (*(volatile unsigned long *)0xFFFFFF80) 82 | #define SH2_DMA_DAR0 (*(volatile unsigned long *)0xFFFFFF84) 83 | #define SH2_DMA_TCR0 (*(volatile unsigned long *)0xFFFFFF88) 84 | #define SH2_DMA_CHCR0 (*(volatile unsigned long *)0xFFFFFF8C) 85 | #define SH2_DMA_VCR0 (*(volatile unsigned long *)0xFFFFFFA0) 86 | #define SH2_DMA_DRCR0 (*(volatile unsigned char *)0xFFFFFE71) 87 | 88 | #define SH2_DMA_SAR1 (*(volatile unsigned long *)0xFFFFFF90) 89 | #define SH2_DMA_DAR1 (*(volatile unsigned long *)0xFFFFFF94) 90 | #define SH2_DMA_TCR1 (*(volatile unsigned long *)0xFFFFFF98) 91 | #define SH2_DMA_CHCR1 (*(volatile unsigned long *)0xFFFFFF9C) 92 | #define SH2_DMA_VCR1 (*(volatile unsigned long *)0xFFFFFFA8) 93 | #define SH2_DMA_DRCR1 (*(volatile unsigned char *)0xFFFFFE72) 94 | 95 | #define SH2_DMA_DMAOR (*(volatile unsigned long *)0xFFFFFFB0) 96 | 97 | #define SH2_INT_IPRA (*(volatile unsigned short *)0xFFFFFEE2) 98 | 99 | #define SEGA_CTRL_UP 0x0001 100 | #define SEGA_CTRL_DOWN 0x0002 101 | #define SEGA_CTRL_LEFT 0x0004 102 | #define SEGA_CTRL_RIGHT 0x0008 103 | #define SEGA_CTRL_B 0x0010 104 | #define SEGA_CTRL_C 0x0020 105 | #define SEGA_CTRL_A 0x0040 106 | #define SEGA_CTRL_START 0x0080 107 | #define SEGA_CTRL_Z 0x0100 108 | #define SEGA_CTRL_Y 0x0200 109 | #define SEGA_CTRL_X 0x0400 110 | #define SEGA_CTRL_MODE 0x0800 111 | 112 | #define SEGA_CTRL_TYPE 0xF000 113 | #define SEGA_CTRL_THREE 0x0000 114 | #define SEGA_CTRL_SIX 0x1000 115 | #define SEGA_CTRL_NONE 0xF000 116 | 117 | 118 | /* global functions in sh2_crt0.s */ 119 | extern void fast_memcpy(void *dst, void *src, int len); 120 | extern void CacheControl(int mode); 121 | extern void CacheClearLine(void* ptr); 122 | extern void ScreenStretch(int src, int width, int height, int interp); 123 | 124 | 125 | #endif 126 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/Makefile: -------------------------------------------------------------------------------- 1 | MDLD = m68k-elf-ld 2 | MDAS = m68k-elf-as 3 | SHLD = sh-elf-ld 4 | SHCC = sh-elf-gcc 5 | SHAS = sh-elf-as 6 | RM = rm -f 7 | 8 | export VPATH := $(CURDIR) $(CURDIR)/../../src 9 | 10 | FLAGS = -m2 -mb -O6 -Wall -g -fomit-frame-pointer -D__MARS__ -DDBL_PIXEL 11 | HWFLAGS = -m2 -mb -O1 -Wall -g -fomit-frame-pointer -D__MARS__ -DDBL_PIXEL 12 | LDFLAGS = -T $(GENDEV)/ldscripts/mars.ld -Map output.map -relax -small -e _start --oformat binary 13 | 14 | INCS = -I. -I./../../src -I$(GENDEV)/sh-elf/include -I$(GENDEV)/sh-elf/sh-elf/include 15 | 16 | LIBS = -L$(GENDEV)/sh-elf/sh-elf/lib -L$(GENDEV)/sh-elf/lib/gcc/sh-elf/$(GENDEV_GCC_VERSION) -lm -lc -lgcc -lgcc-Os-4-200 17 | 18 | OBJS = sh2_crt0.o main.o data.o draw.o game.o maps.o sprites.o yeti.o module.o sound.o hw_32x.o font.o files-psyg.o 19 | 20 | all: m68k_crt0.bin m68k_crt1.bin hw_32x.o YETI3D-32X.bin 21 | 22 | YETI3D-32X.bin: $(OBJS) 23 | $(SHLD) $(LDFLAGS) -o temp.bin $(OBJS) $(LIBS) 24 | dd if=temp.bin of=YETI3D-32X.bin bs=1024K conv=sync 25 | 26 | m68k_crt0.bin: m68k_crt0.s 27 | $(MDAS) -m68000 --register-prefix-optional -o m68k_crt0.o m68k_crt0.s 28 | $(MDLD) -T $(GENDEV)/ldscripts/md.ld --oformat binary -o m68k_crt0.bin m68k_crt0.o 29 | 30 | m68k_crt1.bin: m68k_crt1.s 31 | $(MDAS) -m68000 --register-prefix-optional -o m68k_crt1.o m68k_crt1.s 32 | $(MDLD) -T $(GENDEV)/ldscripts/md.ld --oformat binary -o m68k_crt1.bin m68k_crt1.o 33 | 34 | hw_32x.o: hw_32x.c 35 | $(SHCC) $(HWFLAGS) -c $< -o $@ 36 | 37 | %.o: %.c 38 | $(SHCC) $(FLAGS) -c $< -o $@ 39 | 40 | %.o: %.s 41 | $(SHAS) -I. --small -o $@ $< 42 | 43 | clean: 44 | $(RM) -f *.o *.out *.bin *.map 45 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/files-psyg.s: -------------------------------------------------------------------------------- 1 | .text 2 | 3 | ! MODs for level music 4 | 5 | .align 2 6 | modName1: 7 | .asciz "SOTBeast2_2.MOD" 8 | modName2: 9 | .asciz "SOTBeast2_4.MOD" 10 | modName3: 11 | .asciz "SOTBeast2_5.MOD" 12 | 13 | .align 4 14 | mod1: 15 | .incbin "music/SOTBeast2_2.MOD" 16 | modEnd1: 17 | .align 4 18 | mod2: 19 | .incbin "music/SOTBeast2_4.MOD" 20 | modEnd2: 21 | .align 4 22 | mod3: 23 | .incbin "music/SOTBeast2_5.MOD" 24 | modEnd3: 25 | 26 | .align 4 27 | 28 | .global _modName 29 | _modName: 30 | .long modName1 31 | .long modName2 32 | .long modName3 33 | 34 | .global _modSize 35 | _modSize: 36 | .long modEnd1 - mod1 37 | .long modEnd2 - mod2 38 | .long modEnd3 - mod3 39 | 40 | .global _modPtr 41 | _modPtr: 42 | .long mod1 43 | .long mod2 44 | .long mod3 45 | 46 | 47 | ! SFXs for game sounds 48 | 49 | .align 2 50 | sfxName1: 51 | .asciz "pl-oof.raw" 52 | sfxName2: 53 | .asciz "pl-sht.raw" 54 | sfxName3: 55 | .asciz "pl-pain.raw" 56 | sfxName4: 57 | .asciz "pl-dth.raw" 58 | sfxName5: 59 | .asciz "en-near.raw" 60 | sfxName6: 61 | .asciz "en-atk.raw" 62 | sfxName7: 63 | .asciz "en-pain.raw" 64 | sfxName8: 65 | .asciz "en-dth.raw" 66 | 67 | .align 4 68 | sfx1: 69 | .incbin "sounds/pl-oof.raw" 70 | sfxEnd1: 71 | .align 4 72 | sfx2: 73 | .incbin "sounds/pl-sht.raw" 74 | sfxEnd2: 75 | .align 4 76 | sfx3: 77 | .incbin "sounds/pl-pain.raw" 78 | sfxEnd3: 79 | .align 4 80 | sfx4: 81 | .incbin "sounds/pl-dth.raw" 82 | sfxEnd4: 83 | .align 4 84 | sfx5: 85 | .incbin "sounds/en-near.raw" 86 | sfxEnd5: 87 | .align 4 88 | sfx6: 89 | .incbin "sounds/en-atk.raw" 90 | sfxEnd6: 91 | .align 4 92 | sfx7: 93 | .incbin "sounds/en-pain.raw" 94 | sfxEnd7: 95 | .align 4 96 | sfx8: 97 | .incbin "sounds/en-dth.raw" 98 | sfxEnd8: 99 | 100 | .align 4 101 | 102 | .global _sfxName 103 | _sfxName: 104 | .long sfxName1 105 | .long sfxName2 106 | .long sfxName3 107 | .long sfxName4 108 | .long sfxName5 109 | .long sfxName6 110 | .long sfxName7 111 | .long sfxName8 112 | 113 | .global _sfxSize 114 | _sfxSize: 115 | .long sfxEnd1 - sfx1 116 | .long sfxEnd2 - sfx2 117 | .long sfxEnd3 - sfx3 118 | .long sfxEnd4 - sfx4 119 | .long sfxEnd5 - sfx5 120 | .long sfxEnd6 - sfx6 121 | .long sfxEnd7 - sfx7 122 | .long sfxEnd8 - sfx8 123 | 124 | .global _sfxPtr 125 | _sfxPtr: 126 | .long sfx1 127 | .long sfx2 128 | .long sfx3 129 | .long sfx4 130 | .long sfx5 131 | .long sfx6 132 | .long sfx7 133 | .long sfx8 134 | 135 | .align 4 136 | 137 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/files.h: -------------------------------------------------------------------------------- 1 | #define NUM_MODS 3 2 | 3 | extern char *modName[NUM_MODS]; 4 | extern int modSize[NUM_MODS]; 5 | extern int modPtr[NUM_MODS]; 6 | 7 | #define NUM_SFX 8 8 | 9 | extern char *sfxName[NUM_SFX]; 10 | extern int sfxSize[NUM_SFX]; 11 | extern int sfxPtr[NUM_SFX]; 12 | 13 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/hw_32x.h: -------------------------------------------------------------------------------- 1 | #ifndef HW_32X_H 2 | #define HW_32X_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | extern void Hw32xSetFGColor(int s, int r, int g, int b); 9 | extern void Hw32xSetBGColor(int s, int r, int g, int b); 10 | extern void Hw32xInit(int vmode, int lineskip); 11 | extern int Hw32xScreenGetX(); 12 | extern int Hw32xScreenGetY(); 13 | extern void Hw32xScreenSetXY(int x, int y); 14 | extern void Hw32xScreenClear(); 15 | extern void Hw32xScreenPutChar(int x, int y, unsigned char ch); 16 | extern void Hw32xScreenClearLine(int Y); 17 | extern int Hw32xScreenPrintData(const char *buff, int size); 18 | extern int Hw32xScreenPuts(const char *str); 19 | extern void Hw32xScreenPrintf(const char *format, ...); 20 | extern void Hw32xDelay(int ticks); 21 | extern void Hw32xScreenFlip(int wait); 22 | extern void Hw32xFlipWait(); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/m68k_crt0.s: -------------------------------------------------------------------------------- 1 | | SEGA 32X support code for the 68000 2 | | by Chilly Willy 3 | | First part of rom header 4 | 5 | .text 6 | 7 | | Initial exception vectors. When the console is first turned on, it is 8 | | in MegaDrive mode. All vectors just point to the code to start up the 9 | | Mars adapter. After the adapter is enabled, none of these vectors will 10 | | appear as the adpater uses its own vector table to route exceptions to 11 | | the jump table. 0x3F0 is where the 68000 starts at for the 32X. 12 | 13 | .long 0x01000000,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 14 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 15 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 16 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 17 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 18 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 19 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 20 | .long 0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0,0x000003F0 21 | 22 | | Standard MegaDrive ROM header at 0x100 23 | 24 | .ascii "SEGA GENESIS " 25 | .ascii "(C)SEGA 2010.JUL" 26 | .ascii "32X Yeti3D Demo " 27 | .ascii " " 28 | .ascii " " 29 | .ascii "32X Yeti3D Demo " 30 | .ascii " " 31 | .ascii " " 32 | .ascii "GM MK-0000 -00" 33 | .word 0x0000 34 | .ascii "J6 " 35 | .long 0x00000000,0x003FFFFF /* ROM start, end */ 36 | .long 0x00FF0000,0x00FFFFFF /* RAM start, end */ 37 | 38 | | .ascii "RA" /* External RAM */ 39 | | .byte 0xF8 /* don't clear + odd bytes */ 40 | | .byte 0x20 /* SRAM */ 41 | | .long 0x00200001,0x0020FFFF /* SRAM start, end */ 42 | 43 | .ascii " " /* no SRAM */ 44 | 45 | .ascii " " 46 | .ascii " " 47 | .ascii " " 48 | .ascii " " 49 | .ascii "F " /* enable any hardware configuration */ 50 | 51 | | Mars exception vector jump table at 0x200 52 | 53 | jmp 0x880800.l /* reset = hot start */ 54 | jsr 0x880806.l /* EX_BusError */ 55 | jsr 0x880806.l /* EX_AddrError */ 56 | jsr 0x880806.l /* EX_IllInstr */ 57 | jsr 0x880806.l /* EX_DivByZero */ 58 | jsr 0x880806.l /* EX_CHK */ 59 | jsr 0x880806.l /* EX_TrapV */ 60 | jsr 0x880806.l /* EX_Priviledge */ 61 | jsr 0x880806.l /* EX_Trace */ 62 | jsr 0x880806.l /* EX_LineA */ 63 | jsr 0x880806.l /* EX_LineF */ 64 | .space 72 /* reserved */ 65 | jsr 0x880806.l /* EX_Spurious */ 66 | jsr 0x880806.l /* EX_Level1 */ 67 | jsr 0x880806.l /* EX_Level2 */ 68 | jsr 0x880806.l /* EX_Level3 */ 69 | jmp 0x88080C.l /* EX_Level4 HBlank */ 70 | jsr 0x880806.l /* EX_Level5 */ 71 | jmp 0x880812.l /* EX_Level6 VBlank */ 72 | jsr 0x880806.l /* EX_Level7 */ 73 | jsr 0x880806.l /* EX_Trap0 */ 74 | jsr 0x880806.l /* EX_Trap1 */ 75 | jsr 0x880806.l /* EX_Trap2 */ 76 | jsr 0x880806.l /* EX_Trap3 */ 77 | jsr 0x880806.l /* EX_Trap4 */ 78 | jsr 0x880806.l /* EX_Trap5 */ 79 | jsr 0x880806.l /* EX_Trap6 */ 80 | jsr 0x880806.l /* EX_Trap7 */ 81 | jsr 0x880806.l /* EX_Trap8 */ 82 | jsr 0x880806.l /* EX_Trap9 */ 83 | jsr 0x880806.l /* EX_TrapA */ 84 | jsr 0x880806.l /* EX_TrapB */ 85 | jsr 0x880806.l /* EX_TrapC */ 86 | jsr 0x880806.l /* EX_TrapD */ 87 | jsr 0x880806.l /* EX_TrapE */ 88 | jsr 0x880806.l /* EX_TrapF */ 89 | .space 166 /* reserved */ 90 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/module.h: -------------------------------------------------------------------------------- 1 | #ifndef _MODULE_H_ 2 | #define _MODULE_H_ 3 | 4 | #include 5 | 6 | 7 | #define AMIGA_PAL_CPU_CLOCK ( 7093789 ) /* Hz unit (~7 MHz) */ 8 | 9 | #ifndef FALSE 10 | #define FALSE ( (uint8_t) 0 ) 11 | #endif 12 | #ifndef TRUE 13 | #define TRUE ( (uint8_t) 1 ) 14 | #endif 15 | 16 | /* MOD enum Constants */ 17 | #define MOD_SIGNATURE_LENGTH ( (uint8_t) 4 ) 18 | #define MOD_NAME_LENGTH ( (uint8_t) 20 ) 19 | #define MOD_SAMPLE_NAME_LENGTH ( (uint8_t) 22 ) 20 | #define MOD_NUMBER_OF_SAMPLES ( (uint8_t) 31 ) 21 | #define MOD_ROWS_PER_CHANNEL ( (uint8_t) 64 ) 22 | #define MOD_NUMBER_OF_ORDERS ( (uint8_t) 128 ) 23 | #define MOD_SIGNATURE_OFFSET ( (int16_t) 1080 ) /* 0x0438 */ 24 | #define MOD_FINE_TUNE_VALUES ( (uint8_t) 16 ) 25 | #define MOD_NUMBER_OF_NOTES ( (uint8_t) 36 ) 26 | #define MOD_NUMBER_OF_CHANNELS ( (uint8_t) 8 ) 27 | #define MOD_TIMER_SPEED ( (uint8_t) 50 ) /* timer speed, we need a speed of 50 Hz = 50 ticks per second */ 28 | 29 | /* EFFECTS */ 30 | #define EFFECT_ARPEGGIO ( (uint8_t) 0x00 ) /* Effect 0xy (Arpeggio) */ 31 | #define EFFECT_PORTA_UP ( (uint8_t) 0x01 ) /* Effect 1xy (Porta Up) */ 32 | #define EFFECT_PORTA_DOWN ( (uint8_t) 0x02 ) /* Effect 2xy (Porta Down) */ 33 | #define EFFECT_PORTA_TO_NOTE ( (uint8_t) 0x03 ) /* Effect 3xy (Porta To Note) */ 34 | #define EFFECT_VIBRATO ( (uint8_t) 0x04 ) /* Effect 4xy (Vibrato) */ 35 | #define EFFECT_PORTA_PLUS_VOL_SLIDE ( (uint8_t) 0x05 ) /* Effect 5xy (Porta + Vol Slide) */ 36 | #define EFFECT_VIBRATO_PLUS_VOL_SLIDE ( (uint8_t) 0x06 ) /* Effect 6xy (Vibrato + Vol Slide) */ 37 | #define EFFECT_TREMOLO ( (uint8_t) 0x07 ) /* Effect 7xy (Tremolo) */ 38 | #define EFFECT_PAN ( (uint8_t) 0x08 ) /* Effect 8xy (Pan) */ 39 | #define EFFECT_SAMPLE_OFFSET ( (uint8_t) 0x09 ) /* Effect 9xy (Sample Offset) */ 40 | #define EFFECT_VOLUME_SLIDE ( (uint8_t) 0x0A ) /* Effect Axy (Volume Slide) */ 41 | #define EFFECT_JUMP_TO_PATTERN ( (uint8_t) 0x0B ) /* Effect Bxy (Jump To Pattern) */ 42 | #define EFFECT_SET_VOLUME ( (uint8_t) 0x0C ) /* Effect Cxy (Set Volume) */ 43 | #define EFFECT_PATTERN_BREAK ( (uint8_t) 0x0D ) /* Effect Dxy (Pattern Break) */ 44 | #define EFFECT_EXTENDED_EFFECTS ( (uint8_t) 0x0E ) /* Extended Effects */ 45 | #define EFFECT_SET_SPEED ( (uint8_t) 0x0F ) /* Effect Fxy (Set Speed) */ 46 | 47 | #define EFFECT_SET_FILTER ( (uint8_t) 0x00 ) /* Effect E0x (Set Filter) */ 48 | #define EFFECT_FINE_PORTA_UP ( (uint8_t) 0x01 ) /* Effect E1x (Fine Porta Up) */ 49 | #define EFFECT_FINE_PORTA_DOWN ( (uint8_t) 0x02 ) /* Effect E2x (Fine Porta Down) */ 50 | #define EFFECT_GLISSANDO_CONTROL ( (uint8_t) 0x03 ) /* Effect E3x (Glissando Control) */ 51 | #define EFFECT_SET_VIBRATO_WAVEFORM ( (uint8_t) 0x04 ) /* Effect E4x (Set Vibrato Waveform) */ 52 | #define EFFECT_SET_FINETUNE ( (uint8_t) 0x05 ) /* Effect E5x (Set Finetune) */ 53 | #define EFFECT_PATTERN_LOOP ( (uint8_t) 0x06 ) /* Effect E6x (Pattern Loop) */ 54 | #define EFFECT_SET_TREMOLO_WAVEFORM ( (uint8_t) 0x07 ) /* Effect E7x (Set Tremolo WaveForm) */ 55 | #define EFFECT_POSITION_PANNING ( (uint8_t) 0x08 ) /* Effect E8x (Position Panning) */ 56 | #define EFFECT_RETRIG_NOTE ( (uint8_t) 0x09 ) /* Effect E9x (Retrig Note) */ 57 | #define EFFECT_FINE_VOLUME_SLIDE_UP ( (uint8_t) 0x0A ) /* Effect EAx (Fine Volume Slide Up) */ 58 | #define EFFECT_FINE_VOLUME_SLIDE_DOWN ( (uint8_t) 0x0B ) /* Effect EBx (Fine Volume Slide Down) */ 59 | #define EFFECT_CUT_NOTE ( (uint8_t) 0x0C ) /* Effect ECx (Cut Note) */ 60 | #define EFFECT_DELAY_NOTE ( (uint8_t) 0x0D ) /* Effect EDx (Delay Note) */ 61 | #define EFFECT_PATTERN_DELAY ( (uint8_t) 0x0E ) /* Effect EEx (Pattern Delay) */ 62 | #define EFFECT_INVERT_LOOP ( (uint8_t) 0x0F ) /* Effect EFx (Invert Loop) */ 63 | 64 | 65 | struct NoteTag 66 | { 67 | uint8_t SampleNumber; 68 | uint8_t EffectNumber; 69 | uint8_t EffectParameter; 70 | uint8_t NoteExists; /* boolean flag */ 71 | uint8_t PeriodFrequencyCol; /* column position in AmigaPeriodsTable[][] */ 72 | uint16_t PeriodFrequency; 73 | }; 74 | 75 | struct ChannelTag 76 | { 77 | uint8_t LastInstrument; 78 | int8_t Volume; /* default volume of sample */ 79 | uint8_t PortaSpeed; 80 | uint8_t VibratoSpeed; 81 | uint8_t VibratoDepth; 82 | uint8_t TremoloSpeed; 83 | uint8_t TremoloDepth; 84 | uint8_t WaveformControl; /* upper 4 bits for the tremolo wavecontrol, and the lower 4 bits for the vibrato wavecontrol */ 85 | int8_t VibratoPosition; 86 | int8_t TremoloPosition; 87 | uint8_t PatLoopRow; 88 | uint8_t PatLoopNo; 89 | int16_t PanValue; /* not used */ 90 | int16_t PeriodFrequency; 91 | int16_t PortaTo; /* note to port to value */ 92 | uint32_t SampleOffset; 93 | }; 94 | 95 | struct SampleTag 96 | { 97 | uint8_t FineTune; 98 | uint8_t Volume; 99 | 100 | int8_t* SampleBuff_p; /* pointer to the actual physical data in memory */ 101 | uint32_t LoopStart; 102 | uint32_t LoopLength; 103 | uint32_t SampleLength; /* The maximum size for a sample on the Amiga is 128K. */ 104 | }; 105 | 106 | /* main data structure */ 107 | struct ModTag 108 | { 109 | uint8_t IsPlaying; /* flags - b0 = 1 = playing, 0 = stopped; b7 = 1 = loop at end */ 110 | uint8_t SongLength; /* song length (1 to 128) */ 111 | uint8_t NumberOfPatterns; /* number of physical patterns (1 to 64) */ 112 | uint8_t NumberOfChannels; /* number of channels (4, 6, or 8) */ 113 | uint8_t Speed; /* number of ticks (or times the function is called) between each time a new row is processed */ 114 | uint8_t Tick; /* current music tick */ 115 | int8_t Row; /* current row number value 0-63 */ 116 | uint8_t Order; /* current value */ 117 | uint8_t Pattern; /* current value */ 118 | uint8_t PatternDelay; /* number of notes to delay pattern for */ 119 | 120 | uint16_t NumSamples; /* sets timing for beats per minute */ 121 | 122 | uint32_t* PatternsBuff_p; /* start of pattern data (1 to 64 * 1024) */ 123 | 124 | uint8_t Orders[ MOD_NUMBER_OF_ORDERS ]; /* pattern playing orders (128 entries of 0 to 63) */ 125 | 126 | struct SampleTag Inst[ MOD_NUMBER_OF_SAMPLES ]; /* instrument headers */ 127 | struct ChannelTag Channels[ MOD_NUMBER_OF_CHANNELS ]; /* run time channel info */ 128 | struct NoteTag Notes[ MOD_NUMBER_OF_CHANNELS ]; /* run time note info */ 129 | }; 130 | 131 | 132 | /* 133 | Initialize Module struct for playing 134 | returns 0 if no error 135 | */ 136 | uint8_t InitMOD(uint8_t* Data_p, struct ModTag* Mod_p); 137 | 138 | /* 139 | Cleanup MOD - stop playing and release voices 140 | */ 141 | void ExitMOD(struct ModTag* Mod_p); 142 | 143 | /* 144 | Start playing Module 145 | loop = bool = TRUE = loop forever, = FALSE = play once 146 | returns the previously playing Module, if any 147 | */ 148 | struct ModTag* StartMOD(struct ModTag* Mod_p, uint8_t loop); 149 | 150 | /* 151 | Pause/resume Module 152 | pause = bool = TRUE = pause, = FALSE = resume 153 | */ 154 | void PauseMOD(struct ModTag* Mod_p, uint8_t pause); 155 | 156 | /* 157 | Stop playing Module 158 | */ 159 | void StopMOD(struct ModTag* Mod_p); 160 | 161 | /* 162 | Wait for Module to play through once 163 | */ 164 | void WaitMOD(struct ModTag* Mod_p); 165 | 166 | /* 167 | Check Module play status 168 | returns 0 if done playing 169 | */ 170 | uint8_t CheckMOD(struct ModTag* Mod_p); 171 | 172 | /* 173 | Set global volume 174 | vol = 0 = off, = 16 = max 175 | returns the previous volume setting 176 | */ 177 | uint8_t VolumeMOD(uint8_t vol); 178 | 179 | 180 | #endif 181 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/music/SOTBeast2_2.MOD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/platform/32X/music/SOTBeast2_2.MOD -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/music/SOTBeast2_4.MOD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/platform/32X/music/SOTBeast2_4.MOD -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/music/SOTBeast2_5.MOD: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/platform/32X/music/SOTBeast2_5.MOD -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/sound.h: -------------------------------------------------------------------------------- 1 | #ifndef _SAMPLE_H_ 2 | #define _SAMPLE_H_ 3 | 4 | #include 5 | 6 | 7 | extern void fill_buffer(unsigned long buff); 8 | extern char snd_buffer[]; 9 | extern uint16_t svc_num_samples; 10 | 11 | #define NUM_SAMPLES svc_num_samples 12 | 13 | #ifdef CD_SAMPLE_RATE 14 | #define NUM_VOICES 8 15 | #define MAX_NUM_SAMPLES 1024 16 | #define SAMPLE_RATE 44100 17 | #define SAMPLE_CENTER 258 18 | #else 19 | #define NUM_VOICES 8 20 | #define MAX_NUM_SAMPLES 512 21 | #define SAMPLE_RATE 22050 22 | #define SAMPLE_CENTER 516 23 | #endif 24 | 25 | 26 | /* Sample Voice Flags */ 27 | #define VF_ENABLED 0x4000 /* voice is allocated and ready to use */ 28 | #define VF_ONESHOT 0x2000 /* automatically disable after playing (for sound effects mainly) */ 29 | #define VF_LOOPS 0x1000 /* voice loops when it reaches the end */ 30 | #define VF_MODULE 0x0800 /* voice belongs to module */ 31 | #define VF_PLAYING 0x0001 /* voice is playing */ 32 | 33 | 34 | /* Sample Voice Structure */ 35 | typedef struct voice { 36 | int8_t* wave; 37 | uint32_t index; 38 | uint32_t step; 39 | uint32_t loop; 40 | uint32_t length; 41 | uint16_t left; 42 | uint16_t right; 43 | uint16_t flags; 44 | uint8_t pad[6]; /* padded to take exactly two cache lines */ 45 | } voice_t; 46 | 47 | 48 | /* 49 | * Lock the voices to allow access by only one SH2 50 | * id = 2 = locked by Master SH2 51 | */ 52 | void SVC_Lock(int16_t id); 53 | 54 | /* 55 | * Unlock the voices 56 | */ 57 | void SVC_Unlock(void); 58 | 59 | /* 60 | * Pause/Resume all sound output 61 | */ 62 | void SVC_Pause(uint16_t pause); 63 | 64 | /* 65 | * Allocate a voice and play a sample 66 | * svc = sample to play (in voice format - is copied to allocated voice) 67 | * 68 | * returns voice allocated, 0 to 7, 0xFFFF = no available voices 69 | */ 70 | uint16_t SVC_Start(voice_t* svc); 71 | 72 | /* 73 | * Update sample on a voice 74 | * vc = index of voice to update (0 to 7) 75 | * svc = sample to play (in voice format - fields copied if not -1) 76 | */ 77 | void SVC_Update(uint16_t vc, voice_t* svc); 78 | 79 | /* 80 | * Return voice flags field 81 | * vc = index of voice (0 to 7) 82 | * 83 | * returns voice flags 84 | */ 85 | uint16_t SVC_Status(uint16_t vc); 86 | 87 | /* 88 | * Set pointer to module to call during the sample buffer update 89 | * returns previously set module 90 | */ 91 | void* SVC_SetMOD(void* Mod_p); 92 | 93 | /* 94 | * Update sample on a voice 95 | * vc = index of voice to update (0 to 7) 96 | * svc = sample to play (in voice format - fields copied if not -1) 97 | * 98 | * This is a special update for calling from the Slave SH2 99 | */ 100 | void SSVC_Update(uint16_t vc, voice_t* svc); 101 | 102 | /* 103 | * Update step on a voice 104 | * vc = index of voice to update (0 to 7) 105 | * step = new step 106 | * 107 | * This is a special update for calling from the Slave SH2 108 | */ 109 | void SSVC_UpdateStep(uint16_t vc, uint32_t step); 110 | 111 | /* 112 | * Update volume on a voice 113 | * vc = index of voice to update (0 to 7) 114 | * vol = new volume 115 | * 116 | * This is a special update for calling from the Slave SH2 117 | */ 118 | void SSVC_UpdateVol(uint16_t vc, uint32_t vol); 119 | 120 | #endif 121 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/sounds/en-atk.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/platform/32X/sounds/en-atk.raw -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/sounds/en-dth.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/platform/32X/sounds/en-dth.raw -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/sounds/en-near.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/platform/32X/sounds/en-near.raw -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/sounds/en-pain.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/platform/32X/sounds/en-pain.raw -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/sounds/pl-dth.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/platform/32X/sounds/pl-dth.raw -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/sounds/pl-oof.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/platform/32X/sounds/pl-oof.raw -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/sounds/pl-pain.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/platform/32X/sounds/pl-pain.raw -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/32X/sounds/pl-sht.raw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/noname22/megadrive-gcc/8dba616419318135a16981fabb405e066b02b256/examples/Yeti3D-GPL/platform/32X/sounds/pl-sht.raw -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/ddraw/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | #include "../win32/yeti3dwin32.h" 44 | 45 | char* lpszClassName = "Yeti3D"; 46 | char* lpszCaption = YETI_STR_TITLE; 47 | char* lpszMessage = 48 | YETI_STR_TITLE " " YETI_STR_VERSION " (DirectDraw Version)\n" 49 | "Compilied using Watcom C/C++ v11 (Release Build)\n\n" 50 | YETI_STR_COPYRIGHT "\n" 51 | "Website: " YETI_STR_URL "\n"; 52 | 53 | framebuffer_t framebuffer; 54 | yeti_t yeti; 55 | 56 | WNDCLASS wc; 57 | MSG msg; 58 | DDPIXELFORMAT ddpf; 59 | DDSURFACEDESC ddsd; 60 | DDSCAPS ddscaps; 61 | IDirectDrawSurface* lpDDSPrimary; 62 | IDirectDraw* lpDD; 63 | 64 | void d3d_flip(void) 65 | { 66 | static unsigned MarkTime; 67 | 68 | if ((int)(MarkTime - timeGetTime()) < 0) 69 | { 70 | MarkTime = timeGetTime() + YETI_VIEWPORT_INTERVAL; 71 | 72 | keyboard_update(&yeti.keyboard); 73 | game_loop(&yeti); 74 | 75 | ZeroMemory(&ddsd, sizeof(ddsd)); 76 | ddsd.dwSize = sizeof(ddsd); 77 | 78 | if (lpDDSPrimary->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL) == DD_OK) 79 | { 80 | viewport_to_video( 81 | (u16*) ddsd.lpSurface, 82 | ddsd.lPitch, 83 | &yeti.viewport, 84 | ddpf.dwRBitMask, 85 | ddpf.dwGBitMask, 86 | ddpf.dwBBitMask); 87 | 88 | lpDDSPrimary->Unlock(ddsd.lpSurface); 89 | } 90 | } 91 | } 92 | 93 | LRESULT CALLBACK WindowProc(HWND hWnd, unsigned uMsg, WPARAM wParam, LPARAM lParam) 94 | { 95 | switch (uMsg) 96 | { 97 | case WM_KEYDOWN: 98 | { 99 | switch (wParam) 100 | { 101 | case VK_ESCAPE: 102 | { 103 | DestroyWindow(hWnd); 104 | break; 105 | } 106 | } 107 | break; 108 | } 109 | case WM_DESTROY: 110 | { 111 | PostQuitMessage(0); 112 | break; 113 | } 114 | default: 115 | { 116 | return DefWindowProc(hWnd, uMsg, wParam, lParam); 117 | } 118 | } 119 | return 0; 120 | } 121 | 122 | WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) 123 | { 124 | MessageBox(0, lpszMessage, lpszCaption, MB_OK); 125 | lpszMessage = 0; 126 | 127 | wc.style = CS_HREDRAW | CS_VREDRAW; 128 | wc.lpfnWndProc = WindowProc; 129 | wc.cbClsExtra = 0; 130 | wc.cbWndExtra = sizeof(DWORD); 131 | wc.hInstance = hInstance; 132 | wc.hIcon = NULL; 133 | wc.hCursor = NULL; 134 | wc.hbrBackground = GetStockObject(BLACK_BRUSH); 135 | wc.lpszMenuName = NULL; 136 | wc.lpszClassName = lpszClassName; 137 | 138 | if (!RegisterClass(&wc)) lpszMessage = "Could not register class."; 139 | else 140 | { 141 | HWND hWnd = CreateWindow( 142 | lpszClassName, 143 | lpszCaption, 144 | WS_VISIBLE |WS_POPUP, 145 | 0, 0, YETI_VIEWPORT_WIDTH, YETI_VIEWPORT_HEIGHT, 146 | NULL, 147 | NULL, 148 | hInstance, 149 | NULL); 150 | 151 | if (!hWnd) lpszMessage = "Could not create window."; 152 | else 153 | { 154 | ShowWindow(hWnd, nCmdShow); 155 | UpdateWindow(hWnd); 156 | ShowCursor(false); 157 | 158 | if (DirectDrawCreate(NULL, &lpDD, NULL) != DD_OK) 159 | { 160 | lpszMessage = "Could not create direct draw interface."; 161 | } 162 | else 163 | { 164 | lpDD->SetCooperativeLevel(hWnd, DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT); 165 | lpDD->SetDisplayMode(YETI_VIEWPORT_WIDTH, YETI_VIEWPORT_HEIGHT, 16); 166 | 167 | ddsd.dwSize = sizeof(ddsd); 168 | ddsd.dwFlags = DDSD_CAPS; 169 | ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; 170 | 171 | if (lpDD->CreateSurface(&ddsd, &lpDDSPrimary, NULL) != DD_OK) 172 | { 173 | lpszMessage = "Could not create direct draw primary surface."; 174 | } 175 | else 176 | { 177 | ddpf.dwSize = sizeof(ddpf); 178 | lpDDSPrimary->GetPixelFormat(&ddpf); 179 | 180 | yeti_init(&yeti, &framebuffer, &framebuffer, textures, palette, lua); 181 | game_init(&yeti); 182 | 183 | while (msg.message != WM_QUIT) 184 | { 185 | if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 186 | { 187 | TranslateMessage(&msg); 188 | DispatchMessage(&msg); 189 | } 190 | else 191 | { 192 | d3d_flip(); 193 | } 194 | } 195 | lpDDSPrimary->Release(); 196 | } 197 | lpDD->Release(); 198 | } 199 | } 200 | ShowCursor(true); 201 | } 202 | if (lpszMessage) 203 | { 204 | MessageBox(0, lpszMessage, lpszCaption, MB_OK); 205 | } 206 | 207 | return msg.wParam; 208 | } 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/ddraw/yeti3d.lk1: -------------------------------------------------------------------------------- 1 | FIL data.obj,draw.obj,font.obj,game.obj,maps.obj,sprites.obj,yeti.obj,yeti3dwin32.obj,main.obj 2 | 3 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/ddraw/yeti3d.mk: -------------------------------------------------------------------------------- 1 | project : c:\yeti3dgpl\platform\ddraw\yeti3d.exe .SYMBOLIC 2 | 3 | !include c:\yeti3dgpl\platform\ddraw\yeti3d.mk1 4 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/ddraw/yeti3d.mk1: -------------------------------------------------------------------------------- 1 | !define BLANK "" 2 | c:\yeti3dgpl\platform\ddraw\data.obj : c:\yeti3dgpl\src\data.c .AUTODEPEND 3 | @c: 4 | cd c:\yeti3dgpl\platform\ddraw 5 | *wcc386 ..\..\src\data.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__WIN32__& 6 | -zq -otexan -d1 -5r -bt=nt -mf 7 | 8 | c:\yeti3dgpl\platform\ddraw\draw.obj : c:\yeti3dgpl\src\draw.c .AUTODEPEND 9 | @c: 10 | cd c:\yeti3dgpl\platform\ddraw 11 | *wcc386 ..\..\src\draw.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__WIN32__& 12 | -zq -otexan -d1 -5r -bt=nt -mf 13 | 14 | c:\yeti3dgpl\platform\ddraw\font.obj : c:\yeti3dgpl\src\font.c .AUTODEPEND 15 | @c: 16 | cd c:\yeti3dgpl\platform\ddraw 17 | *wcc386 ..\..\src\font.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__WIN32__& 18 | -zq -otexan -d1 -5r -bt=nt -mf 19 | 20 | c:\yeti3dgpl\platform\ddraw\game.obj : c:\yeti3dgpl\src\game.c .AUTODEPEND 21 | @c: 22 | cd c:\yeti3dgpl\platform\ddraw 23 | *wcc386 ..\..\src\game.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__WIN32__& 24 | -zq -otexan -d1 -5r -bt=nt -mf 25 | 26 | c:\yeti3dgpl\platform\ddraw\maps.obj : c:\yeti3dgpl\src\maps.c .AUTODEPEND 27 | @c: 28 | cd c:\yeti3dgpl\platform\ddraw 29 | *wcc386 ..\..\src\maps.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__WIN32__& 30 | -zq -otexan -d1 -5r -bt=nt -mf 31 | 32 | c:\yeti3dgpl\platform\ddraw\sprites.obj : c:\yeti3dgpl\src\sprites.c .AUTODE& 33 | PEND 34 | @c: 35 | cd c:\yeti3dgpl\platform\ddraw 36 | *wcc386 ..\..\src\sprites.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__WIN3& 37 | 2__ -zq -otexan -d1 -5r -bt=nt -mf 38 | 39 | c:\yeti3dgpl\platform\ddraw\yeti.obj : c:\yeti3dgpl\src\yeti.c .AUTODEPEND 40 | @c: 41 | cd c:\yeti3dgpl\platform\ddraw 42 | *wcc386 ..\..\src\yeti.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__WIN32__& 43 | -zq -otexan -d1 -5r -bt=nt -mf 44 | 45 | c:\yeti3dgpl\platform\ddraw\yeti3dwin32.obj : c:\yeti3dgpl\platform\win32\ye& 46 | ti3dwin32.c .AUTODEPEND 47 | @c: 48 | cd c:\yeti3dgpl\platform\ddraw 49 | *wcc386 ..\win32\yeti3dwin32.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__W& 50 | IN32__ -zq -otexan -d1 -5r -bt=nt -mf 51 | 52 | c:\yeti3dgpl\platform\ddraw\main.obj : c:\yeti3dgpl\platform\ddraw\main.cpp & 53 | .AUTODEPEND 54 | @c: 55 | cd c:\yeti3dgpl\platform\ddraw 56 | *wpp386 main.cpp -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__WIN32__ -zq -ot& 57 | exan -d1 -5r -bt=nt -mf 58 | 59 | c:\yeti3dgpl\platform\ddraw\yeti3d.exe : c:\yeti3dgpl\platform\ddraw\data.ob& 60 | j c:\yeti3dgpl\platform\ddraw\draw.obj c:\yeti3dgpl\platform\ddraw\font.obj & 61 | c:\yeti3dgpl\platform\ddraw\game.obj c:\yeti3dgpl\platform\ddraw\maps.obj c:& 62 | \yeti3dgpl\platform\ddraw\sprites.obj c:\yeti3dgpl\platform\ddraw\yeti.obj c& 63 | :\yeti3dgpl\platform\ddraw\yeti3dwin32.obj c:\yeti3dgpl\platform\ddraw\main.& 64 | obj c:\yeti3dgpl\platform\win32\yeti3dwin32.h .AUTODEPEND 65 | @c: 66 | cd c:\yeti3dgpl\platform\ddraw 67 | @%write yeti3d.lk1 FIL data.obj,draw.obj,font.obj,game.obj,maps.obj,sprites& 68 | .obj,yeti.obj,yeti3dwin32.obj,main.obj 69 | @%append yeti3d.lk1 70 | !ifneq BLANK "" 71 | *wlib -q -n -b yeti3d.imp 72 | @%append yeti3d.lk1 LIBR yeti3d.imp 73 | !endif 74 | !ifneq BLANK "" 75 | @%append yeti3d.lk1 op resource= 76 | !endif 77 | *wlink name yeti3d op inc SYS nt_win op m libr ddraw.lib op maxe=25 op q op& 78 | symf @yeti3d.lk1 79 | 80 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/ddraw/yeti3d.tgt: -------------------------------------------------------------------------------- 1 | 40 2 | targetIdent 3 | 0 4 | MProject 5 | 1 6 | MComponent 7 | 0 8 | 2 9 | WString 10 | 4 11 | NEXE 12 | 3 13 | WString 14 | 5 15 | nw2en 16 | 1 17 | 0 18 | 0 19 | 4 20 | MCommand 21 | 0 22 | 5 23 | MCommand 24 | 0 25 | 6 26 | MItem 27 | 10 28 | yeti3d.exe 29 | 7 30 | WString 31 | 4 32 | NEXE 33 | 8 34 | WVList 35 | 2 36 | 9 37 | MVState 38 | 10 39 | WString 40 | 7 41 | WINLINK 42 | 11 43 | WString 44 | 18 45 | ?????Libraries(,): 46 | 1 47 | 12 48 | WString 49 | 9 50 | ddraw.lib 51 | 0 52 | 13 53 | MVState 54 | 14 55 | WString 56 | 7 57 | WINLINK 58 | 15 59 | WString 60 | 18 61 | ?????Libraries(,): 62 | 0 63 | 16 64 | WString 65 | 9 66 | ddraw.lib 67 | 0 68 | 17 69 | WVList 70 | 0 71 | -1 72 | 1 73 | 1 74 | 0 75 | 18 76 | WPickList 77 | 13 78 | 19 79 | MItem 80 | 3 81 | *.c 82 | 20 83 | WString 84 | 4 85 | COBJ 86 | 21 87 | WVList 88 | 1 89 | 22 90 | MVState 91 | 23 92 | WString 93 | 3 94 | WCC 95 | 24 96 | WString 97 | 23 98 | ?????Macro definitions: 99 | 0 100 | 25 101 | WString 102 | 9 103 | __WIN32__ 104 | 0 105 | 26 106 | WVList 107 | 0 108 | -1 109 | 1 110 | 1 111 | 0 112 | 27 113 | MItem 114 | 16 115 | ..\..\src\data.c 116 | 28 117 | WString 118 | 4 119 | COBJ 120 | 29 121 | WVList 122 | 0 123 | 30 124 | WVList 125 | 0 126 | 19 127 | 1 128 | 1 129 | 0 130 | 31 131 | MItem 132 | 16 133 | ..\..\src\draw.c 134 | 32 135 | WString 136 | 4 137 | COBJ 138 | 33 139 | WVList 140 | 0 141 | 34 142 | WVList 143 | 0 144 | 19 145 | 1 146 | 1 147 | 0 148 | 35 149 | MItem 150 | 16 151 | ..\..\src\font.c 152 | 36 153 | WString 154 | 4 155 | COBJ 156 | 37 157 | WVList 158 | 0 159 | 38 160 | WVList 161 | 0 162 | 19 163 | 1 164 | 1 165 | 0 166 | 39 167 | MItem 168 | 16 169 | ..\..\src\game.c 170 | 40 171 | WString 172 | 4 173 | COBJ 174 | 41 175 | WVList 176 | 0 177 | 42 178 | WVList 179 | 0 180 | 19 181 | 1 182 | 1 183 | 0 184 | 43 185 | MItem 186 | 16 187 | ..\..\src\maps.c 188 | 44 189 | WString 190 | 4 191 | COBJ 192 | 45 193 | WVList 194 | 0 195 | 46 196 | WVList 197 | 0 198 | 19 199 | 1 200 | 1 201 | 0 202 | 47 203 | MItem 204 | 19 205 | ..\..\src\sprites.c 206 | 48 207 | WString 208 | 4 209 | COBJ 210 | 49 211 | WVList 212 | 0 213 | 50 214 | WVList 215 | 0 216 | 19 217 | 1 218 | 1 219 | 0 220 | 51 221 | MItem 222 | 16 223 | ..\..\src\yeti.c 224 | 52 225 | WString 226 | 4 227 | COBJ 228 | 53 229 | WVList 230 | 0 231 | 54 232 | WVList 233 | 0 234 | 19 235 | 1 236 | 1 237 | 0 238 | 55 239 | MItem 240 | 22 241 | ..\win32\yeti3dwin32.c 242 | 56 243 | WString 244 | 4 245 | COBJ 246 | 57 247 | WVList 248 | 0 249 | 58 250 | WVList 251 | 0 252 | 19 253 | 1 254 | 1 255 | 0 256 | 59 257 | MItem 258 | 5 259 | *.cpp 260 | 60 261 | WString 262 | 6 263 | CPPOBJ 264 | 61 265 | WVList 266 | 1 267 | 62 268 | MVState 269 | 63 270 | WString 271 | 3 272 | WPP 273 | 64 274 | WString 275 | 23 276 | ?????Macro definitions: 277 | 0 278 | 65 279 | WString 280 | 9 281 | __WIN32__ 282 | 0 283 | 66 284 | WVList 285 | 0 286 | -1 287 | 1 288 | 1 289 | 0 290 | 67 291 | MItem 292 | 8 293 | main.cpp 294 | 68 295 | WString 296 | 6 297 | CPPOBJ 298 | 69 299 | WVList 300 | 0 301 | 70 302 | WVList 303 | 0 304 | 59 305 | 1 306 | 1 307 | 0 308 | 71 309 | MItem 310 | 3 311 | *.h 312 | 72 313 | WString 314 | 3 315 | NIL 316 | 73 317 | WVList 318 | 0 319 | 74 320 | WVList 321 | 0 322 | -1 323 | 1 324 | 1 325 | 0 326 | 75 327 | MItem 328 | 22 329 | ..\win32\yeti3dwin32.h 330 | 76 331 | WString 332 | 3 333 | NIL 334 | 77 335 | WVList 336 | 0 337 | 78 338 | WVList 339 | 0 340 | 71 341 | 1 342 | 1 343 | 0 344 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/ddraw/yeti3d.wpj: -------------------------------------------------------------------------------- 1 | 40 2 | projectIdent 3 | 0 4 | VpeMain 5 | 1 6 | WRect 7 | -40 8 | -53 9 | 10320 10 | 9920 11 | 2 12 | MProject 13 | 3 14 | MCommand 15 | 0 16 | 4 17 | MCommand 18 | 0 19 | 1 20 | 5 21 | WFileName 22 | 10 23 | yeti3d.tgt 24 | 6 25 | WVList 26 | 1 27 | 7 28 | VComponent 29 | 8 30 | WRect 31 | 0 32 | 0 33 | 5700 34 | 4280 35 | 0 36 | 0 37 | 9 38 | WFileName 39 | 10 40 | yeti3d.tgt 41 | 0 42 | 7 43 | 7 44 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/gba/gba.h: -------------------------------------------------------------------------------- 1 | // gba.h by eloist 2 | // included for all non HAM boneheads ;) 3 | // slightly modified by Emanuel 4 | 5 | 6 | #define REG_INTERUPT *(volatile u32*)0x3007FFC 7 | #define REG_DISPCNT *(volatile u32*)0x4000000 8 | #define REG_DISPCNT_L *(volatile u16*)0x4000000 9 | #define REG_DISPCNT_H *(volatile u16*)0x4000002 10 | #define REG_DISPSTAT *(volatile u16*)0x4000004 11 | #define REG_VCOUNT *(volatile u16*)0x4000006 12 | #define REG_BG0CNT *(volatile u16*)0x4000008 13 | #define REG_BG1CNT *(volatile u16*)0x400000A 14 | #define REG_BG2CNT *(volatile u16*)0x400000C 15 | #define REG_BG3CNT *(volatile u16*)0x400000E 16 | #define REG_BG0HOFS *(volatile u16*)0x4000010 17 | #define REG_BG0VOFS *(volatile u16*)0x4000012 18 | #define REG_BG1HOFS *(volatile u16*)0x4000014 19 | #define REG_BG1VOFS *(volatile u16*)0x4000016 20 | #define REG_BG2HOFS *(volatile u16*)0x4000018 21 | #define REG_BG2VOFS *(volatile u16*)0x400001A 22 | #define REG_BG3HOFS *(volatile u16*)0x400001C 23 | #define REG_BG3VOFS *(volatile u16*)0x400001E 24 | #define REG_BG2PA *(volatile u16*)0x4000020 25 | #define REG_BG2PB *(volatile u16*)0x4000022 26 | #define REG_BG2PC *(volatile u16*)0x4000024 27 | #define REG_BG2PD *(volatile u16*)0x4000026 28 | #define REG_BG2X *(volatile u32*)0x4000028 29 | #define REG_BG2X_L *(volatile u16*)0x4000028 30 | #define REG_BG2X_H *(volatile u16*)0x400002A 31 | #define REG_BG2Y *(volatile u32*)0x400002C 32 | #define REG_BG2Y_L *(volatile u16*)0x400002C 33 | #define REG_BG2Y_H *(volatile u16*)0x400002E 34 | #define REG_BG3PA *(volatile u16*)0x4000030 35 | #define REG_BG3PB *(volatile u16*)0x4000032 36 | #define REG_BG3PC *(volatile u16*)0x4000034 37 | #define REG_BG3PD *(volatile u16*)0x4000036 38 | #define REG_BG3X *(volatile u32*)0x4000038 39 | #define REG_BG3X_L *(volatile u16*)0x4000038 40 | #define REG_BG3X_H *(volatile u16*)0x400003A 41 | #define REG_BG3Y *(volatile u32*)0x400003C 42 | #define REG_BG3Y_L *(volatile u16*)0x400003C 43 | #define REG_BG3Y_H *(volatile u16*)0x400003E 44 | #define REG_WIN0H *(volatile u16*)0x4000040 45 | #define REG_WIN1H *(volatile u16*)0x4000042 46 | #define REG_WIN0V *(volatile u16*)0x4000044 47 | #define REG_WIN1V *(volatile u16*)0x4000046 48 | #define REG_WININ *(volatile u16*)0x4000048 49 | #define REG_WINOUT *(volatile u16*)0x400004A 50 | #define REG_MOSAIC *(volatile u32*)0x400004C 51 | #define REG_MOSAIC_L *(volatile u32*)0x400004C 52 | #define REG_MOSAIC_H *(volatile u32*)0x400004E 53 | #define REG_BLDMOD *(volatile u16*)0x4000050 54 | #define REG_COLEV *(volatile u16*)0x4000052 55 | #define REG_COLEY *(volatile u16*)0x4000054 56 | #define REG_SG10 *(volatile u32*)0x4000060 57 | #define REG_SG10_L *(volatile u16*)0x4000060 58 | #define REG_SG10_H *(volatile u16*)0x4000062 59 | #define REG_SG11 *(volatile u16*)0x4000064 60 | #define REG_SG20 *(volatile u16*)0x4000068 61 | #define REG_SG21 *(volatile u16*)0x400006C 62 | #define REG_SG30 *(volatile u32*)0x4000070 63 | #define REG_SG30_L *(volatile u16*)0x4000070 64 | #define REG_SG30_H *(volatile u16*)0x4000072 65 | #define REG_SG31 *(volatile u16*)0x4000074 66 | #define REG_SG40 *(volatile u16*)0x4000078 67 | #define REG_SG41 *(volatile u16*)0x400007C 68 | #define REG_SGCNT0 *(volatile u32*)0x4000080 69 | #define REG_SGCNT0_L *(volatile u16*)0x4000080 70 | #define REG_SGCNT0_H *(volatile u16*)0x4000082 71 | #define REG_SGCNT1 *(volatile u16*)0x4000084 72 | #define REG_SGBIAS *(volatile u16*)0x4000088 73 | #define REG_SGWR0 *(volatile u32*)0x4000090 74 | #define REG_SGWR0_L *(volatile u16*)0x4000090 75 | #define REG_SGWR0_H *(volatile u16*)0x4000092 76 | #define REG_SGWR1 *(volatile u32*)0x4000094 77 | #define REG_SGWR1_L *(volatile u16*)0x4000094 78 | #define REG_SGWR1_H *(volatile u16*)0x4000096 79 | #define REG_SGWR2 *(volatile u32*)0x4000098 80 | #define REG_SGWR2_L *(volatile u16*)0x4000098 81 | #define REG_SGWR2_H *(volatile u16*)0x400009A 82 | #define REG_SGWR3 *(volatile u32*)0x400009C 83 | #define REG_SGWR3_L *(volatile u16*)0x400009C 84 | #define REG_SGWR3_H *(volatile u16*)0x400009E 85 | #define REG_SGFIF0A *(volatile u32*)0x40000A0 86 | #define REG_SGFIFOA_L *(volatile u16*)0x40000A0 87 | #define REG_SGFIFOA_H *(volatile u16*)0x40000A2 88 | #define REG_SGFIFOB *(volatile u32*)0x40000A4 89 | #define REG_SGFIFOB_L *(volatile u16*)0x40000A4 90 | #define REG_SGFIFOB_H *(volatile u16*)0x40000A6 91 | #define REG_DM0SAD *(volatile u32*)0x40000B0 92 | #define REG_DM0SAD_L *(volatile u16*)0x40000B0 93 | #define REG_DM0SAD_H *(volatile u16*)0x40000B2 94 | #define REG_DM0DAD *(volatile u32*)0x40000B4 95 | #define REG_DM0DAD_L *(volatile u16*)0x40000B4 96 | #define REG_DM0DAD_H *(volatile u16*)0x40000B6 97 | #define REG_DM0CNT *(volatile u32*)0x40000B8 98 | #define REG_DM0CNT_L *(volatile u16*)0x40000B8 99 | #define REG_DM0CNT_H *(volatile u16*)0x40000BA 100 | #define REG_DM1SAD *(volatile u32*)0x40000BC 101 | #define REG_DM1SAD_L *(volatile u16*)0x40000BC 102 | #define REG_DM1SAD_H *(volatile u16*)0x40000BE 103 | #define REG_DM1DAD *(volatile u32*)0x40000C0 104 | #define REG_DM1DAD_L *(volatile u16*)0x40000C0 105 | #define REG_DM1DAD_H *(volatile u16*)0x40000C2 106 | #define REG_DM1CNT *(volatile u32*)0x40000C4 107 | #define REG_DM1CNT_L *(volatile u16*)0x40000C4 108 | #define REG_DM1CNT_H *(volatile u16*)0x40000C6 109 | #define REG_DM2SAD *(volatile u32*)0x40000C8 110 | #define REG_DM2SAD_L *(volatile u16*)0x40000C8 111 | #define REG_DM2SAD_H *(volatile u16*)0x40000CA 112 | #define REG_DM2DAD *(volatile u32*)0x40000CC 113 | #define REG_DM2DAD_L *(volatile u16*)0x40000CC 114 | #define REG_DM2DAD_H *(volatile u16*)0x40000CE 115 | #define REG_DM2CNT *(volatile u32*)0x40000D0 116 | #define REG_DM2CNT_L *(volatile u16*)0x40000D0 117 | #define REG_DM2CNT_H *(volatile u16*)0x40000D2 118 | #define REG_DM3SAD *(volatile u32*)0x40000D4 119 | #define REG_DM3SAD_L *(volatile u16*)0x40000D4 120 | #define REG_DM3SAD_H *(volatile u16*)0x40000D6 121 | #define REG_DM3DAD *(volatile u32*)0x40000D8 122 | #define REG_DM3DAD_L *(volatile u16*)0x40000D8 123 | #define REG_DM3DAD_H *(volatile u16*)0x40000DA 124 | #define REG_DM3CNT *(volatile u32*)0x40000DC 125 | #define REG_DM3CNT_L *(volatile u16*)0x40000DC 126 | #define REG_DM3CNT_H *(volatile u16*)0x40000DE 127 | #define REG_TM0D *(volatile u16*)0x4000100 128 | #define REG_TM0CNT *(volatile u16*)0x4000102 129 | #define REG_TM1D *(volatile u16*)0x4000104 130 | #define REG_TM1CNT *(volatile u16*)0x4000106 131 | #define REG_TM2D *(volatile u16*)0x4000108 132 | #define REG_TM2CNT *(volatile u16*)0x400010A 133 | #define REG_TM3D *(volatile u16*)0x400010C 134 | #define REG_TM3CNT *(volatile u16*)0x400010E 135 | #define REG_SCD0 *(volatile u16*)0x4000120 136 | #define REG_SCD1 *(volatile u16*)0x4000122 137 | #define REG_SCD2 *(volatile u16*)0x4000124 138 | #define REG_SCD3 *(volatile u16*)0x4000126 139 | #define REG_SCCNT *(volatile u32*)0x4000128 140 | #define REG_SCCNT_L *(volatile u16*)0x4000128 141 | #define REG_SCCNT_H *(volatile u16*)0x400012A 142 | #define REG_P1 *(volatile u16*)0x4000130 143 | #define REG_P1CNT *(volatile u16*)0x4000132 144 | #define REG_R *(volatile u16*)0x4000134 145 | #define REG_HS_CTRL *(volatile u16*)0x4000140 146 | #define REG_JOYRE *(volatile u32*)0x4000150 147 | #define REG_JOYRE_L *(volatile u16*)0x4000150 148 | #define REG_JOYRE_H *(volatile u16*)0x4000152 149 | #define REG_JOYTR *(volatile u32*)0x4000154 150 | #define REG_JOYTR_L *(volatile u16*)0x4000154 151 | #define REG_JOYTR_H *(volatile u16*)0x4000156 152 | #define REG_JSTAT *(volatile u32*)0x4000158 153 | #define REG_JSTAT_L *(volatile u16*)0x4000158 154 | #define REG_JSTAT_H *(volatile u16*)0x400015A 155 | #define REG_IE *(volatile u16*)0x4000200 156 | #define REG_IF *(volatile u16*)0x4000202 157 | #define REG_WSCNT *(volatile u16*)0x4000204 158 | #define REG_IME *(volatile u16*)0x4000208 159 | #define REG_PAUSE *(volatile u16*)0x4000300 160 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/gba/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: GBA port 28 | ** Auth: Derek Evans 29 | ** 30 | ** Copyright (C) 2003, Derek Evans 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #include "../../src/yeti.h" 40 | #include "../../src/font.h" 41 | #include "gba.h" 42 | 43 | IN_EWRAM yeti_t yeti; 44 | 45 | int min(int a, int b) 46 | { 47 | return MIN(a, b); 48 | } 49 | 50 | int max(int a, int b) 51 | { 52 | return MAX(a, b); 53 | } 54 | 55 | typedef struct 56 | { 57 | int Sx, l, u, v; 58 | } edge_t; 59 | 60 | typedef struct 61 | { 62 | u16 attribute0; 63 | u16 attribute1; 64 | u16 attribute2; 65 | u16 attribute3; 66 | } OAMEntry; 67 | 68 | edge_t EdgeLeft[200]; 69 | edge_t EdgeRight[200]; 70 | 71 | /* 72 | ** Name: yeti_putc 73 | ** Desc: Puts a given character onto the screen. 74 | */ 75 | void yeti_putc(int x, int c) 76 | { 77 | ((OAMEntry*)0x7000000)[x].attribute2 = ((c - ' ') << 1) + 512; 78 | } 79 | 80 | /* 81 | ** Name: yeti_putc 82 | ** Desc: Puts a given string onto the screen. 83 | */ 84 | void yeti_puts(int x, char* s) 85 | { 86 | while (*s) yeti_putc(x++, *s++); 87 | } 88 | 89 | void itos(int i, char* s) 90 | { 91 | //#define DIGITS(X) if(i>=X){c=0;do{i-=X;c++;}while(i >= X);*s++='0'+c;} 92 | #define DIGITS(X) for(c=0;i>=X;i-=X,c++);*s++='0'+c; 93 | 94 | int c; 95 | DIGITS(100000); DIGITS(10000); DIGITS(1000); DIGITS(100); DIGITS(10); 96 | *s++ = '0' + i; 97 | *s = 0; 98 | } 99 | 100 | void gba_init(void) 101 | { 102 | int i; 103 | 104 | REG_DISPCNT_L = 0x1445; 105 | REG_BG2PA = 171; 106 | REG_BG2PD = 206; 107 | 108 | // Setup the sprites to be used for overlayed text. 109 | for(i = 0; i < 128; i++) 110 | { 111 | ((OAMEntry*)0x7000000)[i].attribute0 = ((i / 30) + 16) << 3 | 0x2000; 112 | ((OAMEntry*)0x7000000)[i].attribute1 = ((i % 30) + 0) << 3; 113 | ((OAMEntry*)0x7000000)[i].attribute2 = 0; 114 | ((OAMEntry*)0x7000000)[i].attribute3 = 0; 115 | } 116 | // Copy the rom font into sprite ram. 117 | memcpy((void*)0x6014000, fontData, 91 * sizeof(fontchar_t)); 118 | // Copy our rom palette into palette ram. 119 | memcpy((void*)0x5000200, palette, 256 * 2); 120 | 121 | ((u16*)0x5000200)[255] = RGB_SET(31, 31, 0); 122 | 123 | REG_TM2CNT = 0x80; 124 | REG_TM3CNT = 0x84; 125 | } 126 | 127 | void gba_flip(void) 128 | { 129 | int i; 130 | framebuffer_t* temp; 131 | 132 | i = ~(*(u8*)0x04000130); 133 | 134 | yeti.keyboard.a = i & 1; 135 | yeti.keyboard.b = i & 2; 136 | yeti.keyboard.select = i & 4; 137 | yeti.keyboard.right = i & 16; 138 | yeti.keyboard.left = i & 32; 139 | yeti.keyboard.up = i & 64; 140 | yeti.keyboard.down = i & 128; 141 | 142 | i = ~(*(u8*)0x04000131); 143 | 144 | yeti.keyboard.l = i & 1; 145 | yeti.keyboard.r = i & 2; 146 | 147 | // Flip the frame buffers. 148 | *(u8*)0x04000000 ^= 0x10; 149 | temp = yeti.viewport.back; 150 | yeti.viewport.back = yeti.viewport.front; 151 | yeti.viewport.front = temp; 152 | } 153 | 154 | int main(void) 155 | { 156 | char s[10]; 157 | u16 real = 0; 158 | 159 | gba_init(); 160 | yeti_init(&yeti, (framebuffer_t*) 0x06000000, (framebuffer_t*) 0x0600A000, textures, palette, lua); 161 | game_init(&yeti); 162 | 163 | yeti_puts(60 + 6, "Yeti3D Engine (GBA)"); 164 | yeti_puts(90 + 5, "(C) 2003 Derek/Torlus"); 165 | //yeti_puts(82, "FPS:"); 166 | 167 | #define timelag() (int)((*(volatile u16*)0x400010C) - real) 168 | 169 | while (!yeti.keyboard.select) 170 | { 171 | game_tick(&yeti); 172 | game_draw(&yeti); 173 | 174 | for (real += YETI_VIEWPORT_INTERVAL; timelag() > YETI_VIEWPORT_INTERVAL_ERROR; real += YETI_VIEWPORT_INTERVAL) 175 | { 176 | game_tick(&yeti); 177 | } 178 | 179 | //itos(yeti.tick * 1000 / (*(volatile u16*)0x400010C), s); 180 | //yeti_puts(0, s); 181 | 182 | while (timelag() < -YETI_VIEWPORT_INTERVAL_ERROR); 183 | 184 | gba_flip(); 185 | } 186 | return 0; 187 | } 188 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/gba/make.bat: -------------------------------------------------------------------------------- 1 | @del game.gba 2 | 3 | @set orgpath=%path% 4 | @set path=C:\devkitadv\bin;%path% 5 | @set CFLAGS=-marm -mthumb-interwork -mlong-calls -O1 -D __GBA__ 6 | 7 | del *.o 8 | 9 | @REM Assemble ARM/Thumb Code 10 | @REM ======================= 11 | 12 | @echo ====== Compiling Assembly Files 13 | REM as -mthumb-interwork -o poly.text.iwram.o poly.text.iwram.s 14 | 15 | REM I still haven't been able to link this into Yeti3D 16 | REM as -mthumb-interwork -o crt0.o crt0.s 17 | 18 | @echo ====== Compiling C Files 19 | gcc %CFLAGS% -c *.c ..\..\src\*.c 20 | 21 | @echo ====== Linking 22 | gcc %CFLAGS% -o game.elf *.o 23 | 24 | objcopy -O binary game.elf game.gba 25 | 26 | @del game.elf 27 | @set path=%orgpath% 28 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/opengl/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #include 40 | #include 41 | 42 | #include 43 | #include 44 | #include 45 | 46 | #include "../win32/yeti3dwin32.h" 47 | 48 | framebuffer_t framebuffer; 49 | yeti_t yeti; 50 | 51 | GLfloat fogColor[4] = {0.0, 0.5, 0.0, 1}; 52 | unsigned texture_lists[255]; 53 | u8 texture[64][64][3]; 54 | float yeti_to_gl = 1.0 / (256 * 64); 55 | 56 | void wglSetDisplayMode(int width, int height, int bpp) 57 | { 58 | DEVMODE dm; 59 | 60 | dm.dmSize = sizeof(dm); 61 | dm.dmPelsWidth = width; 62 | dm.dmPelsHeight = height; 63 | dm.dmBitsPerPel = bpp; 64 | dm.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; 65 | 66 | ChangeDisplaySettings(&dm, CDS_FULLSCREEN); 67 | } 68 | 69 | void wglResetDisplaymode(void) 70 | { 71 | ChangeDisplaySettings(NULL, CDS_FULLSCREEN); 72 | } 73 | 74 | void draw_texture(yeti_t* yeti, polyclip_t src, int n, int tid) 75 | { 76 | int i, x, y; 77 | 78 | if (texture_lists[tid]) 79 | { 80 | glBindTexture(GL_TEXTURE_2D, texture_lists[tid]); 81 | } 82 | else 83 | { 84 | glGenTextures(1, &texture_lists[tid]); 85 | glBindTexture(GL_TEXTURE_2D, texture_lists[tid]); 86 | 87 | for (y = 0; y < 64; y++) 88 | { 89 | for (x = 0; x < 64; x++) 90 | { 91 | i = textures[tid][y][x]; 92 | texture[y][x][0] = palette[i][0]; 93 | texture[y][x][1] = palette[i][1]; 94 | texture[y][x][2] = palette[i][2]; 95 | } 96 | } 97 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //LINEAR); 98 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 99 | glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, texture); 100 | } 101 | 102 | glBegin(n == 4 ? GL_QUADS : GL_POLYGON); 103 | 104 | for (i = n; i--;) 105 | { 106 | vertex_t* v = src[i]; 107 | float c = 1.0 * v->l / i2f(63); 108 | 109 | glColor3f(c, c, c); 110 | glTexCoord2f(v->u * yeti_to_gl, v->v * yeti_to_gl); 111 | glVertex3f(f2fl(v->x), f2fl(v->y), -f2fl(v->z)); 112 | } 113 | 114 | glEnd(); 115 | } 116 | 117 | void CALLBACK IdleFunc() 118 | { 119 | static unsigned MarkTime; 120 | 121 | if ((int)(MarkTime - timeGetTime()) < 0) 122 | { 123 | MarkTime = timeGetTime() + YETI_VIEWPORT_INTERVAL; 124 | 125 | keyboard_update(&yeti.keyboard); 126 | 127 | glClear(/*GL_COLOR_BUFFER_BIT |*/ GL_DEPTH_BUFFER_BIT); 128 | 129 | game_loop(&yeti); 130 | 131 | glFlush(); 132 | auxSwapBuffers(); 133 | } 134 | } 135 | 136 | void CALLBACK ReshapeFunc(GLsizei w, GLsizei h) 137 | { 138 | if (!h) return; 139 | glViewport(0, 0, w, h); 140 | glMatrixMode(GL_PROJECTION); 141 | glLoadIdentity(); 142 | gluPerspective(85.0, 1.0 * w / h, 0.1, 40.0); 143 | glMatrixMode(GL_MODELVIEW); 144 | glLoadIdentity(); 145 | 146 | //glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); 147 | //glHint (GL_FOG_HINT, GL_FASTEST); 148 | 149 | glEnable(GL_TEXTURE_2D); 150 | glEnable(GL_CULL_FACE); 151 | glCullFace(GL_BACK); 152 | glEnable(GL_DEPTH_TEST); 153 | glEnable(GL_FOG); 154 | //glFogi(GL_FOG_MODE, GL_EXP); 155 | glFogi (GL_FOG_MODE, GL_LINEAR); 156 | glFogi(GL_FOG_START, 0); 157 | glFogi(GL_FOG_END, 20); 158 | glFogfv (GL_FOG_COLOR, fogColor); 159 | glFogf(GL_FOG_DENSITY, 0.05); 160 | 161 | glClearColor(fogColor[0], fogColor[1], fogColor[2], fogColor[3]); 162 | } 163 | 164 | void CALLBACK MainLoop(void) 165 | { 166 | // 167 | } 168 | 169 | void main(void) 170 | { 171 | int width = 640; 172 | int height = 480; 173 | 174 | auxInitDisplayMode (AUX_DOUBLE | AUX_RGB); 175 | auxInitPosition( 176 | (GetSystemMetrics(SM_CXSCREEN) - width) / 2, 177 | (GetSystemMetrics(SM_CYSCREEN) - height) / 2, 178 | width, height); 179 | auxInitWindow(YETI_STR_CAPTION); 180 | 181 | //ShowCursor(0); 182 | //SetWindowPos(auxGetHWND(), HWND_TOPMOST, -4, -23, 0, 0, SWP_NOSIZE); 183 | //wglSetDisplayMode(width, height, 16); 184 | 185 | palette_overbright(palette, palette, i2fdiv2(5)); 186 | 187 | yeti_init(&yeti, &framebuffer, &framebuffer, textures, palette, lua); 188 | game_init(&yeti); 189 | 190 | auxReshapeFunc(ReshapeFunc); 191 | auxIdleFunc(IdleFunc); 192 | 193 | auxMainLoop(MainLoop); 194 | 195 | //wglResetDisplaymode(); 196 | } 197 | //--------------------------------------------------------------------------- 198 | 199 | 200 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/opengl/yeti3d.lk1: -------------------------------------------------------------------------------- 1 | FIL data.obj,draw.obj,font.obj,game.obj,maps.obj,sprites.obj,yeti.obj,yeti3dwin32.obj,main.obj 2 | LIBR \watcom\lib386\nt\glaux.lib,\watcom\lib386\nt\glu32.lib,\watcom\lib386\nt\opengl32.lib 3 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/opengl/yeti3d.mk: -------------------------------------------------------------------------------- 1 | project : c:\yeti3dgpl\platform\opengl\yeti3d.exe .SYMBOLIC 2 | 3 | !include c:\yeti3dgpl\platform\opengl\yeti3d.mk1 4 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/opengl/yeti3d.mk1: -------------------------------------------------------------------------------- 1 | !define BLANK "" 2 | c:\yeti3dgpl\platform\opengl\data.obj : c:\yeti3dgpl\src\data.c .AUTODEPEND 3 | @c: 4 | cd c:\yeti3dgpl\platform\opengl 5 | *wcc386 ..\..\src\data.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__PATCH_D& 6 | RAW_TEXTURE__ -d__WINDOWS__ -d__WIN32__ -d__YETI_EDITOR__ -zq -od -d2 -5r -b& 7 | t=nt -mf 8 | 9 | c:\yeti3dgpl\platform\opengl\draw.obj : c:\yeti3dgpl\src\draw.c .AUTODEPEND 10 | @c: 11 | cd c:\yeti3dgpl\platform\opengl 12 | *wcc386 ..\..\src\draw.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__PATCH_D& 13 | RAW_TEXTURE__ -d__WINDOWS__ -d__WIN32__ -d__YETI_EDITOR__ -zq -od -d2 -5r -b& 14 | t=nt -mf 15 | 16 | c:\yeti3dgpl\platform\opengl\font.obj : c:\yeti3dgpl\src\font.c .AUTODEPEND 17 | @c: 18 | cd c:\yeti3dgpl\platform\opengl 19 | *wcc386 ..\..\src\font.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__PATCH_D& 20 | RAW_TEXTURE__ -d__WINDOWS__ -d__WIN32__ -d__YETI_EDITOR__ -zq -od -d2 -5r -b& 21 | t=nt -mf 22 | 23 | c:\yeti3dgpl\platform\opengl\game.obj : c:\yeti3dgpl\src\game.c .AUTODEPEND 24 | @c: 25 | cd c:\yeti3dgpl\platform\opengl 26 | *wcc386 ..\..\src\game.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__PATCH_D& 27 | RAW_TEXTURE__ -d__WINDOWS__ -d__WIN32__ -d__YETI_EDITOR__ -zq -od -d2 -5r -b& 28 | t=nt -mf 29 | 30 | c:\yeti3dgpl\platform\opengl\maps.obj : c:\yeti3dgpl\src\maps.c .AUTODEPEND 31 | @c: 32 | cd c:\yeti3dgpl\platform\opengl 33 | *wcc386 ..\..\src\maps.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__PATCH_D& 34 | RAW_TEXTURE__ -d__WINDOWS__ -d__WIN32__ -d__YETI_EDITOR__ -zq -od -d2 -5r -b& 35 | t=nt -mf 36 | 37 | c:\yeti3dgpl\platform\opengl\sprites.obj : c:\yeti3dgpl\src\sprites.c .AUTOD& 38 | EPEND 39 | @c: 40 | cd c:\yeti3dgpl\platform\opengl 41 | *wcc386 ..\..\src\sprites.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__PATC& 42 | H_DRAW_TEXTURE__ -d__WINDOWS__ -d__WIN32__ -d__YETI_EDITOR__ -zq -od -d2 -5r& 43 | -bt=nt -mf 44 | 45 | c:\yeti3dgpl\platform\opengl\yeti.obj : c:\yeti3dgpl\src\yeti.c .AUTODEPEND 46 | @c: 47 | cd c:\yeti3dgpl\platform\opengl 48 | *wcc386 ..\..\src\yeti.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__PATCH_D& 49 | RAW_TEXTURE__ -d__WINDOWS__ -d__WIN32__ -d__YETI_EDITOR__ -zq -od -d2 -5r -b& 50 | t=nt -mf 51 | 52 | c:\yeti3dgpl\platform\opengl\yeti3dwin32.obj : c:\yeti3dgpl\platform\win32\y& 53 | eti3dwin32.c .AUTODEPEND 54 | @c: 55 | cd c:\yeti3dgpl\platform\opengl 56 | *wcc386 ..\win32\yeti3dwin32.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__P& 57 | ATCH_DRAW_TEXTURE__ -d__WINDOWS__ -d__WIN32__ -d__YETI_EDITOR__ -zq -od -d2 & 58 | -5r -bt=nt -mf 59 | 60 | c:\yeti3dgpl\platform\opengl\main.obj : c:\yeti3dgpl\platform\opengl\main.c & 61 | .AUTODEPEND 62 | @c: 63 | cd c:\yeti3dgpl\platform\opengl 64 | *wcc386 main.c -i=C:\WATCOM\h;C:\WATCOM\h\nt -w4 -e25 -d__PATCH_DRAW_TEXTUR& 65 | E__ -d__WINDOWS__ -d__WIN32__ -d__YETI_EDITOR__ -zq -od -d2 -5r -bt=nt -mf 66 | 67 | c:\yeti3dgpl\platform\opengl\yeti3d.exe : c:\yeti3dgpl\platform\opengl\data.& 68 | obj c:\yeti3dgpl\platform\opengl\draw.obj c:\yeti3dgpl\platform\opengl\font.& 69 | obj c:\yeti3dgpl\platform\opengl\game.obj c:\yeti3dgpl\platform\opengl\maps.& 70 | obj c:\yeti3dgpl\platform\opengl\sprites.obj c:\yeti3dgpl\platform\opengl\ye& 71 | ti.obj c:\yeti3dgpl\platform\opengl\yeti3dwin32.obj c:\yeti3dgpl\platform\op& 72 | engl\main.obj c:\watcom\lib386\nt\glaux.lib c:\watcom\lib386\nt\glu32.lib c:& 73 | \watcom\lib386\nt\opengl32.lib .AUTODEPEND 74 | @c: 75 | cd c:\yeti3dgpl\platform\opengl 76 | @%write yeti3d.lk1 FIL data.obj,draw.obj,font.obj,game.obj,maps.obj,sprites& 77 | .obj,yeti.obj,yeti3dwin32.obj,main.obj 78 | @%append yeti3d.lk1 LIBR \watcom\lib386\nt\glaux.lib,\watcom\lib386\nt\glu3& 79 | 2.lib,\watcom\lib386\nt\opengl32.lib 80 | !ifneq BLANK "" 81 | *wlib -q -n -b yeti3d.imp 82 | @%append yeti3d.lk1 LIBR yeti3d.imp 83 | !endif 84 | !ifneq BLANK "" 85 | @%append yeti3d.lk1 op resource= 86 | !endif 87 | *wlink name yeti3d d all op inc SYS nt_win op m op maxe=25 op q op symf @ye& 88 | ti3d.lk1 89 | 90 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/opengl/yeti3d.tgt: -------------------------------------------------------------------------------- 1 | 40 2 | targetIdent 3 | 0 4 | MProject 5 | 1 6 | MComponent 7 | 0 8 | 2 9 | WString 10 | 4 11 | NEXE 12 | 3 13 | WString 14 | 5 15 | nw2en 16 | 1 17 | 0 18 | 1 19 | 4 20 | MCommand 21 | 0 22 | 5 23 | MCommand 24 | 0 25 | 6 26 | MItem 27 | 10 28 | yeti3d.exe 29 | 7 30 | WString 31 | 4 32 | NEXE 33 | 8 34 | WVList 35 | 0 36 | 9 37 | WVList 38 | 0 39 | -1 40 | 1 41 | 1 42 | 0 43 | 10 44 | WPickList 45 | 14 46 | 11 47 | MItem 48 | 3 49 | *.c 50 | 12 51 | WString 52 | 4 53 | COBJ 54 | 13 55 | WVList 56 | 1 57 | 14 58 | MVState 59 | 15 60 | WString 61 | 3 62 | WCC 63 | 16 64 | WString 65 | 23 66 | ?????Macro definitions: 67 | 1 68 | 17 69 | WString 70 | 60 71 | __PATCH_DRAW_TEXTURE__ __WINDOWS__ __WIN32__ __YETI_EDITOR__ 72 | 0 73 | 18 74 | WVList 75 | 0 76 | -1 77 | 1 78 | 1 79 | 0 80 | 19 81 | MItem 82 | 16 83 | ..\..\src\data.c 84 | 20 85 | WString 86 | 4 87 | COBJ 88 | 21 89 | WVList 90 | 0 91 | 22 92 | WVList 93 | 0 94 | 11 95 | 1 96 | 1 97 | 0 98 | 23 99 | MItem 100 | 16 101 | ..\..\src\draw.c 102 | 24 103 | WString 104 | 4 105 | COBJ 106 | 25 107 | WVList 108 | 0 109 | 26 110 | WVList 111 | 0 112 | 11 113 | 1 114 | 1 115 | 0 116 | 27 117 | MItem 118 | 16 119 | ..\..\src\font.c 120 | 28 121 | WString 122 | 4 123 | COBJ 124 | 29 125 | WVList 126 | 0 127 | 30 128 | WVList 129 | 0 130 | 11 131 | 1 132 | 1 133 | 0 134 | 31 135 | MItem 136 | 16 137 | ..\..\src\game.c 138 | 32 139 | WString 140 | 4 141 | COBJ 142 | 33 143 | WVList 144 | 0 145 | 34 146 | WVList 147 | 0 148 | 11 149 | 1 150 | 1 151 | 0 152 | 35 153 | MItem 154 | 16 155 | ..\..\src\maps.c 156 | 36 157 | WString 158 | 4 159 | COBJ 160 | 37 161 | WVList 162 | 0 163 | 38 164 | WVList 165 | 0 166 | 11 167 | 1 168 | 1 169 | 0 170 | 39 171 | MItem 172 | 19 173 | ..\..\src\sprites.c 174 | 40 175 | WString 176 | 4 177 | COBJ 178 | 41 179 | WVList 180 | 0 181 | 42 182 | WVList 183 | 0 184 | 11 185 | 1 186 | 1 187 | 0 188 | 43 189 | MItem 190 | 16 191 | ..\..\src\yeti.c 192 | 44 193 | WString 194 | 4 195 | COBJ 196 | 45 197 | WVList 198 | 0 199 | 46 200 | WVList 201 | 0 202 | 11 203 | 1 204 | 1 205 | 0 206 | 47 207 | MItem 208 | 22 209 | ..\win32\yeti3dwin32.c 210 | 48 211 | WString 212 | 4 213 | COBJ 214 | 49 215 | WVList 216 | 0 217 | 50 218 | WVList 219 | 0 220 | 11 221 | 1 222 | 1 223 | 0 224 | 51 225 | MItem 226 | 6 227 | main.c 228 | 52 229 | WString 230 | 4 231 | COBJ 232 | 53 233 | WVList 234 | 0 235 | 54 236 | WVList 237 | 0 238 | 11 239 | 1 240 | 1 241 | 0 242 | 55 243 | MItem 244 | 5 245 | *.lib 246 | 56 247 | WString 248 | 3 249 | NIL 250 | 57 251 | WVList 252 | 0 253 | 58 254 | WVList 255 | 0 256 | -1 257 | 1 258 | 1 259 | 0 260 | 59 261 | MItem 262 | 35 263 | ..\..\..\watcom\lib386\nt\glaux.lib 264 | 60 265 | WString 266 | 3 267 | NIL 268 | 61 269 | WVList 270 | 0 271 | 62 272 | WVList 273 | 0 274 | 55 275 | 1 276 | 1 277 | 0 278 | 63 279 | MItem 280 | 35 281 | ..\..\..\watcom\lib386\nt\glu32.lib 282 | 64 283 | WString 284 | 3 285 | NIL 286 | 65 287 | WVList 288 | 0 289 | 66 290 | WVList 291 | 0 292 | 55 293 | 1 294 | 1 295 | 0 296 | 67 297 | MItem 298 | 38 299 | ..\..\..\watcom\lib386\nt\opengl32.lib 300 | 68 301 | WString 302 | 3 303 | NIL 304 | 69 305 | WVList 306 | 0 307 | 70 308 | WVList 309 | 0 310 | 55 311 | 1 312 | 1 313 | 0 314 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/opengl/yeti3d.wpj: -------------------------------------------------------------------------------- 1 | 40 2 | projectIdent 3 | 0 4 | VpeMain 5 | 1 6 | WRect 7 | 0 8 | 0 9 | 1600 10 | 2800 11 | 2 12 | MProject 13 | 3 14 | MCommand 15 | 0 16 | 4 17 | MCommand 18 | 0 19 | 1 20 | 5 21 | WFileName 22 | 10 23 | yeti3d.tgt 24 | 6 25 | WVList 26 | 1 27 | 7 28 | VComponent 29 | 8 30 | WRect 31 | 0 32 | 0 33 | 5700 34 | 4280 35 | 0 36 | 0 37 | 9 38 | WFileName 39 | 10 40 | yeti3d.tgt 41 | 0 42 | 9 43 | 7 44 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/win32/yeti3dwin32.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #include "yeti3dwin32.h" 40 | 41 | /* 42 | ** Name: keyboard_update 43 | ** Desc: Updates a keyboard structure with the latest keyboard states. These 44 | ** are standard Quake keys. 45 | ** Note: Win32 only. 46 | */ 47 | void keyboard_update(keyboard_t* kb) 48 | { 49 | kb->up = GetAsyncKeyState(VK_UP) < 0; 50 | kb->down = GetAsyncKeyState(VK_DOWN) < 0; 51 | kb->left = GetAsyncKeyState(VK_LEFT) < 0; 52 | kb->right = GetAsyncKeyState(VK_RIGHT) < 0; 53 | kb->a = GetAsyncKeyState(VK_CONTROL) < 0; 54 | kb->b = GetAsyncKeyState(' ') < 0; 55 | kb->l = GetAsyncKeyState('A') < 0; 56 | kb->r = GetAsyncKeyState('Z') < 0; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/platform/win32/yeti3dwin32.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #ifndef __YETI3DWIN32_H__ 40 | #define __YETI3DWIN32_H__ 41 | 42 | #include 43 | #include "../../src/game.h" 44 | 45 | #ifdef __cplusplus 46 | extern "C"{ 47 | #endif 48 | 49 | void keyboard_update(keyboard_t* kb); 50 | 51 | #ifdef __cplusplus 52 | }; 53 | #endif 54 | 55 | #endif 56 | 57 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/readme.txt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | */ 32 | 33 | The Yeti 3D Engine - 1:35 AM 10/24/2003 34 | ======================================= 35 | 36 | How to compile 37 | ============== 38 | 39 | You will need to download and install GCC for the GBA. I currently use 40 | DevKit Advanced: http://devkitadv.sourceforge.net/index.html 41 | 42 | Once you have GCC installed, run the make.bat script to create a new build. 43 | 44 | I have GCC installed in the folder "C:\devkitadv\", so if you install somewhere 45 | else then you will need to change the make.bat script a little. 46 | 47 | Contacts 48 | ======== 49 | 50 | If you would like a copy of the latest code or to ask what my future plans are, 51 | email myself at: 52 | 53 | derek@theteahouse.com.au 54 | 55 | At some stage I'd like to optimize the texture mapper for the GBA, but that will 56 | be after im 100% sure the C++ is as fast as it can be. 57 | 58 | Contact me if you would like to contribute to the project. The latest version can be 59 | downloaded from: 60 | 61 | http://www.theteahouse.com.au/gba/index.html 62 | 63 | Engine Technical Notes 64 | ====================== 65 | 66 | These are design notes for the Yeti engine. Other engines use very different algorithms. 67 | Im still refining the engine to improve quality while maintaining a acceptable rendering 68 | speed. 69 | 70 | - The current viewport is 120x80 pixels, 15bit. 71 | - All textures are 64x64 8bit. 72 | - Textures are converted to 15bit via a pre-calculated lighting LUT. 73 | - Polygons can be any convex shape. Only squares are currently used. 74 | - Each vertex is described as X, Y, Z, U, V and brightness. 75 | - The renderer uses 24:8 fixed point maths. 76 | - Polygons are clipped in 3D space using 45 degree planes. Distance to plane 77 | calculations therefore use only additions and subtractions. 78 | - Polygon edges are clipped using one divide and 6 multiplies. 79 | - 4 clipping planes are used. No front plane is required. No back plane is used. 80 | - No per-span clipping is used. Fixed point errors are hidden offscreen. 81 | - Ray-casting is used to build a visablity list and valid polygon rendering order. 82 | - Models are merged into the VIS without sorting. 83 | - No Z-buffers are used. Rendering is back-to-front (painters algorithm). 84 | - The is an acceptable level of overdraw. Complete polygons are culled. Polygon edges 85 | are drawn faster than using a per span clipper. 86 | - Lighting is pre-calculated on startup. Lighting can be moved at runtime. 87 | - Lighting is expanded per vertex and interpolated along polygon edges. 88 | - A reciprocal table is used to eliminate all divides from the DDA texture mapper. 89 | - The affine texture loop is unrolled and renders blocks of 32 pixels. 90 | 91 | Kinda Regards 92 | Derek Evans 93 | derek@theteahouse.com.au 94 | 95 | 1:35 AM 10/24/2003 -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/src/data.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __DATA_H__ 3 | #define __DATA_H__ 4 | #include "yeti.h" 5 | #endif 6 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/src/extra.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #include "extra.h" 40 | 41 | /******************************************************************************/ 42 | 43 | void* yeti_load_file(char* filename) 44 | { 45 | void* r = 0; 46 | FILE* fp = fopen(filename, "rb"); 47 | 48 | if (fp) 49 | { 50 | if (!fseek(fp, 0, SEEK_END)) 51 | { 52 | int n = ftell(fp); 53 | if ((r = malloc(n)) != 0) 54 | { 55 | fseek(fp, 0, SEEK_SET); 56 | fread(r, 1, n, fp); 57 | } 58 | } 59 | fclose(fp); 60 | } 61 | return r; 62 | } 63 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/src/extra.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #ifndef __EXTRA_H__ 40 | #define __EXTRA_H__ 41 | 42 | #include "yeti.h" 43 | 44 | /******************************************************************************/ 45 | 46 | #include 47 | #include 48 | 49 | #ifdef __cplusplus 50 | extern "C"{ 51 | #endif 52 | 53 | void* yeti_load_file(char* filename); 54 | 55 | #ifdef __cplusplus 56 | }; 57 | #endif 58 | 59 | /******************************************************************************/ 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/src/font.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | #ifndef __FONT_H_ 26 | #define __FONT_H_ 27 | 28 | #define FONT_WIDTH 8 29 | #define FONT_HEIGHT 728 30 | 31 | extern const unsigned short Palette[]; 32 | extern const unsigned short fontData[]; 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/src/game.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #ifndef __GAME_H__ 40 | #define __GAME_H__ 41 | 42 | #include "yeti.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C"{ 46 | #endif 47 | 48 | extern void game_init(yeti_t* yeti); 49 | extern void game_draw(yeti_t* yeti); 50 | extern void game_tick(yeti_t* yeti); 51 | extern void game_loop(yeti_t* yeti); 52 | 53 | #ifdef __cplusplus 54 | } // extern "C" 55 | #endif 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/src/maps.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #include "yeti.h" 40 | 41 | #include "maps/e1m1.c" 42 | 43 | 44 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/src/model.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #include "model.h" 40 | 41 | /******************************************************************************/ 42 | 43 | #undef CODE_IN_IWRAM 44 | #define CODE_IN_IWRAM 45 | 46 | void CODE_IN_IWRAM md2_tmap(vertex_t* p, int n, YETI_ROM u16* texture, int textsize, framebuffer_t* dst) 47 | { 48 | int lt_i, lt_x, lt_xx, lt_u, lt_uu, lt_v, lt_vv; 49 | int rt_i, rt_x, rt_xx, rt_u, rt_uu, rt_v, rt_vv; 50 | int x1, x2, i, j, u, uu, v, vv; 51 | int lt_length = 0, rt_length = 0; 52 | int y1 = 999999, y2 = -999999; 53 | 54 | for (i = n; i--;) 55 | { 56 | p[i].d = fixup(p[i].y); 57 | if (p[i].y < y1) {y1 = p[i].y; lt_i = rt_i = i;} 58 | if (p[i].y > y2) {y2 = p[i].y;} 59 | } 60 | 61 | if ((y1 = fixup(y1)) < YETI_VIEWPORT_Y1) y1 = YETI_VIEWPORT_Y1; 62 | if ((y2 = fixup(y2)) > YETI_VIEWPORT_Y2) y2 = YETI_VIEWPORT_Y2; 63 | 64 | for (; y1 < y2; y1++) 65 | { 66 | if (--lt_length <= 0) 67 | { 68 | do { 69 | i = lt_i--; if (lt_i < 0) lt_i = n - 1; 70 | } while ((lt_length = p[lt_i].d - p[i].d) <= 0); 71 | 72 | j = reciprocal[lt_length]; 73 | 74 | lt_xx = r2i((p[lt_i].x - (lt_x = p[i].x)) * j); 75 | lt_uu = r2i((p[lt_i].u - (lt_u = p[i].u)) * j); 76 | lt_vv = r2i((p[lt_i].v - (lt_v = p[i].v)) * j); 77 | } 78 | if (--rt_length <= 0) 79 | { 80 | do { 81 | i = rt_i++; if (rt_i >= n) rt_i = 0; 82 | } while ((rt_length = p[rt_i].d - p[i].d) <= 0); 83 | 84 | j = reciprocal[rt_length]; 85 | 86 | rt_xx = r2i((p[rt_i].x - (rt_x = p[i].x)) * j); 87 | rt_uu = r2i((p[rt_i].u - (rt_u = p[i].u)) * j); 88 | rt_vv = r2i((p[rt_i].v - (rt_v = p[i].v)) * j); 89 | } 90 | if ((x1 = fixup(lt_x)) < YETI_VIEWPORT_X1) x1 = YETI_VIEWPORT_X1; 91 | if ((x2 = fixup(rt_x)) > YETI_VIEWPORT_X2) x2 = YETI_VIEWPORT_X2; 92 | 93 | if ((i = x2 - x1) > 0) 94 | { 95 | #ifndef DBL_PIXEL 96 | u16* fb = &dst->pixels[y1][x1]; 97 | 98 | j = reciprocal[i]; 99 | uu = r2i((rt_u - (u = lt_u)) * j); u -= uu; 100 | vv = r2i((rt_v - (v = lt_v)) * j); v -= vv; 101 | 102 | #define AFFINE(I) fb[I] = texture[(f2i(v+=vv) << textsize) + f2i(u+=uu)]; 103 | AFFINE_LOOP; 104 | #undef AFFINE 105 | #else 106 | u32* fb = &dst->pixels[y1][x1]; 107 | 108 | j = reciprocal[i]; 109 | uu = r2i((rt_u - (u = lt_u)) * j); u -= uu; 110 | vv = r2i((rt_v - (v = lt_v)) * j); v -= vv; 111 | 112 | #define AFFINE(I) {u32 c = texture[(f2i(v+=vv) << textsize) + f2i(u+=uu)]; fb[I] = c|(c<<16);} 113 | AFFINE_LOOP; 114 | #undef AFFINE 115 | #endif 116 | } 117 | lt_x += lt_xx; lt_u += lt_uu; lt_v += lt_vv; 118 | rt_x += rt_xx; rt_u += rt_uu; rt_v += rt_vv; 119 | } 120 | } 121 | 122 | void CODE_IN_IWRAM md2_clipped_poly(yeti_t* yeti, polyclip_t src, int n, u16* skin) 123 | { 124 | int i; 125 | polygon_t p; 126 | 127 | for (i = n; i--;) 128 | { 129 | p[i].x = src[i]->sx; 130 | p[i].y = src[i]->sy; 131 | p[i].u = src[i]->u; 132 | p[i].v = src[i]->v; 133 | } 134 | 135 | md2_tmap(p, n, skin, 8, yeti->viewport.back); 136 | } 137 | 138 | void CODE_IN_IWRAM md2_unclipped_poly(yeti_t* yeti, polyclip_t p, int n, u16* skin) 139 | { 140 | int i; 141 | 142 | for (i = n; i--;) 143 | { 144 | if ( 145 | (p[i]->x + p[i]->z) < 0 || 146 | (p[i]->z - p[i]->x) < 0 || 147 | (p[i]->y + p[i]->z) < 0 || 148 | (p[i]->z - p[i]->y) < 0 ) 149 | { 150 | polyclip_t a, b; 151 | 152 | for (i = n; i--; p[i]->d = p[i]->x + p[i]->z); n = polygon_clip(yeti, a, p, n); // Left 153 | for (i = n; i--; a[i]->d = a[i]->z - a[i]->x); n = polygon_clip(yeti, b, a, n); // Right 154 | for (i = n; i--; b[i]->d = b[i]->y + b[i]->z); n = polygon_clip(yeti, a, b, n); // Top 155 | for (i = n; i--; a[i]->d = a[i]->z - a[i]->y); n = polygon_clip(yeti, b, a, n); // Bottom 156 | 157 | p = b; 158 | 159 | break; 160 | } 161 | } 162 | if (n > 2) md2_clipped_poly(yeti, p, n, skin); 163 | } 164 | 165 | /******************************************************************************/ 166 | 167 | #ifdef __WIN32__ 168 | 169 | extern skin_t skin; 170 | 171 | typedef struct 172 | { 173 | short next; 174 | short triangle; 175 | } bucket_node_t; 176 | 177 | void md2_draw(entity_t* e) 178 | { 179 | int i, j, bid; 180 | polyclip_t p; 181 | int nnodes = 0; 182 | static short buckets[YETI_TRIANGLE_BUCKET_MAX]; 183 | static bucket_node_t nodes[1000]; 184 | static vertex_t verts[1000]; 185 | matrix_t m; 186 | yeti_t* yeti = e->yeti; 187 | model_t* model = e->visual.data; 188 | frame_t* f = (frame_t*)((int)model + model->offsetFrames + model->frameSize * (((yeti->tick/3) % 6)+40)); 189 | triangle_t* t = (triangle_t*)((int)model + model->offsetTriangles); 190 | textureCoordinate_t* tc = (textureCoordinate_t*)((int)model + model->offsetTexCoords); 191 | 192 | matrix_rotate_object(m, f2i(e->r), f2i(e->p), f2i(e->t)-512); 193 | 194 | for (i = 0; i < model->numVertices; i++) 195 | { 196 | int u = (f->vertices[i].vertex[0] * f->scale[0] + f->translate[0]) * 10; 197 | int w = (f->vertices[i].vertex[1] * f->scale[1] + f->translate[1]) * 10; 198 | int v = (f->vertices[i].vertex[2] * f->scale[2] + f->translate[2]) * 10 - 128; 199 | int x = f2i(m[0][0] * u + m[0][1] * v + m[0][2] * w) + e->x - yeti->camera->x; 200 | int y = f2i(m[1][0] * u + m[1][1] * v + m[1][2] * w) + e->z - yeti->camera->z; 201 | int z = f2i(m[2][0] * u + m[2][1] * v + m[2][2] * w) + e->y - yeti->camera->y; 202 | 203 | verts[i].x = f2i(yeti->m[0][0] * x + yeti->m[0][1] * y + yeti->m[0][2] * z); 204 | verts[i].y = yeti->is2d ? y : f2i(yeti->m[1][0] * x + yeti->m[1][1] * y + yeti->m[1][2] * z); 205 | verts[i].z = f2i(yeti->m[2][0] * x + yeti->m[2][1] * y + yeti->m[2][2] * z); 206 | 207 | vertex_project(&verts[i]); 208 | } 209 | for (i = 0; i < model->numTriangles; i++) 210 | { 211 | bid = ((e->y - yeti->camera->y - verts[t[i].vertexIndices[0]].z) >> 6) + 212 | (YETI_TRIANGLE_BUCKET_MAX>>1); 213 | 214 | bid = CLAMP(bid, 0, YETI_TRIANGLE_BUCKET_MAX - 1); 215 | 216 | nodes[nnodes].next = buckets[bid]; 217 | nodes[nnodes].triangle = i; 218 | buckets[bid] = nnodes++; 219 | } 220 | for (bid = 0; bid < YETI_TRIANGLE_BUCKET_MAX; bid++) 221 | { 222 | for (i = buckets[bid]; i; i = nodes[i].next) 223 | { 224 | for (j = 0; j < 3; j++) 225 | { 226 | p[j] = &verts[t[i].vertexIndices[j]]; 227 | p[j]->u = (int)tc[t[i].textureIndices[j]].s * i2f(256) / model->skinWidth; 228 | p[j]->v = (int)tc[t[i].textureIndices[j]].t * i2f(256) / model->skinHeight; 229 | } 230 | md2_unclipped_poly(yeti, p, 3, skin[0]); 231 | } 232 | buckets[bid] = 0; 233 | } 234 | } 235 | 236 | #endif 237 | 238 | 239 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/src/model.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | /* 26 | ** Name: Yeti3D 27 | ** Desc: Portable GameBoy Advanced 3D Engine 28 | ** Auth: Derek J. Evans 29 | ** 30 | ** Copyright (C) 2003 Derek J. Evans. All Rights Reserved. 31 | ** 32 | ** YY YY EEEEEE TTTTTT IIIIII 33333 DDDDD 33 | ** YY YY EE TT II 33 DD DD 34 | ** YYYY EEEE TT II 333 DD DD 35 | ** YY EE TT II 33 DD DD 36 | ** YY EEEEEE TT IIIIII 33333 DDDDD 37 | */ 38 | 39 | #ifndef __MODEL_H__ 40 | #define __MODEL_H__ 41 | 42 | #include "yeti.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C"{ 46 | #endif 47 | 48 | typedef struct 49 | { 50 | float u, v; 51 | int vindex; 52 | } md2command_t; 53 | 54 | typedef struct 55 | { 56 | int magic; 57 | int version; 58 | int skinWidth; 59 | int skinHeight; 60 | int frameSize; 61 | int numSkins; 62 | int numVertices; 63 | int numTexCoords; 64 | int numTriangles; 65 | int numGlCommands; 66 | int numFrames; 67 | int offsetSkins; 68 | int offsetTexCoords; 69 | int offsetTriangles; 70 | int offsetFrames; 71 | int offsetGlCommands; 72 | int offsetEnd; 73 | } model_t; 74 | 75 | typedef struct 76 | { 77 | short vertexIndices[3]; 78 | short textureIndices[3]; 79 | } triangle_t; 80 | 81 | typedef struct 82 | { 83 | short s, t; 84 | } textureCoordinate_t; 85 | 86 | typedef struct 87 | { 88 | byte vertex[3]; 89 | byte lightNormalIndex; 90 | } triangleVertex_t; 91 | 92 | typedef struct 93 | { 94 | float scale[3]; 95 | float translate[3]; 96 | char name[16]; 97 | triangleVertex_t vertices[1]; 98 | } frame_t; 99 | 100 | void md2_draw(entity_t* e); 101 | 102 | #ifdef __cplusplus 103 | }; 104 | #endif 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /examples/Yeti3D-GPL/src/sprites.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2003 - Derek John Evans 3 | 4 | This file is part of Yeti3D Portable Engine 5 | 6 | Yeti3D is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU General Public License 8 | as published by the Free Software Foundation; either version 2 9 | of the License, or (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | 15 | See the GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program; if not, write to the Free Software 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 | 21 | Original Source: 2003 - Derek J. Evans 22 | Prepared for public release: 10/24/2003 - Derek J. Evans 23 | */ 24 | 25 | #ifndef __SPRITES__ 26 | #define __SPRITES__ 27 | #include "yeti.h" 28 | #define YETI_SPRITE_MAX 5 29 | extern YETI_ROM sprite_t sprites[]; 30 | extern YETI_ROM u16 spr_00[]; 31 | extern YETI_ROM u16 spr_01[]; 32 | extern YETI_ROM u16 spr_02[]; 33 | extern YETI_ROM u16 spr_03[]; 34 | extern YETI_ROM u16 spr_ball1[]; 35 | #endif 36 | -------------------------------------------------------------------------------- /ldscripts/makefile-gen: -------------------------------------------------------------------------------- 1 | # SEGA MD/CD/32X toolchain makefile by Chilly Willy 2 | # adapted from Jim Ursetto' makefile for the DC 3 | # adapted from Stalin's build script version 0.3 4 | # 5 | # Interesting parameters: 6 | # erase=0|1 Erase build directories on the fly to save space 7 | # thread_model=posix|single Set gcc threading model 8 | # verbose=0|1 Display 9 | # 10 | # Interesting targets (you can 'make' any of these): 11 | # all: build 12 | # build: build-sh2 build-m68k 13 | # build-sh2: build-sh2-binutils build-sh2-gcc 14 | # build-m68k: build-m68k-binutils build-m68k-gcc 15 | # build-sh2-gcc: build-sh2-gcc-pass1 build-sh2-newlib build-sh2-gcc-pass2 16 | # build-m68k-gcc: build-m68k-gcc-pass1 build-m68k-newlib build-m68k-gcc-pass2 17 | # build-sh2-newlib: build-sh2-newlib-only 18 | # build-m68k-newlib: build-m68k-newlib-only 19 | 20 | # User configuration 21 | sh_target=sh-elf 22 | m68k_target=m68k-elf 23 | sh_prefix := /opt/toolchains/sega/$(sh_target) 24 | m68k_prefix := /opt/toolchains/sega/$(m68k_target) 25 | binutils_ver=2.28 26 | gcc_ver=8.3.0 27 | newlib_ver=2.5.0 28 | thread_model=single 29 | erase=0 30 | verbose=1 31 | # Set the languages to build for pass 2 of building gcc. The default 32 | # here is to build C, C++, Objective C, and Objective C++. You may want to take 33 | # out the latter two if you're not worried about them and/or you're short on 34 | # hard drive space. 35 | pass2_languages=c,c++,objc,obj-c++ 36 | 37 | # build variables 38 | install=$(prefix)/bin 39 | pwd := $(shell pwd) 40 | logdir := $(pwd)/logs 41 | PATH := $(sh_prefix)/bin:$(m68k_prefix)/bin:$(PATH) 42 | binutils_dir=binutils-$(binutils_ver) 43 | gcc_dir=gcc-$(gcc_ver) 44 | newlib_dir=newlib-$(newlib_ver) 45 | 46 | all: build 47 | 48 | # ---- build {{{ 49 | 50 | build: build-sh2 build-m68k 51 | build-sh2: build-sh2-binutils build-sh2-gcc 52 | build-m68k: build-m68k-binutils build-m68k-gcc 53 | build-sh2-gcc: build-sh2-gcc-pass1 build-sh2-newlib build-sh2-gcc-pass2 54 | build-m68k-gcc: build-m68k-gcc-pass1 build-m68k-newlib build-m68k-gcc-pass2 55 | build-sh2-newlib: build-sh2-newlib-only 56 | build-m68k-newlib: build-m68k-newlib-only 57 | 58 | # Ensure that, no matter where we enter, prefix and target are set correctly. 59 | build_sh2_targets=build-sh2-binutils build-sh2-gcc build-sh2-gcc-pass1 build-sh2-newlib build-sh2-newlib-only build-sh2-gcc-pass2 60 | build_m68k_targets=build-m68k-binutils build-m68k-gcc build-m68k-gcc-pass1 build-m68k-newlib build-m68k-newlib-only build-m68k-gcc-pass2 61 | $(build_sh2_targets): prefix = $(sh_prefix) 62 | $(build_sh2_targets): target = $(sh_target) 63 | $(build_sh2_targets): extra_configure_args = --with-endian=big --with-cpu=m2 --disable-werror --disable-multilib 64 | $(build_m68k_targets): prefix = $(m68k_prefix) 65 | $(build_m68k_targets): target = $(m68k_target) 66 | $(build_m68k_targets): extra_configure_args = --with-cpu=m68000 --disable-werror --disable-multilib 67 | 68 | # To avoid code repetition, we use the same commands for both 69 | # architectures. But we can't create a single target called 70 | # build-binutils for both sh2 and m68k, because phony targets 71 | # can't be run multiple times. So we create multiple targets. 72 | build_binutils = build-sh2-binutils build-m68k-binutils 73 | build_gcc_pass1 = build-sh2-gcc-pass1 build-m68k-gcc-pass1 74 | build_newlib = build-sh2-newlib-only build-m68k-newlib-only 75 | build_gcc_pass2 = build-sh2-gcc-pass2 build-m68k-gcc-pass2 76 | 77 | # Here we use the essentially same code for multiple targets, 78 | # differing only by the current state of the variables below. 79 | $(build_binutils): build = build-binutils-$(target)-$(binutils_ver) 80 | $(build_binutils): src_dir = binutils-$(binutils_ver) 81 | $(build_binutils): log = $(logdir)/$(build).log 82 | $(build_binutils): logdir 83 | @echo "+++ Building $(src_dir) to $(build)..." 84 | -mkdir -p $(build) 85 | > $(log) 86 | cd $(build); ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) --disable-werror --enable-install-libbfd $(extra_configure_args) $(to_log) 87 | make -C $(build) all install DESTDIR=$(DESTDIR) $(to_log) 88 | $(clean_up) 89 | 90 | $(build_gcc_pass1) $(build_gcc_pass2): build = build-gcc-$(target)-$(gcc_ver) 91 | $(build_gcc_pass1) $(build_gcc_pass2): src_dir = gcc-$(gcc_ver) 92 | $(build_gcc_pass1): log = $(logdir)/$(build)-pass1.log 93 | $(build_gcc_pass1): logdir 94 | @echo "+++ Building $(src_dir) to $(build) (pass 1)..." 95 | -mkdir -p $(build) 96 | > $(log) 97 | cd $(build); ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) --without-headers --with-newlib --enable-languages=c --disable-libssp --disable-tls $(extra_configure_args) $(to_log) 98 | make -C $(build) all-gcc install-gcc DESTDIR=$(DESTDIR) $(to_log) 99 | 100 | $(build_newlib): build = build-newlib-$(target)-$(newlib_ver) 101 | $(build_newlib): src_dir = newlib-$(newlib_ver) 102 | $(build_newlib): log = $(logdir)/$(build).log 103 | $(build_newlib): logdir 104 | @echo "+++ Building $(src_dir) to $(build)..." 105 | -mkdir -p $(build) 106 | > $(log) 107 | cd $(build); ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) $(extra_configure_args) $(to_log) 108 | make -C $(build) all install DESTDIR=$(DESTDIR) $(to_log) 109 | $(clean_up) 110 | 111 | $(build_gcc_pass2): log = $(logdir)/$(build)-pass2.log 112 | $(build_gcc_pass2): logdir 113 | @echo "+++ Building $(src_dir) to $(build) (pass 2)..." 114 | -mkdir -p $(build) 115 | > $(log) 116 | cd $(build); ../$(src_dir)/configure --target=$(target) --prefix=$(prefix) --with-newlib --disable-libssp --disable-tls \ 117 | --enable-threads=$(thread_model) --enable-languages=$(pass2_languages) $(extra_configure_args) $(to_log) 118 | make -C $(build) all install DESTDIR=$(DESTDIR) $(to_log) 119 | $(clean_up) 120 | 121 | # ---- }}}} 122 | 123 | 124 | # ---- support {{{ 125 | 126 | clean: 127 | -rm -rf build-newlib-$(sh_target)-$(newlib_ver) 128 | -rm -rf build-newlib-$(m68k_target)-$(newlib_ver) 129 | -rm -rf build-gcc-$(sh_target)-$(gcc_ver) 130 | -rm -rf build-gcc-$(m68k_target)-$(gcc_ver) 131 | -rm -rf build-binutils-$(sh_target)-$(binutils_ver) 132 | -rm -rf build-binutils-$(m68k_target)-$(binutils_ver) 133 | 134 | logdir: 135 | @mkdir -p $(logdir) 136 | 137 | # If erase=1, erase build directories on the fly. 138 | ifeq (1,$(erase)) 139 | define clean_up 140 | @echo "+++ Cleaning up $(build)..." 141 | -rm -rf $(build) 142 | endef 143 | endif 144 | 145 | # If verbose=1, display output to screen as well as log files 146 | ifeq (1,$(verbose)) 147 | to_log = 2>&1 | tee -a $(log) 148 | else 149 | to_log = >> $(log) 2>&1 150 | endif 151 | 152 | # ---- }}} 153 | 154 | # ---- phony targets {{{ 155 | 156 | .PHONY: all build build-sh2 build-m68k $(build_sh2_targets) $(build_m68k_targets) clean 157 | .PHONY: build-binutils build-newlib build-gcc-pass1 build-gcc-pass2 158 | 159 | # ---- }}}} 160 | -------------------------------------------------------------------------------- /ldscripts/mars-myth-sdram.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_ARCH(sh) 2 | SEARCH_DIR(.) 3 | __DYNAMIC = 0; 4 | 5 | /* 6 | * The memory map look like this: 7 | * +--------------------+ <- 0x02300000 8 | * | .text | 9 | * | _etext | 10 | * | ctor list | the ctor and dtor lists are for 11 | * | dtor list | C++ support 12 | * +--------------------+ 13 | * . . 14 | * . . 15 | * . . 16 | * +--------------------+ <- 0x06000000 17 | * | .data | initialized data goes here 18 | * | _edata | 19 | * +--------------------+ 20 | * | .bss | 21 | * | __bss_start | start of bss, cleared by crt0 22 | * | _end | start of heap, used by sbrk() 23 | * +--------------------+ 24 | * . . 25 | * . . 26 | * . . 27 | * | __stack | top of stack (for Master SH2) 28 | * +--------------------+ <- 0x0603FC00 29 | */ 30 | 31 | MEMORY 32 | { 33 | psram (wx) : ORIGIN = 0x02300000, LENGTH = 0x00100000 34 | ram (wx) : ORIGIN = 0x06000000, LENGTH = 0x0003FC00 35 | } 36 | 37 | /* 38 | * Allocate the stack to be at the top of memory, since the stack 39 | * grows down 40 | */ 41 | 42 | PROVIDE (__stack = 0x0603FC00); 43 | 44 | SECTIONS 45 | { 46 | .text 0x02300000 : 47 | AT ( 0x00000000 ) 48 | { 49 | *(.text .text.*) 50 | . = ALIGN(0x4); 51 | __CTOR_LIST__ = .; 52 | ___CTOR_LIST__ = .; 53 | LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) 54 | *(.ctors) 55 | LONG(0) 56 | __CTOR_END__ = .; 57 | __DTOR_LIST__ = .; 58 | ___DTOR_LIST__ = .; 59 | LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) 60 | *(.dtors) 61 | LONG(0) 62 | __DTOR_END__ = .; 63 | *(.rodata .rodata.*) 64 | *(.gcc_except_table) 65 | 66 | . = ALIGN(0x2); 67 | __INIT_SECTION__ = . ; 68 | *(.init) 69 | SHORT (0x000B) /* rts */ 70 | SHORT (0x0009) /* nop */ 71 | 72 | __FINI_SECTION__ = . ; 73 | *(.fini) 74 | SHORT (0x000B) /* rts */ 75 | SHORT (0x0009) /* nop */ 76 | 77 | _etext = .; 78 | *(.lit) 79 | } > psram 80 | _stext = SIZEOF (.text); 81 | 82 | .data 0x06000000 : 83 | AT ( LOADADDR (.text) + SIZEOF (.text) ) 84 | { 85 | *(.got.plt) *(.got) 86 | *(.shdata) 87 | *(.data .data.*) 88 | _edata = .; 89 | } > ram 90 | _sdata = SIZEOF (.data); 91 | 92 | .bss 0x06000000 + SIZEOF (.data) : 93 | { 94 | . = ALIGN(0x4); 95 | __bss_start = . ; 96 | *(.shbss) 97 | *(.bss .bss.*) 98 | *(COMMON) 99 | _end = ALIGN (0x8); 100 | __end = _end; 101 | end = _end; 102 | } > ram 103 | 104 | .stab 0 (NOLOAD) : 105 | { 106 | *(.stab) 107 | } 108 | 109 | .stabstr 0 (NOLOAD) : 110 | { 111 | *(.stabstr) 112 | } 113 | 114 | .eh_frame 0 (NOLOAD) : 115 | { 116 | *(.eh_frame) 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /ldscripts/mars.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_ARCH(sh) 2 | EXTERN (_start) 3 | ENTRY (_start) 4 | __DYNAMIC = 0; 5 | 6 | /* 7 | * The memory map look like this: 8 | * +--------------------+ <- 0x02000000 9 | * | .text | 10 | * | | 11 | * | __text_end | 12 | * +--------------------+ 13 | * . . 14 | * . . 15 | * . . 16 | * +--------------------+ <- 0x06000000 17 | * | .data | initialized data goes here 18 | * | | 19 | * | __data_end | 20 | * +--------------------+ 21 | * | .bss | 22 | * | __bss_start | start of bss, cleared by crt0 23 | * | | 24 | * | __bss__end | start of heap, used by sbrk() 25 | * +--------------------+ 26 | * . . 27 | * . . 28 | * . . 29 | * | __stack | top of stack (for Master SH2) 30 | * +--------------------+ <- 0x0603FC00 31 | */ 32 | 33 | MEMORY 34 | { 35 | rom (rx) : ORIGIN = 0x02000000, LENGTH = 0x00400000 36 | ram (wx) : ORIGIN = 0x06000000, LENGTH = 0x0003FC00 37 | } 38 | 39 | /* 40 | * Allocate the stack to be at the top of memory, since the stack 41 | * grows down 42 | */ 43 | 44 | PROVIDE (__stack = 0x0603FC00); 45 | 46 | SECTIONS 47 | { 48 | .text 0x02000000 : 49 | AT ( 0x00000000 ) 50 | { 51 | __text_start = .; 52 | *(.text) 53 | *(.text.*) 54 | *(.gnu.linkonce.t.*) 55 | 56 | . = ALIGN(16); 57 | __INIT_SECTION__ = .; 58 | KEEP (*(.init)) 59 | SHORT (0x000B) /* rts */ 60 | SHORT (0x0009) /* nop */ 61 | . = ALIGN(16); 62 | __FINI_SECTION__ = .; 63 | KEEP (*(.fini)) 64 | SHORT (0x000B) /* rts */ 65 | SHORT (0x0009) /* nop */ 66 | 67 | *(.eh_frame_hdr) 68 | KEEP (*(.eh_frame)) 69 | *(.gcc_except_table) 70 | KEEP (*(.jcr)) 71 | 72 | . = ALIGN(16); 73 | __CTOR_LIST__ = .; 74 | ___CTOR_LIST__ = .; 75 | LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) 76 | KEEP (*(SORT(.ctors.*))) 77 | KEEP (*(.ctors)) 78 | LONG(0) 79 | __CTOR_END__ = .; 80 | 81 | . = ALIGN(16); 82 | __DTOR_LIST__ = .; 83 | ___DTOR_LIST__ = .; 84 | LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) 85 | KEEP (*(SORT(.dtors.*))) 86 | KEEP (*(.dtors)) 87 | LONG(0) 88 | __DTOR_END__ = .; 89 | 90 | *(.rdata) 91 | *(.rodata) 92 | *(.rodata.*) 93 | *(.gnu.linkonce.r.*) 94 | . = ALIGN(16); 95 | __text_end = .; 96 | } > rom 97 | __text_size = __text_end - __text_start; 98 | _stext = __text_size; 99 | 100 | .data 0x06000000 : 101 | AT ( LOADADDR (.text) + SIZEOF (.text) ) 102 | { 103 | __data_start = .; 104 | *(.data) 105 | *(.data.*) 106 | *(.gnu.linkonce.d.*) 107 | CONSTRUCTORS 108 | 109 | *(.lit8) 110 | *(.lit4) 111 | *(.sdata) 112 | *(.sdata.*) 113 | *(.gnu.linkonce.s.*) 114 | . = ALIGN(16); 115 | __data_end = .; 116 | } > ram 117 | __data_size = __data_end - __data_start; 118 | _sdata = __data_size; 119 | .bss : 120 | { 121 | __bss_start = .; 122 | *(.bss) 123 | *(.bss.*) 124 | *(.gnu.linkonce.b.*) 125 | *(.sbss) 126 | *(.sbss.*) 127 | *(.gnu.linkonce.sb.*) 128 | *(.scommon) 129 | *(COMMON) 130 | . = ALIGN(16); 131 | end = .; 132 | _end = end; 133 | __end = _end; 134 | __bss_end = .; 135 | } > ram 136 | __bss_size = __bss_end - __bss_start; 137 | 138 | } 139 | -------------------------------------------------------------------------------- /ldscripts/md-myth-psram.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_ARCH(m68k) 2 | SEARCH_DIR(.) 3 | __DYNAMIC = 0; 4 | 5 | /* 6 | * The memory map look like this: 7 | * +--------------------+ <- 0x00300000 8 | * | .text | 9 | * | _etext | 10 | * | ctor list | the ctor and dtor lists are for 11 | * | dtor list | C++ support 12 | * +--------------------+ 13 | * | .data | initialized data goes here 14 | * | _edata | 15 | * +--------------------+ 16 | * | .bss | 17 | * | __bss_start | start of bss, cleared by crt0 18 | * | _end | start of heap, used by sbrk() 19 | * +--------------------+ 20 | * . . 21 | * . . 22 | * . . 23 | * | __stack | top of stack 24 | * +--------------------+ <- 0x00400000 25 | * 26 | * Note - variables in Myth ram MUST be written as words 27 | */ 28 | 29 | MEMORY 30 | { 31 | psram (wx) : ORIGIN = 0x00300000, LENGTH = 0x00100000 32 | } 33 | 34 | /* 35 | * Allocate the stack to be at the top of memory, since the stack 36 | * grows down 37 | */ 38 | 39 | PROVIDE (__stack = 4M); 40 | 41 | SECTIONS 42 | { 43 | .text 0x00300000 : 44 | AT ( 0x00000000 ) 45 | { 46 | *(.text .text.*) 47 | . = ALIGN(0x4); 48 | __CTOR_LIST__ = .; 49 | ___CTOR_LIST__ = .; 50 | LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) 51 | *(.ctors) 52 | LONG(0) 53 | __CTOR_END__ = .; 54 | __DTOR_LIST__ = .; 55 | ___DTOR_LIST__ = .; 56 | LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) 57 | *(.dtors) 58 | LONG(0) 59 | __DTOR_END__ = .; 60 | *(.rodata .rodata.*) 61 | *(.gcc_except_table) 62 | 63 | . = ALIGN(0x2); 64 | __INIT_SECTION__ = . ; 65 | LONG (0x4E560000) /* linkw %fp,#0 */ 66 | *(.init) 67 | SHORT (0x4E5E) /* unlk %fp */ 68 | SHORT (0x4E75) /* rts */ 69 | 70 | __FINI_SECTION__ = . ; 71 | LONG (0x4E560000) /* linkw %fp,#0 */ 72 | *(.fini) 73 | SHORT (0x4E5E) /* unlk %fp */ 74 | SHORT (0x4E75) /* rts */ 75 | 76 | _etext = .; 77 | *(.lit) 78 | } > psram 79 | _stext = SIZEOF (.text); 80 | 81 | .data : 82 | AT ( LOADADDR (.text) + SIZEOF (.text) ) 83 | { 84 | *(.got.plt) *(.got) 85 | *(.shdata) 86 | *(.data .data.*) 87 | _edata = .; 88 | } > psram 89 | _sdata = SIZEOF (.data); 90 | 91 | .bss : 92 | { 93 | . = ALIGN(0x4); 94 | __bss_start = . ; 95 | *(.shbss) 96 | *(.bss .bss.*) 97 | *(COMMON) 98 | _end = ALIGN (0x8); 99 | __end = _end; 100 | end = _end; 101 | } > psram 102 | 103 | .stab 0 (NOLOAD) : 104 | { 105 | *(.stab) 106 | } 107 | 108 | .stabstr 0 (NOLOAD) : 109 | { 110 | *(.stabstr) 111 | } 112 | 113 | .eh_frame 0 (NOLOAD) : 114 | { 115 | *(.eh_frame) 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /ldscripts/md-myth-wram.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_ARCH(m68k) 2 | SEARCH_DIR(.) 3 | __DYNAMIC = 0; 4 | 5 | /* 6 | * The memory map look like this: 7 | * +--------------------+ <- 0x00300000 8 | * | .text | 9 | * | _etext | 10 | * | ctor list | the ctor and dtor lists are for 11 | * | dtor list | C++ support 12 | * +--------------------+ 13 | * . . 14 | * . . 15 | * . . 16 | * +--------------------+ <- 0x00FF0000 17 | * | .data | initialized data goes here 18 | * | _edata | 19 | * +--------------------+ 20 | * | .bss | 21 | * | __bss_start | start of bss, cleared by crt0 22 | * | _end | start of heap, used by sbrk() 23 | * +--------------------+ 24 | * . . 25 | * . . 26 | * . . 27 | * | __stack | top of stack 28 | * +--------------------+ <- 0x01000000 29 | */ 30 | 31 | MEMORY 32 | { 33 | psram (wx) : ORIGIN = 0x00300000, LENGTH = 0x00100000 34 | ram (wx) : ORIGIN = 0x00FF0000, LENGTH = 0x00010000 35 | } 36 | 37 | /* 38 | * Allocate the stack to be at the top of memory, since the stack 39 | * grows down 40 | */ 41 | 42 | PROVIDE (__stack = 16M); 43 | 44 | SECTIONS 45 | { 46 | .text 0x00300000 : 47 | AT ( 0x00000000 ) 48 | { 49 | *(.text .text.*) 50 | . = ALIGN(0x4); 51 | __CTOR_LIST__ = .; 52 | ___CTOR_LIST__ = .; 53 | LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) 54 | *(.ctors) 55 | LONG(0) 56 | __CTOR_END__ = .; 57 | __DTOR_LIST__ = .; 58 | ___DTOR_LIST__ = .; 59 | LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) 60 | *(.dtors) 61 | LONG(0) 62 | __DTOR_END__ = .; 63 | *(.rodata .rodata.*) 64 | *(.gcc_except_table) 65 | 66 | . = ALIGN(0x2); 67 | __INIT_SECTION__ = . ; 68 | LONG (0x4E560000) /* linkw %fp,#0 */ 69 | *(.init) 70 | SHORT (0x4E5E) /* unlk %fp */ 71 | SHORT (0x4E75) /* rts */ 72 | 73 | __FINI_SECTION__ = . ; 74 | LONG (0x4E560000) /* linkw %fp,#0 */ 75 | *(.fini) 76 | SHORT (0x4E5E) /* unlk %fp */ 77 | SHORT (0x4E75) /* rts */ 78 | 79 | _etext = .; 80 | *(.lit) 81 | } > psram 82 | _stext = SIZEOF (.text); 83 | 84 | .data 0x00FF0000 : 85 | AT ( LOADADDR (.text) + SIZEOF (.text) ) 86 | { 87 | *(.got.plt) *(.got) 88 | *(.shdata) 89 | *(.data .data.*) 90 | _edata = .; 91 | } > ram 92 | _sdata = SIZEOF (.data); 93 | 94 | .bss 0x00FF0000 + SIZEOF (.data) : 95 | { 96 | . = ALIGN(0x4); 97 | __bss_start = . ; 98 | *(.shbss) 99 | *(.bss .bss.*) 100 | *(COMMON) 101 | _end = ALIGN (0x8); 102 | __end = _end; 103 | end = _end; 104 | } > ram 105 | 106 | .stab 0 (NOLOAD) : 107 | { 108 | *(.stab) 109 | } 110 | 111 | .stabstr 0 (NOLOAD) : 112 | { 113 | *(.stabstr) 114 | } 115 | 116 | .eh_frame 0 (NOLOAD) : 117 | { 118 | *(.eh_frame) 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /ldscripts/md-split-ram.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_ARCH(m68k) 2 | SEARCH_DIR(.) 3 | __DYNAMIC = 0; 4 | 5 | /* 6 | * The memory map look like this: 7 | * +--------------------+ <- 0x00000000 8 | * | .text | 9 | * | _etext | 10 | * | ctor list | the ctor and dtor lists are for 11 | * | dtor list | C++ support 12 | * +--------------------+ 13 | * . . 14 | * . . 15 | * +--------------------+ <- 0xFFFF0000 16 | * | __stack | top of stack 17 | * +--------------------+ <- 0xFFFF8000 18 | * | .data | initialized data goes here 19 | * | _edata | 20 | * +--------------------+ 21 | * | .bss | 22 | * | __bss_start | start of bss, cleared by crt0 23 | * | _end | start of heap, used by sbrk() 24 | * +--------------------+ 25 | * . . 26 | * . . 27 | * . . 28 | * +--------------------+ <- 0x100000000 29 | */ 30 | 31 | MEMORY 32 | { 33 | rom (rx) : ORIGIN = 0x00000000, LENGTH = 0x00400000 34 | ram (wx) : ORIGIN = 0xFFFF8000, LENGTH = 0x00008000 35 | } 36 | 37 | /* 38 | * Allocate the stack to be at the top of memory, since the stack 39 | * grows down 40 | */ 41 | 42 | PROVIDE (__stack = 0xFFFF8000); 43 | 44 | SECTIONS 45 | { 46 | .text 0x00000000 : 47 | { 48 | *(.text .text.*) 49 | . = ALIGN(0x4); 50 | __CTOR_LIST__ = .; 51 | ___CTOR_LIST__ = .; 52 | LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) 53 | *(.ctors) 54 | LONG(0) 55 | __CTOR_END__ = .; 56 | __DTOR_LIST__ = .; 57 | ___DTOR_LIST__ = .; 58 | LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) 59 | *(.dtors) 60 | LONG(0) 61 | __DTOR_END__ = .; 62 | *(.rodata .rodata.*) 63 | *(.gcc_except_table) 64 | 65 | . = ALIGN(0x2); 66 | __INIT_SECTION__ = . ; 67 | LONG (0x4E560000) /* linkw %fp,#0 */ 68 | *(.init) 69 | SHORT (0x4E5E) /* unlk %fp */ 70 | SHORT (0x4E75) /* rts */ 71 | 72 | __FINI_SECTION__ = . ; 73 | LONG (0x4E560000) /* linkw %fp,#0 */ 74 | *(.fini) 75 | SHORT (0x4E5E) /* unlk %fp */ 76 | SHORT (0x4E75) /* rts */ 77 | 78 | _etext = .; 79 | *(.lit) 80 | } > rom 81 | _stext = SIZEOF (.text); 82 | 83 | .data 0xFFFF8000 : 84 | AT ( LOADADDR (.text) + SIZEOF (.text) ) 85 | { 86 | *(.got.plt) *(.got) 87 | *(.shdata) 88 | *(.data .data.*) 89 | _edata = .; 90 | } > ram 91 | _sdata = SIZEOF (.data); 92 | 93 | .bss 0xFFFF8000 + SIZEOF (.data) : 94 | { 95 | . = ALIGN(0x4); 96 | __bss_start = . ; 97 | *(.shbss) 98 | *(.bss .bss.*) 99 | *(COMMON) 100 | _end = ALIGN (0x8); 101 | __end = _end; 102 | end = _end; 103 | } > ram 104 | 105 | .stab 0 (NOLOAD) : 106 | { 107 | *(.stab) 108 | } 109 | 110 | .stabstr 0 (NOLOAD) : 111 | { 112 | *(.stabstr) 113 | } 114 | 115 | .eh_frame 0 (NOLOAD) : 116 | { 117 | *(.eh_frame) 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /ldscripts/md.ld: -------------------------------------------------------------------------------- 1 | OUTPUT_ARCH(m68k) 2 | SEARCH_DIR(.) 3 | /*GROUP(-lbcc -lc -lgcc)*/ 4 | __DYNAMIC = 0; 5 | 6 | /* 7 | * Setup the memory map of the SEGA Genesis. 8 | * stack grows down from high memory. 9 | * 10 | * The memory map look like this: 11 | * +--------------------+ <- low memory 12 | * | .text | 13 | * | _etext | 14 | * | ctor list | the ctor and dtor lists are for 15 | * | dtor list | C++ support 16 | * +--------------------+ 17 | * . . 18 | * . . 19 | * . . 20 | * +--------------------+ <- 0x00FF0000 21 | * | .data | initialized data goes here 22 | * | _data | 23 | * | _edata | 24 | * +--------------------+ 25 | * | .bss | 26 | * | _bstart | start of bss, cleared by crt0 27 | * | _bend | start of heap, used by sbrk() 28 | * +--------------------+ 29 | * . . 30 | * . . 31 | * . . 32 | * | __stack | top of stack 33 | * +--------------------+ <- 0x01000000 34 | */ 35 | MEMORY 36 | { 37 | rom : ORIGIN = 0x00000000, LENGTH = 0x00400000 38 | ram : ORIGIN = 0x00FF0000, LENGTH = 0x00010000 39 | } 40 | 41 | /* 42 | * allocate the stack to be at the top of memory, since the stack 43 | * grows down 44 | */ 45 | 46 | PROVIDE (__stack = 0x01000000); 47 | 48 | 49 | SECTIONS 50 | { 51 | .text 0x00000000: 52 | { 53 | *(.text .text.*) 54 | . = ALIGN(0x4); 55 | __CTOR_LIST__ = .; 56 | LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) 57 | *(.ctors) 58 | LONG(0) 59 | __CTOR_END__ = .; 60 | __DTOR_LIST__ = .; 61 | LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) 62 | *(.dtors) 63 | LONG(0) 64 | __DTOR_END__ = .; 65 | *(.rodata .rodata.*) 66 | *(.gcc_except_table .gcc_except_table.*) 67 | 68 | . = ALIGN(0x4); 69 | __INIT_SECTION__ = . ; 70 | *(.init) 71 | SHORT (0x4E75) /* rts */ 72 | 73 | __FINI_SECTION__ = . ; 74 | *(.fini) 75 | SHORT (0x4E75) /* rts */ 76 | 77 | _etext = .; 78 | *(.lit) 79 | } > rom 80 | _stext = SIZEOF (.text); 81 | 82 | .data 0xFF0000 : 83 | AT ( ADDR (.text) + SIZEOF (.text) ) 84 | { 85 | *(.got.plt) *(.got) 86 | *(.shdata) 87 | *(.data .data.*) 88 | _edata = .; 89 | } > ram 90 | _sdata = SIZEOF (.data); 91 | 92 | .bss 0xFF0000 + SIZEOF (.data) : 93 | { 94 | _start = . ; 95 | *(.shbss) 96 | *(.bss .bss.*) 97 | *(COMMON) 98 | _bend = . ; 99 | end = . ; 100 | } > ram 101 | 102 | .stab 0 (NOLOAD) : 103 | { 104 | *(.stab) 105 | } 106 | 107 | .stabstr 0 (NOLOAD) : 108 | { 109 | *(.stabstr) 110 | } 111 | 112 | .eh_frame 0 (NOLOAD) : 113 | { 114 | *(.eh_frame) 115 | } 116 | } 117 | 118 | -------------------------------------------------------------------------------- /sourceme.sh: -------------------------------------------------------------------------------- 1 | export PATH=$PATH:/opt/toolchains/sega/m68k-elf/bin:/opt/toolchains/sega/sh-elf/bin 2 | export GENDEV=/opt/toolchains/sega 3 | export GENDEV_GCC_VERSION=8.2.0 4 | -------------------------------------------------------------------------------- /toolchain.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # as per http://gendev.spritesmind.net/forum/viewtopic.php?p=12798 4 | # (mirrored in doc/instrucitons.txt) 5 | 6 | # any arguments are passed to make in the sub-projcets 7 | # sadly, -j2 is a bad idea, because it makes the builds fail :( 8 | 9 | DGCC=8.3.0 10 | GMP=6.1.2 11 | MPFR=3.1.2 12 | MPC=1.0.2 13 | BINUTILS=2.28 14 | NEWLIB=2.5.0 15 | 16 | export GCC_VERSION=$DGCC 17 | export BINUTILS_VERSION=$BINUTILS 18 | export NEWLIB_VERSION=$NEWLIB 19 | export EXTRA_MAKE_FLAGS="$@" 20 | 21 | function Download 22 | { 23 | echo -n " * $1 ..." 24 | wget -c -q $1 25 | echo " done" 26 | } 27 | 28 | function Unpack 29 | { 30 | echo -n " * $1 ..." 31 | tar xf $1 32 | echo " done" 33 | } 34 | 35 | set -e 36 | 37 | echo "Making output directories" 38 | if [ ! -d /opt/toolchains ]; then 39 | sudo mkdir -p /opt/toolchains 40 | fi 41 | sudo chmod 777 /opt/toolchains 42 | 43 | if [ ! -d /opt/toolchains/sega/ldscripts ]; then 44 | mkdir -p /opt/toolchains/sega/ldscripts 45 | fi 46 | 47 | mkdir -p build 48 | mkdir -p download 49 | 50 | cd download 51 | 52 | echo "Downloading gcc" 53 | #Download http://ftp.gnu.org/gnu/gcc/gcc-$DGCC/gcc-core-$DGCC.tar.bz2 54 | #Download http://ftp.gnu.org/gnu/gcc/gcc-$DGCC/gcc-g++-$DGCC.tar.bz2 55 | Download http://ftp.gnu.org/gnu/gcc/gcc-$DGCC/gcc-$DGCC.tar.xz 56 | 57 | echo "" 58 | echo "Downloading dependencies" 59 | Download https://ftp.gnu.org/gnu/mpc/mpc-$MPC.tar.gz 60 | Download https://gmplib.org/download/gmp/gmp-$GMP.tar.bz2 61 | Download http://www.mpfr.org/mpfr-$MPFR/mpfr-$MPFR.tar.bz2 62 | 63 | Download http://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.bz2 64 | Download ftp://sourceware.org/pub/newlib/newlib-$NEWLIB.tar.gz 65 | 66 | cd ../build 67 | 68 | echo "" 69 | echo "Unpacking" 70 | #Unpack ../download/gcc-core-$DGCC.tar.bz2 71 | #Unpack ../download/gcc-g++-$DGCC.tar.bz2 72 | Unpack ../download/gcc-$DGCC.tar.xz 73 | Unpack ../download/mpc-$MPC.tar.gz 74 | Unpack ../download/gmp-$GMP.tar.bz2 75 | Unpack ../download/mpfr-$MPFR.tar.bz2 76 | Unpack ../download/binutils-$BINUTILS.tar.bz2 77 | Unpack ../download/newlib-$NEWLIB.tar.gz 78 | 79 | echo "" 80 | echo "Moving and renaming" 81 | mv mpfr-$MPFR gcc-$DGCC/mpfr 82 | mv mpc-$MPC gcc-$DGCC/mpc 83 | mv gmp-$GMP gcc-$DGCC/gmp 84 | 85 | echo "" 86 | echo "Copying ldscripts and makefiles" 87 | cp ../ldscripts/* . 88 | 89 | #echo "Truncating documentation files (texinfo version incompatibility workaround)" 90 | #for f in gcc-$DGCC/gcc/doc/*.texi; do echo "" > "$f"; done 91 | 92 | echo "" 93 | echo "Building (see build/build.log)" 94 | echo "Note: the script says when it finished successfully." 95 | echo "If it terminates without a message, the build failed and you should check the log file." 96 | date > build.log 97 | CFLAGS="-w" make -f makefile-gen &>> build.log 98 | 99 | echo "" 100 | echo "Installing megadrive ldscripts etc." 101 | cp *.ld /opt/toolchains/sega/ldscripts 102 | cp ../sourceme.sh /opt/toolchains/sega 103 | 104 | echo "" 105 | echo "Done!" 106 | echo "to import the toolchain environment use" 107 | echo " source /opt/toolchains/sega/sourceme.sh" 108 | echo "" 109 | echo "after that you can eg. try and compile the examples in examples/" 110 | --------------------------------------------------------------------------------