forked from KolibriOS/kolibrios
fixed linker and syscall
git-svn-id: svn://kolibrios.org@9063 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
9212ac1784
commit
d2c9bf489c
@ -9,40 +9,67 @@ const (
|
||||
BtnExit=1;
|
||||
)
|
||||
|
||||
func RedrawAll(bar_pos int){
|
||||
os.Redraw(1)
|
||||
os.Window(500,250,420,200, "Test Golang")
|
||||
os.DrawLine(32, 80, 150, 80, colors.Green)
|
||||
os.CreateButton(32, 128, 80, 30, Btn1, colors.Blue);
|
||||
os.CreateButton(300, 128, 80, 30, Btn2, colors.Blue);
|
||||
os.WriteText(32,128, 0x11000000 | colors.White," <- ")
|
||||
os.WriteText(320,128, 0x11000000 | colors.White," -> ")
|
||||
os.DrawBar(bar_pos, 90, 100, 30, colors.Red);
|
||||
type Button struct { // structure gui button
|
||||
label string
|
||||
x int
|
||||
y int
|
||||
id int
|
||||
}
|
||||
|
||||
func Load() {
|
||||
func NewButton() Button {
|
||||
object := Button{"Text",0,0,Btn1} // default data
|
||||
return object
|
||||
}
|
||||
|
||||
func (button *Button) make() {
|
||||
os.CreateButton(button.x, button.y, len(button.label)*15, 30, button.id, colors.Blue);
|
||||
os.WriteText(button.x,button.y, 0x11000000 | colors.White, button.label)
|
||||
}
|
||||
|
||||
func RedrawAll(bar_pos int){
|
||||
os.Redraw(1)
|
||||
os.Window(500,250,420,200, "Example GoLang")
|
||||
os.DrawLine(32, 80, 150, 80, colors.Green)
|
||||
os.DrawBar(bar_pos, 90, 100, 30, colors.Red);
|
||||
|
||||
b1 := NewButton()
|
||||
b1.label = " <- "
|
||||
b1.x = 32
|
||||
b1.y = 128
|
||||
b1.id = Btn1
|
||||
b1.make()
|
||||
|
||||
b2 := NewButton()
|
||||
b2.label = " -> "
|
||||
b2.x = 310
|
||||
b2.y = 128
|
||||
b2.id = Btn2
|
||||
b2.make()
|
||||
}
|
||||
|
||||
func Main() {
|
||||
var pos = 160;
|
||||
//time := os.GetTime()
|
||||
//os.DebugOutStr("Time: ")
|
||||
//os.DebugOutHex(time)
|
||||
var pos=32;
|
||||
for true {
|
||||
switch os.Event() {
|
||||
case os.EVENT_REDRAW:
|
||||
case os.EVENT_REDRAW:
|
||||
RedrawAll(pos)
|
||||
break
|
||||
case os.EVENT_BUTTON:
|
||||
switch os.GetButtonID() {
|
||||
case Btn1:
|
||||
pos-=32
|
||||
RedrawAll(pos)
|
||||
break
|
||||
case Btn2:
|
||||
pos+=32
|
||||
RedrawAll(pos);
|
||||
break
|
||||
case BtnExit:
|
||||
os.Exit()
|
||||
}
|
||||
switch os.GetButtonID() {
|
||||
case Btn1:
|
||||
pos-=32
|
||||
RedrawAll(pos)
|
||||
break
|
||||
case Btn2:
|
||||
pos+=32
|
||||
RedrawAll(pos);
|
||||
break
|
||||
case BtnExit:
|
||||
os.Exit()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,18 +12,23 @@ const (
|
||||
EVENT_DEBUG = 9 /* Debug subsystem event */
|
||||
EVENT_IRQBEGIN = 16
|
||||
)
|
||||
|
||||
func Sleep(uint32)
|
||||
func GetTime()(time uint32)
|
||||
func Event()(uint32)
|
||||
func Event()(int)
|
||||
func GetButtonID()(id int)
|
||||
func CreateButton(x uint32, y uint32, xsize uint32, ysize uint32, id uint32, color uint32)
|
||||
func CreateButton(x int, y int, xsize int, ysize int, id int, color uint32)
|
||||
func Exit()
|
||||
func Redraw(uint32)
|
||||
func Window(y uint32, x uint32, w uint32,h uint32, title string)
|
||||
func WriteText(x uint32 ,y uint32 , color uint32, text string)
|
||||
func WriteText2(uint32 ,string ,uint32, uint32,uint32)
|
||||
func DrawLine(x1 uint32, y1 uint32, x2 uint32, y2 uint32, color uint32)(uint32)
|
||||
func Redraw(int)
|
||||
func Window(y int, x int, w int,h int, title string)
|
||||
func WriteText(x int ,y int , color uint32, text string)
|
||||
func WriteText2(int ,int ,int, uint32,uint32)
|
||||
func DrawLine(x1 int, y1 int, x2 int, y2 int, color uint32)(uint32)
|
||||
func DrawBar(x int, y int, xsize int, ysize int, color uint32)
|
||||
func DebugOutHex(uint32)
|
||||
func DebugOutChar(byte)
|
||||
func DebugOutStr(string)
|
||||
|
||||
func Pointer2byteSlice(ptr uint32) *[]byte __asm__("__unsafe_get_addr")
|
||||
|
||||
//func Pointer2uint32(ptr interface{}) uint32 __asm__("__unsafe_get_addr")
|
@ -17,6 +17,116 @@ global go.os.DebugOutChar
|
||||
global go.os.DebugOutStr
|
||||
global go.os.WriteText2
|
||||
|
||||
global runtime.memequal32..f
|
||||
runtime.memequal32..f:
|
||||
ret
|
||||
|
||||
global runtime.memequal8..f
|
||||
runtime.memequal8..f:
|
||||
ret
|
||||
|
||||
global runtime.memequal
|
||||
runtime.memequal:
|
||||
ret
|
||||
|
||||
global go.os.SetByteString
|
||||
go.os.SetByteString:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
mov eax, [ebp+8]
|
||||
mov ebx, [ebp+12]
|
||||
mov ecx, [ebp+16]
|
||||
mov dh, [ebp+20]
|
||||
mov byte[eax+ecx], dh
|
||||
mov esp, ebp
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
global __go_runtime_error
|
||||
global __go_register_gc_roots
|
||||
global __unsafe_get_addr
|
||||
|
||||
__unsafe_get_addr:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
mov eax, [ebp+8]
|
||||
mov esp, ebp
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
__go_register_gc_roots:
|
||||
__go_runtime_error:
|
||||
ret
|
||||
|
||||
global runtime.writeBarrier
|
||||
global runtime.gcWriteBarrier
|
||||
runtime.writeBarrier:
|
||||
mov eax, [esp+8]
|
||||
mov ebx, [esp+12]
|
||||
mov dword[eax], ebx
|
||||
ret
|
||||
|
||||
global runtime.strequal..f
|
||||
runtime.strequal..f:
|
||||
mov eax,[esp+8]
|
||||
mov ebx,[esp+16]
|
||||
mov ecx,0
|
||||
strcmp_loop:
|
||||
mov byte dl,[eax+ecx]
|
||||
mov byte dh,[ebx+ecx]
|
||||
inc ecx
|
||||
cmp dl,0
|
||||
je strcmp_end_0
|
||||
cmp byte dl,dh
|
||||
je strcmp_loop
|
||||
jl strcmp_end_1
|
||||
jg strcmp_end_2
|
||||
strcmp_end_0:
|
||||
cmp dh,0
|
||||
jne strcmp_end_1
|
||||
xor ecx,ecx
|
||||
ret
|
||||
strcmp_end_1:
|
||||
mov ecx,1
|
||||
ret
|
||||
strcmp_end_2:
|
||||
mov ecx,-1
|
||||
ret
|
||||
|
||||
runtime.gcWriteBarrier:
|
||||
mov eax, [esp+8]
|
||||
mov ebx, [esp+12]
|
||||
mov dword[eax], ebx
|
||||
ret
|
||||
|
||||
global runtime.goPanicIndex
|
||||
runtime.goPanicIndex:
|
||||
ret
|
||||
|
||||
global runtime.registerGCRoots
|
||||
runtime.registerGCRoots:
|
||||
ret
|
||||
|
||||
global memcmp
|
||||
memcmp:
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
mov esi, [ebp+8] ; Move first pointer to esi
|
||||
mov edi, [ebp+12] ; Move second pointer to edi
|
||||
mov ecx, [ebp+16] ; Move length to ecx
|
||||
|
||||
cld ; Clear DF, the direction flag, so comparisons happen
|
||||
; at increasing addresses
|
||||
cmp ecx, ecx ; Special case: If length parameter to memcmp is
|
||||
; zero, don't compare any bytes.
|
||||
repe cmpsb ; Compare bytes at DS:ESI and ES:EDI, setting flags
|
||||
; Repeat this while equal ZF is set
|
||||
setz al
|
||||
mov esp,ebp
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
|
||||
go.os.Sleep:
|
||||
push ebp
|
||||
mov ebp,esp
|
||||
@ -211,3 +321,7 @@ go.os.CreateButton:
|
||||
SECTION .data
|
||||
__hexdigits:
|
||||
db '0123456789ABCDEF'
|
||||
|
||||
__test:
|
||||
dd __hexdigits
|
||||
dd 15
|
Loading…
Reference in New Issue
Block a user