Rabu, 29 Juni 2016

Contoh 26 (Coding) dan Gambarnya

#include <stdlib.h>
#include "screen.cpp"
#include "keyboard.cpp"
#define MOUSE_INT 0x33 /* Interupsi mouse */
#define MOUSE_LEFT_BUTTON 0x00 /* Pilihan tombol kiri */
#define MOUSE_RIGHT_BUTTON 0x01 /* Pilihan tombol kanan */
#define USHORT unsigned short int
UCHAR detectMouse(UCHAR *btn);
USHORT getButtonRelease(UCHAR btn, USHORT *row,
USHORT *col, USHORT maxrel);
void showMouse(void);
int main(void)
{

Screen *layar = new Screen();
Keyboard *tombol = new Keyboard(layar);
USHORT jumlah, baris, kolom;
UCHAR status, button, str[5];
status = detectMouse(&button);
layar->setMode(0x03); layar->setCursorPos(4, 14);
showMouse();
if (!status)
{
layar->writeString("Mouse tidak siap! Tekan ENTER ...");
tombol->getString(str, 0);
delete layar; delete tombol;
exit(EXIT_FAILURE);
}
layar->writeString("Lepas tombol kanan 5x untuk berhenti");
tombol->hideCursor();
jumlah = getButtonRelease(MOUSE_RIGHT_BUTTON,
&baris, &kolom, 5);
delete tombol; delete layar;
return EXIT_SUCCESS;
}
UCHAR detectMouse(UCHAR *btn)
{
UCHAR state, button;
asm mov ah, 0x00; /* Register AH = 0 */
asm mov al, 0x00; /* Register AL = 0, AH:AL = 0:0 */
asm int MOUSE_INT; /* Laksanakan interupsi 0x33 */
asm mov state, al; /* Salin nilai AL ke state */
asm mov button, bl; /* Salin nilai BL ke button */
*btn = button;
return state;
}
USHORT getButtonRelease(UCHAR btn, USHORT *row,
USHORT *col, USHORT maxrel)
{
USHORT rel, nrel, x, y;
rel = nrel = x = y = 0;
while (nrel < maxrel)
{
asm mov ah, 0x00;
asm mov al, 0x06;
asm mov bh, 0x00;
asm mov bl, btn;

asm int MOUSE_INT;
asm mov rel, bx;
asm mov x, cx;
asm mov y, dx;
nrel += rel;
}
*row = y; *col = x;
return rel;
}
void showMouse(void)
{
asm mov ax, 0x00001;
asm int MOUSE_INT;
return;
}


Gambarnya Sebagai Berikut : 



Penjelasannya : 


Fungsi getButtonRelease pada program contoh26.cpp digunakan untuk mendeteksi pelepasan tombol sebanyak beberapa kali. Parameter btn yang bertipe unsigned character digunakan untuk menentukan tombol mouse (tombol kiri atau kanan) yang akan dibatasi pelepasannya. Parameter col dan row bertipe unsigned integer yang dikirimkan secara referensi digunakan untuk mengetahui posisi baris dan kolom pointer mouse ketika tombol mouse terakhir kali dilepas. Parameter maxclick bertipe unsigned integer digunakan untuk menentukan banyak pelepasan tombol mouse.

0 komentar:

Posting Komentar

Posting Lebih Baru Posting Lama Beranda

Diberdayakan oleh Blogger.

Facebook

Popular Posts

Formulir Kontak

Nama

Email *

Pesan *

Subscribe Here

Ad Home

Random Posts

Recent Posts

Recent

Header Ads

Popular Posts

Flickr

Newsletter

Subscribe Our Newsletter

Enter your email address below to subscribe to our newsletter.

Ad Banner

About Us

Random Posts

Popular Posts

 

Followers

 

Social Share Icons

Templates by Nano Yulianto | CSS3 by David Walsh | Powered by {N}Code & Blogger