home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / cpm / apple / aplvidex.ark / IOLOADER.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-04-26  |  7.4 KB  |  465 lines

  1. ;driver for videx card
  2. ;general philosophy
  3. ;BC register for character
  4. ;DE to work stuff
  5. ;HL for writing
  6. FALSE    EQU    00h
  7. TRUE    EQU    NOT FALSE
  8. CPM56    EQU    TRUE
  9. CPM60    EQU    FALSE
  10. space    equ    20h
  11. data    equ    0e0b1h
  12. reg    equ    0e0b0h
  13. speaker    equ    0e030h
  14. videx    equ    0e300h
  15. ram0    equ    0ec00h
  16. ram1    equ    0ed00h
  17. offrom    equ    0efffh
  18. @gendd    macro    ?dd
  19.     if (?dd gt 7fh) and (?dd lt 0ff80h)
  20.     db    100h
  21.     else
  22.     db    ?dd
  23.     endif
  24.     endm
  25. jr    macro    ?n
  26.     db    18h
  27.     @gendd    ?n-$-1
  28.     endm
  29. jrc    macro    ?n
  30.     db    38h
  31.     @gendd    ?n-$-1
  32.     endm
  33. jrnc    macro    ?n
  34.     db    30h
  35.     @gendd    ?n-$-1
  36.     endm
  37. jrz    macro    ?n
  38.     db    28h
  39.     @gendd    ?n-$-1
  40.     endm
  41. jrnz    macro    ?n
  42.     db    20h
  43.     @gendd    ?n-$-1
  44.     endm
  45. ldir    macro    ;;LDIR
  46.     db    0edh,0b0h
  47.     endm
  48.     org    100h
  49.     jmp    mover
  50.     offset    equ    0f300h
  51.     org    180h
  52. begin:    equ    $+offset
  53.     lda    offrom    ;turns off roms
  54.     lda    videx    ;turns on videx
  55.     call    putchar ;
  56.     ora    a    ;clear carry
  57.     lhld    basel
  58.     xchg
  59.     lhld    chorz    ;store chorz offoffset
  60.     mov    a,e
  61.     adc    l    ;add chorz
  62.     mvi    l,0fh    ;register f
  63.     mov    h,a
  64.     shld    reg
  65.     mov    a,d    ;cvertoffoffset
  66.     aci    00h    ;
  67.     dcr    l    ;0eh
  68.     mov    h,a
  69.     shld    reg    
  70.     lda    offrom     ;turn off rom
  71.     ret
  72. ;**************************
  73. putchar:    equ    $+offset
  74.     lda    escflag    ;are we ready to process an escape sequence 
  75.     ora    a
  76.     jnz    escxy
  77. notesc:    equ    $+offset
  78.     mov    a,c
  79.     cpi    ' '
  80.     jc    control    ;handle control if less than SPACE
  81.     lda    chorz
  82.     mov    b,a
  83.     call    chrput
  84.     jmp    done
  85. ;*********************************
  86. ;ring the bell
  87. bell:    equ    $+offset
  88.     mvi    b,0c0h
  89. bell1:    equ    $+offset
  90.     mvi    c,080h
  91. bell2:    equ    $+offset
  92.     dcr    c
  93.     jrnz    bell2-offset
  94.     lda    speaker
  95.     dcr    b
  96.     jrnz    bell1-offset
  97.     ret
  98. ebegin    equ    $+offset
  99. ;***************************************************
  100.     org    2b0h
  101. escxy:     equ    $+offset
  102.     lxi    h,escflag
  103.     inr    m
  104.     mov    a,m
  105.     cpi    02h
  106.     jrnz    xy-offset
  107. notxy:    equ    $+offset
  108.     mov    a,c
  109.     cpi    '='
  110.     rz
  111.     mvi    m,00h
  112.     cpi    'Y'
  113.     jz    cleareos
  114.     cpi    '*'
  115.     jz    formfeed
  116.     cpi    'T'
  117.     jz    cleareol
  118.     ret
  119. xy:    equ    $+offset
  120.     mov    a,c    ;move the character
  121.     sui    ' '
  122.     mov    c,a
  123.     mov    a,m
  124.     cpi    1h
  125.     rz
  126.     cpi    04h
  127.     jrz    bknext-offset
  128.     inx    h    ;points to tempx(now used for tempy)
  129.     mov    m,c
  130.     dcx    h
  131. bkhome:    equ    $+offset
  132.     ret
  133. ;***************************************************
  134. bknext:    equ    $+offset
  135. ;this is the second character after escape
  136.     inx    h    ;points to tempx
  137.     mov    b,m    ;
  138.     dcx    h    ;points to escflag
  139.     mvi    m,00h    ;offset escflag to zero
  140.     jmp    gotoxy
  141. eescxy    equ    $+offset
  142. ;****************************************************
  143.     org    330h
  144. tab:    equ    $+offset
  145.     lxi    h,chorz
  146.     mov    a,m
  147.     ani    0f8h
  148.     ora    a
  149.     adi    08h
  150.     cpi    050h    ;chorz number
  151.     jrc    backtab-offset
  152.     mvi    a,04fh    ;
  153. backtab:    equ    $+offset
  154.     mov    m,a
  155.     ret
  156. ;****************************************************
  157. control:    equ    $+offset
  158.     cpi    'G'-40h    ;ctrl-G=BEL
  159.     jz    bell
  160.     cpi    'I'-40h    ;ctrl-I=TAB
  161.     jz    tab
  162.     cpi    '['-40h    ;ctrl-[=ESC=software leadin
  163.     jz    escxy
  164.     cpi    'H'-40h    ;ctrl-H=BS
  165.     jz    bs
  166.     cpi    'M'-40h    ;ctrl-M=CR
  167.     jz    cr
  168.     cpi    '^'-40h    ;ctrl-^=RS=software home cursor
  169.     jz    homecursor
  170.     cpi    'L'-40h    ;ctrl-L=FF=software cursor forward
  171.     jz    done
  172.     cpi    'K'-40h    ;ctrl-K=VT=software cursor up
  173.     jz    cursorup
  174.     cpi    'J'-40h    ;ctrl-J=LF=software cursor down
  175.     jz    lf
  176.     ret
  177. etab    equ    $+offset
  178. ;************************************
  179.     org    380h
  180. formfeed:    equ    $+offset
  181.     call    homecursor
  182. cleareos:    equ    $+offset
  183.     call    cleareol
  184.     lxi    h,cvert
  185.     mov    a,m
  186.     push    a
  187. clloop:    equ    $+offset
  188.     lxi    h,cvert
  189.     inr    m
  190.     mov    a,m
  191.     cpi    018h    ;24 columns
  192.     jrnc    clback-offset
  193.     call    vtabz
  194.     call    etb
  195.     jmp    clloop
  196. clback:    equ    $+offset
  197.     pop    a
  198.     jmp    vtab
  199. ;****************************************
  200. etb:    equ    $+offset
  201.     mvi    b,0h
  202.     jr    etbloop-offset
  203. cleareol:    equ    $+offset
  204.     lda    chorz
  205.     mov    b,a
  206. etbloop:    equ    $+offset
  207.     mvi    c,' '
  208.     call    chrput
  209.     inr    b
  210.     mov    a,b
  211.     cpi    050h
  212.     jrc    etbloop-offset
  213.     ret
  214. ;**************************************************
  215. homecursor:    equ    $+offset
  216.     xra    a
  217.     mov    b,a
  218.     mov    c,a
  219. gotoxy:    equ    $+offset
  220. ;when entered from escxy b=cvert, c=chorz
  221.     mov    h,b
  222.     mov    l,c
  223.     shld    chorz
  224.     mov    a,b
  225. vtab:    equ    $+offset
  226.     sta    cvert
  227. vtabz:    equ    $+offset
  228.     lhld    chorz
  229.     mov    a,h
  230.     add    a
  231.     add    a    ;x4
  232.     add    h    ;x5
  233.     ora    a    ;clear carry
  234.     mov    h,a
  235.     lda    start
  236.     adc    h
  237. bascal1:    equ    $+offset
  238.     mov    l,a
  239.     rrc
  240.     rrc
  241.     rrc
  242.     rrc
  243.     ani    0fH    ;x80
  244.     mov    h,a
  245.     mov    a,l
  246.     rlc
  247.     rlc
  248.     rlc
  249.     rlc
  250.     ani    0f0H    ;x80
  251.     mov    l,a
  252.     shld    basel 
  253.     ret            
  254. ;*************************
  255. cr:    equ    $+offset
  256.     mvi    a,0h
  257.     sta    chorz
  258.     ret
  259. ;********************************************
  260. bs:    equ    $+offset
  261.     lxi    h,chorz
  262.     mov    a,m
  263.     sui    01h
  264.     jrnc    backbs-offset
  265.     mvi    m,4fh
  266.     jmp    cursorup
  267. backbs:    equ    $+offset
  268.     mov    m,a
  269.     ret
  270. eformfeed    equ    $+offset
  271. ;*******************************************
  272.     org    400h
  273. done:    equ    $+offset
  274.     lxi    h,chorz
  275.     inr    m
  276.     mov    a,m
  277.     cpi    050h    ;width
  278.     rc
  279.     call    cr
  280.     jmp    lf
  281.     ret
  282. ;***********************************
  283. cursorup:    equ    $+offset
  284.     lxi    h,cvert
  285.     dcr    m
  286.     jp    backcu
  287.     inr    m
  288. backcu:    equ    $+offset
  289.     jmp    vtabz
  290. ;**********************************
  291. lf:    equ    $+offset
  292.     lxi    h,cvert
  293.     inr    m
  294.     mov    a,m
  295.     cpi    018h    ;height
  296.     jrc    backlf-offset
  297.     dcr    m
  298.     jrnz    scroll-offset
  299. backlf:    equ    $+offset
  300.     jmp    vtabz
  301. scroll:    equ    $+offset
  302.     lda    cvert
  303.     sta    tempy
  304.     ora    a
  305.     lda    start
  306.     adi    05h
  307.     ani    07fh
  308.     sta    start
  309.     call    bascal1
  310.     lda    basel
  311.     mvi    l,0dh
  312.     mov    h,a
  313.     shld    reg
  314.     dcr    l
  315.     lda    baseh
  316.     mov    h,a
  317.     shld    reg
  318.     mvi    a,17h
  319.     call    vtab
  320.     call    etb
  321.     lda    tempy
  322.     jmp    vtab
  323. psncalc:    equ    $+offset
  324. ;************
  325. ; calculates position in page
  326. ;and offsets the videx card
  327. ;B contains the chorz
  328. ;returns the result in E and the carry flag
  329.     mov    a,b
  330.     ora    a    ;clear carry
  331.     lhld    basel
  332.     xchg
  333.     adc    e
  334.     mov    e,a
  335.     mvi    a,00h
  336.     adc    d
  337.     rrc        ;determine the carry flag
  338.     push    psw
  339.     ani    03h
  340.     rlc        ;x2
  341.     rlc        ;x4
  342.     lxi    h,reg
  343.     ora    l    ;a=a+l
  344.     mov    l,a
  345.     mov    a,m    ;toggle the correct page
  346.     pop    psw
  347.     ret
  348. edone    equ    $+offset
  349. ;******************************
  350. ;CHRPUT   B contains chorz, C contains the character
  351. ;
  352. ;destroys HLchrput:    equ    $+offset
  353.     org    480h
  354. chrput:    equ    $+offset
  355.     call    psncalc
  356.     jrnc    lowpage-offset
  357. hipage:    equ    $+offset
  358.     lxi    h,ram1
  359.     jr     writeit-offset
  360. lowpage:    equ    $+offset
  361.     lxi    h,ram0
  362. writeit:    equ    $+offset
  363.     mov    a,e
  364.     ora    l
  365.     mov    l,a
  366.     mov    a,c
  367.     ani    7fh
  368.     mov    m,a
  369.     ret
  370. ;********************************
  371. temp:    equ    $+offset
  372.     db    0
  373. chorz:    equ    $+offset
  374.     db    0
  375. cvert:    equ    $+offset
  376.     db    0
  377. basel:    equ    $+offset
  378.     db    0
  379. baseh:    equ    $+offset
  380.     db    0
  381. escflag:    equ    $+offset
  382.     db    0
  383. tempx:    equ    $+offset
  384.     db    0
  385. tempy:    equ    $+offset
  386.     db    0
  387. start:    equ    $+offset
  388.     db    0
  389. echrput    equ    $+offset
  390.     org    500h
  391. initseq:    equ    $
  392.     db    07bh,050h,062h,029h,01bh,8,018h,019h,0,8,0c0h
  393.     db    8,0,0,0,0
  394. initflag:    equ    $
  395.     db    0
  396. init:    equ    $
  397.     lda    initflag
  398.     ora    a
  399.     jrnz    backinit
  400.     lda    offrom    ;turn off card
  401.     lda    videx    ;and on again
  402.     lxi    b,1000h    ;16 registers to initialize
  403.     lxi    d,initseq
  404. loop2:    equ    $
  405.     xchg    ;h contains initialization
  406.     mov    a,m    ;in the accumulator
  407.     xchg        ;back agian
  408.     mov    h,a
  409.     mov    l,c
  410.     shld    reg
  411.     inr    c
  412.     dcr    b
  413.     inx    d
  414.     jrnz    loop2
  415.     mvi    a,0h
  416.     sta    escflag
  417.     sta    tempx
  418.     sta    start
  419.     call    formfeed
  420.     lda    offrom
  421.     lda    initflag
  422.     dcr    a
  423.     sta    initflag
  424. backinit:    equ    $
  425.     ret
  426. mover:
  427.     lxi    d,begin
  428.     lxi    h,begin-offset
  429.     lxi    b,ebegin-begin
  430.     ldir
  431.     lxi    d,escxy
  432.     lxi    h,escxy-offset
  433.     lxi    b,eescxy-escxy
  434.     ldir
  435.     lxi    d,tab
  436.     lxi    h,tab-offset
  437.     lxi    b,etab-tab
  438.     ldir
  439.     lxi    d,formfeed
  440.     lxi    h,formfeed-offset
  441.     lxi    b,eformfeed-formfeed
  442.     ldir
  443.     lxi    d,done
  444.     lxi    h,done-offset
  445.     lxi    b,edone-done
  446.     ldir
  447.     lxi    d,chrput
  448.     lxi    h,chrput-offset
  449.     lxi    b,echrput-chrput
  450.     ldir
  451.     call    init
  452.     lxi    h,0f480h
  453. ;ONE OF THE FOLLOWING EQUATES SHOULD BE TRUE
  454.     IF CPM56
  455.     shld    0da0dh
  456.     ENDIF
  457.     IF CPM60
  458.     shld    0fa0dh
  459.     ENDIF
  460.     jmp    0000    ;WARM BOOT
  461.     end
  462.  
  463.  
  464.  
  465.