void Error::Quit() { fprintf(stdout,"\n"); #ifdef __WATCOMC__ INT3(); #endif #ifdef __MSVC__ INT3; #endif exit(1); }
//컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴컴 //Procedure KeyTrap //Author Paul. //Date Fri 13 Oct 1995 // //Description // //Inputs // //Returns // //------------------------------------------------------------------------------ void Error::KeyTrap() { char c; if(kbhit()) { c=getch()&0x00FF; if(c==' ') #ifdef __WATCOMC__ INT3(); #endif #ifdef __MSVC__ INT3; #endif } }
void Display::XX_SetGraphicsMode() { DPMIregs regs; regs.l.eax=regs.l.ebx=regs.l.ecx=regs.l.edx=0; regs.l.edi=regs.l.ebp=regs.l.esi=0; regs.w.ax=0x4f02; regs.w.cx=VESA.mode; regs.w.bx=VESA.mode; VESA.mode=-1; regs.w.di=0; ASM_DOSvia31(0x10,®s,real_mode_stack,REALMODE_STACK_SIZE,0); if (regs.w.ax!=0x004f) INT3(); regs.w.ax=0x4f06; regs.w.bx=0; regs.w.cx=VESA.BytesPerScanLine/VESA.BytesPerPixel; ASM_DOSvia31(0x10,®s,real_mode_stack,REALMODE_STACK_SIZE,0); }
Error& Error::ExitMode() { #ifdef __WATCOMC__ INT3(); #endif #ifdef __MSVC__ INT3; #endif //DAW 28Oct96 if (exitmsg==NULL) { exitmsg="ERROR! "; //TempCode DAW 19Nov96 TraceChain(0); //TempCode DAW 19Nov96 TrackMemUse(); } _Main.QuitGame(); fprintf(stdout, exitmsg); return *this; }
trixel_brick * _trixel_make_brick(int w, int h, int d, bool solid, char * * out_error_message) { trixel_brick * brick = malloc(sizeof(trixel_brick) + w*h*d); memset(brick, 0, sizeof(trixel_brick)); brick->v.dimensions = INT3(w, h, d); _set_brick_metrics(brick); uint8_t fill = solid ? 1 : 0; if(solid) memset(trixel_brick_palette_color(brick, 1), 0xFF, 4); memset(brick->v.data, fill, w * h * d); return brick; error: return NULL; }
static void arbfvp_make_vertex_buffer_for_brick(trixel_state t, trixel_brick * brick) { GLshort width2 = (GLshort)brick->v.dimensions.x / 2, height2 = (GLshort)brick->v.dimensions.y / 2, depth2 = (GLshort)brick->v.dimensions.z / 2; voxmap * mask = voxmap_maskify(&brick->v, 1), * xface, * xa, * yface, * ya, * zface, * za; struct int3 xdim = add_int3(mask->dimensions, INT3(1,0,0)), ydim = add_int3(mask->dimensions, INT3(0,1,0)), zdim = add_int3(mask->dimensions, INT3(0,0,1)); xa = voxmap_make(xdim); xface = voxmap_make(xdim); voxmap_fill_all(xa, 0); voxmap_fill_all(xface, 0); voxmap_copy(xa, INT3(0,0,0), mask); voxmap_copy(xface, INT3(1,0,0), mask); voxmap_sub (xface, xa); voxmap_free(xa); ya = voxmap_make(ydim); yface = voxmap_make(ydim); voxmap_fill_all(ya, 0); voxmap_fill_all(yface, 0); voxmap_copy(ya, INT3(0,0,0), mask); voxmap_copy(yface, INT3(0,1,0), mask); voxmap_sub (yface, ya); voxmap_free(ya); za = voxmap_make(zdim); zface = voxmap_make(zdim); voxmap_fill_all(za, 0); voxmap_fill_all(zface, 0); voxmap_copy(za, INT3(0,0,0), mask); voxmap_copy(zface, INT3(0,0,1), mask); voxmap_sub (zface, za); voxmap_free(za); voxmap_free(mask); int num_vertices = 4 * (voxmap_count(xface) + voxmap_count(yface) + voxmap_count(zface)), buffer_size = 3 * num_vertices * (sizeof(GLshort)+sizeof(GLbyte)); void * buffer = malloc(buffer_size); GLshort * vertices = buffer; GLbyte * normals = (GLbyte*)(vertices + num_vertices*3); for(int z = 0; z < xdim.z; ++z) for(int y = 0; y < xdim.y; ++y) for(int x = 0; x < xdim.x; ++x) if(*voxmap_voxel(xface, x, y, z) == 1) { vertices[ 0] = x -width2; vertices[ 1] = y+1-height2; vertices[ 2] = z -depth2; vertices[ 3] = x -width2; vertices[ 4] = y+1-height2; vertices[ 5] = z+1-depth2; vertices[ 6] = x -width2; vertices[ 7] = y -height2; vertices[ 8] = z+1-depth2; vertices[ 9] = x -width2; vertices[10] = y -height2; vertices[11] = z -depth2; vertices += 12; normals[ 0] = 127; normals[ 1] = 0; normals[ 2] = 0; normals[ 3] = 127; normals[ 4] = 0; normals[ 5] = 0; normals[ 6] = 127; normals[ 7] = 0; normals[ 8] = 0; normals[ 9] = 127; normals[10] = 0; normals[11] = 0; normals += 12; } else if(*voxmap_voxel(xface, x, y, z) == (uint8_t)-1) { vertices[ 0] = x -width2; vertices[ 1] = y -height2; vertices[ 2] = z -depth2; vertices[ 3] = x -width2; vertices[ 4] = y -height2; vertices[ 5] = z+1-depth2; vertices[ 6] = x -width2; vertices[ 7] = y+1-height2; vertices[ 8] = z+1-depth2; vertices[ 9] = x -width2; vertices[10] = y+1-height2; vertices[11] = z -depth2; vertices += 12; normals[ 0] = -128; normals[ 1] = 0; normals[ 2] = 0; normals[ 3] = -128; normals[ 4] = 0; normals[ 5] = 0; normals[ 6] = -128; normals[ 7] = 0; normals[ 8] = 0; normals[ 9] = -128; normals[10] = 0; normals[11] = 0; normals += 12; } for(int z = 0; z < ydim.z; ++z) for(int y = 0; y < ydim.y; ++y) for(int x = 0; x < ydim.x; ++x) if(*voxmap_voxel(yface, x, y, z) == 1) { vertices[ 0] = x -width2; vertices[ 1] = y -height2; vertices[ 2] = z+1-depth2; vertices[ 3] = x+1-width2; vertices[ 4] = y -height2; vertices[ 5] = z+1-depth2; vertices[ 6] = x+1-width2; vertices[ 7] = y -height2; vertices[ 8] = z -depth2; vertices[ 9] = x -width2; vertices[10] = y -height2; vertices[11] = z -depth2; vertices += 12; normals[ 0] = 0; normals[ 1] = 127; normals[ 2] = 0; normals[ 3] = 0; normals[ 4] = 127; normals[ 5] = 0; normals[ 6] = 0; normals[ 7] = 127; normals[ 8] = 0; normals[ 9] = 0; normals[10] = 127; normals[11] = 0; normals += 12; } else if(*voxmap_voxel(yface, x, y, z) == (uint8_t)-1) { vertices[ 0] = x -width2; vertices[ 1] = y -height2; vertices[ 2] = z -depth2; vertices[ 3] = x+1-width2; vertices[ 4] = y -height2; vertices[ 5] = z -depth2; vertices[ 6] = x+1-width2; vertices[ 7] = y -height2; vertices[ 8] = z+1-depth2; vertices[ 9] = x -width2; vertices[10] = y -height2; vertices[11] = z+1-depth2; vertices += 12; normals[ 0] = 0; normals[ 1] = -128; normals[ 2] = 0; normals[ 3] = 0; normals[ 4] = -128; normals[ 5] = 0; normals[ 6] = 0; normals[ 7] = -128; normals[ 8] = 0; normals[ 9] = 0; normals[10] = -128; normals[11] = 0; normals += 12; } for(int z = 0; z < zdim.z; ++z) for(int y = 0; y < zdim.y; ++y) for(int x = 0; x < zdim.x; ++x) if(*voxmap_voxel(zface, x, y, z) == 1) { vertices[ 0] = x+1-width2; vertices[ 1] = y -height2; vertices[ 2] = z -depth2; vertices[ 3] = x+1-width2; vertices[ 4] = y+1-height2; vertices[ 5] = z -depth2; vertices[ 6] = x -width2; vertices[ 7] = y+1-height2; vertices[ 8] = z -depth2; vertices[ 9] = x -width2; vertices[10] = y -height2; vertices[11] = z -depth2; vertices += 12; normals[ 0] = 0; normals[ 1] = 0; normals[ 2] = 127; normals[ 3] = 0; normals[ 4] = 0; normals[ 5] = 127; normals[ 6] = 0; normals[ 7] = 0; normals[ 8] = 127; normals[ 9] = 0; normals[10] = 0; normals[11] = 127; normals += 12; } else if(*voxmap_voxel(zface, x, y, z) == (uint8_t)-1) { vertices[ 0] = x -width2; vertices[ 1] = y -height2; vertices[ 2] = z -depth2; vertices[ 3] = x -width2; vertices[ 4] = y+1-height2; vertices[ 5] = z -depth2; vertices[ 6] = x+1-width2; vertices[ 7] = y+1-height2; vertices[ 8] = z -depth2; vertices[ 9] = x+1-width2; vertices[10] = y -height2; vertices[11] = z -depth2; vertices += 12; normals[ 0] = 0; normals[ 1] = 0; normals[ 2] = -128; normals[ 3] = 0; normals[ 4] = 0; normals[ 5] = -128; normals[ 6] = 0; normals[ 7] = 0; normals[ 8] = -128; normals[ 9] = 0; normals[10] = 0; normals[11] = -128; normals += 12; } voxmap_free(xface); voxmap_free(yface); voxmap_free(zface); glGenBuffers(1, &brick->vertex_buffer); glBindBuffer(GL_ARRAY_BUFFER, brick->vertex_buffer); glBufferData(GL_ARRAY_BUFFER, buffer_size, buffer, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); free(buffer); brick->num_vertices = num_vertices; }
SPtr<ocTriTree> ocTriTree::create(const z3D::Core::AABB& aabb) { vector<Vec3> array_vert; vector<INT3> array_tri; array_vert.push_back(aabb.getCorner(0)); array_vert.push_back(aabb.getCorner(1)); array_vert.push_back(aabb.getCorner(2)); array_vert.push_back(aabb.getCorner(3)); array_vert.push_back(aabb.getCorner(4)); array_vert.push_back(aabb.getCorner(5)); array_vert.push_back(aabb.getCorner(6)); array_vert.push_back(aabb.getCorner(7)); array_tri.push_back(INT3(0, 2, 1)); array_tri.push_back(INT3(1, 2, 3)); array_tri.push_back(INT3(4, 6, 0)); array_tri.push_back(INT3(0, 6, 2)); array_tri.push_back(INT3(4, 0, 1)); array_tri.push_back(INT3(4, 1, 5)); array_tri.push_back(INT3(7, 2, 6)); array_tri.push_back(INT3(7, 3, 2)); array_tri.push_back(INT3(4, 7, 6)); array_tri.push_back(INT3(4, 5, 7)); array_tri.push_back(INT3(5, 3, 7)); array_tri.push_back(INT3(5, 1, 3)); return create(VECTOR_BEGIN_PTR(array_vert), array_vert.size(), VECTOR_BEGIN_PTR(array_tri), array_tri.size()); }
trixel_brick * trixel_read_brick(const void * data, size_t data_length, char * * out_error_message) { const uint8_t * byte_data = (const uint8_t *)data; struct brick_header * header = (struct brick_header *)data; if(data_length < sizeof(struct brick_header)) { asprintf(out_error_message, "Brick data is not big enough for a header.\n" "(got size %u, expected header size %u)", data_length, sizeof(struct brick_header) ); goto error; } if(strncmp(header->magic, BRICK_MAGIC, 4) != 0) { asprintf(out_error_message, "Brick data is not in brick format.\n" "(got magic '%4s', expected magic '%4s')", header->magic, BRICK_MAGIC ); goto error; } if(header->colors > 255) { asprintf(out_error_message, "Brick claims to have more than 255 colors.\n" "(got %u colors)", header->colors ); goto error; } size_t palette_offset = sizeof(struct brick_header), palette_length = 4 * (size_t)header->colors, voxmap_offset = palette_offset + palette_length, voxmap_length = (size_t)header->width * (size_t)header->height * (size_t)header->depth, total_length = sizeof(struct brick_header) + palette_length + voxmap_length; if(data_length < total_length) { asprintf(out_error_message, "Brick data is smaller than it claims to be.\n" "(got length %u, expected length %u)", data_length, total_length ); goto error; } trixel_brick * brick = malloc(sizeof(trixel_brick) + header->width * header->height * header->depth); memset(brick, 0, sizeof(trixel_brick)); brick->v.dimensions = INT3(header->width, header->height, header->depth); _set_brick_metrics(brick); memcpy(brick->palette_data + 4, byte_data + palette_offset, palette_length); memcpy(brick->v.data, byte_data + voxmap_offset, voxmap_length); return brick; error: return NULL; }