1 ; _____________________________________________ 2 ; | | 3 ; | Project: APPLER | 4 ; | File: KBDSETUP.ASM | 5 ; | Compiler: 16-bit TASM (2.5) | 6 ; | | 7 ; | Subject: Keyboard Setup Utility | 8 ; | | 9 ; | Author: Emil Dotchevski | 10 ; |_____________________________________________| 11 12 include GLOBALS.INC 13 include INTERFAC.INC 14 include CONIO.INC 15 16 KBDsetup segment public 17 assume cs:KBDsetup,ds:KBDsetup,es:Keyboard 18 19 GetLineParams GL_ParamStruc 20 ScreenIOParams SIO_ParamStruc <1,KBDsetup,0,0,offset Screen,seg Screen,1,0,1,1> 21 GetKeyParams RK_ParamStruc <1,Fkey,0,0,0,?,ShowAll,0> 22 23 KBDSetupInInit proc far 24 cli 25 push ax ds es 26 mov ax,Emulate 27 mov es,ax 28 assume es:Emulate 29 mov al,es:[C000] 30 mov cs:KeyPressed,al 31 mov es:[C000],0 32 assume ds:CONio 33 mov ax,CONio 34 mov ds,ax 35 mov GL_ParamsOfs, offset GetLineParams 36 mov GL_ParamsSeg, seg GetLineParams 37 mov SIO_ParamsOfs, offset ScreenIOParams 38 mov SIO_ParamsSeg, seg ScreenIOParams 39 mov RK_ParamsOfs, offset GetKeyParams 40 mov RK_ParamsSeg, seg GetKeyParams 41 push cs 42 pop ds 43 assume ds:KBDsetup 44 mov ax,Keyboard 45 mov es,ax 46 assume es:Keyboard 47 mov ax,OldKeys 48 mov es:k_Table,ax 49 pop es ds ax 50 call UnSetBreaks 51 sti 52 ret 53 KBDSetupInInit endp 54 55 KeyPressed db 0 56 OldKeys dw offset Keyboard:k_KbdSetupTable 57 KBDSetupOutInit proc far 58 cli 59 push ax ds es 60 push cs 61 pop ds 62 mov ax,Keyboard 63 mov es,ax 64 assume es:Keyboard 65 mov ax,es:k_Table 66 mov OldKeys,ax 67 mov ax,Emulate 68 mov es,ax 69 assume es:Emulate 70 mov al,KeyPressed 71 mov es:[C000],al 72 mov ax,seg T_Iflags 73 mov es,ax 74 assume es:seg T_Iflags 75 mov byte ptr es:T_Iflags,00000010b 76 pop es ds ax 77 call AppleKeysOn 78 call SetBreaks 79 ret 80 KBDSetupOutInit endp 81 82 assume cs:KBDsetup,ds:KBDsetup,es:Keyboard 83 84 KBD_Keys db 05h,06h,07h,08h,01h,02h,0Ah,18h,0Ch 85 KBD_Procs dw KBD_Left,KBD_Right,KBD_Up,KBD_Down,KBD_Home,KBD_End,KBD_Clear,KBD_Enter,KBD_Esc 86 87 KBDsetupRET: push cs 88 pop ds 89 mov ax,Keyboard 90 mov es,ax 91 KBDloop: mov cs:ActiveFlags,0000000000001000b 92 mov FkeysFlags,0000111111b 93 mov SA_Active,0 94 mov ShowASCII?,0 95 mov es:k_Table,offset k_KbdSetupTable 96 mov ScreenIOparams.CursorFlag,0 97 mov SA_MesFlag,1 98 call ReadKey 99 mov SA_MesFlag,0 100 mov es:k_Table,offset k_DebugTable 101 mov ShowASCII?,1 102 xor bx,bx 103 mov bl,ah 104 mov SA_Active,bx 105 mov si,es:k_Shifts 106 mov ST_Shifts,si 107 mov cs:ActiveFlags,0000000000010000b 108 call KBD_Home 109 xchg si,bx 110 call get_table_ofs 111 mov bx,es:k_AppleTable[bx] 112 mov bl,es:[si][bx] 113 cmp bl,85h 114 ja KBDloop1 115 KBDloop0: mov al,ST_Pos 116 cmp al,bl 117 je KBDloop1 118 call KBD_Down 119 jmp KBDloop0 120 KBDloop1: mov cx,100h 121 call ReadKey 122 mov di,offset KBD_Keys 123 mov cx,offset KBD_Procs- offset KBD_Keys 124 call CalcCommand 125 jc KBDloop1 126 shl di,1 127 call KBD_Procs[di] 128 jnc KBDloop1 129 jmp KBDloop 130 131 KBD_Left: cmp ST_Pos,16 132 jb KBD_LeftRet 133 sub ST_Pos,16 134 mov al,ST_Pos 135 cmp al,ST_BegPrint 136 jae KBD_LeftRet 137 sub ST_BegPrint,16 138 KBD_LeftRet: clc 139 ret 140 141 KBD_Right: cmp ST_Pos,86h-16 142 jnb KBD_RightRet 143 add ST_Pos,16 144 mov al,ST_Pos 145 sub al,ST_BegPrint 146 cmp al,16*4 147 jb KBD_RightRet 148 add ST_BegPrint,16 149 KBD_RightRet: clc 150 ret 151 152 KBD_Up: cmp ST_Pos,0 153 jz KBD_UpRet 154 dec ST_Pos 155 mov al,ST_Pos 156 cmp al,ST_BegPrint 157 jae KBD_UpRet 158 sub ST_BegPrint,16 159 KBD_UpRet: clc 160 ret 161 162 KBD_Down: cmp ST_Pos,85h 163 jae KBD_DownRet 164 inc ST_Pos 165 mov al,ST_Pos 166 sub al,ST_BegPrint 167 cmp al,16*4 168 jb KBD_DownRet 169 add ST_BegPrint,16 170 KBD_DownRet: clc 171 ret 172 173 KBD_Home: mov ST_Pos,0 174 mov ST_BegPrint,0 175 clc 176 ret 177 178 KBD_End: mov ST_Pos,07Fh 179 mov ST_BegPrint,4*16 180 clc 181 ret 182 183 KBD_Clear: mov dl,ST_Pos 184 mov ST_Pos,86h 185 call KBD_Enter 186 mov ST_Pos,dl 187 ret 188 189 KBD_Enter: mov bx,ST_Shifts 190 call get_table_ofs 191 mov si,es:k_AppleTable[bx] 192 mov al,ST_Pos 193 mov bx,SA_Active 194 cmp si,offset Keyboard:a_AltTable 195 jne KBD_Enter1 196 mov es:a_CtrlTable[bx],al 197 KBD_Enter1: cmp si,offset Keyboard:a_CtrlTable 198 jne KBD_Enter2 199 mov es:a_AltTable[bx],al 200 KBD_Enter2: mov es:[si][bx],al 201 KBD_Esc: stc 202 ret 203 204 205 206 FkeyProcs dw Fkey_F1,Fkey_F2,Fkey_F3,Fkey_F4,Fkey_F5 207 dw Fkey_F6,Fkey_F7,Fkey_F8,Fkey_F9,Fkey_F0 208 FkeysMasks dw 1b,10b,100b,1000b,10000b,100000b,1000000b,10000000b,100000000b,1000000000b 209 Fkey proc far 210 push ax bx cx dx si di bp ds es 211 push cs 212 pop ds 213 mov bx,Keyboard 214 mov es,bx 215 push [ActiveFlags] 216 push word ptr [ScreenIOparams.CursorFlag] 217 push word ptr [ScreenIOparams.CursorLen] 218 push word ptr [ScreenIOparams.CursorColor] 219 push [FkeysFlags] 220 push word ptr [SA_MesFlag] 221 mov SA_MesFlag,0 222 push es:k_Table 223 mov es:k_Table,offset k_DebugTable 224 xor bx,bx 225 mov bl,al 226 shl bx,1 227 mov ax,FkeysMasks[bx] 228 mov ScreenIOparams.CursorLen,1 229 mov ScreenIOparams.CursorFlag,1 230 test FkeysFlags,ax 231 jz Fkey_Ret 232 mov FkeysFlags,0000001000b 233 call FkeyProcs[bx] 234 Fkey_Ret: push cs 235 pop ds 236 mov bx,Keyboard 237 mov es,bx 238 pop es:k_Table 239 pop word ptr [SA_MesFlag] 240 pop [FkeysFlags] 241 pop word ptr [ScreenIOparams.CursorColor] 242 pop word ptr [ScreenIOparams.CursorLen] 243 pop word ptr [ScreenIOparams.CursorFlag] 244 pop [ActiveFlags] 245 pop es ds bp di si dx cx bx ax 246 ret 247 Fkey endp 248 249 250 Fkey_F1: mov ax,CONio 251 mov es,ax 252 assume es:CONio 253 xor es:DKO_OldBuffFlag,1 254 cmp es:DKO_OldBuffFlag,0 255 jnz Fkey_F1_Ret 256 call ClearBuffer 257 Fkey_F1_Ret: ret 258 assume es:Keyboard 259 260 Fkey_F2: call Prepare4DOS 261 mov dx,offset Filespec 262 xor cx,cx 263 mov ax,3C01h 264 int 21h 265 jc Fkey_F2errorNC 266 mov bx,ax 267 mov dx,offset RecognizeBytes 268 mov cx,5 269 mov ah,40h 270 int 21h 271 jc Fkey_F2error 272 cmp ax,cx 273 jne Fkey_F2error 274 mov dx,offset SR_KbdParam 275 mov cx,1 276 mov ah,40h 277 int 21h 278 jc Fkey_F2error 279 mov cx,CONio 280 mov ds,cx 281 mov dx,offset CONio:DKO_OldBuffFlag 282 mov cx,1 283 mov ah,40h 284 int 21h 285 jc Fkey_F2error 286 mov cx,Keyboard 287 mov ds,cx 288 mov dx,offset Keyboard:a_NormalTable 289 mov cx,6 * 54h 290 mov ah,40h 291 int 21h 292 jc Fkey_F2error 293 cmp ax,cx 294 jne Fkey_F2error 295 mov ah,3Eh 296 int 21h 297 mov cs:GetKeyParams.RK_ErrPtr,offset SMS_Saved 298 Fkey_F2ret: call SOD4eraperP 299 ret 300 Fkey_F2error: mov ah,3Eh 301 int 21h 302 Fkey_F2errorNC: mov cs:GetKeyParams.RK_ErrPtr,offset SMS_ErrorSave 303 jmp Fkey_F2ret 304 305 306 RecognizeBytes db 0,0FFh,55h,0AAh,0 307 RecognizeBuffer db 5 dup (0) 308 Fkey_F3: call Prepare4DOS 309 mov dx,offset Filespec 310 mov ax,3D00h 311 int 21h 312 jc Fkey_F3errorNC 313 mov bx,ax 314 mov dx,offset RecognizeBuffer 315 mov cx,5 316 mov ah,3Fh 317 int 21h 318 jc Fkey_F3error 319 cmp ax,cx 320 jne Fkey_F3error 321 push cs 322 pop es 323 mov si,offset RecognizeBytes 324 mov di,offset RecognizeBuffer 325 cld 326 rep cmpsb 327 jne Fkey_F3errorT 328 mov dx,offset SR_KbdParam 329 mov cx,1 330 mov ah,3Fh 331 int 21h 332 jc Fkey_F3error 333 mov cx,CONio 334 mov ds,cx 335 mov dx,offset CONio:DKO_OldBuffFlag 336 mov cx,1 337 mov ah,3Fh 338 int 21h 339 jc Fkey_F3error 340 mov cx,Keyboard 341 mov ds,cx 342 mov dx,offset Keyboard:a_NormalTable 343 mov cx,6 * 54h 344 mov ah,3Fh 345 int 21h 346 jc Fkey_F3error 347 cmp ax,cx 348 jne Fkey_F3error 349 mov ah,3Eh 350 int 21h 351 call UpdateKeyboard 352 mov cs:GetKeyParams.RK_ErrPtr,offset SMS_Restored 353 Fkey_F3ret: call SOD4eraperP 354 ret 355 Fkey_F3error: mov ah,3Eh 356 int 21h 357 Fkey_F3errorNC: mov cs:GetKeyParams.RK_ErrPtr,offset SMS_ErrorLoad 358 jmp Fkey_F3ret 359 Fkey_F3errorT: mov ah,3Eh 360 int 21h 361 mov cs:GetKeyParams.RK_ErrPtr,offset SMS_Type 362 jmp Fkey_F3ret 363 364 Fkey_F4: call GoAppleII 365 ret 366 367 FkeyF5_Keys db 7,8,5,6,18h,0Ch 368 FkeyF5_Procs dw FkeyF5_Up,FkeyF5_Down,FkeyF5_Left,FkeyF5_Right,FkeyF5_Enter,FkeyF5_Esc 369 Fkey_F5: mov ActiveFlags,1 370 FkeyF5Loop: call ReadKey 371 mov di,offset FkeyF5_Keys 372 mov cx,offset FkeyF5_Procs- offset FkeyF5_Keys 373 call CalcCommand 374 jc FkeyF5Loop 375 shl di,1 376 mov al,SR_KbdParam 377 mov ah,al 378 call FkeyF5_Procs[di] 379 mov SR_KbdParam,al 380 call UpdateKeyboard 381 jnc FkeyF5Loop 382 ret 383 384 FkeyF5_Up: and ah,01100000b 385 add ah,00100000b 386 and ah,01100000b 387 and al,10011111b 388 or al,ah 389 clc 390 ret 391 392 FkeyF5_Down: and ah,01100000b 393 sub ah,00100000b 394 and ah,01100000b 395 and al,10011111b 396 or al,ah 397 clc 398 ret 399 400 FkeyF5_Left: inc ah 401 and ah,00011111b 402 and al,11100000b 403 or al,ah 404 mov di,offset SR_speeds_v 405 mov cx,10 406 xchg al,ah 407 call CalcCommand 408 xchg al,ah 409 jc FkeyF5_Left 410 ret 411 412 FkeyF5_Right: dec ah 413 and ah,00011111b 414 and al,11100000b 415 or al,ah 416 mov di,offset SR_speeds_v 417 mov cx,10 418 xchg al,ah 419 call CalcCommand 420 xchg al,ah 421 jc FkeyF5_Right 422 ret 423 424 FkeyF5_Enter: 425 FkeyF5_Esc: stc 426 ret 427 428 429 UpdateKeyboard proc far 430 pushf 431 push ax 432 mov al,0ADh ; Disable Keyboard 433 call K_SendCommand 434 jc UK_Exit 435 mov al,0F3h 436 call K_SendData 437 mov al,cs:SR_KbdParam 438 call K_SendData 439 UK_Exit: mov al,0AEh ; Enable Keyboard 440 out 64h,al 441 pop ax 442 popf 443 ret 444 UpdateKeyboard endp 445 446 447 KBD_EXT db '.KBD',0 448 Fkey_F6: mov ActiveFlags,0000000000000100b 449 mov FkeysFlags,0000001000b 450 mov GetLineParams.GL_Buffer,offset Filespec 451 mov GetLineParams.GL_Pos,0 452 mov GetLineParams.GL_BegPrint,0 453 mov GetLineParams.GL_MaxLength,99 454 mov GetLineParams.GL_MaxPrint,27 455 xor bx,bx 456 Seek0_Loop: cmp FileSpec[bx],0 457 jz Seek0_Done 458 inc bl 459 jmp Seek0_Loop 460 Seek0_Done: mov GetLineParams.GL_Length,bl 461 gotoxy 5,51 462 GetLineService _GETLINE 463 push si di 464 mov si,offset KBD_EXT 465 mov di,offset Filespec 466 call AddExt 467 pop di si 468 gotoxy 2,0 469 mov GetLineParams.GL_CX,cx 470 ret 471 472 Fkey_F7: 473 Fkey_F8: 474 Fkey_F9: 475 Fkey_F0: ret 476 477 478 479 480 ; ******************************************************************* 481 ; ** ** 482 ; ** ** 483 ; ** S H O W A L L ** 484 ; ** ** 485 ; ** ** 486 ; ******************************************************************* 487 488 ActiveFlags dw 0 489 ShowAll proc far 490 cli 491 push ax ds bp 492 push word ptr [ScreenIOparams.CursorColor] 493 push word ptr [ScreenIOparams.CursorLen] 494 push word ptr [ScreenIOparams.CursorFlag] 495 push cs 496 pop ds 497 mov ax,Keyboard 498 mov es,ax 499 mov ScreenIOparams.CursorLen,10 500 mov ScreenIOparams.CursorColor,10h 501 mov ScreenIOparams.CursorFlag,1 502 call ShowRepeat 503 call ShowBuffer 504 call ShowFilespec 505 call ShowAssignment 506 call ShowASCII 507 call ShowFuncKeys 508 ScreenIOservice _SHOWLINE 509 call ShowTitle 510 call ShowMessage 511 pop word ptr [ScreenIOparams.CursorFlag] 512 pop word ptr [ScreenIOparams.CursorLen] 513 pop word ptr [ScreenIOparams.CursorColor] 514 pop bp ds ax 515 sti 516 ret 517 ShowAll endp 518 519 520 ; -- Draw box -------------------------- 521 ; Entry: 522 ; AH = Active Flag Bit 523 ; CX = HTAB & VTAB 524 ; BX = Offset of the strings 525 ; DL = Hi-light color 526 ; DH = Number of lines - 1 527 ; Destroy: 528 ; AX,BX,CX,DX 529 DB_CX dw ? 530 DrawBox: push ax 531 mov ax,cx 532 add ax,80 * 2 533 mov cs:DB_CX,ax 534 pop ax 535 test ActiveFlags,ax 536 mov ah,7 537 jz DB_ok1 538 mov ah,dl 539 DB_ok1: ScreenIOservice _STRINGPRINT 540 mov bx,ScreenIOparams.SP_bx 541 dec dh 542 mov al,dh 543 mov dx,cs:DB_CX 544 DB_Loop1: mov cx,dx 545 add dx,80 * 2 546 ScreenIOservice _STRINGPRINT 547 dec al 548 jnz DB_Loop1 549 mov cx,dx 550 mov bx,ScreenIOparams.SP_bx 551 ScreenIOservice _STRINGPRINT 552 ret 553 554 555 ST_StrX db ' APPLER KEYBOARD SETUP ',0 556 ShowTitle: push ax bx cx 557 gotoxy 1,0 558 mov ah,5Fh 559 mov bx,offset ST_StrX 560 ScreenIOservice _STRINGPRINT 561 gotoxy 2,0 562 xor ah,ah 563 ScreenIOservice _STRINGPRINT 564 pop cx bx ax 565 ret 566 567 568 SR_Str db 'ÚRepeat SettingsÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ',0 569 db '³ ³ ',0 570 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ',0 571 SR_str1 db 1,7,'Delay:',0 572 SR_str2 db 1,7,' ms Speed: ',0 573 SR_str3 db 1,7,' ch/s',0 574 SR_delays dw d250,d500,d750,d1000 575 SR_speeds_v db 0,1,2,4,8,0Ah,0Dh,10h,14h,1Fh 576 SR_speeds dw s300,s267,s240,s200,s150,s100,s092,s075,s050,s020 577 d250 db 1,0Bh,' 250',0 578 d500 db 1,0Bh,' 500',0 579 d750 db 1,0Bh,' 750',0 580 d1000 db 1,0Bh,'1000',0 581 s300 db 1,0Bh,'30.0',0 582 s267 db 1,0Bh,'26.7',0 583 s240 db 1,0Bh,'24.0',0 584 s200 db 1,0Bh,'20.0',0 585 s150 db 1,0Bh,'15.0',0 586 s100 db 1,0Bh,'10.0',0 587 s092 db 1,0Bh,' 9.2',0 588 s075 db 1,0Bh,' 7.5',0 589 s050 db 1,0Bh,' 5.0',0 590 s020 db 1,0Bh,' 2.0',0 591 SR_KbdParam db 0 592 ShowRepeat: push ax bx cx dx di 593 gotoxy 3,0 594 mov bx,offset SR_Str 595 mov dx,30Eh 596 mov ax,0000000000000001b 597 call DrawBox 598 gotoxy 5,2 599 mov bx,offset SR_Str1 600 ScreenIOservice _STRINGPRINT 601 xor bx,bx 602 mov bl,SR_KbdParam 603 shr bl,5 604 shl bx,1 605 mov bx,SR_delays[bx] 606 ScreenIOservice _STRINGPRINT 607 mov bx,offset SR_str2 608 ScreenIOservice _STRINGPRINT 609 xor bx,bx 610 mov al,SR_KbdParam 611 and al,00011111b 612 push cx 613 mov di,offset SR_Speeds_v 614 mov cx,10 615 call CalcCommand 616 pop cx 617 shl di,1 618 mov bx,SR_speeds[di] 619 ScreenIOservice _STRINGPRINT 620 mov bx,offset SR_str3 621 ScreenIOservice _STRINGPRINT 622 pop di dx cx bx ax 623 ret 624 625 626 SB_Str db 'ÚBufferÄÄÄÄ¿ ',0 627 db '³ ³ ',0 628 db 'ÀÄÄÄÄÄÄÄÄÄÄÙ ',0 629 SB_Enabled db 1,0Bh,'Enabled',0 630 SB_Disabled db 1,0Bh,'Disabled',0 631 ShowBuffer: push ax bx cx dx es 632 gotoxy 3,36 633 mov bx,offset SB_Str 634 mov dx,30Eh 635 mov ax,0000000000000010b 636 call DrawBox 637 gotoxy 5,38 638 mov ax,CONio 639 mov es,ax 640 assume es:CONio 641 test es:DKO_OldBuffFlag,1 642 mov bx,offset SB_Disabled 643 jz SB_1 644 mov bx,offset SB_Enabled 645 SB_1: ScreenIOservice _STRINGPRINT 646 pop es dx cx bx ax 647 ret 648 assume es:Keyboard 649 650 651 SF_Str db 'ÚFilenameÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿',0 652 db '³ ³',0 653 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ',0 654 Filespec db 'APPLER.KBD',100 dup (0) 655 ShowFilespec: push ax bx cx dx 656 gotoxy 3,49 657 mov bx,offset SF_Str 658 mov dx,30Eh 659 mov ax,0000000000000100b 660 call DrawBox 661 xor dl,dl 662 xchg Filespec[27],dl 663 mov bx,offset Filespec 664 gotoxy 5,51 665 mov ah,0Bh 666 ScreenIOservice _STRINGPRINT 667 xchg Filespec[27],dl 668 pop dx cx bx ax 669 ret 670 671 672 SA_Str db 'ÚKeyboard MapÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿',0 673 db '³ ³',0 674 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ',0 675 SA_Message db 1,0Fh,'Press a key to remap',0 676 SA_Keyboard db 'ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿',0 677 db '³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³ ³ ³³ ³³ ³³ ³',0 678 db 'ÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙ ÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙ',0 679 db 'ÚÄÄÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄÄÄ¿ ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿',0 680 db '³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³ ³ ³³ ³³ ³³ ³',0 681 db 'ÀÄÄÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀ¿ ³ ÀÄÄÙÀÄÄÙÀÄÄÙ³ ³',0 682 db 'ÚÄÄÄÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿³ ³ ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿³ ³',0 683 db '³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³ ³ ³³ ³³ ³³ ³',0 684 db 'ÀÄÄÄÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÄÙ ÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙ',0 685 db 'ÚÄÄÄÄÄÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄÄÄÄÄÄÄÄ¿ ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿ÚÄÄ¿',0 686 db '³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³³ ³ ³ ³³ ³³ ³³ ³',0 687 db 'ÀÄÄÄÄÄÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÙÀÄÄÄÄÄÄÄÄÄÙ ÀÄÄÙÀÄÄÙÀÄÄÙ³ ³',0 688 db 'ÚÄÄÄÄ¿ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ÚÄÄÄÄ¿ ÚÄÄÄÄÄÄ¿ÚÄÄ¿³ ³',0 689 db '³ ³ ³ ³ ³ ³ ³ ³³ ³³ ³',0 690 db 'ÀÄÄÄÄÙ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ÀÄÄÄÄÙ ÀÄÄÄÄÄÄÙÀÄÄÙÀÄÄÙ',0 691 SA_SpcProcs dw SAS_Enter,SAS_Ctrl,SAS_Lshift,SAS_Div,SAS_Rshift,SAS_Caps,SAS_Num 692 SA_TblPtr dw ? 693 SA_Active dw 0 694 SA_MesFlag db 1 695 ShowAssignment: push ax bx cx dx si di 696 mov bx,es:k_Shifts 697 call get_table_ofs 698 mov bx,es:k_AppleTable[bx] 699 mov SA_TblPtr,bx 700 gotoxy 7,0 701 mov bx,offset SA_Str 702 mov dx,110Eh 703 mov ax,0000000000001000b 704 call DrawBox 705 mov bx,offset SA_Keyboard 706 gotoxy 9,1 707 mov dx,15 708 mov ah,7 709 SA_Loop1: ScreenIOservice _STRINGPRINT 710 add cx,2*2 711 add bx,79 712 dec dx 713 jnz SA_Loop1 714 mov bx,offset SA_Message 715 gotoxy 8,58 716 cmp SA_MesFlag,0 717 jz SA_Dont1 718 ScreenIOservice _STRINGPRINT 719 SA_Dont1: mov si,53h 720 SA_Loop2: mov al,SA_Y[si] 721 or al,al 722 jz SA_Next 723 dec al 724 jz SA_Special 725 mov ah,80 * 2 726 mul ah 727 mov cx,ax 728 xor ax,ax 729 mov al,SA_X[si] 730 add cx,ax 731 add cx,ax 732 SA_SpecialRet: mov bx,SA_TblPtr 733 mov bl,es:[bx][si] 734 cmp bl,85h 735 ja SA_Next 736 xor bh,bh 737 add cx,81*2 738 cmp bl,20h 739 mov ax,0B00h+' ' 740 jae SA_NoCtrl 741 mov al,'^' 742 SA_NoCtrl: ScreenIOservice _SYMBPRINT 743 mov al,SA_Table[bx] 744 ScreenIOservice _SYMBPRINT 745 SA_Next: dec si 746 jnz SA_Loop2 747 jmp SA_Ret 748 749 SA_Special: xor bx,bx 750 mov bl,SA_X[si] 751 shl bx,1 752 mov ah,7 753 call SA_SpcProcs[bx] 754 jmp SA_SpecialRet 755 756 SA_Ret: pop di si dx cx bx ax 757 ret 758 759 SAS_Enter: mov bx,SA_TblPtr 760 mov bl,es:[bx][si] 761 xor bh,bh 762 gotoxy 21,76 763 cmp bl,20h 764 mov ax,0B00h+' ' 765 jae SASE_NoCtrl 766 mov al,'^' 767 SASE_NoCtrl: ScreenIOservice _SYMBPRINT 768 mov al,SA_Table[bx] 769 ScreenIOservice _SYMBPRINT 770 gotoxy 12,56 771 ret 772 773 SAS_CtrlStr db 'Ctrl',0 774 SAS_Ctrl: gotoxy 22,2 775 mov bx,offset SAS_CtrlStr 776 test es:k_Shifts,1 777 mov ah,7 778 jz SAS_Ctrl1 779 mov ah,0Fh 780 SAS_Ctrl1: ScreenIOservice _STRINGPRINT 781 gotoxy 22,56 782 ScreenIOservice _STRINGPRINT 783 ret 784 785 SAS_ShiftStr db 'Shift',0 786 SAS_Lshift: gotoxy 19,3 787 mov bx,offset SAS_ShiftStr 788 test es:k_Shifts,M_LEFT_SHIFT or M_RIGHT_SHIFT 789 mov ah,7 790 jz SAS_LS1 791 mov ah,0Fh 792 SAS_LS1: ScreenIOservice _STRINGPRINT 793 ret 794 795 SAS_Rshift: gotoxy 19,53 796 mov bx,offset SAS_ShiftStr 797 test es:k_Shifts,M_LEFT_SHIFT or M_RIGHT_SHIFT 798 mov ah,7 799 jz SAS_RS1 800 mov ah,0Fh 801 SAS_RS1: ScreenIOservice _STRINGPRINT 802 ret 803 804 SAS_CapsStr db 'Caps',0 805 SAS_Caps: gotoxy 16,2 806 mov bx,offset SAS_CapsStr 807 test es:k_Shifts,M_CAPS_LOCK 808 mov ah,7 809 jz SAS_Caps1 810 mov ah,0Fh 811 SAS_Caps1: ScreenIOservice _STRINGPRINT 812 ret 813 814 SAS_NumStr db 'NL',0 815 SAS_Num: gotoxy 10,64 816 mov bx,offset SAS_NumStr 817 test es:k_Shifts,M_NUM_LOCK 818 mov ah,7 819 jz SAS_Num1 820 mov ah,0Fh 821 SAS_Num1: ScreenIOservice _STRINGPRINT 822 ret 823 824 SAS_Div: mov bx,SA_TblPtr 825 mov bl,es:[bx][si] 826 xor bh,bh 827 gotoxy 10,68 828 cmp bl,20h 829 mov ax,0B00h+' ' 830 jae SASD_NoCtrl 831 mov al,'^' 832 SASD_NoCtrl: ScreenIOservice _SYMBPRINT 833 mov al,SA_Table[bx] 834 ScreenIOservice _SYMBPRINT 835 gotoxy 18,46 836 ret 837 838 839 ; 0 1 2 3 4 5 6 7 8 9 A B C D E F 840 SA_X db 0,01,05,09,13,17,21,25,29,33,37,41,45,49,57, 2 ; 00 841 db 07,11,15,19,23,27,31,35,39,43,47,51, 0, 1,08,12 ; 10 842 db 16,20,24,28,32,36,40,44,48,52, 2,53,10,14,18,22 ; 20 843 db 26,30,34,38,42, 3, 4,71, 0,28, 5, 0, 0, 0, 0, 0 ; 30 844 db 0, 0, 0, 0, 0, 6, 0,63,67,71,75,63,67,71,75,63 ; 40 845 db 67,71,65,71 ; 50 846 847 ; 0 1 2 3 4 5 6 7 8 9 A B C D E F 848 SA_Y db 0,09,09,09,09,09,09,09,09,09,09,09,09,09,09,12 ; 00 849 db 12,12,12,12,12,12,12,12,12,12,12,12, 1, 1,15,15 ; 10 850 db 15,15,15,15,15,15,15,15,15,15, 1,09,18,18,18,18 ; 20 851 db 18,18,18,18,18, 1, 1,09, 0,21, 1, 0, 0, 0, 0, 0 ; 30 852 db 0, 0, 0, 0, 0, 1, 0,12,12,12,09,15,15,15,14,18 ; 40 853 db 18,18,21,21 ; 50 854 855 ; 0123456789ABCDEF0123456789ABCDEF 856 SA_Table db '@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_' ; 00 857 db 'ú!"#$%&''()*+,-./0123456789:;<=>?'; 20 858 db '@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_' ; 40 859 db '`abcdefghijklmnopqrstuvwxyz{|}~±' ; 60 860 db 1,2,1Bh,1Ah,18h,19h ; 80 861 862 863 ST_Str db 'ÚÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄ¿',0 864 db '³ ³ ³ ³ ³',0 865 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÙ',0 866 ST_Str1 db 1,0Eh,'³',1,7,' ASCII Char ',1,0Eh,'³',1,7,' ASCII Char ',1,0Eh,'³',1,7,' ASCII Char ',1,0Eh,'³',1,7,' ASCII Char ',1,0Eh,'³',0 867 ST_Str2 db 1,0Eh,'³',1,7,' ÄÄÄÄÄ ÄÄÄÄ ',1,0Eh,'³',1,7,' ÄÄÄÄÄ ÄÄÄÄ ',1,0Eh,'³',1,7,' ÄÄÄÄÄ ÄÄÄÄ ',1,0Eh,'³',1,7,' ÄÄÄÄÄ ÄÄÄÄ ',1,0Eh,'³',0 868 ST_Mes0 db 1,2Fh,' ',0 869 ST_Mes1 db 1,2Fh,'Select new char to assign to <',0 870 ST_Mes2 db 1,2Fh,'>',0 871 872 ST_ShiftTable dw ST_None 873 dw ST_Ctrl 874 dw ST_Ctrl 875 dw ST_Caps 876 dw ST_CapsShift 877 dw ST_Shift 878 dw ST_Num 879 ST_None db 0 880 ST_Ctrl db 'Ctrl+',0 881 ST_Shift db 'Shift+',0 882 ST_Caps db 'Caps+',0 883 ST_CapsShift db 'Caps+Shift+',0 884 ST_Num db 'Num+',0 885 886 ShowASCII? db 0 887 ST_Shifts dw 0 888 ST_BegPrint db 0 889 ST_Pos db 0 890 ShowASCII: push ax bx cx dx si di 891 cmp ShowASCII?,0 892 jnz ST_Go 893 jmp ST_Ret1 894 ST_Go: mov FkeysFlags,0000001000b 895 gotoxy 4,14 896 mov bx,offset ST_Str 897 mov dx,130Eh 898 mov ax,0000000000010000b 899 call DrawBox 900 gotoxy 5,14 901 mov bx,offset ST_Str1 902 ScreenIOservice _STRINGPRINT 903 gotoxy 6,14 904 mov bx,offset ST_Str2 905 ScreenIOservice _STRINGPRINT 906 gotoxy 7,18 907 mov si,cx 908 mov di,cx 909 xor bx,bx 910 mov bl,ST_BegPrint 911 mov dl,4 912 ST_Loop0: mov dh,16 913 ST_Loop: mov al,bl 914 cmp al,85h 915 ja ST_Ret 916 mov ah,7 917 ScreenIOservice _BYTEPRINT 918 add cx,6 919 cmp bl,20h 920 mov al,' ' 921 jae ST_NoCtrl 922 mov al,'^' 923 ST_NoCtrl: mov ah,0Fh 924 ScreenIOservice _SYMBPRINT 925 mov al,SA_Table[bx] 926 ScreenIOservice _SYMBPRINT 927 cmp bl,ST_Pos 928 je ST_ShowCursor 929 ST_ShowCursorR: inc bx 930 add si,80*2 931 mov cx,si 932 dec dh 933 jnz ST_Loop 934 add di,26 935 mov si,di 936 mov cx,di 937 dec dl 938 jnz ST_Loop0 939 ST_Ret: gotoxy 23,15 940 mov bx,offset ST_Mes0 941 ScreenIOservice _STRINGPRINT 942 gotoxy 23,15 943 mov bx,offset ST_Mes1 944 ScreenIOservice _STRINGPRINT 945 mov bx,ST_Shifts 946 call get_table_ofs 947 mov bx,ST_ShiftTable[bx] 948 mov ah,2Eh 949 ScreenIOservice _STRINGPRINT 950 mov bx,SA_Active 951 mov al,ST_Table[bx] 952 cmp al,20h 953 jbe ST_Special 954 ScreenIOservice _SYMBPRINT 955 ST_SpecRet: mov bx,offset ST_Mes2 956 ScreenIOservice _STRINGPRINT 957 ST_Ret1: pop di si dx cx bx ax 958 ret 959 960 ST_ShowCursor: push cx 961 sub cx,9*2 962 ScreenIOservice _CALCXY 963 mov cs:ScreenIOparams.CursorColor,40h 964 ScreenIOservice _SHOWCURSOR 965 pop cx 966 jmp ST_ShowCursorR 967 968 ST_Special: xor bx,bx 969 mov bl,al 970 shl bx,1 971 mov bx,ST_Specials[bx] 972 ScreenIOservice _STRINGPRINT 973 jmp ST_SpecRet 974 975 ST_Specials dw STS_Esc,STS_BS,STS_Tab,STS_Enter,STS_Space,STS_Num 976 dw STS_Home,STS_Up,STS_PgUp,STS_Left,STS_Cntr,STS_Right 977 dw STS_End,STS_Down,STS_PgDn,STS_Ins,STS_Del 978 STS_Esc db 'Esc',0 979 STS_BS db 'BackSpace',0 980 STS_Tab db 'Tab',0 981 STS_Enter db 'Enter',0 982 STS_Space db 'Space',0 983 STS_Num db 'Num',0 984 STS_Home db 'Home',0 985 STS_Up db 'Up',0 986 STS_PgUp db 'PgUp',0 987 STS_Left db 'Left',0 988 STS_Cntr db 'Center',0 989 STS_Right db 'Right',0 990 STS_End db 'End',0 991 STS_Down db 'Down',0 992 STS_PgDn db 'PgDn',0 993 STS_Ins db 'Ins',0 994 STS_Del db 'Del',0 995 996 ST_Table db 0,0,'1234567890-=',1 997 db 2,'QWERTYUIOP[]',3 998 db 0,'ASDFGHJKL;''`' 999 db 0,'\ZXCVBNM,./',0,'*' 1000 db 0,4,0,0,0,0,0,0,0,0,0,0,0 1001 db 5,0,6,7,8,'-',9,10,11,'+',12,13,14,15,16 1002 1003 1004 1005 SFK_Str db '1 2 3 4 5 ' 1006 db '6 7 8 9 10 ',0 1007 FkeysFlags dw 0000111111b 1008 SFK_FkeysMain dw SFK_Buffer, SFK_Save, SFK_Load, SFK_Cont, SFK_Repeat 1009 dw SFK_Name , SFK_None , SFK_None , SFK_None, SFK_None 1010 SFK_None db ' ',0 1011 SFK_Cont db 'Apple ',0 1012 SFK_Load db 'Load ',0 1013 SFK_Save db 'Save ',0 1014 SFK_Repeat db 'Repeat',0 1015 SFK_Buffer db 'Buffer',0 1016 SFK_Assign db 'Assign',0 1017 SFK_Name db 'Name ',0 1018 1019 ShowFuncKeys: push ax bx cx dx si 1020 gotoxy 19h,0 1021 mov bx,offset SFK_Str 1022 mov ah,7 1023 ScreenIOservice _STRINGPRINT 1024 gotoxy 19h,1 1025 xor si,si 1026 mov dx,cs:FkeysFlags 1027 SFK_Loop0: shr dx,1 1028 mov ah,58h 1029 jnc SFK_Next0 1030 mov ah,5Fh 1031 SFK_Next0: mov bx,cs:SFK_FkeysMain[si] 1032 ScreenIOservice _STRINGPRINT 1033 add cx,4 1034 add si,2 1035 cmp si,20 1036 jb SFK_Loop0 1037 pop si dx cx bx ax 1038 ret 1039 1040 1041 1042 SMS_Restored db ' Keyboard setup successfully restored',0 1043 SMS_Saved db ' Keyboard setup successfully saved',0 1044 SMS_ErrorLoad db 1,0Ch,' Error restoring keyboard setup',0 1045 SMS_ErrorSave db 1,0Ch,' Error saving keyboard setup',0 1046 SMS_Type db 1,0Ch,'This file isn''t a keyboard setup file',0 1047 ShowMessage: cmp GetKeyParams.RK_ErrPtr,0 1048 jz SMS_Ret 1049 push ax bx cx dx 1050 mov bx,GetKeyParams.RK_ErrPtr 1051 mov ah,0Ah 1052 gotoxy 8,41 1053 ScreenIOservice _STRINGPRINT 1054 pop dx cx bx ax 1055 SMS_Ret: ret 1056 1057 1058 1059 1060 assume es:Emulate 1061 1062 Upcase: cmp al,'A' 1063 jb UPCSret 1064 cmp al,'Z' 1065 ja UPCSret 1066 or al,20h 1067 UPCSret: ret 1068 1069 CalcCommand: push ax bx cx es ; Returns number of a command 1070 push cs ; Input: 1071 pop es ; di -> offset Commands 1072 call Upcase ; al -> search command 1073 cld ; cx -> commands count 1074 mov bx,di 1075 repne scasb ; Output: 1076 stc ; di <- Number of the command 1077 jne CC_end ; cf <- 1 if not found 1078 sub di,bx 1079 dec di 1080 clc 1081 CC_end: pop es cx bx ax 1082 ret 1083 1084 1085 1086 ; -- Hook INT 24h ---------------------- 1087 1088 OldFlags dw ? 1089 OldFkeys dw ? 1090 Prepare4DOS: saveall 1091 xor ax,ax 1092 xchg ax,cs:ActiveFlags 1093 mov cs:OldFlags,ax 1094 xor ax,ax 1095 xchg ax,cs:FkeysFlags 1096 mov cs:OldFkeys,ax 1097 call ShowAll 1098 ScreenIOservice _SHOWSCREEN 1099 call far ptr SystemTINI 1100 restoreall 1101 ret 1102 1103 1104 1105 ; -- Unhook INT 24h -------------------- 1106 1107 SOD4eraperP: saveall 1108 mov ax,cs:OldFlags 1109 mov cs:ActiveFlags,ax 1110 mov ax,cs:OldFkeys 1111 mov cs:FkeysFlags,ax 1112 mov ax,Emulate 1113 mov es,ax 1114 mov byte ptr [C000],0 1115 call far ptr SystemINIT 1116 restoreall 1117 ret 1118 1119 1120 GetLineUser proc far 1121 ret 1122 GetLineUser endp 1123 1124 1125 GoAppleII: push ax bx es 1126 call ShowAll 1127 ScreenIOservice _SHOWSCREEN 1128 mov ax,Emulate 1129 mov es,ax 1130 mov al,C050 1131 ScreenIOservice _SetScreen 1132 xor bx,bx 1133 xchg bx,ActiveFlags 1134 SwitchToProcess PID_EMULATOR 1135 mov ActiveFlags,bx 1136 pop es bx ax 1137 ret 1138 1139 1140 KBDsetup ends 1141 1142 END