home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / OSBORNE / FLIPKEYS.LBR / FLIPKEYS.AZM / FLIPKEYS.ASM
Assembly Source File  |  2000-06-30  |  12KB  |  432 lines

  1. ;FLIPKEYS.ASM
  2. ;Curt Edwards 11/11/85
  3. ;<<<<<<<<<<<<<<<<<<<< Bdos Call Equates >>>>>>>>>>>     
  4. ;
  5.     boot    equ    00h    ;reset (warm boot)
  6.     conin    equ    01h    ;console input
  7.     conout    equ    02h    ;console output
  8.     prints    equ    09h    ;print string
  9.  
  10. ;
  11. ;<<<<<<<<<<<<<<<<<<<< Misc Equates >>>>>>>>>>>>>>>>>
  12. ;
  13.  
  14.     true    equ    0ffh
  15.     false    equ    00
  16.     Osborne    equ    true    ;Either Osborne or
  17.     normcpm    equ    false    ;normcpm must be true
  18.     bdos    equ    05h    ;bdos address
  19.     bell    equ    07h    ;bell
  20.     eof    equ    1ah    ;end of file or clear screen character
  21.     cr    equ    0dh    ;carrige return
  22.     lf    equ    0ah    ;line feed
  23.     tab    equ    09h    ;tab
  24.     esc    equ    1bh    ;escape
  25. ;
  26. ;<<<<<<<<<<<<<<<<<<<< End of Equates  >>>>>>>>>>>>>
  27. ;
  28.     org     100h
  29.     jmp    start
  30. ;
  31. mess:    db    'Curious aren''t we now!!'    ;for the nosey
  32. prg:    db      '        FLIPKEYS    '           ;who like to poke
  33. vermess:db    '    Version 1.0'        ;around with DDT 
  34. mess1:    db    '      By Curt Edwards'        ;like myself.
  35. mess2:    db    '   SoftStone Technologies'
  36. crnote:    db    'Copyright 11/11/85 All Rights Reserved'
  37. ;
  38. ; <<<<< Set up Local Stack >>>>>
  39. ;
  40. start:
  41.        lxi    h,0    ;zero hl register pair
  42.       dad    sp    ;add the stack pointer
  43.       shld    oldsp    ;store oldsp to restore when done
  44.       lxi    sp,stktop;point to new local stack
  45. ;
  46. ;<<<<<<<<<< S T A R T   O F   P R O G R A M  >>>>>>>
  47. ;
  48. ; <<<<< Print opening message >>>>>
  49. ;
  50.     call    clr    ;clear screen
  51.     lxi    d,omess1;1st line of opening mess
  52.     call    pstring    ;print it
  53.     call    halfon    ;turn off half intensity
  54.     lxi    d,omess2;2nd line of opening mess
  55.     call    pstring    ;print it
  56.     call    halfoff    ;turn half inten on again
  57. ;
  58. ; <<<<< Check if single or double density >>>>>
  59. ;     
  60.     lxi    h,0002h    ;load hl with value of address 3
  61.     mov    a,m    ;put value in a reg
  62.     cpi    0e5h    ;is it single density?
  63.     jz    single    ;yes
  64.     cpi    0e1h    ;is it double density?
  65.     jz    double    ;yes
  66.     jmp     error
  67. ;
  68. error:
  69.     lxi    d,errormess    ;point to error message
  70.     call    pstring        ;print it    
  71.     jmp    fini
  72. ;
  73. ;
  74. single:    
  75.     lhld    0e57fh        ;addr to 1st entry in arrow key vector
  76.     shld    vectadr
  77.     lxi    d,singlemess    ;point to single density message
  78.     call    pstring        ;print it
  79.     jmp    check        ;jmp to check rountine
  80. ;
  81. double:    
  82.     lhld    0e17fh        ;addr to 1st entry in arrow key vector    
  83.     shld    vectadr
  84.     lxi    d,doublemess    ;point to double density message
  85.     call    pstring        ;print it
  86.     jmp    check        ;jmp to check routine 
  87. ;
  88. ; <<<<< Check if current keys are Wordstar or CP/M >>>>>
  89. ;
  90. check:    
  91.     lhld    vectadr
  92.     mov    a,m    ;put up key code in a reg
  93.     cpi    05h    ;is it Wordstar keys?
  94.     jz    ws2cpm    ;yes
  95.     cpi    0bh    ;is it cpm keys
  96.     jz    cpm2ws    ;yes
  97.     jmp    cpm2ws    ;default to cp/m
  98. ;
  99. ;
  100. ; <<<<< Change the key configurations >>>>>
  101. ;
  102. ws2cpm:
  103.     call     halfon    ;turn on half intensity
  104.     lxi    d,wsmess;set up to print key status mess
  105.     call    pstring
  106.     call    halfoff
  107.     lxi    d,wsmess1
  108.     call    pstring
  109.     call    halfon
  110.     lxi    d,wsmess2
  111.     call    pstring
  112.     call    halfoff
  113.     call    uline
  114.     lxi    d,wsmess3
  115.     call    pstring
  116.     call    nuline
  117.     mvi    b,4    ;set up counter
  118.     lhld    vectadr
  119.     lxi    d,cpmtbl;point to cpm key codes
  120. loop1:    ldax    d    ;put code in a reg
  121.     mov    m,a    ;put it in vector
  122.     inx    h    ;increment key code pointer
  123.     inx    d    ;increment table pointer
  124.     dcr    b    ;decrment counter
  125.     jnz    loop1    ;done? no get next code
  126.     jmp    fini    ;yes, return to cp/m
  127. ;
  128. cpm2ws:
  129.     call    halfon        ;turn on half intensity
  130.     lxi    d,cpmmess    ;set up to print key status message
  131.     call    pstring 
  132.     call    halfoff
  133.     lxi    d,cpmmess1
  134.     call    pstring
  135.     call    halfon
  136.     lxi    d,cpmmess2
  137.     call    pstring
  138.     call    halfoff
  139.     call    uline
  140.     lxi    d,cpmmess3
  141.     call    pstring
  142.     call    nuline
  143.     mvi    b,4    ;set up counter
  144.     lhld    vectadr
  145.     lxi    d,wstbl    ;point to ws key codes
  146. loop2:    ldax    d    ;put code in a reg
  147.     mov    m,a    ;put it in vector
  148.     inx    h    ;incr key code pointer
  149.     inx    d    ;incr table pointer
  150.     dcr    b    ;dcr counter
  151.     jnz    loop2    ;done? no get next code
  152.     jmp     fini    ;yes return to cp/m
  153. ;
  154. ; <<< restore old stack pointer and warm boot system >>>
  155. ;
  156. fini:    
  157.     lxi    h,oldsp    ;load h with old stack pointer
  158.     sphl        ;put it in the stack pointer
  159.     ret        ;back to cpm
  160. ;
  161. ;<<<<<<<<<< E N D   O F   P R O G R A M  >>>>>>>>>>>
  162. ;---------------------------------------------------
  163. ;<<<<<<<<<<<<<<<<< SUBROUTINES >>>>>>>>>>>>>>>>>>>>
  164. ;      -------------------------------------
  165. ;     |[[[[ Osborne Specific Routines ]]]]] |
  166. ;      -------------------------------------
  167. ;---------------------------------------------------
  168. ; <<<<< Clear the screen >>>>>
  169. ;
  170. clr:
  171.     push d! push b! push h
  172.     call ilprt
  173.     db    1ah,0
  174.     pop h! pop b! pop d
  175.     ret
  176. ;    
  177. ;--------------------------------------------------
  178. ; <<<<< Set Half Intensity Video >>>>>
  179. ;
  180. halfon:
  181.     push d! push b! push h    ;save enviroment
  182.     call    ilprt        ;call print routine
  183.     db    esc,29h,0     ;code for half inten.
  184.     pop h! pop b! pop d    ;restore enviroment
  185.     ret            ;return to calling routine
  186. ;
  187. ;--------------------------------------------------
  188. ; <<<<< Set Full Intensity Video >>>>> 
  189. ;
  190. halfoff:
  191.     push d! push b! push h    ;save enviroment          
  192.     call    ilprt           ;call print routine       
  193.     db    esc,28h,0       ;code for full inten.     
  194.     pop h! pop b! pop d     ;restore enviroment       
  195.     ret                     ;return to calling routine
  196. ;
  197. ; -------------------------------------------------
  198. ; <<<<< Turn Underline on >>>>>
  199. ;
  200. uline:
  201.     push b! push d! push h    ;save enviroment          
  202.     call    ilprt           ;call print routine       
  203.     db    esc,6ch,0       ;code for underline on
  204.     pop h! pop d! pop b     ;restore enviroment       
  205.     ret                     ;return to calling routine
  206. ; --------------------------------------------------
  207. ; <<<<< Turn Underline off >>>>>
  208. ;
  209. nuline:
  210.     push b! push d! push h    ;save enviroment          
  211.     call    ilprt           ;call print routine       
  212.     db    esc,6dh,0       ;code for underline off   
  213.     pop h! pop d! pop b     ;restore enviroment       
  214.     ret                     ;return to calling routine
  215. ;
  216. ; --------------------------------------------------
  217. ; <<<<< Start Graphics >>>>>
  218. ;
  219. graphon:
  220.     push b! push d! push h    ;save enviroment          
  221.     call    ilprt           ;call print routine       
  222.     db    esc,67h,0       ;code for start graphics  
  223.     pop h! pop d! pop b     ;restore enviroment       
  224.     ret                     ;return to calling routine
  225. ;
  226. ; --------------------------------------------------
  227. ; <<<<< Stop Graphics >>>>> 
  228. ;
  229. graphoff:
  230.     push b! push d! push h    ;save enviroment          
  231.     call    ilprt           ;call print routine       
  232.     db    esc,47h,0       ;code for stop graphics   
  233.     pop h! pop d! pop b     ;restore enviroment       
  234.     ret                     ;return to calling routine
  235. ;
  236. ; --------------------------------------------------
  237. ; <<<<< Set cursor position on screen >>>>>
  238. ;       y=line number x=column number
  239. ;NOTE: yy,xx position must be in the hl register
  240. ;pair when this call is made y in h and x in l
  241. ;
  242. curpos:
  243.     push b! push d! push h     ;save calling enviroment
  244.     xchg        ;put position in hl into de
  245.     lxi    h,posseq;load h with postion sequence
  246.     mov    a,d    ;move y postion in a 
  247.     adi    20h    ;add bias
  248.     mov    m,a    ;put it in postion sequence 3
  249.     inx    h    ;increment h to point to next byte
  250.     mov    a,e    ;put x postion in a
  251.     adi    20h    ;add bias
  252.     mov    m,a    ;put it in position sequence 4
  253.     call    ilprt    ;print complete postion sequence
  254.     db    esc,'=' ;1st two bytes to postion cursor
  255. posseq:    db    0ffh,0ffh,0    ; yy,xx postion, zero to end
  256.     pop h! pop d! pop b    ;restore calling enviroment
  257.     ret            ;go back
  258. ;
  259. ;--------------------------------------------------- 
  260. ;     ------------------------------------------
  261. ;    |[[[[ End of Osborne Specific Routines ]]]]|
  262. ;     -------------------------------------------
  263. ;---------------------------------------------------
  264. ; <<<<< Print out a string w/console out function >>>>>
  265. ;
  266. ;     db must end with 0 to flag end of string
  267. ;
  268. ; MUST HAVE THIS ZERO...----------------------+
  269. ; example:                                    |
  270. ;                                             |
  271. ;    call ilprt                            V
  272. ;    db   cr,lf,'This would be the string',0   
  273. ;
  274. ;
  275. ilprt:    
  276.     xthl        ;put SP in hl, hl now has 1st
  277.             ;character of db at return address
  278.     mov    a,m    ;move 1st char in a register
  279.     inx    h    ;increment string pointer
  280.     xthl        ;put SP in hl again
  281.     ora    a    ;is it zero
  282.     rz        ;yes retrun
  283.     push    h    ;save string pointer
  284.     mov    e,a    ;put 1st character in e
  285.     call    outch    ;call console out routine
  286.     pop    h    ;restore string pointer
  287.     jmp    ilprt    ;get next character
  288. ;
  289. ;---------------------------------------------------
  290. ; <<<<< Print string subroutine >>>>
  291. ; de pair must point to string upon entry
  292. ;
  293. pstring:
  294.     push h! push d! push b
  295.     mvi    c,prints;set up print string function
  296.     call    bdos    ;print it
  297.     pop b! pop d! pop h
  298.     ret
  299. ;
  300. ;---------------------------------------------------
  301. ; <<<< Send Carrige Return/Line Feed >>>>>
  302. ;
  303. crlf:
  304.     push b! push d! push h
  305.     call    ilprt
  306.     db    0dh,0ah,0
  307.     pop h! pop d! pop b
  308.     ret
  309. ;
  310. ;---------------------------------------------------
  311. ; <<<< Reset System (warm boot) >>>>>
  312. ;
  313. wmboot:
  314.     push b! push d! push h
  315.     call    ilprt
  316.     db    cr,lf,lf,'Warm Boot...',cr,lf,0
  317.     mvi    c,boot
  318.     call    bdos
  319.     pop h! pop d! pop b
  320.     ret
  321. ;---------------------------------------------------
  322. ; <<<<< Get a Single Character >>>>>
  323. ;
  324. inch:    push h! push b! push d
  325.     mvi    c,conin
  326.     call    bdos
  327.     pop d! pop b! pop h
  328.     ret        ;on return A reg will hold
  329. ;            ;ascii character    
  330. ;---------------------------------------------------
  331. ; <<<<< Output a Single Character >>>>
  332. ;
  333. outch:
  334.     push h! push b! push d
  335.     mvi    c,conout    ;assumes character is in e register
  336.     call    bdos
  337.     pop d! pop b! pop h
  338.     ret
  339. ;---------------------------------------------------
  340. ; <<<<< Tables >>>>>
  341. ;---------------------------------------------------
  342. ;
  343. ;  <<<<< wordstar arrow key code table >>>>>
  344. ;
  345. ; This is a neat little routine to save someone from
  346. ; having to look up what the ASCII equivilant for a
  347. ; control character is.  By using the uppercase ASCII
  348. ; character in quotes and subtracting 40 hex from it the
  349. ; assembler read it as the proper code.
  350. ; ie: 'E'-40h is read as 05H, beacuse ASCII 'E' is
  351. ;     45h minus 40h equals 05H.
  352.  
  353.  
  354. wstbl:    
  355.     db    'E'-40h ;up arrow    ^E
  356.     db    'D'-40h    ;right arrow ^D
  357.     db    'X'-40h    ;down arrow  ^X
  358.     db    'S'-40h    ;left arrow  ^S
  359. ;
  360. ; <<<<< cp/m arrow key code table >>>>>
  361. ;
  362. cpmtbl:    
  363.     db    'K'-40h    ;up arrow    ^K
  364.     db    'L'-40h    ;right arrow ^L
  365.     db    'J'-40h    ;down arrow  ^J
  366.     db    'H'-40h    ;left arrow  ^H
  367. ;
  368. ;---------------------------------------------------
  369. ; <<<<< Message area >>>>>
  370. ;---------------------------------------------------
  371. ; <<<<< opening message >>>>>
  372. ;
  373. omess1:    db    'FLIPKEYS','$'
  374. omess2: db    ' Version 1.0',cr,lf
  375.     db    '(c)Curt Edwards 11/25/85 ',cr,lf 
  376.     db    'Sysop: SoftStone RCP/M (502) 241-4109',cr,lf
  377.     db    '       P.O Box 694 Crestwood, Ky 40014',cr,lf,'$'
  378. ;
  379. ; <<<<< single density message >>>>>
  380. ;
  381. singlemess:
  382.     db    cr,lf,'Osborne-1 Single density system','$'
  383. ;
  384. ; <<<<< double density message >>>>>
  385. ;
  386. doublemess:
  387.     db    cr,lf,'Osborne-1 Double density system','$'
  388. ;
  389. ; <<<<< ws2cpm message >>>>>
  390. ;
  391. wsmess:
  392.     db    cr,lf,lf,bell,'Arrow keys were ','$'
  393. wsmess1:
  394.     db    'Wordstar','$'
  395. wsmess2:
  396.     db    ' they are now set for ','$'
  397. wsmess3:
  398.     db    'CP/M',cr,lf,lf,'$'
  399. ;
  400. ; <<<<< cpm2ws message >>>>>
  401. ;
  402. cpmmess:
  403.     db    cr,lf,lf,bell,'Arrow keys were ','$'
  404. cpmmess1:
  405.     db    'CP/M','$'
  406. cpmmess2:
  407.     db    ' they are now set for ','$'
  408. cpmmess3:
  409.     db    'Wordstar',cr,lf,lf,'$'
  410. ;
  411. ; <<<<< error message >>>>>
  412. ;
  413. errormess:
  414.     db    cr,lf,lf,lf,bell,bell,'Not a reconizable Osborne system',cr,lf
  415.     db    lf,'Returning to CP/M !','$'
  416.  
  417. ;--------------------------------------------------- 
  418. ; <<<<< Reserve Memory >>>>>
  419. ;---------------------------------------------------
  420. vectadr:
  421.     ds      2    ;starage for 1st entry to arrow key
  422. ;            ;arrow key vetor
  423. ;
  424. oldsp:    ds    2    ;old stack pointer
  425.     ds    32    ;new stack
  426.  
  427. stktop:
  428. ;
  429.     end    100h
  430.     
  431. ■)