fl fl { ROM-chip(GT21L16J1Y) PropForth 5.5 2014/05/27 15:37:26 propeller ROM-chip(GT21L16J1Y) P10 ----> sclk P11 ----> cs P12 ----> si P13 <---- so } \ =========================================================================== \ Constants \ =========================================================================== d12 wconstant SCK d13 wconstant CS d14 wconstant DO d15 wconstant DI \ =========================================================================== \ Variables \ =========================================================================== variable font d28 allot \ =========================================================================== \ Main \ =========================================================================== \ Initialize ports \ ( -- ) : initROM SCK pinout CS pinhi CS pinout DO pinout ; : do_h DO pinhi ; : do_l DO pinlo ; : sck_h SCK pinhi ; : sck_l SCK pinlo ; : di_m DI >m ; \ READ instruction \ ( n1 n2 -- n3-nn ) n1:byte number n2:address[24bit] n3-nn:reading data : read_ROM CS pinlo \ ( n1 n2 ) \ Send instruction 3 h80 8 0 do 2dup and 0<> if do_h else do_l then sck_h sck_l 1 rshift loop 2drop \ Send address h800000 \ ( n1 n2 h800 ) d24 0 do sck_l 2dup and 0<> if do_h else do_l then sck_h 1 rshift loop 2drop \ ( n1 ) do_l sck_l \ Read data 0 do 0 8 0 do 1 lshift sck_h ina COG@ di_m and 0<> if 1 else 0 then or sck_l loop font i + C! loop CS pinhi ; \ Get font address \ ( n1 n2 -- n3 ) n1:decimal[8bit] n2:decimal[8bit] n3:address[24bit] : get_addr1 2dup \ 1 d94 between swap 1 d15 between and if 1- d32 u* swap 1- d3008 u* + else 2dup 1 d94 between swap d16 d47 between and if 1- d32 u* d43584 + swap d16 - d3008 u* + else 2dup 1 d94 between swap d48 d84 between and if 1- d32 u* d138463 + swap d48 - d3008 u* + else 2dup 1 d94 between swap d85 = and if 1- d32 u* d246944 + swap d85 - d3008 u* + else 1- d32 u* d249952 + swap d88 - d3008 u* + thens ; \ Get font address \ ( n1 -- n2 ) n1:ASCII code[h20 - h7F] n2:address[24bit] : get_addr2 h20 - d16 u* d255968 + ; \ Get font address \ ( n1 -- n2 ) n1:ASCII code[h00 - hFF] n2:address[24bit] : get_addr3 d16 u* d257504 + ; \ Get font address \ ( n1 -- n2 ) n1:ASCII code[h00 - hFF] n2:address[24bit] : get_addr4 d16 u* d261600 + ; \ Print character type1(JIS0208:16X16) to TearTerm \ ( n -- ) n1:font address : print_char1 1 swap 8 0 do 2dup \ ( 1 font 1 font ) d16 0 do 2dup \ ( 1 font 1 font 1 font ) C@ j rshift and 0<> if h2A else bl then emit bl emit 1+ loop 2drop cr loop 2drop ; \ Print character type2,3,4(8X16) to TearTerm \ ( n -- ) n1:font address : print_char2 1 swap 8 0 do 2dup \ ( 1 font 1 font ) 8 0 do 2dup \ ( 1 font 1 font 1 font ) C@ j rshift and 0<> if h2A else bl then emit bl emit 1+ loop 2drop cr loop 2drop ; \ ( n1 n2 -- ) n1:data n2:data \ 16X16 : char_type1 get_addr1 d32 swap read_ROM font d32 dump font print_char1 font d16 + print_char1 ; \ ( n1 -- ) n1:ASCII code[h20 - h7F] \ 8X16 : char_type2 h20 - d16 u* d255968 + d16 swap read_ROM font d16 dump font print_char2 font 8 + print_char2 ; \ ( n1 -- ) n1:ASCII code[h00 - hFF] \ 8X16 : char_type3 d16 u* d257504 + dup . cr d16 swap read_ROM font d16 dump font print_char2 font 8 + print_char2 ; \ ( n1 -- ) n1:ASCII code[h00 - hFF] \ 8X16 : char_type4 d16 u* d261600 + dup . cr d16 swap read_ROM font d16 dump font print_char2 font 8 + print_char2 ; : demo initROM 3 d33 char_type1 1 d67 char_type1 d31 7 char_type1 d16 1 char_type1 d17 1 char_type1 ; : test1 h80 h20 do i char_type2 loop ; : test2 h100 0 do i char_type3 loop ; : test3 h100 0 do i char_type4 loop ;