home *** CD-ROM | disk | FTP | other *** search
/ Fujiology Archive / fujiology_archive_v1_0.iso / !FALCON / RG / RES_RIPR.ZIP / RES_RIPR / RIPPER.S < prev    next >
Encoding:
Text File  |  2005-04-30  |  60.9 KB  |  2,883 lines

  1. **************************
  2. **** RESERVOIR RIPPER ****
  3. **** Coded by Mr Pink ****
  4. * (C)1995 RESERVOIR GODS *
  5. **************************
  6.  
  7.  
  8. ; # = $2b (scan code)
  9.  
  10. DEBUG    equ    0
  11.  
  12. BSS_DEBUG    equ    1
  13. new_bss_ikbd    equ    0
  14.  
  15. vars_y    equ    90
  16. regs_y    equ    40
  17. vecs_y    equ    6*7
  18.  
  19. timer_a_ex    equ    0
  20. timer_b_ex    equ    1
  21. timer_c_ex    equ    2
  22. timer_d_ex    equ    3
  23. vbl_ex        equ    4
  24. vbl_q_ex    equ    5
  25. trap_1_ex    equ    6
  26. trap_2_ex    equ    7
  27. trap_13_ex    equ    8
  28. trap_14_ex    equ    9
  29. ikbd_ex        equ    10
  30. blitter_ex    equ    11
  31. line_a_ex    equ    12
  32. line_f_ex    equ    13
  33. hbl_ex        equ    14
  34. error_ex    equ    15
  35. rs232_ex    equ    16
  36. mono_ex        equ    17
  37. mmu_ex        equ    18
  38. trace_ex    equ    19
  39. alt_help_ex    equ    20
  40. fdi_ex        equ    21
  41. reset_ex    equ    22
  42.  
  43.  
  44.     IFNE    BSS_DEBUG
  45.     INCLUDE    "j:\asm\bssdebug\examples\devpac\macros.sh"
  46.     ENDC
  47.  
  48. start_ripper
  49.     move.l  a7,a5
  50.         move.l  4(a5),a5
  51.     lea    $80(a5),a0
  52.     move.l    a0,cmd_adr
  53.         move.l  12(a5),d0
  54.         add.l   20(a5),d0
  55.         add.l   28(a5),d0
  56.         add.l   #$100,d0
  57.         move.l  d0,-(sp)
  58.         move.l  a5,-(sp)
  59.         move    d0,-(sp)
  60.         move    #$4a,-(sp)
  61.         trap    #1
  62.         add.l   #12,sp
  63.  
  64.     clr.w    -(a7)
  65.     pea    $200000
  66.     trap    #1
  67.  
  68.     IFNE    BSS_DEBUG
  69.     SetBreak    <"end_timer_d">,BREAKSimple,0,<"">
  70.     SetWatch    <"pic_x">,WATCHWord
  71.     SetWatch    <"pic_y">,WATCHWord
  72.     SetWatch    <"pic_res">,WATCHWord
  73.     SetWatch    <"cur_pic_adr">,WATCHLong
  74.     SetWatch    <"line_length">,WATCHLong
  75.     ENDC
  76.  
  77.     move.w    #$59,-(a7)    ;get monitor
  78.     trap    #14
  79.     addq.l    #2,a7
  80.     cmp.w    #2,d0
  81.     bne.s    not_vga
  82.     st.b    vga_flag
  83. not_vga
  84.     IFEQ    DEBUG
  85.     bsr    save_system
  86.     ENDC
  87.  
  88.     move.l    #start_ripper,$30.w
  89.     move.l    #end_ripper,$432.w
  90.  
  91.     dc.w    $a00a
  92.  
  93.     lea    intro_txt(pc),a0
  94.     bsr    gemdos_print
  95.     bsr    wait_key
  96.  
  97.     bsr    do_first_menu
  98.     beq.s    do_tsr
  99. term
  100.  
  101.     clr.w    -(a7)
  102.     trap    #1
  103. do_tsr
  104.     clr.b    check_bit
  105.     bsr    do_installation
  106.     move.b    #1,check_bit
  107.  
  108.     IFNE    DEBUG
  109.     bra    init_ripper
  110.     ENDC
  111.  
  112.     bsr    get_drive_dir
  113.     move.l    cmd_adr,a2
  114.     move.b    (a2)+,d0
  115.     subq.w    #1,d0
  116.     bmi.s    no_command
  117.  
  118. .cpy    move.b    (a2)+,(a0)+
  119.     dbra    d0,.cpy
  120.  
  121.     pea    null(pc)
  122.     pea    null(pc)
  123.     pea    ddir
  124.     pea    $4b0000
  125.     trap    #1
  126.     lea    16(a7),a7
  127.  
  128. no_command
  129.     move.w    #0,-(a7)
  130.     move.l    #end_ripper-start_ripper+$100,-(a7)
  131.     move.w    #$31,-(a7)
  132.     trap    #1
  133.  
  134. null    dc.l    0
  135.  
  136. get_drive_dir
  137.     move.w  #$19,-(sp)      ; Get current drive 
  138.     trap    #1              
  139.         addq.l  #2,sp
  140.         move.w    d0,d1
  141.         add.b   #65,d0          ; alter from number to letter  
  142.         move.b  d0,ddir        ; store
  143.  
  144.     clr.b    ddir+2
  145.  
  146.     addq.w    #1,d1
  147.     move.w    d1,-(a7)
  148.     pea    ddir+2
  149.     move.w    #$47,-(a7)
  150.     trap    #1
  151.     addq.l    #8,a7
  152.  
  153.     lea    ddir,a0
  154. .notend    tst.b    (a0)+
  155.     bne.s    .notend
  156.     move.b    #'\',-1(a0)
  157.     clr.b    (a0)
  158.     rts
  159.  
  160.  
  161. do_first_menu:
  162.     bsr    save_screen_info
  163.     bsr    save_pal
  164.     bsr    wait_vbl
  165.     bsr    init_screen
  166.     bsr    init_ikbd
  167.     bsr    do_vector_install_menu
  168.     move.w    d0,-(a7)
  169.     bsr    restore_ikbd    
  170.     bsr    restore_screen_info
  171.     bsr    restore_pal
  172.     tst.w    (a7)+
  173.     rts
  174.  
  175.  
  176. gemdos_print:    pea    (a0)
  177.         move.w    #9,-(a7)
  178.         trap    #1
  179.         addq.w    #6,a7
  180.         rts
  181.  
  182. wait_key:    move.w    #$b,-(a7)    ;interogate keyboard
  183.         trap    #1
  184.         addq.l    #2,a7
  185.         tst    d0        ;is there junk in key buffer?
  186.         beq.s    cnecin        ;no, just wait for key
  187.         bsr.s    cnecin        ;clear key buffer
  188.         bra.s    wait_key    ;check buffer status
  189. cnecin:        move.w    #8,-(a7)    ;get key
  190.         trap    #1
  191.         addq.l    #2,a7        ;returned in D0
  192.         rts
  193.  
  194.  
  195. init_ripper:
  196.     move.l    a7,old_stack+2
  197.     lea    rip_stack,a7
  198.     move.w    sr,-(a7)
  199.     move.w    #$2700,sr
  200.     clr.b    begin_ripping_flag
  201.     clr.b    new_config
  202.     bsr    save_screen_info
  203.     lea    cur_system_vars,a0
  204.     bsr    save_cur_system
  205.     bsr    get_current_vecs
  206.     IFEQ    DEBUG
  207.     bsr    restore_system
  208.     ENDC
  209.     move.l    mfp_sei,d0
  210.     beq.s    .non_mfp
  211.     move.w    d0,a0
  212.     swap    d0
  213.     bclr.b    d0,(a0)
  214. .non_mfp
  215.     clr.b    $fffffa07.w        ;iera
  216.     clr.b    $fffffa13.w        ;imra
  217.     move.b    #%01000000,$fffffa09.w    ;ierb
  218.     move.b    #%01000000,$fffffa15.w    ;imrb
  219.     move.l    #temp_vbl,$70.w
  220.     move.w    #$2300,sr
  221.     bsr    save_pal
  222.     bsr    wait_vbl
  223.     bsr    init_screen
  224.     bsr    init_ikbd
  225.     bsr    get_pic_info
  226.     bsr    print_ripper_menu_txt    
  227.     cmp.b    #reset_ex,vec_family
  228.     beq    do_vec_menu
  229. do_ripper_menu:
  230.     tst.b    key_table+$3b
  231.     bne    show_screen
  232.     tst.b    key_table+$3c
  233.     bne    do_vec_menu
  234.     tst.b    key_table+$3d
  235.     bne    do_save_file
  236.     tst.b    key_table+$3e
  237.     bne    do_save_god_file
  238.     tst.b    key_table+$44
  239.     beq.s    do_ripper_menu
  240.     bsr    restore_ikbd
  241.     bsr    wait_vbl
  242.     bsr    restore_screen_info    
  243.     bsr    restore_pal
  244.     move.w    #$2700,sr
  245.     lea    cur_system_vars,a0
  246.     bsr    restore_cur_system
  247.     tst.b    new_config
  248.     beq.s    .no_new
  249.     clr.b    check_bit
  250.     bsr    do_installation
  251.     move.b    #1,check_bit
  252. .no_new
  253.     move.w    (a7)+,sr
  254. old_stack
  255.     lea    $12345678,a7
  256.     rts
  257.  
  258. print_ripper_menu_txt:
  259.  
  260.     lea    ripper_txt,a0
  261.     move.l    #320-16*3,d0
  262.     moveq    #0,d1
  263.     bsr    print_string
  264.  
  265.     lea    coder_txt,a0
  266.     move.l    #320-16*3,d0
  267.     moveq    #20,d1
  268.     bsr    print_string
  269.  
  270.     lea    rg_txt,a0
  271.     move.l    #320-23*3,d0
  272.     moveq    #30,d1
  273.     bsr    print_string
  274.  
  275.     lea    menu_txt,a0
  276.     moveq    #0,d0
  277.     moveq    #40,d1
  278.     bsr    print_string
  279.  
  280.     lea    entry_txt,a0
  281.     move.l    #320,d0
  282.     moveq    #40,d1
  283.     bsr    print_string
  284.  
  285.     moveq    #0,d0
  286.     move.b    vec_family,d0
  287.     move.l    (v_txt_adrs,d0.w*4),a0
  288.     move.l    #320+6*15,d0
  289.     moveq    #40,d1
  290.     bsr    print_string
  291.  
  292.     lea    variables_txt,a0
  293.     moveq    #0,d0
  294.     move.l    #vars_y,d1
  295.     bsr    print_string
  296.  
  297.     move.w    pic_res,d0
  298.     move.l    (res_txts,d0.w*4),a0
  299.     moveq    #6*6,d0
  300.     move.l    #vars_y,d1
  301.     bsr    print_string
  302.  
  303.  
  304.     lea    word_txts,a6
  305. .loop1    move.l    (a6)+,a0
  306.     cmpa.l    #0,a0
  307.     beq.    .el1
  308.     moveq    #0,d0
  309.     move.w    (a0),d0
  310.     bsr    conv_long_ascii
  311.     lea    long_string+6,a0
  312.     moveq    #0,d0
  313.     move.w    (a6)+,d0
  314.     move.w    (a6)+,d1
  315.     mulu    #6,d1
  316.     add.l    #vars_y,d1
  317.     pea    (a6)
  318.     bsr    print_string
  319.     move.l    (a7)+,a6
  320.     bra.s    .loop1    
  321.  
  322. .el1    lea    byte_txts,a6
  323. .loop2    move.l    (a6)+,a0
  324.     cmpa.l    #0,a0
  325.     beq.    .el2
  326.     moveq    #0,d0
  327.     move.b    (a0),d0
  328.     bsr    conv_long_ascii
  329.     lea    long_string+6,a0
  330.     moveq    #0,d0
  331.     move.w    (a6)+,d0
  332.     move.w    (a6)+,d1
  333.     mulu    #6,d1
  334.     add.l    #vars_y,d1
  335.     pea    (a6)
  336.     bsr    print_string
  337.     move.l    (a7)+,a6
  338.     bra.s    .loop2
  339.  
  340. .el2    lea    screen_vars+12,a6
  341.     moveq    #7,d7
  342.     moveq    #6*5,d6
  343. .loop3    moveq    #0,d0
  344.     move.w    (a6)+,d0
  345.     bsr    conv_long_ascii
  346.     lea    long_string+6,a0
  347.     move.l    d6,d0
  348.     move.l    #vars_y+6*2,d1
  349.     movem.l    d6-7/a6,-(a7)
  350.     bsr    print_string
  351.     movem.l    (a7)+,d6-7/a6
  352.     add.l    #6*10,d6
  353.     dbra    d7,.loop3
  354.  
  355.     moveq    #7,d7
  356.     moveq    #6*5,d6
  357. .loop4    moveq    #0,d0
  358.     move.w    (a6)+,d0
  359.     bsr    conv_long_ascii
  360.     lea    long_string+6,a0
  361.     move.l    d6,d0
  362.     move.l    #vars_y+6*3,d1
  363.     movem.l    d6-7/a6,-(a7)
  364.     bsr    print_string
  365.     movem.l    (a7)+,d6-7/a6
  366.     add.l    #6*10,d6
  367.     dbra    d7,.loop4
  368.  
  369.     rts
  370.  
  371.  
  372. show_screen
  373.     bsr    wait_vbl
  374.     bsr    restore_screen_info    
  375.     bsr    restore_pal
  376. .wt    tst.b    key_table+$3b
  377.     bne.s    .wt
  378. .wt2    tst.b    key_table+$3b
  379.     beq.s    .wt2
  380.  
  381.     bsr    wait_vbl
  382.     bsr    set_my_screen
  383.     bsr    set_resolution
  384.     bsr    set_my_pal
  385. .wt3    tst.b    key_table+$3b
  386.     bne.s    .wt3
  387.     bra    do_ripper_menu
  388.  
  389. get_current_vecs:
  390.     lea    new_adrs,a0
  391.     lea    install_bits,a1
  392. .loop    moveq    #0,d0
  393.     move.w    (a0)+,d0
  394.     bmi.s    .last
  395.     move.w    (a0)+,a2
  396.     move.l    (a2),d1
  397.     cmp.l    (a0)+,d1
  398.     beq.s    .ok
  399.     bclr    #0,(a1,d0.w)
  400.     bra.s    .loop
  401. .ok    bset    #0,(a1,d0.w)
  402.     bra.s    .loop
  403. .last
  404.     move.l    $456.w,a0
  405.     move.w    $454.w,d2
  406.     move.l    #new_vbl_lister,d0
  407. .find    move.l    (a0)+,d1
  408.     beq.s    .novbl
  409.     cmp.l    d0,d1
  410.     beq.s    .got
  411.     dbra    d2,.find
  412. .novbl    bclr    #0,vbl_q_ex(a1)
  413.     rts
  414. .got    bset    #0,vbl_q_ex(a1)
  415.     rts
  416.  
  417.  
  418. do_vec_menu:
  419.     bsr    clear_my_screen
  420.  
  421.     bsr    do_vector_install_menu
  422.     bne.s    .no_new
  423.     st.b    new_config
  424. .no_new
  425.     bsr    clear_my_screen
  426.     bsr    print_ripper_menu_txt
  427.     bra    do_ripper_menu
  428.  
  429. do_save_god_file
  430.     st.b    god_mode
  431.     bra.s    dosavefile
  432. do_save_file
  433.     clr.b    god_mode
  434. dosavefile
  435.     lea    enter_file_txt,a0
  436.     moveq    #0,d0
  437.     move.l    #160,d1
  438.     bsr    print_string
  439.     
  440. .wt1    tst.b    key_table+$3c
  441.     bne.s    .wt1
  442.  
  443.     bsr    enter_file_name
  444.     bmi    .err
  445.     IFEQ    DEBUG
  446.     bsr    restore_system
  447.     ELSE
  448.     bsr    restore_ikbd
  449.     ENDC
  450.     IFNE    new_bss_ikbd
  451.     bsr    init_ikbd
  452.     move.l    $84.w,old_bss_trap_1+2
  453.     move.l    #bss_trap_1,$84.w
  454.     move.l    $b4.w,old_bss_trap_13+2
  455.     move.l    #bss_trap_13,$b4.w
  456.     ENDC
  457.     bsr    save_file
  458. .err    bsr    clear_my_screen
  459.     bsr    print_ripper_menu_txt
  460.     bsr    init_ikbd
  461.     bra    do_ripper_menu
  462.  
  463.  
  464. get_pic_info:
  465.     move.l    #'GRIP',magic
  466.     lea    screen_vars(pc),a0
  467.     bfextu    (a0){0:24},d0
  468.     move.l    d0,pic_adr
  469.     move.l    d0,cur_pic_adr
  470.  
  471.     moveq    #0,d0
  472.     move.w    6(a0),d0        ;line length (words)
  473.     add.l    d0,d0            ;length in bytes
  474.     move.l    d0,line_length        ;save
  475.  
  476.     bsr    get_pic_res
  477.  
  478.     move.w    36(a0),d0        ;82AA - VDE
  479.     sub.w    34(a0),d0        ;82A8 - VDB
  480.     move.w    42(a0),d1        ;82C0 - VCO
  481.  
  482. ;    tst.b    vga_flag
  483. ;    bne.s    .int
  484.     btst    #1,d1            ;interlace mode
  485.     bne.s    .nint            ;yes
  486.     lsr.w    d0
  487. .nint
  488. ;    btst    #3,d1            ;quarter pixel mode
  489. ;    beq.s    .noq
  490. ;    lsr.w    d0
  491. ;.noq    btst    #2,d1            ;halve pixel mode?
  492. ;    beq.s    .noh
  493. ;    lsr.w    d0
  494. .noh    btst    #0,d1            ;line doubling?
  495.     beq.s    .nol
  496.     lsr.w    d0    
  497. .nol    
  498.     
  499. ;    tst.w    d1            ;interlace/double line off?
  500. ;    beq.s    .halve            ;yes, half size
  501. ;    btst    #0,d1            ;line doubling?
  502. ;    beq.s    .norm            ;no
  503. ;    lsr.w    d0            ;y size/2
  504. ;.halve    lsr.w    d0            ;y size/2
  505. .norm    move.w    d0,pic_y        ;store y size
  506.     mulu    6(a0),d0        ;line_width*y lines
  507.     add.l    d0,d0            ;*2 file length in bytes
  508.     move.l    d0,pic_length
  509.  
  510.  
  511. get_pic_res:
  512.     move.b    8(a0),d0            ;8260
  513.     move.w    10(a0),d1            ;8266
  514.     btst    #10,d1
  515.     bne    .two_colour
  516.     btst    #8,d1
  517.     bne    .true_colour
  518.     btst    #4,d1
  519.     bne    .eight_colour
  520.     tst.b    d0
  521.     beq    .sixteen_colour
  522.     cmp.b    #1,d0
  523.     beq    .four_colour
  524. .two_colour    
  525.     clr.w    pic_res
  526.     move.w    6(a0),d0        ;8210 - line width (words)
  527.     lsl.w    #4,d0            ;*16
  528.     move.w    d0,pic_x        ;x pixels
  529.     rts
  530. .four_colour
  531.     moveq    #62,d0
  532.     tst.b    vga_flag
  533.     beq.s    .nvga
  534.     moveq    #23,d0
  535. .nvga    cmp.w    12(a0),d0
  536.     bne    .sixteen_colour
  537.     move.w    #1,pic_res
  538.     move.w    6(a0),d0        ;8210 - line width (words)
  539.     lsl.w    #3,d0            ;*16
  540.     move.w    d0,pic_x        ;x pixels
  541.     rts
  542. .sixteen_colour
  543.     move.w    #2,pic_res
  544.     move.w    6(a0),d0        ;8210 - line width (words)
  545.     lsl.w    #2,d0            ;*4
  546.     move.w    d0,pic_x        ;x pixels
  547.     rts
  548. .eight_colour
  549.     move.w    #3,pic_res
  550.     move.w    6(a0),d0        ;8210 - line width (words)
  551.     add.w    d0,d0            ;*2
  552.     move.w    d0,pic_x        ;x pixels
  553.     rts
  554. .true_colour
  555.     move.w    #4,pic_res
  556.     move.w    6(a0),pic_x
  557. .cont    rts
  558.  
  559.  
  560. enter_file_name
  561.     clr.w    text_counter
  562.  
  563. .loop    clr.b    key_pressed
  564. .wk    tst.b    key_pressed
  565.     beq.s    .wk
  566.     move.b    current_key,d1
  567.     cmp.b    #$1c,d1
  568.     beq    .end_entry
  569.     cmp.b    #1,d1
  570.     beq    .quit_entry
  571.     cmp.b    #$e,d1
  572.     bne.s    .nback
  573.  
  574.     subq.w    #1,text_counter
  575.     bpl.s    .pls
  576.     clr.w    text_counter
  577. .pls    lea    single_string,a0
  578.     move.b    #' ',(a0)
  579.     move.w    text_counter,d0
  580.     mulu    #6,d0
  581.     move.l    #170,d1
  582.     bsr    print_string
  583.  
  584.     lea    file_name,a0
  585.     move.w    text_counter,d0
  586.     clr.b    (a0,d0.w)
  587.     bra    .loop
  588.  
  589. .nback    lea    single_string,a0
  590.     move.b    (scan_code_table,d1.w),d1
  591.     move.b    d1,(a0)
  592.     move.w    text_counter,d0
  593.     lea    file_name,a1
  594.     move.b    d1,(a1,d0.w)
  595.     mulu    #6,d0
  596.     move.l    #170,d1
  597.     bsr    print_string
  598.  
  599.     cmp.w    #640/6-1,text_counter
  600.     bge.s    .ge
  601.     addq.w    #1,text_counter
  602. .ge
  603.  
  604.     bra    .loop
  605.  
  606. .quit_entry
  607.     moveq    #-1,d0
  608.     rts
  609.  
  610. .end_entry
  611.     move.w    text_counter,d0
  612.     clr.b    (file_name+1,d0.w)
  613.     moveq    #0,d0
  614.     rts
  615.  
  616.  
  617. wait_vbl:
  618.     move.l    d0,-(a7)
  619.     move.l    $466.w,d0
  620. .wt    cmp.l    $466.w,d0
  621.     beq.s    .wt
  622.     move.l    (a7)+,d0
  623.     rts
  624.  
  625.  
  626.  
  627.  
  628. ************************
  629. * VECTOR SAVE ROUTINES *
  630. *************************
  631.  
  632. save_system:
  633.     lea    old_system_vars(pc),a0    
  634. save_cur_system
  635.     move.w    sr,-(a7)
  636.     move.w    #$2700,sr
  637.     movec    cacr,d0
  638.     move.w    d0,(a0)+
  639.     move.l    $68.w,(a0)+            ; hbl
  640.     move.l    $70.w,(a0)+            ; vbl
  641.     move.l    $84.w,(a0)+            ; trap #1
  642.     move.l    $b4.w,(a0)+            ; trap #13
  643.     move.l    $b8.w,(a0)+            ; trap #14
  644.     move.l    $110.w,(a0)+            ; Timer D
  645.     move.l    $114.w,(a0)+            ; Timer C
  646.     move.l    $118.w,(a0)+            ; ikbd
  647.     move.l    $120.w,(a0)+            ; Timer B
  648.     move.l    $134.w,(a0)+            ; Timer A
  649.     move.l    $13c.w,(a0)+            ; mono detect
  650.     move.l    $456.w,(a0)+            ; vbl list ptr
  651.     move.l    $466.w,(a0)+            ; current vbl clock
  652.     move.l    $502.w,(a0)+            ; alt-help vector
  653.  
  654.     move.w    $ffff8900.w,(a0)+                ; Interruptions, Son DMA
  655.     move.b    $ffff8903.w,(a0)+                ; Start - High
  656.     move.b    $ffff8905.w,(a0)+                ; Start - Med
  657.     move.b    $ffff8907.w,(a0)+                ; Start - Low
  658.     move.b    $ffff890f.w,(a0)+                ; End - High
  659.     move.b    $ffff8911.w,(a0)+                ; End - Med
  660.     move.b    $ffff8913.w,(a0)+                ; End - Low
  661.     move.w    $ffff8920.w,(a0)+                ; Nb Voies, 8/16, Mono/Stereo
  662.     move.w    $ffff8930.w,(a0)+                ; Matrice : Sources
  663.     move.w    $ffff8932.w,(a0)+                ; Matrice : Destinations
  664.     move.w    $ffff8934.w,(a0)+                ; Prescales d'horloge
  665.     move.w    $ffff8936.w,(a0)+                ; Nb Voies Record,source ADDERIN
  666.     move.w    $ffff8938.w,(a0)+                ; Source ADC + Volumes entrées
  667.     move.w    $ffff893a.w,(a0)+                ; Volumes de Sortie
  668.  
  669.  
  670.     move.b    $fffffa07.w,(a0)+        ; iera
  671.     move.b    $fffffa09.w,(a0)+        ; ierb
  672.     move.b    $fffffa13.w,(a0)+        ; imra
  673.     move.b    $fffffa15.w,(a0)+        ; imrb
  674.     move.b    $fffffa17.w,(a0)+        ; vectore register
  675.     move.b    $fffffa19.w,(a0)+        ; Timer A control
  676.     move.b    $fffffa1b.w,(a0)+        ; Timer B control
  677.     move.b    $fffffa1d.w,(a0)+        ; Timer C & D control
  678.     move.b    $fffffa1f.w,(a0)+        ; Timer A data
  679.     move.b    $fffffa21.w,(a0)+        ; Timer B data
  680.     move.b    $fffffa23.w,(a0)+        ; Timer C data
  681.     move.b    $fffffa25.w,(a0)+        ; Timer D data
  682.     move.b    $ffff8007.w,(a0)+        ; 68030 Configuration 
  683.     move.w    (a7)+,sr
  684.     rts
  685.  
  686. save_screen_info:
  687.     lea    screen_vars(pc),a0    ; Espace de sauvegarde
  688.     move.b    $ffff8201.w,(a0)+    ;0 Vidéo (poids fort)
  689.     move.b    $ffff8203.w,(a0)+    ;1 Vidéo (poids moyen)
  690.     move.b    $ffff820d.w,(a0)+    ;2 Vidéo (poids faible)
  691.     move.b    $ffff820a.w,(a0)+    ;3 Synchronisation vidéo
  692.     move.w    $ffff820e.w,(a0)+    ;4 Offset pour prochaine ligne
  693.     move.w    $ffff8210.w,(a0)+    ;6 Largeur d'une ligne en mots
  694.     move.b    $ffff8260.w,(a0)+    ;8 Résolution ST
  695.     move.b    $ffff8265.w,(a0)+    ;9 Décalage Pixel
  696.     move.w    $ffff8266.w,(a0)+    ;10 Résolution FALCON
  697.     move.w    $ffff8282.w,(a0)+    ;12 HHT-Synchro
  698.     move.w    $ffff8284.w,(a0)+    ;14 Fin du décodage de la ligne
  699.     move.w    $ffff8286.w,(a0)+    ;16 Début du décodage de la ligne
  700.     move.w    $ffff8288.w,(a0)+    ;18 Overscan gauche
  701.     move.w    $ffff828a.w,(a0)+    ;20 Overscan droit
  702.     move.w    $ffff828c.w,(a0)+    ;22 HSS-Synchro
  703.     move.w    $ffff828e.w,(a0)+    ;24 HFS
  704.     move.w    $ffff8290.w,(a0)+    ;26 HEE
  705.     move.w    $ffff82a2.w,(a0)+    ;28 VFT-Synchro
  706.     move.w    $ffff82a4.w,(a0)+    ;30 Fin du décodage de l'image
  707.     move.w    $ffff82a6.w,(a0)+    ;32 Début du décodage de l'image
  708.     move.w    $ffff82a8.w,(a0)+    ;34 VDB
  709.     move.w    $ffff82aa.w,(a0)+    ;36 VDE
  710.     move.w    $ffff82ac.w,(a0)+    ;38 VSS-Synchro
  711.     move.w    $ffff82c0.w,(a0)+    ;40 Reconnaissance ST/FALCON
  712.     move.w    $ffff82c2.w,(a0)    ;42 VCO
  713.  
  714. ;    move.w    #-1,-(a7)
  715. ;    move.w    #$58,-(a7)    
  716. ;    trap    #14
  717. ;    addq.l    #4,a7
  718. ;    move.w    d0,old_vmode
  719.     rts
  720.  
  721. save_pal:
  722.     bsr    wait_vbl
  723.     lea    pal_space,a0
  724.     lea    $ffff8240.w,a1
  725.     moveq    #15,d0
  726. .save_st_pal
  727.     move.w    (a1)+,(a0)+
  728.     dbra    d0,.save_st_pal
  729.  
  730.     lea    $ffff9800.w,a1
  731.     move.w    #255,d0
  732. .save_falc_pal
  733.     move.l    (a1)+,(a0)+
  734.     dbra    d0,.save_falc_pal
  735.  
  736.  
  737.     rts
  738.  
  739. ***************************
  740. * SCREEN SETTING ROUTINES *
  741. ***************************
  742.  
  743. set_resolution
  744.     lea    videl_640_200_2(pc),a0
  745.  
  746.     move.b    #2,$ffff820a.w            ; Internal sync
  747.     clr.b    $ffff8265.w            ; Horizontal scroll reg=0
  748.     addq.l    #4,a0                ; skip screen_length
  749.     move.w    (a0)+,$ffff820e.w        ; line width
  750.     move.w    (a0)+,$ffff8210.w        ; Falcon line width
  751.     move.w    (a0)+,d0            ; Resolution ST
  752.     move.w    (a0)+,d1            ; Resolution FALCON
  753.  
  754.     move.w    d1,$ffff8266.w            ; Resolution FALCON
  755.     tst.w    (a0)+                ; falcon screen mode?
  756.     beq.s    FalconRez            ; yes
  757.     move.b    d0,$ffff8260.w            ; Resolution ST
  758.     move.w    -8(a0),$ffff8210.w        ; Fa;cpm line width
  759. FalconRez
  760.     btst.b    #7,$ffff8006.w            ; VGA monitor ?
  761.     Beq.s    R_Ok                ; no, rgb
  762.     adda.w    #16*2,a0            ; get to VGA data
  763. R_Ok
  764.     move.w    (a0)+,$ffff8282.w        ; HHT - Hold counter
  765.     move.w    (a0)+,$ffff8284.w        ; HBB - Border Begin
  766.     move.w    (a0)+,$ffff8286.w        ; HBE - Border end
  767.     move.w    (a0)+,$ffff8288.w        ; HDB - Display Begin
  768.     move.w    (a0)+,$ffff828a.w        ; HDE - Display End
  769.     move.w    (a0)+,$ffff828c.w        ; HSS - Synchro
  770.     move.w    (a0)+,$ffff828e.w        ; HFS
  771.     move.w    (a0)+,$ffff8290.w        ; HEE
  772.     move.w    (a0)+,$ffff82a2.w        ; VFT - Synchro
  773.     move.w    (a0)+,$ffff82a4.w        ; VBB - Border Begin
  774.     move.w    (a0)+,$ffff82a6.w        ; VBE - Border End
  775.     move.w    (a0)+,$ffff82a8.w        ; VDB - Display Begin
  776.     move.w    (a0)+,$ffff82aa.w        ; VDE - Display End
  777.     move.w    (a0)+,$ffff82ac.w        ; VSS-Synchro
  778.     move.w    (a0)+,$ffff82c0.w        ; FALCON resoultion indicator
  779.     move.w    (a0),$ffff82c2.w        ; resolution info
  780.  
  781.     rts
  782.  
  783.  
  784. init_screen:
  785.     lea    screen_space(pc),a0
  786.     move.l    a0,d0
  787.     clr.b    d0
  788.     lea    physic(pc),a1
  789.     move.l    d0,(a1)
  790.     bsr    wait_vbl
  791.     bsr    set_my_screen
  792.     bsr    set_resolution
  793.     bsr    clear_my_screen
  794.     bsr    set_my_pal
  795.     rts
  796.  
  797. set_my_screen:
  798.     lea    physic(pc),a1
  799.     movea.w    #$8201,a0    ;$fffff8201=screen address
  800.     move.b    1(a1),(a0)
  801.     move.b    2(a1),2(a0)    ;$fffff8203
  802.     move.b    3(a1),$C(a0)    ;$fffff820d
  803.     rts
  804.  
  805.     
  806. clear_my_screen
  807.     move.l    physic(pc),a1
  808.     move.l    #(640*200/8)/4-1,d0
  809. .cl    clr.l    (a1)+
  810.     dbra    d0,.cl
  811.     rts
  812.  
  813. set_my_pal:
  814.     lea    $ffff9800.w,a0
  815.     lea    $ffff8240.w,a1
  816.     moveq    #0,d0
  817.     move.l    d0,(a0)+
  818.     move.w    d0,(a1)+
  819.     moveq    #-1,d0
  820.     move.l    d0,(a0)+
  821.     move.w    d0,(a1)+
  822.     rts
  823.  
  824. ***************************
  825. * VECTOR RESTORE ROUTINES *
  826. ***************************
  827.  
  828. restore_system:
  829.     lea    old_system_vars(pc),a0    
  830. restore_cur_system:
  831.     move.w    sr,-(a7)
  832.     move.w    #$2700,sr
  833.     move.w    (a0)+,d0
  834.     movec    d0,cacr
  835.     move.l    (a0)+,$68.w            ; hbl
  836.     move.l    (a0)+,$70.w            ; vbl
  837.     move.l    (a0)+,$84.w            ; trap #1
  838.     move.l    (a0)+,$b4.w            ; trap #13
  839.     move.l    (a0)+,$b8.w            ; trap #14
  840.     move.l    (a0)+,$110.w            ; Timer D
  841.     move.l    (a0)+,$114.w            ; Timer C
  842.     move.l    (a0)+,$118.w            ; ikbd
  843.     move.l    (a0)+,$120.w            ; Timer B
  844.     move.l    (a0)+,$134.w            ; Timer A
  845.     move.l    (a0)+,$13c.w            ; mono detect
  846.     move.l    (a0)+,$456.w            ; vbl list ptr
  847.     move.l    (a0)+,$466.w            ; current vbl clock
  848.     move.l    (a0)+,$502.w            ; alt-help vector
  849.  
  850.     move.w    (a0)+,$ffff8900.w                ; Interruptions, Son DMA
  851.     move.b    (a0)+,$ffff8903.w                ; Start - High
  852.     move.b    (a0)+,$ffff8905.w                ; Start - Med
  853.     move.b    (a0)+,$ffff8907.w                ; Start - Low
  854.     move.b    (a0)+,$ffff890f.w                ; End - High
  855.     move.b    (a0)+,$ffff8911.w                ; End - Med
  856.     move.b    (a0)+,$ffff8913.w                ; End - Low
  857.     move.w    (a0)+,$ffff8920.w                ; Nb Voies, 8/16, Mono/Stereo
  858.     move.w    (a0)+,$ffff8930.w                ; Matrice : Sources
  859.     move.w    (a0)+,$ffff8932.w                ; Matrice : Destinations
  860.     move.w    (a0)+,$ffff8934.w                ; Prescales d'horloge
  861.     move.w    (a0)+,$ffff8936.w                ; Nb Voies Record,source ADDERIN
  862.     move.w    (a0)+,$ffff8938.w                ; Source ADC + Volumes entrées
  863.     move.w    (a0)+,$ffff893a.w                ; Volumes de Sortie
  864.  
  865.  
  866.     move.b    (a0)+,$fffffa07.w        ; iera
  867.     move.b    (a0)+,$fffffa09.w        ; ierb
  868.     move.b    (a0)+,$fffffa13.w        ; imra
  869.     move.b    (a0)+,$fffffa15.w        ; imrb
  870.     move.b    (a0)+,$fffffa17.w        ; vectore register
  871.     move.b    (a0)+,$fffffa19.w        ; Timer A control
  872.     move.b    (a0)+,$fffffa1b.w        ; Timer B control
  873.     move.b    (a0)+,$fffffa1d.w        ; Timer C & D control
  874.     move.b    (a0)+,$fffffa1f.w        ; Timer A data
  875.     move.b    (a0)+,$fffffa21.w        ; Timer B data
  876.     move.b    (a0)+,$fffffa23.w        ; Timer C data
  877.     move.b    (a0)+,$fffffa25.w        ; Timer D data
  878.     move.b    (a0)+,$ffff8007.w        ; 68030 Configuration 
  879.     move.w    (a7)+,sr
  880.     rts
  881.  
  882.  
  883.  
  884. restore_screen_info:
  885. ;    move.w    sr,-(a7)
  886. ;    ori.w    #$0700,sr
  887. ;    move.w    old_vmode,-(a7)
  888. ;    move.w    #$58,-(a7)
  889. ;    trap    #14
  890. ;    addq.l    #4,a7
  891.  
  892.     lea    screen_vars(pc),a0
  893.     move.b    (a0)+,$ffff8201.w        ; Vidéo (poids fort)
  894.     move.b    (a0)+,$ffff8203.w        ; Vidéo (poids moyen)
  895.     move.b    (a0)+,$ffff820d.w        ; Vidéo (poids faible)
  896.     move.b    (a0)+,$ffff820a.w        ; Synchronisation vidéo
  897.     move.w    (a0)+,$ffff820e.w        ; Offset pour prochaine ligne
  898.     move.w    (a0)+,$ffff8210.w        ; Largeur d'une ligne en mots
  899.     move.b    (a0)+,d0            ; Résolution ST
  900.     move.b    (a0)+,$ffff8265.w        ; Décalage Pixel
  901.     move.w    (a0)+,d1            ; Résolution FALCON
  902.     move.w    (a0)+,$ffff8282.w        ; HHT-Synchro
  903.     move.w    (a0)+,$ffff8284.w        ; Fin du décodage de la ligne
  904.     move.w    (a0)+,$ffff8286.w        ; Début du décodage de la ligne
  905.     move.w    (a0)+,$ffff8288.w        ; Overscan gauche
  906.     move.w    (a0)+,$ffff828a.w        ; Overscan droit
  907.     move.w    (a0)+,$ffff828c.w        ; HSS-Synchro
  908.     move.w    (a0)+,$ffff828e.w        ; HFS
  909.     move.w    (a0)+,$ffff8290.w        ; HEE
  910.     move.w    (a0)+,$ffff82a2.w        ; VFT-Synchro
  911.     move.w    (a0)+,$ffff82a4.w        ; Fin du décodage de l'image
  912.     move.w    (a0)+,$ffff82a6.w        ; Début du décodage de l'image
  913.     move.w    (a0)+,$ffff82a8.w        ; Overscan haut
  914.     move.w    (a0)+,$ffff82aa.w        ; Overscan bas
  915.     move.w    (a0)+,$ffff82ac.w        ; VSS-Synchro
  916.     move.w    (a0)+,$ffff82c0.w        ; Reconnaissance ST/FALCON
  917.     move.w    (a0),$ffff82c2.w        ; Informations résolution
  918.     move.w    d1,$ffff8266.w            ; Fixe résolution FALCON...
  919.     btst.b    #0,$ffff82c0.w            ; Résolution FALCON ?
  920.     bne.s    .Falcon_Rez            ; Si oui,saut !
  921.     move.b    d0,$ffff8260.w            ; Fixe résolution ST...
  922. .Falcon_Rez
  923. ;    move.w    (a7)+,sr
  924.     rts
  925.  
  926. restore_pal
  927.     bsr    wait_vbl
  928.     lea    pal_space,a0
  929.     lea    $ffff8240.w,a1
  930.     moveq    #15,d0
  931. .save_st_pal
  932.     move.w    (a0)+,(a1)+
  933.     dbra    d0,.save_st_pal
  934.  
  935.     lea    $ffff9800.w,a1
  936.     move.w    #255,d0
  937. .save_falc_pal
  938.     move.l    (a0)+,(a1)+
  939.     dbra    d0,.save_falc_pal
  940.  
  941.     rts
  942.  
  943.  
  944. ****************************
  945. * VECTOR INSTALLATION MENU *
  946. ****************************
  947.  
  948. do_vector_install_menu
  949.     lea    vector_menu_txt,a0
  950.     moveq    #0,d0
  951.     moveq    #0,d1
  952.     bsr    print_string
  953.     bsr    display_all_vecs
  954.     clr.b    key_pressed
  955. .loop    tst.b    key_table+$39
  956.     bne    .end
  957.     tst.b    key_table+1
  958.     bne    .quit
  959.     bsr    get_my_key
  960.     cmp.w    #$2b,d0
  961.     bne.s    .non_hash
  962.     bsr    vector_toggle
  963.     bsr    display_all_vecs
  964.     bra.s    .loop
  965. .non_hash
  966.     bsr    convert_my_key
  967.     tst.w    d1
  968.     bmi.s    .loop
  969.  
  970.     moveq    #2,d0
  971.     tst.b    key_table+$38
  972.     bne.s    .setbit
  973.     moveq    #1,d0
  974.     tst.b    key_table+$2a
  975.     bne.s    .setbit
  976.     tst.b    key_table+$36
  977.     bne.s    .setbit    
  978.     moveq    #0,d0
  979. .setbit
  980.     lea    space_txt,a0
  981.     bchg    d0,(install_bits,d1.w)
  982.     bne.s    .space
  983.     lea    star_txt,a0
  984. .space    move.l    (vecs_x,d0.w*4),d0
  985.     mulu    #6,d1
  986.     add.l    #vecs_y,d1
  987.     bsr    print_string
  988.     bra    .loop
  989. .quit    moveq    #-1,d0
  990.     rts
  991. .end    moveq    #0,d0
  992.     rts    
  993.  
  994. display_all_vecs:
  995.     moveq    #22,d7            ;vecs to check
  996.     moveq    #vecs_y,d1    
  997.  
  998.     lea    install_bits,a6
  999. .ly    moveq    #2,d6
  1000. .lx    move.l    (vecs_x,d6.w*4),d0
  1001.     lea    space_txt,a0
  1002.     btst.b    d6,(a6)
  1003.     beq.s    .space
  1004.     lea    star_txt,a0
  1005. .space    movem.l    d0-a6,-(a7)
  1006.     bsr    print_string
  1007.     movem.l    (a7)+,d0-a6
  1008.     dbra    d6,.lx
  1009.     addq.w    #1,a6
  1010.     addq.l    #6,d1
  1011.     dbra    d7,.ly
  1012.  
  1013.     rts
  1014.  
  1015. vector_toggle
  1016.     moveq    #2,d0
  1017.     tst.b    key_table+$38
  1018.     bne.s    .setbit
  1019.     moveq    #1,d0
  1020.     tst.b    key_table+$2a
  1021.     bne.s    .setbit
  1022.     tst.b    key_table+$36
  1023.     bne.s    .setbit    
  1024.     moveq    #0,d0
  1025. .setbit    lea    install_bits,a0
  1026.     moveq    #22,d1
  1027.     bchg    d0,v_toggle_mode
  1028.     bne.s    .all_off
  1029. .on    bset.b    d0,(a0)+
  1030.     dbra    d1,.on
  1031.     rts    
  1032. .all_off
  1033.     bclr.b    d0,(a0)+
  1034.     dbra    d1,.all_off
  1035.     rts
  1036.  
  1037. get_my_key:
  1038.     tst.b    key_pressed
  1039.     beq.s    get_my_key
  1040.     moveq    #0,d0
  1041.     move.b    current_key,d0
  1042.     clr.b    key_pressed
  1043.     rts
  1044.  
  1045. convert_my_key
  1046.     move.w    d0,d1
  1047.     sub.w    #$3b,d1
  1048.     bmi.s    .chk2
  1049.     cmp.b    #10,d1
  1050.     bge.s    .chk2
  1051.     rts    
  1052. .chk2    move.w    d0,d1
  1053.     subq.w    #$2,d1
  1054.     bmi.s    .chk3
  1055.     cmp.w    #14,d1
  1056.     bge.s    .chk3
  1057.     add.w    #10,d1    
  1058.     rts
  1059. .chk3    move.w    d0,d1
  1060.     sub.w    #16,d1
  1061.     bmi.s    .chk4
  1062.     cmp.w    #3,d1
  1063.     bge.s    .chk4
  1064.     add.w    #20,d1
  1065.     rts
  1066. .chk4    moveq    #-1,d1
  1067.     rts
  1068.  
  1069. ********************************
  1070. * VECTOR INSTALLATION ROUTINES *
  1071. ********************************
  1072.  
  1073. do_installation:
  1074.     move.w    sr,-(a7)
  1075.     ori.w    #$0700,sr
  1076.     bsr    install_normals
  1077.     bsr    install_customs
  1078.     move.w    (a7)+,sr
  1079.     rts
  1080.  
  1081. install_normals:
  1082.     lea    reinstall_adrs,a0
  1083.     lea    install_bits,a1
  1084. .loop    move.w    (a0)+,d0        ;get vec family num
  1085.     bmi    .end            ;if minus last
  1086.     move.b    check_bit,d1
  1087.     btst    d1,(a1,d0.w)        ;install/reinstall bit?
  1088.     beq    .next            ;not set
  1089.  
  1090.     move.l    ([a0]),d0        ;get vector ptr
  1091.     beq.s    .install        ;if 0, reinstall
  1092.     btst    #0,d0            ;odd address?
  1093.     bne.s    .install        ;yes
  1094.     cmp.l    4(a0),d0        ;my int installed?
  1095.     beq.s    .next            ;yes
  1096.     move.l    d0,([a0,8])        ;old ptr is jump
  1097.     move.l    4(a0),([a0])        ;install my vecor
  1098.     add.l    #12,a0            ;next ad
  1099.     bra.s    .loop            ;loop
  1100. .install
  1101.     move.l    #end_int,([a0,8])    ;point to rte
  1102.     move.l    4(a0),([a0])        ;install my vector
  1103. .next    add.l    #12,a0
  1104.     bra.s    .loop
  1105. .end    rts
  1106.  
  1107. install_customs:
  1108.     lea    custom_adrs,a0
  1109.     lea    install_bits,a1    
  1110. .loop    move.w    (a0)+,d0
  1111.     bmi    .last
  1112.     move.b    check_bit,d1
  1113.     btst    d1,(a1,d0.w)
  1114.     beq    .next
  1115.     pea    (a0)
  1116.     jsr    ([a0])
  1117.     move.l    (a7)+,a0
  1118. .next    addq.l    #4,a0
  1119.     bra.s    .loop
  1120. .last    rts    
  1121.  
  1122. reinstall_all:
  1123.  
  1124.  
  1125. install_rs232:
  1126.     lea    rs232_adrs,a0
  1127.     bsr    multi_install
  1128.     or.b    #%01011110,$fffffa07.w
  1129.     or.b    #%01011110,$fffffa13.w
  1130.     or.b    #%111,$fffffa09.w
  1131.     or.b    #%111,$fffffa15.w
  1132.     rts
  1133.  
  1134. install_errors:
  1135.     lea    error_adrs,a0
  1136.     bra.s    multi_install
  1137.  
  1138. install_mmu:
  1139.     lea    mmu_adrs,a0
  1140. multi_install:
  1141.  
  1142. .loop    move.l    (a0),a1            ;get vector address
  1143.     cmpa.w    #-1,a1            ;last?
  1144.     beq    .last
  1145.     move.l    (a1),d0            ;get vector ptr
  1146.     beq.s    .install        ;if 0, reinstall
  1147.     btst    #0,d0            ;odd address?
  1148.     bne.s    .install        ;yes
  1149.     cmp.l    4(a0),d0
  1150.     beq.s    .next
  1151.     move.l    d0,([a0,8])        ;old ptr is jump
  1152.     move.l    4(a0),(a1)        ;install my vecor
  1153.     bra.s    .next
  1154. .install
  1155.     move.l    #end_int,([a0,8])    ;point to rte
  1156.     move.l    4(a0),(a1)        ;install my vector
  1157. .next    add.l    #12,a0
  1158.     bra.s    .loop
  1159.  
  1160. .last    rts
  1161.  
  1162.  
  1163.  
  1164. install_timer_a:
  1165.     btst    #5,$fffffa07.w
  1166.     beq.s    .new_a
  1167.     move.l    $134.w,d0        ;current timer a
  1168.     beq.s    .new_a            ;must be non zero!
  1169.     cmp.l    #new_timer_a,d0        ;my timer installed?
  1170.     beq.s    .go_a            ;yes
  1171.     btst    #0,d0            ;odd address?
  1172.     bne.s    .new_a            ;no, even
  1173.     move.l    d0,old_timer_a+2    ;old timer a
  1174.     move.l    #new_timer_a,$134.w    ;my timer a
  1175.     bra    .go_a            ;set timer a on
  1176. .new_a    move.l    #end_timer_a,d0        ;sei routine
  1177.     btst    #3,$fffffa17.w        ;aei/sei
  1178.     bne.s    .sei            ;sei
  1179.     move.l    #end_int,d0        ;dummy RTE
  1180. .sei    move.l    d0,old_timer_a+2    ;end interrupt routine
  1181.     move.l    #new_timer_a,$134.w    ;install timer a
  1182. .go_a    tst.b    $fffffa19.w
  1183.     bne.s    .ok_a
  1184.     move.b    #7,$fffffa19.w        ;Timer A control (delay mode)
  1185.     move.b    #246,$fffffa1f.w    ;Timer A data
  1186. .ok_a    bset    #5,$fffffa07.w        ;Interrupt Enable Register A
  1187.     bset    #5,$fffffa13.w        ;Interrupt Mask Register A
  1188.     rts
  1189.  
  1190.  
  1191. install_timer_b:
  1192.     btst    #0,$fffffa07.w
  1193.     beq.s    .new_b
  1194.     move.l    $120.w,d0        ;current timer b
  1195.     beq.s    .new_b            ;must be non zero!
  1196.     cmp.l    #new_timer_b,d0        ;my timer installed?
  1197.     beq.s    .go_b            ;yes
  1198.     btst    #0,d0            ;odd address?
  1199.     bne.s    .new_b            ;no, even
  1200.     move.l    d0,old_timer_b+2    ;old timer a
  1201.     move.l    #new_timer_b,$120.w    ;my timer a
  1202.     bra    .go_b            ;set timer a on
  1203. .new_b    move.l    #end_timer_b,d0        ;sei routine
  1204.     btst    #3,$fffffa17.w        ;aei/sei
  1205.     bne.s    .sei            ;sei
  1206.     move.l    #end_int,d0        ;dummy RTE
  1207. .sei    move.l    d0,old_timer_b+2    ;end interrupt routine
  1208.     move.l    #new_timer_b,$120.w    ;install timer a
  1209. .go_b    tst.b    $fffffa1b.w
  1210.     bne.s    .ok_b
  1211.     move.b    #7,$fffffa1b.w        ;Timer A control (delay mode)
  1212.     move.b    #246,$fffffa21.w    ;Timer A data
  1213. .ok_b    bset    #0,$fffffa07.w        ;Interrupt Enable Register B
  1214.     bset    #0,$fffffa13.w        ;Interrupt Mask Register B
  1215.     rts
  1216.  
  1217. install_timer_c:
  1218.     btst    #5,$fffffa09.w
  1219.     beq.s    .new_c
  1220.     move.l    $114.w,d0        ;current timer c
  1221.     beq.s    .new_c            ;must be non zero!
  1222.     cmp.l    #new_timer_c,d0        ;my timer installed?
  1223.     beq.s    .go_c            ;yes
  1224.     btst    #0,d0            ;odd address?
  1225.     bne.s    .new_c            ;no, even
  1226.     move.l    d0,old_timer_c+2    ;old timer a
  1227.     move.l    #new_timer_c,$114.w    ;my timer a
  1228.     bra    .go_c            ;set timer a on
  1229. .new_c    move.l    #end_timer_c,d0        ;sei routine
  1230.     btst    #3,$fffffa17.w        ;aei/sei
  1231.     bne.s    .sei            ;sei
  1232.     move.l    #end_int,d0        ;dummy RTE
  1233. .sei    move.l    d0,old_timer_c+2    ;end interrupt routine
  1234.     move.l    #new_timer_c,$114.w    ;install timer a
  1235. .go_c    bftst    $fffffa1c.w{8+5:3}    ;timer c on?
  1236.     bne.s    .ok_c            ;yes
  1237.     or.b    #%111,$fffffa1d.w    ;Timer C/D control (delay mode)
  1238.     move.b    #246,$fffffa23.w    ;Timer C data
  1239. .ok_c    bset    #5,$fffffa09.w        ;Interrupt Enable Register B
  1240.     bset    #5,$fffffa15.w        ;Interrupt Mask Register B
  1241.     rts
  1242.  
  1243.  
  1244. install_timer_d:
  1245.     btst    #4,$fffffa09.w
  1246.     beq.s    .new_d
  1247.     move.l    $110.w,d0        ;current timer d
  1248.     beq.s    .new_d            ;must be non zero!
  1249.     cmp.l    #new_timer_d,d0        ;my timer installed?
  1250.     beq.s    .go_d            ;yes
  1251.     btst    #0,d0            ;odd address?
  1252.     bne.s    .new_d            ;no, even
  1253.     move.l    d0,old_timer_d+2    ;old timer a
  1254.     move.l    #new_timer_d,$110.w    ;my timer b
  1255.     bra    .go_d            ;set timer b on
  1256. .new_d    move.l    #end_timer_d,d0        ;sei routine
  1257.     btst    #3,$fffffa17.w        ;aei/sei
  1258.     bne.s    .sei            ;sei
  1259.     move.l    #end_int,d0        ;dummy RTE
  1260. .sei    move.l    d0,old_timer_d+2    ;end interrupt routine
  1261.     move.l    #new_timer_d,$110.w    ;install timer a
  1262.     or.b    #%0111000,$fffffa1d.w
  1263.     move.b    #246,$fffffa25.w    ;Timer D data
  1264.     bra.s    .ok_d
  1265. .go_d    bftst    $fffffa1c.w{8+1:3}    ;timer d on?
  1266.     bne.s    .ok_d            ;yes
  1267.     or.b    #%0111000,$fffffa1d.w
  1268.     move.b    #246,$fffffa25.w    ;Timer D data
  1269. .ok_d    bset    #4,$fffffa09.w        ;Interrupt Enable Register B
  1270.     bset    #4,$fffffa15.w        ;Interrupt Mask Register B
  1271.     rts
  1272.  
  1273. install_ikbd:
  1274.     move.l    $118.w,d0
  1275.     beq.s    .new_i    
  1276.     cmp.l    #new_ikbd,d0
  1277.     beq    .go_i
  1278.     btst    #0,d0
  1279.     bne.s    .new_i
  1280.     move.l    d0,old_ikbd+2
  1281.     move.l    #new_ikbd,$118.w
  1282.     bra.s    .go_i
  1283. .new_i    move.l    #end_ikbd,old_ikbd+2
  1284.     move.l    #new_ikbd,$118.w
  1285. .go_i    bset    #6,$fffffa09.w
  1286.     bset    #6,$fffffa15.w    
  1287.     rts
  1288.  
  1289. install_fdi:
  1290.     btst    #7,$fffffa09.w
  1291.     beq.s    .new_f
  1292.     move.l    $11c.w,d0
  1293.     beq.s    .new_f
  1294.     cmp.l    #new_fdi,d0
  1295.     beq    .go_f
  1296.     btst    #0,d0
  1297.     bne.s    .new_f
  1298.     move.l    d0,old_fdi+2
  1299.     move.l    #new_fdi,$11c.w
  1300.     bra.s    .go_f
  1301. .new_f    move.l    #end_fdi,old_fdi+2
  1302.     move.l    #new_fdi,$11c.w
  1303. .go_f    bset    #7,$fffffa09.w
  1304.     bset    #7,$fffffa15.w    
  1305.     rts
  1306.  
  1307. install_blitter:
  1308.     btst    #3,$fffffa09.w
  1309.     beq.s    .new_bl
  1310.     move.l    $10c.w,d0
  1311.     beq.s    .new_bl
  1312.     cmp.l    #new_blitter,d0
  1313.     beq    .go_bl
  1314.     btst    #0,d0
  1315.     bne.s    .new_bl
  1316.     move.l    d0,old_blitter+2
  1317.     move.l    #new_blitter,$10c.w
  1318.     bra.s    .go_bl
  1319. .new_bl    move.l    #end_blitter,old_blitter+2
  1320.     move.l    #new_blitter,$10c.w
  1321. .go_bl    bset    #3,$fffffa09.w
  1322.     bset    #3,$fffffa15.w    
  1323.     rts
  1324.  
  1325.  
  1326. install_mono:
  1327.     move.l    #new_mono,$13c.w
  1328.     bset    #7,$fffffa07.w
  1329.     bset    #7,$fffffa13.w
  1330.     rts
  1331.  
  1332. install_trace:
  1333.     move.l    #check_option,$24.w
  1334.     move.w    #$8000,new_sr
  1335.     rts
  1336.  
  1337. install_reset:
  1338.     move.l    #$31415926,$426.w    ;magic
  1339.     move.l    #new_reset,$42a.w    
  1340.     rts
  1341.  
  1342. install_alt_help
  1343.     move.l    #new_alt_help,$502.w
  1344.     rts
  1345.  
  1346. install_vbl_queue:
  1347.     move.l    $456.w,a0
  1348.     move.l    #new_vbl_lister,d0
  1349. .gvbl    move.l    (a0)+,d1
  1350.     beq.s    .install
  1351.     cmp.l    d0,d1
  1352.     bne.s    .gvbl    
  1353.     rts
  1354. .install
  1355.     move.l    #new_vbl_lister,-4(a0)
  1356.     clr.l    (a0)
  1357.     rts
  1358.  
  1359.  
  1360. ***********************
  1361. * NEW VECTOR ROUTINES *
  1362. ***********************
  1363.  
  1364. end_int:    rte
  1365.  
  1366.  
  1367. *
  1368. ** EXCEPTION ERRORS **
  1369. *
  1370.  
  1371. new_bus_error:    clr.b    current_vec
  1372.         move.b    #error_ex,vec_family
  1373.         bsr    check_option
  1374. old_bus_error    jmp    $12345678
  1375.  
  1376. new_address_error:
  1377.         move.b    #1,current_vec
  1378.         move.b    #error_ex,vec_family
  1379.         bsr    check_option
  1380. old_address_error
  1381.         jmp    $12345678
  1382.  
  1383. new_illegal:
  1384.         move.b    #2,current_vec
  1385.         move.b    #error_ex,vec_family
  1386.         bsr    check_option
  1387. old_illegal    jmp    $12345678
  1388.  
  1389. new_divide0:
  1390.         move.b    #3,current_vec
  1391.         move.b    #error_ex,vec_family
  1392.         bsr    check_option
  1393. old_divide0    jmp    $12345678
  1394.  
  1395. new_chk:    move.b    #4,current_vec
  1396.         move.b    #error_ex,vec_family
  1397.         bsr    check_option
  1398. old_chk        jmp    $12345678
  1399.  
  1400.  
  1401. new_trapv:    move.b    #5,current_vec
  1402.         move.b    #error_ex,vec_family
  1403.         bsr    check_option
  1404. old_trapv    jmp    $12345678
  1405.  
  1406.  
  1407. new_priv:    move.b    #6,current_vec
  1408.         move.b    #error_ex,vec_family
  1409.         bsr    check_option
  1410. old_priv    jmp    $12345678
  1411.  
  1412. new_coprovi:    move.b    #7,current_vec
  1413.         move.b    #error_ex,vec_family
  1414.         bsr    check_option
  1415. old_coprovi    jmp    $12345678
  1416.  
  1417. new_format:    move.b    #8,current_vec
  1418.         move.b    #error_ex,vec_family
  1419.         bsr    check_option
  1420. old_format:    jmp    $12345678
  1421.  
  1422. new_uninit:    move.b    #9,current_vec
  1423.         move.b    #error_ex,vec_family
  1424.         bsr    check_option
  1425. old_uninit:    jmp    $12345678
  1426.  
  1427. new_spurious:    move.b    #10,current_vec
  1428.         move.b    #error_ex,vec_family
  1429.         bsr    check_option
  1430. old_spurious:    jmp    $12345678
  1431.  
  1432.  
  1433. new_trace    move.b    #trace_ex,vec_family
  1434.         bsr    check_option
  1435. old_trace:    jmp    "RGOD"
  1436.  
  1437. *
  1438. ** MMU ERRORS **
  1439. *
  1440.  
  1441. new_mmu_config:    clr.b    current_vec
  1442.         move.b    #mmu_ex,vec_family
  1443.         bsr    check_option
  1444. old_mmu_config:    jmp    $12345678
  1445.  
  1446. new_mmu_illegal:
  1447.         move.b    #1,current_vec
  1448.         move.b    #mmu_ex,vec_family
  1449.         bsr    check_option
  1450. old_mmu_illegal: jmp    $12345678
  1451.  
  1452. new_mmu_address:
  1453.             move.b    #2,current_vec
  1454.         move.b    #mmu_ex,vec_family
  1455.         bsr    check_option
  1456. old_mmu_address: jmp    $12345678
  1457.  
  1458.  
  1459. *
  1460. ** RS-232 ERRORS
  1461. *
  1462.  
  1463. new_rs232_cd:      clr.b    current_vec
  1464.         move.b    #rs232_ex,vec_family
  1465.         move.l    #$0001fa11,mfp_sei
  1466.         bsr    check_option
  1467. old_rs232_cd:     jmp    $12345678
  1468. end_rs232_cd:    bclr.b    #1,$fffffa11.w
  1469.         rte
  1470.  
  1471. new_rs232_cts:     move.b    #1,current_vec
  1472.         move.b    #rs232_ex,vec_family
  1473.         move.l    #$0002fa11,mfp_sei
  1474.         bsr    check_option
  1475. old_rs232_cts:     jmp    $12345678
  1476. end_rs232_cts:    bclr.b    #2,$fffffa11.w
  1477.         rte
  1478.  
  1479. new_rs232_te:     move.b    #2,current_vec
  1480.         move.b    #rs232_ex,vec_family
  1481.         move.l    #$0001fa0f,mfp_sei
  1482.         bsr    check_option
  1483. old_rs232_te:     jmp    $12345678
  1484. end_rs232_te:    bclr.b    #1,$fffffa0f.w
  1485.         rte
  1486.  
  1487.  
  1488. new_rs232_tbe:     move.b    #3,current_vec
  1489.         move.b    #rs232_ex,vec_family
  1490.         move.l    #$0002fa0f,mfp_sei
  1491.         bsr    check_option
  1492. old_rs232_tbe:     jmp    $12345678
  1493. end_rs232_tbe:    bclr.b    #2,$fffffa0f.w
  1494.         rte
  1495.  
  1496.  
  1497. new_rs232_re:     move.b    #4,current_vec
  1498.         move.b    #rs232_ex,vec_family
  1499.         move.l    #$0003fa0f,mfp_sei
  1500.         bsr    check_option
  1501. old_rs232_re:     jmp    $12345678
  1502. end_rs232_re:    bclr.b    #3,$fffffa0f.w
  1503.         rte
  1504.  
  1505. new_rs232_rbf:     move.b    #5,current_vec
  1506.         move.b    #rs232_ex,vec_family
  1507.         move.l    #$0004fa0f,mfp_sei
  1508.         bsr    check_option
  1509. old_rs232_rbf:     jmp    $12345678
  1510. end_rs232_rbf:    bclr.b    #4,$fffffa0f.w
  1511.         rte
  1512.  
  1513.  
  1514. new_rs232_ring:    move.b    #6,current_vec
  1515.         move.b    #rs232_ex,vec_family
  1516.         move.l    #$0006fa0f,mfp_sei
  1517.         bsr    check_option
  1518. old_rs232_ring    jmp    $12345678
  1519. end_rs232_ring    bclr.b    #6,$ffffffa0f.w
  1520.         rte
  1521.  
  1522. new_rs232_cb:      move.b    #7,current_vec
  1523.         move.b    #rs232_ex,vec_family
  1524.         move.l    #$0000fa11,mfp_sei
  1525.         bsr    check_option
  1526. old_rs232_cb:     jmp    $12345678
  1527. end_rs232_cb:    bclr.b    #0,$fffffa11.w
  1528.         rte
  1529.  
  1530. *
  1531. *** TRAP EXCEPTIONS
  1532. *
  1533.  
  1534. new_trap_1:    move.b    #trap_1_ex,vec_family
  1535.         bsr    check_option
  1536. old_trap_1:    jmp    $12345678
  1537.  
  1538. new_trap_2:    move.b    #trap_2_ex,vec_family
  1539.         bsr    check_option
  1540. old_trap_2:    jmp    $12345678
  1541.  
  1542. new_trap_13:    move.b    #trap_13_ex,vec_family
  1543.         bsr    check_option
  1544. old_trap_13:    jmp    $12345678
  1545.  
  1546. new_trap_14:    move.b    #trap_14_ex,vec_family
  1547.         bsr    check_option
  1548. old_trap_14:    jmp    $12345678
  1549.  
  1550. new_line_a    move.b    #line_a_ex,vec_family
  1551.         bsr    check_option
  1552. old_line_a    jmp    $12345678
  1553.  
  1554. new_line_f    move.b    #line_f_ex,vec_family
  1555.         bsr    check_option
  1556. old_line_f    jmp    $12345678
  1557.  
  1558. *
  1559. ** TIMER EXCEPTIONS
  1560. *
  1561.  
  1562. new_timer_a    move.b    #timer_a_ex,vec_family
  1563.         move.l    #$0005fa0f,mfp_sei
  1564.         bsr    check_option
  1565. old_timer_a    jmp    $12345678
  1566. end_timer_a    bclr.b    #5,$fffffa0f.w
  1567.         rte
  1568.  
  1569. new_timer_b    move.b    #timer_b_ex,vec_family
  1570.         move.l    #$0000fa0f,mfp_sei
  1571.         bsr    check_option
  1572. old_timer_b    jmp    $12345678
  1573. end_timer_b    bclr.b    #0,$fffffa0f.w
  1574.         rte
  1575.  
  1576.  
  1577. new_timer_c:    move.b    #timer_c_ex,vec_family
  1578.         move.l    #$0005fa11,mfp_sei
  1579.         bsr    check_option
  1580. old_timer_c    jmp    $12345678
  1581. end_timer_c    bclr.b    #5,$fffffa11.w
  1582.         rte
  1583.  
  1584. new_timer_d    move.b    #timer_d_ex,vec_family
  1585.         move.l    #$0004fa11,mfp_sei
  1586.         bsr    check_option
  1587. old_timer_d    jmp    $12345678
  1588. end_timer_d    bclr.b    #4,$fffffa11.w
  1589.         rte
  1590.  
  1591. *
  1592. ** MFP EXCEPTIONS
  1593. *
  1594.  
  1595. new_ikbd    move.b    #ikbd_ex,vec_family
  1596.         move.l    #$0006fa11,mfp_sei
  1597.         bsr    check_option
  1598. old_ikbd    jmp    $12345678
  1599. end_ikbd    bclr.b    #6,$fffffa11.w
  1600.         rte
  1601.  
  1602. new_fdi        move.b    #fdi_ex,vec_family
  1603.         move.l    #$0007fa11,mfp_sei
  1604.         bsr    check_option
  1605. old_fdi        jmp    $12345678
  1606. end_fdi        bclr.b    #7,$fffffa11.w
  1607.         rte
  1608. new_blitter:    move.b    #blitter_ex,vec_family
  1609.         move.l    #$0003fa11,mfp_sei
  1610.         bsr    check_option
  1611. old_blitter:    jmp    $12345678
  1612. end_blitter    bclr.b    #3,$fffffa11.w
  1613.         rte
  1614.  
  1615. new_mono    move.b    #mono_ex,vec_family
  1616.         move.l    #$0007fa0f,mfp_sei
  1617.         bsr    check_option
  1618.         rte
  1619.  
  1620. *
  1621. ** VBL INTERRUPTS
  1622. *
  1623.  
  1624. new_vbl:    move.b    #vbl_ex,vec_family
  1625.         bsr    check_option
  1626. old_vbl:    jmp    $12345678
  1627.  
  1628.  
  1629. new_vbl_lister    move.b    #vbl_q_ex,vec_family
  1630.         bsr    check_option
  1631. .no_rip        rts
  1632.  
  1633. new_hbl:    move.b    #hbl_ex,vec_family
  1634.         bsr    check_option
  1635. old_hbl:    jmp    $12345678
  1636.  
  1637.  
  1638. new_reset:    move.b    #reset_ex,vec_family
  1639.         clr.l    $42a.w
  1640.         clr.l    $426.w
  1641.         bsr    init_ripper
  1642.         move.w    #$2700,sr
  1643.         jmp    ([$4.w])
  1644.     
  1645. new_alt_help    move.b    #alt_help_ex,vec_family
  1646.         bsr    check_option
  1647.         rts
  1648.     
  1649.  
  1650. end_trap
  1651. ;    move.w    (a7),old_sr+2
  1652. ;    move.l    2(a7),old_prg+2
  1653. ;    move.w    #$2700,(a7)
  1654. ;    move.l    #init_trap_ripper,2(a7)        
  1655. ;    rte
  1656. init_trap_ripper
  1657.     movem.l    d0-a6,-(a7)
  1658.     bsr    init_ripper
  1659.     movem.l    (a7)+,d0-a6
  1660.     rte
  1661. ;old_sr    move.w    #$2300,sr
  1662. ;old_prg    jmp    $12345678
  1663.  
  1664.  
  1665. check_option:
  1666.     movem.l    d0-a6,-(a7)
  1667.     moveq    #0,d0
  1668.     move.b    vec_family,d0
  1669.     btst    #2,(install_bits,d0.w)
  1670.     beq.s    .no_restore
  1671.     bsr    do_installation
  1672. .no_restore
  1673.     lea    $ffff9200.w,a0    ;extended port address (read only)
  1674.     move.w    #$fff7,2(a0)    ;write mask
  1675.     move.w    (a0),d0        ;read fire data
  1676.     btst    #1,d0        ;check for option
  1677.     bne.s    no_option    ;if set, option is not pressed
  1678.     bsr    init_ripper
  1679. no_option:
  1680.     clr.l    mfp_sei
  1681. ;    tst.b    install_bits+(trace_ex)
  1682. ;    beq.s    .mvm
  1683. ;    cmp.b    #vbl_q_ex,vec_family
  1684. ;    bne.s    .nv
  1685. ;    move.w    sr,d0
  1686. ;    or.w    new_sr,d0    
  1687. ;    move.w    d0,sr
  1688. ;    bra.s    .mvm
  1689. ;.nv    move.w    new_sr,d0
  1690. ;    or.w    d0,16*4(a7)
  1691. .mvm    movem.l    (a7)+,d0-a6
  1692.     rts
  1693.  
  1694.  
  1695.  *------------------------*
  1696. ** GEMDOS Disk Operations **
  1697.  *------------------------*
  1698.  
  1699. * A0->filename, A1->address, D1=length
  1700.  
  1701.  
  1702. save_file:    tst.b    god_mode
  1703.         bne    save_god_file
  1704.         lea    file_name(pc),a0
  1705.         bsr    create_file
  1706.         bmi    display_gemdos_error
  1707.         lea    magic,a0
  1708.         moveq    #10,d7
  1709.         bsr    write_file
  1710.         bmi    display_gemdos_error        
  1711.         move.w    pic_res,d0
  1712.         cmp.w    #4,d0
  1713.         beq    .no_pal
  1714.         lea    (pal_sizes,d0.w*4),a6
  1715.         move.l    (a6)+,d7
  1716.         beq.s    .no_st
  1717.         lea    pal_space,a0        
  1718.         bsr    write_file
  1719. .no_st        move.l    (a6)+,d7
  1720.         beq.s    .no_pal
  1721.         lea    pal_space+32,a0        
  1722.         bsr    write_file        
  1723.         bmi    display_gemdos_error
  1724. .no_pal
  1725. save_true
  1726.         tst.w    screen_vars+4
  1727.         bne    save_pic_lines
  1728.         move.l    pic_adr,a0
  1729.         move.l    pic_length,d7
  1730.         bsr    write_file
  1731.         bmi    display_gemdos_error
  1732.         bsr    close_file
  1733.         rts
  1734.  
  1735. save_pic_lines
  1736.         move.l    pic_adr,a0
  1737.         moveq    #0,d7
  1738.         move.w    screen_vars+6,d7
  1739.         add.l    d7,d7
  1740.         moveq    #0,d6
  1741.         move.w    screen_vars+4,d6
  1742.         add.l    d6,d6
  1743.         
  1744.         move.w    pic_y,d5
  1745.         subq.w    #1,d5
  1746.         bmi.s    .err
  1747. .lines        bsr    write_file
  1748.         add.l    d6,a0
  1749.         dbra    d5,.lines
  1750.  
  1751. .err        bsr    close_file
  1752.         rts
  1753.  
  1754. save_god_file:    lea    file_name(pc),a0
  1755.         bsr    create_file
  1756.         bmi    display_gemdos_error
  1757.         lea    god_head,a0
  1758.         move.w    #'G4',(a0)
  1759.         move.w    pic_x,2(a0)
  1760.         move.w    pic_y,4(a0)
  1761.         moveq    #6,d7
  1762.         bsr    write_file
  1763.         bmi    display_gemdos_error        
  1764.         
  1765.         cmp.w    #4,pic_res        ;true colour
  1766.         beq    save_true        ;yes
  1767.  
  1768.         bsr    get_god_pal
  1769.         
  1770.         move.w    pic_y,d0
  1771.         subq.w    #1,d0
  1772.         bmi    .err
  1773. .write_line_loop                
  1774.         move.w    d0,-(a7)
  1775.         bsr    convert_god_line
  1776.         move.l    physic(pc),a0        ;line buffer
  1777.         moveq    #0,d7
  1778.         move.w    pic_x,d7        ;x pixels
  1779.         add.l    d7,d7            ;*2=tc line size
  1780.         bsr    write_file
  1781.         bmi    display_gemdos_error
  1782.         move.w    (a7)+,d0
  1783.         dbra    d0,.write_line_loop
  1784.  
  1785. .err        bsr    close_file
  1786.         rts
  1787.  
  1788.  
  1789.  
  1790.  
  1791. * a0=source, a1=dest, a2=colour table
  1792.  
  1793. convert_god_line:
  1794.         move.l    cur_pic_adr,a0
  1795.         move.l    physic(pc),a1    ;buffer space        
  1796.         lea    colour_table,a2
  1797.         move.w    pic_x,d4    ;pixels
  1798.         lsr.w    #4,d4        ;divide by 16
  1799.         subq.w    #1,d4        ;-1 for dbra
  1800.         bmi    .error
  1801.  
  1802. .line        move.w    pic_res,d3    ;0,1,2
  1803.         move.w    (plane_dbra,d3.w*2),d5 ;get dbra amount
  1804.         moveq    #0,d0
  1805. .loop1        moveq    #0,d2        ;d2=current pixel
  1806.         move    #31,d7
  1807.         move.l    a0,a3        ;screen address
  1808.         move.w    d5,d3        ;dbra    amount
  1809. .get_pix    bfextu    (a3){d0:1},d1    ;get bit
  1810.         bfins    d1,d2{d7:1}
  1811. ;        roxr.b    #1,d1        ;shift to X flag
  1812. ;        roxl.b    #1,d2        ;shift from X flag
  1813. ;        lsl.w    d2
  1814. ;        or.w    d1,d2
  1815.         addq.w    #2,a3        ;next plane
  1816.         subq.w    #1,d7
  1817.         dbra    d3,.get_pix                        
  1818.         move.w    (a2,d2.w*2),(a1)+    ;copy pixel    
  1819.         addq.l    #1,d0        ;next pixel
  1820.         cmp.w    #16,d0        ;last in plane
  1821.         blt.s    .loop1
  1822.         move.l    a3,a0
  1823.         dbra    d4,.line
  1824.  
  1825.         move.l    a0,cur_pic_adr
  1826.  
  1827. ;        move.l    line_length,d7        ;line size in words    
  1828. ;        add.l    d7,cur_pic_adr        ;update ptr
  1829.  
  1830. .error        rts    
  1831.  
  1832.  
  1833. get_god_pal:
  1834.         lea    pal_space,a0
  1835.         lea    colour_table,a1
  1836.         move.w    pic_res,d0
  1837.         move.w    (cols_dbra,d0.w*2),d0
  1838.         cmp.w    #255,d0
  1839.         beq    get_256_pal
  1840. .loop        bfextu    (a0){4:1},d1    ;lowest red bit
  1841.         bfextu    (a0){5:3},d2    ;other red bits
  1842.         lsl.w    d2        ;shift up a bit
  1843.         or.w    d2,d1        ;form red byte
  1844.         lsl.w    #1,d1        ;->5 bit value
  1845.         bfins    d1,(a1){0:5}    ;store in table
  1846.         bfextu    (a0){8:1},d1    ;lowest green bit
  1847.         bfextu    (a0){9:3},d2    ;other green bits
  1848.         lsl.w    d2        ;shift up a bit
  1849.         or.w    d2,d1        ;form green byte
  1850.         lsl.w    #2,d1        ;->6 bit value
  1851.         bfins    d1,(a1){5:6}    ;store in table
  1852.         bfextu    (a0){12:1},d1    ;lowest blue bit
  1853.         bfextu    (a0){13:3},d2    ;other blue bits
  1854.         lsl.w    d2        ;shift up a bit
  1855.         or.w    d2,d1        ;form blue byte
  1856.         lsl.w    #1,d1        ;->5 bit value
  1857.         bfins    d1,(a1){11:5}    ;store in table
  1858.         addq.w    #2,a0
  1859.         addq.w    #2,a1
  1860.         dbra    d0,.loop    ;loop for all colours
  1861.         rts        
  1862.  
  1863. get_256_pal:    lea    32(a0),a0
  1864.         lea    colour_table,a1
  1865. .loop        bfextu    (a0){0:5},d1
  1866.         bfins    d1,(a1){0:5}
  1867.         bfextu    (a0){8:6},d1
  1868.         bfins    d1,(a1){5:6}                
  1869.         bfextu    (a0){24:5},d1
  1870.         bfins    d1,(a1){11:5}                
  1871.         addq.w    #4,a0
  1872.         addq.w    #2,a1
  1873.         dbra    d0,.loop
  1874.         rts
  1875.  
  1876. cols_dbra    dc.w    0,3,15,255
  1877. plane_dbra    dc.w    0,1,3,7
  1878.  
  1879. pal_sizes    dc.l    4,8
  1880.         dc.l    8,16
  1881.         dc.l    16,64
  1882.         dc.l    0,256    
  1883.  
  1884.  
  1885. display_gemdos_error:
  1886.         lea    gemdos_errors,a0
  1887.         move.l    #(end_gemdos_errors-gemdos_errors)/8-1,d1
  1888. .find_err    cmp.l    (a0)+,d0
  1889.         beq    found_gemdos_error
  1890.         addq.l    #4,a0
  1891.         dbra    d1,.find_err
  1892.         lea    unerr,a0
  1893. found_gemdos_error
  1894.         move.l    (a0),a0
  1895.         moveq    #0,d0
  1896.         move.l    #180,d1
  1897.         bsr    print_string
  1898.         rts
  1899.  
  1900. create_file:    movem.l    d1-2/a0-2,-(a7)
  1901.         clr.w    -(a7)
  1902.         pea    (a0)
  1903.         move.w    #$3c,-(a7)
  1904.         trap    #1
  1905.         addq.l    #8,a7
  1906.         movem.l    (a7)+,d1-2/a0-a2
  1907.         move.w    d0,file_handle
  1908.         rts
  1909.  
  1910. open_file:    movem.l    d1-2/a0-2,-(a7)
  1911.         clr.w    -(a7)
  1912.         pea    (a0)
  1913.         move.w    #$3d,-(a7)
  1914.         trap    #1
  1915.         addq.l    #8,a7
  1916.         movem.l    (a7)+,d1-2/a0-a2
  1917.         move.w    d0,file_handle    
  1918.         rts
  1919.  
  1920. read_file:    movem.l    d1-2/a0-2,-(a7)
  1921.         pea    (a0)
  1922.         move.l    d7,-(a7)
  1923.         move.w    file_handle,-(a7)
  1924.         move.w    #$3f,-(a7)
  1925.         trap    #1
  1926.         lea    12(a7),a7
  1927.         movem.l    (a7)+,d1-2/a0-a2
  1928.         cmp.l    d7,d0
  1929.         beq.s    .rf
  1930.         move.l    #-1000,d0
  1931. .rf        rts
  1932.  
  1933. write_file:    movem.l    d1-2/a0-2,-(a7)
  1934.         pea    (a0)
  1935.         move.l    d7,-(a7)
  1936.         move.w    file_handle,-(a7)
  1937.         move.w    #$40,-(a7)    
  1938.         trap    #1
  1939.         lea    12(a7),a7
  1940.         movem.l    (a7)+,d1-2/a0-a2
  1941.         cmp.l    d7,d0
  1942.         beq.s    .l9
  1943.         move.l    #-1001,d0
  1944. .l9        rts
  1945.  
  1946. file_seek:    movem.l    d1-2/a0-2,-(a7)
  1947.         move.w    d0,-(a7)
  1948.         move.w    file_handle,-(a7)
  1949.         move.l    d1,-(a7)
  1950.         move.w    #$42,-(a7)
  1951.         trap    #1
  1952.         lea    10(a7),a7
  1953.         movem.l    (a7)+,d1-2/a0-a2
  1954.         rts
  1955.  
  1956. close_file:    movem.l    d1-2/a0-2,-(a7)
  1957.         move.w    file_handle,-(a7)
  1958.         move.w    #$3e,-(a7)
  1959.         trap    #1
  1960.         addq.l    #4,a7
  1961.         movem.l    (a7)+,d1-2/a0-a2
  1962.         rts
  1963.  
  1964. ***************************************
  1965. * STRING PRINTING/CONVERSION ROUTINES *
  1966. ***************************************
  1967.  
  1968. print_string
  1969.     move.l    physic(pc),a1        ;screen
  1970.     mulu    #80,d1            ;y line * line size
  1971.     add.l    d1,a1            ;get to y line
  1972.     lea    tiny_font(pc),a2    ;font data
  1973. .line    move.l    d0,d2            ;start x
  1974. .nxt    moveq    #0,d1            ;clear d1
  1975.     move.b    (a0)+,d1        ;get byte from string
  1976.     beq    .last
  1977.     cmp.b    #13,d1            ;return?
  1978.     bne.s    .not_return        ;no
  1979.     add.l    #80*8*6,d0        ;next line
  1980.     bra.s    .line            ;restore x pos
  1981. .not_return
  1982.     sub.b    #32,d1        ;- first char
  1983.     mulu    #36,d1        ;* char size
  1984.     moveq    #5,d4        ;6 y lines
  1985. .yl    bfextu    (a2){d1:6},d3    
  1986.     bfins    d3,(a1){d2:6}
  1987.     addq.l    #6,d1        ;next char pos in char
  1988.     add.l    #80*8,d2    ;next screen line
  1989.     dbra    d4,.yl        ;loop y times
  1990.     sub.l    #80*8*6-6,d2    ;next x pos
  1991.     bra.s    .nxt
  1992. .last    rts
  1993.  
  1994. * enter with d0=long value
  1995.  
  1996. conv_long_ascii:
  1997.     movem.l    d0-3/a0,-(a7)
  1998.     lea    long_string,a0
  1999.     moveq    #$20,d2
  2000.     moveq    #9,d1
  2001. .clr    move.b    d2,(a0)+
  2002.     dbra    d1,.clr    
  2003.     clr.b    (a0)
  2004.     tst.l    d0
  2005.     beq.s    .endc
  2006.     moveq    #10,d2
  2007.     moveq    #$30,d3    
  2008. .conv    divul.l    d2,d1:d0
  2009.     add.b    d3,d1
  2010.     move.b    d1,-(a0)
  2011.     cmp.w    d2,d0
  2012.     bcc.s    .conv
  2013.     tst.b    d0
  2014.     beq.s    .endc
  2015.     add.b    d3,d0
  2016.     move.b    d0,-(a0)
  2017. .endc    movem.l    (a7)+,d0-3/a0
  2018.     rts
  2019.  
  2020.  *-------------------*
  2021. ** KEYBOARD ROUTINES **
  2022.  *-------------------*
  2023.  
  2024.  
  2025. init_ikbd:    bsr    clear_ikbd
  2026.         moveq    #$11,d0
  2027.         bsr    send_ikbd
  2028.         move.l    $118.w,old118
  2029.         move.l    #my_ikbd,$118.w
  2030.         lea    key_table,a0
  2031.         moveq    #127,d0
  2032. .cl        clr.b    (a0)+
  2033.         dbra    d0,.cl
  2034.         rts
  2035.  
  2036. restore_ikbd:    bsr    clear_ikbd
  2037.         move.l    old118,$118.w
  2038.         rts
  2039.  
  2040. clear_ikbd:     btst    #0,$fffffc00.w        ;is ikbd data reg full?
  2041.                 beq.s   ikbd_ok            ;its empty so end
  2042.                 move.b  $fffffc02.w,D0        ;get ikbd data
  2043.                 bra.s   clear_ikbd        ;loop
  2044. ikbd_ok:        rts                             ;return
  2045.  
  2046. send_ikbd:      lea     $fffffc00.w,a0        ;ikbd control register
  2047. waitkeyready:   btst    #1,(a0)            ;is data reg empty?
  2048.                 beq.s   waitkeyready        ;no, wait for empty
  2049.                 move.b  d0,2(a0)        ;write to ikbd data reg
  2050.                 rts                             ;return
  2051.  
  2052. my_ikbd:    move.w    #$2500,sr        ;set ipl level
  2053.  
  2054.         movem.l    d0/a0-a1,-(a7)        ;save registers
  2055.         movea.w    #$fffffc00,a0        ;ikbd control registers
  2056.  
  2057.         move.b    (a0),d0            ;read control reg
  2058.         btst    #7,d0            ;int request?
  2059.         beq    endmykey        ;no
  2060.  
  2061. keyloop        moveq    #0,d0            ;clear d0
  2062.         move.b    2(a0),d0        ;read ikbd data
  2063.         tst.b    key_cntr        ;is this first byte
  2064.         beq    chk_head        ;yes, so check for header
  2065.         
  2066.         move.l    key_ptr(pc),a1        ;ptr into key storage area
  2067.         move.b    d0,(a1)+        ;store keyboard data
  2068.         move.l    a1,key_ptr        ;update ptr
  2069.         subq.b    #1,key_cntr        ;decrement data to get
  2070.         bne    last_key_check        ;more data to get
  2071.  
  2072. process_packet:
  2073.         lea    key_buffer,a1        ;start of key storage data
  2074.         moveq    #0,d0            ;clear d0
  2075.         move.b    (a1),d0            ;get first byte
  2076.         sub.l    #$f6,d0        ;minus default packet header value
  2077.         and.w    #$f,d0            ;mask off unwanted bits
  2078.         cmp.w    #10,d0            ;is it a valid packet
  2079.         bge.s    .noj            ;no
  2080.         jsr    ([key_handlers,d0.w*4])    ;jump to packet handler routine
  2081. .noj        bra    last_key_check        ;check for more key data
  2082.  
  2083. chk_head    cmp.w    #$f6,d0            ;is it packer header
  2084.         blt.s    store_key        ;no, store as a key
  2085.  
  2086.         move.b    d0,key_buffer        ;store packet header
  2087.         move.l    #key_buffer+1,key_ptr    ;init key pointer
  2088.         lea    packet_table,a1        ;packet table
  2089.         sub.b    #$f6,d0            ;d0 is offset
  2090.         move.b    (a1,d0.w),key_cntr    ;bytes of data to be read
  2091.         bra    last_key_check        ;get data
  2092.  
  2093. store_key
  2094.         IFNE    DEBUG
  2095.         movem.l    d0-a6,-(a7)
  2096.         lea    $f96.w,a0
  2097.         jsr    ([$1132.w])
  2098.         movem.l    (a7)+,d0-a6
  2099.         ENDC
  2100.         lea    key_table,a1        ;keypress table
  2101.         bclr    #7,d0            ;check 'release' bit
  2102.         beq.s    setkey            ;0, so set key press
  2103.         clr.b    (a1,d0.w)        ;key released
  2104.     IFNE    new_bss_ikbd
  2105.     cmp.b    #$3a,d0
  2106.     bne.s    .not_caps
  2107.     eor.b    #1,caps_lock
  2108. .not_caps
  2109.     ENDC
  2110.         bra.s    last_key_check        ;get key data
  2111. setkey        st.b    (a1,d0.w)        ;set key pressed
  2112.         st.b    key_pressed
  2113.         move.b    d0,current_key
  2114.     IFNE    new_bss_ikbd
  2115.     move.b    d0,bss_key
  2116.     ENDC
  2117.  
  2118. last_key_check:    move.b    (a0),d0        ;read ikbd control
  2119.         btst    #0,d0        ;more data to read?
  2120.         bne    keyloop        ;yes, so process it
  2121. endmykey    movem.l    (a7)+,d0/a0-1    ;restore registers
  2122.         bclr    #6,$fffffa11.w    ;signal end of ikbd interrupt
  2123.         rte
  2124.  
  2125. packet_table:
  2126.         dc.b    1    ;$f6 - keyboard packet
  2127.         dc.b    5    ;$f7 - absolute mouse packet
  2128.         dc.b    2    ;$f8 - relative mouse position / no buttons
  2129.         dc.b    2    ;$f9 - relative mouse / left button
  2130.         dc.b    2    ;$fa - relative mouse / right button
  2131.         dc.b    2    ;$fb - relative mouse / both buttons
  2132.         dc.b    6    ;$fc - time of day
  2133.         dc.b    2    ;$fd - joystick report
  2134.         dc.b    1    ;$fe - joystick 0 event
  2135.         dc.b    1    ;$ff - joystick 1 event
  2136.         even
  2137.  
  2138. key_handlers:
  2139.         dc.l    keyboard_packet_handler    ;$f6
  2140.         dc.l    absolute_mouse_handler    ;$f7
  2141.         dc.l    relative_mouse_handler    ;$f8
  2142.         dc.l    relative_mouse_handler    ;$f9
  2143.         dc.l    relative_mouse_handler    ;$fa
  2144.         dc.l    relative_mouse_handler    ;$fb
  2145.         dc.l    time_of_day_handler    ;$fc
  2146.         dc.l    joystick_report_handler    ;$fd
  2147.         dc.l    joystick0_handler    ;$fe
  2148.         dc.l    joystick1_handler    ;$ff
  2149.  
  2150. keyboard_packet_handler:
  2151.         moveq    #0,d0            ;clear d0
  2152.         move.b    1(a0),d0        ;get key
  2153.         bclr    #7,d0            ;key pressed?
  2154.         beq.s    .setkey            ;yes, set it
  2155.         clr.b    (key_table,d0.w)    ;indicate key release
  2156.     IFNE    new_bss_ikbd
  2157.     cmp.b    #$3a,d0
  2158.     bne.s    .not_caps
  2159.     eor.b    #1,caps_lock
  2160. .not_caps
  2161.     ENDC
  2162.         rts                             ;return
  2163. .setkey        st.b    (key_table,d0.w)    ;clear key
  2164.         st.b    key_pressed
  2165.         move.b    d0,current_key
  2166.     IFNE    new_bss_ikbd
  2167.     move.b    d0,bss_key
  2168.     ENDC
  2169.         rts                             ;return
  2170.  
  2171. absolute_mouse_handler:            ;no absolute mouse handler!
  2172. time_of_day_handler:            ;no time of day handler!
  2173. joystick_report_handler:
  2174.         move.b    1(a1),j1_packet        ;get joystick 1 packet
  2175.         move.b    2(a1),j2_packet        ;get joystick 2 packet
  2176.         rts                             ;return
  2177.  
  2178. joystick0_handler:
  2179.         move.b    1(a1),j1_packet        ;save joystick 1 packet
  2180.         rts                             ;return
  2181.  
  2182. joystick1_handler:
  2183.         move.b    1(a1),j2_packet        ;save joystick 2 packet
  2184.         rts                             ;return
  2185.  
  2186. relative_mouse_handler:
  2187.         st.b    mouse_moved        ;indicate mouse moved
  2188.  
  2189.         move.b    (a1),d0            ;get mouse key info
  2190.         and.w    #%11,d0            ;isolate l+r buttons
  2191.         move.b    d0,mousek        ;save mouse key info
  2192.  
  2193. .nolimits    move.b    1(a1),d0        ;mouse x movement
  2194.         ext.w    d0            ;extend to signed word
  2195.         add.w    d0,mousex        ;update mouse x position
  2196.         move.b    2(a1),d0        ;mouse y movement
  2197.         ext.w    d0            ;extedn to signed word
  2198.         add.w    d0,mousey        ;update mouse y position
  2199. ;        rts                             ;return
  2200.  
  2201.         move.w    mousex,d0
  2202.         cmp.w    mousex_min,d0
  2203.         bgt.s    .xok1
  2204.         move.w    mousex_min,mousex
  2205.         bra.s    .xok2
  2206. .xok1        cmp.w    mousex_max,d0
  2207.         blt.s    .xok2
  2208.         move.w    mousex_max,mousex
  2209. .xok2        move.w    mousey,d0
  2210.         cmp.w    mousey_min,d0
  2211.         bgt.s    .yok1
  2212.         move.w    mousey_min,mousey
  2213.         bra.s    .yok2
  2214. .yok1        cmp.w    mousey_max,d0
  2215.         blt.s    .yok2
  2216.         move.w    mousey_max,mousey
  2217. .yok2        rts
  2218.  
  2219.         IFNE    new_bss_ikbd
  2220.  
  2221.     dc.l    'XBRA'
  2222.     dc.l    'BS13'
  2223. bss_trap_13:
  2224.     move.l    a7,a0            ;sp
  2225.     move.w    (a0),d0            ;get sr
  2226.     btst    #13,d0            ;super mode?
  2227.     beq.s    .user_mode        ;no user
  2228.     addq.l    #8,a0            ;get to parameters
  2229.     bra.s    .cont            ;continue
  2230. .user_mode    
  2231.     move.l    USP,a0            ;user stack ptr
  2232. .cont    cmp.w    #$b,(a0)        ;my kbshift
  2233.     beq    my_kbshift        ;yes
  2234. old_bss_trap_13
  2235.     jmp    "RGOD"
  2236.         
  2237. my_kbshift:    move.w    2(a0),d0
  2238.         bpl    set_kbshift
  2239.         bsr    get_kbshift
  2240.         rte
  2241.         
  2242. get_kbshift        
  2243. .read        tst.b    key_table+$36    ;right_shift
  2244.         beq.s    .nors
  2245.         bset    #0,d0
  2246. .nors        tst.b    key_table+$2a    ;right_shift
  2247.         beq.s    .nols
  2248.         bset    #1,d0
  2249. .nols        tst.b    key_table+$1d
  2250.         beq.s    .no_ctl
  2251.         bset    #2,d0
  2252. .no_ctl        tst.b    key_table+$38    ;right_shift
  2253.         beq.s    .noalt
  2254.         bset    #3,d0
  2255.         tst.b    key_table+$47
  2256.         beq.s    .no_clr
  2257.         bset    #5,d0
  2258. .no_clr        tst.b    key_table+$52    
  2259.         beq.s    .no_ins
  2260.         bset    #6,d0
  2261. .no_ins        
  2262. .noalt        tst.b    caps_lock    ;right_shift
  2263.         beq.s    .nocaps
  2264.         bset    #4,d0
  2265. .nocaps        rts
  2266.  
  2267. set_kbshift    lsr.b    d0
  2268.         bcc.s    .no_rs
  2269.         st.b    key_table+$36
  2270. .no_rs        lsr.b    d0
  2271.         bcc.s    .no_ls
  2272.         st.b    key_table+$2a
  2273. .no_ls        lsr.b    d0
  2274.         bcc.s    .no_ctl
  2275.         st.b    key_table+$1d
  2276. .no_ctl        lsr.b    d0
  2277.         bcc.s    .no_alt
  2278.         st.b    key_table+$38
  2279. .no_alt        lsr.b    d0
  2280.         bcc.s    .no_caps
  2281.         st.b    caps_lock
  2282. .no_caps    lsr.b    d0
  2283.         bcc.s    .no_clr
  2284.         st.b    key_table+$47
  2285.         st.b    key_table+$38
  2286. .no_clr        lsr.b    d0
  2287.         bcc.s    .no_ins
  2288.         st.b    key_table+$52
  2289.         st.b    key_table+$38
  2290. .no_ins        rte
  2291.  
  2292. bss_shift_scan_code_table:
  2293. *                0123456789ABCDEF
  2294.     dc.b    '⓪⓪!"£$%^&*()_+⓪⓪'
  2295.     dc.b    'QWERTYUIOP{}⓪⓪AS'
  2296.     dc.b    'DFGHJKL:@¯⓪~ZXCV'
  2297.     dc.b    'BNM<>?⓪⓪⓪ ⓪⓪⓪⓪⓪⓪'
  2298.     dc.b    '⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪-⓪⓪⓪+⓪'    
  2299.     dc.b    '⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪'
  2300.     dc.b    '|⓪⓪()/*789456123'
  2301.     dc.b    '0.⓪'
  2302.     even
  2303.  
  2304. bss_scan_code_table:
  2305. *                0123456789ABCDEF
  2306.     dc.b    '⓪⓪1234567890-=⓪⓪'
  2307.     dc.b    'qwertyuiop[]⓪⓪as'
  2308.     dc.b    "dfghjkl;'`⓪#zxcv"
  2309.     dc.b    'bnm,./⓪⓪⓪ ⓪⓪⓪⓪⓪⓪'
  2310.     dc.b    '⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪-⓪⓪⓪+⓪'    
  2311.     dc.b    '⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪⓪'
  2312.     dc.b    '\⓪⓪()/*789456123'
  2313.     dc.b    '0.⓪'
  2314.     even
  2315.  
  2316.     
  2317. caps_lock    ds.b    1
  2318. bss_key        ds.b    1
  2319.         even
  2320.  
  2321.     dc.l    'XBRA'
  2322.     dc.l    'BSS1'
  2323. bss_trap_1:
  2324.     move.l    a7,a0            ;sp
  2325.     move.w    (a0),d0            ;get sr
  2326.     btst    #13,d0            ;super mode?
  2327.     beq.s    .user_mode        ;no user
  2328.     addq.l    #8,a0            ;get to parameters
  2329.     bra.s    .cont            ;continue
  2330. .user_mode    
  2331.     move.l    USP,a0            ;user stack ptr
  2332. .cont    cmp.w    #$6,(a0)        ;my kbshift
  2333.     bne    bss_trap_1        ;yes
  2334.     cmp.w    #$ff,2(a0)
  2335.     beq    my_crawio
  2336. old_bss_trap_1
  2337.     jmp    "RGOD"
  2338.  
  2339. my_crawio
  2340.     moveq    #0,d0
  2341.     tst.b    bss_key
  2342.     beq    end_crawio
  2343.     bsr    get_kbshift
  2344.     lea    bss_scan_code_table,a0
  2345.     bftst    d0{30:2}
  2346.     beq.s    .non_shift
  2347.     lea    bss_shift_scan_code_table,a0
  2348. .non_shift
  2349.     lsl.w    #8,d0
  2350.     moveq    #0,d1
  2351.     move.b    bss_key,d1
  2352.     move.b    d1,d0
  2353.     swap    d0
  2354.     move.b    (a0,d1.w),d1
  2355.     cmp.b    #'⓪',d1
  2356.     bne.s    .non_ascii
  2357.     move.b    d1,d0
  2358. .non_ascii
  2359.     clr.b    bss_key
  2360. end_crawio
  2361.     rte
  2362.  
  2363.     ENDC
  2364.  
  2365. temp_vbl:    addq.l    #1,$466.w
  2366.         rte
  2367.         
  2368. ***************************************************************************
  2369.     DATA
  2370. ***************************************************************************
  2371.  
  2372. my_vector_table:
  2373.     
  2374. o    set    0
  2375.     rept    $100
  2376.     dc.l    my_vector_table+o
  2377. o    set    o+4
  2378.     endr
  2379.  
  2380. my_vector_jump:
  2381. o    set    0
  2382.     rept    $100
  2383.     jmp    ([o.w])
  2384. o    set    o+4
  2385.     endr
  2386.  
  2387. tiny_font    incbin    g:\ripper\tinyfnt.bin
  2388.         even
  2389.  
  2390. Videl_640_200_2
  2391.     dc.l    640*200/8+256            * General
  2392.     dc.w    0,40,0,$400
  2393.     dc.w    0                                        * Flag Ordre
  2394.  
  2395.     dc.w    510,409,80,1007,160,434,0,0    * RGB
  2396.     dc.w    625,613,47,127,527,619
  2397.     dc.w    $181,%0100
  2398.  
  2399.     dc.w    198,141,21,627,80,150,0,0    * VGA 47 Hz
  2400.      dc.w    1337,1300,100,315,1115,1333
  2401.     dc.w    $186,%1001
  2402.  
  2403. reinstall_adrs:
  2404.     dc.w    line_a_ex
  2405.     dc.l    $28,new_line_a,old_line_a+2
  2406.     dc.w    line_f_ex
  2407.     dc.l    $2c,new_line_f,old_line_f+2
  2408.     dc.w    trap_1_ex
  2409.     dc.l    $84,new_trap_1,old_trap_1+2
  2410.     dc.w    trap_2_ex
  2411.     dc.l    $88,new_trap_2,old_trap_2+2
  2412.     dc.w    trap_13_ex
  2413.     dc.l    $b4,new_trap_13,old_trap_13+2
  2414.     dc.w    trap_14_ex
  2415.     dc.l    $b8,new_trap_14,old_trap_14+2
  2416.     dc.w    hbl_ex
  2417.     dc.l    $68,new_hbl,old_hbl+2
  2418.     dc.w    vbl_ex
  2419.     dc.l    $70,new_vbl,old_vbl+2
  2420.     dc.w    trace_ex
  2421.     dc.l    $24,new_trace,old_trace+2
  2422.     dc.w    -1
  2423.  
  2424.  
  2425. custom_adrs
  2426.     dc.w    timer_a_ex
  2427.     dc.l    install_timer_a
  2428.     dc.w    timer_b_ex
  2429.     dc.l    install_timer_b
  2430.     dc.w    timer_c_ex
  2431.     dc.l    install_timer_c
  2432.     dc.w    timer_d_ex
  2433.     dc.l    install_timer_d
  2434.     dc.w    ikbd_ex
  2435.     dc.l    install_ikbd
  2436.     dc.w    blitter_ex
  2437.     dc.l    install_blitter
  2438.     dc.w    fdi_ex
  2439.     dc.l    install_fdi
  2440.     dc.w    reset_ex
  2441.     dc.l    install_reset
  2442.     dc.w    vbl_q_ex
  2443.     dc.l    install_vbl_queue
  2444.     dc.w    alt_help_ex
  2445.     dc.l    install_alt_help
  2446.     dc.w    mono_ex
  2447.     dc.l    install_mono
  2448.     dc.w    error_ex
  2449.     dc.l    install_errors
  2450.     dc.w    rs232_ex
  2451.     dc.l    install_rs232
  2452.     dc.w    mmu_ex
  2453.     dc.l    install_mmu
  2454. ;    dc.w    trace_ex
  2455. ;    dc.l    install_trace
  2456.     dc.w    -1
  2457.  
  2458. error_adrs:
  2459.     dc.l    $8,new_bus_error,old_bus_error+2
  2460.     dc.l    $c,new_address_error,old_address_error+2
  2461.     dc.l    $10,new_illegal,old_illegal+2
  2462.     dc.l    $14,new_divide0,old_divide0+2
  2463.     dc.l    $18,new_chk,old_chk+2
  2464.     dc.l    $1c,new_trapv,old_trapv+2
  2465.     dc.l    $20,new_priv,old_priv+2
  2466.     dc.l    $34,new_coprovi,old_coprovi+2
  2467.     dc.l    $38,new_format,old_format+2
  2468.     dc.l    $3c,new_uninit,old_uninit+2
  2469.     dc.l    $60,new_spurious,old_spurious+2
  2470.     dc.l    -1
  2471.  
  2472. rs232_adrs:
  2473.     dc.l    $100,new_rs232_cb,old_rs232_cb+2
  2474.     dc.l    $104,new_rs232_cd,old_rs232_cd+2
  2475.     dc.l    $108,new_rs232_cts,old_rs232_cts+2
  2476.     dc.l    $124,new_rs232_te,old_rs232_te+2
  2477.     dc.l    $128,new_rs232_tbe,old_rs232_tbe+2
  2478.     dc.l    $12c,new_rs232_re,old_rs232_re+2
  2479.     dc.l    $130,new_rs232_rbf,old_rs232_rbf+2
  2480.     dc.l    $138,new_rs232_ring,old_rs232_ring+2
  2481.     dc.l    -1
  2482.  
  2483. mmu_adrs:
  2484.     dc.l    $e0,new_mmu_config,old_mmu_config+2
  2485.     dc.l    $e4,new_mmu_illegal,old_mmu_illegal+2
  2486.     dc.l    $e8,new_mmu_address,old_mmu_address+2
  2487.     dc.l    -1
  2488.  
  2489.  
  2490.  
  2491. ripper_txt
  2492. *                123456789 123456
  2493.     dc.b    "RESERVOIR RIPPER",13
  2494.     dc.b    "----------------",0
  2495. coder_txt
  2496.     dc.b    "CODED BY MR PINK",0
  2497. rg_txt
  2498. *                123456789 123456789 123
  2499.     dc.b    "(C) 1995 RESERVOIR GODS",0
  2500. menu_txt
  2501.     dc.b    "[F1]  VIEW SCREEN",13
  2502.     dc.b    "[F2]  VECTOR MENU",13
  2503.     dc.b    "[F3]  SAVE SCREEN (RIP)",13
  2504.     dc.b    "[F4]  SAVE SCREEN (GOD)",13,13
  2505.     dc.b    "[F10] EXIT RIPPER",13
  2506.     dc.b    0
  2507.  
  2508. variables_txt:
  2509.  
  2510. *                0         1         2         3         4         5         6         7         8
  2511. *                 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789
  2512.     dc.b    "COLS:               X:        Y:",13
  2513. ;    dc.b    "STWIDTH:      FALWIDTH:      ST-SHIFT:      SP-SHIFT:      HSCROLL:      SYNC:",13
  2514.     dc.b    "OFFSET:          WIDTH:      ST-SHIFT:      SP-SHIFT:      HSCROLL:      SYNC:",13
  2515.     dc.b    "HHT:      HBB:      HBE:      HDB:      HDE:      HSS:      HFS:      HEE:",13
  2516.     dc.b    "VFT:      VBB:      VBE:      VDB:      VDE:      VSS:      VCL:      VCO:",0
  2517.     even
  2518. word_txts
  2519.     dc.l    pic_x
  2520.     dc.w    6*23,0
  2521.     dc.l    pic_y
  2522.     dc.w    6*33,0
  2523.  
  2524.     dc.l    screen_vars+4        ;st width
  2525.     dc.w    6*9,1
  2526.     dc.l    screen_vars+6        ;030 width
  2527.     dc.w    6*24,1
  2528.     dc.l    screen_vars+10        ;sp shift
  2529.     dc.w    6*54,1
  2530.     dc.l    0
  2531.  
  2532. byte_txts
  2533.     dc.l    screen_vars+8        ;st shift
  2534.     dc.w    6*39,1
  2535.     dc.l    screen_vars+9
  2536.     dc.w    6*68,1
  2537.     dc.l    screen_vars+3        ;sync hz
  2538.     dc.w    6*79,1
  2539.     dc.l    0
  2540.  
  2541. intro_txt
  2542.     dc.b    27,"E"
  2543. *                123456789 123456789 12346789 123456789
  2544.     dc.b    "           RESERVOIR RIPPER",13,10
  2545.     dc.b    "           ----------------",13,10,13,10
  2546.     dc.b    "           CODED BY MR PINK",13,10,13,10
  2547.     dc.b    "       (C) 1995 RESERVOIR GODS"
  2548.     dc.b    0
  2549.     even
  2550.  
  2551. vecs_x    dc.l    34*6,52*6,69*6
  2552.  
  2553.  
  2554. vector_menu_txt:
  2555. *                         1         2         3         4         5        6
  2556. *                123456789 123456789 123456789 123456789 123456789 123*5789 123456789
  2557.     dc.b    "                                         VECTOR INSTALLATION MENU",13
  2558.     dc.b    "                                         ------------------------",13,13,13
  2559.     dc.b    "KEY  VECTOR                   INSTALL          REINSTALL          RESTORE",13
  2560.     dc.b    "---  ------                   -------          -[SHIFT]-          -[ALT]-",13,13
  2561.     DC.B    "F1   TIMER A",13
  2562.     DC.B    "F2   TIMER B",13
  2563.     DC.B    "F3   TIMER C",13
  2564.     DC.B    "F4   TIMER D",13
  2565.     DC.B    "F5   VBL",13
  2566.     DC.B    "F6   VBL QUEUE",13
  2567.     DC.B    "F7   TRAP #1",13
  2568.     DC.B    "F8   TRAP #2",13
  2569.     DC.B    "F9   TRAP #13",13
  2570.     DC.B    "F10  TRAP #14",13
  2571.     DC.B    "1    IKBD",13
  2572.     DC.B    "2    BLiTTER DONE",13
  2573.     DC.B    "3    LINE A",13
  2574.     DC.B    "4    LINE F",13
  2575.     DC.B    "5    HBL",13
  2576.     DC.B    "6    ERROR EXEPTIONS",13
  2577.     DC.B    "7    RS-232 INTERRUPTS",13
  2578.     DC.B    "8    MONO MONITOR DETECT",13
  2579.     DC.B    "9    MMU VECTORS",13
  2580.     DC.B    "0    TRACE EXCEPTION",13
  2581.     DC.B    "Q    ALT HELP",13
  2582.     DC.B    "W    FLOPPY/HD INTERRUPT",13
  2583.     DC.B    "E    RESET",13,13
  2584. *                         1         2         3         4         5        6
  2585. *                123456789 123456789 123456789 123456789 123456789 123*5789 123456789 123456789
  2586.     dc.b    "         [#] TOGGLE ALL                [SPACE] EXIT MENU            [ESC] CANCEL"
  2587.     dc.b    0
  2588.  
  2589. space_txt    dc.b    ' ',0
  2590. star_txt    dc.b    '*',0
  2591.  
  2592. on_txt    dc.b    27,"Y"
  2593. on_y    dc.b    32
  2594. on_x    dc.b    32
  2595.     dc.b    "[ON] ",0
  2596. off_txt    dc.b    27,"Y"
  2597. off_y    dc.b    32
  2598. off_x    dc.b    32
  2599.     dc.b    "[OFF]",0
  2600.  
  2601. enter_file_txt    dc.b    "ENTER FILENAME:",0
  2602. single_string    dc.b    'A',0
  2603.  
  2604.  
  2605. v0_txt    dc.b    "TIMER A",0
  2606. v1_txt    dc.b    "TIMER B",0
  2607. v2_txt    dc.b    "TIMER C",0
  2608. v3_txt    dc.b    "TIMER D",0
  2609. v4_txt    dc.b    "VBL",0
  2610. v5_txt    dc.b    "VBL QUEUE",0
  2611. v6_txt    dc.b    "TRAP #1",0
  2612. v7_txt    dc.b    "TRAP #2",0
  2613. v8_txt    dc.b    "TRAP #13",0
  2614. v9_txt    dc.b    "TRAP #14",0
  2615. v10_txt    dc.b    "IKBD",0
  2616. v11_txt    dc.b    "BLITTER",0
  2617. v12_txt    dc.b    "LINE A",0
  2618. v13_txt    dc.b    "LINE F",0
  2619. v14_txt    dc.b    "HBL",0
  2620. v15_txt    dc.b    "ERROR",0
  2621. v16_txt    dc.b    "RS232",0
  2622. v17_txt    dc.b    "MONO",0
  2623. v18_txt    dc.b    "MMU",0
  2624. v19_txt    dc.b    "TRACE",0
  2625. v20_txt    dc.b    "ALT_HELP",0
  2626. v21_txt    dc.b    "FDI",0
  2627. v22_txt    dc.b    "RESET",0
  2628.  
  2629. entry_txt    dc.b    "ENTERED VIA:",0
  2630.     even
  2631.  
  2632. v_txt_adrs:
  2633.     dc.l    v0_txt
  2634.     dc.l    v1_txt
  2635.     dc.l    v2_txt
  2636.     dc.l    v3_txt
  2637.     dc.l    v4_txt
  2638.     dc.l    v5_txt
  2639.     dc.l    v6_txt
  2640.     dc.l    v7_txt
  2641.     dc.l    v8_txt
  2642.     dc.l    v9_txt
  2643.     dc.l    v10_txt
  2644.     dc.l    v11_txt
  2645.     dc.l    v12_txt
  2646.     dc.l    v13_txt
  2647.     dc.l    v14_txt
  2648.     dc.l    v15_txt
  2649.     dc.l    v16_txt
  2650.     dc.l    v17_txt
  2651.     dc.l    v18_txt
  2652.     dc.l    v19_txt
  2653.     dc.l    v20_txt
  2654.     dc.l    v21_txt
  2655.     dc.l    v22_txt
  2656.  
  2657. gemdos_errors:
  2658.     dc.l    -1000,frerr
  2659.     dc.l    -1001,fwerr
  2660.  
  2661.     dc.l    -32,einvfn
  2662.     dc.l    -33,efilnf
  2663.     dc.l    -34,epthnf
  2664.     dc.l    -36,eaccdn
  2665.     dc.l    -37,eihndl
  2666.     dc.l    -39,ensmem
  2667.     dc.l    -40,eimba
  2668.     dc.l    -46,edrive
  2669.     dc.l    -48,ensame
  2670.     dc.l    -49,enmfil
  2671.     dc.l    -58,elocked
  2672.     dc.l    -59,enslock
  2673.     dc.l    -64,erange
  2674.     dc.l    -65,eintrn
  2675.     dc.l    -66,eplfmt
  2676.     dc.l    -67,egsbf
  2677.     dc.l    -80,eloop
  2678.     dc.l    -200,emount
  2679. end_gemdos_errors
  2680.  
  2681. einvfn:    dc.b    "INVALID FUNCTION",0
  2682. efilnf:    dc.b    "FILE NOT FOUND",0
  2683. epthnf:    dc.b    "PATH NOT FOUND",0
  2684. eaccdn: dc.b    "ACCESS DENIED",0
  2685. eihndl: dc.b    "INVALID HANDLE",0
  2686. enhndl:    dc.b    "NO MORE HANDLES",0
  2687. ensmem:    dc.b    "OUT OF MEMORY",0
  2688. eimba:    dc.b    "INVALID MEMORY BLOCK ADDRESS",0
  2689. edrive:    dc.b    "INVALID DRIVE",0
  2690. ensame:    dc.b    "CROSS DEVICE RENAME",0
  2691. enmfil:    dc.b    "NO MORE FILES",0
  2692. elocked: dc.b    "RECORD IS ALREADY LOCKED",0
  2693. enslock: dc.b    "INVALID LOCK REMOVAL REQUEST",0
  2694. erange:    dc.b    "RANGE ERROR",0
  2695. eintrn: dc.b    "INTERNAL ERROR",0
  2696. eplfmt: dc.b    "INVALID PROGRAM LOAD FORMAT",0
  2697. egsbf: dc.b    "MEMORY BLOCK GROWTH FAILURE",0
  2698. eloop: dc.b    "TOO MANY SYMBOLIC LINKS",0
  2699. emount: dc.b    "MOUNT POINT CROSSED",0
  2700. frerr:    dc.b    "FILE READ ERROR",0
  2701. fwerr:    dc.b    "FILE WRITE ERROR",0
  2702. unerr:    dc.b    "UNKNOWN ERROR",0
  2703.  
  2704. scan_code_table:
  2705. *                0123456789ABCDEF
  2706.     dc.b    '**1234567890_=**'
  2707.     dc.b    'QWERTYUIOP[]**AS'
  2708.     dc.b    'DFGHJKL:,`*#ZXCV'
  2709.     dc.b    'BNM,./*** ******'
  2710.     dc.b    '**********-***+*'    
  2711.     dc.b    '****************'
  2712.     dc.b    '\**()/*789456123'
  2713.     dc.b    '0.*'
  2714.     even
  2715.  
  2716. res_txts:
  2717.     dc.l    two_colour_txt
  2718.     dc.l    four_colour_txt
  2719.     dc.l    sixteen_colour_txt
  2720.     dc.l    ep_colour_txt
  2721.     dc.l    t_colour_txt
  2722.  
  2723. two_colour_txt:
  2724.     dc.b    "2 COLOUR",0
  2725. four_colour_txt:
  2726.     dc.b    "4 COLOUR",0
  2727. sixteen_colour_txt:
  2728.     dc.b    "16 COLOUR",0
  2729. ep_colour_txt
  2730.     dc.b    "256 COLOUR",0
  2731. t_colour_txt
  2732.     dc.b    "TRUE COLOUR",0
  2733.  
  2734. long_string
  2735.     dc.b    '0123456789',0
  2736.  
  2737. reg_string    dc.b    "A0 =",0
  2738.  
  2739.     even
  2740.  
  2741. new_adrs:
  2742.     dc.w    error_ex,$8
  2743.     dc.l    new_bus_error
  2744.  
  2745.     dc.w    line_a_ex,$28
  2746.     dc.l    new_line_a
  2747.  
  2748.     dc.w    line_f_ex,$2c
  2749.     dc.l    new_line_f
  2750.  
  2751.     dc.w    hbl_ex,$68
  2752.     dc.l    new_hbl
  2753.  
  2754.     dc.w    vbl_ex,$70
  2755.     dc.l    new_vbl
  2756.  
  2757.     dc.w    trap_1_ex,$84
  2758.     dc.l    new_trap_1
  2759.  
  2760.     dc.w    trap_2_ex,$88
  2761.     dc.l    new_trap_2
  2762.  
  2763.     dc.w    trap_13_ex,$b4
  2764.     dc.l    new_trap_13
  2765.  
  2766.     dc.w    trap_14_ex,$b8
  2767.     dc.l    new_trap_14
  2768.  
  2769.     dc.w    mmu_ex,$e0
  2770.     dc.l    new_mmu_config
  2771.     
  2772.     dc.w    rs232_ex,$100
  2773.     dc.l    new_rs232_cb
  2774.  
  2775.     dc.w    blitter_ex,$10c
  2776.     dc.l    new_blitter
  2777.     
  2778.     dc.w    timer_d_ex,$110
  2779.     dc.l    new_timer_d
  2780.  
  2781.     dc.w    timer_c_ex,$114
  2782.     dc.l    new_timer_c
  2783.  
  2784.     dc.w    ikbd_ex,$118
  2785.     dc.l    new_ikbd
  2786.  
  2787.     dc.w    fdi_ex,$11c
  2788.     dc.l    new_fdi
  2789.  
  2790.     dc.w    timer_b_ex,$120
  2791.     dc.l    new_timer_b
  2792.  
  2793.     dc.w    timer_a_ex,$134
  2794.     dc.l    new_timer_a
  2795.  
  2796.     dc.w    mono_ex,$13c
  2797.     dc.l    new_mono
  2798.  
  2799.     dc.w    alt_help_ex,$502
  2800.     dc.l    new_alt_help
  2801.     
  2802.     dc.w    reset_ex,$42a
  2803.     dc.l    new_reset
  2804.  
  2805.     dc.w    trace_ex,$24
  2806.     dc.l    new_trace
  2807.  
  2808.     dc.w    -1
  2809.  
  2810. key_ptr:    dc.l     key_buffer
  2811.  
  2812. ddir:  dc.b    "A:\*.*"
  2813.        ds.b    256
  2814.  
  2815. ***************************************************************************
  2816.     BSS
  2817. ***************************************************************************
  2818. god_mode        ds.b    1
  2819. new_config        ds.b    1
  2820. check_bit        ds.b    1
  2821. vec_family        ds.b    1
  2822. v_toggle_mode        ds.b    1
  2823. vga_flag        ds.b    1
  2824. current_vec        ds.b    1
  2825. begin_ripping_flag    ds.b    1
  2826. reinstall_flag        ds.b    1
  2827. mouse_moved    ds.b    1
  2828. key_pressed    ds.b    1
  2829. current_key    ds.b    1
  2830. j1_packet:    ds.b    1
  2831. j2_packet:    ds.b    1
  2832.         even
  2833.  
  2834. new_sr        ds.w    1
  2835. cur_pic_adr    ds.l    1
  2836.  
  2837. cmd_adr        ds.l    1
  2838.  
  2839. god_head    ds.b    6
  2840.  
  2841. pic_adr        ds.l    1
  2842. magic        ds.l    1
  2843. pic_res        ds.w    1
  2844. pic_x        ds.w    1
  2845. pic_y        ds.w    1
  2846. line_length    ds.l    1
  2847.  
  2848. physic        ds.l    1
  2849. old118        ds.l    1
  2850. mfp_sei        ds.l    1
  2851.  
  2852. pic_length    ds.l    1
  2853. file_handle    ds.w    1
  2854. text_counter    ds.w    1
  2855. old_vmode:    ds.w    1
  2856.  
  2857. mousek:            ds.w    1
  2858. mouse_key:        ds.w    1
  2859. mousex:            ds.w    1
  2860. mousey:            ds.w    1
  2861. mousex_min:        ds.w    1
  2862. mousex_max:        ds.w    1
  2863. mousey_min:        ds.w    1
  2864. mousey_max:        ds.w    1
  2865. key_cntr:        ds.w    1
  2866. key_table:        ds.b    128
  2867. key_buffer:          ds.b     256
  2868.  
  2869. file_name:        ds.b    256
  2870.  
  2871. old_system_vars    ds.b    256
  2872. cur_system_vars    ds.b    256
  2873.  
  2874. screen_vars    ds.b    50
  2875. pal_space    ds.b    (256*4)+(16*2)
  2876.  
  2877. colour_table    ds.w    256
  2878. install_bits    ds.b    24
  2879.         ds.b    1024
  2880. rip_stack    ds.l    4
  2881.         ds.b    256
  2882. screen_space    ds.b    16000
  2883. end_ripper