2015年12月29日 星期二

New build asrock am1b-itx am1 xp-sp2 system

[new-system asrock am1b-itx MINI-ITX am1 xp-sp2]
install xpsp2 with shipped dvd driver ,
all hardware device driver install OK, all driver identify by system.
After a little test and usage.
system seems not work perfectly with vga driver
 ( sometime BSOD with ATI2DVAG.DLL error)

after update with 14-4-xp32-64-dd-ccc-pack3.exe  from AMD sites'  legency driver

The whole system became more more more stable,
and ATI2DVAG.DLL Blue BSOD disappear.


[新系統 asrock am1b-itx am1 xp-sp2]
新裝了 xp-sp2 的 am1b-itx CPU 5350 , 8G ram , 320G 2.5" harddisk.
用 附帶的 dvd-driver 安裝, 裝置管理員,所有的裝置都有找到適當的驅動.
一開始的時候 vga driver 在開啟新的 ap 時(如sketchup) 不定時會 bsod 死當,或跳回
640x480 16 色模式.

到 amd 網站下載 14-4-xp32-64-dd-ccc-pack3.exe 安裝了新的驅動後,
整個系統就非常穩定, 沒有再發生 vga driver 異常,或系統死當的情形了.

2015年7月3日 星期五

must modify to compile iVerilog 2015-07-01 HEAD version

Below change is for Mingw32 to build icarus iverilog 2015-07-01 git HEAD version
and mingw must have pthread dev package installed


\MinGW\msys\1.0\home\lcf\iverilog\config.h (3 hits)
    Line 38: // lcf
    Line 41: // lcf
    Line 44: // lcf
# undef HAVE_TIMES
//# undef HAVE_IOSFWD
#define HAVE_IOSFWD
// lcf
//# undef HAVE_GETOPT_H
#define HAVE_GETOPT_H
// lcf
// # undef HAVE_INTTYPES_H
#define HAVE_INTTYPES_H
// lcf
# undef HAVE_LIBIBERTY_H


   
\MinGW\msys\1.0\home\lcf\iverilog\libveriuser\config.h (1 hit)
    Line 42: // lcf

#include  stdint.h     // angle bracket
// lcf
#endif /* IVL_config_H */   


   
\MinGW\msys\1.0\home\lcf\iverilog\libveriuser\priv.h (1 hit)
    Line 24: // lcf
# include  stdio.h   // angle bracket
#include "config.h"
// lcf   



\MinGW\msys\1.0\home\lcf\iverilog\vhdlpp\vhdlpp_config.h (1 hit)
    Line 33: // lcf
// # undef HAVE_GETOPT_H
#define HAVE_GETOPT_H
// lcf
// # undef HAVE_INTTYPES_H
#define HAVE_INTTYPES_H
   

   
\MinGW\msys\1.0\home\lcf\iverilog\vpi\sys_priv.h (1 hit)
    Line 25: // lcf
#include  stdint.h    // angle bracket
// lcf   
   
   
   
\MinGW\msys\1.0\home\lcf\iverilog\vvp\config.h (3 hits)
    Line 43: // lcf
    Line 49: // lcf
    Line 56: // lcf
// # undef HAVE_IOSFWD
#define HAVE_IOSFWD
// lcf

# undef HAVE_DLFCN_H
# undef HAVE_DL_H
// # undef HAVE_GETOPT_H
#define HAVE_GETOPT_H
// lcf
# undef HAVE_LIBREADLINE
# undef HAVE_READLINE_READLINE_H
# undef HAVE_LIBHISTORY
# undef HAVE_READLINE_HISTORY_H
// # undef HAVE_INTTYPES_H
#define HAVE_INTTYPES_H
// lcf

2015年6月15日 星期一

How to Use 22nice CP/M 2.2 emulator in dosbox(emu)



[[[1]  22nce142.zip  extract  x:\22nice     ;; x: is your selection drive maybe c: d:

[[[2] change dosbox.conf     in [autoexec]  section

  mount c x:\22nice
  c:

[[[3] copy some  cpm(80)   .com file to    x:\22nice   , for example MBASIC.COM


[[[4]  rename x:\22nice\MBASIC.COM   to MBASIC.CPM


[[[5] START DOSBOX

[[[6]
22NICE.exe [CR]
GENCOM MBASIC.CPM PROCESSOR=Z80  ;; will generate small MBASIC.COM

MBASIC [CR]    ;;  RUN z80/cpm80's MBASIC  will bring up Microsoft cp/m basic
 
      

2015年5月26日 星期二

build your own custom menu_bar in sketchUP 8

icon png file and ruby file  put in  Your_sketchup_install_dir/Plugins/m/

FILE: tool_bar_test.rb


   require 'sketchup.rb'
    puts("start tool_bar_test")

    toolbar = UI::Toolbar.new "tool_my_bar"

    cmd = UI::Command.new("xyz_cmd 1") {
       Sketchup.send_action("selectDimensionTool:")
       # UI.messagebox "exe cmd 1"

    }

    path="Plugins/m/"
    
    ic_1 = "reset_16.png"
    ic_2 = "reset_24.png"    

    small=Sketchup.find_support_file(ic_1 ,path)
    large=Sketchup.find_support_file(ic_2 ,path)
    cmd.small_icon = small
    cmd.large_icon = large
    cmd.tooltip = "I am cmd 1"
    cmd.status_bar_text = "st I am cmd 1"
    cmd.menu_text = "cmd 1 txt"
    toolbar = toolbar.add_item cmd


    cmd2 = UI::Command.new("xyz_cmd 2") {
       UI.messagebox "ver [004] exe cmd2"
    }
    # ic_1 = "northtool_small.png"
    # ic_2 = "northtool.png"   
    small=Sketchup.find_support_file(ic_1 ,path)
    large=Sketchup.find_support_file(ic_2 ,path)
    cmd2.small_icon = small
    cmd2.large_icon = large
    cmd2.tooltip = "Test cmd2"
    cmd2.status_bar_text = "st I am cmd2"
    cmd2.menu_text = "cmd 2 txt"
    toolbar = toolbar.add_item cmd2

    toolbar.show

    puts(cmd.small_icon)
    puts(cmd.large_icon)
    puts("end tool_bar_test")

2014年10月26日 星期日

windows dll share data , using pelles C 7.0R

/*
   dll file must using same folder's dll,
   X:/xx/xxx/my_dll.dll
   O:/ooo/oo/my_dll.dll
 my_dll.dll  =content=  mydll.dll
but loading to memory , it's two different dll.
*/
 
/* below is dll key function and compiler option */
/*
compiler option :  Enable microsoft extension ,   calling conv: __cdecl

*/

#pragma data_seg(".shared")
    int share_var_k = 0;
#pragma data_seg()
#pragma comment(linker, "/section:.shared,RWS")


DLLAPI int WINAPI get_share_var(void)
{   
     return share_var_k;
}

DLLAPI void WINAPI set_share_var(int value)
{   
     share_var_k = value;
}





/* ---- cut ---- */





/* -------------- below is test file function ------*/

int main(int argc, char *argv[])
{
    printf("Hello, world!\n");
    for(int i=0;i<25 br="" i="">    {
        int value=0;
        set_share_var(i);
        Sleep(1000);
        value = get_share_var();
        printf("%d\r\n",value);
    }
    return 0;

2014年10月18日 星期六

lcc-win32 build openeuolua


build a openeuolua.dll for

work for LFW LuaForWindows_v5.1.4-46.exe (from goggle code)

in OpenEUOLua.zip   OpenEUOLua.txt copy rename to -->  openeuolua.c

; make an lib for lcc-win32 usage
copy X:\lua\5.1\lib\lua51.lib
pedump /EXP lua51.lib > 51.exp
buildlib 51.exp lua51_lcc.lib
 
makefile
[code]
SRCDIR=e:\lcc\p\openeuolua
CFLAGS=-I"E:\lcc\p\OpenEUOLua\lua51\include" -I"e:\lcc\include" -DWIN32 -DLUA_BUILD_AS_DLL
CC=$(LCCROOT)\bin\lcc.exe
LINKER=$(LCCROOT)\bin\lcclnk.exe
OBJS=\
    openeuolua.obj

LIBS=e:\lcc\p\openeuolua\lua51_lcc.lib
EXE=e:\lua\5.1\clibs\openeuolua.dll

$(EXE):    $(OBJS) Makefile
    $(LINKER)  -s -dll -entry DllMain -nounderscores -o e:\lua\5.1\clibs\openeuolua.dll $(OBJS) $(LIBS)

# Build openeuolua.c
OPENEUOLUA_C=\
    $(SRCDIR)\lua51\include\lauxlib.h\
    $(SRCDIR)\lua51\include\lua.h\
    $(SRCDIR)\lua51\include\luaconf.h\

openeuolua.obj: $(OPENEUOLUA_C) $(SRCDIR)\openeuolua.c
    $(CC) -c $(CFLAGS) $(SRCDIR)\openeuolua.c

link:
    $(LINKER)  -s -dll -entry DllMain -nounderscores -o e:\lua\5.1\clibs\openeuolua.dll $(OBJS) $(LIBS)

clean:
    del $(OBJS) openeuolua.dll
[/code]

build lua dll module in mingw/msys

1. install mingw/msys , base_mingw,base_msys,g++
2. postinstall msys

3. download & build lua 5.1.5
    make mingw
4. write a dll4lua.c   
    gcc  -O2  -c  -o dll4lua.o  dll4lua.c
    gcc  -O    -shared -o dll4lua.dll  dll4lua.o -llua

2014年10月16日 星期四

xpsp3 install mingw using mingw-get-setup , after download ok , need run postinstall script/batch file

as title say:
   When online install msys + mingw , using  mingw-get-setup
after install ok , need to run postinstall script, otherwise
msys.bat environment don't recongnize your mingw tool-chain.

2014年10月13日 星期一

LUA read only table

-----------------------------------------------
-- file DIR.lua

function readOnly (table)
  local proxy = {}
  local mt = {       -- create metatable
    __index = table
    ,__newindex = function (x,k,v)
      error("read-only "..k, 2)
    end
    ,__metatable = false
  }
  setmetatable(proxy, mt)
  return proxy
end

local t = { LEFT = 7, RIGHT = 8 }
DIR = readOnly(t)

---------------------------------------------
-- file test.lua
dofile("DIR.lua")

print("t="..tostring(t))

print("LEFT="..DIR.LEFT)
-- DIR.LEFT = 9                -- : read-only LEFT
print("LEFT="..DIR.LEFT)

mt = getmetatable(DIR)
print("mt="..tostring(mt))

---------------------------------------------
-- output
t=nil
LEFT=7
LEFT=7
mt=false

LUA Point class example 2

--
-- refine Point class for LUA
--
function class()
  local cls = {}
  cls.__index = cls
  return setmetatable(cls,
    { __call = function (c, ...)
       instance = setmetatable({}, cls)
       if cls.__init then
          cls.__init(instance, ...)
       end
       return instance
      end
    }
  )
end

Point = class()
Point.key_list = {"x","y","z"}

function Point.__index(t,key)
  error("No such Point member or init:"..key ,2)
end

function Point.__newindex(t,key,value)
  for i = 1,#Point.key_list do
    if key == Point.key_list[i] then
       -- t[key] = value
       rawset(t,key,value)
       return
    end 
  end
  error("No such Point member :"..key ,2)
end

function Point:__init(...)
 args = { ... }
 if #args == 3 then
   self.x = args[1]
   self.y = args[2]
   self.z = args[3]
 elseif #args == 2 then
   self.x = args[1]
   self.y = args[2]
 else
    error("2D or 3D only" ,2)  
 end
end

function Point:__tostring()
  local out = ""..self.x..","..self.y
 
  local zz = rawget(self,"z")      
  if zz ~= nil then
     out=out..","..self.z
  end
  return out 
end

--
-- Usage
--

p1 = Point(1,2)
p2 = Point(3,4)

p1.x = 8

x1,y1=p1.x,p1.y
print(string.format("x1,y1=%d,%d",x1,y1))

-- p2 = p1

print(string.format("x2,y2=%d,%d",p2.x,p2.y))
--
local points = {p1,p2}
print("points[1].x=" .. points[1].x)
print("points[2].y=" .. points[2].y)


print("p1="..tostring(p1))
--print("p1="..p1)

p3 = Point(4,5,6)
print("p3="..tostring(p3))

--[[ below is two  error test
print("p1.z="..p1.z)  -- : No such Point member or init:z
p1.xxx = 567          -- : No such Point member :xxx
-- ]]

--
--[[ output
--
x1,y1=8,2
x2,y2=3,4
points[1].x=8
points[2].y=4
p1=8,2
p3=4,5,6
: No such Point member or init:z
: No such Point member :xxx
-- ]]

2014年10月12日 星期日

lua 2d/3d point class

--
-- define Point class for LUA
--
Point = {}
Point.key_list = {"x","y","z"}

function Point.__index(t,key)
  error("No such Point member or init:"..key ,2)
end

function Point.__newindex(t,key,value)
  for i = 1,#Point.key_list do
    if key == Point.key_list[i] then
       -- t[key] = value
       rawset(t,key,value)
       return
    end 
  end
  error("No such Point member :"..key ,2)
end

function Point.new(...)
 local pt = {}
 args = { ... }
 if #args == 3 then
   pt.x = args[1]
   pt.y = args[2]
   pt.z = args[3]
 elseif #args == 2 then
   pt.x = args[1]
   pt.y = args[2]
 else
    error("2D or 3D only" ,2)  
 end
 setmetatable(pt,Point)
 return pt
end

--
-- Usage
--

p1 = Point.new(1,2)
p2 = Point.new(3,4)

p1.x = 8

x1,y1=p1.x,p1.y
print(string.format("x1,y1=%d,%d",x1,y1))

-- p2 = p1

print(string.format("x2,y2=%d,%d",p2.x,p2.y))
--
local points = {p1,p2}
print("points[1].x=" .. points[1].x)
print("points[2].y=" .. points[2].y)

-- [[ below is two  error test
print("p1.z="..p1.z)  -- : No such Point member or init:z
p1.xxx = 567          -- : No such Point member :xxx
-- ]]

--
--[[ output
--
x1,y1=8,2
x2,y2=3,4
points[1].x=8
points[2].y=4
: No such Point member or init:z
: No such Point member :xxx
-- ]]

2014年9月27日 星期六

lua queue example

[code]
queue = {}
           
function queue.new()
  return { first = 1, last = 0 }
end

function queue.push( Q, value)
  local last = Q.last + 1
  Q.last = last
  Q[last] = value
end

function queue.pop(Q)
  local first = Q.first
  local last = Q.last
  if first > last then error("Q is empty") end
  local value = Q[first]
  Q[first] = nil
  if first >= last then
    Q.first = 1
    Q.last = 0
  else
    Q.first = first + 1
  end
  return value
end

function queue.size(Q)
  local first,last = Q.first,Q.last
  print(string.format("(%d,%d)",first,last))
  if (last < first) then return 0 end
  return last-first+1
end

nq = queue.new()
print("q'size1="..queue.size(nq))
-- queue.pop(nq)

for i = 1, 10 ,2  do
  queue.push( nq, i)
end
print("q'size2="..queue.size(nq))

for m = nq.first,nq.last do
  print(""..m.."]="..nq[m])
end

print("first "..nq[nq.first])
local v
v = nq.first       print(" v1 =".. v)
v = queue.pop(nq)  print("pop = "..v)

v = nq.first       print(" v2 =".. v)
v = queue.pop(nq)  print("pop = "..v)

for m = nq.first,nq.last do
  print(""..m.."]="..nq[m])
end

local n = queue.size(nq)
print("q'size3="..n)
for i=1,n do
    v=queue.pop(nq)
    print(""..i.."]="..v)
end

print("q'size4="..queue.size(nq))
print("#nq="..#nq)
[/code]


---- output ----
(1,0)
q'size1=0
(1,5)
q'size2=5
1]=1
2]=3
3]=5
4]=7
5]=9
first 1
 v1 =1
pop = 1
 v2 =2
pop = 3
3]=5
4]=7
5]=9
(3,5)
q'size3=3
1]=5
2]=7
3]=9
(1,0)
q'size4=0
#nq=0

車 和 東 , 兩個 不喜歡的 簡體字 寫法

  车 是 草書 形變, 很難 和 小孩 解釋 為什麼 長這樣(反正你就背), 反而 車 就 很形象. 东 是 草書 形變, 很難 和 小孩 解釋 為什麼 長這樣( 反正你就背), (古人觀察到 日出東方, 東 是 木頭 加 日 , 那個方向 是 東.