initial commit!
This commit is contained in:
1
libs/libgccvb/.idea/.name
generated
Normal file
1
libs/libgccvb/.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
||||
libgccvb
|
||||
22
libs/libgccvb/.idea/compiler.xml
generated
Normal file
22
libs/libgccvb/.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
||||
42
libs/libgccvb/.idea/deployment.xml
generated
Normal file
42
libs/libgccvb/.idea/deployment.xml
generated
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PublishConfigData">
|
||||
<serverData>
|
||||
<paths name="gamiac">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
<paths name="gamiac dev">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
<paths name="mila">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
<paths name="pvb">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
<paths name="pvb dev">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
</serverData>
|
||||
</component>
|
||||
</project>
|
||||
6
libs/libgccvb/.idea/encodings.xml
generated
Normal file
6
libs/libgccvb/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="PROJECT" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
||||
10
libs/libgccvb/.idea/libgccvb.iml
generated
Normal file
10
libs/libgccvb/.idea/libgccvb.iml
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
8
libs/libgccvb/.idea/misc.xml
generated
Normal file
8
libs/libgccvb/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CppTools.Loader" reportImplicitCastToBool="false" reportNameNeverReferenced="false" reportNameReferencedOnce="false" reportRedundantCast="false" reportRedundantQualifier="false" reportStaticCallFromInstance="false" reportDuplicatedSymbols="false" warnedAboutFileOutOfSourceRoot="true" version="3" currentProject="$PROJECT_DIR$/makefile" sdkErrorReported="true" additionalPreprocessorDefs="" automaticallyIncludedHeaderFiles=" C:\vbde\libs\libgccvb\affine.h; C:\vbde\libs\libgccvb\affine.h; C:\vbde\libs\libgccvb\asm.h; C:\vbde\libs\libgccvb\asm.h; C:\vbde\libs\libgccvb\audio.h; C:\vbde\libs\libgccvb\audio.h; C:\vbde\libs\libgccvb\bgmap.h; C:\vbde\libs\libgccvb\bgmap.h; C:\vbde\libs\libgccvb\controller.h; C:\vbde\libs\libgccvb\controller.h; C:\vbde\libs\libgccvb\hw.h; C:\vbde\libs\libgccvb\hw.h; C:\vbde\libs\libgccvb\interrupts.h; C:\vbde\libs\libgccvb\interrupts.h; C:\vbde\libs\libgccvb\libgccvb.h; C:\vbde\libs\libgccvb\libgccvb.h; C:\vbde\libs\libgccvb\math.h; C:\vbde\libs\libgccvb\math.h; C:\vbde\libs\libgccvb\mem.h; C:\vbde\libs\libgccvb\mem.h; C:\vbde\libs\libgccvb\misc.h; C:\vbde\libs\libgccvb\misc.h; C:\vbde\libs\libgccvb\object.h; C:\vbde\libs\libgccvb\object.h; C:\vbde\libs\libgccvb\random.h; C:\vbde\libs\libgccvb\random.h; C:\vbde\libs\libgccvb\timer.h; C:\vbde\libs\libgccvb\timer.h; C:\vbde\libs\libgccvb\types.h; C:\vbde\libs\libgccvb\types.h; C:\vbde\libs\libgccvb\video.h; C:\vbde\libs\libgccvb\video.h; C:\vbde\libs\libgccvb\vip.h; C:\vbde\libs\libgccvb\vip.h; C:\vbde\libs\libgccvb\world.h; C:\vbde\libs\libgccvb\world.h; " compilerSelect="GCC" javaIncludes="false">
|
||||
<system-include-dir path="$PROJECT_DIR$/../../system/batch//../..//libs/libgccvb" />
|
||||
<system-include-dir path="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" />
|
||||
</project>
|
||||
8
libs/libgccvb/.idea/modules.xml
generated
Normal file
8
libs/libgccvb/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/libgccvb.iml" filepath="$PROJECT_DIR$/.idea/libgccvb.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
82
libs/libgccvb/affine.c
Normal file
82
libs/libgccvb/affine.c
Normal file
@@ -0,0 +1,82 @@
|
||||
#include "types.h"
|
||||
#include "affine.h"
|
||||
|
||||
|
||||
// clear a world's affine param table based on world height
|
||||
void affine_clr_param(u8 world) {
|
||||
int i,tmp;
|
||||
s16 *param;
|
||||
|
||||
tmp = (world<<4);
|
||||
param = (s16*)((WAM[tmp+9]<<1)+0x00020000);
|
||||
for (i = 0; i < (WAM[tmp+8]<<3); i++) param[i]=0;
|
||||
}
|
||||
|
||||
// scale an affine background
|
||||
// world: number of the world to apply scaling to, must be using affine BGM
|
||||
// centerX/centerY: center point (relative to the world) to scale around.
|
||||
// imageW/imageH: original image width and height
|
||||
// scaleX/scaleY: scale factor per axis.
|
||||
// lowest positive: 0.0156254
|
||||
// highest positive: 512
|
||||
// lowest negative: -512
|
||||
// highest negative: -0.015625
|
||||
// '1' is 100% scale, '2' is 200%, '0.05' is 5%, etc
|
||||
void affine_scale(u8 world, s16 centerX, s16 centerY, u16 imageW, u16 imageH, float scaleX, float scaleY) {
|
||||
int i,tmp;
|
||||
s16 *param;
|
||||
f16 XSrc,XScl,YScl;
|
||||
f32 YSrc;
|
||||
|
||||
tmp = (world<<4);
|
||||
param = (s16*)((WAM[tmp+9]<<1)+0x00020000);
|
||||
|
||||
XScl = inverse_fixed(scaleX);
|
||||
YScl = inverse_fixed(scaleY);
|
||||
|
||||
XSrc = -fixed_13_3((centerX-((imageW*scaleX)/2))/scaleX); //keep image centered
|
||||
YSrc = -fixed_7_9((centerY-((imageH*scaleY)/2))/scaleY);
|
||||
|
||||
i=0;
|
||||
while (i < (int)(WAM[tmp+8]<<3)) {
|
||||
param[i++] = XSrc; //XSrc
|
||||
i++; //Prlx
|
||||
param[i++] = (YSrc>>6); //YSrc -- convert from 7.9 to 13.3 fixed
|
||||
param[i++] = XScl; //XScl
|
||||
i+=4; //skip remaining entries
|
||||
|
||||
YSrc += YScl; //grab value of next scanline
|
||||
}
|
||||
}
|
||||
|
||||
// scale an affine background
|
||||
// world: number of the world to apply scaling to, must be using affine BGM
|
||||
// scale: scale factor.
|
||||
// lowest positive: 0.0156254
|
||||
// highest positive: 512
|
||||
// lowest negative: -512
|
||||
// highest negative: -0.015625
|
||||
// '1' is 100% scale, '2' is 200%, '0.05' is 5%, etc
|
||||
void affine_fast_scale(u8 world, float scale) {
|
||||
int i,tmp;
|
||||
s16 *param;
|
||||
f16 XScl,YScl;
|
||||
f32 YSrc;
|
||||
|
||||
tmp = (world<<4);
|
||||
param = (s16*)((WAM[tmp+9]<<1)+0x00020000);
|
||||
|
||||
XScl = YScl = inverse_fixed(scale);
|
||||
YSrc = 0;
|
||||
|
||||
i=0;
|
||||
while (i < (int)(WAM[tmp+8]<<3)) {
|
||||
param[i++] = 0; //XSrc
|
||||
i++; //Prlx
|
||||
param[i++] = (YSrc>>6); //YSrc -- convert from 7.9 to 13.3 fixed
|
||||
param[i++] = XScl; //XScl
|
||||
i+=4; //skip remaining entries
|
||||
|
||||
YSrc += YScl; //grab value of next scanline
|
||||
}
|
||||
}
|
||||
25
libs/libgccvb/affine.h
Normal file
25
libs/libgccvb/affine.h
Normal file
@@ -0,0 +1,25 @@
|
||||
// affine.h
|
||||
// v0.1 beta (preliminary scaling functions added)
|
||||
// functions and macros to make affine transformations easier
|
||||
// for use with gccVB
|
||||
// written by Parasyte (parasytic_i[at]yahoo.com)
|
||||
|
||||
#ifndef _LIBGCCVB_AFFINE_H
|
||||
#define _LIBGCCVB_AFFINE_H
|
||||
|
||||
|
||||
#include "types.h"
|
||||
#include "video.h"
|
||||
|
||||
|
||||
#define fixed_7_9(n) (f32)(n * (1<<9)) //convert from float\int\etc to 7.9 fixed
|
||||
#define fixed_13_3(n) (f16)(n * (1<<3)) //convert from float\int\etc to 13.3 fixed
|
||||
#define inverse_fixed(n) (f16)((1<<18)/fixed_7_9(n)) //convert from float\int\etc to 7.9 fixed (with inversion)
|
||||
|
||||
|
||||
void affine_clr_param(u8 world);
|
||||
void affine_scale(u8 world, s16 centerX, s16 centerY, u16 imageW, u16 imageH, float scaleX, float scaleY);
|
||||
void affine_fast_scale(u8 world, float scale);
|
||||
|
||||
|
||||
#endif
|
||||
49
libs/libgccvb/asm.c
Normal file
49
libs/libgccvb/asm.c
Normal file
@@ -0,0 +1,49 @@
|
||||
#include "types.h"
|
||||
#include "asm.h"
|
||||
|
||||
|
||||
//u32 jump_addr(void *addr);
|
||||
asm(".globl _jump_addr");
|
||||
asm("_jump_addr:");
|
||||
asm("add -4,sp;");
|
||||
asm("st.w lp,0[sp];");
|
||||
asm("jal __dojump;");
|
||||
asm("ld.w 0[sp],lp;");
|
||||
asm("add 4,sp;");
|
||||
asm("jmp [lp];");
|
||||
asm("__dojump:");
|
||||
asm("jmp [r6];");
|
||||
|
||||
void inline set_intlevel(u8 level)
|
||||
{
|
||||
asm(
|
||||
"stsr sr5,r5;"
|
||||
"movhi 0xFFF1,r0,r6;"
|
||||
"movea 0xFFFF,r6,r6;"
|
||||
"and r5,r6;"
|
||||
"mov %0,r5;"
|
||||
"andi 0x000F,r5,r5;"
|
||||
"shl 0x10,r5;"
|
||||
"or r6,r5;"
|
||||
"ldsr r5,sr5;"
|
||||
: /* Output */
|
||||
: "r" (level) /* Input */
|
||||
: "r5", "r6" /* Clobber */
|
||||
);
|
||||
}
|
||||
|
||||
int inline get_intlevel()
|
||||
{
|
||||
int level;
|
||||
|
||||
asm(
|
||||
"stsr sr5,r5;"
|
||||
"shr 0x10,r5;"
|
||||
"andi 0x000F,r5,r5;"
|
||||
"mov r5,%0;"
|
||||
: "=r" (level) /* Output */
|
||||
: /* Input */
|
||||
: "r5" /* Clobber */
|
||||
);
|
||||
return level;
|
||||
}
|
||||
13
libs/libgccvb/asm.h
Normal file
13
libs/libgccvb/asm.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef _LIBGCCVB_ASM_H
|
||||
#define _LIBGCCVB_ASM_H
|
||||
|
||||
|
||||
#define INT_ENABLE asm("CLI;")
|
||||
#define INT_DISABLE asm("SEI;")
|
||||
|
||||
u32 jump_addr(void *addr);
|
||||
extern void set_intlevel(u8 level);
|
||||
extern int get_intlevel();
|
||||
|
||||
|
||||
#endif
|
||||
10
libs/libgccvb/audio.c
Normal file
10
libs/libgccvb/audio.c
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "types.h"
|
||||
#include "audio.h"
|
||||
|
||||
u8* const WAVEDATA1 = (u8*)0x01000000; // 0x01000000 - 0x0100007F Waveform 1 RAM
|
||||
u8* const WAVEDATA2 = (u8*)0x01000080; // 0x01000080 - 0x010000FF Waveform 2 RAM
|
||||
u8* const WAVEDATA3 = (u8*)0x01000100; // 0x01000100 - 0x0100017F Waveform 3 RAM
|
||||
u8* const WAVEDATA4 = (u8*)0x01000180; // 0x01000180 - 0x010001FF Waveform 4 RAM
|
||||
u8* const WAVEDATA5 = (u8*)0x01000200; // 0x01000200 - 0x0100027F Waveform 5 RAM
|
||||
u8* const MODDATA = (u8*)0x01000280;
|
||||
SOUNDREG* const SND_REGS = (SOUNDREG*)0x01000400;
|
||||
52
libs/libgccvb/audio.h
Normal file
52
libs/libgccvb/audio.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef _LIBGCCVB_AUDIO_H
|
||||
#define _LIBGCCVB_AUDIO_H
|
||||
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
||||
typedef struct SOUNDREG
|
||||
{
|
||||
// this table is for the most part untested, but looks to be accurate
|
||||
// | D7 || D6 || D5 || D4 || D3 || D2 || D1 || D0 |
|
||||
u8 SxINT; // [----Enable----][--XXXXXXXXXX--][-Interval/??--][--------------------------------Interval Data---------------------------------]
|
||||
u8 spacer1[3];
|
||||
u8 SxLRV; // [---------------------------L Level----------------------------][---------------------------R Level----------------------------]
|
||||
u8 spacer2[3];
|
||||
u8 SxFQL; // [------------------------------------------------------Frequency Low Byte------------------------------------------------------]
|
||||
u8 spacer3[3];
|
||||
u8 SxFQH; // [--XXXXXXXXXX--][--XXXXXXXXXX--][--XXXXXXXXXX--][--XXXXXXXXXX--][--XXXXXXXXXX--][--------------Frequency High Byte-------------]
|
||||
u8 spacer4[3];
|
||||
u8 SxEV0; // [---------------------Initial Envelope Value-------------------][------U/D-----][-----------------Envelope Step----------------]
|
||||
u8 spacer5[3];
|
||||
//Ch. 1-4 [--XXXXXXXXXX--][--XXXXXXXXXX--][--XXXXXXXXXX--][--XXXXXXXXXX--][--XXXXXXXXXX--][--XXXXXXXXXX--][------R/S-----][----On/Off----]
|
||||
//Ch. 5 [--XXXXXXXXXX--][------E/D-----][----?/Short---][--Mod./Sweep--][--XXXXXXXXXX--][--XXXXXXXXXX--][------R/S-----][----On/Off----]
|
||||
u8 SxEV1; //Ch. 6 [--XXXXXXXXXX--][----------------------E/D---------------------][--XXXXXXXXXX--][--XXXXXXXXXX--][------R/S-----][----On/Off----]
|
||||
u8 spacer6[3];
|
||||
// Ch. 1-5 only (I believe address is only 3 bits, but may be 4, needs testing)
|
||||
u8 SxRAM; // [--XXXXXXXXXX--][--XXXXXXXXXX--][--XXXXXXXXXX--][--XXXXXXXXXX--][--XXXXXXXXXX--][--------------Waveform RAM Address------------]
|
||||
u8 spacer7[3];
|
||||
// Ch. 5 only
|
||||
u8 S5SWP; // [------CLK-----][-------------Sweep/Modulation Time------------][------U/D-----][----------------Number of Shifts--------------]
|
||||
u8 spacer8[35];
|
||||
} SOUNDREG;
|
||||
|
||||
extern u8* const WAVEDATA1;
|
||||
extern u8* const WAVEDATA2;
|
||||
extern u8* const WAVEDATA3;
|
||||
extern u8* const WAVEDATA4;
|
||||
extern u8* const WAVEDATA5;
|
||||
extern u8* const MODDATA;
|
||||
extern SOUNDREG* const SND_REGS;
|
||||
#define SSTOP *(u8*)0x01000580
|
||||
|
||||
/***** Sound Register Mnemonics *****/
|
||||
#define WAVE1 0x00 // Voluntary wave channel #1
|
||||
#define WAVE2 0x01 // Voluntary wave channel #2
|
||||
#define WAVE3 0x02 // Voluntary wave channel #3
|
||||
#define WAVE4 0x03 // Voluntary wave channel #4
|
||||
#define SWEEP 0x04 // Sweep/modulation channel
|
||||
#define NOISE 0x05 // Pseudorandom noise channel
|
||||
|
||||
|
||||
#endif
|
||||
61
libs/libgccvb/bgmap.h
Normal file
61
libs/libgccvb/bgmap.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef _LIBGCCVB_BGMAP_H
|
||||
#define _LIBGCCVB_BGMAP_H
|
||||
|
||||
|
||||
#include "types.h"
|
||||
#include "video.h"
|
||||
|
||||
|
||||
/***** BGMap Macros (For the lazy ;) *****/
|
||||
/*
|
||||
These calculate the address of a BGMap cell from a segment #
|
||||
and X, Y coordinates. (Which range from 0 to 63) Not very
|
||||
efficient for games, but useful for pre-calculation, debugging,
|
||||
or easier-to-read example code, I suppose...
|
||||
*/
|
||||
|
||||
// Procedural
|
||||
/***************************/
|
||||
|
||||
// Set a cell's char #.
|
||||
#define BGM_CSET(n,x,y,c) BGMM[((n) << 12) + ((y) << 6) + (x)] = (BGMM[((n) << 12) + ((y) << 6) + (x)] & 0xF000) | (u16)(c)
|
||||
// Turns on horizontal flipping for a cell.
|
||||
#define BGM_HSET(n,x,y) BGMM[((n) << 12) + ((y) << 6) + (x)] |= BGM_HFLIP
|
||||
// Turns off horizontal flipping for a cell.
|
||||
#define BGM_HCLEAR(n,x,y) BGMM[((n) << 12) + ((y) << 6) + (x)] &= 0xDFFF
|
||||
// Turns on vertical flipping for a cell.
|
||||
#define BGM_VSET(n,x,y) BGMM[((n) << 12) + ((y) << 6) + (x)] |= BGM_VFLIP
|
||||
// Turns off vertical flipping for a cell.
|
||||
#define BGM_VCLEAR(n,x,y) BGMM[((n) << 12) + ((y) << 6) + (x)] &= 0xEFFF
|
||||
// Set the palette used by a cell. Example: BGM_PALSET(0,1,2,BGM_PAL3);
|
||||
#define BGM_PALSET(n,x,y,p) BGMM[((n) << 12) + ((y) << 6) + (x)] = (BGMM[((n) << 12) + ((y) << 6) + (x)] & 0x3FFF) | (u16)(p)
|
||||
|
||||
|
||||
// Expressional
|
||||
/***************************/
|
||||
|
||||
// Return a cell's char #.
|
||||
#define BGM_CGET(n,x,y) (BGMM[((n) << 12) + ((y) << 6) + (x)] & (u16)0x7FF)
|
||||
// Return -1 if a cell is flipped horizontally; 0 if not.
|
||||
#define BGM_HGET(n,x,y) ((BGMM[((n) << 12) + ((y) << 6) + (x)] & (u16)BGM_HFLIP) == BGM_HFLIP ? -1 : 0)
|
||||
// Return -1 if a cell is flipped vertically; 0 if not.
|
||||
#define BGM_VGET(n,x,y) ((BGMM[((n) << 12) + ((y) << 6) + (x)] & (u16)BGM_VFLIP) == BGM_VFLIP ? -1 : 0)
|
||||
// Return a cell's palette. Example: BGM_PALGET(BGM_PAL2);
|
||||
#define BGM_PALGET(n,x,y) (BGMM[((n) << 12) + ((y) << 6) + (x)] & (u16)0xC000)
|
||||
|
||||
/* BGMap Flags */
|
||||
/* OR these together with a Char # to build a BGMap Cell
|
||||
-OR-
|
||||
Compare the output of the BGM_?GET macros above.
|
||||
*/
|
||||
|
||||
#define BGM_PAL0 0x0000
|
||||
#define BGM_PAL1 0x4000
|
||||
#define BGM_PAL2 0x8000
|
||||
#define BGM_PAL3 0xC000
|
||||
|
||||
#define BGM_HFLIP 0x2000
|
||||
#define BGM_VFLIP 0x1000
|
||||
|
||||
|
||||
#endif
|
||||
308
libs/libgccvb/compiler/crt0.s
Normal file
308
libs/libgccvb/compiler/crt0.s
Normal file
@@ -0,0 +1,308 @@
|
||||
.section .text
|
||||
.align 1
|
||||
|
||||
|
||||
/*************************************************
|
||||
pointers
|
||||
*************************************************/
|
||||
|
||||
.global _keyVector
|
||||
_keyVector = 0x0500FFC0
|
||||
|
||||
.global _timVector
|
||||
_timVector = 0x0500FFC4
|
||||
|
||||
.global _croVector
|
||||
_croVector = 0x0500FFC8
|
||||
|
||||
.global _comVector
|
||||
_comVector = 0x0500FFCC
|
||||
|
||||
.global _vipVector
|
||||
_vipVector = 0x0500FFD0
|
||||
|
||||
|
||||
|
||||
/*************************************************
|
||||
startup code
|
||||
*************************************************/
|
||||
.global _start
|
||||
|
||||
_start:
|
||||
|
||||
/* wait for WRAM */
|
||||
movea 0x2000, r0, r6
|
||||
wait_for_wram_loop:
|
||||
add -1, r6
|
||||
bnz wait_for_wram_loop
|
||||
|
||||
/* dummy reads */
|
||||
movhi hi(__data_start), r0, r7
|
||||
movea lo(__data_start), r7, r7
|
||||
movea 0x0008, r0, r8
|
||||
dummy_read_cycle:
|
||||
ld.b 0[r7], r9
|
||||
add 1, r7
|
||||
cmp r8, r7
|
||||
blt dummy_read_cycle
|
||||
|
||||
/* initiallize .data section */
|
||||
movhi hi(__data_lma), r0, r6
|
||||
movea lo(__data_lma), r6, r6
|
||||
movhi hi(__data_start), r0, r7
|
||||
movea lo(__data_start), r7, r7
|
||||
movhi hi(__data_end), r0, r8
|
||||
movea lo(__data_end), r8, r8
|
||||
jr end_init_data
|
||||
|
||||
top_init_data:
|
||||
ld.b 0[r6], r9
|
||||
st.b r9, 0[r7]
|
||||
add 1, r6
|
||||
add 1, r7
|
||||
end_init_data:
|
||||
cmp r8, r7
|
||||
blt top_init_data
|
||||
|
||||
/* initiallize .dram_data section */
|
||||
movhi hi(__dram_data_start), r0, r7
|
||||
movea lo(__dram_data_start), r7, r7
|
||||
movhi hi(__dram_data_end), r0, r8
|
||||
movea lo(__dram_data_end), r8, r8
|
||||
jr end_init_dram_data
|
||||
|
||||
top_init_dram_data:
|
||||
ld.b 0[r6], r9
|
||||
st.b r9, 0[r7]
|
||||
add 1, r6
|
||||
add 1, r7
|
||||
end_init_dram_data:
|
||||
cmp r8, r7
|
||||
blt top_init_dram_data
|
||||
|
||||
/* initiallize .sram_data section */
|
||||
movhi hi(__sram_data_start), r0, r7
|
||||
movea lo(__sram_data_start), r7, r7
|
||||
movhi hi(__sram_data_end), r0, r8
|
||||
movea lo(__sram_data_end), r8, r8
|
||||
jr end_init_sram_data
|
||||
|
||||
top_init_sram_data:
|
||||
ld.b 0[r6], r9
|
||||
st.b r9, 0[r7]
|
||||
add 1, r6
|
||||
add 1, r7
|
||||
end_init_sram_data:
|
||||
cmp r8, r7
|
||||
blt top_init_sram_data
|
||||
|
||||
/* clear .bss section */
|
||||
movhi hi(__bss_start), r0, r6
|
||||
movea lo(__bss_start), r6, r6
|
||||
movhi hi(__bss_end), r0, r7
|
||||
movea lo(__bss_end), r7, r7
|
||||
jr end_init_bss
|
||||
top_init_bss:
|
||||
st.h r0, 0[r6]
|
||||
add 1, r6
|
||||
end_init_bss:
|
||||
cmp r7, r6
|
||||
blt top_init_bss
|
||||
|
||||
/* clear .dram_bss section */
|
||||
movhi hi(__dram_bss_start), r0, r6
|
||||
movea lo(__dram_bss_start), r6, r6
|
||||
movhi hi(__dram_bss_end), r0, r7
|
||||
movea lo(__dram_bss_end), r7, r7
|
||||
jr end_init_dram_bss
|
||||
top_init_dram_bss:
|
||||
st.b r0, 0[r6]
|
||||
add 1, r6
|
||||
end_init_dram_bss:
|
||||
cmp r7, r6
|
||||
blt top_init_dram_bss
|
||||
|
||||
/* clear .sram_bss section */
|
||||
movhi hi(__sram_bss_start), r0, r6
|
||||
movea lo(__sram_bss_start), r6, r6
|
||||
movhi hi(__sram_bss_end), r0, r7
|
||||
movea lo(__sram_bss_end), r7, r7
|
||||
jr end_init_sram_bss
|
||||
top_init_sram_bss:
|
||||
st.b r0, 0[r6]
|
||||
add 1, r6
|
||||
end_init_sram_bss:
|
||||
cmp r7, r6
|
||||
blt top_init_sram_bss
|
||||
|
||||
/* disable-clear-enable cache GCC 4.7 */
|
||||
ldsr r0, sr5
|
||||
ldsr r0, chcw
|
||||
mov 2, r1
|
||||
ldsr r1, chcw
|
||||
|
||||
/* setup sp, fp, gp, and tp */
|
||||
movhi hi(__stack), r0,sp
|
||||
movea lo(__stack), sp,sp
|
||||
|
||||
movhi hi(__gp), r0, gp
|
||||
movea lo(__gp), gp, gp
|
||||
|
||||
movhi hi(__tp), r0,tp
|
||||
movea lo(__tp), tp, tp
|
||||
|
||||
__call_main:
|
||||
/* long call main function */
|
||||
movhi hi(__end),r0,lp
|
||||
movea lo(__end),lp,lp
|
||||
|
||||
movhi hi(_main),r0,r1
|
||||
movea lo(_main),r1,r1
|
||||
jmp [r1]
|
||||
__end:
|
||||
|
||||
/* Reset when main returns */
|
||||
movhi hi(0xFFFFFFF0),r0,lp
|
||||
movea lo(0xffffFFF0),lp,lp
|
||||
jmp [lp]
|
||||
|
||||
/* interrupt handler*/
|
||||
|
||||
__interrupt_handler:
|
||||
jmp [r1]
|
||||
|
||||
.global __interrupt_handler_prolog
|
||||
|
||||
__interrupt_handler_prolog:
|
||||
addi -0x0048,sp,sp
|
||||
st.w lp,0x0000[sp]
|
||||
st.w r30,0x0004[sp]
|
||||
st.w r19,0x0008[sp]
|
||||
st.w r18,0x000c[sp]
|
||||
st.w r17,0x0010[sp]
|
||||
st.w r16,0x0014[sp]
|
||||
st.w r15,0x0018[sp]
|
||||
st.w r14,0x001c[sp]
|
||||
st.w r13,0x0020[sp]
|
||||
st.w r12,0x0024[sp]
|
||||
st.w r11,0x0028[sp]
|
||||
st.w r10,0x002c[sp]
|
||||
st.w r9,0x0030[sp]
|
||||
st.w r8,0x0034[sp]
|
||||
st.w r7,0x0038[sp]
|
||||
st.w r6,0x003c[sp]
|
||||
st.w r2,0x0040[sp]
|
||||
st.w r1,0x0044[sp]
|
||||
movhi hi(_keyVector),r0,r1
|
||||
movea lo(_keyVector),r1,r1
|
||||
stsr sr5,r6
|
||||
shr 0x0E,r6
|
||||
andi 0x003C,r6,r6
|
||||
add r6,r1
|
||||
ld.w -4[r1],r1
|
||||
cmp r0,r1
|
||||
be __interrupt_handler_epilogue
|
||||
jal __interrupt_handler
|
||||
|
||||
|
||||
__interrupt_handler_epilogue:
|
||||
ld.w 0x0000[sp],lp
|
||||
ld.w 0x0004[sp],r30
|
||||
ld.w 0x0008[sp],r19
|
||||
ld.w 0x000c[sp],r18
|
||||
ld.w 0x0010[sp],r17
|
||||
ld.w 0x0014[sp],r16
|
||||
ld.w 0x0018[sp],r15
|
||||
ld.w 0x001c[sp],r14
|
||||
ld.w 0x0020[sp],r13
|
||||
ld.w 0x0024[sp],r12
|
||||
ld.w 0x0028[sp],r11
|
||||
ld.w 0x002c[sp],r10
|
||||
ld.w 0x0030[sp],r9
|
||||
ld.w 0x0034[sp],r8
|
||||
ld.w 0x0038[sp],r7
|
||||
ld.w 0x003c[sp],r6
|
||||
ld.w 0x0040[sp],r2
|
||||
ld.w 0x0044[sp],r1
|
||||
addi 0x0048,sp,sp
|
||||
reti
|
||||
|
||||
.section ".vbvectors","ax"
|
||||
.align 1
|
||||
|
||||
.global _rom_title
|
||||
|
||||
/* Rom info table (07FFFDE0h) */
|
||||
_rom_title:
|
||||
.ascii "change this title " /* Game Title */
|
||||
.byte 0x00,0x00,0x00,0x00,0x00 /* Reserved */
|
||||
.ascii "MFGMID" /* Manufacture/Game ID */
|
||||
.byte 0x01 /* Rom Version */
|
||||
|
||||
|
||||
/* Hardware Interupt Vectors */
|
||||
_interrupt_table:
|
||||
|
||||
/* INTKEY (7FFFE00h) - Controller Interrupt */
|
||||
jr __interrupt_handler_prolog
|
||||
.fill 0x0c
|
||||
|
||||
/* INTTIM (7FFFE10h) - Timer Interrupt */
|
||||
jr __interrupt_handler_prolog
|
||||
.fill 0x0c
|
||||
|
||||
/* INTCRO (7FFFE20h) - Expansion Port Interrupt */
|
||||
jr __interrupt_handler_prolog
|
||||
.fill 0x0c
|
||||
|
||||
/* INTCOM (7FFFE30h) - Link Port Interrupt */
|
||||
jr __interrupt_handler_prolog
|
||||
.fill 0x0c
|
||||
|
||||
/* INTVPU (7FFFE40h) - Video Retrace Interrupt */
|
||||
jr __interrupt_handler_prolog
|
||||
.fill 0x0c
|
||||
|
||||
/* Unused vectors (7FFFE50h-7FFFF5Fh) */
|
||||
.fill 0x010F
|
||||
|
||||
/* (7FFFF60h) - Float exception */
|
||||
reti
|
||||
.fill 0x0E
|
||||
|
||||
/* Unused vector */
|
||||
.fill 0x10
|
||||
|
||||
/* (7FFFF80h) - Divide by zero exception */
|
||||
reti
|
||||
.fill 0x0E
|
||||
|
||||
/* (7FFFF90h) - Invalid Opcode exception */
|
||||
reti
|
||||
.fill 0x0E
|
||||
|
||||
/* (7FFFFA0h) - Trap 0 exception */
|
||||
reti
|
||||
.fill 0x0E
|
||||
|
||||
/* (7FFFFB0h) - Trap 1 exception */
|
||||
reti
|
||||
.fill 0x0E
|
||||
|
||||
/* (7FFFFC0h) - Trap Address exception */
|
||||
reti
|
||||
.fill 0x0E
|
||||
|
||||
/* (7FFFFD0h) - NMI/Duplex exception */
|
||||
reti
|
||||
.fill 0x0F
|
||||
|
||||
/* Unused vector */
|
||||
.fill 0x10
|
||||
|
||||
/* Reset Vector (7FFFFF0h) - This is how the ROM boots */
|
||||
movhi hi(_start), r0, r1
|
||||
movea lo(_start), r1, r1
|
||||
jmp [r1]
|
||||
.fill 0x06
|
||||
|
||||
123
libs/libgccvb/compiler/vb.ld
Normal file
123
libs/libgccvb/compiler/vb.ld
Normal file
@@ -0,0 +1,123 @@
|
||||
OUTPUT_FORMAT("elf32-v810", "elf32-v810", "elf32-v810")
|
||||
OUTPUT("a.elf") /* force elf format output */
|
||||
OUTPUT_ARCH(v810)
|
||||
TARGET(elf32-v810)
|
||||
ENTRY(_start)
|
||||
SEARCH_DIR(.);
|
||||
|
||||
MEMORY
|
||||
{
|
||||
wram (!r) : ORIGIN = 0x05000000, LENGTH = 64k /*64k*/
|
||||
dram (!r) : ORIGIN = 0x0003D800, LENGTH = 0k
|
||||
sram (!r) : ORIGIN = 0x06000000, LENGTH = 16M
|
||||
rom (rx) : ORIGIN = 0x07000000, LENGTH = 16M
|
||||
}
|
||||
|
||||
/*
|
||||
If not defined, define interrupt
|
||||
Handlers as system reset
|
||||
*/
|
||||
|
||||
__text_vma = ORIGIN(rom);
|
||||
__data_vma = ORIGIN(wram);
|
||||
__sram_vma = ORIGIN(sram);
|
||||
__dram_vma = ORIGIN(dram);
|
||||
__stack = ORIGIN(wram) + LENGTH(wram) - 64;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
/* Read-only sections, merged into text segment: */
|
||||
.text __text_vma :
|
||||
{
|
||||
PROVIDE (__tp = .);
|
||||
*(.text*)
|
||||
} >rom = 0xFF
|
||||
|
||||
.rodata :
|
||||
{
|
||||
*(.rodata*)
|
||||
} >rom = 0xFF
|
||||
|
||||
v = .;
|
||||
|
||||
/* Ram memory */
|
||||
__data_lma = .;
|
||||
.data __data_vma : AT(__data_lma)
|
||||
{
|
||||
PROVIDE (__data_start = .);
|
||||
*(.data*)
|
||||
} >wram = 0xFF
|
||||
|
||||
.sdata ALIGN(2):
|
||||
{
|
||||
PROVIDE (__gp = . + 0x8000);
|
||||
*(.sdata*)
|
||||
PROVIDE (__data_end = .);
|
||||
} >wram = 0xFF
|
||||
|
||||
.dram_data __dram_vma : AT(v + SIZEOF(.data) + SIZEOF(.sdata))
|
||||
{
|
||||
PROVIDE (__dram_data_start = .);
|
||||
*(.dram_data*)
|
||||
PROVIDE (__dram_data_end = .);
|
||||
} >dram = 0xFF
|
||||
|
||||
.sram_data __sram_vma : AT(v + SIZEOF(.data) + SIZEOF(.sdata) + SIZEOF(.dram_data)) SUBALIGN(2)
|
||||
{
|
||||
PROVIDE (__sram_data_start = .);
|
||||
*(.sram_data*)
|
||||
PROVIDE (__sram_data_end = .);
|
||||
} >sram = 0xFF
|
||||
|
||||
.sbss (NOLOAD):
|
||||
{
|
||||
PROVIDE (__bss_start = .);
|
||||
*(.sbss*)
|
||||
*(.scommon*)
|
||||
} >wram = 0xFF
|
||||
|
||||
.bss (NOLOAD):
|
||||
{
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
PROVIDE (__bss_end = .);
|
||||
} >wram = 0xFF
|
||||
|
||||
.dram_bss (NOLOAD):
|
||||
{
|
||||
PROVIDE(__dram_bss_start = .);
|
||||
*(.dram_bss*)
|
||||
PROVIDE(__dram_bss_end = .);
|
||||
} >dram = 0xFF
|
||||
|
||||
/* SRAM Work RAM */
|
||||
.sram_bss (NOLOAD): SUBALIGN(2)
|
||||
{
|
||||
PROVIDE(__sram_bss_start = .);
|
||||
*(.sram_bss*)
|
||||
PROVIDE(__sram_bss_end = .);
|
||||
} >sram
|
||||
|
||||
/* Prevent overlaps with vbvectors */
|
||||
/* The use of new variables is because GCC 4.7's linker doesn't override the v value */
|
||||
v1 = v + SIZEOF(.data) + SIZEOF(.sdata);
|
||||
|
||||
/* Compute the vector address */
|
||||
/* This promotes . to a power of two */
|
||||
|
||||
v2 = v1 + 0x21F; /* add size of jump table */
|
||||
v3 = v2 & 0x00FFFFFF;
|
||||
v4 = v3 | (v3 >> 1);
|
||||
v5 = v4 | (v4 >> 2);
|
||||
v6 = v5 | (v5 >> 4);
|
||||
v7 = v6 | (v6 >> 8);
|
||||
v8 = v7 | (v7 >> 16);
|
||||
|
||||
__vbvectors_vma = __text_vma + v8 - 0x21F;
|
||||
|
||||
/* Place interrupt and reset vector at end of rom */
|
||||
.vbvectors __vbvectors_vma :
|
||||
{
|
||||
KEEP (*(.vbvectors))
|
||||
} >rom = 0xFF
|
||||
}
|
||||
40
libs/libgccvb/controller.c
Normal file
40
libs/libgccvb/controller.c
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "types.h"
|
||||
#include "hw.h"
|
||||
#include "controller.h"
|
||||
|
||||
|
||||
u16 oldkeydown = 0x0000;
|
||||
u16 oldkeyup = 0x0000;
|
||||
|
||||
|
||||
/* Reads the keypad, returns the 16 button bits */
|
||||
u16 vbReadPad()
|
||||
{
|
||||
HW_REGS[SCR] = (S_INTDIS | S_HW);
|
||||
while (HW_REGS[SCR] & S_STAT);
|
||||
return (HW_REGS[SDHR] << 8) | HW_REGS[SDLR];
|
||||
}
|
||||
|
||||
/* Check if a button has been pressed since the last read. If button state matches last read, it is returned as 'off' */
|
||||
u16 vbPadKeyDown()
|
||||
{
|
||||
u16 keystate,keydown;
|
||||
|
||||
keystate = vbReadPad() & K_ANY;
|
||||
keydown = (oldkeydown & keystate) ^ keystate;
|
||||
oldkeydown = keystate;
|
||||
|
||||
return keydown;
|
||||
}
|
||||
|
||||
/* Check if a button has been released since the last read. If button state matches last read, it is returned as 'off' */
|
||||
u16 vbPadKeyUp()
|
||||
{
|
||||
u16 keystate,keyup;
|
||||
|
||||
keystate = vbReadPad() & K_ANY;
|
||||
keyup = (oldkeyup & ~keystate);
|
||||
oldkeyup = keystate;
|
||||
|
||||
return keyup;
|
||||
}
|
||||
46
libs/libgccvb/controller.h
Normal file
46
libs/libgccvb/controller.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef _LIBGCCVB_CONTROLLER_H
|
||||
#define _LIBGCCVB_CONTROLLER_H
|
||||
|
||||
|
||||
#include "types.h"
|
||||
#include "hw.h"
|
||||
|
||||
|
||||
/* Hardware reg SCR definitions */
|
||||
#define S_INTDIS 0x80 // Disable Interrups
|
||||
#define S_SW 0x20 // Software Reading
|
||||
#define S_SWCK 0x10 // Software Clock, Interrupt?
|
||||
#define S_HW 0x04 // Hardware Reading
|
||||
#define S_STAT 0x02 // Hardware Reading Status
|
||||
#define S_HWDIS 0x01 // Disable Hardware Reading
|
||||
|
||||
/* Keypad Definitions */
|
||||
#define K_ANY 0xFFFC // All keys, without pwr & sgn
|
||||
#define K_BTNS 0x303C // All buttons; no d-pads, pwr or sgn
|
||||
#define K_PADS 0xCFC0 // All d-pads
|
||||
#define K_LPAD 0x0F00 // Left d-pad only
|
||||
#define K_RPAD 0xC0C0 // Right d-pad only
|
||||
#define K_PWR 0x0001 // Low Battery
|
||||
#define K_SGN 0x0002 // Signature; 1 = Standard Pad
|
||||
#define K_A 0x0004 // A Button
|
||||
#define K_B 0x0008 // B Button
|
||||
#define K_RT 0x0010 // R Trigger
|
||||
#define K_LT 0x0020 // L Trigger
|
||||
#define K_RU 0x0040 // Right Pad, Up
|
||||
#define K_RR 0x0080 // Right Pad, Right
|
||||
#define K_LR 0x0100 // Left Pad, Right
|
||||
#define K_LL 0x0200 // Left Pad, Left
|
||||
#define K_LD 0x0400 // Left Pad, Down
|
||||
#define K_LU 0x0800 // Left Pad, Up
|
||||
#define K_STA 0x1000 // Start Button
|
||||
#define K_SEL 0x2000 // Select Button
|
||||
#define K_RL 0x4000 // Right Pad, Left
|
||||
#define K_RD 0x8000 // Right Pad, Down
|
||||
|
||||
|
||||
u16 vbReadPad();
|
||||
u16 vbPadKeyDown();
|
||||
u16 vbPadKeyUp();
|
||||
|
||||
|
||||
#endif
|
||||
5
libs/libgccvb/hw.c
Normal file
5
libs/libgccvb/hw.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "types.h"
|
||||
#include "hw.h"
|
||||
|
||||
|
||||
u8* const HW_REGS = (u8*)0x02000000;
|
||||
28
libs/libgccvb/hw.h
Normal file
28
libs/libgccvb/hw.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#ifndef _LIBGCCVB_HW_H
|
||||
#define _LIBGCCVB_HW_H
|
||||
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
||||
extern u8* const HW_REGS;
|
||||
|
||||
/***** Hardware Register Mnemonics *****/
|
||||
#define CCR 0x00 // Communication Control Register (0x0200 0000)
|
||||
#define CCSR 0x04 // COMCNT Control Register (0x0200 0004)
|
||||
#define CDTR 0x08 // Transmitted Data Register (0x0200 0008)
|
||||
#define CDRR 0x0C // Received Data Register (0x0200 000C)
|
||||
#define SDLR 0x10 // Serial Data Low Register (0x0200 0010)
|
||||
#define SDHR 0x14 // Serial Data High Register (0x0200 0014)
|
||||
#define TLR 0x18 // Timer Low Register (0x0200 0018)
|
||||
#define THR 0x1C // Timer High Register (0x0200 001C)
|
||||
#define TCR 0x20 // Timer Control Register (0x0200 0020)
|
||||
#define WCR 0x24 // Wait-state Control Register (0x0200 0024)
|
||||
#define SCR 0x28 // Serial Control Register (0x0200 0028)
|
||||
|
||||
/********Cache Management***************/
|
||||
#define CACHE_ENABLE asm("mov 2,r1 \n ldsr r1,sr24": /* No Output */: /* No Input */: "r1" /* Reg r1 Used */)
|
||||
#define CACHE_DISABLE asm("ldsr r0,sr24")
|
||||
|
||||
|
||||
#endif
|
||||
15
libs/libgccvb/interrupts.h
Normal file
15
libs/libgccvb/interrupts.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef _LIBGCCVB_INTERRUPTS_H_
|
||||
#define _LIBGCCVB_INTERRUPTS_H_
|
||||
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
||||
extern u32 keyVector;
|
||||
extern u32 timVector;
|
||||
extern u32 croVector;
|
||||
extern u32 comVector;
|
||||
extern u32 vpuVector;
|
||||
|
||||
|
||||
#endif
|
||||
23
libs/libgccvb/libgccvb.h
Normal file
23
libs/libgccvb/libgccvb.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef _LIBGCCVB_H_
|
||||
#define _LIBGCCVB_H_
|
||||
|
||||
|
||||
#include "affine.h"
|
||||
#include "audio.h"
|
||||
#include "asm.h"
|
||||
#include "bgmap.h"
|
||||
#include "interrupts.h"
|
||||
#include "hw.h"
|
||||
#include "controller.h"
|
||||
#include "mem.h"
|
||||
#include "misc.h"
|
||||
#include "object.h"
|
||||
#include "random.h"
|
||||
#include "types.h"
|
||||
#include "video.h"
|
||||
#include "vip.h"
|
||||
#include "world.h"
|
||||
#include "timer.h"
|
||||
|
||||
|
||||
#endif
|
||||
120
libs/libgccvb/makefile
Normal file
120
libs/libgccvb/makefile
Normal file
@@ -0,0 +1,120 @@
|
||||
#Makefile taken from Wikipedia.org
|
||||
#
|
||||
# Specify the main target
|
||||
TARGET = libgccvb
|
||||
|
||||
# Default build type
|
||||
#TYPE = debug
|
||||
TYPE = release
|
||||
#TYPE = preprocessor
|
||||
|
||||
LIBGCCVB = $(VBDE)/libs/libgccvb
|
||||
|
||||
# Which directories contain source files
|
||||
DIRS := $(shell find $(LIBGCCVB) -type d -print)
|
||||
|
||||
# Which libraries are linked
|
||||
LIBS =
|
||||
# Dynamic libraries
|
||||
DLIBS =
|
||||
|
||||
# Obligatory headers
|
||||
ESSENTIALS = -include $(LIBGCCVB)/libgccvb.h \
|
||||
|
||||
# The next blocks change some variables depending on the build type
|
||||
ifeq ($(TYPE), debug)
|
||||
LDPARAM = -fno-builtin -ffreestanding
|
||||
CCPARAM = -nodefaultlibs -mv810 -Wall -O0 -Winline $(ESSENTIALS)
|
||||
MACROS = __DEBUG
|
||||
endif
|
||||
|
||||
ifeq ($(TYPE), release)
|
||||
LDPARAM =
|
||||
CCPARAM = -nodefaultlibs -mv810 -finline-functions -Wall -O3 -Winline $(ESSENTIALS)
|
||||
MACROS = NDEBUG
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(TYPE), preprocessor)
|
||||
LDPARAM =
|
||||
CCPARAM = -nodefaultlibs -mv810 -Wall -O -Winline $(ESSENTIALS) -E -P
|
||||
MACROS = __DEBUG
|
||||
endif
|
||||
|
||||
|
||||
# Add directories to the include and library paths
|
||||
|
||||
INCPATH := $(shell find $(LIBGCCVB) -type d -print)
|
||||
|
||||
|
||||
# Which files to add to backups, apart from the source code
|
||||
EXTRA_FILES = makefile
|
||||
|
||||
# The compiler
|
||||
GCC = v810-gcc
|
||||
OBJCOPY = v810-objcopy
|
||||
OBJDUMP = v810-objdump
|
||||
AR = v810-ar
|
||||
|
||||
# Where to store object and dependancy files.
|
||||
STORE = .make-$(TYPE)
|
||||
|
||||
# Makes a list of the source (.cpp) files.
|
||||
SOURCE := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.c))
|
||||
|
||||
# List of header files.
|
||||
HEADERS := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.h))
|
||||
|
||||
# Makes a list of the object files that will have to be created.
|
||||
OBJECTS := $(addprefix $(STORE)/, $(SOURCE:.c=.o))
|
||||
|
||||
# Same for the .d (dependancy) files.
|
||||
DFILES := $(addprefix $(STORE)/,$(SOURCE:.c=.d))
|
||||
|
||||
# Specify phony rules. These are rules that are not real files.
|
||||
.PHONY: clean backup dirs
|
||||
|
||||
# Main target. The @ in front of a command prevents make from displaying
|
||||
# it to the standard output.
|
||||
|
||||
all: $(TARGET).a
|
||||
|
||||
$(TARGET).a: dirs $(OBJECTS)
|
||||
@echo Config file: $(CONFIG_FILE)
|
||||
@echo Creating $(TARGET).a
|
||||
@$(AR) rcs $@ $(OBJECTS)
|
||||
@echo Done $@
|
||||
|
||||
# Rule for creating object file and .d file, the sed magic is to add
|
||||
# the object path at the start of the file because the files gcc
|
||||
# outputs assume it will be in the same dir as the source file.
|
||||
$(STORE)/%.o: %.c
|
||||
@echo Creating o file for $(TYPE) $*...
|
||||
@$(GCC) -Wp,-MD,$(STORE)/$*.dd $(foreach INC,$(INCPATH),-I$(INC))\
|
||||
$(foreach MACRO,$(MACROS),-D$(MACRO)) $(CCPARAM) -c $< -o $@
|
||||
@sed -e '1s/^\(.*\)$$/$(subst /,\/,$(dir $@))\1/' $(STORE)/$*.dd > $(STORE)/$*.d
|
||||
@rm -f $(STORE)/$*.dd
|
||||
|
||||
# Empty rule to prevent problems when a header is deleted.
|
||||
%.h: ;
|
||||
|
||||
# Cleans up the objects, .d files and executables.
|
||||
clean:
|
||||
@echo Making clean.
|
||||
@-rm -f $(foreach DIR,$(DIRS),$(STORE)/$(DIR)/*.d $(STORE)/$(DIR)/*.o)
|
||||
@-rm -Rf $(STORE)
|
||||
|
||||
# Backup the source files.
|
||||
backup:
|
||||
@-if [ ! -e .backup ]; then mkdir .backup; fi;
|
||||
@zip .backup/backup_`date +%d-%m-%y_%H.%M`.zip $(SOURCE) $(HEADERS) $(EXTRA_FILES)
|
||||
|
||||
# Create necessary directories
|
||||
dirs:
|
||||
@-if [ ! -e $(STORE) ]; then mkdir $(STORE); fi;
|
||||
@-$(foreach DIR,$(DIRS), if [ ! -e $(STORE)/$(DIR) ]; \
|
||||
then mkdir -p $(STORE)/$(DIR); fi; )
|
||||
|
||||
# Includes the .d files so it knows the exact dependencies for every
|
||||
# source.
|
||||
-include $(DFILES)
|
||||
144
libs/libgccvb/makefile-game
Normal file
144
libs/libgccvb/makefile-game
Normal file
@@ -0,0 +1,144 @@
|
||||
#Makefile taken from Wikipedia.org
|
||||
#
|
||||
|
||||
# Specify the main target
|
||||
BUILD_DIR = build
|
||||
|
||||
# Specify the main target
|
||||
TARGET = $(BUILD_DIR)/output
|
||||
|
||||
# Default build type
|
||||
#TYPE = debug
|
||||
TYPE = release
|
||||
#TYPE = preprocessor
|
||||
|
||||
# Libgccvb's home
|
||||
LIBGCCVB_PATH = $(VBDE)/libs/libgccvb
|
||||
|
||||
# Which directories contain source files
|
||||
DIRS := $(shell find . $(LIBGCCVB_PATH) -path ./build -prune -o -type d -print)
|
||||
|
||||
# Which libraries are linked
|
||||
LIBS =
|
||||
ROMHEADER=lib/vb.hdr
|
||||
|
||||
# Dynamic libraries
|
||||
DLIBS =
|
||||
|
||||
|
||||
GAME_ESSENTIALS = -include $(LIBGCCVB_PATH)/libgccvb.h
|
||||
|
||||
# The next blocks change some variables depending on the build type
|
||||
ifeq ($(TYPE),debug)
|
||||
LDPARAM = -T$(LIBGCCVB_PATH)/compiler/vb.ld -lm
|
||||
CCPARAM = -fno-builtin -ffreestanding -nodefaultlibs -mv810 -O -Wall $(GAME_ESSENTIALS)
|
||||
MACROS = __DEBUG
|
||||
endif
|
||||
|
||||
ifeq ($(TYPE), release)
|
||||
LDPARAM = -T$(LIBGCCVB_PATH)/compiler/vb.ld -lm
|
||||
CCPARAM = -nodefaultlibs -mv810 -finline-functions -Wall -O3 -Winline $(GAME_ESSENTIALS) -I$(VBDE)/libs/libgccvb/
|
||||
MACROS = NDEBUG
|
||||
endif
|
||||
|
||||
ifeq ($(TYPE),preprocessor)
|
||||
LDPARAM = -T$(LIBGCCVB_PATH)/compiler/vb.ld -lm
|
||||
CCPARAM = -nodefaultlibs -mv810 -Wall -Winline $(GAME_ESSENTIALS) -E
|
||||
MACROS = __DEBUG
|
||||
endif
|
||||
|
||||
# Add directories to the include and library paths
|
||||
INCPATH_GAME := $(shell find * -type d -print)
|
||||
|
||||
LIBPATH =
|
||||
|
||||
# Which files to add to backups, apart from the source code
|
||||
EXTRA_FILES = makefile
|
||||
|
||||
# The compiler
|
||||
GCC = v810-gcc
|
||||
AS = v810-as
|
||||
OBJCOPY = v810-objcopy
|
||||
OBJDUMP = v810-objdump
|
||||
|
||||
# Where to store object and dependancy files.
|
||||
STORE = $(BUILD_DIR)/$(TYPE)
|
||||
|
||||
# Makes a list of the source (.cpp) files.
|
||||
SOURCE := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.c))
|
||||
|
||||
# Makes a list of the source (.s) files.
|
||||
ASM := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.s))
|
||||
|
||||
# List of header files.
|
||||
HEADERS := $(foreach DIR,$(DIRS),$(wildcard $(DIR)/*.h))
|
||||
|
||||
# Makes a list of the object files that will have to be created.
|
||||
C_OBJECTS := $(addprefix $(STORE)/, $(SOURCE:.c=.o))
|
||||
|
||||
# Makes a list of the object files that will have to be created.
|
||||
ASM_OBJECTS := $(addprefix $(STORE)/, $(ASM:.s=.o))
|
||||
|
||||
# Same for the .d (dependancy) files.
|
||||
DFILES := $(addprefix $(STORE)/,$(SOURCE:.c=.d))
|
||||
|
||||
# Specify phony rules. These are rules that are not real files.
|
||||
.PHONY: clean backup dirs
|
||||
|
||||
# Main target. The @ in front of a command prevents make from displaying
|
||||
# it to the standard output.
|
||||
|
||||
all: $(TARGET).vb
|
||||
|
||||
$(TARGET).vb: main.elf
|
||||
@echo Creating $@
|
||||
@$(OBJCOPY) -O binary main.elf $@
|
||||
@echo $(TARGET).vb done
|
||||
# @echo Generating assembler code
|
||||
# @$(OBJDUMP) -t main.elf > sections.txt
|
||||
# @$(OBJDUMP) -S main.elf > machine.asm
|
||||
|
||||
|
||||
main.elf: dirs $(C_OBJECTS) $(ASM_OBJECTS)
|
||||
@echo Linking $(TARGET).
|
||||
@$(GCC) -o $@ -nostartfiles $(C_OBJECTS) $(ASM_OBJECTS) $(LDPARAM) \
|
||||
$(foreach LIBRARY, $(LIBS),-l$(LIBRARY)) $(foreach LIB,$(LIBPATH),-L$(LIB))
|
||||
|
||||
# Rule for creating object file and .d file, the sed magic is to add
|
||||
# the object path at the start of the file because the files gcc
|
||||
# outputs assume it will be in the same dir as the source file.
|
||||
$(STORE)/%.o: %.c
|
||||
@echo Creating object file for $*...
|
||||
@$(GCC) -Wp,-MD,$(STORE)/$*.dd $(CCPARAM) $(foreach INC, $(INCPATH_GAME),-I$(INC))\
|
||||
$(foreach MACRO,$(MACROS),-D$(MACRO)) -c $< -o $@
|
||||
@sed -e '1s/^\(.*\)$$/$(subst /,\/,$(dir $@))\1/' $(STORE)/$*.dd > $(STORE)/$*.d
|
||||
@rm -f $(STORE)/$*.dd
|
||||
|
||||
$(STORE)/%.o: %.s
|
||||
@echo Creating object file for $*
|
||||
@$(AS) -o $@ $<
|
||||
|
||||
# Empty rule to prevent problems when a header is deleted.
|
||||
%.h: ;
|
||||
|
||||
# Cleans up the objects, .d files and executables.
|
||||
clean:
|
||||
@echo Making clean.
|
||||
@-rm -f $(foreach DIR,$(DIRS),$(STORE)/$(DIR)/*.d $(STORE)/$(DIR)/*.o)
|
||||
@-rm -Rf $(STORE)
|
||||
@-rm -f $(ENGINE)
|
||||
|
||||
# Backup the source files.
|
||||
backup:
|
||||
@-if [ ! -e .backup ]; then mkdir .backup; fi;
|
||||
@zip .backup/backup_`date +%d-%m-%y_%H.%M`.zip $(SOURCE) $(HEADERS) $(EXTRA_FILES)
|
||||
|
||||
# Create necessary directories
|
||||
dirs:
|
||||
@-if [ ! -e $(STORE) ]; then mkdir -p $(STORE); fi;
|
||||
@-$(foreach DIR,$(DIRS), if [ ! -e $(STORE)/$(DIR) ]; \
|
||||
then mkdir -p $(STORE)/$(DIR); fi; )
|
||||
|
||||
# Includes the .d files so it knows the exact dependencies for every
|
||||
# source.
|
||||
-include $(DFILES)
|
||||
5
libs/libgccvb/makefile-game-minimal
Normal file
5
libs/libgccvb/makefile-game-minimal
Normal file
@@ -0,0 +1,5 @@
|
||||
# Minimal makefile, only suited for projects with a single c file
|
||||
|
||||
all:
|
||||
v810-gcc *.c -o main.elf -Wall -nodefaultlibs -mv810 -T$(VBDE)/libs/libgccvb/compiler/vb.ld -I$(VBDE)/libs/libgccvb -B$(VBDE)/msys/1.0/v810/v810-win32/v810/lib/
|
||||
v810-objcopy -O binary main.elf output.vb
|
||||
17
libs/libgccvb/math.c
Normal file
17
libs/libgccvb/math.c
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "math.h"
|
||||
|
||||
float squareRootFloat(float number)
|
||||
{
|
||||
long i;
|
||||
float x, y;
|
||||
const float f = 1.5F;
|
||||
|
||||
x = number * 0.5F;
|
||||
y = number;
|
||||
i = * ( long * ) &y;
|
||||
i = 0x5f3759df - ( i >> 1 );
|
||||
y = * ( float * ) &i;
|
||||
y = y * ( f - ( x * y * y ) );
|
||||
y = y * ( f - ( x * y * y ) );
|
||||
return number * y;
|
||||
}
|
||||
133
libs/libgccvb/math.h
Normal file
133
libs/libgccvb/math.h
Normal file
@@ -0,0 +1,133 @@
|
||||
#ifndef _LIBGCCVB_MATH_H_
|
||||
#define _LIBGCCVB_MATH_H_
|
||||
|
||||
|
||||
//Fixed Point macros
|
||||
#define fix7_9 s16
|
||||
#define fix13_3 s16
|
||||
#define fix23_9 s32
|
||||
|
||||
// round functions
|
||||
#define FIX23_9_ROUNDTOI(n) ((FIX23_9TOI(n)) + (((n) & 0x000001FF) >> 8))
|
||||
|
||||
#define F_ROUND(n) (int)((n) + 0.5f)
|
||||
//floor and ceil
|
||||
#define F_FLOOR(n) (int) ((n)-0.5f)
|
||||
#define F_CEIL(n) (int)((n)+0.5f)
|
||||
|
||||
//convert a float to fixed point and back
|
||||
#define FTOFIX7_9(n) (fix7_9) ((n) * 512.0f+0.5f)
|
||||
#define FTOFIX13_3(n) (fix13_3)((n) * 8.0f+0.5f)
|
||||
#define FTOFIX23_9(n) (fix23_9)((n) * 512.0f+0.5f)
|
||||
|
||||
#define FIX7_9TOF(n) (float) ((n) / 512.0f)
|
||||
#define FIX13_3TOF(n) (float) ((n) / 8.0f)
|
||||
#define FIX23_9TOF(n) (float) ((n) / 512.0f)
|
||||
|
||||
//convert an int to fixed point and back
|
||||
#define ITOFIX7_9(n) (fix7_9) ((n)<<9)
|
||||
#define ITOFIX13_3(n) (fix13_3)((n)<<3)
|
||||
#define ITOFIX23_9(n) (fix23_9)((n)<<9)
|
||||
|
||||
#define FIX7_9TOI(n) (s16) ((n)>>9)
|
||||
#define FIX13_3TOI(n) (s16) ((n)>>3)
|
||||
#define FIX23_9TOI(n) (s32) ((n)>>9)
|
||||
|
||||
#define FIX23_9TOFIX13_3(n) (fix7_9)((n)>>6)
|
||||
#define FIX23_9TOFIX7_9(n) (fix7_9)(n)
|
||||
#define FIX7_9TOFIX23_9(n) (fix23_9)(n)
|
||||
#define FIX13_3TOFIX7_9(n) (fix7_9) ((n)<<6)
|
||||
#define FIX7_9TOFIX13_3(n) (fix13_3)((n)>>6)
|
||||
|
||||
//Return fractional part of fixed
|
||||
#define FIX7_9_FRAC(n) ((n)&0x01FF)
|
||||
#define FIX13_3_FRAC(n) ((n)&0x0007)
|
||||
#define FIX23_9_FRAC(n) ((n)&0x01FF)
|
||||
|
||||
//fixed multiplication, what a mess of brackets
|
||||
//question how do we return an s32 from s16*s16 without forcing a promotion to s32
|
||||
#define FIX7_9_MULT(a,b) (fix7_9) ((((s32)(a))*((s32)(b)))>>9)
|
||||
#define FIX13_3_MULT(a,b) (fix13_3)((((s32)(a))*((s32)(b)))>>3)
|
||||
#define FIX23_9_MULT(a,b) (fix23_9)((((s64)(a))*((s64)(b)))>>9)
|
||||
|
||||
//Fixed division
|
||||
#define FIX7_9_DIV(a,b) (fix7_9) ((((s32)(a))<<9)/((s32)(b)))
|
||||
#define FIX13_3_DIV(a,b) (fix13_3)((((s32)(a))<<3)/((s32)(b)))
|
||||
#define FIX23_9_DIV(a,b) (fix23_9)((((s64)(a))<<9)/((s64)(b)))
|
||||
|
||||
static const s16 SINLUT[] = {
|
||||
0, 6, 12, 18, 25, 31, 37, 43, //1
|
||||
50, 56, 62, 68, 75, 81, 87, 93, //2
|
||||
99, 106, 112, 118, 124, 130, 136, 142, //3
|
||||
148, 154, 160, 166, 172, 178, 184, 190, //4
|
||||
195, 201, 207, 213, 218, 224, 230, 235, //5
|
||||
241, 246, 252, 257, 263, 268, 273, 279, //6
|
||||
284, 289, 294, 299, 304, 310, 314, 319, //7
|
||||
324, 329, 334, 339, 343, 348, 353, 357, //8
|
||||
362, 366, 370, 375, 379, 383, 387, 391, //9
|
||||
395, 399, 403, 407, 411, 414, 418, 422, //10
|
||||
425, 429, 432, 435, 439, 442, 445, 448, //11
|
||||
451, 454, 457, 460, 462, 465, 468, 470, //12
|
||||
473, 475, 477, 479, 482, 484, 486, 488, //13
|
||||
489, 491, 493, 495, 496, 498, 499, 500, //14
|
||||
502, 503, 504, 505, 506, 507, 508, 508, //15
|
||||
509, 510, 510, 511, 511, 511, 511, 512, //16
|
||||
511, 511, 511, 511, 511, 511, 510, 510, //17
|
||||
509, 508, 508, 507, 506, 505, 504, 503, //18
|
||||
502, 500, 499, 498, 496, 495, 493, 491, //19
|
||||
489, 488, 486, 484, 482, 479, 477, 475, //20
|
||||
473, 470, 468, 465, 462, 460, 457, 454, //21
|
||||
451, 448, 445, 442, 439, 435, 432, 429, //22
|
||||
425, 422, 418, 414, 411, 407, 403, 399, //23
|
||||
395, 391, 387, 383, 379, 375, 370, 366, //24
|
||||
362, 357, 353, 348, 343, 339, 334, 329, //25
|
||||
324, 319, 314, 310, 304, 299, 294, 289, //26
|
||||
284, 279, 273, 268, 263, 257, 252, 246, //27
|
||||
241, 235, 230, 224, 218, 213, 207, 201, //28
|
||||
195, 190, 184, 178, 172, 166, 160, 154, //29
|
||||
148, 142, 136, 130, 124, 118, 112, 106, //30
|
||||
99, 93, 87, 81, 75, 68, 62, 56, //31
|
||||
50, 43, 37, 31, 25, 18, 12, 6, //32
|
||||
0, -6, -12, -18, -25, -31, -37, -43, //33
|
||||
-50, -56, -62, -68, -75, -81, -87, -93, //34
|
||||
-99, -106, -112, -118, -124, -130, -136, -142, //35
|
||||
-148, -154, -160, -166, -172, -178, -184, -190, //36
|
||||
-195, -201, -207, -213, -218, -224, -230, -235, //37
|
||||
-241, -246, -252, -257, -263, -268, -273, -279, //38
|
||||
-284, -289, -294, -299, -305, -310, -315, -319, //39
|
||||
-324, -329, -334, -339, -343, -348, -353, -357, //40
|
||||
-362, -366, -370, -375, -379, -383, -387, -391, //41
|
||||
-395, -399, -403, -407, -411, -414, -418, -422, //42
|
||||
-425, -429, -432, -435, -439, -442, -445, -448, //43
|
||||
-451, -454, -457, -460, -462, -465, -468, -470, //44
|
||||
-473, -475, -477, -479, -482, -484, -486, -488, //45
|
||||
-489, -491, -493, -495, -496, -498, -499, -500, //46
|
||||
-502, -503, -504, -505, -506, -507, -508, -508, //47
|
||||
-509, -510, -510, -511, -511, -511, -511, -512, //48
|
||||
-511, -511, -511, -511, -511, -511, -510, -510, //49
|
||||
-509, -508, -508, -507, -506, -505, -504, -503, //50
|
||||
-502, -500, -499, -498, -496, -495, -493, -491, //51
|
||||
-489, -488, -486, -484, -482, -479, -477, -475, //52
|
||||
-473, -470, -468, -465, -462, -460, -457, -454, //53
|
||||
-451, -448, -445, -442, -439, -435, -432, -429, //54
|
||||
-425, -422, -418, -414, -411, -407, -403, -399, //55
|
||||
-395, -391, -387, -383, -379, -375, -370, -366, //56
|
||||
-362, -357, -353, -348, -343, -339, -334, -329, //57
|
||||
-324, -319, -314, -310, -304, -299, -294, -289, //58
|
||||
-284, -279, -273, -268, -263, -257, -252, -246, //59
|
||||
-241, -235, -230, -224, -218, -213, -207, -201, //60
|
||||
-195, -190, -184, -178, -172, -166, -160, -154, //61
|
||||
-148, -142, -136, -130, -124, -118, -112, -106, //62
|
||||
-99, -93, -87, -81, -75, -68, -62, -56, //63
|
||||
-50, -43, -37, -31, -25, -18, -12, -6 };//64
|
||||
|
||||
#define COS(x) SINLUT[((x)+128)&0x1FF]
|
||||
#define SIN(x) SINLUT[(x)&0x1FF]
|
||||
|
||||
#define COSF(x) FIX7_9TOF(SINLUT[((x)+128)&0x1FF])
|
||||
#define SINF(x) FIX7_9TOF(SINLUT[(x)&0x1FF])
|
||||
|
||||
float squareRootFloat(float number);
|
||||
|
||||
|
||||
#endif
|
||||
37
libs/libgccvb/mem.c
Normal file
37
libs/libgccvb/mem.c
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "types.h"
|
||||
#include "mem.h"
|
||||
|
||||
|
||||
u8* const EXPANSION = (u8*)0x04000000; // Expansion bus area
|
||||
u8* const WORKRAM = (u8*)0x05000000; // Scratchpad RAM; USE WITH CAUTION! (In fact, just leave it alone!)
|
||||
u16* const SAVERAM = (u16*)0x06000000; // Cartridge's Battery-backed SRAM
|
||||
|
||||
|
||||
/***** Ancillary Functions *****/
|
||||
|
||||
// Copy a block of data from one area in memory to another.
|
||||
void copymem (u8* dest, const u8* src, u16 num)
|
||||
{
|
||||
u16 i;
|
||||
for (i = 0; i < num; i++) {
|
||||
*dest++ = *src++;
|
||||
}
|
||||
}
|
||||
|
||||
// Set each byte in a block of data to a given value.
|
||||
void setmem (u8* dest, u8 src, u16 num)
|
||||
{
|
||||
u16 i;
|
||||
for (i = 0; i < num; i++) {
|
||||
*dest++ = src;
|
||||
}
|
||||
}
|
||||
|
||||
// Copy a block of data from one area in memory to another, adding a given value to each byte, first.
|
||||
void addmem (u8* dest, const u8* src, u16 num, u8 offset)
|
||||
{
|
||||
u16 i;
|
||||
for (i = 0; i < num; i++) {
|
||||
*dest++ = (*src++ + offset);
|
||||
}
|
||||
}
|
||||
19
libs/libgccvb/mem.h
Normal file
19
libs/libgccvb/mem.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef _LIBGCCVB_MEM_H
|
||||
#define _LIBGCCVB_MEM_H
|
||||
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
||||
extern u8* const EXPANSION;
|
||||
extern u8* const WORKRAM;
|
||||
extern u16* const SAVERAM;
|
||||
|
||||
|
||||
/***** Ancillary Functions *****/
|
||||
void copymem (u8* dest, const u8* src, u16 num);
|
||||
void setmem (u8* dest, u8 src, u16 num);
|
||||
void addmem (u8* dest, const u8* src, u16 num, u8 offset);
|
||||
|
||||
|
||||
#endif
|
||||
85
libs/libgccvb/misc.c
Normal file
85
libs/libgccvb/misc.c
Normal file
@@ -0,0 +1,85 @@
|
||||
#include "types.h"
|
||||
#include "mem.h"
|
||||
#include "video.h"
|
||||
#include "misc.h"
|
||||
|
||||
|
||||
const char nums[16]="0123456789ABCDEF";
|
||||
|
||||
char *itoa(u32 num, u8 base, u8 digits)
|
||||
{
|
||||
int i;
|
||||
static char rev[11];
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
rev[9-i] = nums[num%base];
|
||||
num /= base;
|
||||
}
|
||||
|
||||
i=0;
|
||||
while (rev[i] == '0') i++;
|
||||
if (i >= (10-digits)) i=(10-digits);
|
||||
|
||||
rev[10] = 0;
|
||||
|
||||
return rev+i;
|
||||
}
|
||||
|
||||
void cls()
|
||||
{
|
||||
setmem((void*)(BGMap(0)), 0, 8192);
|
||||
}
|
||||
|
||||
void vbTextOut(u16 bgmap, u16 col, u16 row, char *t_string)
|
||||
/* The font must reside in Character segment 3 */
|
||||
{
|
||||
u16 i = 0,
|
||||
pos = row * 64 + col;
|
||||
|
||||
while(t_string[i])
|
||||
{
|
||||
//BGMM[(0x1000 * bgmap) + pos + i] = (u16)t_string[i] - 32 + 0x600;
|
||||
BGMM[(0x1000 * bgmap) + pos + i] = (u16)t_string[i] + 0x600;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
void vbPrint(u8 bgmap, u16 x, u16 y, char *t_string, u16 bplt)
|
||||
{
|
||||
// Font consists of the last 256 chars (1792-2047)
|
||||
u16 i=0,pos=0,col=x;
|
||||
|
||||
while(t_string[i])
|
||||
{
|
||||
pos = (y << 6) + x;
|
||||
|
||||
switch(t_string[i])
|
||||
{
|
||||
case 7:
|
||||
// Bell (!)
|
||||
break;
|
||||
case 9:
|
||||
// Horizontal Tab
|
||||
x = (x / tabsize + 1) * tabsize;
|
||||
break;
|
||||
case 10:
|
||||
// Carriage Return
|
||||
y++;
|
||||
x = col;
|
||||
break;
|
||||
case 13:
|
||||
// Line Feed
|
||||
// x = col;
|
||||
break;
|
||||
default:
|
||||
BGMM[(0x1000 * bgmap) + pos] = ((u16)t_string[i] + 0x700) | (bplt << 14);
|
||||
if (x++ > 63)
|
||||
{
|
||||
x = col;
|
||||
y++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
18
libs/libgccvb/misc.h
Normal file
18
libs/libgccvb/misc.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _LIBGCCVB_MISC_H
|
||||
#define _LIBGCCVB_MISC_H
|
||||
|
||||
|
||||
#include "types.h"
|
||||
#include "mem.h"
|
||||
#include "video.h"
|
||||
|
||||
// horizontal tab size in chars
|
||||
#define tabsize 4
|
||||
|
||||
char *itoa(u32 num, u8 base, u8 digits);
|
||||
void cls();
|
||||
void vbTextOut(u16 bgmap, u16 col, u16 row, char *t_string);
|
||||
void vbPrint(u8 bgmap, u16 x, u16 y, char *t_string, u16 bplt);
|
||||
|
||||
|
||||
#endif
|
||||
14
libs/libgccvb/object.c
Normal file
14
libs/libgccvb/object.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include "types.h"
|
||||
#include "video.h"
|
||||
#include "object.h"
|
||||
|
||||
|
||||
// (Obsoleted by the OBJ_* macros...)
|
||||
void vbSetObject (u16 n, u8 header, s16 x, s16 p, s16 y, u16 chr)
|
||||
{
|
||||
n <<= 2;
|
||||
OAM[n ] = (u16)x;
|
||||
OAM[n + 1] = (u16)p | ((u16)header << 8);
|
||||
OAM[n + 2] = (u16)y;
|
||||
OAM[n + 3] = ((header & 0x3C) << 10) | (chr & 0x7FF);
|
||||
}
|
||||
48
libs/libgccvb/object.h
Normal file
48
libs/libgccvb/object.h
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef _LIBGCCVB_OBJECT_H
|
||||
#define _LIBGCCVB_OBJECT_H
|
||||
|
||||
|
||||
#include "types.h"
|
||||
#include "video.h"
|
||||
|
||||
/***** Object Manipulation Macros *****/
|
||||
|
||||
#define OBJ_XSET(n,x) OAM[ (n) << 2] = (x)
|
||||
#define OBJ_YSET(n,y) OAM[((n) << 2) + 2] = (y)
|
||||
#define OBJ_PSET(n,p) OAM[((n) << 2) + 1] = (OAM[((n) << 2) + 1] & 0xC000) | ((u16)(p) & 0x3FFF)
|
||||
#define OBJ_CSET(n,c) OAM[((n) << 2) + 3] = (OAM[((n) << 2) + 3] & 0xF000) | ((u16)(c) & 0x07FF)
|
||||
#define OBJ_HSET(n,h) OAM[((n) << 2) + 3] = (OAM[((n) << 2) + 3] & 0xDFFF) | (((u16)(h) << 13) & 0x2000)
|
||||
#define OBJ_VSET(n,v) OAM[((n) << 2) + 3] = (OAM[((n) << 2) + 3] & 0xEFFF) | (((u16)(v) << 12) & 0x1000)
|
||||
#define OBJ_PALSET(n,pal) OAM[((n) << 2) + 3] = (((pal) << 14) & 0xC000) | (OAM[((n) << 2) + 3] & 0x3FFF)
|
||||
#define OBJ_VIS(n,v) OAM[((n) << 2) + 1] = (((v) << 14) & 0xC000) | (OAM[((n) << 2) + 1] & 0x3FFF)
|
||||
|
||||
/***** Object Functions *****/
|
||||
|
||||
// (Obsoleted by the OBJ_* macros...)
|
||||
void vbSetObject (u16 n, u8 header, s16 x, s16 p, s16 y, u16 chr);
|
||||
|
||||
// Object attributes
|
||||
#define JX 0 // Display pointer X
|
||||
#define JP 2 // Paralax
|
||||
#define JY 4 // Display pointer Y
|
||||
#define JCA 6 // Character No.
|
||||
|
||||
/***** "vbSetObject" header flags *****/
|
||||
// (OR these together to build an Object Header)
|
||||
#define JLON 0x8000
|
||||
#define JRON 0x4000
|
||||
|
||||
#define OBJ_ON 0x00C0
|
||||
#define OBJ_LON 0x0080
|
||||
#define OBJ_RON 0x0040
|
||||
|
||||
#define OBJ_PAL0 0x0000
|
||||
#define OBJ_PAL1 0x0010
|
||||
#define OBJ_PAL2 0x0020
|
||||
#define OBJ_PAL3 0x0030
|
||||
|
||||
#define OBJ_HFLIP 0x0008
|
||||
#define OBJ_VFLIP 0x0004
|
||||
|
||||
|
||||
#endif
|
||||
34
libs/libgccvb/random.c
Normal file
34
libs/libgccvb/random.c
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "random.h"
|
||||
|
||||
|
||||
// When run at startup gets a random number based on the changing CTA
|
||||
long randseed()
|
||||
{
|
||||
long
|
||||
random = 1;
|
||||
int
|
||||
rand,
|
||||
prevnum = 0,
|
||||
count = 1;
|
||||
|
||||
while (count < 30000) //repeat through many times to make more random and to allow the CTA value to change multiple times
|
||||
{
|
||||
rand = VIP_REGS[CTA]; //CTA = (*(BYTE*)(0x0005F830));
|
||||
if (random == 0) random = 1; //prevent % by zero
|
||||
|
||||
random += ((rand*count) + (count%random)); //just randomly doing stuff to the number
|
||||
|
||||
if (rand == prevnum) //if the CTA value doesnt change then count up
|
||||
count++;
|
||||
else
|
||||
count = 0; //if the number does change then restart the counter
|
||||
prevnum = rand; //keep track of the last number
|
||||
}
|
||||
return random; //returns the random seed
|
||||
}
|
||||
|
||||
// Returns a random number in the requested range from the random seed
|
||||
int randnum(long seed, int randnums)
|
||||
{
|
||||
return (seed%randnums);
|
||||
}
|
||||
9
libs/libgccvb/random.h
Normal file
9
libs/libgccvb/random.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef _LIBGCCVB_RANDOM_H
|
||||
#define _LIBGCCVB_RANDOM_H
|
||||
|
||||
|
||||
long randseed();
|
||||
int randnum(long seed, int randnums);
|
||||
|
||||
|
||||
#endif
|
||||
13
libs/libgccvb/readme.txt
Normal file
13
libs/libgccvb/readme.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
"Seiryu" Virtual Boy Library
|
||||
|
||||
A collaborative effort by:
|
||||
|
||||
Amos "RunnerPack" Bieler Slapped it together and inserted most of the errors ;)
|
||||
Alberto "Virtual-E" Covarrubias Made veCC (and the library upon which this one is based) and a TON of other VB tools.
|
||||
Cody "frostgiant" Planteen Deciphered the sound hardware and made the sound routines.
|
||||
David Tucker Oh, he only STARTED THE WHOLE VB DEV'ING SCENE!!!!!
|
||||
"Parasyte" Made the crt0.o and linker script, among MANY other things.
|
||||
Pat "DogP" Daderko Investigated many hardware specs to help improve emulator compatibility.
|
||||
And probably others... (You know who you are!)
|
||||
|
||||
BTW, "Seiryu" (sigh-roo) is a variety of Japanese Red-Leaf Maple tree.
|
||||
16
libs/libgccvb/stdarg.h
Normal file
16
libs/libgccvb/stdarg.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef _LIBGCCVB_STDARG_H_
|
||||
#define _LIBGCCVB_STDARG_H_
|
||||
|
||||
#ifndef _VA_LIST
|
||||
#define _VA_LIST
|
||||
typedef char *va_list;
|
||||
#endif
|
||||
|
||||
//#define va_start(list, start) ((void)((list) = (sizeof(start)<4 ? \
|
||||
// (char *)((int *)&(start)+1) : (char *)(&(start)+1))))
|
||||
#define va_start(list, start) ((void)((list) = (sizeof(start)<4 ? (char *)((int *)&(start)+1) : (char *)(&(start)+1))))
|
||||
#define va_end(list) ((void)0)
|
||||
#define va_arg(list, mode) *(mode *)(&(list = (char*)(((int)list + 7)&~3U))[-4])
|
||||
|
||||
|
||||
#endif
|
||||
48
libs/libgccvb/timer.c
Normal file
48
libs/libgccvb/timer.c
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "types.h"
|
||||
#include "hw.h"
|
||||
#include "timer.h"
|
||||
|
||||
|
||||
u8 tcr_val = 0;
|
||||
|
||||
void timer_enable(int enb)
|
||||
{
|
||||
if (enb) tcr_val |= TIMER_ENB;
|
||||
else tcr_val &= ~TIMER_ENB;
|
||||
HW_REGS[TCR] = tcr_val;
|
||||
}
|
||||
|
||||
u16 timer_get()
|
||||
{
|
||||
return (HW_REGS[TLR] | (HW_REGS[THR] << 8));
|
||||
}
|
||||
|
||||
void timer_set(u16 time)
|
||||
{
|
||||
HW_REGS[TLR] = (time & 0xFF);
|
||||
HW_REGS[THR] = (time >> 8);
|
||||
}
|
||||
|
||||
void timer_freq(int freq)
|
||||
{
|
||||
if (freq) tcr_val |= TIMER_20US;
|
||||
else tcr_val &= ~TIMER_20US;
|
||||
HW_REGS[TCR] = tcr_val;
|
||||
}
|
||||
|
||||
void timer_int(int enb)
|
||||
{
|
||||
if (enb) tcr_val |= TIMER_INT;
|
||||
else tcr_val &= ~TIMER_INT;
|
||||
HW_REGS[TCR] = tcr_val;
|
||||
}
|
||||
|
||||
int timer_getstat()
|
||||
{
|
||||
return (!!(HW_REGS[TCR] & TIMER_ZSTAT));
|
||||
}
|
||||
|
||||
void timer_clearstat()
|
||||
{
|
||||
HW_REGS[TCR] = (tcr_val|TIMER_ZCLR);
|
||||
}
|
||||
34
libs/libgccvb/timer.h
Normal file
34
libs/libgccvb/timer.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef _LIBGCCVB_TIMER_H_
|
||||
#define _LIBGCCVB_TIMER_H_
|
||||
|
||||
|
||||
#include "types.h"
|
||||
#include "hw.h"
|
||||
|
||||
|
||||
//use with 20us timer (range = 0 to 1300)
|
||||
#define TIME_US(n) (((n)/20)-1)
|
||||
|
||||
//use with 100us timer (range = 0 to 6500, and 0 to 6.5)
|
||||
#define TIME_MS(n) (((n)*10)-1)
|
||||
#define TIME_SEC(n) (((n)*10000)-1)
|
||||
|
||||
|
||||
#define TIMER_ENB 0x01
|
||||
#define TIMER_ZSTAT 0x02
|
||||
#define TIMER_ZCLR 0x04
|
||||
#define TIMER_INT 0x08
|
||||
#define TIMER_20US 0x10
|
||||
#define TIMER_100US 0x00
|
||||
|
||||
|
||||
void timer_enable(int enb);
|
||||
u16 timer_get();
|
||||
void timer_set(u16 time);
|
||||
void timer_freq(int freq);
|
||||
void timer_int(int enb);
|
||||
int timer_getstat();
|
||||
void timer_clearstat();
|
||||
|
||||
|
||||
#endif
|
||||
26
libs/libgccvb/types.h
Normal file
26
libs/libgccvb/types.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef _LIBGCCVB_TYPES_H
|
||||
#define _LIBGCCVB_TYPES_H
|
||||
|
||||
|
||||
// quick, easy types Byte(s) Range
|
||||
typedef unsigned char u8; /* 1 0 ... 255 */
|
||||
typedef unsigned short u16; /* 2 0 ... 65,535 */
|
||||
typedef unsigned long u32; /* 4 0 ... 4,294,967,295 */
|
||||
|
||||
typedef signed char s8; /* 1 -128 ... 127*/
|
||||
typedef signed short s16; /* 2 -32,768 ... 32,767*/
|
||||
typedef signed long s32; /* 4 -2,147,483,648 ... 2,147,483,647 */
|
||||
|
||||
typedef unsigned char BYTE; /* 1 0 ... 255 */
|
||||
typedef unsigned short HWORD; /* 2 0 ... 65,535 */
|
||||
typedef unsigned long WORD; /* 4 0 ... 4,294,967,295 */
|
||||
|
||||
typedef enum {false, true} bool;
|
||||
|
||||
// for fixed point math
|
||||
#define f8 s8
|
||||
#define f16 s16
|
||||
#define f32 s32
|
||||
|
||||
|
||||
#endif
|
||||
139
libs/libgccvb/video.c
Normal file
139
libs/libgccvb/video.c
Normal file
@@ -0,0 +1,139 @@
|
||||
#include "types.h"
|
||||
#include "vip.h"
|
||||
#include "video.h"
|
||||
|
||||
|
||||
/***** Display RAM *****/
|
||||
u32* const L_FRAME0 = (u32*)0x00000000; // Left Frame Buffer 0
|
||||
u32* const L_FRAME1 = (u32*)0x00008000; // Left Frame Buffer 1
|
||||
u32* const R_FRAME0 = (u32*)0x00010000; // Right Frame Buffer 0
|
||||
u32* const R_FRAME1 = (u32*)0x00018000; // Right Frame Buffer 1
|
||||
u16* const BGMM = (u16*)BGMMBase; // Pointer to BGMM
|
||||
u16* const WAM = (u16*)WAMBase; // Pointer to WAM
|
||||
u16* const CLMN_TBL = (u16*)0x0003DC00; // Base address of Column Tables
|
||||
u16* const OAM = (u16*)OAMBase; // Pointer to OAM
|
||||
|
||||
|
||||
/* Macro to set the brightness registers */
|
||||
#define SET_BRIGHT(a,b,c) VIP_REGS[BRTA]=(u16)(a); VIP_REGS[BRTB]=(u16)(b); VIP_REGS[BRTC]=(u16)(c)
|
||||
|
||||
/* Macro to set the GPLT (BGMap palette) */
|
||||
#define SET_GPLT(n,pal) VIP_REGS[GPLT0+n]=pal
|
||||
|
||||
/* Macro to set the JPLT (OBJ palette) */
|
||||
#define SET_JPLT(n,pal) VIP_REGS[JPLT0+n]=pal
|
||||
|
||||
|
||||
/* Delay execution */
|
||||
void vbWaitFrame(u16 count)
|
||||
{
|
||||
u16 i;
|
||||
|
||||
for (i = 0; i <= count; i++) {
|
||||
while (!(VIP_REGS[XPSTTS] & XPBSYR));
|
||||
while (VIP_REGS[XPSTTS] & XPBSYR);
|
||||
}
|
||||
}
|
||||
|
||||
/* Turn the display on */
|
||||
void vbDisplayOn()
|
||||
{
|
||||
VIP_REGS[REST] = 0;
|
||||
VIP_REGS[XPCTRL] = VIP_REGS[XPSTTS] | XPEN;
|
||||
VIP_REGS[DPCTRL] = VIP_REGS[DPSTTS] | (SYNCE | RE | DISP);
|
||||
VIP_REGS[FRMCYC] = 0;
|
||||
VIP_REGS[INTCLR] = VIP_REGS[INTPND];
|
||||
//while (!(VIP_REGS[DPSTTS] & 0x3C)); //required?
|
||||
|
||||
VIP_REGS[BRTA] = 0;
|
||||
VIP_REGS[BRTB] = 0;
|
||||
VIP_REGS[BRTC] = 0;
|
||||
VIP_REGS[GPLT0] = 0xE4; /* Set all eight palettes to: 11100100 */
|
||||
VIP_REGS[GPLT1] = 0xE4; /* (i.e. "Normal" dark to light progression.) */
|
||||
VIP_REGS[GPLT2] = 0xE4;
|
||||
VIP_REGS[GPLT3] = 0xE4;
|
||||
VIP_REGS[JPLT0] = 0xE4;
|
||||
VIP_REGS[JPLT1] = 0xE4;
|
||||
VIP_REGS[JPLT2] = 0xE4;
|
||||
VIP_REGS[JPLT3] = 0xE4;
|
||||
VIP_REGS[BKCOL] = 0; /* Clear the screen to black before rendering */
|
||||
}
|
||||
|
||||
// Turn the display off
|
||||
void vbDisplayOff()
|
||||
{
|
||||
VIP_REGS[REST] = 0;
|
||||
VIP_REGS[XPCTRL] = 0;
|
||||
VIP_REGS[DPCTRL] = 0;
|
||||
VIP_REGS[FRMCYC] = 0;
|
||||
VIP_REGS[INTCLR] = VIP_REGS[INTPND];
|
||||
}
|
||||
|
||||
// Call this after the display is on and you want the image to show up
|
||||
void vbDisplayShow()
|
||||
{
|
||||
VIP_REGS[BRTA] = 32;
|
||||
VIP_REGS[BRTB] = 64;
|
||||
VIP_REGS[BRTC] = 32;
|
||||
}
|
||||
|
||||
// Call this to hide the image; e.g. while setting things up
|
||||
void vbDisplayHide()
|
||||
{
|
||||
VIP_REGS[BRTA] = 0;
|
||||
VIP_REGS[BRTB] = 0;
|
||||
VIP_REGS[BRTC] = 0;
|
||||
}
|
||||
|
||||
void vbFXFadeIn(u16 wait)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i <= 32; i++) {
|
||||
vbWaitFrame(wait);
|
||||
SET_BRIGHT(i,i*2,i);
|
||||
}
|
||||
}
|
||||
|
||||
void vbFXFadeOut(u16 wait)
|
||||
{
|
||||
s8 i;
|
||||
|
||||
for (i = 32; i >= 0; i--) {
|
||||
vbWaitFrame(wait);
|
||||
SET_BRIGHT(i,i*2,i);
|
||||
}
|
||||
}
|
||||
|
||||
u8 const colTable[128] =
|
||||
{
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xE0, 0xBC,
|
||||
0xA6, 0x96, 0x8A, 0x82, 0x7A, 0x74, 0x6E, 0x6A,
|
||||
0x66, 0x62, 0x60, 0x5C, 0x5A, 0x58, 0x56, 0x54,
|
||||
0x52, 0x50, 0x50, 0x4E, 0x4C, 0x4C, 0x4A, 0x4A,
|
||||
0x48, 0x48, 0x46, 0x46, 0x46, 0x44, 0x44, 0x44,
|
||||
0x42, 0x42, 0x42, 0x40, 0x40, 0x40, 0x40, 0x40,
|
||||
0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3C,
|
||||
0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C,
|
||||
0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C
|
||||
};
|
||||
|
||||
// Setup the default Column Table
|
||||
void vbSetColTable()
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i <= 127; i++) {
|
||||
CLMN_TBL[i ] = colTable[i];
|
||||
CLMN_TBL[i + 256] = colTable[i];
|
||||
CLMN_TBL[i + 128] = colTable[127 - i];
|
||||
CLMN_TBL[i + 384] = colTable[127 - i];
|
||||
}
|
||||
}
|
||||
54
libs/libgccvb/video.h
Normal file
54
libs/libgccvb/video.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef _LIBGCCVB_VIDEO_H
|
||||
#define _LIBGCCVB_VIDEO_H
|
||||
|
||||
|
||||
#include "types.h"
|
||||
#include "vip.h"
|
||||
|
||||
|
||||
/***** Display RAM *****/
|
||||
extern u32* const L_FRAME0;
|
||||
#define CharSeg0 0x00006000 // Characters 0-511
|
||||
extern u32* const L_FRAME1;
|
||||
#define CharSeg1 0x0000E000 // Characters 512-1023
|
||||
extern u32* const R_FRAME0;
|
||||
#define CharSeg2 0x00016000 // Characters 1024-1535
|
||||
extern u32* const R_FRAME1;
|
||||
#define CharSeg3 0x0001E000 // Characters 1536-2047
|
||||
#define BGMMBase 0x00020000 // Base address of BGMap Memory
|
||||
extern u16* const BGMM;
|
||||
#define BGMap(b) (BGMMBase + (b * 0x2000)) // Address of BGMap b (0 <= b <= 13)
|
||||
|
||||
#define WAMBase 0x0003D800 // Base address of World Attribute Memory
|
||||
extern u16* const WAM;
|
||||
#define World(w) (WAMBase + (w * 0x0020)) // Address of World w (0 <= w <= 31)
|
||||
extern u16* const CLMN_TBL;
|
||||
#define OAMBase 0x0003E000 // Base address of Object Attribute Memory
|
||||
extern u16* const OAM;
|
||||
#define Object(o) (OAMBase + (o * 0x0008)) // Address of Obj o (0 <= o <= 1023)
|
||||
|
||||
/* Macro to set the brightness registers */
|
||||
#define SET_BRIGHT(a,b,c) VIP_REGS[BRTA]=(u16)(a); \
|
||||
VIP_REGS[BRTB]=(u16)(b); \
|
||||
VIP_REGS[BRTC]=(u16)(c)
|
||||
|
||||
/* Macro to set the GPLT (BGMap palette) */
|
||||
#define SET_GPLT(n,pal) VIP_REGS[GPLT0+n]=pal
|
||||
|
||||
/* Macro to set the JPLT (OBJ palette) */
|
||||
#define SET_JPLT(n,pal) VIP_REGS[JPLT0+n]=pal
|
||||
|
||||
void vbWaitFrame(u16 count);
|
||||
void vbDisplayOn();
|
||||
void vbDisplayOff();
|
||||
void vbDisplayShow();
|
||||
void vbDisplayHide();
|
||||
void vbFXFadeIn(u16 wait);
|
||||
void vbFXFadeOut(u16 wait);
|
||||
|
||||
extern u8 const colTable[128];
|
||||
|
||||
void vbSetColTable();
|
||||
|
||||
|
||||
#endif
|
||||
5
libs/libgccvb/vip.c
Normal file
5
libs/libgccvb/vip.c
Normal file
@@ -0,0 +1,5 @@
|
||||
#include "types.h"
|
||||
#include "vip.h"
|
||||
|
||||
/****** VIP Registers ******/
|
||||
volatile u16* VIP_REGS = (u16*)0x0005F800;
|
||||
77
libs/libgccvb/vip.h
Normal file
77
libs/libgccvb/vip.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifndef _LIBGCCVB_VIP_H
|
||||
#define _LIBGCCVB_VIP_H
|
||||
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
||||
/* Defines for INTPND\INTENB\INTCLR */
|
||||
#define TIMEERR 0x8000
|
||||
#define XPEND 0x4000
|
||||
#define SBHIT 0x2000
|
||||
#define FRAMESTART 0x0010
|
||||
#define GAMESTART 0x0008
|
||||
#define RFBEND 0x0004
|
||||
#define LFBEND 0x0002
|
||||
#define SCANERR 0x0001
|
||||
|
||||
/* Defines for DPSTTS\DPCTRL */
|
||||
#define LOCK 0x0400 // VPU SELECT CTA
|
||||
#define SYNCE 0x0200 // L,R_SYNC TO VPU
|
||||
#define RE 0x0100 // MEMORY REFLASH CYCLE ON
|
||||
#define FCLK 0x0080
|
||||
#define SCANRDY 0x0040
|
||||
#define DISP 0x0002 // DISPLAY ON
|
||||
#define DPRST 0x0001 // RESET VPU COUNTER AND WAIT FCLK
|
||||
|
||||
/* Defines for XPSTTS\XPCTRL */
|
||||
#define SBOUT 0x8000 // In FrameBuffer drawing included
|
||||
#define OVERTIME 0x0010 // Processing
|
||||
#define XPBSYR 0x000C // In the midst of drawing processing reset
|
||||
#define XPBSY1 0x0008 // In the midst of FrameBuffer1 picture editing
|
||||
#define XPBSY0 0x0004 // In the midst of FrameBuffer0 picture editing
|
||||
#define XPEN 0x0002 // Start of drawing
|
||||
#define XPRST 0x0001 // Forcing idling
|
||||
|
||||
|
||||
/****** VIP Registers ******/
|
||||
extern volatile u16* VIP_REGS;
|
||||
|
||||
/****** VIP Register Mnemonics ******/
|
||||
#define INTPND 0x00
|
||||
#define INTENB 0x01
|
||||
#define INTCLR 0x02
|
||||
|
||||
#define DPSTTS 0x10
|
||||
#define DPCTRL 0x11
|
||||
#define BRTA 0x12
|
||||
#define BRTB 0x13
|
||||
#define BRTC 0x14
|
||||
#define REST 0x15
|
||||
|
||||
#define FRMCYC 0x17
|
||||
#define CTA 0x18
|
||||
|
||||
#define XPSTTS 0x20
|
||||
#define XPCTRL 0x21
|
||||
#define VER 0x22
|
||||
|
||||
#define SPT0 0x24
|
||||
#define SPT1 0x25
|
||||
#define SPT2 0x26
|
||||
#define SPT3 0x27
|
||||
|
||||
#define GPLT0 0x30
|
||||
#define GPLT1 0x31
|
||||
#define GPLT2 0x32
|
||||
#define GPLT3 0x33
|
||||
|
||||
#define JPLT0 0x34
|
||||
#define JPLT1 0x35
|
||||
#define JPLT2 0x36
|
||||
#define JPLT3 0x37
|
||||
|
||||
#define BKCOL 0x38
|
||||
|
||||
|
||||
#endif
|
||||
24
libs/libgccvb/world.c
Normal file
24
libs/libgccvb/world.c
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "types.h"
|
||||
#include "video.h"
|
||||
#include "world.h"
|
||||
|
||||
|
||||
WORLD* const WA = (WORLD*)0x0003D800;
|
||||
|
||||
|
||||
/***** World Functions *****/
|
||||
// (Obsoleted by the WORLD_* macros...)
|
||||
void vbSetWorld (s16 nw, u16 header, u16 gx, s16 gp, u16 gy, u16 mx, s16 mp, u16 my, u16 width, u16 height)
|
||||
{
|
||||
u16 tmp = nw << 4;
|
||||
|
||||
WAM[tmp++] = header;
|
||||
WAM[tmp++] = gx;
|
||||
WAM[tmp++] = gp;
|
||||
WAM[tmp++] = gy;
|
||||
WAM[tmp++] = mx;
|
||||
WAM[tmp++] = mp;
|
||||
WAM[tmp++] = my;
|
||||
WAM[tmp++] = width;
|
||||
WAM[tmp] = height;
|
||||
}
|
||||
66
libs/libgccvb/world.h
Normal file
66
libs/libgccvb/world.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef _LIBGCCVB_WORLD_H
|
||||
#define _LIBGCCVB_WORLD_H
|
||||
|
||||
|
||||
#include "types.h"
|
||||
#include "video.h"
|
||||
|
||||
|
||||
typedef struct WORLD
|
||||
{
|
||||
u16 head;
|
||||
u16 gx;
|
||||
s16 gp;
|
||||
u16 gy;
|
||||
u16 mx;
|
||||
s16 mp;
|
||||
u16 my;
|
||||
u16 w;
|
||||
u16 h;
|
||||
u16 param;
|
||||
u16 ovr;
|
||||
u16 spacer[5];
|
||||
} WORLD;
|
||||
|
||||
extern WORLD* const WA;
|
||||
|
||||
/* "vbSetWorld" header flags */
|
||||
/* (OR these together to build a World Header) */
|
||||
|
||||
#define WRLD_ON 0xC000 // There_are_two_screens!__USE_THEM!!!
|
||||
#define WRLD_LON 0x8000
|
||||
#define WRLD_RON 0x4000
|
||||
#define WRLD_OBJ 0x3000
|
||||
#define WRLD_AFFINE 0x2000
|
||||
#define WRLD_HBIAS 0x1000
|
||||
#define WRLD_BGMAP 0x0000
|
||||
|
||||
#define WRLD_1x1 0x0000
|
||||
#define WRLD_1x2 0x0100
|
||||
#define WRLD_1x4 0x0200
|
||||
#define WRLD_1x8 0x0300
|
||||
#define WRLD_2x1 0x0400
|
||||
#define WRLD_2x2 0x0500
|
||||
#define WRLD_2x4 0x0600
|
||||
#define WRLD_4x2 0x0900
|
||||
#define WRLD_4x1 0x0800
|
||||
#define WRLD_8x1 0x0C00
|
||||
|
||||
#define WRLD_OVR 0x0080
|
||||
#define WRLD_END 0x0040
|
||||
|
||||
/* Macros for world manipulation */
|
||||
// (Obsoleted by the WA array of WORLD structures...)
|
||||
#define WORLD_HEAD(n,head) WAM[(n << 4)] = head
|
||||
#define WORLD_GSET(n,gx,gp,gy) WAM[(n << 4) + 1] = gx; WAM[(n << 4) + 2] = gp; WAM[(n << 4) + 3] = gy
|
||||
#define WORLD_MSET(n,mx,mp,my) WAM[(n << 4) + 4] = mx; WAM[(n << 4) + 5] = mp; WAM[(n << 4) + 6] = my
|
||||
#define WORLD_SIZE(n,w,h) WAM[(n << 4) + 7] = w; WAM[(n << 4) + 8] = h
|
||||
#define WORLD_PARAM(n,p) WAM[(n << 4) + 9] = ((p - 0x20000) >> 1) & 0xFFF0
|
||||
#define WORLD_OVER(n,o) WAM[(n << 4) + 10] = o
|
||||
|
||||
/***** World Functions *****/
|
||||
// (Obsoleted by the WORLD_* macros...)
|
||||
void vbSetWorld (s16 nw, u16 header, u16 gx, s16 gp, u16 gy, u16 mx, s16 mp, u16 my, u16 width, u16 height);
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user