Created
May 24, 2019 15:13
-
-
Save 12Me21/1ef203dafbafcdbfe83c8c962cfb7895 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' | |
' SOFT KEYBOARD + HELP + CMPL + GUIDE | |
' | |
' ※プログラム内に含まれるいくつかの命令はシステム専用命令で通常実行環境では使えません | |
' | |
' 2018.11.06:UISTATE | |
' 2018.11.07:TOUCH(FRAME COUNTER),UIMASK | |
' 2018.11.08:確認方法の間違いを直してもらったので見直してコメント追加 | |
' 2018.11.09:CTRLKEYボタン追加 | |
' 2018.11.15:UIGETCMPL | |
' 2018.11.18:CMPLの選択追加 | |
' 2018.11.19:CMPLのページ切り替えと不要時の消去追加 | |
' 2018.11.19:単漢字変換追加(マウスだと外周以外選択不能・・) | |
' 2018.11.21:単漢字変換モード追加 | |
' 2018.12.03:GPUTCHR新しい引数に対応/CAPSキー追加/全体的なキーレイアウトの見直し | |
' 2018.12.03:ファンクションキーの定義文字列表示 | |
' 2018.12.05:GLOAD対応 | |
' 2018.12.10:ENUM対応 | |
' 2018.12.11:ボタン配置の変更(種別切り替えを左下へ、機能を右下への実験) | |
' 2018.12.17:表示優先順位調整 | |
' 2018.12.18:レイアウトをスロット1,2から読み込む方法へ変更 | |
' 2018.12.23:DEF表示対応 | |
' 2019.01.04:HELPレンダリングテスト | |
' 2019.01.08:候補レイアウト調整 | |
' 2019.02.06:キーコードを最新の情報に置き換え | |
' 2019.02.06:ヘルプの表示機能も統合(ソフトキーボードとは排他制御) | |
' 2019.02.15:キーコードを最新の情報に置き換え | |
' 2019.02.15:ヘルプの表示追加 | |
' 2019.02.18:ヘルプ横向きに対応 | |
' 2019.02.19:SBLIBからUSBキー処理部分抜出 | |
' -------------------------------------- | |
' 2019.02.26:新しいUISTATEに対応 | |
' 2019.02.27:キーマスクに対応 | |
' 2019,03,02:HELPを別ファイル(HELP.PRG)に分離 | |
' 2019.03.07:起動時必ず画像を読み込む | |
' 2019.03.08:メインループ前にスプライトを生成して置く | |
' 2019.03.09:漢字と命令候補スプライトを別扱いへ(定義だけして未実装) | |
' 2019.03.11:ひとまず、漢字の方がが優先順位が高い扱いとする | |
' -------------------------------------- | |
' 2019.03.11:引数付きの新しいUISTATEの仕様に対応 | |
' 2019.03.12:メインループ前にスプライトを生成中止 | |
' 2019.03.13:レイヤー1を描画の基本とする | |
' 2019.03.18:候補選択にカーソル追加(背景の点滅) | |
' -------------------------------------- | |
' 2019.03.19:下キーが押されるまでカーソル消しておく | |
' 2019.03.19:ソフトキーが出たら命令候補のフラグを無視してパネルを表示 | |
' 2019.03.20:ヘルプに操作ボタン追加 | |
' 2019.03.26:命令候補のマスク範囲の間違い修正 | |
' 2019.03.28:クローズ時のマスク解放修正 | |
' -------------------------------------- | |
' 2019.03.29:UIST仕様変更に対応 | |
' 2019.04.02:レイアウト配置変更に対応 | |
' -------------------------------------- | |
' 2019.04.04:CMPL定義位置2廃止 | |
' 2019.04.05:単漢字変換モード修正(モード切替でリセット) | |
' 2019.04.11:ヘルプを高速にON/OFFした場合の対応 | |
' 2019.04.20:タッチした場所にマウスを移動 | |
' 2019.04.23:BS入力後の単漢字変換でエラー修正 | |
' | |
' | |
'実行前にPROJECTでカレントを指定しておくこと | |
' | |
' | |
OPTION STRICT | |
SYSPARAM "MOUSECURSOR",1 | |
'--- CONTROL PORT | |
VAR UIST=0,UIP1=0,UIP2=0,UIP3=0,UIP4=0,UIP5=0 | |
'--- TOUCH STATE | |
VAR TOUCHTIME=0, TOUCHX=0, TOUCHY=0 | |
'--- UIST(SYSTEM RESERVED) | |
CONST #UIST_SKEY =&B000_00000_00_00_0_001 'SOFTKEY | |
CONST #UIST_HELP =&B000_00000_00_00_0_010 'HELP | |
CONST #UIST_CMPL =&B000_00000_00_00_0_100 'CMPL | |
CONST #UIST_HELPCTRL=&B000_00000_00_00_1_000 'HELP操作禁止 | |
CONST #UIST_LAYTYPE =&B000_00000_00_11_0_000 '配置(0: 1: 2: 3:) | |
CONST #UIST_LAYUD =&B000_00000_00_01_0_000 '配置(00: 01:) | |
CONST #UIST_LAYLR =&B000_00000_00_10_0_000 '配置(10: 11:) | |
CONST #UIST_RESERVED=&B000_00000_11_00_0_000 '予約 | |
CONST #UIST_MASKALL =&B000_11111_00_00_0_000 ' | |
CONST #UIST_MASKSTD =&B000_00001_00_00_0_000 '通常キー | |
CONST #UIST_MASKENT =&B000_00010_00_00_0_000 'ENTER | |
CONST #UIST_MASKEDT =&B000_00100_00_00_0_000 'BS+DEL+CSRLF+CSRRI | |
CONST #UIST_MASKCSR =&B000_01000_00_00_0_000 'CSRUP,DW | |
CONST #UIST_MASKRST =&B000_10000_00_00_0_000 '上記以外のキー | |
CONST #SFT_LAYTYPE=4 | |
'--- UIP1(USER) | |
CONST #UIP1_KEYMODE =&H00000003,#SFT_KEYMODE =0 | |
CONST #UIP1_KEYSHIFT =&H00000004,#SFT_KEYSHIFT =2 | |
CONST #UIP1_KEYCTRL =&H00000008,#SFT_KEYCTRL =3 | |
CONST #UIP1_REQKEYMODE=&H000000F0,#SFT_REQKEYMODE =4 | |
CONST #UIP1_REQPAGE =&H00000F00,#SFT_REQPAGE =8 | |
CONST #UIP1_KEYPAGE0 =&H0000F000,#SFT_KEYPAGE0 =12 | |
CONST #UIP1_KEYPAGE1 =&H000F0000,#SFT_KEYPAGE1 =16 | |
CONST #UIP1_KEYPAGE2 =&H00F00000,#SFT_KEYPAGE2 =20 | |
CONST #UIP1_VERSION =&HF0000000,#SFT_VERSION =28 | |
'--- | |
CONST #UIPVERSION=1 | |
'--- | |
CONST #KEYLAY_RIGHT=0 | |
CONST #KEYLAY_DOWN =1 | |
CONST #KEYLAY_LEFT =2 | |
CONST #KEYLAY_UP =3 | |
CONST #MAX_KEYLAY =4 | |
'--- | |
CONST #SE_KEY=139 | |
CONST #SE_KEY_VOL=24 | |
VAR KEYLAYTYPE=#KEYLAY_RIGHT | |
VAR KEYMASK=0 | |
VAR CMPLREDRAW=0 | |
VAR HELPCTRL=0 | |
'--- UIP2(USER) | |
CONST #UIP2_X =&H0000FFFF,#SFT_X =0 | |
CONST #UIP2_Y =&HFFFF0000,#SFT_Y =16 | |
'--- UIP3(USER) | |
CONST #UIP3_FLASH =&HFFFFFFFF '0=NONE | |
'--- UIP4(USER) | |
'--- UIP5(USER) | |
'--- FLASH KEY | |
CONST #FLASH_WAIT=30 | |
VAR FLASHKEY$="あ" | |
'--- COLOR | |
CONST #C_MASKOFF =RGB(128, 64, 64, 64) | |
CONST #C_FLASHON =RGB(255,255, 0, 64) | |
CONST #C_FLASHOFF=RGB(255, 8, 8, 8) | |
CONST #C_CMPLBASE=RGB(160, 15, 15, 15) | |
CONST #C_KANJI =RGB(255,255,128,240) | |
CONST #C_HELP =RGB(160, 32, 64,160) | |
'--- SPLINK STYLE | |
CONST #SPLK_BRD=&B0001 'SPLINK SYNC b0(HIDE/CLR) | |
CONST #SPLK_COL=&B1001 'SPLINK SYNC b0(HIDE/CLR) b3(COLOR) | |
'--- LAYER | |
CONST #LAY_BASE=1 | |
CONST #LAY_HELP=0 | |
'--- ALPHA BLEND | |
CONST #ALPON=3 'ALPHA * ALPHA | |
'--- BUTTON(KEYBOARD/STICK) | |
ENUM \ | |
#INP_MIX=0,\ | |
#INP_BUTTON,\ | |
#INP_KEY,\ | |
#INP_STICKL,\ | |
#INP_STICKR,\ | |
#MAX_INP | |
ENUM \ | |
#IMD_NEW=0,\ | |
#IMD_REPEAT,\ | |
#IMD_IMPACT,\ | |
#IMD_RELEASE,\ | |
#IMD_VX,\ | |
#IMD_VY,\ | |
#IMD_REPVX,\ | |
#IMD_REPVY,\ | |
#IMD_OLD,\ | |
#IMD_TIME,\ | |
#IMD_X,\ | |
#IMD_Y,\ | |
#MAX_IMD | |
CONST #MAX_IDTBL=3 | |
DIM IDTBL[#MAX_IDTBL]=[\ | |
#INP_BUTTON,\ | |
#INP_KEY,\ | |
#INP_STICKL\ | |
] | |
VAR OLDKEY$="",KEY$="" | |
VAR INSMODE=0,CAPSMODE=0,ISESC=0,ISSHIFT=0,ISCTRL=0 | |
VAR ISBS=0,BSCNT=0,ISDEL=0,DELCNT=0 | |
VAR ISENT=0,ENTCNT=0,ISTAB=0,TABCNT=0 | |
VAR PGUPCNT=0,ISPGUP=0,PGDWCNT=0,ISPGDW=0 | |
VAR HMCNT=0,ISHOME=0,EDCNT=0,ISEND=0 | |
VAR INP[#MAX_INP,#MAX_IMD] | |
'--- KEY REPEAT | |
VAR KW1,KW2 | |
SYSPARAM "KEYREPEAT" OUT KW1,KW2 | |
'--- CONTROLLER REPEAT | |
BREPEAT #B_LUP,KW1,KW2 | |
BREPEAT #B_LDOWN,KW1,KW2 | |
BREPEAT #B_LLEFT,KW1,KW2 | |
BREPEAT #B_LRIGHT,KW1,KW2 | |
BREPEAT #B_RUP,KW1,KW2 | |
BREPEAT #B_RDOWN,KW1,KW2 | |
BREPEAT #B_RLEFT,KW1,KW2 | |
BREPEAT #B_RRIGHT,KW1,KW2 | |
'--- Z | |
CONST #Z_MOS =-4095 | |
CONST #Z_TOP =-4000 | |
CONST #Z_INFO =-1000 | |
CONST #Z_HELP =-10 | |
CONST #Z_KEY =-2 'CHILD | |
CONST #Z_TX =0 | |
CONST #Z_SPTOP=100 | |
CONST #Z_SPHI =500 | |
CONST #Z_SP =1000 | |
CONST #Z_SPLO =1500 | |
CONST #Z_GR =2000 | |
CONST #Z_GRLO =3000 | |
CONST #Z_END =4000 | |
'--- BOARD STATUS(0=CLOSE,1=OPEN) | |
VAR USE_SKEY=0 | |
VAR USE_HELP=0 | |
VAR USE_CMPL=0 | |
ANIMDEF | |
'--- 起動時の状態でファイル名等を変更する | |
CONST #SLOT_LAYW=1 | |
CONST #SLOT_LAYH=2 | |
VAR GPAGE=(ENVTYPE()!=2)*4 'UIRUN=2 | |
VAR GRPFILE$="" | |
'--- レイアウトデータを読み込んで利用可能にしておく | |
EXEC "KEYLAY01.TXT",#SLOT_LAYW | |
EXEC "KEYLAY02.TXT",#SLOT_LAYH | |
'--- RESET SCREEN | |
CONST #SCW=1280,#SCH=720 | |
IF GETPAGE() THEN | |
'--- RUN | |
ACLS | |
XSCREEN #SCW,#SCH,#SCW/#SCH | |
TSCREEN 0,16,16:COLOR 0,#C_YELLOW | |
TOFS 0,#SCW/4,0 | |
TPRINT 0,"### DEBUG MODE ###" | |
TLAYER 0,#LAY_BASE | |
TSCREEN 1,16,16:COLOR 1,#C_CYAN | |
TLAYER 1,#LAY_BASE | |
TSCREEN 4,16,16 '4=CONSOLE | |
ELSE | |
'--- UIRUN | |
SPCLR:CLS 'ACLS禁止(対応していない機能で誤動作) | |
TSCREEN 4,16,16 | |
ENDIF | |
SPPAGE GETPAGE() | |
'--- ベースレイヤーの変更 | |
TLAYER 4,#LAY_BASE | |
SPLAYER #LAY_BASE | |
' | |
'### KEY MASK | |
' | |
CONST #MSK_SYS=&B000_00000_00_00_0_001 'キーじゃない部品 | |
CONST #MSK_OFF=&B000_11111_00_00_0_000 | |
CONST #MSK_STD=&B000_00001_00_00_0_000 | |
CONST #MSK_SPC=&B000_00001_00_00_0_000 | |
CONST #MSK_ALP=&B000_00001_00_00_0_000 | |
CONST #MSK_NUM=&B000_00001_00_00_0_000 | |
CONST #MSK_JP =&B000_00001_00_00_0_000 | |
CONST #MSK_MRK=&B000_00001_00_00_0_000 | |
CONST #MSK_RUN=&B000_00001_00_00_0_000 | |
CONST #MSK_DIR=&B000_00001_00_00_0_000 | |
CONST #MSK_LST=&B000_00001_00_00_0_000 | |
CONST #MSK_ENT=&B000_00010_00_00_0_000 | |
CONST #MSK_BS =&B000_00100_00_00_0_000 | |
CONST #MSK_DEL=&B000_00100_00_00_0_000 | |
CONST #MSK_LF =&B000_00100_00_00_0_000 | |
CONST #MSK_RI =&B000_00100_00_00_0_000 | |
CONST #MSK_UP =&B000_01000_00_00_0_000 | |
CONST #MSK_DW =&B000_01000_00_00_0_000 | |
CONST #MSK_ETC=&B000_10000_00_00_0_000 | |
' | |
'### KEYBOARD CONTROL CODE(2019.2.15) | |
' | |
ENUM \ | |
#CK_UP = &h10000, #CK_DOWN, #CK_LEFT, #CK_RIGHT,\ | |
#CK_BS, #CK_DEL, #CK_PAGEUP, #CK_PAGEDOWN, #CK_TAB,\ | |
#CK_LINETOP, #CK_LINEEND, #CK_LINEJUMP,\ | |
#CK_FILETOP, #CK_FILEEND,\ | |
#CK_INSLINE, #CK_DELLINE, #CK_DELRIGHT, #CK_UNDO, #CK_REDO,\ | |
#CK_SELECTSTART, #CK_SELECTEND,\ | |
#CK_COPY, #CK_CUT, #CK_PASTE, #CK_SMARTDEL,\ | |
#CK_RUN, #CK_EDIT, #CK_EDIT0, #CK_EDIT1, #CK_EDIT2, #CK_EDIT3,\ | |
#CK_STOP, #CK_EXIT, #CK_TOOL, #CK_TOOL2, #CK_TOOL3, #CK_SYSREQ,\ | |
#CK_LOAD, #CK_SAVE, #CK_LISTERR, #CK_SOFTKEY, #CK_ESCAPE,\ | |
#CK_FONT, #CK_WRAP,\ | |
#CK_SPLIT, #CK_SPLIT_SINGLE, #CK_SPLIT_VERTICAL, #CK_SPLIT_HORIZONAL,\ | |
#CK_TAB_INC, #CK_TAB_DEC, #CK_COMMENTOUT, #CK_UNCOMMENTOUT,\ | |
#CK_SCROLL_UP, #CK_SCROLL_DOWN, #CK_SCROLL_LEFT,\ | |
#CK_SCROLL_RIGHT, #CK_SCROLL_PAGEUP, #CK_SCROLL_PAGEDOWN,\ | |
#CK_HELP, #CK_HELP_ON, #CK_HELP_OFF,\ | |
#_obsolete_CK_HELP_PREVHEADER, #_obsolete_CK_HELP_NEXTHEADER, #_obsolete_CK_HELP_COPY,\ | |
#_obsolete_CK_HELP_UP, #_obsolete_CK_HELP_DOWN, #_obsolete_CK_HELP_UPD,\ | |
#CK_FIND_REPL, #_obsolete_CK_FIND_REPLALL, #_obsolete_CK_FIND_REPLNEXT,\ | |
#CK_FIND_REPLSWITCH, #CK_FIND_PREV, #CK_FIND_NEXT, #CK_FINDMODE,\ | |
#CK_FOCUS_NEXT, #CK_FOCUS_PREV, #CK_FOCUS_MAIN, #CK_FOCUS_SUB,\ | |
#CK_FUNC1, #CK_FUNC2, #CK_FUNC3, #CK_FUNC4, #CK_FUNC5,\ | |
#CK_INSERT, #CK_RESET,\ | |
#CK_SOFTKEY_ON, #CK_SOFTKEY_OFF, #CK_TRACE, #CK_PERFGAUGE,\ | |
#CK_SPLIT_GUIDE, #CK_COMPLETION_OFF,\ | |
#CK_SOFTKEY_RIGHT,#CK_SOFTKEY_DOWN,#CK_SOFTKEY_LEFT,#CK_SOFTKEY_UP,\ | |
#CK_ENUMEND | |
'--- SPRITE | |
CONST #SP_MOUSE =0 | |
CONST #SP_HELPTOP =5 | |
CONST #SP_HELPEND =29 | |
CONST #SP_BRDTOP =30 'max 3x3(SOFTWAREKEYBOARD) | |
CONST #SP_BRDEND =38 | |
CONST #SP_CMPLBRDTOP=40 'max 3x3(CMPLBOARD) | |
CONST #SP_CMPLBRDEND=48 | |
CONST #SP_CMPLUP =49 | |
CONST #SP_CMPLDW =50 | |
CONST #SP_CMPLOK =51 | |
CONST #SP_CMPLCSR =52 | |
CONST #SP_CMPLSLD1 =53 | |
CONST #SP_CMPLSLD2 =54 | |
CONST #SP_CMPLNUM =55 | |
CONST #SP_CMPLTOP =56 'max 24 word | |
CONST #SP_CMPLEND =79 | |
CONST #SP_KANJBRDTOP=80 'max 3x3(CMPLBOARD) | |
CONST #SP_KANJBRDEND=88 | |
CONST #SP_KANJTOP =89 'max 21 word | |
CONST #SP_KANJEND =109 | |
CONST #SP_CTRLTOP =110 'max 90 key | |
CONST #SP_CTRLEND =199 | |
CONST #SP_KEYTOP =200 'max 184 key | |
CONST #SP_KEYEND =383 | |
'--- BOARD(PARENT) | |
ENUM \ | |
#MODE_EN=0,\ | |
#MODE_MK,\ | |
#MODE_JP,\ | |
#MODE_CTRL,\ | |
#MODE_NONE,\ | |
#MAX_MODE | |
'--- BOARD POSITION & SIZE | |
VAR C_KEY=RGB(224,255,255,255) | |
VAR BRD_X,BRD_Y,BRD_W,BRD_H | |
VAR BRDMOVE=0,BRDOX=0,BRDOY=0 | |
'--- BOARD STATUS | |
VAR KEYMODE=#MODE_EN,KEYSHIFT=0,KEYCTRL=0 | |
VAR REQKEYMODE=#MODE_NONE,REQPAGE=0 | |
DIM KBD$[#MAX_MODE]=[ "@KB_EN","@KB_MK","@KB_JP","@KB_CTRL","" ] | |
DIM KEYPAGE[#MAX_MODE] | |
FILL KEYPAGE,0 | |
'--- KEYWORD補間 | |
CONST #CMPLOK_TAB =1 | |
CONST #CMPLOK_ENTER=2 | |
CONST #CMPLOK_ESC =-1 | |
CONST #CMPLOK_RIGHT=-2 | |
CONST #CMPLOK_LEFT =-3 | |
VAR C_CMPL=RGB(224,160,160,255) | |
VAR CMPLBRD_W,CMPLBRD_H | |
VAR CMPLBRD_OX,CMPLBRD_OY,CMPL_SX | |
VAR CMPL_U,CMPL_V | |
'VAR CMPL_U2,CMPL_V2 | |
VAR CMPL_W,CMPL_H '1ぎょうのさいだいさいず | |
VAR CMPL_AW,CMPL_AH 'ていぎえりあのさいだいさいず | |
VAR CMPL_KU1,CMPL_KV1,CMPL_KW1,CMPL_KH1,CMPL_KX1,CMPL_KY1 | |
VAR CMPL_KU2,CMPL_KV2,CMPL_KW2,CMPL_KH2,CMPL_KX2,CMPL_KY2 | |
VAR CMPLTS=-1,CMPLMAX,CMPL_MODE=0 | |
VAR CMPLOX=0,CMPLOY=0,CMPLPGY=0,CMPLVY=0,CMPLOK=0 | |
VAR CMPLCX=0,CMPLCY=0,CMPLACTIVE=0,ISCMPLBRD=0 | |
VAR CMPL_LX,CMPL_LY,CMPL_CNTX=0,CMPL_CNTY=0 | |
VAR CMPLLIST$ | |
CONST #MAX_CMPL=4096 | |
DIM CMPLTOP[#MAX_CMPL],CMPLCNT[#MAX_CMPL] | |
'--- CMPL BACKUP | |
VAR _C_CMPL | |
VAR _CMPLBRD_W,_CMPLBRD_H | |
VAR _CMPLBRD_OX,_CMPLBRD_OY,_CMPL_SX | |
VAR _CMPL_U,_CMPL_V | |
VAR _CMPL_AW,_CMPL_AH | |
VAR _CMPL_W,_CMPL_H,_CMPL_CNTX,_CMPL_CNTY | |
VAR _CMPL_LX,_CMPL_LY | |
VAR _CMPL_KX1,_CMPL_KY1 | |
VAR _CMPL_KU1,_CMPL_KV1,_CMPL_KW1,_CMPL_KH1 | |
VAR _CMPL_KX2,_CMPL_KY2 | |
VAR _CMPL_KU2,_CMPL_KV2,_CMPL_KW2,_CMPL_KH2 | |
'--- HELPを読み込んで利用可能にしておく | |
CONST #SLOT_HELP=3 | |
EXEC "HELP.PRG",#SLOT_HELP | |
'--- COLOR | |
CONST #MAX_COL=18 | |
DIM COLNAME$[#MAX_COL],COLVAL[#MAX_COL] | |
INITCOL | |
'--- FONT | |
DIM FONTX[128],FONTW[128] | |
MKFONTXW | |
'--- KANJI | |
CONST #MAX_KANJI=(10*5-(2+4)) | |
VAR KANJIMODE=0 | |
VAR OLDKJ$="",KJCHR$="",KJLIST$="",LASTKJ$="" | |
DIM KANJI$[#MAX_KANJI] | |
SETKANJI KANJI$ | |
'--- 初めて起動した時のステータス読込み | |
UIST=UISTATE(0) | |
UIP1=UISTATE(1) | |
UIP2=UISTATE(2) | |
UIP3=UISTATE(3) | |
UIP4=UISTATE(4) | |
UIP5=UISTATE(5) | |
' | |
'### 最初のスプライト定義 | |
' | |
'--- SOFTKEYBOARD | |
KEYMODE=#MODE_EN | |
KEYSHIFT=0 | |
KEYCTRL=0 | |
REQKEYMODE=#MODE_EN | |
REQPAGE=0 | |
FILL KEYPAGE,0 | |
SETLAYOUT 'ここでCMPLの表示位置も変化 | |
SETUISTPOS BRD_X,BRD_Y | |
'--- LOAD GRP&RESET | |
LOADG GRPFILE$,GETPAGE() | |
'--- MOUSE | |
SPPAGE -1 | |
SPSET #SP_MOUSE,0,0,16,16,0 | |
SPHOME #SP_MOUSE,8,8 | |
SPFUNC #SP_MOUSE,"FUNCMOS" | |
SPCOL #SP_MOUSE,0,0,1,1 | |
SPVAR #SP_MOUSE,"KEY",-1 | |
SPVAR #SP_MOUSE,"TIME",0 | |
SPROT #SP_MOUSE,45 | |
SPANIM #SP_MOUSE,"C",-16,#C_RED,-16,#C_WHITE,0 | |
IF GETPAGE()==0 THEN | |
SPCOLOR #SP_MOUSE,RGB(0,255,255,255) | |
ENDIF | |
SPPAGE GETPAGE() | |
' | |
'### MAIN | |
' | |
LOOP | |
VSYNC '先に同期を取る | |
SB_INPUT0 'キー、ボタン、スティック、マウス、タッチの状態 | |
UISTSUB 'ステータスの状態 | |
UPDATECMPL '命令候補判定 | |
CALL SPRITE 'キーとマウスの接触判定 | |
UPDATEKEY 'キーとの接触状態がマウススプライトに残っている | |
HELPUPDATE 'ヘルプの判定 | |
ENDLOOP | |
END | |
'--------------------------------------- | |
'--------------------------------------- | |
'--------------------------------------- | |
'--------------------------------------- | |
' SPFUNC:MOUSE(TOUCH) | |
'--------------------------------------- | |
DEF FUNCMOS | |
SPOFS CALLIDX(),TOUCHX,TOUCHY,#Z_MOS | |
END | |
'--------------------------------------- | |
' CHECK & CONTROL UISTATE | |
'--------------------------------------- | |
DEF UISTSUB | |
VAR OLDKL=KEYLAYTYPE | |
'--- READ | |
UISTREAD | |
'--- | |
KEYMASK = UIST AND #UIST_MASKALL | |
HELPCTRL = UIST AND #UIST_HELPCTRL | |
KEYLAYTYPE=(UIST AND #UIST_LAYTYPE) >> #SFT_LAYTYPE | |
'--- CHANGE KEY LAYOUT? | |
IF KEYLAYTYPE!=OLDKL THEN | |
IF USE_SKEY THEN | |
DB "="*32+" CHANGE START" | |
SKEYCLOSE | |
CHANGELAYOUT 0 | |
SKEYOPEN | |
DB "="*32+" CHANGE END:"+STR$(KEYLAYTYPE) | |
DB "" | |
ENDIF | |
ENDIF | |
'--- VIEW | |
IF UIST AND #UIST_CMPL THEN CMPLOPEN ELSE CMPLCLOSE | |
IF UIST AND #UIST_SKEY THEN SKEYOPEN ELSE SKEYCLOSE | |
IF UIST AND #UIST_HELP THEN HELPOPEN ELSE HELPCLOSE | |
'--- てんめつするキー | |
IF UIP3 AND #UIP3_FLASH THEN | |
FLASHKEY$=CHR$(UIP3) | |
ELSE | |
FLASHKEY$="" | |
ENDIF | |
'--- WRITE | |
UISTWRITE | |
END | |
'--------------------------------------- | |
' READ UIST | |
'--------------------------------------- | |
DEF UISTREAD | |
'--- READ STATUS | |
UIST=UISTATE(0) | |
UIP1=UISTATE(1) | |
UIP2=UISTATE(2) | |
UIP3=UISTATE(3) | |
UIP4=UISTATE(4) | |
UIP5=UISTATE(5) | |
' | |
' デバッグ用のキー確認 | |
' | |
IF GETPAGE()==0 THEN RETURN | |
'--- '1':SOFTKEY? | |
IF KEYBOARD(&H1E,2) THEN | |
UIST=UIST XOR #UIST_SKEY | |
IF UIST AND #UIST_SKEY THEN UIST=UIST AND NOT(#UIST_HELP OR #UIST_CMPL) | |
ENDIF | |
'--- '2':HELP? | |
IF KEYBOARD(&H1F,2) THEN | |
UIST=UIST XOR #UIST_HELP | |
IF UIST AND #UIST_HELP THEN UIST=UIST AND NOT(#UIST_SKEY OR #UIST_CMPL) | |
ENDIF | |
'--- '3':CMPL? | |
IF KEYBOARD(&H20,2) THEN | |
UIST=UIST XOR #UIST_CMPL | |
IF UIST AND #UIST_CMPL THEN UIST=UIST AND NOT(#UIST_SKEY OR #UIST_HELP) | |
ENDIF | |
'--- '4':RESET? | |
IF KEYBOARD(&H21,2) THEN UIST=0 | |
'--- '5'-'9':MASK | |
IF KEYBOARD(&H22,2) THEN UIST=UIST XOR #UIST_MASKSTD '5 | |
IF KEYBOARD(&H23,2) THEN UIST=UIST XOR #UIST_MASKENT '6 | |
IF KEYBOARD(&H24,2) THEN UIST=UIST XOR #UIST_MASKEDT '7 | |
IF KEYBOARD(&H25,2) THEN UIST=UIST XOR #UIST_MASKCSR '8 | |
IF KEYBOARD(&H26,2) THEN UIST=UIST XOR #UIST_MASKRST '9 | |
'--- '0':HELP CONTROL | |
IF KEYBOARD(&H27,2) THEN UIST=UIST XOR #UIST_HELPCTRL | |
'--- '-':LAYOUT | |
VAR LAY=(KEYLAYTYPE+1) MOD #MAX_KEYLAY | |
IF KEYBOARD(&H2D,2) THEN | |
UIST=UIST AND NOT(#UIST_LAYTYPE) | |
UIST=UIST OR (LAY << #SFT_LAYTYPE) | |
ENDIF | |
'--- '^' | |
'IF KEYBOARD(&H2E,2) THEN UIST=UIST XOR #UIST_LAYLR | |
'--- | |
END | |
'--------------------------------------- | |
' WRITE UIST(UIST0書き込みはきんし) | |
'--------------------------------------- | |
DEF UISTWRITE | |
IF GETPAGE() THEN UISTATE 0,UIST 'SYSTEM | |
UISTATE 1,UIP1 | |
UISTATE 2,UIP2 | |
UISTATE 3,UIP3 | |
UISTATE 4,UIP4 | |
UISTATE 5,UIP5 | |
END | |
'======================================= | |
'======================================= | |
'======================================= | |
'--------------------------------------- | |
' UPDATE HELP | |
'--------------------------------------- | |
DEF HELPUPDATE | |
IF USE_HELP==0 THEN RETURN | |
'DB "HELPUPDATE" | |
IF ISESC THEN HELPEXIT:RETURN | |
'IF ISCTRL && ISTAB THEN ENVFOCUS 0 'TO MAIN | |
HELP_UPDATESUB HELPCTRL 'HELP SLOT | |
END | |
'--------------------------------------- | |
' OPEN HELP | |
'--------------------------------------- | |
DEF HELPOPEN | |
IF USE_HELP THEN RETURN | |
DB "HELPOPEN" | |
IF USE_SKEY THEN SKEYCLOSE | |
IF USE_CMPL THEN PUSHCLOSECMPL:RETURN 'CMPLCLOSE | |
HELP_OPENSUB 'HELP SLOT | |
USE_HELP=1 | |
'--- かきおわったらHELPふようになっている? | |
IF UISTATE(0) AND #UIST_HELP THEN | |
'--- つうじょうどおり | |
SETMASK | |
VAR X,Y,W,H | |
GETLAYPOS 0 OUT X,Y,W,H | |
UIFOCUS X,Y,W,H | |
ELSE | |
'--- きょうせいてきにとじる | |
HELPCLOSE | |
ENDIF | |
END | |
'--------------------------------------- | |
' CLOSE HELP | |
'--------------------------------------- | |
DEF HELPCLOSE | |
IF USE_HELP==0 THEN RETURN | |
DB "HELPCLOSE" | |
HELP_CLOSESUB 'HELP SLOT | |
CLRMASK | |
USE_HELP=0 | |
END | |
'--------------------------------------- | |
' EXIT HELP | |
'--------------------------------------- | |
DEF HELPEXIT | |
SKEYPUSH #CK_HELP | |
END | |
'======================================= | |
'======================================= | |
'======================================= | |
'--------------------------------------- | |
' OPEN CMPL | |
'--------------------------------------- | |
DEF CMPLOPEN | |
IF USE_CMPL THEN RETURN | |
DB "CMPLOPEN" | |
IF USE_SKEY THEN SKEYCLOSE | |
IF USE_HELP THEN HELPCLOSE | |
USE_CMPL=1 | |
OPEN_CMPLBRD | |
SETMASK | |
END | |
'--------------------------------------- | |
' CLOSE CMPL | |
'--------------------------------------- | |
DEF CMPLCLOSE | |
IF USE_CMPL==0 THEN RETURN | |
DB "CMPLCLOSE" | |
CLOSE_CMPLBRD | |
CLRMASK | |
USE_CMPL=0 | |
END | |
'--------------------------------------- | |
' OPEN CMPL BOARD SUB | |
'--------------------------------------- | |
DEF OPEN_CMPLBRD | |
DB "-- OPEN_CMPLBRD" | |
IF ISCMPLBRD THEN RETURN | |
'--- 新しい座標でSHOW | |
KANJICLOSE | |
SETCMPL | |
SPSHOW #SP_CMPLBRDTOP | |
ISCMPLBRD=1 | |
END | |
'--------------------------------------- | |
' CLOSE CMPL BOARD SUB | |
'--------------------------------------- | |
DEF CLOSE_CMPLBRD | |
DB "-- CLOSE_CMPLBRD" | |
IF ISCMPLBRD==0 THEN RETURN | |
'--- | |
HELP_MINICLOSE | |
SPHIDE #SP_CMPLBRDTOP | |
ISCMPLBRD=0 | |
END | |
'--------------------------------------- | |
' GET POSITION&SIZE | |
'--------------------------------------- | |
DEF GETLAYPOS SWCP OUT X,Y,W,H | |
VAR LAY=CHKLAYOUT() | |
VAR OX=CMPLBRD_W*(SWCP!=0) | |
VAR OY=CMPLBRD_H*(SWCP!=0) | |
'--- | |
IF LAY==#KEYLAY_UP THEN | |
W=#SCW:H=#SCH/2:X=OX+8:Y=0+8 | |
ELSEIF LAY==#KEYLAY_DOWN THEN | |
W=#SCW:H=#SCH/2:X=OX+8:Y=H+8 | |
ELSEIF LAY==#KEYLAY_LEFT THEN | |
W=#SCW/2:H=#SCH:X=0+8:Y=OY+8 | |
ELSE | |
W=#SCW/2:H=#SCH:X=W+8:Y=OY+8 | |
ENDIF | |
END | |
'--------------------------------------- | |
' SET MASK | |
'--------------------------------------- | |
DEF SETMASK | |
'IF GETPAGE() THEN RETURN | |
'--- | |
VAR X,Y,W,H,LAY=CHKLAYOUT() | |
IF USE_CMPL THEN | |
W=CMPLBRD_W:H=CMPLBRD_H | |
IF SPUSED(#SP_CMPLBRDTOP) THEN | |
SPOFS #SP_CMPLBRDTOP OUT X,Y | |
ENDIF | |
ELSE | |
GETLAYPOS 0 OUT X,Y,W,H | |
ENDIF | |
'--- | |
DB FORMAT$("UIMASK:%D,%D(%D,%D)",X,Y,W,H) | |
UIMASK X,Y,X+W-1,Y+H-1 | |
'--- | |
'VAR GP=SPPAGE() | |
'SPPAGE -1 | |
'VAR SP=SPSET(0,0,W,H,0) | |
'IF SP>-1 THEN | |
' SPOFS SP,X,Y,-4000 | |
' SPCOLOR SP,RGB(64,255,255,255) | |
' SPANIM SP,"C.",-16,#C_CLEAR,1 | |
'ENDIF | |
'SPPAGE GP | |
END | |
'--------------------------------------- | |
' CLEAR MASK | |
'--------------------------------------- | |
DEF CLRMASK | |
UIMASK | |
END | |
'--------------------------------------- | |
' CMPL UPDATE | |
'--------------------------------------- | |
DEF UPDATECMPL | |
IF USE_CMPL==0 && ISCMPLBRD==0 THEN RETURN | |
'DB "UPDATECMPL" | |
'--- SHOW? | |
IF SPUSED(#SP_CMPLBRDTOP) THEN | |
IF SPHIDE(#SP_CMPLBRDTOP) THEN SPSHOW #SP_CMPLBRDTOP | |
ENDIF | |
'--- CHANGE? | |
VAR I,J,LN | |
VAR TIME,CNT,OX=0,OY=0,PG=0,SW=0 | |
VAR LIST$ | |
UIGETCMPL OUT TIME,CNT,LIST$ | |
'--- 単漢字? | |
IF KANJIMODE THEN | |
'--- 命令候補に変化があったか? | |
IF CNT==0 THEN UPDATEKANJI:RETURN | |
'--- 単漢字おわり | |
KANJICLOSE | |
CMPLOY=0:CMPLCY=0 | |
ENDIF | |
'--- 命令候補に変化があったか? | |
IF TIME!=CMPLTS || CMPLREDRAW THEN | |
'--- | |
CMPLTS=TIME:CMPLMAX=CNT:CMPLLIST$=LIST$ | |
CMPLREDRAW=0 | |
'--- 命令候補のリストは存在するか? | |
IF CNT==0 THEN CLRCMPL:RETURN | |
'--- MAKE LIST(先にページごとの個数を数えておく) | |
IF CNT!=LEN(LIST$) || CNT>=#MAX_CMPL THEN | |
DB FORMAT$("ERROR CMPLCOUNT(%D) LIST$(%D)",CNT,LEN(LIST$)) | |
STOP | |
RETURN | |
ENDIF | |
'--- RESET CURSOR | |
RESETCMPL | |
'--- 命令ごとの長さを調べて並べる | |
I=0:CNT=0:CMPLPGY=0 | |
WHILE I<CMPLMAX | |
IF CNT==0 THEN CMPLTOP[CMPLPGY]=I:OX=0 | |
LN=PUTGC(0,0,LIST$[I],0) 'LENGTH ONLY | |
IF CMPL_MODE THEN | |
'--- 単独CMPL | |
CMPLCNT[CMPLPGY]=1:INC CMPLPGY:CNT=0:INC I | |
ELSE | |
'--- ソフトキーボードと同時に出るCMPL | |
IF LN<CMPL_SX-10 THEN LN=CMPL_SX-10 | |
IF OX+LN+10>CMPL_W THEN | |
'--- 横にはみ出ていたら改行 | |
CMPLCNT[CMPLPGY]=CNT | |
INC CMPLPGY:CNT=0:OX=0 | |
ELSE | |
'--- 横に並べる | |
INC CNT:OX=OX+LN+10:INC I | |
ENDIF | |
ENDIF | |
WEND | |
CMPLCNT[CMPLPGY]=CNT:INC CMPLPGY:SW=1 | |
SW=1 | |
'--- DEBUG | |
' SPSET #SP_KEYEND,CMPL_U,CMPL_V,320,260 | |
' SPOFS #SP_KEYEND,1280-(320+16),16 | |
'--- | |
ENDIF | |
'--- HELP_MINIOPEN | |
IF CMPL_MODE && CMPLACTIVE THEN | |
SPOFS #SP_CMPLTOP+CMPLCY,1 OUT OX,OY | |
IF OX+88+256>#SCW THEN OX=OX-312 ELSE OX=OX+88 | |
HELP_MINIOPEN SPVAR(#SP_CMPLTOP+CMPLCY,"NAME"),OX,OY-28 | |
ELSE | |
HELP_MINICLOSE | |
ENDIF | |
'--- CREATE NUMBER | |
VAR GP=GTARGET() | |
GTARGET GETPAGE() | |
VAR NX=1632,NY=32,NW=48,NH=44 | |
GFILL NX,NY,NX+NW-1,NY+NH-1,#C_CLEAR:NY=NY+4 | |
LN=PUTGC(NX+4,NY,STR$(CMPLOY+CMPLCY+1,3),8):NY=NY+19 | |
GFILL NX,NY,NX+NW-1,NY+1,#C_WHITE:NY=NY+7 | |
LN=PUTGC(NX+4,NY,STR$(CNT,3),8):NY=NY+18 | |
GTARGET GP | |
'--- SIZE | |
VAR CNTMY=CMPL_CNTY | |
IF CMPLMAX<CMPL_CNTY THEN CNTMY=CMPLMAX | |
'--- MOVE?( CMPL_MODE==1 たんどくCMPLONLY ) | |
VAR VX,VY=CMPLVY | |
VAR KEYX,KEYY,_RT | |
VAR OLDCY=CMPLCY,OLDOY=CMPLOY | |
IF CMPL_MODE THEN | |
'--- | |
SB_BUTVEC "KEY","REPEAT" OUT KEYX,KEYY | |
IF SB_KEYSTAT("ENTER") THEN CMPLOK=#CMPLOK_ENTER:RETURN | |
IF SB_KEYSTAT("TAB") THEN CMPLOK=#CMPLOK_TAB:RETURN | |
IF SB_KEYSTAT("ESC") THEN CMPLOK=#CMPLOK_ESC:RETURN | |
IF KEYX>0 THEN CMPLOK=#CMPLOK_RIGHT:RETURN ' | |
IF KEYX<0 THEN CMPLOK=#CMPLOK_LEFT :RETURN ' | |
'--- | |
IF CMPLVY==0 THEN VY=KEYY | |
IF VY==0 && SW==0 THEN RETURN | |
IF CMPLACTIVE==0 && VY THEN | |
SPSHOW #SP_CMPLCSR | |
CMPLACTIVE=1:VY=0 | |
ENDIF | |
'--- MOVE CURSOR | |
CMPLCY=CMPLCY+VY:VY=0:CMPLVY=0 | |
IF CMPLCY<0 THEN CMPLCY=0 :VY=-1 | |
IF CMPLCY>CNTMY-1 THEN CMPLCY=CNTMY-1:VY= 1 | |
'--- PAGEUP/DOWN(たいおうがむりだった) | |
' IF VY==0 THEN | |
' IF SB_KEYSTAT("PGUP") THEN VY=-1 | |
' IF SB_KEYSTAT("PGDW") THEN VY=1 | |
' ENDIF | |
ENDIF | |
'--- PAGE OFFSET | |
CNTMY=CMPLMAX-CNTMY | |
CMPLOY=CMPLOY+VY:CMPLVY=0 | |
IF CMPLOY<0 THEN CMPLOY=0 | |
IF CMPLOY>CNTMY THEN CMPLOY=CNTMY | |
'--- NOT REDRAW | |
IF SW==0 && OLDCY==CMPLCY && OLDOY==CMPLOY THEN RETURN | |
'--- スプライト消去とページ切り替えボタンの追加 | |
CLRCMPL | |
IF CMPLMAX==0 THEN RETURN | |
'--- 候補ボタンを生成 | |
VAR SP,GX,GY,U=CMPL_U,V=CMPL_V | |
VAR KU,KV=V,KX=CMPL_LX,KY=CMPL_LY,KW=64,KH=CMPL_H | |
VAR C$ | |
GTARGET GETPAGE() | |
IF CMPL_MODE THEN GX=8+8:GY=4 ELSE GX=8:GY=8 | |
'--- | |
FOR J=0 TO CMPL_CNTY-1 | |
IF J+CMPLOY>=CMPLPGY THEN BREAK | |
CNT=CMPLTOP[J+CMPLOY]:OX=0 | |
FOR I=0 TO CMPLCNT[J+CMPLOY]-1 | |
'--- CHECK LENGTH | |
C$=LIST$[CNT]:LN=PUTGC(0,0,C$,0) 'LENGTH ONLY | |
IF LN<CMPL_SX THEN LN=CMPL_SX-(CMPL_MODE==1)*10 | |
'--- DRAW NAME | |
KU=U+OX:KW=LN+8:KH=CMPL_H-2 | |
GFILL KU,KV,KU+KW-1,KV+KH-1,#C_CLEAR | |
GRFILL KU,KV,KW-8,KH,8,#C_CMPLBASE | |
CMPLSUB KU,KV,KW,KH,C$ | |
_RT=PUTGC(KU+GX,KV+GY,C$,1) | |
'--- MAKE SPRITE | |
SP=SPSET(#SP_CMPLTOP,#SP_CMPLEND,KU,KV,KW,KH,0) | |
IF SP>-1 THEN | |
MKSPKEY SP,OX+KX,KY,KU,KV,KW,KH,C$,0,#MSK_OFF,#SP_CMPLBRDTOP | |
SPVAR SP,"CMPL",CNT 'CMPL LIST NO. | |
ENDIF | |
'--- | |
OX=OX+LN+10:INC CNT | |
NEXT | |
KY=KY+CMPL_H:KV=KV+CMPL_H | |
NEXT | |
GTARGET GP | |
END | |
'--------------------------------------- | |
' ROUNDED CORNERS FILL | |
'--------------------------------------- | |
DEF GRFILL X,Y,W,H,R,C | |
VAR RE=R+1 | |
'--- CLEAR | |
GFILL X,Y,X+W-1,Y+H-1,#C_CLEAR | |
'--- CHECK SIZE | |
IF H<=R*4 THEN | |
R=H/2:RE=R+1 | |
GCIRFILL X+R ,Y+R,R,C | |
GCIRFILL X+W-RE,Y+R,R,C | |
GFILL X+R,Y,X+W-RE,Y+H-1,C | |
ELSE | |
GCIRFILL X+R ,Y+R ,R,C | |
GCIRFILL X+R ,Y+H-RE,R,C | |
GCIRFILL X+W-RE,Y+R ,R,C | |
GCIRFILL X+W-RE,Y+H-RE,R,C | |
GFILL X+R,Y ,X+W-RE,Y+H-1 ,C | |
GFILL X ,Y+R,X+W-1 ,Y+H-RE,C | |
ENDIF | |
END | |
'--------------------------------------- | |
' CIRCLE FILL | |
'--------------------------------------- | |
DEF GCIRFILL X,Y,R,C | |
GCIRCLE X,Y,R,C | |
GPAINT X,Y,C | |
END | |
'--------------------------------------- | |
' CMPL SUB OBJECT | |
'--------------------------------------- | |
DEF CMPLSUB U,V,W,H,C$ | |
'--- | |
IF CMPL_MODE THEN RETURN | |
IF INSTR(C$,"#C_")<0 THEN RETURN | |
'--- CHECK COLOR | |
VAR I | |
FOR I=0 TO #MAX_COL-1 | |
IF C$==COLNAME$[I] THEN | |
GFILL U+8,V+28,U+W-16,V+H-(1+6),COLVAL[I] | |
BREAK | |
ENDIF | |
NEXT | |
END | |
'--------------------------------------- | |
' CLEAR CMPL KEY | |
'--------------------------------------- | |
DEF CLRCMPL | |
'--- CLEAR CMPL | |
SPCLR #SP_CMPLTOP,#SP_CMPLEND | |
'--- ページが無い?(↑↓ボタン) | |
'IF CMPLPGY<CMPL_CNTY+1 THEN | |
' IF SPUSED(#SP_CMPLUP) THEN SPHIDE #SP_CMPLUP | |
' IF SPUSED(#SP_CMPLDW) THEN SPHIDE #SP_CMPLDW | |
'ELSE | |
' IF SPUSED(#SP_CMPLUP) THEN SPSHOW #SP_CMPLUP | |
' IF SPUSED(#SP_CMPLDW) THEN SPSHOW #SP_CMPLDW | |
'ENDIF | |
END | |
'======================================= | |
'======================================= | |
'======================================= | |
' | |
' KANJI CLOSE | |
' | |
DEF KANJICLOSE | |
DB "KANJICLOSE" | |
OLDKJ$="" | |
KANJIMODE=0 | |
CLRCMPL | |
CMPLREDRAW=1 | |
END | |
'--------------------------------------- | |
' KANJI UPDATE | |
'--------------------------------------- | |
DEF UPDATEKANJI | |
DB "UPDATEKANJI" | |
'--- CHANGE? | |
VAR C,I,J,L,T,OX=0,PG=0,SW=0 | |
IF KJCHR$!=OLDKJ$ THEN | |
'--- 渡された文字から該当する単漢字リストを選択 | |
OLDKJ$=KJCHR$:I=CHKKANJI(KJCHR$) | |
IF I<0 THEN RETURN '該当する文字なし | |
'--- MAKE LIST(先にページごとの個数を数えておく) | |
KJLIST$=KANJI$[I]:CMPLMAX=LEN(KJLIST$) | |
CMPLOY=0:CMPLPGY=0 | |
FOR I=0 TO CMPLMAX-1 | |
C=I MOD CMPL_CNTX | |
IF C==0 THEN CMPLTOP[CMPLPGY]=I | |
IF C==CMPL_CNTX-1 THEN CMPLCNT[CMPLPGY]=CMPL_CNTX:INC CMPLPGY | |
NEXT | |
IF CMPLMAX!=CMPL_CNTX THEN CMPLCNT[CMPLPGY]=C+1:INC CMPLPGY | |
SW=1 | |
'--- | |
ENDIF | |
'--- REDRAW? | |
VAR VX,VY | |
IF CMPLVY==0 && SW==0 THEN | |
'--- MOVE CURSOR | |
SB_BUTVEC "KEY","REPEAT" OUT VX,VY | |
CMPLCY=CMPLCY+VY | |
IF CMPLCY<0 THEN CMPLCY=0 | |
IF CMPLCY>CMPL_CNTY-1 THEN CMPLCY=CMPL_CNTY-1 | |
RETURN | |
ENDIF | |
'--- PAGE OFFSET | |
I=CMPLOY:CMPLOY=CMPLOY+CMPLVY:CMPLVY=0 | |
IF CMPLOY<0 THEN CMPLOY=0 | |
IF CMPLPGY>CMPL_CNTY THEN | |
IF CMPLOY>CMPLPGY-CMPL_CNTY THEN CMPLOY=CMPLPGY-CMPL_CNTY | |
ELSE | |
CMPLOY=0 | |
ENDIF | |
IF SW==0 && CMPLOY==I THEN RETURN 'NOT REDRAW | |
'--- スプライト消去とページ切り替えボタンの追加 | |
CLRCMPL | |
'--- 最大2行の候補ボタンを生成(同じような処理なので命令候補との統合を考える) | |
VAR SP,U=CMPL_U,V=CMPL_V | |
VAR KX=CMPL_LX,KY=CMPL_LY,KU,KV=V,KW=58,KH=52 | |
VAR C$ | |
'--- | |
VAR KT=KEYLAYTYPE | |
IF KT==#KEYLAY_LEFT || KT==#KEYLAY_RIGHT THEN KW=KW+2 | |
'--- | |
VAR GP=GTARGET() | |
GTARGET GETPAGE() | |
'--- | |
FOR J=0 TO CMPL_CNTY-1 | |
IF J+CMPLOY>=CMPLPGY THEN BREAK | |
C=CMPLTOP[J+CMPLOY]:OX=0 | |
FOR I=0 TO CMPLCNT[J+CMPLOY]-1 | |
'--- WRITE NAME | |
C$=MID$(KJLIST$,C,1):KU=U+OX | |
GRFILL KU,KV,KW,KH,8,#C_CMPLBASE | |
GPUTCHR KU+12,KV+12,C$,16,2,2,#C_WHITE,#ALPON | |
'--- MAKE SPRITE | |
SP=SPSET(#SP_CMPLTOP,#SP_CMPLEND,KU,KV,KW,KH,0) | |
IF SP>-1 THEN | |
MKSPKEY SP,OX+KX,KY,KU,KV,KW,KH,C$,0,#MSK_OFF,#SP_CMPLBRDTOP | |
SPVAR SP,"CMPL",C 'KANJI NO. | |
ENDIF | |
'--- | |
OX=OX+KW+4:INC C | |
NEXT | |
KY=KY+KH+4::KV=KV+KH | |
NEXT | |
GTARGET GP | |
END | |
'--------------------------------------- | |
' 単漢字変換リスト内に指定された文字があるか調べる | |
'--------------------------------------- | |
DEF CHKKANJI( K$ ) | |
VAR I | |
FOR I=0 TO #MAX_KANJI-1 | |
IF INSTR(KANJI$[I],K$)>-1 THEN BREAK | |
NEXT | |
IF I==#MAX_KANJI THEN I=-1 | |
RETURN I | |
END | |
'======================================= | |
'======================================= | |
'======================================= | |
'======================================= | |
'■ソフトウェアキーボードの表示 | |
'======================================= | |
' [in] KEYLAYTYPE:表示するばしょ | |
' | |
' UIST:BASIC側からの表示制御用のビット情報 | |
' UIP1:キー種別、シフト、コントロール、リクエストキー種別、リクエストページ、キー種別ごとのサブ情報 | |
' UIP2:X座標,Y座標 | |
' UIP3:ダイレクトな文字点滅指定用 | |
' UIP4:未使用 | |
' UIP5:未使用 | |
' | |
'======================================= | |
COMMON DEF SKEYOPEN | |
IF USE_SKEY THEN RETURN | |
DB FORMAT$("SOFTKEY OPEN:%D",KEYLAYTYPE) | |
'--- OPEN | |
IF USE_HELP THEN HELPCLOSE | |
'--- INITIALIZE | |
VAR X,Y,VER | |
'--- UIP1:STATUS | |
KEYMODE =(UIP1 AND #UIP1_KEYMODE) >> #SFT_KEYMODE | |
KEYSHIFT =(UIP1 AND #UIP1_KEYSHIFT) >> #SFT_KEYSHIFT | |
KEYCTRL =(UIP1 AND #UIP1_KEYCTRL) >> #SFT_KEYCTRL | |
REQKEYMODE =(UIP1 AND #UIP1_REQKEYMODE) >> #SFT_REQKEYMODE | |
REQPAGE =(UIP1 AND #UIP1_REQPAGE) >> #SFT_REQPAGE | |
KEYPAGE[0] =(UIP1 AND #UIP1_KEYPAGE0) >> #SFT_KEYPAGE0 | |
KEYPAGE[1] =(UIP1 AND #UIP1_KEYPAGE1) >> #SFT_KEYPAGE1 | |
KEYPAGE[2] =(UIP1 AND #UIP1_KEYPAGE2) >> #SFT_KEYPAGE2 | |
VER =(UIP1 AND #UIP1_VERSION) >> #SFT_VERSION | |
'--- VERSIONごとの判定 | |
IF VER!=#UIPVERSION THEN VER=VER | |
'--- UIP2:POSITION | |
X=GETSHORT((UIP2 AND #UIP2_X) >> #SFT_X) | |
Y=GETSHORT((UIP2 AND #UIP2_Y) >> #SFT_Y) | |
'--- SHOW CMPL/KANJIBOARD | |
USE_SKEY=1 | |
KANJICLOSE | |
OPEN_CMPLBRD | |
'--- CREATE SOFTKEY | |
SETLAYOUT | |
MKBRD #SP_BRDTOP,"FUNCBRD",BRD_X,BRD_Y,BRD_W,BRD_H,C_KEY,#Z_HELP | |
SETKEY KEYMODE | |
'--- SHOW KEYBOARD | |
SPSHOW #SP_BRDTOP | |
SPOFS #SP_BRDTOP,BRD_X,BRD_Y | |
SPLINK #SP_CMPLBRDTOP,#SP_BRDTOP | |
'--- | |
SETMASK | |
END | |
'--------------------------------------- | |
' 符号付き16ビット(これどうやるんだっけな…) | |
'--------------------------------------- | |
DEF GETSHORT(CNT) | |
IF CNT<&H8000 THEN RETURN CNT | |
RETURN -(&H8000-(CNT AND &H7FFF)) | |
END | |
'======================================= | |
'■ソフトウェアキーボードを閉じる | |
'======================================= | |
COMMON DEF SKEYCLOSE | |
IF USE_SKEY==0 THEN RETURN | |
DB "SOFTKEY CLOSE" | |
'--- UIP1:STATUS | |
UIP1=(KEYMODE AND #UIP1_KEYMODE) << #SFT_KEYMODE | |
UIP1=UIP1 OR ((KEYSHIFT AND #UIP1_KEYSHIFT) << #SFT_KEYSHIFT) | |
UIP1=UIP1 OR ((KEYCTRL AND #UIP1_KEYCTRL) << #SFT_KEYCTRL) | |
UIP1=UIP1 OR ((REQKEYMODE AND #UIP1_REQKEYMODE) << #SFT_REQKEYMODE) | |
UIP1=UIP1 OR ((REQPAGE AND #UIP1_REQPAGE) << #SFT_REQPAGE) | |
UIP1=UIP1 OR ((KEYPAGE[0] AND #UIP1_KEYPAGE0) << #SFT_KEYPAGE0) | |
UIP1=UIP1 OR ((KEYPAGE[1] AND #UIP1_KEYPAGE1) << #SFT_KEYPAGE1) | |
UIP1=UIP1 OR ((KEYPAGE[2] AND #UIP1_KEYPAGE2) << #SFT_KEYPAGE2) | |
UIP1=UIP1 OR ((#UIPVERSION AND #UIP1_VERSION) << #SFT_VERSION) | |
'--- UIP2:POSITION | |
VAR X,Y | |
SPOFS #SP_BRDTOP OUT X,Y | |
SETUISTPOS X,Y | |
'--- | |
SPHIDE #SP_BRDTOP | |
CLOSE_CMPLBRD | |
CLRMASK | |
USE_SKEY=0 | |
END | |
' | |
' WRITE POSITION | |
' | |
DEF SETUISTPOS X,Y | |
UIP2=(X AND #UIP2_X) << #SFT_X | |
UIP2=UIP2 OR ((X AND #UIP2_Y) << #SFT_Y) | |
END | |
'--------------------------------------- | |
' ソフトウェアキーボードのアップデート(マウスとキーの確認) | |
'--------------------------------------- | |
DEF UPDATEKEY | |
'IF USE_SKEY==0 && USE_CMPL==0 THEN RETURN | |
'DB "UPDATEKEY" | |
'--- | |
VAR SPKEY=-1,NO=-1 | |
'--- | |
IF CMPLOK==0 THEN | |
'--- ボードの移動アニメ中は処理しない | |
' IF SPUSED(#SP_BRDTOP) && !SPCHK(#SP_BRDTOP) THEN | |
' '--- ボード移動中? | |
' IF BRDMOVE THEN | |
' '--- タッチされている? | |
' IF TOUCHTIME THEN | |
' '--- 移動受付 | |
' BRD_X=TOUCHX-BRDOX:BRD_Y=TOUCHY-BRDOY | |
' SPOFS #SP_BRDTOP,BRD_X,BRD_Y | |
' ELSE | |
' '--- 放されて終了 | |
' BRDMOVE=0 | |
' ENDIF | |
' IF CMPL_MODE THEN SETMASK | |
' RETURN | |
' ENDIF | |
' ENDIF | |
'--- マウススプライトに残されたキーとの接触情報確認 | |
SPKEY=SPVAR(#SP_MOUSE,"KEY") | |
IF SPKEY==-1 THEN RETURN | |
'--- 今回触っていた情報を消す | |
SPVAR #SP_MOUSE,"KEY",-1 | |
'--- 押しているか?(取得できるタイミングか?) | |
IF TOUCHTIME!=1 THEN | |
'--- リピートを受け付けないキー? | |
IF SPVAR(SPKEY,"REPT")==0 THEN RETURN | |
'--- リピート確認 | |
IF TOUCHTIME<KW1 THEN RETURN | |
IF (TOUCHTIME-KW1) MOD KW2 THEN RETURN | |
ENDIF | |
'--- 文字列型か? | |
VAR M,P,X,Y,S | |
VAR N$=SPVAR(SPKEY,"NAME") | |
IF TYPEOF(N$)==3 THEN | |
'--- 移動用のバーに触った? | |
' IF INSTR(N$,"BAR")>-1 THEN | |
' SPOFS #SP_BRDTOP OUT X,Y | |
' BRDMOVE=1:BRDOX=TOUCHX-X:BRDOY=TOUCHY-Y | |
' RETURN | |
' ENDIF | |
'--- 縦横切替 | |
IF INSTR(N$,"CHANGELAY")>-1 THEN NEXTLAYOUT:RETURN | |
'--- SHIFT? | |
IF INSTR(N$,"CAPS")>-1 THEN CAPSMODE=!CAPSMODE:RETURN | |
'--- キーボードの補助モード切替? | |
M=#MODE_NONE:P=KEYPAGE[KEYMODE] | |
NO=VAL(RIGHT$(N$,1)) | |
IF INSTR(N$,"KEYTP" )>-1 THEN M=NO:N$="" | |
IF INSTR(N$,"JP" )>-1 THEN M=KEYMODE:P=!P:N$="" | |
IF INSTR(N$,"MK" )>-1 THEN M=KEYMODE:P=NO:N$="" | |
IF M!=#MODE_NONE THEN | |
REQKEYMODE=M | |
KEYPAGE[KEYMODE]=P | |
KANJICLOSE '単漢字変換モードoff | |
RETURN | |
ENDIF | |
'--- 単漢字変換モード切替? | |
IF INSTR(N$,"KJ")>-1 THEN | |
M=KANJIMODE | |
KANJICLOSE | |
KANJIMODE=!M | |
IF KANJIMODE THEN KJCHR$=LASTKJ$ '"あ" | |
RETURN | |
ENDIF | |
'--- 候補のページ切替 | |
IF N$=="CMPLUP" THEN CMPLVY=-1:RETURN | |
IF N$=="CMPLDOWN" THEN CMPLVY= 1:RETURN | |
'--- 命令候補上ENTERボタンが押された? | |
IF N$=="OK" THEN CMPLOK=#CMPLOK_ENTER | |
'--- ヘルプ関係のボタンが押された? | |
IF INSTR(N$,"HELP")>-1 THEN | |
'--- ヘルプ制御可能? | |
IF USE_HELP THEN | |
'*** ヘルプのマウスによるそうさはフォーカスがなくてもいかすようにした | |
' IF HELPCTRL==0 THEN | |
IF N$=="HELPUP" THEN HELP_MOVE 0,-1, 0:RETURN | |
IF N$=="HELPDW" THEN HELP_MOVE 0, 1, 0:RETURN | |
IF N$=="HELPPGUP" THEN HELP_MOVE 0, 0,-1:RETURN | |
IF N$=="HELPPGDW" THEN HELP_MOVE 0, 0, 1:RETURN | |
IF N$=="HELPNEXT" THEN HELP_MOVE 1, 0, 0:RETURN | |
IF N$=="HELPBACK" THEN HELP_MOVE -1, 0, 0:RETURN | |
IF N$=="HELPCOPY" THEN HELP_COPY:RETURN | |
' ENDIF | |
IF N$=="HELPESC" THEN HELPEXIT:RETURN | |
ENDIF | |
RETURN | |
ENDIF | |
ENDIF | |
ENDIF | |
'--- 命令候補上のボタンが押された? | |
IF SPKEY!=-1 THEN NO=SPVAR(SPKEY,"CMPL") | |
IF NO>-1 || CMPLOK>0 THEN | |
'--- 命令候補モード? | |
IF KANJIMODE==0 THEN | |
'--- CMPL ENTER/TAB? | |
IF CMPLOK THEN | |
'--- 選択前のENTER? | |
IF CMPLACTIVE==0 && CMPLOK==#CMPLOK_ENTER THEN | |
SKEYPUSH CHR$(13) | |
PUSHCLOSECMPL | |
RETURN | |
ENDIF | |
'--- 選択中の命令候補を探す(必ず見つかるはず) | |
FOR M=#SP_CMPLTOP TO #SP_CMPLEND | |
IF SPVAR(M,"CMPL")==CMPLOY+CMPLCY THEN | |
NO=CMPLOY+CMPLCY:N$=SPVAR(M,"NAME"):BREAK | |
ENDIF | |
NEXT | |
ENDIF | |
'--- 命令候補流し込み | |
BEEP #SE_KEY,,#SE_KEY_VOL | |
UIPUSHCMPL NO | |
PUSHCLOSECMPL | |
RETURN | |
ENDIF | |
'--- 漢字として出力 | |
N$=MID$(KJLIST$,NO,1) | |
'--- | |
ELSEIF KANJIMODE THEN | |
'--- 漢字モードで最初の文字をキーボードから押した | |
IF TYPEOF(N$)==3 THEN | |
IF NO==-1 && N$!="" THEN | |
IF CHKKANJI( N$ )>-1 THEN KJCHR$=N$:RETURN | |
ENDIF | |
ENDIF | |
ENDIF | |
'--- :命令候補キャンセル? | |
IF CMPLOK<0 THEN | |
NO=0 | |
PUSHCLOSECMPL | |
RETURN | |
ENDIF | |
'--- FUNCTION? | |
VAR F$ | |
IF SPKEY>-1 THEN | |
F$=SPVAR(SPKEY,"FUNC") | |
IF F$!="" THEN N$=F$ | |
ENDIF | |
'--- ここまで来たら文字(またはコマンド)として表示 | |
SKEYPUSH N$ | |
'--- | |
IF KEYMODE==#MODE_JP THEN | |
LASTKJ$=N$ | |
IF TYPEOF(N$)!=3 THEN LASTKJ$="" | |
ENDIF | |
END | |
'--------------------------------------- | |
' キー情報を返す | |
'--------------------------------------- | |
DEF SKEYPUSH N$ | |
BEEP #SE_KEY,,#SE_KEY_VOL | |
'--- | |
IF GETPAGE() THEN TPRINT 0,N$;"(";TYPEOF(N$);")":RETURN | |
'--- キーとして出力 | |
PUSHKEY N$ | |
END | |
'--------------------------------------- | |
' 命令候補を閉じるリクエスト発行 | |
'--------------------------------------- | |
DEF PUSHCLOSECMPL | |
DB "##### PUSHKEY COMPLETION_OFF" | |
CLRCMPL | |
PUSHKEY #CK_COMPLETION_OFF | |
RESETCMPL 'カーソル操作関係初期化 | |
END | |
'--------------------------------------- | |
' CMPL UPDATE | |
'--------------------------------------- | |
DEF RESETCMPL | |
CMPLCX=0:CMPLCY=0 | |
CMPLOX=0:CMPLOY=0 | |
CMPLACTIVE=0 | |
CMPLOK=0 | |
IF SPUSED(#SP_CMPLCSR) THEN SPHIDE #SP_CMPLCSR | |
END | |
'======================================= | |
'======================================= | |
'======================================= | |
'======================================= | |
'■各種ボードの背景用ウィンドウ生成 | |
'======================================= | |
COMMON DEF MKBRD SP,FN$,BX,BY,BW,BH,C,Z | |
VAR I=SP,U=1760,V=0,W=BW-32*2,H=BH-32*2 | |
'--- MAKE WINDOW | |
SETPARTS I ,U ,V, BX, BY, Z, 1, 1 ':0,0(PARENT) | |
SETPARTS I+1,U+32*1,V, 32, 0,-1,W/32, 1 ':1,0 | |
SETPARTS I+2,U+32*2,V,32+W, 0,-1, 1, 1 ':2,0 | |
SETPARTS I+3,U+32*3,V, 0, 32,-1, 1,H/32 ':0,1 | |
SETPARTS I+4,U+32*4,V, 32, 32,-1,W/32,H/32 ':1,1 | |
SETPARTS I+5,U+32*5,V,32+W, 32,-1, 1,H/32 ':2,1 | |
SETPARTS I+6,U+32*6,V, 0,32+H,-1, 1, 1 ':0,2 | |
SETPARTS I+7,U+32*7,V, 32,32+H,-1,W/32, 1 ':1,2 | |
SETPARTS I+8,U+32*8,V,32+W,32+H,-1, 1, 1 ':2,2 | |
IF FN$!="" THEN SPFUNC I,FN$ | |
'--- SET LINK&COLOR | |
FOR I=1 TO 3*3-1 | |
SPLINK SP+I,SP,#SPLK_COL | |
NEXT | |
'--- 親を消しておく | |
SPCOLOR SP,C | |
SPHIDE SP | |
END | |
'--------------------------------------- | |
' SET BOX PARTS | |
'--------------------------------------- | |
DEF SETPARTS I,U,V,X,Y,Z,W,H | |
SPSET I,U,V,32,32,0 | |
SPOFS I,X,Y,Z | |
SPSCALE I,W,H | |
END | |
'--------------------------------------- | |
' SPFUNC:BOARD | |
'--------------------------------------- | |
DEF FUNCBRD | |
VAR IX=CALLIDX() | |
IF SPSHOW(IX) THEN SETKEY REQKEYMODE | |
REQKEYMODE=#MODE_NONE | |
END | |
'--------------------------------------- | |
' SET KEY (MODE&TYPE) | |
'--------------------------------------- | |
DEF SETKEY KM | |
'--- CHECK SHIFT/CTRL | |
IF ISSHIFT!=KEYSHIFT THEN | |
KEYSHIFT=ISSHIFT | |
IF KM==#MODE_NONE THEN KM=KEYMODE | |
ENDIF | |
IF ISCTRL!=KEYCTRL THEN | |
KEYCTRL=ISCTRL | |
IF KM==#MODE_NONE THEN KM=KEYMODE | |
ENDIF | |
'--- NOT REQ?(CHECK) | |
IF KM==#MODE_NONE THEN RETURN | |
'--- JP? | |
OLDKJ$="":KEYMODE=KM | |
'--- IS CTRL? | |
IF ISCTRL THEN KM=#MODE_CTRL | |
'--- SELECT BOARD | |
VAR NM$=KBD$[KM],EX$=NM$+"_EX" | |
IF KM==#MODE_MK THEN | |
NM$=NM$+"_"+CHR$(ASC("A")+KEYPAGE[KM]) | |
ELSEIF KM==#MODE_JP THEN | |
IF KEYPAGE[KM] THEN NM$=NM$+"_K" ELSE NM$=NM$+"_H" | |
ENDIF | |
MKKEY 1,#SP_KEYTOP,#SP_KEYEND,NM$+STR$(KEYSHIFT) | |
'--- ADD EXBOARD | |
MKKEY 0,#SP_KEYTOP,#SP_KEYEND,EX$ | |
'--- CONTROL | |
MKKEY 1,#SP_CTRLTOP,#SP_CTRLEND,"@KB_CTRL"+STR$(KEYSHIFT) | |
'--- ADD DEF | |
IF KM!=#MODE_CTRL && ISCTRL==0 THEN | |
MKKEY 0,#SP_KEYTOP,#SP_KEYEND,"@KB_DEF"+STR$(KEYSHIFT) | |
ELSE | |
MKKEY 0,#SP_KEYTOP,#SP_KEYEND,"@KB_CTRL_EX"+STR$(KEYSHIFT) | |
ENDIF | |
END | |
'--------------------------------------- | |
' MAKE KEY | |
'--------------------------------------- | |
DEF MKKEY CLR,SPT,SPE,DTNAME$ | |
VAR SP,I,X,Y,U,V,W,H,R,MSK | |
VAR UMK,VMK,MK=0,LAY=GETLAYSLOT() | |
VAR N$,TX$ | |
'--- CLEAR | |
IF CLR THEN SPCLR SPT,SPE | |
'--- CHECK MARK | |
IF INSTR(DTNAME$,KBD$[#MODE_MK])>-1 THEN | |
IF INSTR(DTNAME$,"EX")==-1 THEN | |
'--- MARK | |
MK=1 | |
RESTORE STR$(LAY)+":"+DTNAME$+"_TX" | |
READ UMK,VMK,TX$ | |
DTNAME$=KBD$[#MODE_MK]+"_"+RIGHT$(DTNAME$,1) '0 or 1 | |
ENDIF | |
ENDIF | |
'--- LAYOUT DATA | |
DTNAME$=STR$(LAY)+":"+DTNAME$ | |
IF CHKLABEL(DTNAME$,1)==0 THEN BACKCOLOR #C_RED:STOP | |
RESTORE DTNAME$ | |
'--- | |
I=0 | |
LOOP | |
'--- | |
READ X | |
IF X==-1 THEN BREAK | |
READ Y,U,V,W,H,N$,R,MSK | |
'--- MARK? | |
IF MK THEN | |
U=UMK+(I MOD 10)*64 | |
V=VMK+(I DIV 10)*56 | |
N$=MID$(TX$,I,1):INC I | |
ENDIF | |
IF TYPEOF(N$)==3 && N$==" " THEN CONTINUE | |
'--- CREATE | |
SPSET SPT,SPE,U,V,W,H,0 OUT SP | |
IF SP==-1 THEN RETURN | |
'--- MAKE KEY SPRITE | |
MKSPKEY SP,X,Y,U,V,W,H,N$,R,MSK,#SP_BRDTOP | |
'--- | |
ENDLOOP | |
END | |
'======================================= | |
'■SET NEW KEY1 | |
'======================================= | |
COMMON DEF MKSPKEY SP,X,Y,U,V,W,H,N$,R,MSK,PAR | |
SPLINK SP,PAR,#SPLK_BRD | |
SPOFS SP,X+W/2,Y+H/2,#Z_KEY | |
SPCHR SP,U,V,W,H | |
SPHOME SP,W/2,H/2 | |
IF TYPEOF(N$)==3 && N$=="SPACE" THEN N$=" " | |
SPVAR SP,"NAME",N$ | |
SPVAR SP,"SW",0 | |
SPVAR SP,"UV",(U<<16)+V | |
SPVAR SP,"V",V | |
SPVAR SP,"CMPL",-1 | |
SPVAR SP,"REPT",R | |
SPVAR SP,"FUNC","" | |
SPVAR SP,"MASK",MSK | |
SPCOLOR SP,C_KEY | |
SPFUNC SP,"FUNCKEY" | |
SPCOL SP | |
SPHIDE SP | |
'--- FUNCTION? | |
IF TYPEOF(N$)>2 THEN RETURN | |
VAR NO=0 | |
IF N$==#CK_FUNC1 THEN NO=1 | |
IF N$==#CK_FUNC2 THEN NO=2 | |
IF N$==#CK_FUNC3 THEN NO=3 | |
IF N$==#CK_FUNC4 THEN NO=4 | |
IF N$==#CK_FUNC5 THEN NO=5 | |
IF NO==0 THEN RETURN | |
'--- DRAW FUNCTION KEY | |
VAR CNT=10 | |
N$=KEY(NO):NO=LEN(N$) | |
U=U+56:V=V+17:W=16*CNT:H=16 | |
IF NO>CNT THEN N$=LEFT$(N$,CNT):N$=N$+"…" | |
IF GETPAGE() THEN GTARGET 4 | |
GFILL U,V,U+W-(1+4),V+H-1,#C_WHITE | |
GPUTCHR U,V,N$,16,#C_BLACK,2 | |
IF GETPAGE() THEN GTARGET 0 | |
'--- | |
SPVAR SP,"FUNC",N$ | |
END | |
'--------------------------------------- | |
' SPFUNC:KEY(キー1個ずつの呼び出し先) | |
'--------------------------------------- | |
DEF FUNCKEY | |
VAR IX=CALLIDX() | |
VAR N$=SPVAR(IX,"NAME"),C$="" | |
'--- 親はSHOW? | |
VAR PAR=SPLINK(IX) | |
IF PAR!=-1 && SPSHOW(PAR) THEN SPSHOW IX | |
'--- CHECK MASK | |
VAR MS=SPVAR(IX,"MASK") | |
VAR KM=KEYMASK | |
'--- マスクされているか? | |
VAR C=#C_WHITE | |
IF MS!=#MSK_SYS THEN | |
IF MS!=#MSK_OFF THEN | |
'--- 指定されたキーグループ | |
IF KM AND MS THEN C=#C_MASKOFF | |
ELSE | |
'--- それ以外のキー | |
IF KM AND #MSK_ETC THEN C=#C_MASKOFF | |
ENDIF | |
'--- 指定された1文字を点滅する? | |
IF TYPEOF(N$)==3 && FLASHKEY$==N$ THEN | |
C=#C_FLASHOFF | |
IF (MAINCNT() MOD #FLASH_WAIT)<#FLASH_WAIT/2 THEN C=#C_FLASHON | |
ENDIF | |
ENDIF | |
'--- キーの色設定 | |
SPCOLOR IX,C | |
'--- TOUCH PASS? | |
IF C!=#C_WHITE THEN RETURN | |
'--- CHECK KEY NAME | |
VAR X,Y,U,V,W,H,SW=0 | |
IF TYPEOF(N$)==3 THEN | |
SPCHR IX OUT U,V,W,H | |
'--- CMPL CURSOR | |
IF CMPL_MODE THEN | |
IF SPVAR(IX,"CMPL")==CMPLCY+CMPLOY THEN | |
C=(MAINCNT()>>1) MOD 32 | |
IF C>16 THEN C=32-C | |
SPCHR #SP_CMPLCSR,0,0,W-24,4 | |
SPHOME #SP_CMPLCSR,W/2,8-5 | |
SPOFS IX OUT X,Y | |
SPOFS #SP_CMPLCSR,X+12,Y+(H/2),-2 | |
ENDIF | |
ENDIF | |
'--- MODE SWITCH | |
VAR NO=VAL(RIGHT$(N$,1)) | |
VAR P=KEYPAGE[KEYMODE] | |
U=(SPVAR(IX,"UV") >> 16) AND &HFFFF | |
V=SPVAR(IX,"UV") AND &HFFFF | |
C$=N$ | |
'--- | |
IF INSTR(N$,"CAPS")>-1 THEN SPCHR IX,U,V+(NO!=CAPSMODE)*H,W,H | |
IF INSTR(N$,"KEYTP")>-1 THEN SPCHR IX,U,V+(NO==KEYMODE)*H,W,H | |
IF INSTR(N$,"JP")>-1 THEN SPCHR IX,U,V+(NO==P)*H,W,H | |
IF INSTR(N$,"MK")>-1 THEN SPCHR IX,U,V+(NO==P)*H,W,H | |
IF INSTR(N$,"KJ")>-1 THEN SPCHR IX,U,V+(NO!=KANJIMODE)*H,W,H | |
'--- | |
ENDIF | |
'--- マウススプライトに触れているか? | |
IF SPHITSP(IX,#SP_MOUSE)==0 THEN | |
'--- OFF | |
SPANIM IX,"S",-4,1,1,1 | |
SPVAR IX,"SW",0 | |
RETURN | |
ENDIF | |
'--- ON(触られているキーの情報を記録に残す) | |
SPVAR #SP_MOUSE,"KEY",IX | |
IF SPVAR(IX,"SW")==0 THEN | |
'--- 1ST | |
SPANIM IX,"S",-4,1.25,1.25,1 | |
SPVAR IX,"SW",1 | |
'--- | |
ENDIF | |
END | |
'--------------------------------------- | |
' MAKE COLOR | |
'--------------------------------------- | |
DEF INITCOL | |
@COLDATA | |
DATA "#C_AQUA",#C_AQUA | |
DATA "#C_BLACK",#C_BLACK\ | |
DATA "#C_BLUE",#C_BLUE\ | |
DATA "#C_CYAN",#C_CYAN\ | |
DATA "#C_FUCHSIA",#C_FUCHSIA\ | |
DATA "#C_GRAY",#C_GRAY\ | |
DATA "#C_GREEN",#C_GREEN\ | |
DATA "#C_LIME",#C_LIME\ | |
DATA "#C_MAGENTA",#C_MAGENTA\ | |
DATA "#C_MAROON",#C_MAROON\ | |
DATA "#C_NAVY",#C_NAVY\ | |
DATA "#C_OLIVE",#C_OLIVE\ | |
DATA "#C_PURPLE",#C_PURPLE\ | |
DATA "#C_RED",#C_RED\ | |
DATA "#C_SILVER",#C_SILVER\ | |
DATA "#C_TEAL",#C_TEAL\ | |
DATA "#C_WHITE",#C_WHITE\ | |
DATA "#C_YELLOW",#C_YELLOW\ | |
'--- | |
RESTORE @COLDATA | |
VAR I | |
FOR I=0 TO #MAX_COL-1 | |
READ COLNAME$[I],COLVAL[I] | |
NEXT | |
END | |
'--------------------------------------- | |
' MAKE FONT OFFSET&SIZE | |
'--------------------------------------- | |
DEF MKFONTXW | |
VAR I=0,U,V,W,H,HX,SX,HSW,SSW | |
VAR R,G,B,A,P=GTARGET() | |
GTARGET 5 'FONT | |
FOR V=1024 TO 1024+32-1 STEP 16 | |
FOR U=0 TO 1024-1 STEP 16 | |
HX=0:SX=0:HSW=0:SSW=0 | |
FOR W=0 TO 16-1 | |
FOR H=0 TO 16-1 | |
RGB GPGET(U+W,H+V) OUT A,R,G,B | |
IF A THEN BREAK | |
NEXT | |
IF H==16 THEN | |
IF HSW==0 THEN INC HX ELSE BREAK | |
ELSE | |
IF HSW==0 THEN HSW=1 | |
IF HSW THEN INC SX | |
ENDIF | |
NEXT | |
IF HX==16 THEN HX=0:SX=16 | |
FONTX[I]=HX:FONTW[I]=SX | |
INC I | |
NEXT | |
NEXT | |
GTARGET P | |
END | |
'--------------------------------------- | |
' GRAPHIC PUT | |
'--------------------------------------- | |
DEF PUTGC( X,Y,TX$,SW ) | |
VAR DX=0,C,I,W,FX,S=1,L=LEN(TX$) | |
VAR C$ | |
FOR I=0 TO L-1 | |
C$=MID$(TX$,I,1):C=ASC(C$):FX=0:W=16 | |
IF C<128 THEN FX=FONTX[C]:X=X-FX*S | |
W=FONTW[C]:IF SW>1 THEN W=SW | |
IF SW THEN GPUTCHR X+DX,Y,C$,16,S,S,#C_WHITE,#ALPON | |
DX=DX+(FX+W+2)*S | |
NEXT | |
RETURN DX | |
END | |
'======================================= | |
'======================================= | |
'======================================= | |
'======================================= | |
'■入力情報の取得 | |
'======================================= | |
COMMON DEF GETINPUT OUT ES,SF,SX,SY,BX,BY,KX,KY | |
ES=ISESC:SF=ISSHIFT | |
SX=0:SY=0:BX=0:BY=0:KX=0:KY=0 | |
SB_BUTVEC "STICKL","REPEAT" OUT SX,SY | |
SB_BUTVEC "BUTTON","REPEAT" OUT BX,BY | |
SB_BUTVEC "KEY","REPEAT" OUT KX,KY | |
IF BY THEN IF SF THEN SY=BY:BY=0 ELSE SY=0 | |
IF KY THEN IF SF THEN SY=KY:BY=0 ELSE BY=KY | |
END | |
'======================================= | |
'■UISTの取得 | |
'======================================= | |
COMMON DEF GETUIST() | |
RETURN UIST | |
END | |
'======================================= | |
'■ソフトウェアキーボードサイズの取得 | |
'======================================= | |
COMMON DEF GETBRDSIZE OUT BW,BH | |
BW=BRD_W:BH=BRD_H | |
END | |
'======================================= | |
'■基本グラフィックページの取得(デバッグ用) | |
'======================================= | |
COMMON DEF GETPAGE() | |
RETURN GPAGE | |
END | |
'======================================= | |
'■現在のソフトウェアキーボードの縦横状態取得 | |
'======================================= | |
COMMON DEF CHKLAYOUT() | |
RETURN KEYLAYTYPE | |
END | |
'======================================= | |
'■つぎの縦横状態へ | |
'======================================= | |
DEF NEXTLAYOUT | |
VAR NX=#CK_SOFTKEY_RIGHT | |
IF KEYLAYTYPE==#KEYLAY_RIGHT THEN NX=#CK_SOFTKEY_DOWN | |
IF KEYLAYTYPE==#KEYLAY_DOWN THEN NX=#CK_SOFTKEY_LEFT | |
IF KEYLAYTYPE==#KEYLAY_LEFT THEN NX=#CK_SOFTKEY_UP | |
CMPLREDRAW=1 | |
SKEYPUSH NX | |
END | |
'======================================= | |
'■ソフトキーボード縦横の切り替え | |
'======================================= | |
COMMON DEF CHANGELAYOUT AD | |
CLRMASK | |
KEYLAYTYPE=(KEYLAYTYPE+AD) MOD #MAX_KEYLAY | |
SETLAYOUT | |
SETMASK | |
END | |
' | |
' GET LAYOUT SLOT | |
' | |
DEF GETLAYSLOT() | |
IF KEYLAYTYPE==#KEYLAY_UP THEN RETURN #SLOT_LAYW | |
IF KEYLAYTYPE==#KEYLAY_DOWN THEN RETURN #SLOT_LAYW | |
RETURN #SLOT_LAYH | |
END | |
'--------------------------------------- | |
'SET KEYBOARD LAYOUT | |
' | |
'(in) | |
' KEYLAYTYPE: | |
' | |
'--------------------------------------- | |
DEF SETLAYOUT | |
VAR LAY=GETLAYSLOT() | |
DB FORMAT$("SET LAYOUT:%D:%D",KEYLAYTYPE,LAY) | |
'--- レイアウトデータを読み込んで利用可能にしておく | |
RESTORE STR$(LAY)+":@KB_INIT" | |
'--- IMAGE FILE | |
VAR G$,CUR$=PROJECT() | |
READ G$ | |
IF G$=="" THEN | |
G$="PARTS.PNG" | |
IF GETPAGE()==0 THEN | |
IF INSTR(CUR$,"#S/")<0 && INSTR(CUR$,"#H/")<0 THEN G$="PARTS" | |
ENDIF | |
ENDIF | |
GRPFILE$=G$ '読み込みは起動時1回のみとしている | |
'--- BOARD | |
READ C_KEY | |
READ BRD_W,BRD_H | |
READ BRD_X,BRD_Y | |
BRDMOVE=0 | |
BRDOX=BRD_X:BRDOY=BRD_Y | |
'--- KEYWORD補間(CMPL BOARD) | |
READ _C_CMPL | |
READ _CMPLBRD_W ,_CMPLBRD_H | |
READ _CMPLBRD_OX,_CMPLBRD_OY | |
READ _CMPL_SX | |
READ _CMPL_U ,_CMPL_V | |
'READ _CMPL_U2 ,_CMPL_V2 | |
READ _CMPL_AW ,_CMPL_AH 'さいだいさいず | |
READ _CMPL_W ,_CMPL_H | |
READ _CMPL_CNTX ,_CMPL_CNTY | |
READ _CMPL_LX ,_CMPL_LY | |
'--- ↑ボタン | |
READ _CMPL_KX1,_CMPL_KY1 | |
READ _CMPL_KU1,_CMPL_KV1,_CMPL_KW1,_CMPL_KH1 | |
'--- ↓ボタン | |
READ _CMPL_KX2,_CMPL_KY2 | |
READ _CMPL_KU2,_CMPL_KV2,_CMPL_KW2,_CMPL_KH2 | |
'--- | |
IF ISCMPLBRD THEN | |
CLOSE_CMPLBRD | |
SETCMPL | |
OPEN_CMPLBRD | |
ENDIF | |
'--- 読み込んだ座標と表示サイズを使わずに計算で求めることにした 2019.3.31 | |
VAR W,H | |
GETLAYPOS 1 OUT BRD_X,BRD_Y,W,H | |
BRDOX=BRD_X:BRDOY=BRD_Y | |
DB FORMAT$("BOARD POSITION %D,%D",BRD_X,BRD_Y) | |
END | |
'--------------------------------------- | |
' COPY CMPL | |
'--------------------------------------- | |
DEF CMPLCOPY | |
C_CMPL =_C_CMPL | |
CMPLBRD_W =_CMPLBRD_W | |
CMPLBRD_H =_CMPLBRD_H | |
CMPLBRD_OX=_CMPLBRD_OX | |
CMPLBRD_OY=_CMPLBRD_OY | |
CMPL_SX =_CMPL_SX | |
CMPL_U =_CMPL_U | |
CMPL_V =_CMPL_V | |
CMPL_AW =_CMPL_AW | |
CMPL_AH =_CMPL_AH | |
'CMPL_U2 =_CMPL_U2 | |
'CMPL_V2 =_CMPL_V2 | |
CMPL_W =_CMPL_W | |
CMPL_H =_CMPL_H | |
CMPL_CNTX =_CMPL_CNTX | |
CMPL_CNTY =_CMPL_CNTY | |
CMPL_LX =_CMPL_LX | |
CMPL_LY =_CMPL_LY | |
CMPL_KX1 =_CMPL_KX1 | |
CMPL_KY1 =_CMPL_KY1 | |
CMPL_KU1 =_CMPL_KU1 | |
CMPL_KV1 =_CMPL_KV1 | |
CMPL_KW1 =_CMPL_KW1 | |
CMPL_KH1 =_CMPL_KH1 | |
CMPL_KX2 =_CMPL_KX2 | |
CMPL_KY2 =_CMPL_KY2 | |
CMPL_KU2 =_CMPL_KU2 | |
CMPL_KV2 =_CMPL_KV2 | |
CMPL_KW2 =_CMPL_KW2 | |
CMPL_KH2 =_CMPL_KH2 | |
END | |
'--------------------------------------- | |
' SET CMPL STATUS | |
'--------------------------------------- | |
DEF SETCMPL | |
VAR U,V,W,H,X,Y | |
'--- ソフトキー利用中? | |
IF USE_SKEY THEN | |
'--- ソフトキー位置近くに表示する値をもらう | |
CMPLCOPY | |
'--- | |
CMPL_MODE=0 | |
ELSE | |
'--- コンソールまたはエディタのカーソル位置近くに表示する値をもらう | |
ENVLOCATE OUT X,Y | |
W=240 :H=26*8+56-4 | |
CMPLBRD_W=W :CMPLBRD_H=H | |
X=X+24 :Y=Y+24 | |
IF X>#SCW-W THEN X=X-(W+24+4) | |
IF Y>#SCH-H THEN Y=Y-(H+24+4) | |
CMPLBRD_OX=X :CMPLBRD_OY=Y | |
'--- | |
C_CMPL=RGB(224,240,240,255) | |
'--- | |
CMPL_SX =W-16 | |
'--- | |
CMPL_U =1088 :CMPL_V =368 | |
CMPL_AW =320 :CMPL_AH =280 | |
CMPL_W =W-12 :CMPL_H =24 | |
' CMPL_U2 =1088 :CMPL_V2 =368+CMPL_H | |
CMPL_CNTX=1 :CMPL_CNTY=8 | |
CMPL_LX =8 :CMPL_LY =8 | |
'--- ↑ボタン | |
CMPL_KX1=0 :CMPL_KY1=CMPLBRD_H-56 | |
CMPL_KU1=128 :CMPL_KV1=400 | |
CMPL_KW1=64 :CMPL_KH1=56 | |
'--- ↓ボタン | |
CMPL_KX2=64 :CMPL_KY2=CMPLBRD_H-56 | |
CMPL_KU2=192 :CMPL_KV2=400 | |
CMPL_KW2=64 :CMPL_KH2=56 | |
'--- | |
CMPL_MODE=1 | |
SETMASK | |
ENDIF | |
'--- CREATE CMPL BOARD | |
MKBRD #SP_CMPLBRDTOP,"",CMPLBRD_OX,CMPLBRD_OY,CMPLBRD_W,CMPLBRD_H,C_CMPL,#Z_HELP | |
'--- ↑ボタン | |
U=CMPL_KU1:V=CMPL_KV1:W=CMPL_KW1:H=CMPL_KH1:X=CMPL_KX1:Y=CMPL_KY1 | |
SPSET #SP_CMPLUP,U,V,W,H | |
MKSPKEY #SP_CMPLUP,X,Y,U,V,W,H,"CMPLUP" ,1,#MSK_OFF,#SP_CMPLBRDTOP | |
'--- ↓ボタン | |
U=CMPL_KU2:V=CMPL_KV2:W=CMPL_KW2:H=CMPL_KH2:X=CMPL_KX2:Y=CMPL_KY2 | |
SPSET #SP_CMPLDW,U,V,W,H | |
MKSPKEY #SP_CMPLDW,X,Y,U,V,W,H,"CMPLDOWN",1,#MSK_OFF,#SP_CMPLBRDTOP | |
'--- ENTERボタン | |
IF CMPL_MODE THEN | |
'--- CREATE NUMBER | |
SPSET #SP_CMPLNUM,1632,32,48,44 | |
SPLINK #SP_CMPLNUM,#SP_CMPLBRDTOP,#SPLK_BRD | |
SPOFS #SP_CMPLNUM,X+W,Y,-100 | |
'--- CREATE ENTER | |
U=1216:V=1656::W=CMPL_KW2:H=CMPL_KH2:X=CMPLBRD_W-W | |
SPSET #SP_CMPLOK,U,V,W,H | |
MKSPKEY #SP_CMPLOK,X,Y,U,V,W,H,"OK",1,#MSK_OFF,#SP_CMPLBRDTOP | |
'--- CMPL CURSOR | |
SPPAGE -1 | |
SPSET #SP_CMPLCSR,0,0,16,8,&H10 | |
SPLINK #SP_CMPLCSR,#SP_CMPLBRDTOP,#SPLK_BRD | |
SPCOLOR #SP_CMPLCSR,RGB(255,255,140,0) | |
SPANIM #SP_CMPLCSR,"S",-10,0.9,1,-20,1,1,0 | |
'--- CMPL SLIDER BASE | |
' X=CMPLBRD_W-12:Y=20 | |
' SPSET #SP_CMPLSLD1,0,0,6,168 | |
' SPLINK #SP_CMPLSLD1,#SP_CMPLBRDTOP,#SPLK_BRD | |
' SPOFS #SP_CMPLSLD1,X,Y,-1 | |
' SPCOLOR #SP_CMPLSLD1,#C_GRAY | |
'--- CMPL SLIDER THUMB | |
' SPSET #SP_CMPLSLD2,0,0,6,6 | |
' SPLINK #SP_CMPLSLD2,#SP_CMPLSLD1,#SPLK_BRD | |
' SPOFS #SP_CMPLSLD2,0,0,-1 | |
' SPCOLOR #SP_CMPLSLD2,#C_RED | |
'--- | |
SPPAGE GETPAGE() | |
ELSE | |
SPCLR #SP_CMPLOK | |
SPCLR #SP_CMPLCSR | |
ENDIF | |
'--- HIDE | |
SPHIDE #SP_CMPLBRDTOP | |
SPUNLINK #SP_CMPLBRDTOP | |
'--- ADJUST OFFSET | |
SPOFS #SP_CMPLBRDTOP,CMPLBRD_OX,CMPLBRD_OY | |
END | |
'======================================= | |
'======================================= | |
'======================================= | |
'--- USBKEY | |
CONST #USBKEY_ESC =&H29 | |
CONST #USBKEY_SPACE =&H2C | |
CONST #USBKEY_UP =&H52 | |
CONST #USBKEY_DOWN =&H51 | |
CONST #USBKEY_LEFT =&H50 | |
CONST #USBKEY_RIGHT =&H4F | |
CONST #USBKEY_ENTER =&H28 | |
CONST #USBKEY_ENTER2=&H58 | |
CONST #USBKEY_CTRL =&HE0 | |
CONST #USBKEY_CTRL2 =&HE4 | |
CONST #USBKEY_ALT =&HE2 | |
CONST #USBKEY_ALT2 =&HE6 | |
CONST #USBKEY_WIN =&HE3 | |
CONST #USBKEY_WIN2 =&HE7 | |
CONST #USBKEY_SHIFT =&HE1 | |
CONST #USBKEY_SHIFT2=&HE5 | |
CONST #USBKEY_CAPS =&H39 | |
CONST #USBKEY_TAB =&H2B | |
CONST #USBKEY_INS =&H49 | |
CONST #USBKEY_DEL =&H4C | |
CONST #USBKEY_BS =&H2A | |
CONST #USBKEY_HANZEN=&H35 | |
CONST #USBKEY_AT =&H2F | |
'--- | |
CONST #USBKEY_1 =&H1E | |
CONST #USBKEY_2 =&H1F | |
CONST #USBKEY_3 =&H20 | |
CONST #USBKEY_4 =&H21 | |
CONST #USBKEY_5 =&H22 | |
CONST #USBKEY_6 =&H23 | |
CONST #USBKEY_7 =&H24 | |
CONST #USBKEY_8 =&H25 | |
CONST #USBKEY_9 =&H26 | |
CONST #USBKEY_0 =&H27 | |
CONST #USBKEY_MINUS =&H2D | |
CONST #USBKEY_CARET =&H2E '^ | |
CONST #USBKEY_YEN =&H89 | |
'--- | |
CONST #USBKEY_A =&H04 | |
CONST #USBKEY_B =&H05 | |
CONST #USBKEY_C =&H06 | |
CONST #USBKEY_D =&H07 | |
CONST #USBKEY_E =&H08 | |
CONST #USBKEY_F =&H09 | |
CONST #USBKEY_G =&H0A | |
CONST #USBKEY_H =&H0B | |
CONST #USBKEY_I =&H0C | |
CONST #USBKEY_J =&H0D | |
CONST #USBKEY_K =&H0E | |
CONST #USBKEY_L =&H0F | |
CONST #USBKEY_M =&H10 | |
CONST #USBKEY_N =&H11 | |
CONST #USBKEY_O =&H12 | |
CONST #USBKEY_P =&H13 | |
CONST #USBKEY_Q =&H14 | |
CONST #USBKEY_R =&H15 | |
CONST #USBKEY_S =&H16 | |
CONST #USBKEY_T =&H17 | |
CONST #USBKEY_U =&H18 | |
CONST #USBKEY_V =&H19 | |
CONST #USBKEY_W =&H1A | |
CONST #USBKEY_X =&H1B | |
CONST #USBKEY_Y =&H1C | |
CONST #USBKEY_Z =&H1D | |
'--- | |
CONST #USBKEY_HOME =&H4A | |
CONST #USBKEY_END =&H4D | |
CONST #USBKEY_PGUP =&H4B | |
CONST #USBKEY_PGDW =&H4E | |
CONST #USBKEY_MENU =&H65 'APPLICATION | |
'======================================= | |
'■入力系デバイス読込み(INKEY$利用禁止!) | |
'======================================= | |
COMMON DEF SB_INPUT0 | |
' | |
'### TOUCH | |
' | |
TOUCH OUT TOUCHTIME,TOUCHX,TOUCHY | |
IF SPCHK(#SP_MOUSE) THEN SPOFS #SP_MOUSE,TOUCHX,TOUCHY | |
' | |
'### KEY(FROM USB) | |
' | |
SYSPARAM "KEYREPEAT" OUT KW1,KW2 | |
VAR N=0 | |
IF KEYBOARD(#USBKEY_UP,0) THEN N=N OR (1<<#B_LUP) | |
IF KEYBOARD(#USBKEY_DOWN,0) THEN N=N OR (1<<#B_LDOWN) | |
IF KEYBOARD(#USBKEY_LEFT,0) THEN N=N OR (1<<#B_LLEFT) | |
IF KEYBOARD(#USBKEY_RIGHT,0) THEN N=N OR (1<<#B_LRIGHT) | |
IF KEYBOARD(#USBKEY_SHIFT,0) THEN N=N OR (1<<#B_L1) 'X/L1 | |
IF KEYBOARD(#USBKEY_SHIFT2,0) THEN N=N OR (1<<#B_L1) 'X/L1 | |
IF KEYBOARD(#USBKEY_CTRL,0) THEN N=N OR (1<<#B_L2) 'Y/L2 | |
IF KEYBOARD(#USBKEY_CTRL2,0) THEN N=N OR (1<<#B_L2) 'Y/L2 | |
'--- | |
KEYSUB #INP_KEY,N | |
'--- SPECIAL KEY | |
ISSHIFT=KEYBOARD(#USBKEY_SHIFT,0) OR KEYBOARD(#USBKEY_SHIFT2,0) | |
ISCTRL=KEYBOARD(#USBKEY_CTRL,0) OR KEYBOARD(#USBKEY_CTRL2,0) | |
ISESC=KEYBOARD(#USBKEY_ESC,2) | |
IF KEYBOARD(#USBKEY_INS,2) THEN INSMODE=!INSMODE | |
IF KEYBOARD(#USBKEY_CAPS,2) THEN CAPSMODE=!CAPSMODE | |
KEYREP KEYBOARD(#USBKEY_TAB,0),TABCNT OUT ISTAB,TABCNT | |
KEYREP KEYBOARD(#USBKEY_BS,0),BSCNT OUT ISBS,BSCNT | |
KEYREP KEYBOARD(#USBKEY_DEL,0),DELCNT OUT ISDEL,DELCNT | |
VAR E=KEYBOARD(#USBKEY_ENTER,0) OR KEYBOARD(#USBKEY_ENTER2,0) | |
KEYREP E,ENTCNT OUT ISENT,ENTCNT | |
KEYREP KEYBOARD(#USBKEY_PGUP,0),PGUPCNT OUT ISPGUP,PGUPCNT | |
KEYREP KEYBOARD(#USBKEY_PGDW,0),PGDWCNT OUT ISPGDW,PGDWCNT | |
KEYREP KEYBOARD(#USBKEY_HOME,0),HMCNT OUT ISHOME,HMCNT | |
KEYREP KEYBOARD(#USBKEY_END,0),EDCNT OUT ISEND,EDCNT | |
' | |
'### BUTTON | |
' | |
KEYSUB #INP_BUTTON,BUTTON(0) | |
ISSHIFT=ISSHIFT OR ((BUTTON(0) AND ((1<<#B_L1) OR (1<<#B_R1)))!=0) | |
ISCTRL =ISCTRL OR ((BUTTON(0) AND ((1<<#B_L2) OR (1<<#B_R2)))!=0) | |
'--- CHECK CAPSMODE | |
ISSHIFT=ISSHIFT XOR CAPSMODE | |
' | |
'### STICK(L) | |
' | |
VAR X,Y,LM=0.2 | |
STICK 0,0 OUT X,Y | |
N=0 | |
IF X>-LM && X<LM THEN X=0 | |
IF Y>-LM && Y<LM THEN Y=0 | |
IF Y<-LM THEN N=N OR (1<<#B_LUP) | |
IF Y> LM THEN N=N OR (1<<#B_LDOWN) | |
IF X<-LM THEN N=N OR (1<<#B_LLEFT) | |
IF X> LM THEN N=N OR (1<<#B_LRIGHT) | |
KEYSUB #INP_STICKL,N | |
' | |
'### STICK(R) | |
' | |
STICK 0,1 OUT X,Y | |
N=0 | |
IF X>-LM && X<LM THEN X=0 | |
IF Y>-LM && Y<LM THEN Y=0 | |
IF Y<-LM THEN N=N OR (1<<#B_LUP) | |
IF Y> LM THEN N=N OR (1<<#B_LDOWN) | |
IF X<-LM THEN N=N OR (1<<#B_LLEFT) | |
IF X> LM THEN N=N OR (1<<#B_LRIGHT) | |
KEYSUB #INP_STICKR,N | |
' | |
'### MIX | |
' | |
VAR S,RX=0,RY=0,ID=#INP_MIX | |
X=0:Y=0 | |
'--- VECTOR | |
FOR N=0 TO #MAX_IDTBL-1 | |
S=IDTBL[N] | |
IF INP[S,#IMD_VX] THEN X=INP[S,#IMD_VX] | |
IF INP[S,#IMD_VY] THEN Y=INP[S,#IMD_VY] | |
IF INP[S,#IMD_REPVX] THEN RX=INP[S,#IMD_REPVX] | |
IF INP[S,#IMD_REPVY] THEN RY=INP[S,#IMD_REPVY] | |
NEXT | |
INP[ID,#IMD_VX]=X | |
INP[ID,#IMD_VY]=Y | |
INP[ID,#IMD_REPVX]=RX | |
INP[ID,#IMD_REPVY]=RY | |
'--- BUTTON | |
VAR TP | |
TP=#IMD_NEW :INP[ID,TP]=INP[#INP_KEY,TP] OR INP[#INP_BUTTON,TP] | |
TP=#IMD_REPEAT:INP[ID,TP]=INP[#INP_KEY,TP] OR INP[#INP_BUTTON,TP] | |
TP=#IMD_IMPACT:INP[ID,TP]=INP[#INP_KEY,TP] OR INP[#INP_BUTTON,TP] | |
END | |
'--------------------------------------- | |
' CHECK KEY REPEAT | |
'--------------------------------------- | |
DEF KEYREP N,C OUT _F,_C | |
_F=0:_C=0 | |
IF N==0 THEN RETURN | |
_C=C+1 | |
_F=((_C==1) || ((_C>=KW1) && ((_C-KW1) MOD KW2)==0)) | |
END | |
'--------------------------------------- | |
' CHECK REPEAT, MAKE VECTOR | |
'--------------------------------------- | |
DEF KEYSUB ID,N | |
'--- | |
INP[ID,#IMD_OLD]=INP[ID,#IMD_NEW] | |
INP[ID,#IMD_NEW]=N | |
'--- IMPACT | |
INP[ID,#IMD_IMPACT]=N AND (NOT INP[ID,#IMD_OLD]) | |
'--- REPEAT | |
VAR R=0,T=INP[ID,#IMD_TIME] | |
IF INP[ID,#IMD_OLD]!=N THEN T=0 ELSE INC T | |
IF T==0 || (T>=KW1 && ((T-KW1) MOD KW2)==0) THEN R=N | |
INP[ID,#IMD_TIME]=T | |
INP[ID,#IMD_REPEAT]=R | |
'--- VECTOR(REPEAT) | |
VAR VX=0,VY=0 | |
IF R AND (1<<#B_LUP) THEN DEC VY | |
IF R AND (1<<#B_LDOWN) THEN INC VY | |
IF R AND (1<<#B_LLEFT) THEN DEC VX | |
IF R AND (1<<#B_LRIGHT) THEN INC VX | |
INP[ID,#IMD_REPVX]=VX | |
INP[ID,#IMD_REPVY]=VY | |
'--- VECTOR(NEW) | |
VX=0:VY=0 | |
IF N AND (1<<#B_LUP) THEN DEC VY | |
IF N AND (1<<#B_LDOWN) THEN INC VY | |
IF N AND (1<<#B_LLEFT) THEN DEC VX | |
IF N AND (1<<#B_LRIGHT) THEN INC VX | |
INP[ID,#IMD_VX]=VX | |
INP[ID,#IMD_VY]=VY | |
END | |
'======================================= | |
'■特殊キーの状態 | |
'======================================= | |
COMMON DEF SB_KEYSTAT(N$) | |
IF N$=="INS" || N$=="INSERT" THEN RETURN INSMODE | |
IF N$=="ESC" || N$=="ESCAPE" THEN RETURN ISESC:?"ESC" | |
IF N$=="BS" || N$=="BACKSPACE" THEN RETURN ISBS | |
IF N$=="DEL" || N$=="DELETE" THEN RETURN ISDEL | |
IF N$=="ENT" || N$=="ENTER" THEN RETURN ISENT | |
IF N$=="CAPS" || N$=="CAPSLOCK" THEN RETURN CAPSMODE | |
IF N$=="PGUP" || N$=="PAGEUP" THEN RETURN ISPGUP | |
IF N$=="PGDW" || N$=="PAGEDOWN" THEN RETURN ISPGDW | |
IF N$=="HOME" THEN RETURN ISHOME | |
IF N$=="END" THEN RETURN ISEND | |
IF N$=="TAB" THEN RETURN ISTAB | |
IF N$=="SHIFT" THEN RETURN ISSHIFT | |
IF N$=="CTRL" THEN RETURN ISCTRL | |
END | |
'======================================= | |
'■ビット単位のボタン情報 | |
'======================================= | |
COMMON DEF SB_BUTTON(ID$,MD$) | |
VAR ID,MD | |
GETIDMODE ID$,MD$ OUT ID,MD | |
IF ID==-1 || MD==-1 THEN RETURN 0 'NONE | |
RETURN INP[ID,MD] | |
END | |
'--------------------------------------- | |
' GET ID&MODE | |
'--------------------------------------- | |
DEF GETIDMODE ID$,MD$ OUT _ID,_MD | |
VAR ID=-1,MD=-1 | |
'--- | |
IF ID$=="MIX" THEN ID=#INP_MIX | |
IF ID$=="BUTTON" THEN ID=#INP_BUTTON | |
IF ID$=="KEY" THEN ID=#INP_KEY | |
IF ID$=="STICKL" THEN ID=#INP_STICKL | |
IF ID$=="STICKR" THEN ID=#INP_STICKR | |
'--- | |
IF MD$=="NEW" THEN MD=#IMD_NEW | |
IF MD$=="REPEAT" THEN MD=#IMD_REPEAT | |
IF MD$=="IMPACT" THEN MD=#IMD_IMPACT | |
IF MD$=="RELEASE" THEN MD=#IMD_RELEASE | |
IF MD$=="OLD" THEN MD=#IMD_OLD | |
'--- | |
_ID=ID | |
_MD=MD | |
END | |
'======================================= | |
'■方向キーによる移動量 | |
'======================================= | |
COMMON DEF SB_BUTVEC ID$,MD$ OUT _VX,_VY | |
VAR ID,MD | |
GETIDMODE ID$,MD$ OUT ID,MD | |
_VX=0:_VY=0 | |
IF ID!=-1 THEN | |
IF MD$=="NEW" THEN | |
_VX=INP[ID,#IMD_VX] | |
_VY=INP[ID,#IMD_VY] | |
ELSEIF MD$=="REPEAT" THEN | |
_VX=INP[ID,#IMD_REPVX] | |
_VY=INP[ID,#IMD_REPVY] | |
ENDIF | |
ENDIF | |
END | |
'======================================= | |
'======================================= | |
'======================================= | |
'======================================= | |
'■デバッグ用表示(UIRUNの時は表示されません) | |
'======================================= | |
COMMON DEF DB TX$ | |
IF GETPAGE()==0 THEN RETURN | |
PRINT TX$ | |
END | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment