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