home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / kaypro / kp-ubios.mac < prev    next >
Text File  |  1994-07-13  |  13KB  |  578 lines

  1. ;****************************************************************
  2. ;*                                *
  3. ;*              CBIOSZ for CPM 2.2u1            *
  4. ;*                                *    
  5. ;****************************************************************
  6. ;
  7. ;HISTORY:
  8. ;vs 0.9 
  9. ;4/25/86     disassembled, cleaned up, rewritten, commented 
  10. ;        and zcpr3 and cursor, keyboard routines added
  11. ;        still much not understood.. note several unknx 
  12. ;        (unknown) routines after months of stubborn 
  13. ;        hacking (and bludgeoning).. PLEASE send further
  14. ;        improvements and commenting to:
  15. ;                    Will Ridenour
  16. ;                    338 S. Campbell
  17. ;                    Macomb, Il 61455
  18. ;                    (309) 833-1109 (voice)    
  19. ;
  20. ;NOTE:        this cbios is experimental... been using it for
  21. ;        weeks without problems or bugs (with ws, turbo, bds c
  22. ;        assemblers, loaders, etc.) but since I'm on my own out
  23. ;        here in the midwest, i have no beta testers.. use at
  24. ;        your own risk and if you find bugs.. let me know or, 
  25. ;        even better, fix them and let me know what you did.
  26. ;
  27. ;FURTHER NOTE:    I removed several routines from this bios that made
  28. ;        bdos calls... I think they were a very half baked way to
  29. ;        make a shell of the 2x's masmenu system.... since
  30. ;        I never use the masmenu I haven't missed these routines
  31. ;        ... if you want to put them back, you're on your own... but
  32. ;        for god's sakes find a better way than putting bdos calls
  33. ;        in the bios.    
  34.  
  35.     .z80        ;set up to compile with m80
  36.     aseg        ;comment these lines out and cap 
  37.             ;pseudo -ops to use z80mr
  38.             ;since no macros or maclibs can also use 
  39.             ;zasm or such as long as it's a z80 assembler
  40.             ;may need to alter some syntax if not m80
  41. ;
  42. ;******* system    location equates
  43. ;
  44.     boot    equ    1
  45.     jbdos    equ    5        
  46.     bdloc    equ    0D406h
  47.     ccp    equ    0CC00h
  48.     bios    equ    0E200h
  49.     iobyte    equ    3        ;iobyte vector in page zero
  50.     duvct    equ    4        ;default drive user vector
  51.     tpa    equ    100h        ;start of transient program area
  52. ;
  53. ;******* zcpr specific equates
  54. ;    graf    equ    4fh    ;toggle byte for graphics (not implemented)
  55.     whlb    equ    04bh    ;zcpr3 wheel byte
  56.     login    equ    0f0h    ;log in to disk A, user 15
  57.                 ;works nicely to keep all system files out
  58.                 ;in a15 and applications in a0
  59. ;    
  60. ;******* 
  61.     bitport    equ    14h    ;system select port
  62.     maxdsk    equ    2    ;standard 2 floppy 2x kaypro
  63.     keyreg    equ    5    ;keyboard register 
  64.     quiet    equ    8    ;value to turn off clicker
  65.     vidsel    equ    1ch    ;video select port    
  66.     cureg    equ    1fh    ;video cursor register 
  67.     cursor    equ    0f000h    ;nonblink block    
  68.     cflag    equ    0f1f0h  ;this may be heresy-- using unused area
  69.                 ;of tcap to store cursor and keyboard
  70.                 ;values-- but its seems logical and it's
  71.                 ;going to waste otherwise -- unused area
  72.                 ;above bios stack at e6f0 may be used if
  73.                 ;you wish to remain orthadox    
  74.     curs1    equ    0f1f1h    ;values for cursor and keyboard stored
  75.     curs2    equ    0f1f2h    ;under tcap
  76.     kybd    equ    0f1f3h
  77. ;    
  78.     org    bios        ;use 3d80 offset to load with ddt or zsid
  79.                 ;if not changing tpa size from 58k
  80. ;
  81. ;******** standard cpm bios jump table
  82.  
  83.     jp    cboot        ;arrive here from cold boot        
  84. jwboot:    jp    wboot        ;jump to warm boot
  85.     jp    const        ;jump to console status routine
  86.     jp    conin        ;console in
  87.     jp    conout        ;console out
  88.     jp    list        ;list out
  89.     jp    punch        ;punch out
  90.     jp    reader        ;reader in
  91.     jp    home        ;home disk routine
  92.     jp    seldsk        ;select disk routine
  93.     jp    settrk        ;set track routine
  94.     jp    setsec        ;set sector
  95.     jp    setdma        ;set default memory address
  96.     jp    read        ;read file
  97.     jp    write        ;write file
  98.     jp    listst        ;list status
  99.     jp    sectran        ;sector translate
  100. ;
  101. const:    call    unkn2        ;can't comment on any of the following    
  102.     call    unkn3        ;these routines are mostly in rom 
  103.     db    19h        ;and don't have that sorted out yet
  104. conin:    call    const        
  105.     and    a
  106.     db    28h
  107.     db    0fah
  108.     call    unkn3
  109.     db    1ah
  110. conout:    push    bc
  111.     call    unkn2        
  112.     pop    bc
  113.     call    unkn3        
  114.     db    1bh
  115. list:    push    bc
  116.     call    unkn2        
  117.     pop    bc
  118.     call    unkn3        
  119.     db    1ch
  120. punch:    push    bc
  121.     call    unkn2        
  122.     pop    bc
  123.     call    unkn3        
  124.     db    1dh
  125. reader:    call    unkn2        
  126.     call    unkn3        
  127.     db    1eh
  128. home:    call    unkn3
  129.     db    1fh
  130. seldsk:    call    unkn3        
  131.     db    20h
  132. settrk:    call    unkn3        
  133.     db    21h
  134. setsec:    call    unkn3
  135.     db    22h
  136. setdma:    call    unkn3
  137.     db    23h
  138. read:    call    unkn1        
  139.     call    unkn3        
  140.     db    24h
  141. write:    call    unkn1        
  142.     call    unkn3        
  143.     db    25h
  144. listst:    call    unkn3        
  145.     db    26h
  146. sectran:
  147.     call    unkn3
  148.     db    27h    
  149. ;
  150. unkn1:    ld    hl,2800h
  151.     ld    (stak+2),hl
  152.     ld    hl,800h
  153.     ld    (stak+4),hl    
  154.     ret    
  155. ;
  156. unkn2:    ld    a,(sizkbf)    
  157.     and    a
  158.     ret    z
  159.     ld    hl,(stak+2)    
  160.     ld    a,h
  161.     or    l
  162.     ret    z
  163.     dec    hl
  164.     ld    (stak+2),hl    
  165.     ld    a,h
  166.     or    l
  167.     ret    nz
  168.     ld    hl,(stak+4)    
  169.     ld    (stak+2),hl    
  170.     ld    hl,0000h    
  171.     ld    (stak+4),hl    
  172.     call    unkn3        
  173.     inc    (hl)
  174.     ret    
  175. ;
  176. unkn3:    pop    hl
  177.     ld    d,(hl)
  178.     ld    (stak+6),sp
  179.     ld    sp,stak+35h
  180.     ld    hl,unkn4
  181.     push    hl
  182.     jp    gorom1        
  183. ;
  184. unkn4:    ld    sp,(stak+6)
  185.     ei
  186.     ret
  187. ;
  188. ioconfg:            ;configuration for iobyte
  189.     db    10011001b    ;99h to support Kaypro internal    modem
  190.                 ;set to 81h to use serial data port 
  191.                 ;for external modem
  192.     db    0    
  193. ;*** the following section may as well be in hebrew.. be glad if
  194. ;*** someone can sort it out
  195. ;
  196. unkn5:    db    18h,4ch        ;can't guarantee that any of this is
  197.     db    0        ;right since i don't know what it's
  198.     ret    nc        ;doing yet... bytes are right but op codes
  199.     pop    hl        ;don't make any sense to me yet
  200.     jp    pe,0000h    
  201.     db    18h,4ch
  202.     db    0    
  203.     ret    po
  204.     pop    hl
  205.     jp    pe,0000h    
  206.     db    18h,4ch
  207.     db    0    
  208.     ret    po
  209.     pop    bc
  210.     ld    l,b
  211.     db    0,0    
  212.     dec    b
  213.     dec    b
  214.     db    0,0,0    
  215. ;
  216. ; note: config will no longer work on this system to set number pad and
  217. ;    vector keys... sorry... keybuf can hold approx 16 characters per
  218. ;    number pad key +2 bytes at beginning for each key definition 
  219. ;    (1 for number of relative bytes to location of definition and 1 
  220. ;    for number of bytes in definition.. number of bytes comes first
  221. ;    have defined zero key as 'HOLD, <RTN>' to show how to do your own. 
  222. ;    seems to me this is more space than needed but haven't been able 
  223. ;    to cut it down.. has something to do with values in indexed
  224. ;    registers(ix iy), but haven't got that figured yet.. at any rate 
  225. ;    it seems that we could get more flexibility out of this with some 
  226. ;    thought.. would be very grateful for help
  227. ;
  228. sizkbf:    db    0ffh    ;don't know if this is really size of key buf
  229.             ;or just a coincidence.. changing it doesn't
  230.             ;help in cutting size of buffer    
  231. keybuf:    db    05h    ;5 bytes in 'HOLD' <RTN>
  232.     db    1ch    ;1ch bytes to location of definition
  233.     db    01h,20h,01h,21h,01h,22h,01h,23h,01h,24h,01h,25h
  234.     db    01h,26h,01h,27h,01h,28h,01h,29h,01h,2ah,01h,2bh
  235.     db    01h,2ch
  236.     db    'HOLD',0dh    ;HOLD <RTN>
  237.     db    '123456789-,',0dh,'.'
  238.     db    0ffh,0ffh    ;end markers don't need to be there
  239.                 ;if nothing defined
  240.     db    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
  241.     db    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
  242.     db    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
  243.     db    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
  244.     db    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
  245.     db    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
  246.     db    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
  247.     db    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 
  248.     db    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  249. ;note:  above buffer must be exactly 255 bytes long (incl defs) unless
  250. ;    you figure out indexed registers... otherwise all key defs will be off    
  251. ;
  252. uparo:    db    05h        ;ws keys ^E
  253. dnaro:    db    18h        ;^X
  254. rtaro:    db    13h        ;^S
  255. lfaro:    db    04h        ;^D
  256.     db    0f0h,0f1h,0f2h,0f3h,0f4h,0f5h,0f6h,0f7h,0f8h  ;key vectors?
  257.     db    0f9h,0fah,0fbh,0fch,0fdh
  258. keydef:    db    '1234567890-='
  259.     db    '`qwy[]a;',27h,'\zm,./eiou!@#$%^&*()_+~'
  260.     db    'QWY{}A:"|ZM<>?EIOU'
  261.  
  262. ;******************* cold boot routines
  263. ;
  264. cboot:    di            ;disable interupts    
  265.     ld    sp,stak+35h    
  266.     in    a,(bitport)
  267.     and    7fh
  268.     out    (bitport),a
  269.     ld    d,36h
  270.     call    gorom1        
  271.     ld    de,0054h    
  272.     add    hl,de
  273.     ex    de,hl
  274.     ld    ix,cbuf1    
  275.     ld    a,4
  276. cloop1:    ex    af,af'        ;cloop1 was 4 calls in a row to the same
  277.     ld    bc,0002h    ;subroutine called only here-- replaced with
  278.     ld    a,2        ;a loop and put inline
  279.                 ;-- cloop1 and two are setting up
  280.     call    cloop2        ;indexed registers, don't quite follow yet
  281.     add    ix,bc        ;cloop2 was the same called 2,
  282.     ld    a,4        ;then 4 times, then 2 again.. made another
  283.     call    cloop2        ;series of loops
  284.     add    ix,bc
  285.     ld    a,2
  286.     call    cloop2        
  287.     inc    ix
  288.     ex    de,hl
  289.     ld    d,00h
  290.     ld    e,(ix+0f9h)
  291.     add    hl,de
  292.     ld    e,(ix+0efh)
  293.     add    hl,de
  294.     ex    de,hl
  295.     ex    af,af'
  296.     dec    a
  297.     jr    nz,cloop1
  298.     ld    bc,cbuf1    
  299.     ld    d,36h
  300.     call    gorom1        
  301.     ld    bc,unkn6    
  302.     ld    d,00h
  303.     call    gorom1        
  304.     ld    bc,unkn5    
  305.     ld    d,2ah
  306.     call    gorom1        
  307.     ld    bc,keybuf    
  308.     ld    d,2bh
  309.     call    gorom1        
  310.     ld    a,login            
  311.     ld    (duvct),a        
  312.     ld    a,(ioconfg)        ;this is also repeated in gocpm    
  313.     ld    (iobyte),a    
  314.     ld    d,28h
  315.     ld    bc,signon        ;uses a rom sub to print signon
  316.     call    gorom1            ;msg... 'Kaypro CPM 2.2' in rom    
  317.                     ;u1 added in bios, added z3 and
  318.     ei                ;tpa size... considered adding
  319.                     ;date and my initials, but this
  320.                     ;is too far from finished to feel
  321.                     ;proprietary... add your own if
  322.                     ;it makes you feel good
  323. ;    
  324. ;*********** routines to initialize system for zcpr3
  325. ;
  326.     ld    hl,path
  327.     ld    de,40h
  328.     ld     bc,9            ;load path 
  329.     ldir
  330. ;
  331.     ld    a,0ffh
  332.     ld    (whlb),a        ;set wheel byte
  333. ;
  334. ;graphics byte set commented out because graphics don't seem to make any
  335. ;trouble on u1... will need to add 8th bit filter toggle to conout
  336. ;to use this
  337. ;    
  338. ;    ld    a,0
  339. ;    ld    (graf),a        ;set graphics byte
  340.     ld    hl,0e700h        ;initialize high memory buffers
  341.     ld    a,17            ;zeroing all the way to f7ff
  342. zloop:    ld    b,0ffh            ;even tho top at f5.. doesn't 
  343. zero:    ld    (hl),0            ;add more than a milisecond to cboot
  344.     inc    hl            ;and keeps things clear and clean
  345.     djnz    zero            ;for planned additions
  346.     dec     a    
  347.     jr    nz,zloop
  348.     ld    hl,mcmd            ;initialize multiple command
  349.     ld    de,0f400h        ;buffer and load cold boot command
  350.     ld    bc,24
  351.     ldir
  352.     jr    gocpm            ;all done so get ready to go to cpm
  353. ;
  354. ;****************** warm boot routines
  355. ;
  356. wboot:    ld    sp,stak+35h    
  357. ;    ld    hl,0000h    
  358. ;    ld    (buf1),hl    ;what's going on here?    
  359. ;    ld    (buf2),hl    
  360.     ld    d,29h
  361.     call    gorom1        
  362. ;
  363. ;***************** gocpm routines shared by warm and cold boot
  364. ;
  365. gocpm:
  366. ;
  367. ;***************** cursor set routine
  368. ;
  369.     ld    a,(cflag)    ;check to see if cursor defs are loaded
  370.     cp    0        
  371.     jr    nz,stcurs    ;yes so go set them
  372.     ld    a,1        ;no so load then first
  373.     ld    (cflag),a    
  374.     ld    hl,cursor
  375.     ld    (curs1),hl
  376.     ld    a,quiet
  377.     ld    (kybd),a
  378. stcurs:    ld    a,0ah        ;select cursor reg 1
  379.     out    (vidsel),a
  380.     ld    a,(curs1)
  381.     out    (cureg),a    ;set blink and top of cursor
  382.     ld    a,0bh        ;select cursor reg 2
  383.     out    (vidsel),a
  384.     ld    a,(curs2)        ;set bottom of cursor
  385.     out    (cureg),a
  386. ;
  387. ;***************** routine to set keyboard to quiet (or not)
  388. ;
  389. ;    note: this doesn't work as well as I'd like -- clicker is
  390. ;    on at cold boot... shuts off after warm boot.. don't know why
  391. ;    probably something in rom
  392. ;
  393.     ld    a,(kybd)
  394.     out    (keyreg),a
  395. ;
  396. ;***************** loading warm boot and bios jumps
  397. ;
  398.     ld    a,0c3h
  399.     ld    (0),a    
  400.     ld    (jbdos),a
  401.     ld    hl,jwboot    
  402.     ld    (boot),hl    
  403.     ld    hl,bdloc
  404.     ld    (6),hl
  405.     ld    a,(duvct)
  406.     and    0fh        ;zero out user nibble
  407.     cp    maxdsk+1    ;make sure it's a valid disk
  408.     ld    a,(duvct)        ;get a fresh copy
  409.     jr     c,gocp2        ;if ok then skip        
  410.     xor    a        ;else default to disk a user 0
  411. gocp2:    ld    (duvct),a    ;reload
  412.     ld    c,a        ;pass du to ccp for action
  413.     ld    sp,tpa        ;set stack pointer for program exec
  414.     jp    ccp        ;note all entry is at 1st ccp entry
  415.                 ;seems to me that zcpr3 and multiple
  416.                 ;commands make 2 entry points meaningless
  417. ;    
  418. cloop2:    ld    l,(ix+00h)
  419.     ld    h,(ix+01h)
  420.     add    hl,de
  421.     ld    (ix+00h),l
  422.     ld    (ix+01h),h
  423.     add    ix,bc
  424.     dec    a
  425.     jr    nz,cloop2
  426.     ret    
  427. ;
  428. unkn6:    call    gorom2        ;seems to me this can be cleaned up
  429.     db    01h        ;with loop(s), but don't understand it
  430.     call    gorom2        ;well enough yet
  431.     db    02h
  432.     call    gorom2        
  433.     db    03h
  434.     call    gorom2        
  435.     db    04h
  436.     call    gorom2        
  437.     db    05h
  438.     call    gorom2        
  439.     db    06h
  440.     call    gorom2
  441.     db    07h
  442.     call    gorom2        
  443.     db    08h
  444.     call    gorom2        
  445.     db    0dh
  446.     call    gorom2        
  447.     db    0eh
  448.     call    gorom2
  449.     db    0fh
  450.     call    gorom2        
  451.     db    10h
  452.     call    gorom2        
  453.     db    9h
  454.     call    gorom2        
  455.     db    0ah
  456.     call    gorom2        
  457.     db    0bh
  458.     call    gorom2        
  459.     db    0ch
  460.     call    gorom2        
  461.     db    11h
  462.     call    gorom2
  463.     db    12h
  464. ;
  465. gorom1:    ld    a,(iobyte)    
  466.     ld    h,a
  467.     in    a,(bitport)
  468.     push    af
  469.     set    7,a
  470.     out    (bitport),a
  471.     ld    a,h
  472.     call    004bh        
  473.     pop    bc
  474.     ex    af,af'        ;these were push and pop
  475.                 ;same space but faster
  476.     ld    a,b
  477.     and    80h
  478.     ld    b,a
  479.     in    a,(bitport)
  480.     and    7fh
  481.     or    b
  482.     out    (bitport),a
  483.     ex    af,af'
  484.     ret    
  485. ;
  486. gorom2:    ex    (sp),hl
  487.     ld    (stak+07ah),sp
  488.     ld    sp,stak+090h
  489.     push    de
  490.     push    bc
  491.     push    af
  492.     push    ix
  493.     push    iy
  494.     ld    d,(hl)
  495.     in    a,(bitport)
  496.     ex    af,af'
  497.     set    7,a
  498.     out    (bitport),a
  499.     call    004bh        
  500.     ex    af,af'
  501.     and    0fch
  502.     ld    d,a
  503.     in    a,(bitport)
  504.     and    03h
  505.     or    d
  506.     out    (bitport),a
  507.     pop    iy
  508.     pop    ix
  509.     pop    af
  510.     pop    bc
  511.     pop    de
  512.     ld     sp,(stak+07ah)
  513.     pop    hl
  514.     ei
  515.     reti
  516.     
  517. ;
  518. cbuf1:    db    0,0
  519.     ld    e,00h        ;don't know what all this is
  520.     ld    e,00h        ;zsid and ddt alter some values in here
  521.     db    0,0,0,0    
  522.     ld    e,00h
  523.     inc    hl
  524.     nop    
  525.     dec    b
  526.     nop    
  527.     ld    e,00h
  528.     ld    e,00h
  529.     db    0,0,0    
  530.     dec    b
  531.     nop    
  532.     dec    b
  533.     db    0,0,0,0,0    
  534.     dec    b
  535.     nop    
  536.     inc    hl
  537.     nop    
  538.     ld    e,00h
  539.     dec    b
  540.     nop    
  541.     dec    b
  542.     db    0,0,0,0    
  543.     ld    e,00h
  544.     ld    e,00h
  545.     db    0,0,0,0    
  546.     ld    e,00h
  547.     inc    hl
  548.     nop    
  549.     dec    b
  550.     nop    
  551.     ld    e,00h
  552.     ld    e,00h
  553.     db    0,0,0    
  554.     inc    d
  555.     nop    
  556.     inc    d
  557.     db    0,0,0,0,0    
  558.     inc    d
  559.     nop    
  560.     rla    
  561.     nop    
  562.     inc    bc
  563.     nop    
  564.     inc    d
  565.     nop    
  566.     inc    d
  567. ;
  568.     db    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  569. signon:    db    'u1z3 58k tpa',0dh,0ah,0
  570. path:    db    01h,0,01h,0fh,0,0,0,0,0
  571. mcmd:    db    04h,0f4h,0D0h,0,'LDR SYS.ENV;STARTUP',0    
  572.     db    'END'        ;end of bios
  573. stak    equ    $+8        ;note this is bottom of stack-- top is
  574.                 ;0afh bytes higher (have compressed it much)
  575.                 ;may possibly be compressed further 
  576. ;    
  577.     end    
  578. ≤à