Hi guys. I spended all day for listening podcasts about japan live. I want to go to japan, if you want to sponsor me you can send me money(for more information chat via icq:444220842) :) or give me freelance work(rails, asp.net, java or other technologies, preference to c/c++ qt job) :)
See you later.
воскресенье, 22 июня 2008 г.
среда, 18 июня 2008 г.
Display flickr images using javascript.
Type.registerNamespace("Voodoo");
Voodoo.FlickrImages = function(element) {
Voodoo.FlickrImages.initializeBase(this, [element]);
this._numberOfPages = 0;
this._currentItem = 17;
this._maxItems = 0;
this._xml = null;
}
Voodoo.FlickrImages.prototype = {
initialize: function() {
Voodoo.FlickrImages.callBaseMethod(this, 'initialize');
$addHandler(this._prevButton, 'click', Function.createDelegate(this, this.onPrevButtonClick));
$addHandler(this._nextButton, 'click', Function.createDelegate(this, this.onNextButtonClick));
/// url for getting feeds from flickr with urls and titles to images.
Proxy.GetXml("http://api.flickr.com/services/feeds/photos_public.gne", 600,
Function.createDelegate(this, this.onGetXmlSuccess),
Function.createDelegate(this, this.onGetXmlFailure),
this);
},
dispose: function() {
Voodoo.FlickrImages.callBaseMethod(this, 'dispose');
},
onGetXmlSuccess : function(result, context, methodName) {
this._xml = result;
this._maxItems = this._xml.getElementsByTagName('feed').item(0).childNodes.length - 17 / 2;
this.reloadImage();
},
onGetXmlFailure : function(error) {
},
onPrevButtonClick : function(e) {
if (this._currentItem != 17)
{
this._currentItem -= 2;
this.reloadImage();
}
},
onNextButtonClick : function(e) {
if (this._currentItem != this._maxItems)
{
this._currentItem += 2;
this.reloadImage();
}
},
reloadImage : function() {
this._imagesPanel.innerHTML = "
},
get_ImagesPanel : function() {
return this._imagesPanel;
},
set_ImagesPanel : function(value) {
this._imagesPanel = value;
},
get_PrevButton : function() {
return this._prevButton;
},
set_PrevButton : function(value) {
this._prevButton = value;
},
get_NextButton : function() {
return this._nextButton;
},
set_NextButton : function(value) {
this._nextButton = value;
},
get_NumberOfPages : function() {
return this._numberOfPages;
},
set_NumberOfPages : function(value) {
this._numberOfPages = value;
}
}
Voodoo.FlickrImages.registerClass('Voodoo.FlickrImages', Sys.UI.Control);
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
Voodoo.FlickrImages = function(element) {
Voodoo.FlickrImages.initializeBase(this, [element]);
this._numberOfPages = 0;
this._currentItem = 17;
this._maxItems = 0;
this._xml = null;
}
Voodoo.FlickrImages.prototype = {
initialize: function() {
Voodoo.FlickrImages.callBaseMethod(this, 'initialize');
$addHandler(this._prevButton, 'click', Function.createDelegate(this, this.onPrevButtonClick));
$addHandler(this._nextButton, 'click', Function.createDelegate(this, this.onNextButtonClick));
/// url for getting feeds from flickr with urls and titles to images.
Proxy.GetXml("http://api.flickr.com/services/feeds/photos_public.gne", 600,
Function.createDelegate(this, this.onGetXmlSuccess),
Function.createDelegate(this, this.onGetXmlFailure),
this);
},
dispose: function() {
Voodoo.FlickrImages.callBaseMethod(this, 'dispose');
},
onGetXmlSuccess : function(result, context, methodName) {
this._xml = result;
this._maxItems = this._xml.getElementsByTagName('feed').item(0).childNodes.length - 17 / 2;
this.reloadImage();
},
onGetXmlFailure : function(error) {
},
onPrevButtonClick : function(e) {
if (this._currentItem != 17)
{
this._currentItem -= 2;
this.reloadImage();
}
},
onNextButtonClick : function(e) {
if (this._currentItem != this._maxItems)
{
this._currentItem += 2;
this.reloadImage();
}
},
reloadImage : function() {
this._imagesPanel.innerHTML = "
" + this._xml.getElementsByTagName('feed').item(0).childNodes.item(this._currentItem).childNodes.item(13).textContent + "
";},
get_ImagesPanel : function() {
return this._imagesPanel;
},
set_ImagesPanel : function(value) {
this._imagesPanel = value;
},
get_PrevButton : function() {
return this._prevButton;
},
set_PrevButton : function(value) {
this._prevButton = value;
},
get_NextButton : function() {
return this._nextButton;
},
set_NextButton : function(value) {
this._nextButton = value;
},
get_NumberOfPages : function() {
return this._numberOfPages;
},
set_NumberOfPages : function(value) {
this._numberOfPages = value;
}
}
Voodoo.FlickrImages.registerClass('Voodoo.FlickrImages', Sys.UI.Control);
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
вторник, 17 июня 2008 г.
Write simple expander for text area(Very simple effect).
Today I started to recollect my knowledge in javascript and for simple training I wrote expander for html element textarea.
// library/expander.js
expander = {
_init : function() {
var elements = document.getElementsByTagName('textarea');
for(var i = 0; i < elements.length; i++)
{
var area = elements[i];
if (area.className.search(/\bexpander\b/) != -1)
{
expander.addActions(area);
}
}
},
addActions : function(area) {
area._rows = area.rows;
area._cols = area.cols;
area.onkeyup = expander._onkeyup;
area.onfocus = expander._onfocus;
},
_onkeyup : function(e) {
var area = e.target;
if ((area.value.length - area.rows) / area.cols > area.rows)
{
var count = (area.value.length - area.rows) / (area.cols * area.rows);
var lines = area.value.split('\n');
var line = lines[lines.length - 1];
if (line.length > area.cols)
{
var n = Math.floor(line.length / area.cols);
for(var i = 0; i < n; i++)
{
lines[lines.length - 1 + i] = line.substring(0, area.cols);
line = line.substring(area.cols, line.length);
}
if (line.length != 0)
{
lines[lines.length - 1 + i] = line;
}
area.value = lines.join('\n');
}
else
{
area.value += '\n';
}
area.rows += count;
}
else
{
if (area.value.length + area.cols <= area.cols * area.rows)
{
var count = area.cols * area.rows / (area.value.length + area.cols);
area.rows -= count - 1;
}
}
area._rows = area.rows;
area._cols = area.cols;
},
_onfocus : function(e) {
var area = e.target;
area.rows = area._rows;
area.cols = area._cols;
}
};
window.onload = expander._init;
// test.html
.html.
.head.
.title. Test page ./title.
.script. type="text/javascript" language="javascript" src="library/expander.js"../script.
./head.
.body.
.textarea id="area1" class="simple-text expander" rows="1" cols="20"../textarea.
.textarea id="area2" class="simple-text expander" rows="1" cols="20"../textarea.
./body.
./html.
// library/expander.js
expander = {
_init : function() {
var elements = document.getElementsByTagName('textarea');
for(var i = 0; i < elements.length; i++)
{
var area = elements[i];
if (area.className.search(/\bexpander\b/) != -1)
{
expander.addActions(area);
}
}
},
addActions : function(area) {
area._rows = area.rows;
area._cols = area.cols;
area.onkeyup = expander._onkeyup;
area.onfocus = expander._onfocus;
},
_onkeyup : function(e) {
var area = e.target;
if ((area.value.length - area.rows) / area.cols > area.rows)
{
var count = (area.value.length - area.rows) / (area.cols * area.rows);
var lines = area.value.split('\n');
var line = lines[lines.length - 1];
if (line.length > area.cols)
{
var n = Math.floor(line.length / area.cols);
for(var i = 0; i < n; i++)
{
lines[lines.length - 1 + i] = line.substring(0, area.cols);
line = line.substring(area.cols, line.length);
}
if (line.length != 0)
{
lines[lines.length - 1 + i] = line;
}
area.value = lines.join('\n');
}
else
{
area.value += '\n';
}
area.rows += count;
}
else
{
if (area.value.length + area.cols <= area.cols * area.rows)
{
var count = area.cols * area.rows / (area.value.length + area.cols);
area.rows -= count - 1;
}
}
area._rows = area.rows;
area._cols = area.cols;
},
_onfocus : function(e) {
var area = e.target;
area.rows = area._rows;
area.cols = area._cols;
}
};
window.onload = expander._init;
// test.html
.html.
.head.
.title. Test page ./title.
.script. type="text/javascript" language="javascript" src="library/expander.js"../script.
./head.
.body.
.textarea id="area1" class="simple-text expander" rows="1" cols="20"../textarea.
.textarea id="area2" class="simple-text expander" rows="1" cols="20"../textarea.
./body.
./html.
понедельник, 16 июня 2008 г.
Music of the day
Slipknot (sic)
Poison for my brain)) such as sharepoint.
---
Today I found very good information about audit in sharepoint,
for more information :) see
http://www.microsoft.com/Rus/Msdn/publish/articles/bb397403.mspx
Poison for my brain)) such as sharepoint.
---
Today I found very good information about audit in sharepoint,
for more information :) see
http://www.microsoft.com/Rus/Msdn/publish/articles/bb397403.mspx
3 exam is approved by lecturer
It's beatifull day today)). Now I'll start to prepare for my evening basketball because 3 examination is approved.
суббота, 14 июня 2008 г.
exams))
Now I'm preparing for my exams. I try to inside out learn all having information about politology, sometimes I'm parsing wiki for additional knowlegdes but I haven't time, aaaa what do I have to do???
пятница, 13 июня 2008 г.
Information for anonymous readers.)
You might have noticed that my blog are writting with long break and sometimes with extrimly posting information(such as that day). Now I'm studing and have't time to write more pretty post. But фs soon as the opportunity I'll start to type more intresting and .NET article)).
The day after tomorrow)
Today I take my first task in new project.
M: "Go to read books about features in SharePoint;)"
One of the most abilities given to me that's chance working with ASP.NET and javascript, css and other crap) as you know it's black line for me.
M: "Go to read books about features in SharePoint;)"
One of the most abilities given to me that's chance working with ASP.NET and javascript, css and other crap) as you know it's black line for me.
Please approve my death.
Now I'm sitting on new project about 3 days.
1 day - Aaahhh, My death is so closely;) (I started to learn share point technologies:)).
2 day - all tired, we are alone in this cruel world.
3 day - I feel good, 6 hours and I'm going to sugar holiday.
1 day - Aaahhh, My death is so closely;) (I started to learn share point technologies:)).
2 day - all tired, we are alone in this cruel world.
3 day - I feel good, 6 hours and I'm going to sugar holiday.
четверг, 22 мая 2008 г.
Class for parsing 3ds file.
After googling I found information about 3ds format and proved that it is so simple.
// OGLObject.h
#pragma once
#define MAX_VERTEXES 80000
#define MAX_POLYGONS 80000
#define MAX_NAME_SIZE 20
typedef struct VertextTypeStruct {
float x;
float y;
float z;
} VertexType;
typedef struct PolygonTypeStruct {
int a;
int b;
int c;
} PolygonType;
typedef struct MapCoordinatesStruct {
float u;
float v;
} MapCoordinates;
//
// Create for one 3ds file
//
class OGLObject
{
public:
OGLObject();
~OGLObject();
char * name() const;
int id() const;
VertexType * vertexes( ) const;
PolygonType * polygons( ) const;
public:
int load3DS( char * filename );
int loadTexture( char * filename );
private:
char * m_name;
int m_countOfVertex;
int m_countOfPolygons;
VertexType * m_vertexes;
PolygonType * m_polygons;
MapCoordinates * m_mapCoordinates;
int m_idTexture;
};
// OGLObject.cpp
int OGLObject::load3DS(char *filename)
{
int i;
FILE * l_file = fopen( filename, "rb" );
if (l_file == NULL)
{
return 0;
} // File could't be found
unsigned short l_chunkId;
unsigned int l_chunkLength;
unsigned char l_char;
unsigned short l_quantity;
unsigned short l_faceFlags;
while( ftell( l_file ) < filelength( fileno( l_file ) ) )
{
fread( &l_chunkId, 2, 1, l_file );
fread( &l_chunkLength, 4, 1, l_file );
switch( l_chunkId )
{
case 0x4d4d: // MAIN CHUNK
break;
case 0x3d3d: // 3D EDITOR CHUNK
break;
case 0x4000: // OBJECT BLOCK
// Parse name of object
i = 0;
do
{
fread( &l_char, 1, 1, l_file );
m_name[i] = l_char;
i++;
} while (l_char != '\0' && i < 20);
break;
case 0x4100: // EMPTY chunk
break;
case 0x4110: // VERTICES LIST
fread( &l_quantity, sizeof( unsigned short ), 1, l_file );
m_countOfVertex = l_quantity;
for(i = 0; i < l_quantity; i++)
{
fread( &m_vertexes[i].x, sizeof( float ), 1, l_file );
fread( &m_vertexes[i].y, sizeof( float ), 1, l_file );
fread( &m_vertexes[i].z, sizeof( float ), 1, l_file );
}
break;
case 0x4120:
fread( &l_quantity, sizeof( unsigned short ), 1, l_file );
m_countOfPolygons = l_quantity;
for(i = 0; i < l_quantity; i++)
{
fread( &m_polygons[i].a, sizeof( unsigned short ), 1, l_file );
fread( &m_polygons[i].b, sizeof( unsigned short ), 1, l_file );
fread( &m_polygons[i].c, sizeof( unsigned short ), 1, l_file );
fread( &l_faceFlags, sizeof( float ), 1, l_file );
}
break;
case 0x4140:
fread ( &l_quantity, sizeof (unsigned short), 1, l_file);
for (i = 0; i < l_quantity; i++)
{
fread (&m_mapCoordinates[i].u, sizeof (float), 1, l_file);
fread (&m_mapCoordinates[i].v, sizeof (float), 1, l_file);
}
break;
default:
fseek( l_file, l_chunkLength - 6, SEEK_CUR );
}
}
fclose( l_file );
return 1;
}
// OGLObject.h
#pragma once
#define MAX_VERTEXES 80000
#define MAX_POLYGONS 80000
#define MAX_NAME_SIZE 20
typedef struct VertextTypeStruct {
float x;
float y;
float z;
} VertexType;
typedef struct PolygonTypeStruct {
int a;
int b;
int c;
} PolygonType;
typedef struct MapCoordinatesStruct {
float u;
float v;
} MapCoordinates;
//
// Create for one 3ds file
//
class OGLObject
{
public:
OGLObject();
~OGLObject();
char * name() const;
int id() const;
VertexType * vertexes( ) const;
PolygonType * polygons( ) const;
public:
int load3DS( char * filename );
int loadTexture( char * filename );
private:
char * m_name;
int m_countOfVertex;
int m_countOfPolygons;
VertexType * m_vertexes;
PolygonType * m_polygons;
MapCoordinates * m_mapCoordinates;
int m_idTexture;
};
// OGLObject.cpp
int OGLObject::load3DS(char *filename)
{
int i;
FILE * l_file = fopen( filename, "rb" );
if (l_file == NULL)
{
return 0;
} // File could't be found
unsigned short l_chunkId;
unsigned int l_chunkLength;
unsigned char l_char;
unsigned short l_quantity;
unsigned short l_faceFlags;
while( ftell( l_file ) < filelength( fileno( l_file ) ) )
{
fread( &l_chunkId, 2, 1, l_file );
fread( &l_chunkLength, 4, 1, l_file );
switch( l_chunkId )
{
case 0x4d4d: // MAIN CHUNK
break;
case 0x3d3d: // 3D EDITOR CHUNK
break;
case 0x4000: // OBJECT BLOCK
// Parse name of object
i = 0;
do
{
fread( &l_char, 1, 1, l_file );
m_name[i] = l_char;
i++;
} while (l_char != '\0' && i < 20);
break;
case 0x4100: // EMPTY chunk
break;
case 0x4110: // VERTICES LIST
fread( &l_quantity, sizeof( unsigned short ), 1, l_file );
m_countOfVertex = l_quantity;
for(i = 0; i < l_quantity; i++)
{
fread( &m_vertexes[i].x, sizeof( float ), 1, l_file );
fread( &m_vertexes[i].y, sizeof( float ), 1, l_file );
fread( &m_vertexes[i].z, sizeof( float ), 1, l_file );
}
break;
case 0x4120:
fread( &l_quantity, sizeof( unsigned short ), 1, l_file );
m_countOfPolygons = l_quantity;
for(i = 0; i < l_quantity; i++)
{
fread( &m_polygons[i].a, sizeof( unsigned short ), 1, l_file );
fread( &m_polygons[i].b, sizeof( unsigned short ), 1, l_file );
fread( &m_polygons[i].c, sizeof( unsigned short ), 1, l_file );
fread( &l_faceFlags, sizeof( float ), 1, l_file );
}
break;
case 0x4140:
fread ( &l_quantity, sizeof (unsigned short), 1, l_file);
for (i = 0; i < l_quantity; i++)
{
fread (&m_mapCoordinates[i].u, sizeof (float), 1, l_file);
fread (&m_mapCoordinates[i].v, sizeof (float), 1, l_file);
}
break;
default:
fseek( l_file, l_chunkLength - 6, SEEK_CUR );
}
}
fclose( l_file );
return 1;
}
3ds
Today I will start to write tool for rendering 3ds model using OpenGL(glut library) to the screen. But I have some questions that's requring to google)
Format diskette
Not so long ago I have to write program for formating diskette without using BIOS interrupt. How do you see in the near future is not so simple it was do)
Source:))
#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif
#include
#include
#include
#include
#define SEC_SIZE 2
typedef struct _DPT_
{
unsigned char srt_hut;
unsigned char dma_hlt;
unsigned char motor_w;
unsigned char sec_size;
unsigned char eot;
unsigned char gap_rw;
unsigned char dtl;
unsigned char gap_f;
unsigned char fill_char;
unsigned char hst;
unsigned char mot_start;
} DPT;
DPT far *get_dpt (void);
void fdc_out (unsigned char byte);
int fdc_inp (void);
void int_wait (void);
void dma_init (void far *);
void tdelay (int cnt);
void interrupt IRQ6 (__CPPARGS);
void interrupt (*oldIRQ6) (__CPPARGS);
char buffer[512];
static int IRQ=0;
void main (void)
{
unsigned iter, side = 0, sector = 0, track = 0;
unsigned old_sec_size, old_fill_char, old_eot;
unsigned char fill_char;
int i, j;
long l;
char status[7], main_status;
DPT _far *fdpt;
FILE * config;
oldIRQ6 = _dos_getvect (8+6);
_dos_setvect (8+6, IRQ6);
// We're opening a file in order to store in it
// the very first sector of the diskette
config = fopen ("flopic.cfg", "r");
fscanf(config, "%d", &track);
fscanf(config, "%c", &fill_char); // read one space
fscanf(config, "%c", &fill_char);
fclose(config);
// Getting Diskette Parameter Table pointer
fdpt = get_dpt();
old_sec_size = fdpt->sec_size;
old_fill_char = fdpt->fill_char;
old_eot = fdpt->eot;
fdpt->sec_size = SEC_SIZE;
fdpt->fill_char = 0xf8; // default byte for filling TODO: set to your sym
fdpt->eot = 15;
// Turning on the motor in the "A:" drive
// Enabling interrupts before actual turning on
_enable();
outp (0x3F2, 0x1C);
// Waiting while motor speeds up
tdelay (18);
// Displaying contents of the controller state register
printf ("Motor is on.\t\t");
printf ("State: %02.2X\n", inp(0x3F4));
// recalibrate
fdc_out (7);
fdc_out (0);
int_wait();
// We need to move drive head to the CYL track
// "Seek" command
fdc_out (0xf);
// The "Seek" command needs 2 parameters:
// a Head/Drive number and a Track number.
// Since we're working with "A:" drive and 0 head,
// first parameter is 0, second parameter is CYL
fdc_out (0);
fdc_out (track);
// Displaying contents of the controller state register
printf ("\n<<>> \t\t");
printf ("State: %02.2X\n", inp(0x3F4));
// Interrupt notifies us about operation end
int_wait();
// Delay for head positioning
tdelay (5);
// In order to check the result of the "Seek" command
// we're sending "Read Interrupt State" command
// Displaying ST0 register and number of a track after
// "Seek" command execution PCN
fdc_out (0x8);
printf ("Interrupt state:\t");
printf ("ST0: %02.2X, \t", fdc_inp());
printf ("PCN: %02.2X\n", fdc_inp());
// For more detailed info of FDC state
// we're sending "Read Media/Drive State" command,
// displaying ST3 register
fdc_out (4);
fdc_out (0);
printf ("Media/Drive state:\t ST3: %02.2X\n", fdc_inp());
// Setting speed of data transfer to 500 KB/sec
outp (0x3F7, 0);
// Setting buffer for DMA
for(iter = 1, i = 0; iter < 16; iter++, i += 4)
{
buffer[i] = track;
buffer[i + 1] = 0; // Side [0, 1]
buffer[i + 2] = iter; // Sector
buffer[i + 3] = 2; // SEC_SIZE - 512
}
// DMA initialization
dma_init ((void far *)buffer);
fdc_out(0x4d); // format CYL or track
// Sending some technical info to FDC.
// This info may be obtained form the Diskette Parameter Table.
// Parameters are:
// - sector size;
// - last sector on a track;
// - gap length;
// - number of bytes to be read/write
fdc_out (0); // format A:
fdc_out (fdpt->sec_size);
fdc_out (fdpt->eot);
fdc_out (fdpt->gap_rw);
fdc_out (fdpt->fill_char);
// Waiting for interrupt (end of operation)
int_wait();
fdpt->sec_size = old_sec_size;
fdpt->eot = old_eot;
fdpt->fill_char = old_fill_char;
outp (0x3F2, 0xC);
lll:
_dos_setvect (8+6, oldIRQ6);
}
// Writes a byte to FDC
void fdc_out (unsigned char parm)
{
asm mov dx,3F4h
loop_fdc_out:
asm in al,dx
asm test al,80h // Is controller ready?
asm jz loop_fdc_out // No, waiting...
asm inc dx
asm mov al, parm // Writing the byte
asm out dx, al
}
// Reads a byte from FDC
int fdc_inp (void)
{
asm mov dx,3F4h
loop_fdc_inp:
asm in al,dx
asm test al,80h // Is controller ready?
asm jz loop_fdc_inp // No, waiting...
asm inc dx
asm in al, dx // Reading a byte
return _AL;
}
// Waits for an interrupt generated by FDC
void int_wait (void) {
_enable();
while (IRQ==0) {};
IRQ = 0;
}
void interrupt IRQ6 (__CPPARGS) {
IRQ = 1;
outportb (0x20, 0x20);
}
// DMA initialization routine
void dma_init (void far *buf)
{
unsigned long f_adr;
unsigned sg, of;
// Computing 24-bit address for the data buffer
f_adr = ((unsigned long)FP_SEG(buf) << 4)
+ (unsigned long)FP_OFF(buf);
// Splitting the address into a page number
// and an offset
sg = (f_adr >> 16) & 0xff;
of = f_adr & 0xffff;
// Disabling ints during DMA programming
_disable();
asm mov al,4ah // FDC read data command
asm out 12,al // We're working with 16-bit ports.
// Next byte sent to 16-bit port is less significiant
asm out 11,al // DMA mode
asm mov ax,of // Buffer offset LSB
asm out 4,al
asm mov al,ah // Buffer offset MSB
asm out 4,al
asm mov ax,sg // Page number
asm out 81h,al
asm mov ax,511 // Data length
asm out 5,al
asm mov al,ah
asm out 5,al
asm mov al,2 // channel 2 enabled
asm out 10,al
// It's now safe to enable ints
_enable();
}
// This routine returns a Diskette Parameter Table address
DPT far *get_dpt(void)
{
void far * far *ptr;
ptr = (void far * far *)MK_FP(0x0, 0x78);
return (DPT far*)(*ptr);
}
// This routine waits for cnt timer ticks.
// Timer frequency is 18.2 Hz
void tdelay (int cnt)
{
asm push bx
asm push dx
asm push si
asm mov si, cnt
asm mov ah, 0
asm int 1ah
asm mov bx, dx
asm add bx, si
delay_loop:
asm int 1ah
asm cmp dx, bx
asm jne delay_loop
asm pop si
asm pop dx
asm pop bx
}
Before using the program, you have to create flopic.cfg file that's contain data("
Source:))
#ifdef __cplusplus
#define __CPPARGS ...
#else
#define __CPPARGS
#endif
#include
#include
#include
#include
#define SEC_SIZE 2
typedef struct _DPT_
{
unsigned char srt_hut;
unsigned char dma_hlt;
unsigned char motor_w;
unsigned char sec_size;
unsigned char eot;
unsigned char gap_rw;
unsigned char dtl;
unsigned char gap_f;
unsigned char fill_char;
unsigned char hst;
unsigned char mot_start;
} DPT;
DPT far *get_dpt (void);
void fdc_out (unsigned char byte);
int fdc_inp (void);
void int_wait (void);
void dma_init (void far *);
void tdelay (int cnt);
void interrupt IRQ6 (__CPPARGS);
void interrupt (*oldIRQ6) (__CPPARGS);
char buffer[512];
static int IRQ=0;
void main (void)
{
unsigned iter, side = 0, sector = 0, track = 0;
unsigned old_sec_size, old_fill_char, old_eot;
unsigned char fill_char;
int i, j;
long l;
char status[7], main_status;
DPT _far *fdpt;
FILE * config;
oldIRQ6 = _dos_getvect (8+6);
_dos_setvect (8+6, IRQ6);
// We're opening a file in order to store in it
// the very first sector of the diskette
config = fopen ("flopic.cfg", "r");
fscanf(config, "%d", &track);
fscanf(config, "%c", &fill_char); // read one space
fscanf(config, "%c", &fill_char);
fclose(config);
// Getting Diskette Parameter Table pointer
fdpt = get_dpt();
old_sec_size = fdpt->sec_size;
old_fill_char = fdpt->fill_char;
old_eot = fdpt->eot;
fdpt->sec_size = SEC_SIZE;
fdpt->fill_char = 0xf8; // default byte for filling TODO: set to your sym
fdpt->eot = 15;
// Turning on the motor in the "A:" drive
// Enabling interrupts before actual turning on
_enable();
outp (0x3F2, 0x1C);
// Waiting while motor speeds up
tdelay (18);
// Displaying contents of the controller state register
printf ("Motor is on.\t\t");
printf ("State: %02.2X\n", inp(0x3F4));
// recalibrate
fdc_out (7);
fdc_out (0);
int_wait();
// We need to move drive head to the CYL track
// "Seek" command
fdc_out (0xf);
// The "Seek" command needs 2 parameters:
// a Head/Drive number and a Track number.
// Since we're working with "A:" drive and 0 head,
// first parameter is 0, second parameter is CYL
fdc_out (0);
fdc_out (track);
// Displaying contents of the controller state register
printf ("\n<<
printf ("State: %02.2X\n", inp(0x3F4));
// Interrupt notifies us about operation end
int_wait();
// Delay for head positioning
tdelay (5);
// In order to check the result of the "Seek" command
// we're sending "Read Interrupt State" command
// Displaying ST0 register and number of a track after
// "Seek" command execution PCN
fdc_out (0x8);
printf ("Interrupt state:\t");
printf ("ST0: %02.2X, \t", fdc_inp());
printf ("PCN: %02.2X\n", fdc_inp());
// For more detailed info of FDC state
// we're sending "Read Media/Drive State" command,
// displaying ST3 register
fdc_out (4);
fdc_out (0);
printf ("Media/Drive state:\t ST3: %02.2X\n", fdc_inp());
// Setting speed of data transfer to 500 KB/sec
outp (0x3F7, 0);
// Setting buffer for DMA
for(iter = 1, i = 0; iter < 16; iter++, i += 4)
{
buffer[i] = track;
buffer[i + 1] = 0; // Side [0, 1]
buffer[i + 2] = iter; // Sector
buffer[i + 3] = 2; // SEC_SIZE - 512
}
// DMA initialization
dma_init ((void far *)buffer);
fdc_out(0x4d); // format CYL or track
// Sending some technical info to FDC.
// This info may be obtained form the Diskette Parameter Table.
// Parameters are:
// - sector size;
// - last sector on a track;
// - gap length;
// - number of bytes to be read/write
fdc_out (0); // format A:
fdc_out (fdpt->sec_size);
fdc_out (fdpt->eot);
fdc_out (fdpt->gap_rw);
fdc_out (fdpt->fill_char);
// Waiting for interrupt (end of operation)
int_wait();
fdpt->sec_size = old_sec_size;
fdpt->eot = old_eot;
fdpt->fill_char = old_fill_char;
outp (0x3F2, 0xC);
lll:
_dos_setvect (8+6, oldIRQ6);
}
// Writes a byte to FDC
void fdc_out (unsigned char parm)
{
asm mov dx,3F4h
loop_fdc_out:
asm in al,dx
asm test al,80h // Is controller ready?
asm jz loop_fdc_out // No, waiting...
asm inc dx
asm mov al, parm // Writing the byte
asm out dx, al
}
// Reads a byte from FDC
int fdc_inp (void)
{
asm mov dx,3F4h
loop_fdc_inp:
asm in al,dx
asm test al,80h // Is controller ready?
asm jz loop_fdc_inp // No, waiting...
asm inc dx
asm in al, dx // Reading a byte
return _AL;
}
// Waits for an interrupt generated by FDC
void int_wait (void) {
_enable();
while (IRQ==0) {};
IRQ = 0;
}
void interrupt IRQ6 (__CPPARGS) {
IRQ = 1;
outportb (0x20, 0x20);
}
// DMA initialization routine
void dma_init (void far *buf)
{
unsigned long f_adr;
unsigned sg, of;
// Computing 24-bit address for the data buffer
f_adr = ((unsigned long)FP_SEG(buf) << 4)
+ (unsigned long)FP_OFF(buf);
// Splitting the address into a page number
// and an offset
sg = (f_adr >> 16) & 0xff;
of = f_adr & 0xffff;
// Disabling ints during DMA programming
_disable();
asm mov al,4ah // FDC read data command
asm out 12,al // We're working with 16-bit ports.
// Next byte sent to 16-bit port is less significiant
asm out 11,al // DMA mode
asm mov ax,of // Buffer offset LSB
asm out 4,al
asm mov al,ah // Buffer offset MSB
asm out 4,al
asm mov ax,sg // Page number
asm out 81h,al
asm mov ax,511 // Data length
asm out 5,al
asm mov al,ah
asm out 5,al
asm mov al,2 // channel 2 enabled
asm out 10,al
// It's now safe to enable ints
_enable();
}
// This routine returns a Diskette Parameter Table address
DPT far *get_dpt(void)
{
void far * far *ptr;
ptr = (void far * far *)MK_FP(0x0, 0x78);
return (DPT far*)(*ptr);
}
// This routine waits for cnt timer ticks.
// Timer frequency is 18.2 Hz
void tdelay (int cnt)
{
asm push bx
asm push dx
asm push si
asm mov si, cnt
asm mov ah, 0
asm int 1ah
asm mov bx, dx
asm add bx, si
delay_loop:
asm int 1ah
asm cmp dx, bx
asm jne delay_loop
asm pop si
asm pop dx
asm pop bx
}
Before using the program, you have to create flopic.cfg file that's contain data("
среда, 30 апреля 2008 г.
sorttable.js bugs in ASP.NET with ms ajax
Hi all, 1 month ago I worked in project, where I wrote custom widget(table with header sort event).
And I downloaded very pretty javascript library(sorttable, http://www.kryogenix.org/code/browser/sorttable/), but I couldn't understand, why when I include this library in page with Ms Ajax control's, exceptions try to fuck my browser and brain.
After google, I found blog of japan guy(don't remember link, butthankful for him) some information about forEach method, that's uses in MS Ajax and sorttable library. For fixing this bug, you may try to replace forEach method in sorttable library to simple for loop, example (in init()):
/*forEach(document.getElementsByTagName('table'), function(table) {
if (table.className.search(/\bsortable\b/) != -1) {
var index = table.id.indexOf("_header");
var sortingFields = table.id.substring(0, index);
sorttable.makeSortable(table, sortingFields);
}
}); */
for(i=0;i < document.getElementsByTagName('table').length;i++)
{
table=document.getElementsByTagName('table')[i];
if (table.className.search(/\bsortable\b/) != -1) {
var index = table.id.indexOf("_header");
var sortingFields = table.id.substring(0, index);
sorttable.makeSortable(table, sortingFields);
}
};
That's all, thanks for reading.
And I downloaded very pretty javascript library(sorttable, http://www.kryogenix.org/code/browser/sorttable/), but I couldn't understand, why when I include this library in page with Ms Ajax control's, exceptions try to fuck my browser and brain.
After google, I found blog of japan guy(don't remember link, butthankful for him) some information about forEach method, that's uses in MS Ajax and sorttable library. For fixing this bug, you may try to replace forEach method in sorttable library to simple for loop, example (in init()):
/*forEach(document.getElementsByTagName('table'), function(table) {
if (table.className.search(/\bsortable\b/) != -1) {
var index = table.id.indexOf("_header");
var sortingFields = table.id.substring(0, index);
sorttable.makeSortable(table, sortingFields);
}
}); */
for(i=0;i < document.getElementsByTagName('table').length;i++)
{
table=document.getElementsByTagName('table')[i];
if (table.className.search(/\bsortable\b/) != -1) {
var index = table.id.indexOf("_header");
var sortingFields = table.id.substring(0, index);
sorttable.makeSortable(table, sortingFields);
}
};
That's all, thanks for reading.
Day of qt
Not so long ago I've start to write different programmes based on c++ qt framework.
It's very great full, very thoughtful, very similar to C#, java. But Qt haven't event model or delegate model. But it have more flexible model, SIGNALS and SLOTS.
For example:
You have model (A) and (B) and (C)
(A) have to send data to model (B) and (C).
and you write:
QObject::connect(A, SIGNAL(sendDataSignal()),
B, SLOT( )));
You can also subscribe for example: signal to signal, signal to slot. It's build a chain.
It hasn't long been seen nothing convenient.
It's very great full, very thoughtful, very similar to C#, java. But Qt haven't event model or delegate model. But it have more flexible model, SIGNALS and SLOTS.
For example:
You have model (A) and (B) and (C)
(A) have to send data to model (B) and (C).
and you write:
QObject::connect(A, SIGNAL(sendDataSignal(
B, SLOT(
You can also subscribe for example: signal to signal, signal to slot. It's build a chain.
It hasn't long been seen nothing convenient.
суббота, 19 января 2008 г.
Hi, all.
It's my the first blog but not last. I'm tring to write sometimes artices that's devoting .NET programming. Sometimes .NET is voodoo. And you can see what I mean).
Подписаться на:
Комментарии (Atom)
Архив блога
-
▼
2008
(16)
-
▼
июня
(10)
- Hi guys. I spended all day for listening podcasts ...
- Display flickr images using javascript.
- Write simple expander for text area(Very simple ef...
- Music of the day
- 3 exam is approved by lecturer
- exams))
- Music for this day.)
- Information for anonymous readers.)
- The day after tomorrow)
- Please approve my death.
-
▼
июня
(10)