"Don't tell me how hard you work. Tell me how you get done."
- James J. Ling

J2ME Bluetooth Application (RFCOMM)

August 30, 2006

Oh my God! I just can’t help not posting what I feel…I think I made it! If I’m not mistaken, I was able to connect two Bluetooth devices and communicate with each other through the RFCOMM serial protocol. I run it in the Java Wireless Toolkit because my PC could not even create new J2ME application in NetBeans. And I wish to test this module in a real device.

Here’s the result:

Build Result:
Project “BluetoothMidlet” loaded
Project settings saved
Building “BluetoothMidlet”
Build complete

Server side:

Running with storage root DefaultColorPhone
Running with locale: English_United States.1252
Waiting for connection…
Received from Client: INFO
Waiting for connection…
Execution completed.
1312245 bytecodes executed
27107 thread switches
896 classes in the system (including system classes)
5922 dynamic objects allocated (192736 bytes)
4 garbage collections (118500 bytes collected)
 

 
Client side:

Running with storage root temp.DefaultColorPhone1156995903898
Running with locale: English_United States.1252
deviceDiscovered()
Address: 0123456789AF
Major Device Class: 512
Minor Device Class: 4
Friendly Name: WirelessToolkit
inquiryCompleted()
servicesDiscovered()
SERVICE_SEARCH_COMPLETED
Service URL: btspp://0123456789AF:1;master=false;encrypt=false;authenticate=false
InfoServer: Your command was: INFO
Execution completed.
1102515 bytecodes executed
3463 thread switches
897 classes in the system (including system classes)
5892 dynamic objects allocated (191284 bytes)
5 garbage collections (132372 bytes collected)

Thanks to Miss Ebony Domingo for the J2ME tutorials and encouragement and to Niel for helping me gather resources.

To  Jc and Marlon…Wish to test this on real devices soon! I wanna know if it could stream voice through RFCOMM. Cheers!

Posted by phengpheng at 8:56 pm | permalink | comments[4]

Rotation practice in OpenGL

August 29, 2006

Someone guess what this code do…:)  This is an OpenGL code in C++

 

#include <GL/glut.h>

void event_display (void)
{
    glClear(GL_COLOR_BUFFER_BIT);

 glColor3f(1.0, 1.0, 0.0);
 glRotatef(45.0, 0.0, 0.0, 1.0);
 glRotatef(-45.0, 0.0, 1.0, 0.0);
 glRotatef(90.0, 1.0, 0.0, 0.0);
 glRotatef(45.0, 0.0, 1.0, 0.0);
 glRotatef(-45.0, 0.0, 0.0, 1.0);
 
 glutWireCube(.5);

 glColor3f(1.0, 1.0, 1.0);
    glBegin(GL_LINES);
  glVertex3f(0.0, 0.0, 0.0);
        glVertex3f(1.0, 1.0, 1.0);
    glEnd();

   
 glFlush();
}

 

void init (void)
{
    glClearColor(0.0, 0.0, 0.0, 0.0);

}

void main(int argc, char** argv)
{
    glutInit(&argc, argv);
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
    glutInitWindowSize(300, 300);
    glutInitWindowPosition(0, 0);
    glutCreateWindow(argv[0]);

    init();

    glutDisplayFunc(event_display);
    glutMainLoop();
}

Posted by phengpheng at 7:56 am | permalink | comments[3]

Convert Binary to Hexadecimal

August 25, 2006

lea si, input
xor cx,cx

mov cl, 4

check:
    mov ah, 00
    int 16h

    cmp al, ‘0′
    jb check
   
    cmp al, ‘1′
    ja check
   
    mov [si], al
    inc si
   
loop check

call convert
   

int 20h

input db 5 dup (’$')

;——————–convert——————–
convert:

    dec si

    mov ah, 09
    lea dx, input
    int 21h
   
    mov ah, 02h
    mov dl, 0ah
    int 21h
    mov dl, 0dh
    int 21h
   
    xor bx,bx
    mov cl,0

    xxx:

    mov al, [si]        ; al contains character not value
    sub al,30h          ; convert to value

    shl al, cl
    add bl,al

   
    dec si
    inc cl
   
    cmp cl,4
    jne xxx

   
    add bl,30h        ; 0-9

    cmp bl,’9′       
    jbe print

    add bl, 7h        ; A-F   

print:
    mov ah, 02
    mov dl,bl
    int 21h
   
ret

Posted by phengpheng at 4:18 pm | permalink | Add comment

Converting hexadimal to binary

August 11, 2006

This is a shorter and lazier version of hex to binary conversion. It displays right away the binary equivalent of a valid hexadecimal and waits user to press enter key to end. Thanks to sir for the convert algo…hehe:) 

check:
    mov ah, 00
    int 16h

    cmp ah, 1ch                               ; scan key for enter key
    je exit

    cmp al, ‘0′
    jb check
    
    cmp al, ‘9′
    ja ucase
    
    sub al, 30h
    call convert
    jmp check

ucase:
    cmp al, ‘A’
    jb check

    cmp al, ‘F’
    ja lcase
    
    sub al, 37h
    
    call convert
    
    jmp check

lcase:
    cmp al, ‘a’
    jb check
    
    cmp al, ‘f’
    ja check
    
    sub al, 57h
    
    call convert

    jmp check
     
exit:
    int 20h
    
loop check

;———————–convert——————————
convert:

    mov ch, 4        ; 4 bits
    mov cl, 3        
    mov bl, al
    
    xxx:
        mov al, bl
        shr al, cl    
        and al, 01    ; bit masking- isolate least bit 0
    
        add al, 30h

        mov ah, 02    ; display binary equivalent
        mov dl, al
        int 21h
    
        dec cl        
        dec ch
    
    jnz xxx
    
    mov dl, ‘ ‘
    int 21h
    ret

Posted by phengpheng at 2:06 pm | permalink | Add comment

Count Vowels & Consonants

August 6, 2006

Well…i posted this code na although it is not yet perfect. :)

If number of vowels/consonants is 10 or more, it will display it’s ascii equivalent not the number. I shall post the update soon or perhaps you want to help me with it…hehe:)

mov ah, 0ah
lea dx, parameter
int 21h

mov ah, 02h
mov dl, 0ah
int 21h
mov dl, 0dh
int 21h

;—————–initializtions—————–
xor bx,bx                     ; count vowels
xor dl, dl                      ; count consonants

lea si, input                  ; load string
xor cx, cx  
mov cl, [actlen]             ; loop counter

;———————loop———————–
; idea: filter out lot letters
; check if vowels. if yes, update vowel counter
; if no, update consonant counter
;————————————————
voc:

    mov al, [si]
 
    cmp al, 122                 ; filter not letters
    ja skip
    cmp al, 96
    ja check
    cmp al, 90
    ja skip
    cmp al, 65
    jb skip

check:
    cmp al, ‘A’
    je vowel

    cmp al, ‘a’
    je vowel

    cmp al, ‘E’
    je vowel

    cmp al, ‘e’
    je vowel
 
    cmp al, ‘I’
    je vowel

    cmp al, ‘i’
    je vowel

    cmp al, ‘O’
    je vowel

    cmp al, ‘o’
    je vowel
 
    cmp al, ‘U’
    je vowel

    cmp al, ‘u’
    je vowel

    jne cons

vowel:
    inc bl
    jmp skip
cons:
    inc dl
     jmp skip

skip:
    inc si

loop voc

;—————-end of loop————————-

;so that bl becomes character
add bl, 48
add dl, 48

;———————–results———————-
; first is the consonant count
; followed by vowel count
;—————————————————-
mov ah, 02h
mov dl, dl
int 21h
mov dl,0ah
int 21h
mov dl,0dh
int 21h
mov dl, bl
int 21h
int 20h

parameter label byte
maxlen db 20
actlen db ?
input db 20 dup (’$')

Posted by phengpheng at 5:21 pm | permalink | comments[3]

     

August 2006
M T W T F S S
« Jul   Sep »
 123456
78910111213
14151617181920
21222324252627
28293031  

Sponsored Links

About Me

A Computer Science graduate who is a fanatic in assembly, java, and j2me programming. Developed BlueVoice system (Direct Voice Communication in Mobile Phones), this system allows mobile users to experience FREE VOICE CALLS

Subscribe

Technorati
Bloglines

Tagboard

tinnitus treatment:

thanks You sure do know what your’e talking about. Man, this blog is just great! I cant wait to read more of what youv’e got to say. Im really happy that I came across this when I did because I was really starting

phengpheng:

Haven’t managed my blog for a long time already because I’m so busy now… Sorry to cause you guyz trouble…

Jun Mark:

hoW tO creaTE a PrOGram thAT woULD oUTpuT ascii table???

Jun Mark:

pLZ anSwer mY qUEstions

cutieGurl:

how to convert binary to hexadecimal, decimal and octal?????????please. answer me??????????

mary ann:

kuya, ung binary to decimal converter nyo. mali man? ung sa mga compare mo. ung may 0,9,A,F etc… bad character lumalabaspls rep asap po. tnx

carol:

how to convert decimal to binary to octal and hexadecimal

Galwin:

been here!

galwin:

nice site. hope you could visit mine, too.

pathy:

FRIENDS FOREVER!! Miss you na!!!

ridvan:

aus, i seldom see lady programmers. hehe. keep it up. and oh yeah, i guess i saw you during the MICT Quiz Show held in cdo. :)
keep up the codes!

phengpheng:

I miss updating this blog… Sana may time and pc ako to learn new stuffs aside from my work…

support:

Congratulations, you’ve just completed the installation of this shoutbox.

pheng:

uy! you’re here again!

Jay:

Woooohhhh orange…sweat… nakakasilaw! hehe :)

jay:

tagboard flood hehe sensya… had nothing fun to do. :)

pheng:

jaaaaayyyyy….:) ketal man?:)

niel:

no spamming please :p hehehe joke lang jay.

Jay:

Uyyyyyy!!!! Grraaaaaaaiiiinnnneeee
:)
Sssshhhh, el sikret! :)
Niiiiiiiiiiiiieeeeeel
Sup dude!!!!
Paaaaaaaaaaaaaathy
Ketal!?

niel:

ei pheng! :D slick-elegant layout! love it!

Leave a message ▼