mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 03:25:14 -04:00
DS: Increase camera sensitivity, fix window not being restored properly after quitting game, fix keyboard not hiding debug console, allocate another 128 kb vram bank for textures
This commit is contained in:
parent
02082d71fb
commit
2326020f89
@ -15,8 +15,6 @@ void Gfx_Create(void) {
|
||||
Gfx.MaxTexWidth = 256;
|
||||
Gfx.MaxTexHeight = 256;
|
||||
Gfx.Created = true;
|
||||
|
||||
videoSetMode(MODE_0_3D);
|
||||
glInit();
|
||||
|
||||
glClearColor(0, 15, 10, 31);
|
||||
@ -24,13 +22,12 @@ void Gfx_Create(void) {
|
||||
glAlphaFunc(7);
|
||||
|
||||
glClearDepth(0x7FFF);
|
||||
|
||||
glViewport(0, 0, 255, 191);
|
||||
|
||||
vramSetBankA(VRAM_A_TEXTURE);
|
||||
vramSetBankB(VRAM_B_TEXTURE);
|
||||
vramSetBankB(VRAM_C_TEXTURE);
|
||||
vramSetBankD(VRAM_D_TEXTURE);
|
||||
// setup memory for textures
|
||||
|
||||
glPolyFmt(POLY_ALPHA(31) | POLY_CULL_NONE);
|
||||
}
|
||||
@ -41,8 +38,9 @@ cc_bool Gfx_TryRestoreContext(void) {
|
||||
|
||||
void Gfx_Free(void) {
|
||||
Gfx_FreeState();
|
||||
vramSetBankA(VRAM_A_MAIN_BG);
|
||||
vramSetBankA(VRAM_A_LCD);
|
||||
vramSetBankB(VRAM_B_LCD);
|
||||
vramSetBankD(VRAM_C_LCD);
|
||||
vramSetBankD(VRAM_D_LCD);
|
||||
}
|
||||
|
||||
@ -239,7 +237,7 @@ static void* gfx_vertices;
|
||||
struct DSTexturedVertex {
|
||||
short x, y, z;
|
||||
cc_uint8 r, g, b;
|
||||
float u, v;
|
||||
int u, v;
|
||||
};
|
||||
struct DSColouredVertex {
|
||||
short x, y, z;
|
||||
@ -256,8 +254,8 @@ static void PreprocessTexturedVertices(void) {
|
||||
dst->x = floattov16(v.x / 32.0f);
|
||||
dst->y = floattov16(v.y / 32.0f);
|
||||
dst->z = floattov16(v.z / 32.0f);
|
||||
dst->u = v.U;
|
||||
dst->v = v.V;
|
||||
dst->u = floattof32(v.U);
|
||||
dst->v = floattof32(v.V);
|
||||
dst->r = PackedCol_R(v.Col);
|
||||
dst->g = PackedCol_G(v.Col);
|
||||
dst->b = PackedCol_B(v.Col);
|
||||
@ -446,8 +444,8 @@ static void Draw_ColouredTriangles(int verticesCount, int startVertex) {
|
||||
static void Draw_TexturedTriangles(int verticesCount, int startVertex) {
|
||||
glBegin(GL_QUADS);
|
||||
int width = 0, height = 0;
|
||||
glGetInt(GL_GET_TEXTURE_WIDTH, &width);
|
||||
glGetInt(GL_GET_TEXTURE_HEIGHT, &height);
|
||||
glGetInt(GL_GET_TEXTURE_WIDTH, &width); width = inttof32(width);
|
||||
glGetInt(GL_GET_TEXTURE_HEIGHT, &height); height = inttof32(height);
|
||||
|
||||
|
||||
for (int i = 0; i < verticesCount; i++)
|
||||
@ -455,7 +453,7 @@ static void Draw_TexturedTriangles(int verticesCount, int startVertex) {
|
||||
struct DSTexturedVertex* v = (struct DSTexturedVertex*)gfx_vertices + startVertex + i;
|
||||
|
||||
glColor3b(v->r, v->g, v->b);
|
||||
glTexCoord2t16(floattot16(v->u * width), floattot16(v->v * height));
|
||||
glTexCoord2t16(f32tot16(mulf32(v->u, width)), f32tot16(mulf32(v->v, height)));
|
||||
glVertex3v16(v->x, v->y, v->z);
|
||||
}
|
||||
glEnd();
|
||||
|
@ -10,10 +10,12 @@
|
||||
#include "Bitmap.h"
|
||||
#include "Errors.h"
|
||||
#include "ExtMath.h"
|
||||
#include "Camera.h"
|
||||
#include <nds/arm9/background.h>
|
||||
#include <nds/arm9/input.h>
|
||||
#include <nds/arm9/console.h>
|
||||
#include <nds/arm9/keyboard.h>
|
||||
#include <nds/interrupts.h>
|
||||
|
||||
static cc_bool launcherMode, keyboardOpen;
|
||||
static int bg_id;
|
||||
@ -22,6 +24,14 @@ static u16* bg_ptr;
|
||||
struct _DisplayData DisplayInfo;
|
||||
struct _WindowData WindowInfo;
|
||||
|
||||
static void InitConsoleWindow(void) {
|
||||
videoSetModeSub(MODE_0_2D);
|
||||
vramSetBankH(VRAM_H_SUB_BG);
|
||||
setBrightness(2, 0);
|
||||
|
||||
consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 22, 3, false, true);
|
||||
}
|
||||
|
||||
void Window_Init(void) {
|
||||
DisplayInfo.Width = SCREEN_WIDTH;
|
||||
DisplayInfo.Height = SCREEN_HEIGHT;
|
||||
@ -36,8 +46,13 @@ void Window_Init(void) {
|
||||
|
||||
Input_SetTouchMode(true);
|
||||
Input.Sources = INPUT_SOURCE_GAMEPAD;
|
||||
|
||||
consoleDemoInit();
|
||||
InitConsoleWindow();
|
||||
}
|
||||
|
||||
void Window_Free(void) { }
|
||||
|
||||
void Window_Create2D(int width, int height) {
|
||||
launcherMode = true;
|
||||
videoSetMode(MODE_5_2D);
|
||||
vramSetBankA(VRAM_A_MAIN_BG);
|
||||
|
||||
@ -45,10 +60,10 @@ void Window_Init(void) {
|
||||
bg_ptr = bgGetGfxPtr(bg_id);
|
||||
}
|
||||
|
||||
void Window_Free(void) { }
|
||||
|
||||
void Window_Create2D(int width, int height) { launcherMode = true; }
|
||||
void Window_Create3D(int width, int height) { launcherMode = false; }
|
||||
void Window_Create3D(int width, int height) {
|
||||
launcherMode = false;
|
||||
videoSetMode(MODE_0_3D);
|
||||
}
|
||||
|
||||
void Window_SetTitle(const cc_string* title) { }
|
||||
void Clipboard_GetText(cc_string* value) { }
|
||||
@ -93,6 +108,7 @@ static void ProcessTouchInput(int mods) {
|
||||
static int curX, curY; // current touch position
|
||||
touchPosition touch;
|
||||
touchRead(&touch);
|
||||
Camera.Sensitivity = 100; // TODO not hardcode this
|
||||
|
||||
if (keysDown() & KEY_TOUCH) { // stylus went down
|
||||
curX = touch.px;
|
||||
@ -178,7 +194,11 @@ static void OnKeyPressed(int key) {
|
||||
}
|
||||
|
||||
void Window_OpenKeyboard(struct OpenKeyboardArgs* args) {
|
||||
Keyboard* kbd = keyboardDemoInit();
|
||||
Keyboard* kbd = keyboardGetDefault();
|
||||
keyboardInit(kbd, 3, BgType_Text4bpp, BgSize_T_256x512,
|
||||
20, 0, false, true);
|
||||
videoBgDisableSub(0); // hide console
|
||||
|
||||
kbd->OnKeyPressed = OnKeyPressed;
|
||||
keyboardShow();
|
||||
|
||||
@ -191,6 +211,7 @@ void Window_SetKeyboardText(const cc_string* text) { }
|
||||
void Window_CloseKeyboard(void) {
|
||||
keyboardHide();
|
||||
keyboardOpen = false;
|
||||
videoBgEnableSub(0); // show console
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user