; ----------------------------------------------------------------------------------- ;; ;; Copyright 2008, 2009, 2012, 2013 Shane Tyler Yorks ;; ;; This file is a part of LearnerKernel ;; ;; LearnerKernel is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; ;; Please refer to the README file for additional information. ;; ; ----------------------------------------------------------------------------------- emu_space = 10 ;Number of sectors to provide to the emulator to play with: set to 0 when checking program size ;==================================================================================== ;Program header macros ;------------------------------------------------------------------------------------ macro begin { format binary as "img" use32 file "kernel.bin" magic_number dd 0x0b131d19, 0x11357345, 0x4f1e3641, 0x021c0a2f, 0x8b38a312 dd (pEnd-pBeg)/512 org 0x01000000 pBeg: } ;------------------------------------------------------------------------------------ macro end { int 0x06 virtual align 512 pEnd: end virtual times (pEnd-$+emu_space*512) db 0 } ;------------------------------------------------------------------------------------ macro terminate { cli @@: hlt jmp @b } ;==================================================================================== ;ISR Numbers ;------------------------------------------------------------------------------------ ;System ;------------------------------------------------------------------------------------ sys_reset = 0x30 sys_realmode = 0x31 sys_scanchk = 0x32 sys_loadsec = 0x33 sys_savesec = 0x34 sys_safe = 0x35 sys_vecload = 0x36 sys_vecsave = 0x37 sys_sleep = 0x38 sys_copyright = 0x39 sys_isrrep = 0x3a sys_atoi = 0x3b ;------------------------------------------------------------------------------------ ;Graphics ;------------------------------------------------------------------------------------ grp_setgrph = 0x41 grp_flip = 0x42 grp_clrs = 0x43 grp_draw = 0x44 grp_colormap = 0x45 grp_vecmap = 0x46 ;------------------------------------------------------------------------------------ ;Text ;------------------------------------------------------------------------------------ txt_settext = 0x40 txt_copy = 0x47 txt_clrs = 0x48 txt_prints = 0x49 txt_printi = 0x4a txt_printx = 0x4b txt_getch = 0x4c txt_gets = 0x4d ;==================================================================================== ;Colors ;------------------------------------------------------------------------------------ blink = 0x80 ;------------------------------------------------------------------------------------ bgblack = 0x00 bgblue = 0x10 bggreen = 0x20 bgcyan = 0x30 bgdarkred = 0x40 bgpurple = 0x50 bgbrown = 0x60 bgsilver = 0x70 ;------------------------------------------------------------------------------------ fgblack = 0x00 fgblue = 0x01 fggreen = 0x02 fgcyan = 0x03 fgdarkred = 0x04 fgpurple = 0x05 fgbrown = 0x06 fgsilver = 0x07 fggray = 0x08 fglightblue = 0x09 fglightgreen = 0x0a fgskyblue = 0x0b fgred = 0x0c fgyellow = 0x0e fgwhite = 0x0f dcolor = bgblue + fggreen ;Default color ;==================================================================================== ;Data structures ;------------------------------------------------------------------------------------ struc rgbi x, y { .xloc dd 0 .yloc dd 0 .xsz dd x .ysz dd y .data rw x*y } ;------------------------------------------------------------------------------------ struc VectorColors [x, y] { forward db x dw y common db 0 } ;==================================================================================== ;Scan Codes ;------------------------------------------------------------------------------------ sc_esc = 0x01 sc_1 = 0x02 sc_2 = 0x03 sc_3 = 0x04 sc_4 = 0x05 sc_5 = 0x06 sc_6 = 0x07 sc_7 = 0x08 sc_8 = 0x09 sc_9 = 0x0a sc_0 = 0x0b sc_minus = 0x0c sc_plus = 0x0d sc_backspace = 0x0e sc_tab = 0x0f sc_q = 0x10 sc_w = 0x11 sc_e = 0x12 sc_r = 0x13 sc_t = 0x14 sc_y = 0x15 sc_u = 0x16 sc_i = 0x17 sc_o = 0x18 sc_p = 0x19 sc_lsb = 0x1a sc_rsb = 0x1b sc_enter = 0x1c sc_ctrl = 0x1d sc_a = 0x1e sc_s = 0x1f sc_d = 0x20 sc_f = 0x21 sc_g = 0x22 sc_h = 0x23 sc_j = 0x24 sc_k = 0x25 sc_l = 0x26 sc_semicolon = 0x27 sc_apostrophe = 0x28 sc_backslash = 0x2b sc_backtick = 0x29 sc_lshift = 0x2a sc_z = 0x2c sc_x = 0x2d sc_c = 0x2e sc_v = 0x2f sc_b = 0x30 sc_n = 0x31 sc_m = 0x32 sc_comma = 0x33 sc_period = 0x34 sc_rshift = 0x36 sc_prntscr = 0x37 sc_alt = 0x38 sc_space = 0x39 sc_capslock = 0x3a sc_f1 = 0x3b sc_f2 = 0x3c sc_f3 = 0x3d sc_f4 = 0x3e sc_f5 = 0x3f sc_f6 = 0x40 sc_f7 = 0x41 sc_f8 = 0x42 sc_f9 = 0x43 sc_f10 = 0x44 sc_numlock = 0x45 sc_scrolllock = 0x46 sc_home = 0x47 sc_up = 0x48 sc_pageup = 0x49 sc_keyminus = 0x4a sc_left = 0x4b sc_keypad5 = 0x4c sc_right = 0x4d sc_keyplus = 0x4e sc_down = 0x50 sc_pagedown = 0x51 sc_ins = 0x52 sc_del = 0x53 sc_f11 = 0x57 sc_f12 = 0x58 sc_win = 0x5b sc_menu = 0x5d sc_break = 0xc5 ;------------------------------------------------------------------------------------ macro kchk x { mov al, x int sys_scanchk or al, al jz @f }