2012年10月19日 星期五

[Web] jquery + processing.js

用 JQuery + JQuery UI + javascript + PHP + Processing.js

製作這個網站 - drawall



讓網友可以隨手塗鴉, 分享彼此的大作

也可以以四格連環漫畫的方式創作

主要的繪圖介面當然是以 Processing.js 來作



現在 chrome, firefox 對 HTML 5 支援度已經作得滿不錯了

其它的 UI 部份全部由 JQuery + JQuery UI 製作



以 JQuery 建構網是滿方便快速, 但可能有 performance issue

不過一樣的呈現方式, 以 javascript 來寫可能也會滿複雜的

用 JQuery 撰寫時間真的縮短許多

2012年10月16日 星期二

How to make a bootloader and test with VirtualBox

Make a bootloader



以 x86 來說, BIOS 在執行完所有任務後, 最後一件事就是
搜尋 floppy, hard disk, cdrom 的 cylinder 0, head 0, sector 1
(在 hard disk 上稱做 MBR)並將該 sector (512 bytes) 載入記憶體的
0x0000:7C00 開始執行. 在 MBR 還會多檢查最後 2 bytes 是否為 0x55AA

所以我們最簡單的 boot code 如下


[BITS 16]
[org 0x7C00]

start:
mov si,MSG
call print_string
jmp $

print_string: ; Expects null terminated message in si
mov al,[si]
or al,al
jz .end
inc si
call print_char
jmp print_string
.end:
retn

print_char:
mov ah,0x0E ; Specifies that we want to write a character to the screen
mov bl,0x07 ; Specifies output text color. Not required, but useful to know
mov bh,0x00 ; Page number. Leave this alone.
int 0x10 ; Signal video interrupt to BIOS
retn

;data
MSG db 'Welcome My Operating System!',0x0A,0

TIMES 510 - ($ - $$) db 0  ; clear 0 between data and 0xAA55
DW 0xAA55



用 nasm build binary executable file


nasm -f bin -o boot.bin boot.asm



Test with VirtualBox (version: 4.2.0)

首先, 用VirtualBox新增一個虛擬機器, 類型跟作業系統可以選 Windows, Windows XP
建立完成後, 找到這個虛擬機器的 hard disk file (.vdi) 用 HEX Editor 打開
找到這個位址 0x0000:0150 如下



紅框內的值就代表這個 vdi file 的 MBR 在 0x0000:2000
接下來把 boot.bin 的 512 bytes 完全 copy 到 0x0000:2000~0x0000:21FF
就大功告成了, 開機畫面如下




Reference 

Using Virtualbox as a bootloader testing environment
X86 開機流程小記 
Operating System Development - bootloader

Python Tkinter First Example

import tkinter as tk def on_closing():     root.destroy() class MainWindow(tk.Tk):     def __init__(self, *args, **kwargs):         tk.Tk.__...