1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-05-03 01:10:13 +00:00

Run clang-format on ./internal/c/*cpp files

This commit is contained in:
Matthew Kilgore 2022-05-06 00:00:36 -04:00 committed by Matt Kilgore
parent a822756306
commit 1aa8d7a42f
24 changed files with 40722 additions and 31187 deletions

166
.clang-format Normal file
View file

@ -0,0 +1,166 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 160
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
StatementAttributeLikeMacros:
- Q_EMIT
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: AfterHash
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PointerAlignment: Right
ReflowComments: true
SortIncludes: true
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Latest
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,289 +1,292 @@
//Common
int32 requestedKeyboardOverlayImage=0;
// Common
int32 requestedKeyboardOverlayImage = 0;
#ifndef QB64_GUI //begin stubs
//STUB: simulate generating a hardware surface
int32 new_hardware_img(int32 x, int32 y, uint32 *pixels, int32 flags){
//create hardware img
int32 handle;
hardware_img_struct* hardware_img;
handle=list_add(hardware_img_handles);
hardware_img=(hardware_img_struct*)list_get(hardware_img_handles,handle);
hardware_img->w=x;
hardware_img->h=y;
hardware_img->dest_context_handle=0;
hardware_img->depthbuffer_handle=0;
hardware_img->pending_commands=0;
hardware_img->remove=0;
hardware_img->alpha_disabled=0;
hardware_img->depthbuffer_mode=DEPTHBUFFER_MODE__ON;
hardware_img->valid=1;
hardware_img->source_state.PO2_fix=PO2_FIX__OFF;
hardware_img->source_state.texture_wrap=TEXTURE_WRAP_MODE__UNKNOWN;
hardware_img->source_state.smooth_stretched=SMOOTH_MODE__UNKNOWN;
hardware_img->source_state.smooth_shrunk=SMOOTH_MODE__UNKNOWN;
if (flags&NEW_HARDWARE_IMG__BUFFER_CONTENT){
hardware_img->texture_handle=0;
if (flags&NEW_HARDWARE_IMG__DUPLICATE_PROVIDED_BUFFER){
hardware_img->software_pixel_buffer=NULL;
}else{
free(pixels);//the buffer was meant to be consumed, so we just free it immediately
hardware_img->software_pixel_buffer=NULL;
}
#ifndef QB64_GUI // begin stubs
// STUB: simulate generating a hardware surface
int32 new_hardware_img(int32 x, int32 y, uint32 *pixels, int32 flags) {
// create hardware img
int32 handle;
hardware_img_struct *hardware_img;
handle = list_add(hardware_img_handles);
hardware_img =
(hardware_img_struct *)list_get(hardware_img_handles, handle);
hardware_img->w = x;
hardware_img->h = y;
hardware_img->dest_context_handle = 0;
hardware_img->depthbuffer_handle = 0;
hardware_img->pending_commands = 0;
hardware_img->remove = 0;
hardware_img->alpha_disabled = 0;
hardware_img->depthbuffer_mode = DEPTHBUFFER_MODE__ON;
hardware_img->valid = 1;
hardware_img->source_state.PO2_fix = PO2_FIX__OFF;
hardware_img->source_state.texture_wrap = TEXTURE_WRAP_MODE__UNKNOWN;
hardware_img->source_state.smooth_stretched = SMOOTH_MODE__UNKNOWN;
hardware_img->source_state.smooth_shrunk = SMOOTH_MODE__UNKNOWN;
if (flags & NEW_HARDWARE_IMG__BUFFER_CONTENT) {
hardware_img->texture_handle = 0;
if (flags & NEW_HARDWARE_IMG__DUPLICATE_PROVIDED_BUFFER) {
hardware_img->software_pixel_buffer = NULL;
} else {
free(pixels); // the buffer was meant to be consumed, so we just
// free it immediately
hardware_img->software_pixel_buffer = NULL;
}
return handle;
}
#else //end stubs
int32 force_NPO2_fix=0;//This should only be set to 1 for debugging QB64
uint32 *NPO2_buffer=(uint32*)malloc(4);
int32 NPO2_buffer_size_in_pixels=1;
uint32 *NPO2_texture_generate(int32 *px, int32 *py, uint32 *pixels){
int32 ox=*px;
int32 oy=*py;
int32 nx=1;
int32 ny=1;
//assume not negative & not 0
while ((ox&1)==0){
ox>>=1;
nx<<=1;
}
if (ox!=1){//x is not a power of 2
while (ox!=0){
ox>>=1;
nx<<=1;
}
nx<<1;
}
while ((oy&1)==0){
oy>>=1;
ny<<=1;
}
if (oy!=1){//y is not a power of 2
while (oy!=0){
oy>>=1;
ny<<=1;
}
ny<<1;
}
//reset original values
ox=*px;
oy=*py;
if (nx==ox&&ny==oy){ //no action required
return pixels;
}
int32 size_in_pixels=nx*ny;
if (size_in_pixels>NPO2_buffer_size_in_pixels){
NPO2_buffer=(uint32*)realloc(NPO2_buffer,size_in_pixels*4);
NPO2_buffer_size_in_pixels=size_in_pixels;
}
//copy source NPO2 rectangle into destination PO2 rectangle
if (nx==ox){ //can copy as a single block
memcpy(NPO2_buffer,pixels,ox*oy*4);
}else{
uint32 *dst_pixel_offset=NPO2_buffer;
uint32 *src_pixel_offset=pixels;
while (oy--){
memcpy(dst_pixel_offset,src_pixel_offset,ox*4);
dst_pixel_offset+=nx;
src_pixel_offset+=ox;
}
oy=*py;
}
//tidy edges - extend the right-most column and bottom-most row to avoid pixel/color bleeding
//rhs column
if (ox!=nx){
for (int y=0;y<oy;y++){
NPO2_buffer[ox+nx*y]=NPO2_buffer[ox+nx*y-1];
}
}
//bottom row + 1 pixel for corner
if (oy!=ny){
for (int x=0;x<(ox+1);x++){
NPO2_buffer[nx*oy+x]=NPO2_buffer[nx*oy+x-nx];
}
}
//int maxtexsize;
//glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxtexsize);
//alert(maxtexsize);
//alert(nx);
//alert(ny);
*px=nx;
*py=ny;
return NPO2_buffer;
return handle;
}
#else // end stubs
int32 force_NPO2_fix = 0; // This should only be set to 1 for debugging QB64
uint32 *NPO2_buffer = (uint32 *)malloc(4);
int32 NPO2_buffer_size_in_pixels = 1;
uint32 *NPO2_texture_generate(int32 *px, int32 *py, uint32 *pixels) {
int32 ox = *px;
int32 oy = *py;
int32 nx = 1;
int32 ny = 1;
// assume not negative & not 0
while ((ox & 1) == 0) {
ox >>= 1;
nx <<= 1;
}
int32 new_texture_handle(){
GLuint texture=0;
glGenTextures(1,&texture);
return (int32)texture;
if (ox != 1) { // x is not a power of 2
while (ox != 0) {
ox >>= 1;
nx <<= 1;
}
nx << 1;
}
int32 new_hardware_img(int32 x, int32 y, uint32 *pixels, int32 flags){
//note: non power-of-2 dimensioned textures are supported on modern 3D cards and
// even on some older cards, as long as mip-mapping is not being used
// therefore, no attempt is made to convert the non-power-of-2 SCREEN sizes via software
// to avoid the performance hit this would incur
//create hardware img
int32 handle;
hardware_img_struct* hardware_img;
handle=list_add(hardware_img_handles);
hardware_img=(hardware_img_struct*)list_get(hardware_img_handles,handle);
hardware_img->w=x;
hardware_img->h=y;
hardware_img->dest_context_handle=0;
hardware_img->depthbuffer_handle=0;
hardware_img->pending_commands=0;
hardware_img->remove=0;
hardware_img->alpha_disabled=0;
hardware_img->depthbuffer_mode=DEPTHBUFFER_MODE__ON;
hardware_img->valid=1;
hardware_img->source_state.PO2_fix=PO2_FIX__OFF;
hardware_img->source_state.texture_wrap=TEXTURE_WRAP_MODE__UNKNOWN;
hardware_img->source_state.smooth_stretched=SMOOTH_MODE__UNKNOWN;
hardware_img->source_state.smooth_shrunk=SMOOTH_MODE__UNKNOWN;
if (flags&NEW_HARDWARE_IMG__BUFFER_CONTENT){
hardware_img->texture_handle=0;
if (flags&NEW_HARDWARE_IMG__DUPLICATE_PROVIDED_BUFFER){
hardware_img->software_pixel_buffer=(uint32*)malloc(x*y*4);
memcpy(hardware_img->software_pixel_buffer,pixels,x*y*4);
}else{
hardware_img->software_pixel_buffer=pixels;
}
}else{
hardware_img->software_pixel_buffer=NULL;
hardware_img->texture_handle=new_texture_handle();
glBindTexture (GL_TEXTURE_2D, hardware_img->texture_handle);
//non-power of 2 dimensions fallback support
static int glerrorcode;
glerrorcode=glGetError();//clear any previous errors
if (force_NPO2_fix==0) glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_BGRA, GL_UNSIGNED_BYTE, pixels);
glerrorcode=glGetError();
if (glerrorcode!=0||force_NPO2_fix==1){
int32 nx=x,ny=y;
uint32 *npixels=NPO2_texture_generate(&nx,&ny,pixels);
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, nx, ny, 0, GL_BGRA, GL_UNSIGNED_BYTE,npixels);
hardware_img->source_state.PO2_fix=PO2_FIX__EXPANDED;
hardware_img->PO2_w=nx;
hardware_img->PO2_h=ny;
glerrorcode=glGetError();
if (glerrorcode){
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, x, y, GL_BGRA, GL_UNSIGNED_BYTE, pixels );
glerrorcode=glGetError();
if (glerrorcode){
alert("gluBuild2DMipmaps failed");
alert(glerrorcode);
}
hardware_img->source_state.PO2_fix=PO2_FIX__MIPMAPPED;
hardware_img->PO2_w=x;
hardware_img->PO2_h=y;
while ((oy & 1) == 0) {
oy >>= 1;
ny <<= 1;
}
if (oy != 1) { // y is not a power of 2
while (oy != 0) {
oy >>= 1;
ny <<= 1;
}
ny << 1;
}
// reset original values
ox = *px;
oy = *py;
if (nx == ox && ny == oy) { // no action required
return pixels;
}
int32 size_in_pixels = nx * ny;
if (size_in_pixels > NPO2_buffer_size_in_pixels) {
NPO2_buffer = (uint32 *)realloc(NPO2_buffer, size_in_pixels * 4);
NPO2_buffer_size_in_pixels = size_in_pixels;
}
// copy source NPO2 rectangle into destination PO2 rectangle
if (nx == ox) { // can copy as a single block
memcpy(NPO2_buffer, pixels, ox * oy * 4);
} else {
uint32 *dst_pixel_offset = NPO2_buffer;
uint32 *src_pixel_offset = pixels;
while (oy--) {
memcpy(dst_pixel_offset, src_pixel_offset, ox * 4);
dst_pixel_offset += nx;
src_pixel_offset += ox;
}
oy = *py;
}
// tidy edges - extend the right-most column and bottom-most row to avoid
// pixel/color bleeding rhs column
if (ox != nx) {
for (int y = 0; y < oy; y++) {
NPO2_buffer[ox + nx * y] = NPO2_buffer[ox + nx * y - 1];
}
}
// bottom row + 1 pixel for corner
if (oy != ny) {
for (int x = 0; x < (ox + 1); x++) {
NPO2_buffer[nx * oy + x] = NPO2_buffer[nx * oy + x - nx];
}
}
// int maxtexsize;
// glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxtexsize);
// alert(maxtexsize);
// alert(nx);
// alert(ny);
*px = nx;
*py = ny;
return NPO2_buffer;
}
int32 new_texture_handle() {
GLuint texture = 0;
glGenTextures(1, &texture);
return (int32)texture;
}
int32 new_hardware_img(int32 x, int32 y, uint32 *pixels, int32 flags) {
// note: non power-of-2 dimensioned textures are supported on modern 3D
// cards and
// even on some older cards, as long as mip-mapping is not being used
// therefore, no attempt is made to convert the non-power-of-2 SCREEN
// sizes via software to avoid the performance hit this would incur
// create hardware img
int32 handle;
hardware_img_struct *hardware_img;
handle = list_add(hardware_img_handles);
hardware_img =
(hardware_img_struct *)list_get(hardware_img_handles, handle);
hardware_img->w = x;
hardware_img->h = y;
hardware_img->dest_context_handle = 0;
hardware_img->depthbuffer_handle = 0;
hardware_img->pending_commands = 0;
hardware_img->remove = 0;
hardware_img->alpha_disabled = 0;
hardware_img->depthbuffer_mode = DEPTHBUFFER_MODE__ON;
hardware_img->valid = 1;
hardware_img->source_state.PO2_fix = PO2_FIX__OFF;
hardware_img->source_state.texture_wrap = TEXTURE_WRAP_MODE__UNKNOWN;
hardware_img->source_state.smooth_stretched = SMOOTH_MODE__UNKNOWN;
hardware_img->source_state.smooth_shrunk = SMOOTH_MODE__UNKNOWN;
if (flags & NEW_HARDWARE_IMG__BUFFER_CONTENT) {
hardware_img->texture_handle = 0;
if (flags & NEW_HARDWARE_IMG__DUPLICATE_PROVIDED_BUFFER) {
hardware_img->software_pixel_buffer = (uint32 *)malloc(x * y * 4);
memcpy(hardware_img->software_pixel_buffer, pixels, x * y * 4);
} else {
hardware_img->software_pixel_buffer = pixels;
}
} else {
hardware_img->software_pixel_buffer = NULL;
hardware_img->texture_handle = new_texture_handle();
glBindTexture(GL_TEXTURE_2D, hardware_img->texture_handle);
// non-power of 2 dimensions fallback support
static int glerrorcode;
glerrorcode = glGetError(); // clear any previous errors
if (force_NPO2_fix == 0)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_BGRA,
GL_UNSIGNED_BYTE, pixels);
glerrorcode = glGetError();
if (glerrorcode != 0 || force_NPO2_fix == 1) {
int32 nx = x, ny = y;
uint32 *npixels = NPO2_texture_generate(&nx, &ny, pixels);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, nx, ny, 0, GL_BGRA,
GL_UNSIGNED_BYTE, npixels);
hardware_img->source_state.PO2_fix = PO2_FIX__EXPANDED;
hardware_img->PO2_w = nx;
hardware_img->PO2_h = ny;
glerrorcode = glGetError();
if (glerrorcode) {
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, x, y, GL_BGRA,
GL_UNSIGNED_BYTE, pixels);
glerrorcode = glGetError();
if (glerrorcode) {
alert("gluBuild2DMipmaps failed");
alert(glerrorcode);
}
hardware_img->source_state.PO2_fix = PO2_FIX__MIPMAPPED;
hardware_img->PO2_w = x;
hardware_img->PO2_h = y;
}
set_render_source(INVALID_HARDWARE_HANDLE);
}
return handle;
set_render_source(INVALID_HARDWARE_HANDLE);
}
void hardware_img_buffer_to_texture(int32 handle){
static hardware_img_struct* hardware_img;
hardware_img=(hardware_img_struct*)list_get(hardware_img_handles,handle);
if (hardware_img->texture_handle==0){
hardware_img->texture_handle=new_texture_handle();
glBindTexture (GL_TEXTURE_2D, hardware_img->texture_handle);
//non-power of 2 dimensions fallback support
static int glerrorcode;
glerrorcode=glGetError();//clear any previous errors
if (force_NPO2_fix==0) glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, hardware_img->w, hardware_img->h, 0, GL_BGRA, GL_UNSIGNED_BYTE, hardware_img->software_pixel_buffer);
glerrorcode=glGetError();
if (glerrorcode!=0||force_NPO2_fix==1){
hardware_img->source_state.PO2_fix=PO2_FIX__EXPANDED;
int32 x=hardware_img->w;
int32 y=hardware_img->h;
uint32 *pixels=NPO2_texture_generate(&x,&y,hardware_img->software_pixel_buffer);
hardware_img->PO2_w=x;
hardware_img->PO2_h=y;
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_BGRA, GL_UNSIGNED_BYTE,pixels);
glerrorcode=glGetError();
if (glerrorcode){
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, hardware_img->w, hardware_img->h, GL_BGRA, GL_UNSIGNED_BYTE, hardware_img->software_pixel_buffer);
glerrorcode=glGetError();
if (glerrorcode){
alert("gluBuild2DMipmaps failed");
alert(glerrorcode);
}
hardware_img->source_state.PO2_fix=PO2_FIX__MIPMAPPED;
hardware_img->PO2_w=hardware_img->w;
hardware_img->PO2_h=hardware_img->h;
return handle;
}
void hardware_img_buffer_to_texture(int32 handle) {
static hardware_img_struct *hardware_img;
hardware_img =
(hardware_img_struct *)list_get(hardware_img_handles, handle);
if (hardware_img->texture_handle == 0) {
hardware_img->texture_handle = new_texture_handle();
glBindTexture(GL_TEXTURE_2D, hardware_img->texture_handle);
// non-power of 2 dimensions fallback support
static int glerrorcode;
glerrorcode = glGetError(); // clear any previous errors
if (force_NPO2_fix == 0)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, hardware_img->w,
hardware_img->h, 0, GL_BGRA, GL_UNSIGNED_BYTE,
hardware_img->software_pixel_buffer);
glerrorcode = glGetError();
if (glerrorcode != 0 || force_NPO2_fix == 1) {
hardware_img->source_state.PO2_fix = PO2_FIX__EXPANDED;
int32 x = hardware_img->w;
int32 y = hardware_img->h;
uint32 *pixels = NPO2_texture_generate(
&x, &y, hardware_img->software_pixel_buffer);
hardware_img->PO2_w = x;
hardware_img->PO2_h = y;
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, x, y, 0, GL_BGRA,
GL_UNSIGNED_BYTE, pixels);
glerrorcode = glGetError();
if (glerrorcode) {
gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, hardware_img->w,
hardware_img->h, GL_BGRA, GL_UNSIGNED_BYTE,
hardware_img->software_pixel_buffer);
glerrorcode = glGetError();
if (glerrorcode) {
alert("gluBuild2DMipmaps failed");
alert(glerrorcode);
}
hardware_img->source_state.PO2_fix = PO2_FIX__MIPMAPPED;
hardware_img->PO2_w = hardware_img->w;
hardware_img->PO2_h = hardware_img->h;
}
free(hardware_img->software_pixel_buffer);
hardware_img->software_pixel_buffer=NULL;//2015 critical bug fix
set_render_source(INVALID_HARDWARE_HANDLE);
}
free(hardware_img->software_pixel_buffer);
hardware_img->software_pixel_buffer = NULL; // 2015 critical bug fix
set_render_source(INVALID_HARDWARE_HANDLE);
}
void hardware_img_requires_depthbuffer(hardware_img_struct* hardware_img){
if (hardware_img->depthbuffer_handle==0){
//inspiration... http://www.opengl.org/wiki/Framebuffer_Object_Examples#Color_texture.2C_Depth_texture
static GLuint depth_tex;
#ifndef QB64_GLES
glGenTextures(1, &depth_tex);
glBindTexture(GL_TEXTURE_2D, depth_tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, hardware_img->w, hardware_img->h, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depth_tex, 0/*mipmap level*/);
#else
glGenRenderbuffers(1, &depth_tex);
glBindRenderbuffer(GL_RENDERBUFFER, depth_tex);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, hardware_img->w, hardware_img->h);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_tex);
#endif
//NULL means reserve texture memory, but texels are undefined
glClear(GL_DEPTH_BUFFER_BIT);
hardware_img->depthbuffer_handle=depth_tex;
set_render_source(INVALID_HARDWARE_HANDLE);
}
}
}
void hardware_img_requires_depthbuffer(hardware_img_struct *hardware_img) {
if (hardware_img->depthbuffer_handle == 0) {
// inspiration...
// http://www.opengl.org/wiki/Framebuffer_Object_Examples#Color_texture.2C_Depth_texture
static GLuint depth_tex;
#ifndef QB64_GLES
glGenTextures(1, &depth_tex);
glBindTexture(GL_TEXTURE_2D, depth_tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE,
GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, hardware_img->w,
hardware_img->h, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE,
NULL);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_TEXTURE_2D, depth_tex, 0 /*mipmap level*/);
#else
glGenRenderbuffers(1, &depth_tex);
glBindRenderbuffer(GL_RENDERBUFFER, depth_tex);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16,
hardware_img->w, hardware_img->h);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
GL_RENDERBUFFER, depth_tex);
#endif
// NULL means reserve texture memory, but texels are undefined
glClear(GL_DEPTH_BUFFER_BIT);
hardware_img->depthbuffer_handle = depth_tex;
set_render_source(INVALID_HARDWARE_HANDLE);
}
}
#endif

View file

@ -1,80 +1,107 @@
#ifndef DEPENDENCY_PRINTER
//stubs
void sub__printimage(int32 i){
return;
// stubs
void sub__printimage(int32 i) { return; }
#else
void sub__printimage(int32 i) {
#ifdef QB64_WINDOWS
static LPSTR szPrinterName = NULL;
DWORD dwNameLen;
HDC dc;
DOCINFO di;
uint32 w, h;
int32 x, y;
int32 i2;
BITMAPFILEHEADER bmfHeader;
BITMAPINFOHEADER bi;
img_struct *s, *s2;
if (i >= 0) {
validatepage(i);
s = &img[page[i]];
} else {
x = -i;
if (x >= nextimg) {
error(258);
return;
}
s = &img[x];
if (!s->valid) {
error(258);
return;
}
}
#else
void sub__printimage(int32 i){
#ifdef QB64_WINDOWS
static LPSTR szPrinterName=NULL;
DWORD dwNameLen;
HDC dc;
DOCINFO di;
uint32 w,h;
int32 x,y;
int32 i2;
BITMAPFILEHEADER bmfHeader;
BITMAPINFOHEADER bi;
img_struct *s,*s2;
if (i>=0){
validatepage(i); s=&img[page[i]];
}else{
x=-i;
if (x>=nextimg){error(258); return;}
s=&img[x];
if (!s->valid){error(258); return;}
}
if (!szPrinterName) szPrinterName=(LPSTR)malloc(65536);
dwNameLen=65536;
GetDefaultPrinter(szPrinterName,&dwNameLen);
if((dc=CreateDC(TEXT("WINSPOOL"),szPrinterName,NULL,NULL))==NULL) goto failed;
ZeroMemory(&di,sizeof(DOCINFO));
di.cbSize=sizeof(DOCINFO);
di.lpszDocName=TEXT("Document");
if(StartDoc(dc,&di)<=0){DeleteDC(dc); goto failed;}
if(StartPage(dc)<=0){EndDoc(dc); DeleteDC(dc); goto failed;}
w=GetDeviceCaps(dc,HORZRES);
h=GetDeviceCaps(dc,VERTRES);
i2=func__newimage(w,h,32,1);
if (i2==-1){EndDoc(dc); DeleteDC(dc); goto failed;}
s2=&img[-i2];
sub__dontblend(i2,1);
sub__putimage(NULL,NULL,NULL,NULL,i,i2,NULL,NULL,NULL,NULL,8+32);
ZeroMemory(&bi,sizeof(BITMAPINFOHEADER));
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biWidth = w;
bi.biHeight = h;
bi.biPlanes = 1;
bi.biBitCount = 32;
bi.biCompression = BI_RGB;
bi.biSizeImage = 0;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
for (y=0;y<h;y++){
SetDIBitsToDevice(dc,0,y,w,1,0,0,0,1,s2->offset32+(y*w),(BITMAPINFO*)&bi, DIB_RGB_COLORS);
}
sub__freeimage(i2,1);
if(EndPage(dc)<=0){EndDoc(dc); DeleteDC(dc); goto failed;}
if(EndDoc(dc)<=0){DeleteDC(dc); goto failed;}
DeleteDC(dc);
failed:;
#endif
if (!szPrinterName)
szPrinterName = (LPSTR)malloc(65536);
dwNameLen = 65536;
GetDefaultPrinter(szPrinterName, &dwNameLen);
if ((dc = CreateDC(TEXT("WINSPOOL"), szPrinterName, NULL, NULL)) == NULL)
goto failed;
ZeroMemory(&di, sizeof(DOCINFO));
di.cbSize = sizeof(DOCINFO);
di.lpszDocName = TEXT("Document");
if (StartDoc(dc, &di) <= 0) {
DeleteDC(dc);
goto failed;
}
if (StartPage(dc) <= 0) {
EndDoc(dc);
DeleteDC(dc);
goto failed;
}
w = GetDeviceCaps(dc, HORZRES);
h = GetDeviceCaps(dc, VERTRES);
i2 = func__newimage(w, h, 32, 1);
if (i2 == -1) {
EndDoc(dc);
DeleteDC(dc);
goto failed;
}
s2 = &img[-i2];
sub__dontblend(i2, 1);
sub__putimage(NULL, NULL, NULL, NULL, i, i2, NULL, NULL, NULL, NULL,
8 + 32);
ZeroMemory(&bi, sizeof(BITMAPINFOHEADER));
bi.biSize = sizeof(BITMAPINFOHEADER);
bi.biWidth = w;
bi.biHeight = h;
bi.biPlanes = 1;
bi.biBitCount = 32;
bi.biCompression = BI_RGB;
bi.biSizeImage = 0;
bi.biXPelsPerMeter = 0;
bi.biYPelsPerMeter = 0;
bi.biClrUsed = 0;
bi.biClrImportant = 0;
for (y = 0; y < h; y++) {
SetDIBitsToDevice(dc, 0, y, w, 1, 0, 0, 0, 1, s2->offset32 + (y * w),
(BITMAPINFO *)&bi, DIB_RGB_COLORS);
}
sub__freeimage(i2, 1);
if (EndPage(dc) <= 0) {
EndDoc(dc);
DeleteDC(dc);
goto failed;
}
if (EndDoc(dc) <= 0) {
DeleteDC(dc);
goto failed;
}
DeleteDC(dc);
failed:;
#endif
}
#endif

View file

@ -1,2 +1,2 @@
//forward references
// forward references
void sub__printimage(int32 i);

View file

@ -1,33 +1,37 @@
mtri1_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri1_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,135 +72,172 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri1_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri1_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset32+(y*dwidth+x2))=src_offset32[(g2ty>>16)*swidth+(g2tx>>16)];
*(dst_offset32 + (y * dwidth + x2)) =
src_offset32[(g2ty >> 16) * swidth + (g2tx >> 16)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri1_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri1_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri1_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri1_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset32+(y*dwidth+x1))=src_offset32[(ty>>16)*swidth+(tx>>16)];
*(dst_offset32 + (y * dwidth + x1)) =
src_offset32[(ty >> 16) * swidth + (tx >> 16)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri1_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri1_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(y*dwidth+x1);
pixel_offset32 = dst_offset32 + (y * dwidth + x1);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(pixel_offset32++)=src_offset32[(ty>>16)*swidth+(tx>>16)];
*(pixel_offset32++) = src_offset32[(ty >> 16) * swidth + (tx >> 16)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri1_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri1_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri1_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri1_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri1_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri1s_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri1s_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,136 +72,173 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri1s_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri1s_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset32+(x2*dheight+y))=src_offset32[(g2ty>>16)*swidth+(g2tx>>16)];
*(dst_offset32 + (x2 * dheight + y)) =
src_offset32[(g2ty >> 16) * swidth + (g2tx >> 16)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri1s_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri1s_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri1s_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri1s_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset32+(x1*dheight+y))=src_offset32[(ty>>16)*swidth+(tx>>16)];
*(dst_offset32 + (x1 * dheight + y)) =
src_offset32[(ty >> 16) * swidth + (tx >> 16)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri1s_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri1s_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(x1*dheight+y);
pixel_offset32 = dst_offset32 + (x1 * dheight + y);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*pixel_offset32=src_offset32[(ty>>16)*swidth+(tx>>16)];
pixel_offset32+=dheight;
*pixel_offset32 = src_offset32[(ty >> 16) * swidth + (tx >> 16)];
pixel_offset32 += dheight;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri1s_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri1s_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri1s_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri1s_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri1s_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri1t_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri1t_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,135 +72,175 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri1t_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri1t_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset32+(y*dwidth+x2))=src_offset32[((g2ty>>16)%sheight)*swidth+((g2tx>>16)%swidth)];
*(dst_offset32 + (y * dwidth + x2)) =
src_offset32[((g2ty >> 16) % sheight) * swidth +
((g2tx >> 16) % swidth)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri1t_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri1t_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri1t_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri1t_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset32+(y*dwidth+x1))=src_offset32[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)];
*(dst_offset32 + (y * dwidth + x1)) =
src_offset32[((ty >> 16) % sheight) * swidth +
((tx >> 16) % swidth)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri1t_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri1t_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(y*dwidth+x1);
pixel_offset32 = dst_offset32 + (y * dwidth + x1);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(pixel_offset32++)=src_offset32[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)];
*(pixel_offset32++) = src_offset32[((ty >> 16) % sheight) * swidth +
((tx >> 16) % swidth)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri1t_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri1t_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri1t_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri1t_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri1t_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri1ts_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri1ts_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,136 +72,176 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri1ts_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri1ts_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset32+(x2*dheight+y))=src_offset32[((g2ty>>16)%sheight)*swidth+((g2tx>>16)%swidth)];
*(dst_offset32 + (x2 * dheight + y)) =
src_offset32[((g2ty >> 16) % sheight) * swidth +
((g2tx >> 16) % swidth)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri1ts_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri1ts_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri1ts_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri1ts_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset32+(x1*dheight+y))=src_offset32[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)];
*(dst_offset32 + (x1 * dheight + y)) =
src_offset32[((ty >> 16) % sheight) * swidth +
((tx >> 16) % swidth)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri1ts_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri1ts_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(x1*dheight+y);
pixel_offset32 = dst_offset32 + (x1 * dheight + y);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*pixel_offset32=src_offset32[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)];
pixel_offset32+=dheight;
*pixel_offset32 = src_offset32[((ty >> 16) % sheight) * swidth +
((tx >> 16) % swidth)];
pixel_offset32 += dheight;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri1ts_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri1ts_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri1ts_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri1ts_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri1ts_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri2_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri2_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,204 +72,254 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri2_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri2_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(y*dwidth+x2);
pixel_offset32 = dst_offset32 + (y * dwidth + x2);
//--------plot pixel--------
switch((col=src_offset32[(g2ty>>16)*swidth+(g2tx>>16)])&0xFF000000){
case 0xFF000000:
*pixel_offset32=col;
switch ((col = src_offset32[(g2ty >> 16) * swidth + (g2tx >> 16)]) &
0xFF000000) {
case 0xFF000000:
*pixel_offset32 = col;
break;
case 0x0:
case 0x0:
break;
case 0x80000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend128[*pixel_offset32>>24]<<24);
break;
case 0x7F000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend127[*pixel_offset32>>24]<<24);
case 0x80000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend128[*pixel_offset32 >> 24] << 24);
break;
default:
destcol=*pixel_offset32;
cp=cblend+(col>>24<<16);
*pixel_offset32=
cp[(col<<8&0xFF00)+(destcol&255) ]
+(cp[(col&0xFF00) +(destcol>>8&255) ]<<8)
+(cp[(col>>8&0xFF00)+(destcol>>16&255)]<<16)
+(ablend[(col>>24)+(destcol>>16&0xFF00)]<<24);
};//switch
case 0x7F000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend127[*pixel_offset32 >> 24] << 24);
break;
default:
destcol = *pixel_offset32;
cp = cblend + (col >> 24 << 16);
*pixel_offset32 =
cp[(col << 8 & 0xFF00) + (destcol & 255)] +
(cp[(col & 0xFF00) + (destcol >> 8 & 255)] << 8) +
(cp[(col >> 8 & 0xFF00) + (destcol >> 16 & 255)] << 16) +
(ablend[(col >> 24) + (destcol >> 16 & 0xFF00)] << 24);
}; // switch
//--------done plot pixel--------
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri2_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri2_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri2_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri2_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(y*dwidth+x1);
pixel_offset32 = dst_offset32 + (y * dwidth + x1);
//--------plot pixel--------
switch((col=src_offset32[(ty>>16)*swidth+(tx>>16)])&0xFF000000){
case 0xFF000000:
*pixel_offset32=col;
switch ((col = src_offset32[(ty >> 16) * swidth + (tx >> 16)]) &
0xFF000000) {
case 0xFF000000:
*pixel_offset32 = col;
break;
case 0x0:
case 0x0:
break;
case 0x80000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend128[*pixel_offset32>>24]<<24);
break;
case 0x7F000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend127[*pixel_offset32>>24]<<24);
case 0x80000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend128[*pixel_offset32 >> 24] << 24);
break;
default:
destcol=*pixel_offset32;
cp=cblend+(col>>24<<16);
*pixel_offset32=
cp[(col<<8&0xFF00)+(destcol&255) ]
+(cp[(col&0xFF00) +(destcol>>8&255) ]<<8)
+(cp[(col>>8&0xFF00)+(destcol>>16&255)]<<16)
+(ablend[(col>>24)+(destcol>>16&0xFF00)]<<24);
};//switch
case 0x7F000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend127[*pixel_offset32 >> 24] << 24);
break;
default:
destcol = *pixel_offset32;
cp = cblend + (col >> 24 << 16);
*pixel_offset32 =
cp[(col << 8 & 0xFF00) + (destcol & 255)] +
(cp[(col & 0xFF00) + (destcol >> 8 & 255)] << 8) +
(cp[(col >> 8 & 0xFF00) + (destcol >> 16 & 255)] << 16) +
(ablend[(col >> 24) + (destcol >> 16 & 0xFF00)] << 24);
}; // switch
//--------done plot pixel--------
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri2_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri2_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(y*dwidth+x1);
pixel_offset32 = dst_offset32 + (y * dwidth + x1);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//--------plot pixel--------
switch((col=src_offset32[(ty>>16)*swidth+(tx>>16)])&0xFF000000){
case 0xFF000000:
*pixel_offset32=col;
switch ((col = src_offset32[(ty >> 16) * swidth + (tx >> 16)]) &
0xFF000000) {
case 0xFF000000:
*pixel_offset32 = col;
break;
case 0x0:
case 0x0:
break;
case 0x80000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend128[*pixel_offset32>>24]<<24);
break;
case 0x7F000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend127[*pixel_offset32>>24]<<24);
case 0x80000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend128[*pixel_offset32 >> 24] << 24);
break;
default:
destcol=*pixel_offset32;
cp=cblend+(col>>24<<16);
*pixel_offset32=
cp[(col<<8&0xFF00)+(destcol&255) ]
+(cp[(col&0xFF00) +(destcol>>8&255) ]<<8)
+(cp[(col>>8&0xFF00)+(destcol>>16&255)]<<16)
+(ablend[(col>>24)+(destcol>>16&0xFF00)]<<24);
};//switch
case 0x7F000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend127[*pixel_offset32 >> 24] << 24);
break;
default:
destcol = *pixel_offset32;
cp = cblend + (col >> 24 << 16);
*pixel_offset32 =
cp[(col << 8 & 0xFF00) + (destcol & 255)] +
(cp[(col & 0xFF00) + (destcol >> 8 & 255)] << 8) +
(cp[(col >> 8 & 0xFF00) + (destcol >> 16 & 255)] << 16) +
(ablend[(col >> 24) + (destcol >> 16 & 0xFF00)] << 24);
}; // switch
//--------done plot pixel--------
pixel_offset32++;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri2_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri2_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri2_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri2_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri2_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri2s_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri2s_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,204 +72,254 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri2s_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri2s_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(x2*dheight+y);
pixel_offset32 = dst_offset32 + (x2 * dheight + y);
//--------plot pixel--------
switch((col=src_offset32[(g2ty>>16)*swidth+(g2tx>>16)])&0xFF000000){
case 0xFF000000:
*pixel_offset32=col;
switch ((col = src_offset32[(g2ty >> 16) * swidth + (g2tx >> 16)]) &
0xFF000000) {
case 0xFF000000:
*pixel_offset32 = col;
break;
case 0x0:
case 0x0:
break;
case 0x80000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend128[*pixel_offset32>>24]<<24);
break;
case 0x7F000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend127[*pixel_offset32>>24]<<24);
case 0x80000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend128[*pixel_offset32 >> 24] << 24);
break;
default:
destcol=*pixel_offset32;
cp=cblend+(col>>24<<16);
*pixel_offset32=
cp[(col<<8&0xFF00)+(destcol&255) ]
+(cp[(col&0xFF00) +(destcol>>8&255) ]<<8)
+(cp[(col>>8&0xFF00)+(destcol>>16&255)]<<16)
+(ablend[(col>>24)+(destcol>>16&0xFF00)]<<24);
};//switch
case 0x7F000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend127[*pixel_offset32 >> 24] << 24);
break;
default:
destcol = *pixel_offset32;
cp = cblend + (col >> 24 << 16);
*pixel_offset32 =
cp[(col << 8 & 0xFF00) + (destcol & 255)] +
(cp[(col & 0xFF00) + (destcol >> 8 & 255)] << 8) +
(cp[(col >> 8 & 0xFF00) + (destcol >> 16 & 255)] << 16) +
(ablend[(col >> 24) + (destcol >> 16 & 0xFF00)] << 24);
}; // switch
//--------done plot pixel--------
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri2s_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri2s_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri2s_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri2s_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(x1*dheight+y);
pixel_offset32 = dst_offset32 + (x1 * dheight + y);
//--------plot pixel--------
switch((col=src_offset32[(ty>>16)*swidth+(tx>>16)])&0xFF000000){
case 0xFF000000:
*pixel_offset32=col;
switch ((col = src_offset32[(ty >> 16) * swidth + (tx >> 16)]) &
0xFF000000) {
case 0xFF000000:
*pixel_offset32 = col;
break;
case 0x0:
case 0x0:
break;
case 0x80000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend128[*pixel_offset32>>24]<<24);
break;
case 0x7F000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend127[*pixel_offset32>>24]<<24);
case 0x80000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend128[*pixel_offset32 >> 24] << 24);
break;
default:
destcol=*pixel_offset32;
cp=cblend+(col>>24<<16);
*pixel_offset32=
cp[(col<<8&0xFF00)+(destcol&255) ]
+(cp[(col&0xFF00) +(destcol>>8&255) ]<<8)
+(cp[(col>>8&0xFF00)+(destcol>>16&255)]<<16)
+(ablend[(col>>24)+(destcol>>16&0xFF00)]<<24);
};//switch
case 0x7F000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend127[*pixel_offset32 >> 24] << 24);
break;
default:
destcol = *pixel_offset32;
cp = cblend + (col >> 24 << 16);
*pixel_offset32 =
cp[(col << 8 & 0xFF00) + (destcol & 255)] +
(cp[(col & 0xFF00) + (destcol >> 8 & 255)] << 8) +
(cp[(col >> 8 & 0xFF00) + (destcol >> 16 & 255)] << 16) +
(ablend[(col >> 24) + (destcol >> 16 & 0xFF00)] << 24);
}; // switch
//--------done plot pixel--------
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri2s_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri2s_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(x1*dheight+y);
pixel_offset32 = dst_offset32 + (x1 * dheight + y);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//--------plot pixel--------
switch((col=src_offset32[(ty>>16)*swidth+(tx>>16)])&0xFF000000){
case 0xFF000000:
*pixel_offset32=col;
switch ((col = src_offset32[(ty >> 16) * swidth + (tx >> 16)]) &
0xFF000000) {
case 0xFF000000:
*pixel_offset32 = col;
break;
case 0x0:
case 0x0:
break;
case 0x80000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend128[*pixel_offset32>>24]<<24);
break;
case 0x7F000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend127[*pixel_offset32>>24]<<24);
case 0x80000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend128[*pixel_offset32 >> 24] << 24);
break;
default:
destcol=*pixel_offset32;
cp=cblend+(col>>24<<16);
*pixel_offset32=
cp[(col<<8&0xFF00)+(destcol&255) ]
+(cp[(col&0xFF00) +(destcol>>8&255) ]<<8)
+(cp[(col>>8&0xFF00)+(destcol>>16&255)]<<16)
+(ablend[(col>>24)+(destcol>>16&0xFF00)]<<24);
};//switch
case 0x7F000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend127[*pixel_offset32 >> 24] << 24);
break;
default:
destcol = *pixel_offset32;
cp = cblend + (col >> 24 << 16);
*pixel_offset32 =
cp[(col << 8 & 0xFF00) + (destcol & 255)] +
(cp[(col & 0xFF00) + (destcol >> 8 & 255)] << 8) +
(cp[(col >> 8 & 0xFF00) + (destcol >> 16 & 255)] << 16) +
(ablend[(col >> 24) + (destcol >> 16 & 0xFF00)] << 24);
}; // switch
//--------done plot pixel--------
pixel_offset32+=dheight;
pixel_offset32 += dheight;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri2s_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri2s_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri2s_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri2s_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri2s_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri2t_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri2t_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,204 +72,257 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri2t_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri2t_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(y*dwidth+x2);
pixel_offset32 = dst_offset32 + (y * dwidth + x2);
//--------plot pixel--------
switch((col=src_offset32[((g2ty>>16)%sheight)*swidth+((g2tx>>16)%swidth)])&0xFF000000){
case 0xFF000000:
*pixel_offset32=col;
switch ((col = src_offset32[((g2ty >> 16) % sheight) * swidth +
((g2tx >> 16) % swidth)]) &
0xFF000000) {
case 0xFF000000:
*pixel_offset32 = col;
break;
case 0x0:
case 0x0:
break;
case 0x80000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend128[*pixel_offset32>>24]<<24);
break;
case 0x7F000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend127[*pixel_offset32>>24]<<24);
case 0x80000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend128[*pixel_offset32 >> 24] << 24);
break;
default:
destcol=*pixel_offset32;
cp=cblend+(col>>24<<16);
*pixel_offset32=
cp[(col<<8&0xFF00)+(destcol&255) ]
+(cp[(col&0xFF00) +(destcol>>8&255) ]<<8)
+(cp[(col>>8&0xFF00)+(destcol>>16&255)]<<16)
+(ablend[(col>>24)+(destcol>>16&0xFF00)]<<24);
};//switch
case 0x7F000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend127[*pixel_offset32 >> 24] << 24);
break;
default:
destcol = *pixel_offset32;
cp = cblend + (col >> 24 << 16);
*pixel_offset32 =
cp[(col << 8 & 0xFF00) + (destcol & 255)] +
(cp[(col & 0xFF00) + (destcol >> 8 & 255)] << 8) +
(cp[(col >> 8 & 0xFF00) + (destcol >> 16 & 255)] << 16) +
(ablend[(col >> 24) + (destcol >> 16 & 0xFF00)] << 24);
}; // switch
//--------done plot pixel--------
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri2t_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri2t_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri2t_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri2t_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(y*dwidth+x1);
pixel_offset32 = dst_offset32 + (y * dwidth + x1);
//--------plot pixel--------
switch((col=src_offset32[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)])&0xFF000000){
case 0xFF000000:
*pixel_offset32=col;
switch ((col = src_offset32[((ty >> 16) % sheight) * swidth +
((tx >> 16) % swidth)]) &
0xFF000000) {
case 0xFF000000:
*pixel_offset32 = col;
break;
case 0x0:
case 0x0:
break;
case 0x80000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend128[*pixel_offset32>>24]<<24);
break;
case 0x7F000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend127[*pixel_offset32>>24]<<24);
case 0x80000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend128[*pixel_offset32 >> 24] << 24);
break;
default:
destcol=*pixel_offset32;
cp=cblend+(col>>24<<16);
*pixel_offset32=
cp[(col<<8&0xFF00)+(destcol&255) ]
+(cp[(col&0xFF00) +(destcol>>8&255) ]<<8)
+(cp[(col>>8&0xFF00)+(destcol>>16&255)]<<16)
+(ablend[(col>>24)+(destcol>>16&0xFF00)]<<24);
};//switch
case 0x7F000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend127[*pixel_offset32 >> 24] << 24);
break;
default:
destcol = *pixel_offset32;
cp = cblend + (col >> 24 << 16);
*pixel_offset32 =
cp[(col << 8 & 0xFF00) + (destcol & 255)] +
(cp[(col & 0xFF00) + (destcol >> 8 & 255)] << 8) +
(cp[(col >> 8 & 0xFF00) + (destcol >> 16 & 255)] << 16) +
(ablend[(col >> 24) + (destcol >> 16 & 0xFF00)] << 24);
}; // switch
//--------done plot pixel--------
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri2t_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri2t_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(y*dwidth+x1);
pixel_offset32 = dst_offset32 + (y * dwidth + x1);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//--------plot pixel--------
switch((col=src_offset32[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)])&0xFF000000){
case 0xFF000000:
*pixel_offset32=col;
switch ((col = src_offset32[((ty >> 16) % sheight) * swidth +
((tx >> 16) % swidth)]) &
0xFF000000) {
case 0xFF000000:
*pixel_offset32 = col;
break;
case 0x0:
case 0x0:
break;
case 0x80000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend128[*pixel_offset32>>24]<<24);
break;
case 0x7F000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend127[*pixel_offset32>>24]<<24);
case 0x80000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend128[*pixel_offset32 >> 24] << 24);
break;
default:
destcol=*pixel_offset32;
cp=cblend+(col>>24<<16);
*pixel_offset32=
cp[(col<<8&0xFF00)+(destcol&255) ]
+(cp[(col&0xFF00) +(destcol>>8&255) ]<<8)
+(cp[(col>>8&0xFF00)+(destcol>>16&255)]<<16)
+(ablend[(col>>24)+(destcol>>16&0xFF00)]<<24);
};//switch
case 0x7F000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend127[*pixel_offset32 >> 24] << 24);
break;
default:
destcol = *pixel_offset32;
cp = cblend + (col >> 24 << 16);
*pixel_offset32 =
cp[(col << 8 & 0xFF00) + (destcol & 255)] +
(cp[(col & 0xFF00) + (destcol >> 8 & 255)] << 8) +
(cp[(col >> 8 & 0xFF00) + (destcol >> 16 & 255)] << 16) +
(ablend[(col >> 24) + (destcol >> 16 & 0xFF00)] << 24);
}; // switch
//--------done plot pixel--------
pixel_offset32++;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri2t_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri2t_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri2t_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri2t_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri2t_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri2ts_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri2ts_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,204 +72,257 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri2ts_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri2ts_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(x2*dheight+y);
pixel_offset32 = dst_offset32 + (x2 * dheight + y);
//--------plot pixel--------
switch((col=src_offset32[((g2ty>>16)%sheight)*swidth+((g2tx>>16)%swidth)])&0xFF000000){
case 0xFF000000:
*pixel_offset32=col;
switch ((col = src_offset32[((g2ty >> 16) % sheight) * swidth +
((g2tx >> 16) % swidth)]) &
0xFF000000) {
case 0xFF000000:
*pixel_offset32 = col;
break;
case 0x0:
case 0x0:
break;
case 0x80000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend128[*pixel_offset32>>24]<<24);
break;
case 0x7F000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend127[*pixel_offset32>>24]<<24);
case 0x80000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend128[*pixel_offset32 >> 24] << 24);
break;
default:
destcol=*pixel_offset32;
cp=cblend+(col>>24<<16);
*pixel_offset32=
cp[(col<<8&0xFF00)+(destcol&255) ]
+(cp[(col&0xFF00) +(destcol>>8&255) ]<<8)
+(cp[(col>>8&0xFF00)+(destcol>>16&255)]<<16)
+(ablend[(col>>24)+(destcol>>16&0xFF00)]<<24);
};//switch
case 0x7F000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend127[*pixel_offset32 >> 24] << 24);
break;
default:
destcol = *pixel_offset32;
cp = cblend + (col >> 24 << 16);
*pixel_offset32 =
cp[(col << 8 & 0xFF00) + (destcol & 255)] +
(cp[(col & 0xFF00) + (destcol >> 8 & 255)] << 8) +
(cp[(col >> 8 & 0xFF00) + (destcol >> 16 & 255)] << 16) +
(ablend[(col >> 24) + (destcol >> 16 & 0xFF00)] << 24);
}; // switch
//--------done plot pixel--------
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri2ts_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri2ts_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri2ts_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri2ts_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(x1*dheight+y);
pixel_offset32 = dst_offset32 + (x1 * dheight + y);
//--------plot pixel--------
switch((col=src_offset32[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)])&0xFF000000){
case 0xFF000000:
*pixel_offset32=col;
switch ((col = src_offset32[((ty >> 16) % sheight) * swidth +
((tx >> 16) % swidth)]) &
0xFF000000) {
case 0xFF000000:
*pixel_offset32 = col;
break;
case 0x0:
case 0x0:
break;
case 0x80000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend128[*pixel_offset32>>24]<<24);
break;
case 0x7F000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend127[*pixel_offset32>>24]<<24);
case 0x80000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend128[*pixel_offset32 >> 24] << 24);
break;
default:
destcol=*pixel_offset32;
cp=cblend+(col>>24<<16);
*pixel_offset32=
cp[(col<<8&0xFF00)+(destcol&255) ]
+(cp[(col&0xFF00) +(destcol>>8&255) ]<<8)
+(cp[(col>>8&0xFF00)+(destcol>>16&255)]<<16)
+(ablend[(col>>24)+(destcol>>16&0xFF00)]<<24);
};//switch
case 0x7F000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend127[*pixel_offset32 >> 24] << 24);
break;
default:
destcol = *pixel_offset32;
cp = cblend + (col >> 24 << 16);
*pixel_offset32 =
cp[(col << 8 & 0xFF00) + (destcol & 255)] +
(cp[(col & 0xFF00) + (destcol >> 8 & 255)] << 8) +
(cp[(col >> 8 & 0xFF00) + (destcol >> 16 & 255)] << 16) +
(ablend[(col >> 24) + (destcol >> 16 & 0xFF00)] << 24);
}; // switch
//--------done plot pixel--------
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri2ts_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri2ts_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset32=dst_offset32+(x1*dheight+y);
pixel_offset32 = dst_offset32 + (x1 * dheight + y);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//--------plot pixel--------
switch((col=src_offset32[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)])&0xFF000000){
case 0xFF000000:
*pixel_offset32=col;
switch ((col = src_offset32[((ty >> 16) % sheight) * swidth +
((tx >> 16) % swidth)]) &
0xFF000000) {
case 0xFF000000:
*pixel_offset32 = col;
break;
case 0x0:
case 0x0:
break;
case 0x80000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend128[*pixel_offset32>>24]<<24);
break;
case 0x7F000000:
*pixel_offset32=(((*pixel_offset32&0xFEFEFE)+(col&0xFEFEFE))>>1)+(ablend127[*pixel_offset32>>24]<<24);
case 0x80000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend128[*pixel_offset32 >> 24] << 24);
break;
default:
destcol=*pixel_offset32;
cp=cblend+(col>>24<<16);
*pixel_offset32=
cp[(col<<8&0xFF00)+(destcol&255) ]
+(cp[(col&0xFF00) +(destcol>>8&255) ]<<8)
+(cp[(col>>8&0xFF00)+(destcol>>16&255)]<<16)
+(ablend[(col>>24)+(destcol>>16&0xFF00)]<<24);
};//switch
case 0x7F000000:
*pixel_offset32 =
(((*pixel_offset32 & 0xFEFEFE) + (col & 0xFEFEFE)) >> 1) +
(ablend127[*pixel_offset32 >> 24] << 24);
break;
default:
destcol = *pixel_offset32;
cp = cblend + (col >> 24 << 16);
*pixel_offset32 =
cp[(col << 8 & 0xFF00) + (destcol & 255)] +
(cp[(col & 0xFF00) + (destcol >> 8 & 255)] << 8) +
(cp[(col >> 8 & 0xFF00) + (destcol >> 16 & 255)] << 16) +
(ablend[(col >> 24) + (destcol >> 16 & 0xFF00)] << 24);
}; // switch
//--------done plot pixel--------
pixel_offset32+=dheight;
pixel_offset32 += dheight;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri2ts_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri2ts_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri2ts_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri2ts_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri2ts_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri3_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri3_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,135 +72,172 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri3_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri3_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset+(y*dwidth+x2))=src_offset[(g2ty>>16)*swidth+(g2tx>>16)];
*(dst_offset + (y * dwidth + x2)) =
src_offset[(g2ty >> 16) * swidth + (g2tx >> 16)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri3_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri3_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri3_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri3_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset+(y*dwidth+x1))=src_offset[(ty>>16)*swidth+(tx>>16)];
*(dst_offset + (y * dwidth + x1)) =
src_offset[(ty >> 16) * swidth + (tx >> 16)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri3_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri3_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset=dst_offset+(y*dwidth+x1);
pixel_offset = dst_offset + (y * dwidth + x1);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(pixel_offset++)=src_offset[(ty>>16)*swidth+(tx>>16)];
*(pixel_offset++) = src_offset[(ty >> 16) * swidth + (tx >> 16)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri3_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri3_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri3_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri3_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri3_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri3s_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri3s_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,136 +72,173 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri3s_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri3s_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset+(x2*dheight+y))=src_offset[(g2ty>>16)*swidth+(g2tx>>16)];
*(dst_offset + (x2 * dheight + y)) =
src_offset[(g2ty >> 16) * swidth + (g2tx >> 16)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri3s_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri3s_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri3s_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri3s_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset+(x1*dheight+y))=src_offset[(ty>>16)*swidth+(tx>>16)];
*(dst_offset + (x1 * dheight + y)) =
src_offset[(ty >> 16) * swidth + (tx >> 16)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri3s_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri3s_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset=dst_offset+(x1*dheight+y);
pixel_offset = dst_offset + (x1 * dheight + y);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*pixel_offset=src_offset[(ty>>16)*swidth+(tx>>16)];
pixel_offset+=dheight;
*pixel_offset = src_offset[(ty >> 16) * swidth + (tx >> 16)];
pixel_offset += dheight;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri3s_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri3s_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri3s_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri3s_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri3s_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri3t_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri3t_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,135 +72,175 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri3t_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri3t_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset+(y*dwidth+x2))=src_offset[((g2ty>>16)%sheight)*swidth+((g2tx>>16)%swidth)];
*(dst_offset + (y * dwidth + x2)) =
src_offset[((g2ty >> 16) % sheight) * swidth +
((g2tx >> 16) % swidth)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri3t_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri3t_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri3t_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri3t_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset+(y*dwidth+x1))=src_offset[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)];
*(dst_offset + (y * dwidth + x1)) =
src_offset[((ty >> 16) % sheight) * swidth +
((tx >> 16) % swidth)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri3t_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri3t_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset=dst_offset+(y*dwidth+x1);
pixel_offset = dst_offset + (y * dwidth + x1);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(pixel_offset++)=src_offset[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)];
*(pixel_offset++) =
src_offset[((ty >> 16) % sheight) * swidth + ((tx >> 16) % swidth)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri3t_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri3t_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri3t_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri3t_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri3t_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri3ts_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri3ts_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,136 +72,176 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri3ts_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri3ts_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset+(x2*dheight+y))=src_offset[((g2ty>>16)%sheight)*swidth+((g2tx>>16)%swidth)];
*(dst_offset + (x2 * dheight + y)) =
src_offset[((g2ty >> 16) % sheight) * swidth +
((g2tx >> 16) % swidth)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri3ts_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri3ts_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri3ts_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri3ts_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*(dst_offset+(x1*dheight+y))=src_offset[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)];
*(dst_offset + (x1 * dheight + y)) =
src_offset[((ty >> 16) % sheight) * swidth +
((tx >> 16) % swidth)];
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri3ts_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri3ts_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset=dst_offset+(x1*dheight+y);
pixel_offset = dst_offset + (x1 * dheight + y);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*pixel_offset=src_offset[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)];
pixel_offset+=dheight;
*pixel_offset =
src_offset[((ty >> 16) % sheight) * swidth + ((tx >> 16) % swidth)];
pixel_offset += dheight;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri3ts_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri3ts_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri3ts_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri3ts_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri3ts_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri4_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri4_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,139 +72,177 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri4_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri4_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
col=src_offset[(g2ty>>16)*swidth+(g2tx>>16)];
if (col!=transparent_color) *(dst_offset+(y*dwidth+x2))=col;
col = src_offset[(g2ty >> 16) * swidth + (g2tx >> 16)];
if (col != transparent_color)
*(dst_offset + (y * dwidth + x2)) = col;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri4_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri4_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri4_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri4_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
col=src_offset[(ty>>16)*swidth+(tx>>16)];
if (col!=transparent_color) *(dst_offset+(y*dwidth+x1))=col;
col = src_offset[(ty >> 16) * swidth + (tx >> 16)];
if (col != transparent_color)
*(dst_offset + (y * dwidth + x1)) = col;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri4_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri4_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset=dst_offset+(y*dwidth+x1);
pixel_offset = dst_offset + (y * dwidth + x1);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
col=src_offset[(ty>>16)*swidth+(tx>>16)];
if (col!=transparent_color) *pixel_offset=col;
col = src_offset[(ty >> 16) * swidth + (tx >> 16)];
if (col != transparent_color)
*pixel_offset = col;
pixel_offset++;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri4_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri4_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri4_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri4_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri4_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri4s_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri4s_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,139 +72,177 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri4s_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri4s_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
col=src_offset[(g2ty>>16)*swidth+(g2tx>>16)];
if (col!=transparent_color) *(dst_offset+(x2*dheight+y))=col;
col = src_offset[(g2ty >> 16) * swidth + (g2tx >> 16)];
if (col != transparent_color)
*(dst_offset + (x2 * dheight + y)) = col;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri4s_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri4s_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri4s_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri4s_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
col=src_offset[(ty>>16)*swidth+(tx>>16)];
if (col!=transparent_color) *(dst_offset+(x1*dheight+y))=col;
col = src_offset[(ty >> 16) * swidth + (tx >> 16)];
if (col != transparent_color)
*(dst_offset + (x1 * dheight + y)) = col;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri4s_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri4s_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset=dst_offset+(x1*dheight+y);
pixel_offset = dst_offset + (x1 * dheight + y);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
col=src_offset[(ty>>16)*swidth+(tx>>16)];
if (col!=transparent_color) *pixel_offset=col;
pixel_offset+=dheight;
col = src_offset[(ty >> 16) * swidth + (tx >> 16)];
if (col != transparent_color)
*pixel_offset = col;
pixel_offset += dheight;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri4s_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri4s_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri4s_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri4s_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri4s_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri4t_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri4t_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,139 +72,180 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri4t_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri4t_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
col=src_offset[((g2ty>>16)%sheight)*swidth+((g2tx>>16)%swidth)];
if (col!=transparent_color) *(dst_offset+(y*dwidth+x2))=col;
col = src_offset[((g2ty >> 16) % sheight) * swidth +
((g2tx >> 16) % swidth)];
if (col != transparent_color)
*(dst_offset + (y * dwidth + x2)) = col;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri4t_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri4t_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri4t_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri4t_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
col=src_offset[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)];
if (col!=transparent_color) *(dst_offset+(y*dwidth+x1))=col;
col = src_offset[((ty >> 16) % sheight) * swidth +
((tx >> 16) % swidth)];
if (col != transparent_color)
*(dst_offset + (y * dwidth + x1)) = col;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri4t_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri4t_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset=dst_offset+(y*dwidth+x1);
pixel_offset = dst_offset + (y * dwidth + x1);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
col=src_offset[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)];
if (col!=transparent_color) *pixel_offset=col;
col =
src_offset[((ty >> 16) % sheight) * swidth + ((tx >> 16) % swidth)];
if (col != transparent_color)
*pixel_offset = col;
pixel_offset++;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri4t_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri4t_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri4t_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri4t_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri4t_usegrad3;
}
}
return;

View file

@ -1,33 +1,37 @@
mtri4ts_usegrad3:;
if(final == 1){
if(no_edge_overlap) y2 = y2 - 1;
if (final == 1) {
if (no_edge_overlap)
y2 = y2 - 1;
}
//not on screen?
if(y1 >= dheight){
// not on screen?
if (y1 >= dheight) {
return;
}
if(y2 < 0){
if(final) return;
//jump to y2's position
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
if (y2 < 0) {
if (final)
return;
// jump to y2's position
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = y2 - y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -38,23 +42,26 @@ if(y2 < 0){
goto mtri4ts_final;
}
//clip top
if(y1 < 0){
//note; original point locations are referenced because they are unmodified & represent the true distance of the run
// clip top
if (y1 < 0) {
// note; original point locations are referenced because they are unmodified
// & represent the true distance of the run
y = -y1;
p1 = g1->p1; p2 = g1->p2;
p1 = g1->p1;
p2 = g1->p2;
d = g1->y2 - g1->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g1->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
g1->ty += i64 * y / d;
i64 = p2->x - p1->x;
g1->x += i64 * y / d;
p1 = g2->p1; p2 = g2->p2;
p1 = g2->p1;
p2 = g2->p2;
}
d = g2->y2 - g2->y1;
if(d){
if (d) {
i64 = p2->tx - p1->tx;
g2->tx += i64 * y / d;
i64 = p2->ty - p1->ty;
@ -65,139 +72,180 @@ if(y1 < 0){
y1 = 0;
}
if(y2 >= dheight){ //clip bottom
if (y2 >= dheight) { // clip bottom
y2 = dheight - 1;
}
//move indexed variable values into direct variables for faster referencing within 2nd bottleneck
g1x = g1->x; g2x = g2->x;
g1tx = g1->tx; g2tx = g2->tx;
g1ty = g1->ty; g2ty = g2->ty;
g1xi = g1->xi; g2xi = g2->xi;
g1txi = g1->txi; g2txi = g2->txi;
g1tyi = g1->tyi; g2tyi = g2->tyi;
// move indexed variable values into direct variables for faster referencing
// within 2nd bottleneck
g1x = g1->x;
g2x = g2->x;
g1tx = g1->tx;
g2tx = g2->tx;
g1ty = g1->ty;
g2ty = g2->ty;
g1xi = g1->xi;
g2xi = g2->xi;
g1txi = g1->txi;
g2txi = g2->txi;
g1tyi = g1->tyi;
g2tyi = g2->tyi;
//2nd bottleneck
for(y=y1;y<=y2;y++){
if(g1x < 0) x1 = (g1x - 65535) / 65536;else x1 = g1x / 65536; //int-style rounding of fixed-point value
if(g2x < 0) x2 = (g2x - 65535) / 65536;else x2 = g2x / 65536;
if(x1 >= dwidth | x2 < 0) goto mtri4ts_donerow; //crop if(entirely offscreen
tx = g1tx; ty = g1ty;
//calculate gradients if they might be required
if(x1 != x2){
// 2nd bottleneck
for (y = y1; y <= y2; y++) {
if (g1x < 0)
x1 = (g1x - 65535) / 65536;
else
x1 = g1x / 65536; // int-style rounding of fixed-point value
if (g2x < 0)
x2 = (g2x - 65535) / 65536;
else
x2 = g2x / 65536;
if (x1 >= dwidth | x2 < 0)
goto mtri4ts_donerow; // crop if(entirely offscreen
tx = g1tx;
ty = g1ty;
// calculate gradients if they might be required
if (x1 != x2) {
d = g2x - g1x;
i64 = g2tx - g1tx; txi = (i64 << 16) / d;
i64 = g2ty - g1ty; tyi = (i64 << 16) / d;
}else{
txi = 0; tyi = 0;
i64 = g2tx - g1tx;
txi = (i64 << 16) / d;
i64 = g2ty - g1ty;
tyi = (i64 << 16) / d;
} else {
txi = 0;
tyi = 0;
}
//calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); //note; works for positive & negative values
// calculate pixel offsets from ideals
loff = ((g1x & 65535) - 32768); // note; works for positive & negative
// values
roff = ((g2x & 65535) - 32768);
if(roff < 0){ //not enough of rhs pixel exists to use
if(x2 < dwidth & no_edge_overlap == 0){ //onscreen check
//draw rhs pixel as is
if (roff < 0) { // not enough of rhs pixel exists to use
if (x2 < dwidth & no_edge_overlap == 0) { // onscreen check
// draw rhs pixel as is
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
col=src_offset[((g2ty>>16)%sheight)*swidth+((g2tx>>16)%swidth)];
if (col!=transparent_color) *(dst_offset+(x2*dheight+y))=col;
col = src_offset[((g2ty >> 16) % sheight) * swidth +
((g2tx >> 16) % swidth)];
if (col != transparent_color)
*(dst_offset + (x2 * dheight + y)) = col;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//move left one position
// move left one position
x2--;
if(x1 > x2 | x2 < 0) goto mtri4ts_donerow; //no more to do
}else{
if(no_edge_overlap){
if (x1 > x2 | x2 < 0)
goto mtri4ts_donerow; // no more to do
} else {
if (no_edge_overlap) {
x2 = x2 - 1;
if(x1 > x2 | x2 < 0) goto mtri4ts_donerow; //no more to do
if (x1 > x2 | x2 < 0)
goto mtri4ts_donerow; // no more to do
}
}
if(loff > 0){
//draw lhs pixel as is
if(x1 >= 0){
if (loff > 0) {
// draw lhs pixel as is
if (x1 >= 0) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
col=src_offset[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)];
if (col!=transparent_color) *(dst_offset+(x1*dheight+y))=col;
col = src_offset[((ty >> 16) % sheight) * swidth +
((tx >> 16) % swidth)];
if (col != transparent_color)
*(dst_offset + (x1 * dheight + y)) = col;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
}
//skip to next x location, effectively reducing steps by 1
// skip to next x location, effectively reducing steps by 1
x1++;
if(x1 > x2) goto mtri4ts_donerow;
loff = -(65536 - loff); //adjust alignment to jump to next ideal offset
if (x1 > x2)
goto mtri4ts_donerow;
loff = -(65536 - loff); // adjust alignment to jump to next ideal offset
}
//align to loff
// align to loff
i64 = -loff;
tx += (i64 * txi) / 65536;
ty += (i64 * tyi) / 65536;
if(x1 < 0){ //clip left
if (x1 < 0) { // clip left
d = g2x - g1x;
i64 = g2tx - g1tx;
tx += ((i64 << 16) * -x1) / d;
i64 = g2ty - g1ty;
ty += ((i64 << 16) * -x1) / d;
if(x1 < 0) x1 = 0;
if (x1 < 0)
x1 = 0;
}
if(x2 >= dwidth){
x2 = dwidth - 1; //clip right
if (x2 >= dwidth) {
x2 = dwidth - 1; // clip right
}
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
pixel_offset=dst_offset+(x1*dheight+y);
pixel_offset = dst_offset + (x1 * dheight + y);
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//bottleneck
for(x=x1;x<=x2;x++){
// bottleneck
for (x = x1; x <= x2; x++) {
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
col=src_offset[((ty>>16)%sheight)*swidth+((tx>>16)%swidth)];
if (col!=transparent_color) *pixel_offset=col;
pixel_offset+=dheight;
col =
src_offset[((ty >> 16) % sheight) * swidth + ((tx >> 16) % swidth)];
if (col != transparent_color)
*pixel_offset = col;
pixel_offset += dheight;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
tx += txi;
ty += tyi;
}
mtri4ts_donerow:;
if(y != y2){
g1x += g1xi; g1tx += g1txi; g1ty += g1tyi;
g2x += g2xi; g2tx += g2txi; g2ty += g2tyi;
mtri4ts_donerow:;
if (y != y2) {
g1x += g1xi;
g1tx += g1txi;
g1ty += g1tyi;
g2x += g2xi;
g2tx += g2txi;
g2ty += g2tyi;
}
}
if(final == 0){
//update indexed variable values with direct variable values which have changed & may be required
g1->x = g1x; g2->x = g2x;
g1->tx = g1tx; g2->tx = g2tx;
g1->ty = g1ty; g2->ty = g2ty;
mtri4ts_final:;
if(y2 < dheight - 1){ //no point continuing if(offscreen!
if(g1->y2 < g2->y2) g1 = g3;else g2 = g3;
//avoid doing the same row twice
if (final == 0) {
// update indexed variable values with direct variable values which have
// changed & may be required
g1->x = g1x;
g2->x = g2x;
g1->tx = g1tx;
g2->tx = g2tx;
g1->ty = g1ty;
g2->ty = g2ty;
mtri4ts_final:;
if (y2 < dheight - 1) { // no point continuing if(offscreen!
if (g1->y2 < g2->y2)
g1 = g3;
else
g2 = g3;
// avoid doing the same row twice
y1 = g3->y1 + 1;
y2 = g3->y2;
g1->x += g1->xi; g1->tx += g1->txi; g1->ty += g1->tyi;
g2->x += g2->xi; g2->tx += g2->txi; g2->ty += g2->tyi;
g1->x += g1->xi;
g1->tx += g1->txi;
g1->ty += g1->tyi;
g2->x += g2->xi;
g2->tx += g2->txi;
g2->ty += g2->tyi;
final = 1;
goto mtri4ts_usegrad3;
}
}
return;

View file

@ -1,7 +1,8 @@
//Note: Updated 23/9/2018: Switched to www.qb64.org since .net is down; replaces implementation with download sample code from wiki
//Note: Updated 26/3/2014: Switched to WWW.QB64.NET to avoid IP changes when QB64 moves servers
//Note: Updated 16/1/2013: Switched to QB64.NET IP service
//Note: Updated 15/7/2013: Switched to 223.27.25.123 because of DNS issues
// Note: Updated 23/9/2018: Switched to www.qb64.org since .net is down;
// replaces implementation with download sample code from wiki Note: Updated
// 26/3/2014: Switched to WWW.QB64.NET to avoid IP changes when QB64 moves
// servers Note: Updated 16/1/2013: Switched to QB64.NET IP service Note: Updated
// 15/7/2013: Switched to 223.27.25.123 because of DNS issues
/*
'ip.php:
@ -51,138 +52,200 @@
$CHECKING:ON
*/
qbs* WHATISMYIP(){ //changed name from FUNC_WHATISMYIP to WHATISMYIP
qbs *WHATISMYIP() { // changed name from FUNC_WHATISMYIP to WHATISMYIP
qbs *tqbs;
ptrszint tmp_long;
int32 tmp_fileno;
uint32 qbs_tmp_base=qbs_tmp_list_nexti;
uint8 *tmp_mem_static_pointer=mem_static_pointer;
uint32 tmp_cmem_sp=cmem_sp;
uint32 qbs_tmp_base = qbs_tmp_list_nexti;
uint8 *tmp_mem_static_pointer = mem_static_pointer;
uint32 tmp_cmem_sp = cmem_sp;
// include "data1.txt"
qbs *_FUNC_WHATISMYIP_STRING_WHATISMYIP=NULL;
if (!_FUNC_WHATISMYIP_STRING_WHATISMYIP)_FUNC_WHATISMYIP_STRING_WHATISMYIP=qbs_new(0,0);
qbs *_FUNC_WHATISMYIP_STRING_URL=NULL;
if (!_FUNC_WHATISMYIP_STRING_URL)_FUNC_WHATISMYIP_STRING_URL=qbs_new(0,0);
qbs *_FUNC_WHATISMYIP_STRING_URL2=NULL;
if (!_FUNC_WHATISMYIP_STRING_URL2)_FUNC_WHATISMYIP_STRING_URL2=qbs_new(0,0);
float *_FUNC_WHATISMYIP_SINGLE_X=NULL;
if(_FUNC_WHATISMYIP_SINGLE_X==NULL){
_FUNC_WHATISMYIP_SINGLE_X=(float*)mem_static_malloc(4);
*_FUNC_WHATISMYIP_SINGLE_X=0;
qbs *_FUNC_WHATISMYIP_STRING_WHATISMYIP = NULL;
if (!_FUNC_WHATISMYIP_STRING_WHATISMYIP)
_FUNC_WHATISMYIP_STRING_WHATISMYIP = qbs_new(0, 0);
qbs *_FUNC_WHATISMYIP_STRING_URL = NULL;
if (!_FUNC_WHATISMYIP_STRING_URL)
_FUNC_WHATISMYIP_STRING_URL = qbs_new(0, 0);
qbs *_FUNC_WHATISMYIP_STRING_URL2 = NULL;
if (!_FUNC_WHATISMYIP_STRING_URL2)
_FUNC_WHATISMYIP_STRING_URL2 = qbs_new(0, 0);
float *_FUNC_WHATISMYIP_SINGLE_X = NULL;
if (_FUNC_WHATISMYIP_SINGLE_X == NULL) {
_FUNC_WHATISMYIP_SINGLE_X = (float *)mem_static_malloc(4);
*_FUNC_WHATISMYIP_SINGLE_X = 0;
}
float *_FUNC_WHATISMYIP_SINGLE_CLIENT=NULL;
if(_FUNC_WHATISMYIP_SINGLE_CLIENT==NULL){
_FUNC_WHATISMYIP_SINGLE_CLIENT=(float*)mem_static_malloc(4);
*_FUNC_WHATISMYIP_SINGLE_CLIENT=0;
float *_FUNC_WHATISMYIP_SINGLE_CLIENT = NULL;
if (_FUNC_WHATISMYIP_SINGLE_CLIENT == NULL) {
_FUNC_WHATISMYIP_SINGLE_CLIENT = (float *)mem_static_malloc(4);
*_FUNC_WHATISMYIP_SINGLE_CLIENT = 0;
}
qbs *_FUNC_WHATISMYIP_STRING_E=NULL;
if (!_FUNC_WHATISMYIP_STRING_E)_FUNC_WHATISMYIP_STRING_E=qbs_new(0,0);
qbs *_FUNC_WHATISMYIP_STRING_URL3=NULL;
if (!_FUNC_WHATISMYIP_STRING_URL3)_FUNC_WHATISMYIP_STRING_URL3=qbs_new(0,0);
byte_element_struct *byte_element_2=NULL;
if (!byte_element_2){
if ((mem_static_pointer+=12)<mem_static_limit) byte_element_2=(byte_element_struct*)(mem_static_pointer-12); else byte_element_2=(byte_element_struct*)mem_static_malloc(12);
qbs *_FUNC_WHATISMYIP_STRING_E = NULL;
if (!_FUNC_WHATISMYIP_STRING_E)
_FUNC_WHATISMYIP_STRING_E = qbs_new(0, 0);
qbs *_FUNC_WHATISMYIP_STRING_URL3 = NULL;
if (!_FUNC_WHATISMYIP_STRING_URL3)
_FUNC_WHATISMYIP_STRING_URL3 = qbs_new(0, 0);
byte_element_struct *byte_element_2 = NULL;
if (!byte_element_2) {
if ((mem_static_pointer += 12) < mem_static_limit)
byte_element_2 = (byte_element_struct *)(mem_static_pointer - 12);
else
byte_element_2 = (byte_element_struct *)mem_static_malloc(12);
}
qbs *_FUNC_WHATISMYIP_STRING_X=NULL;
if (!_FUNC_WHATISMYIP_STRING_X)_FUNC_WHATISMYIP_STRING_X=qbs_new(0,0);
byte_element_struct *byte_element_3=NULL;
if (!byte_element_3){
if ((mem_static_pointer+=12)<mem_static_limit) byte_element_3=(byte_element_struct*)(mem_static_pointer-12); else byte_element_3=(byte_element_struct*)mem_static_malloc(12);
qbs *_FUNC_WHATISMYIP_STRING_X = NULL;
if (!_FUNC_WHATISMYIP_STRING_X)
_FUNC_WHATISMYIP_STRING_X = qbs_new(0, 0);
byte_element_struct *byte_element_3 = NULL;
if (!byte_element_3) {
if ((mem_static_pointer += 12) < mem_static_limit)
byte_element_3 = (byte_element_struct *)(mem_static_pointer - 12);
else
byte_element_3 = (byte_element_struct *)mem_static_malloc(12);
}
float *_FUNC_WHATISMYIP_SINGLE_T=NULL;
if(_FUNC_WHATISMYIP_SINGLE_T==NULL){
_FUNC_WHATISMYIP_SINGLE_T=(float*)mem_static_malloc(4);
*_FUNC_WHATISMYIP_SINGLE_T=0;
float *_FUNC_WHATISMYIP_SINGLE_T = NULL;
if (_FUNC_WHATISMYIP_SINGLE_T == NULL) {
_FUNC_WHATISMYIP_SINGLE_T = (float *)mem_static_malloc(4);
*_FUNC_WHATISMYIP_SINGLE_T = 0;
}
qbs *_FUNC_WHATISMYIP_STRING_A2=NULL;
if (!_FUNC_WHATISMYIP_STRING_A2)_FUNC_WHATISMYIP_STRING_A2=qbs_new(0,0);
qbs *_FUNC_WHATISMYIP_STRING_A=NULL;
if (!_FUNC_WHATISMYIP_STRING_A)_FUNC_WHATISMYIP_STRING_A=qbs_new(0,0);
float *_FUNC_WHATISMYIP_SINGLE_L=NULL;
if(_FUNC_WHATISMYIP_SINGLE_L==NULL){
_FUNC_WHATISMYIP_SINGLE_L=(float*)mem_static_malloc(4);
*_FUNC_WHATISMYIP_SINGLE_L=0;
qbs *_FUNC_WHATISMYIP_STRING_A2 = NULL;
if (!_FUNC_WHATISMYIP_STRING_A2)
_FUNC_WHATISMYIP_STRING_A2 = qbs_new(0, 0);
qbs *_FUNC_WHATISMYIP_STRING_A = NULL;
if (!_FUNC_WHATISMYIP_STRING_A)
_FUNC_WHATISMYIP_STRING_A = qbs_new(0, 0);
float *_FUNC_WHATISMYIP_SINGLE_L = NULL;
if (_FUNC_WHATISMYIP_SINGLE_L == NULL) {
_FUNC_WHATISMYIP_SINGLE_L = (float *)mem_static_malloc(4);
*_FUNC_WHATISMYIP_SINGLE_L = 0;
}
float *_FUNC_WHATISMYIP_SINGLE_I=NULL;
if(_FUNC_WHATISMYIP_SINGLE_I==NULL){
_FUNC_WHATISMYIP_SINGLE_I=(float*)mem_static_malloc(4);
*_FUNC_WHATISMYIP_SINGLE_I=0;
float *_FUNC_WHATISMYIP_SINGLE_I = NULL;
if (_FUNC_WHATISMYIP_SINGLE_I == NULL) {
_FUNC_WHATISMYIP_SINGLE_I = (float *)mem_static_malloc(4);
*_FUNC_WHATISMYIP_SINGLE_I = 0;
}
float *_FUNC_WHATISMYIP_SINGLE_I2=NULL;
if(_FUNC_WHATISMYIP_SINGLE_I2==NULL){
_FUNC_WHATISMYIP_SINGLE_I2=(float*)mem_static_malloc(4);
*_FUNC_WHATISMYIP_SINGLE_I2=0;
float *_FUNC_WHATISMYIP_SINGLE_I2 = NULL;
if (_FUNC_WHATISMYIP_SINGLE_I2 == NULL) {
_FUNC_WHATISMYIP_SINGLE_I2 = (float *)mem_static_malloc(4);
*_FUNC_WHATISMYIP_SINGLE_I2 = 0;
}
byte_element_struct *byte_element_5=NULL;
if (!byte_element_5){
if ((mem_static_pointer+=12)<mem_static_limit) byte_element_5=(byte_element_struct*)(mem_static_pointer-12); else byte_element_5=(byte_element_struct*)mem_static_malloc(12);
byte_element_struct *byte_element_5 = NULL;
if (!byte_element_5) {
if ((mem_static_pointer += 12) < mem_static_limit)
byte_element_5 = (byte_element_struct *)(mem_static_pointer - 12);
else
byte_element_5 = (byte_element_struct *)mem_static_malloc(12);
}
// end of "data1.txt
mem_lock *sf_mem_lock;
new_mem_lock();
sf_mem_lock=mem_lock_tmp;
sf_mem_lock->type=3;
if (new_error) goto exit_subfunc;
qbs_set(_FUNC_WHATISMYIP_STRING_URL,qbs_new_txt_len("www.qb64.org/ip.php",19));
qbs_cleanup(qbs_tmp_base,0);
qbs_set(_FUNC_WHATISMYIP_STRING_URL2,_FUNC_WHATISMYIP_STRING_URL);
qbs_cleanup(qbs_tmp_base,0);
*_FUNC_WHATISMYIP_SINGLE_X=func_instr(NULL,_FUNC_WHATISMYIP_STRING_URL2,qbs_new_txt_len("/",1),0);
qbs_cleanup(qbs_tmp_base,0);
if ((*_FUNC_WHATISMYIP_SINGLE_X)||new_error){
qbs_set(_FUNC_WHATISMYIP_STRING_URL2,qbs_left(_FUNC_WHATISMYIP_STRING_URL,qbr(*_FUNC_WHATISMYIP_SINGLE_X- 1 )));
qbs_cleanup(qbs_tmp_base,0);
sf_mem_lock = mem_lock_tmp;
sf_mem_lock->type = 3;
if (new_error)
goto exit_subfunc;
qbs_set(_FUNC_WHATISMYIP_STRING_URL,
qbs_new_txt_len("www.qb64.org/ip.php", 19));
qbs_cleanup(qbs_tmp_base, 0);
qbs_set(_FUNC_WHATISMYIP_STRING_URL2, _FUNC_WHATISMYIP_STRING_URL);
qbs_cleanup(qbs_tmp_base, 0);
*_FUNC_WHATISMYIP_SINGLE_X = func_instr(NULL, _FUNC_WHATISMYIP_STRING_URL2,
qbs_new_txt_len("/", 1), 0);
qbs_cleanup(qbs_tmp_base, 0);
if ((*_FUNC_WHATISMYIP_SINGLE_X) || new_error) {
qbs_set(_FUNC_WHATISMYIP_STRING_URL2,
qbs_left(_FUNC_WHATISMYIP_STRING_URL,
qbr(*_FUNC_WHATISMYIP_SINGLE_X - 1)));
qbs_cleanup(qbs_tmp_base, 0);
}
*_FUNC_WHATISMYIP_SINGLE_CLIENT=func__openclient(qbs_add(qbs_new_txt_len("TCP/IP:80:",10),_FUNC_WHATISMYIP_STRING_URL2));
qbs_cleanup(qbs_tmp_base,0);
if ((-(*_FUNC_WHATISMYIP_SINGLE_CLIENT== 0 ))||new_error){
*_FUNC_WHATISMYIP_SINGLE_CLIENT = func__openclient(qbs_add(
qbs_new_txt_len("TCP/IP:80:", 10), _FUNC_WHATISMYIP_STRING_URL2));
qbs_cleanup(qbs_tmp_base, 0);
if ((-(*_FUNC_WHATISMYIP_SINGLE_CLIENT == 0)) || new_error) {
goto exit_subfunc;
}
qbs_set(_FUNC_WHATISMYIP_STRING_E,qbs_add(func_chr( 13 ),func_chr( 10 )));
qbs_cleanup(qbs_tmp_base,0);
qbs_set(_FUNC_WHATISMYIP_STRING_URL3,qbs_right(_FUNC_WHATISMYIP_STRING_URL,qbr(_FUNC_WHATISMYIP_STRING_URL->len-*_FUNC_WHATISMYIP_SINGLE_X+ 1 )));
qbs_cleanup(qbs_tmp_base,0);
qbs_set(_FUNC_WHATISMYIP_STRING_X,qbs_add(qbs_add(qbs_add(qbs_new_txt_len("GET ",4),_FUNC_WHATISMYIP_STRING_URL3),qbs_new_txt_len(" HTTP/1.1",9)),_FUNC_WHATISMYIP_STRING_E));
qbs_cleanup(qbs_tmp_base,0);
qbs_set(_FUNC_WHATISMYIP_STRING_X,qbs_add(qbs_add(qbs_add(qbs_add(_FUNC_WHATISMYIP_STRING_X,qbs_new_txt_len("Host: ",6)),_FUNC_WHATISMYIP_STRING_URL2),_FUNC_WHATISMYIP_STRING_E),_FUNC_WHATISMYIP_STRING_E));
qbs_cleanup(qbs_tmp_base,0);
sub_put2(qbr(*_FUNC_WHATISMYIP_SINGLE_CLIENT),NULL,byte_element((uint64)_FUNC_WHATISMYIP_STRING_X->chr,_FUNC_WHATISMYIP_STRING_X->len,byte_element_3),0);
qbs_cleanup(qbs_tmp_base,0);
*_FUNC_WHATISMYIP_SINGLE_T=func_timer(NULL,0);
do{
sub__delay( 0.05E+0 );
sub_get2(qbr(*_FUNC_WHATISMYIP_SINGLE_CLIENT),NULL,_FUNC_WHATISMYIP_STRING_A2,0);
qbs_cleanup(qbs_tmp_base,0);
qbs_set(_FUNC_WHATISMYIP_STRING_A,qbs_add(_FUNC_WHATISMYIP_STRING_A,_FUNC_WHATISMYIP_STRING_A2));
qbs_cleanup(qbs_tmp_base,0);
if ((-(*_FUNC_WHATISMYIP_SINGLE_L== 0 ))||new_error){
*_FUNC_WHATISMYIP_SINGLE_I=func_instr(NULL,_FUNC_WHATISMYIP_STRING_A,qbs_add(_FUNC_WHATISMYIP_STRING_E,_FUNC_WHATISMYIP_STRING_E),0);
qbs_cleanup(qbs_tmp_base,0);
if ((*_FUNC_WHATISMYIP_SINGLE_I)||new_error){
*_FUNC_WHATISMYIP_SINGLE_I2=func_instr(qbr(*_FUNC_WHATISMYIP_SINGLE_I+ 4 ),_FUNC_WHATISMYIP_STRING_A,_FUNC_WHATISMYIP_STRING_E,1);
qbs_cleanup(qbs_tmp_base,0);
if ((*_FUNC_WHATISMYIP_SINGLE_I2)||new_error){
*_FUNC_WHATISMYIP_SINGLE_L=func_val(qbs_add(qbs_new_txt_len("&H",2),func_mid(_FUNC_WHATISMYIP_STRING_A,qbr(*_FUNC_WHATISMYIP_SINGLE_I+ 4 ),qbr(*_FUNC_WHATISMYIP_SINGLE_I2-*_FUNC_WHATISMYIP_SINGLE_I- 2 ),1)));
qbs_cleanup(qbs_tmp_base,0);
qbs_set(_FUNC_WHATISMYIP_STRING_A,func_mid(_FUNC_WHATISMYIP_STRING_A,qbr(*_FUNC_WHATISMYIP_SINGLE_I+ 4 +*_FUNC_WHATISMYIP_SINGLE_I2-*_FUNC_WHATISMYIP_SINGLE_I- 2 ),NULL,0));
qbs_cleanup(qbs_tmp_base,0);
qbs_set(_FUNC_WHATISMYIP_STRING_E, qbs_add(func_chr(13), func_chr(10)));
qbs_cleanup(qbs_tmp_base, 0);
qbs_set(_FUNC_WHATISMYIP_STRING_URL3,
qbs_right(_FUNC_WHATISMYIP_STRING_URL,
qbr(_FUNC_WHATISMYIP_STRING_URL->len -
*_FUNC_WHATISMYIP_SINGLE_X + 1)));
qbs_cleanup(qbs_tmp_base, 0);
qbs_set(_FUNC_WHATISMYIP_STRING_X,
qbs_add(qbs_add(qbs_add(qbs_new_txt_len("GET ", 4),
_FUNC_WHATISMYIP_STRING_URL3),
qbs_new_txt_len(" HTTP/1.1", 9)),
_FUNC_WHATISMYIP_STRING_E));
qbs_cleanup(qbs_tmp_base, 0);
qbs_set(_FUNC_WHATISMYIP_STRING_X,
qbs_add(qbs_add(qbs_add(qbs_add(_FUNC_WHATISMYIP_STRING_X,
qbs_new_txt_len("Host: ", 6)),
_FUNC_WHATISMYIP_STRING_URL2),
_FUNC_WHATISMYIP_STRING_E),
_FUNC_WHATISMYIP_STRING_E));
qbs_cleanup(qbs_tmp_base, 0);
sub_put2(qbr(*_FUNC_WHATISMYIP_SINGLE_CLIENT), NULL,
byte_element((uint64)_FUNC_WHATISMYIP_STRING_X->chr,
_FUNC_WHATISMYIP_STRING_X->len, byte_element_3),
0);
qbs_cleanup(qbs_tmp_base, 0);
*_FUNC_WHATISMYIP_SINGLE_T = func_timer(NULL, 0);
do {
sub__delay(0.05E+0);
sub_get2(qbr(*_FUNC_WHATISMYIP_SINGLE_CLIENT), NULL,
_FUNC_WHATISMYIP_STRING_A2, 0);
qbs_cleanup(qbs_tmp_base, 0);
qbs_set(_FUNC_WHATISMYIP_STRING_A,
qbs_add(_FUNC_WHATISMYIP_STRING_A, _FUNC_WHATISMYIP_STRING_A2));
qbs_cleanup(qbs_tmp_base, 0);
if ((-(*_FUNC_WHATISMYIP_SINGLE_L == 0)) || new_error) {
*_FUNC_WHATISMYIP_SINGLE_I = func_instr(
NULL, _FUNC_WHATISMYIP_STRING_A,
qbs_add(_FUNC_WHATISMYIP_STRING_E, _FUNC_WHATISMYIP_STRING_E),
0);
qbs_cleanup(qbs_tmp_base, 0);
if ((*_FUNC_WHATISMYIP_SINGLE_I) || new_error) {
*_FUNC_WHATISMYIP_SINGLE_I2 = func_instr(
qbr(*_FUNC_WHATISMYIP_SINGLE_I + 4),
_FUNC_WHATISMYIP_STRING_A, _FUNC_WHATISMYIP_STRING_E, 1);
qbs_cleanup(qbs_tmp_base, 0);
if ((*_FUNC_WHATISMYIP_SINGLE_I2) || new_error) {
*_FUNC_WHATISMYIP_SINGLE_L = func_val(
qbs_add(qbs_new_txt_len("&H", 2),
func_mid(_FUNC_WHATISMYIP_STRING_A,
qbr(*_FUNC_WHATISMYIP_SINGLE_I + 4),
qbr(*_FUNC_WHATISMYIP_SINGLE_I2 -
*_FUNC_WHATISMYIP_SINGLE_I - 2),
1)));
qbs_cleanup(qbs_tmp_base, 0);
qbs_set(_FUNC_WHATISMYIP_STRING_A,
func_mid(_FUNC_WHATISMYIP_STRING_A,
qbr(*_FUNC_WHATISMYIP_SINGLE_I + 4 +
*_FUNC_WHATISMYIP_SINGLE_I2 -
*_FUNC_WHATISMYIP_SINGLE_I - 2),
NULL, 0));
qbs_cleanup(qbs_tmp_base, 0);
}
}
}else{
if ((qbs_cleanup(qbs_tmp_base,-(_FUNC_WHATISMYIP_STRING_A->len>=*_FUNC_WHATISMYIP_SINGLE_L)))||new_error){
qbs_set(_FUNC_WHATISMYIP_STRING_WHATISMYIP,qbs_left(_FUNC_WHATISMYIP_STRING_A,qbr(*_FUNC_WHATISMYIP_SINGLE_L)));
qbs_cleanup(qbs_tmp_base,0);
sub_close(qbr(*_FUNC_WHATISMYIP_SINGLE_CLIENT),1);
} else {
if ((qbs_cleanup(qbs_tmp_base, -(_FUNC_WHATISMYIP_STRING_A->len >=
*_FUNC_WHATISMYIP_SINGLE_L))) ||
new_error) {
qbs_set(_FUNC_WHATISMYIP_STRING_WHATISMYIP,
qbs_left(_FUNC_WHATISMYIP_STRING_A,
qbr(*_FUNC_WHATISMYIP_SINGLE_L)));
qbs_cleanup(qbs_tmp_base, 0);
sub_close(qbr(*_FUNC_WHATISMYIP_SINGLE_CLIENT), 1);
goto exit_subfunc;
}
}
dl_continue_4:;
}while((!(-(((float)((func_timer(NULL,0))))>((float)((*_FUNC_WHATISMYIP_SINGLE_T+ 5 ))))))&&(!new_error));
dl_exit_4:;
sub_close(qbr(*_FUNC_WHATISMYIP_SINGLE_CLIENT),1);
exit_subfunc:;
dl_continue_4:;
} while ((!(-(((float)((func_timer(NULL, 0)))) >
((float)((*_FUNC_WHATISMYIP_SINGLE_T + 5)))))) &&
(!new_error));
dl_exit_4:;
sub_close(qbr(*_FUNC_WHATISMYIP_SINGLE_CLIENT), 1);
exit_subfunc:;
free_mem_lock(sf_mem_lock);
// include "free1.txt"
@ -194,8 +257,13 @@ qbs* WHATISMYIP(){ //changed name from FUNC_WHATISMYIP to WHATISMYIP
qbs_free(_FUNC_WHATISMYIP_STRING_A2);
qbs_free(_FUNC_WHATISMYIP_STRING_A);
// end of "free1.txt"
if ((tmp_mem_static_pointer>=mem_static)&&(tmp_mem_static_pointer<=mem_static_limit)) mem_static_pointer=tmp_mem_static_pointer; else mem_static_pointer=mem_static;
cmem_sp=tmp_cmem_sp;
qbs_maketmp(_FUNC_WHATISMYIP_STRING_WHATISMYIP);return _FUNC_WHATISMYIP_STRING_WHATISMYIP;
if ((tmp_mem_static_pointer >= mem_static) &&
(tmp_mem_static_pointer <= mem_static_limit))
mem_static_pointer = tmp_mem_static_pointer;
else
mem_static_pointer = mem_static;
cmem_sp = tmp_cmem_sp;
qbs_maketmp(_FUNC_WHATISMYIP_STRING_WHATISMYIP);
return _FUNC_WHATISMYIP_STRING_WHATISMYIP;
}

File diff suppressed because it is too large Load diff