mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
fix: bad sprite impl
This commit is contained in:
@@ -2,12 +2,13 @@ graphics.setBackground(3,3,3);
|
||||
graphics.resetPalette();
|
||||
|
||||
var _fsh = {};
|
||||
_fsh.titlebarTex = new GL.Tex(2, 14, base64.atob("/u/+/v3+/f39/f39/f39/f39/P39/Pz8/Pv7+w=="));
|
||||
_fsh.titlebarTex = new GL.Texture(2, 14, base64.atob("/u/+/v3+/f39/f39/f39/f39/P39/Pz8/Pv7+w=="));
|
||||
_fsh.scrdim = con.getmaxyx();
|
||||
_fsh.scrwidth = _fsh.scrdim[1];
|
||||
_fsh.scrheight = _fsh.scrdim[0];
|
||||
_fsh.brandName = "f\xb3Sh";
|
||||
_fsh.brandLogoTexSmall = new GL.Tex(24, 14, base64.atob("//////////////////////////////////////////j///////////////////////////////j////////////////////////z8/P///j///+hoaGhof+hof////////Pz//////j//6Gh//////+hof////////Pz//////j//6Gh//////+hoaGhof//8/Pz8/P///j///+hoaH///+hof//oaH///Pz//////j//////6Gh//+hof//oaH///Pz//////j///////+hof+hof//oaH///Pz//////j///////+hof+hof//oaH///Pz//////j//6GhoaGh//+hof//oaH///////////j///////////////////////////////j/////////////////////////////////////////////////////"));
|
||||
_fsh.brandLogoTexSmall = new GL.Texture(24, 14, base64.atob("//////////////////////////////////////////j///////////////////////////////j////////////////////////z8/P///j///+hoaGhof+hof////////Pz//////j//6Gh//////+hof////////Pz//////j//6Gh//////+hoaGhof//8/Pz8/P///j///+hoaH///+hof//oaH///Pz//////j//////6Gh//+hof//oaH///Pz//////j///////+hof+hof//oaH///Pz//////j///////+hof+hof//oaH///Pz//////j//6GhoaGh//+hof//oaH///////////j///////////////////////////////j/////////////////////////////////////////////////////"));
|
||||
_fsh.scrlayout = ["com.fsh.clock","com.fsh.calendar","com.fsh.apps_n_files"];
|
||||
|
||||
_fsh.drawTitlebar = function(titletext) {
|
||||
GL.drawTexPattern(_fsh.titlebarTex, 0, 0, 560, 14);
|
||||
@@ -26,6 +27,8 @@ _fsh.drawTitlebar = function(titletext) {
|
||||
};
|
||||
|
||||
|
||||
_fsh.widget = function()
|
||||
|
||||
// screen init
|
||||
con.color_pair(254, 255);
|
||||
con.clear();
|
||||
|
||||
@@ -6,7 +6,7 @@ Has no affiliation with OpenGL by Khronos Group
|
||||
|
||||
var GL = {};
|
||||
|
||||
GL.Tex = function(w, h, bytes) {
|
||||
GL.Texture = function(w, h, bytes) {
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
this.texData = bytes;
|
||||
@@ -17,41 +17,41 @@ GL.Tex = function(w, h, bytes) {
|
||||
};
|
||||
GL.SpriteSheet = function(tilew, tileh, tex) {
|
||||
this.tileWidth = tilew;
|
||||
this.tileHeight = tile;
|
||||
this.tileHeight = tileh;
|
||||
this.texture = tex;
|
||||
|
||||
if (!tex instanceof GL.Tex) {
|
||||
throw "Texture is not an instance of GL.Tex";
|
||||
if (!tex instanceof GL.Texture) {
|
||||
throw "Texture is not an instance of GL.Texture";
|
||||
}
|
||||
|
||||
this.getOffX = function(x) { // THIS, or: GL.SpriteSheet.prototype.getOffX
|
||||
var tx = tileWidth * x;
|
||||
if (tx + tileWidth > tex.width) throw "Sprite x-offset of "+tx+" is greater than sprite width "+tex.width;
|
||||
var tx = this.tileWidth * x;
|
||||
if (tx + this.tileWidth > this.texture.width) throw "Sprite x-offset of "+tx+" is greater than sprite width "+this.texture.width;
|
||||
return tx;
|
||||
};
|
||||
|
||||
this.getOffY = function(y) {
|
||||
var ty = tileHeight * y;
|
||||
if (ty + tileHeight > tex.height) throw "Sprite y-offset of "+ty+" is greater than sprite height "+tex.height;
|
||||
var ty = this.tileHeight * y;
|
||||
if (ty + this.tileHeight > this.texture.height) throw "Sprite y-offset of "+ty+" is greater than sprite height "+this.texture.height;
|
||||
return ty;
|
||||
};
|
||||
};
|
||||
GL.drawTexPattern = function(tex, x, y, width, height) {
|
||||
GL.drawTexPattern = function(texture, x, y, width, height) {
|
||||
for (var yy = 0; yy < height; yy++) {
|
||||
for (var xx = 0; xx < width; xx++) {
|
||||
var tx = xx % tex.width;
|
||||
var ty = yy % tex.height;
|
||||
var c = tex.texData[ty * tex.width + tx];
|
||||
var tx = xx % texture.width;
|
||||
var ty = yy % texture.height;
|
||||
var c = texture.texData[ty * texture.width + tx];
|
||||
graphics.plotPixel(x + xx, y + yy, c);
|
||||
}
|
||||
}
|
||||
};
|
||||
GL.drawTexPatternOver = function(tex, x, y, width, height) {
|
||||
GL.drawTexPatternOver = function(texture, x, y, width, height) {
|
||||
for (var yy = 0; yy < height; yy++) {
|
||||
for (var xx = 0; xx < width; xx++) {
|
||||
var tx = xx % tex.width;
|
||||
var ty = yy % tex.height;
|
||||
var c = tex.texData[ty * tex.width + tx];
|
||||
var tx = xx % texture.width;
|
||||
var ty = yy % texture.height;
|
||||
var c = texture.texData[ty * texture.width + tx];
|
||||
if (c != 255) {
|
||||
graphics.plotPixel(x + xx, y + yy, c);
|
||||
}
|
||||
@@ -61,16 +61,16 @@ GL.drawTexPatternOver = function(tex, x, y, width, height) {
|
||||
/*
|
||||
* Draws a texture verbatim - color of 255 will be written to the screen buffer
|
||||
*/
|
||||
GL.drawTexImage = function(tex, x, y) {
|
||||
GL.drawTexPattern(tex, x, y, tex.width, tex.height);
|
||||
GL.drawTexImage = function(texture, x, y) {
|
||||
GL.drawTexPattern(texture, x, y, texture.width, texture.height);
|
||||
};
|
||||
/*
|
||||
* Draws texture with blitting - color of 255 will pass-thru what's already on the screen buffer
|
||||
*/
|
||||
GL.drawTexImageOver = function(tex, x, y) {
|
||||
for (var ty = 0; ty < tex.height; ty++) {
|
||||
for (var tx = 0; tx < tex.width; tx++) {
|
||||
var c = tex.texData[ty * tex.width + tx];
|
||||
GL.drawTexImageOver = function(texture, x, y) {
|
||||
for (var ty = 0; ty < texture.height; ty++) {
|
||||
for (var tx = 0; tx < texture.width; tx++) {
|
||||
var c = texture.texData[ty * texture.width + tx];
|
||||
if (c != 255) {
|
||||
graphics.plotPixel(x + tx, y + ty, c);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ GL.drawSprite = function(sheet, xi, yi, x, y) {
|
||||
var offy = sheet.getOffY(yi);
|
||||
for (var ty = 0; ty < sheet.tileHeight; ty++) {
|
||||
for (var tx = 0; tx < sheet.tileWidth; tx++) {
|
||||
var c = sheet.tex.texData[(ty + offy) * tex.width + (tx + offx)];
|
||||
var c = sheet.texture.texData[(ty + offy) * sheet.texture.width + (tx + offx)];
|
||||
graphics.plotPixel(x + tx, y + ty, c);
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ GL.drawSpriteOver = function(sheet, xi, yi, x, y) {
|
||||
var offy = sheet.getOffY(yi);
|
||||
for (var ty = 0; ty < sheet.tileHeight; ty++) {
|
||||
for (var tx = 0; tx < sheet.tileWidth; tx++) {
|
||||
var c = sheet.tex.texData[(ty + offy) * tex.width + (tx + offx)];
|
||||
var c = sheet.texture.texData[(ty + offy) * sheet.texture.width + (tx + offx)];
|
||||
if (c != 255) {
|
||||
graphics.plotPixel(x + tx, y + ty, c);
|
||||
}
|
||||
|
||||
@@ -729,7 +729,7 @@ class GraphicsAdapter(val vm: VM, val lcdMode: Boolean = false, lcdInvert: Boole
|
||||
private val LCD_BASE_COL = Color(0xa1a99cff.toInt())
|
||||
|
||||
val DRAW_SHADER_FRAG = """
|
||||
#version 120
|
||||
#version 130
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
@@ -746,7 +746,7 @@ void main(void) {
|
||||
""".trimIndent()
|
||||
|
||||
val DRAW_SHADER_FRAG_LCD = """
|
||||
#version 120
|
||||
#version 130
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
@@ -767,7 +767,7 @@ void main(void) {
|
||||
""".trimIndent()
|
||||
|
||||
val DRAW_SHADER_FRAG_LCD_NOINV = """
|
||||
#version 120
|
||||
#version 130
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
@@ -788,7 +788,7 @@ void main(void) {
|
||||
""".trimIndent()
|
||||
|
||||
val DRAW_SHADER_VERT = """
|
||||
#version 120
|
||||
#version 130
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec4 a_color;
|
||||
@@ -807,7 +807,7 @@ void main() {
|
||||
""".trimIndent()
|
||||
|
||||
val TEXT_TILING_SHADER = """
|
||||
#version 120
|
||||
#version 130
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
@@ -894,7 +894,7 @@ void main() {
|
||||
""".trimIndent()
|
||||
|
||||
val TEXT_TILING_SHADER_LCD = """
|
||||
#version 120
|
||||
#version 130
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
@@ -991,7 +991,7 @@ void main() {
|
||||
""".trimIndent()
|
||||
|
||||
val TEXT_TILING_SHADER_LCD_NOINV = """
|
||||
#version 120
|
||||
#version 130
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user