home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / MAGGIE22.ARJ / magg22st.msa / GOODIES / ST_INTRO.ZIP / M21.ST / GREETS.S next >
Text File  |  1996-09-12  |  8KB  |  470 lines

  1. ;
  2. ;
  3. ;    Greetings
  4. ;
  5.  
  6. ; NOTE: put the actual blitting on an Interrupt and make the
  7. ;  text buffers in normal time?
  8.  
  9. ; a6 is nearly always used as the start of greet_data buffers
  10. ;
  11.  
  12.  
  13. bufferheight = 32
  14.  
  15.         section    text
  16.  
  17. greetings
  18.         pea    (a6)
  19.         jsr    clear_screens
  20.         bsr    swap_screens
  21.  
  22.         move.l    #greet_draw,vbl_routine
  23.  
  24.         lea    greet_data_1,a6
  25.         bsr    clear_buffer
  26.         lea    greet_data_2,a6
  27.         bsr    clear_buffer
  28.  
  29.         lea    greetings_list,a0
  30. greet_loop:
  31.         lea    greet_data_1,a6
  32.         bsr    check_for_new
  33.         lea    greet_data_2,a6
  34.         bsr    check_for_new
  35.         lea    greet_data_3,a6
  36.         bsr    check_for_new
  37.         bra    greet_loop
  38.  
  39.  
  40. greet_done:
  41.         move.w    #200,d5            ;wait enough
  42. .loop        bsr    wait_vbl
  43.         dbf    d5,.loop
  44.  
  45.         clr.l    vbl_routine
  46.         move.l    (a7)+,a6
  47.         rts
  48.  
  49.  
  50.  
  51. check_for_new:
  52.         cmp.w    #1,onflag(a6)
  53.         bne.s    .dontdo            ;buffer switched off
  54.  
  55.         move.w    #-1,onflag(a6)        ;switch off temporarily
  56.         move.l    a0,-(a7)
  57.         bsr    clear_buffer
  58.         move.l    (a7)+,a0
  59.         bsr    buffer_text
  60.  
  61.         move.l    a0,-(a7)
  62.         bsr    init_greet
  63.  
  64.         move.w    #0,onflag(a6)        ;put it on
  65.         move.l    (a7)+,a0
  66. .dontdo
  67.         move.b    (a0),d0
  68.         bmi.s    .finished
  69.  
  70.         cmp.b    #1,d0
  71.         bne.s    .1
  72.         move.w    #1,greet_data_1+onflag
  73.         addq.l    #1,a0
  74. .1        cmp.b    #2,d0
  75.         bne.s    .2
  76.         move.w    #1,greet_data_2+onflag
  77.         addq.l    #1,a0
  78. .2        cmp.b    #3,d0
  79.         bne.s    .3
  80.         move.w    #1,greet_data_3+onflag
  81.         addq.l    #1,a0
  82. .3        cmp.b    #4,d0
  83.         bne.s    .4
  84.         move.w    #1,greet_data_4+onflag
  85.         addq.l    #1,a0
  86. .4        rts
  87.  
  88.  
  89.  
  90.  
  91. .finished:    move.l    (a7)+,d0        ;oops
  92.         bra    greet_done
  93.         rts
  94.  
  95.  
  96. ;--------------------------------------------------------------
  97. greet_draw:
  98.         lea    greet_data_1,a6
  99.         bsr    draw_greet
  100.         lea    greet_data_2,a6
  101.         bsr    draw_greet
  102.         lea    greet_data_3,a6
  103.         bsr    draw_greet
  104.         lea    greet_data_4,a6
  105.         bsr    draw_greet
  106.  
  107.         bsr    swap_screens
  108. ; Can't wait for a vbl. We're in the interrupt, dummy!
  109.         rts
  110.  
  111.  
  112.  
  113. get_height:
  114.         movem.l    greet_height(a6),d0/d1/d2/d3/d4
  115.         move.l    d3,d4
  116.         move.l    d0,d3            ;save old coords...
  117.  
  118.         add.l    d1,d0
  119.         add.l    d2,d1
  120.         movem.l    d0/d1/d2/d3/d4,greet_height(a6)
  121.         rts
  122.  
  123. ;--------------------------------------------------------------
  124. clear_difference:
  125.         cmp.w    d0,d4            ;old height > new height
  126.         bgt    .clear_bottom
  127.  
  128.         sub.w    d4,d0            ;get difference
  129.         exg.l    d0,d4            ;swap 'em
  130.                         ;d4 = difference
  131.                         ;d0 = top height
  132.         bsr    fix_copy_regs
  133.         bsr    clearit
  134.         rts
  135. .clear_bottom:
  136.         sub.w    d0,d4
  137.         add.w    #bufferheight,d0            ;now at bottom
  138.         bsr    fix_copy_regs
  139.         bsr    clearit
  140.         rts
  141.  
  142.  
  143. ;--------------------------------------------------------------
  144. clearit:
  145.         subq.w    #1,d1
  146.         bmi.s    .dontdo
  147.  
  148.         move.l    logic,a1
  149.         add.w    bitoffset(a6),a1
  150.         mulu.w    #160,d0
  151.         add.l    d0,a1
  152.         moveq    #0,d2
  153. .copy:
  154. o        set    0
  155.         rept    20
  156.         move.w    d2,o(a1)
  157. o        set    o+8
  158.         endr
  159.  
  160.         lea    160(a1),a1
  161.         dbf    d1,.copy
  162.  
  163. .dontdo        rts
  164.  
  165.  
  166.  
  167. ;--------------------------------------------------------------
  168.  
  169. copy_to_screen:
  170.         move.w    #bufferheight,d4    ;intended height
  171.         bsr    fix_copy_regs
  172.  
  173.         move.l    logic,a1
  174.         add.w    bitoffset(a6),a1
  175.  
  176.         mulu.w    #160,d0
  177.         add.l    d0,a1
  178.         subq.w    #1,d1
  179.         bmi.s    .dontdo
  180. .copy:
  181. o        set    0
  182.         rept    20
  183.         move.w    (a0)+,o(a1)
  184. o        set    o+8
  185.         endr
  186.  
  187.         lea    160(a1),a1
  188.         dbf    d1,.copy
  189. .dontdo
  190.         rts
  191.  
  192.  
  193. fix_copy_regs:
  194.         cmp.w    #200,d0
  195.         bge.s    .ohdear
  196.         move.w    #200,d1
  197.         sub.w    d0,d1
  198.         cmp.w    d4,d1
  199.         blt.s    .clipped
  200.         move.w    d4,d1            ;max of bufferheight
  201. .clipped:        
  202.         rts
  203. .ohdear:
  204.         moveq    #0,d0
  205.         moveq    #0,d1
  206.         rts
  207.  
  208.  
  209. ; call with a0 - text string
  210.  
  211. buffer_text:
  212.         move.w    #0,text_x
  213.         move.w    #0,text_y
  214.  
  215. .get_letter
  216.         moveq    #0,d2
  217.         move.b    (a0)+,d2        ;d0 = letter to do
  218.         beq    .text_done
  219.         moveq    #0,d1
  220.         sub.w    #" ",d2
  221.         move.w    #Char_Width,d1
  222.         lea    text_convert_table,a5
  223.         move.b    (a5,d2.w),d2
  224.         bpl.s    .ok2
  225.         move.w    #Space_Width,d1
  226.         bra    .dont_draw
  227. .ok2
  228.         move.w    d1,text_to_add
  229.         pea    (a0)
  230.           bsr       .text_draw_letter
  231.         move.l    (a7)+,a0
  232. .dont_draw:
  233.         move.w    text_to_add,d0
  234.         add.w    d0,text_x
  235.         bra    .get_letter
  236.  
  237. .text_done:    ;subq.l    #1,a0
  238.         rts
  239.  
  240. ;--------------------------------------------------------------
  241. .text_draw_letter:
  242.         movem.w    text_x,d0/d1
  243.         mulu.w    #8*48,d2
  244.         add.l    #text_font+(8*8),d2
  245.         move.l    d2,a0
  246.  
  247.         move.l    textbuffer(a6),A1
  248.  
  249.         mulu.w    #40,D1            ;can't be bothered...
  250.         add.l    D1,A1
  251.  
  252.         move.w    D0,D1
  253.         and.w    #$F,D0            ;d0 = shift amt
  254.  
  255.         move.w    d0,d7
  256.         lea    text_mask_table,a5
  257.  
  258.         add.w    d7,d7
  259.         move.w    0(a5,d7.w),d6        ;left mask
  260.         move.w    d6,d7
  261.         not.w    d7
  262.  
  263.         eor.w    d0,d1            ;d1 = x-offset
  264.         asr.w    #3,d1            ;16 pixels = 2 bytes
  265.         add.w    d1,a1
  266.  
  267.         moveq    #bufferheight-1,d5
  268. .doline:
  269.         move.l    (a0)+,d1        ;fiddle with
  270.         or.l    (a0)+,d1        ;convert 2 oneplane
  271.         ror.l    d0,d1
  272.         eor.w    d1,2(a1)        ;middle section sorted...
  273.         swap    d1
  274.         move.w    d1,d3
  275.         and.w    d6,d3
  276.         eor.w    d3,0(a1)
  277.         and.w    d7,d1
  278.         eor.w    d1,4(a1)
  279.         lea    40(a1),a1
  280.         dbf    d5,.doline
  281.         rts
  282.  
  283. clear_buffer:
  284.         move.l    textbuffer(a6),a0
  285.         move.w    #(40*bufferheight)/4-1,d0
  286.         moveq    #0,d1
  287. .clear        move.l    d1,(a0)+
  288.         dbf    d0,.clear
  289.         rts
  290.  
  291. get_random_number:
  292.         tst.w    random_done
  293.         bne.s    .ok
  294.         move.w    $468.w,random_seed
  295.         st    random_done
  296. .ok        movem.w    random_seed,d0/d1/d2
  297.         add.w    d2,d1
  298.         rol.w    #5,d2
  299.         add.w    #$8231,d2
  300.         ror.w    #3,d1
  301.         sub.w    #$3279,d1
  302.         sub.w    d1,d0
  303.         movem.w    d0/d1/d2,random_seed
  304.         rts
  305.  
  306.  
  307. init_greet:
  308.         movem.l    d0-a6,-(a7)
  309.         bsr    get_random_number
  310.         and.w    #%111,d0
  311.         mulu.w    #2*4,d0
  312.         add.l    #greet_height_init,d0
  313.         move.l    d0,a1
  314.  
  315.         movem.l    (a1),d5-d6
  316.  
  317.         ;bsr    get_random_number
  318.         ;ext.l    d0
  319.         ;ext.l    d1
  320.         ;asr.l    #5,d0
  321.         ;asr.l    #5,d1
  322.         ;add.l    d0,d5
  323.         ;add.l    d1,d6
  324.         movem.l    d5-d6,greet_speed(a6)
  325.  
  326.         move.l    #200*$10000,d7
  327.  
  328.         move.l    d7,greet_height(a6)
  329.         move.l    d7,old_height1(a6)
  330.         move.l    d7,old_height2(a6)
  331.         movem.l    (a7)+,d0-a6
  332.         rts
  333.  
  334. draw_greet:
  335.         tst.w    onflag(a6)        ;-1 = channel switched off
  336.         bne    .noton            ;0 = onscreen
  337.  
  338.         bsr    get_height
  339.         swap    d0
  340.         swap    d4
  341.         bsr    clear_difference
  342.         move.l    textbuffer(a6),a0
  343.         move.w    greet_height(a6),d0
  344.         bsr    copy_to_screen
  345.  
  346.         move.w    greet_height(a6),d0
  347.         cmp.w    #220,d0
  348.         blt.s    .stillon        ;gone off?
  349.  
  350.         move.w    #1,onflag(a6)        ;1 = signal new needed
  351. .stillon
  352.         rts
  353.  
  354. .noton:
  355. .dontchange:
  356.         rts
  357.  
  358.  
  359. greetings_list:
  360.         dc.b    ' Muchos Hellos to',0
  361.         dc.b    'Reservoir Gods',0
  362.         dc.b    '             ExA',0
  363.         dc.b    '     Absence',0
  364.         dc.b    '        Aura',0
  365.         dc.b    ' Arto et Andres',0
  366.         dc.b    2
  367.         dc.b    '    EkO     ',0
  368.         dc.b    '  Adrenaline',0
  369.         dc.b    '         Niels',0
  370.         dc.b    '     Therapy',0
  371.         dc.b    '          Hydroxid',0
  372.         dc.b    'Psychosis',0
  373.         dc.b    '         Lazer',0
  374.         dc.b    '     Inter',0
  375.         dc.b    '        T S C C',0
  376.         dc.b    '    Stax',0
  377.         dc.b    '       Aggression',0
  378.         dc.b    'NoCrew',0
  379.         dc.b    '      Impulse',0
  380.         dc.b    3
  381.         dc.b    'Oxyron',0
  382.         dc.b    '    Sanity',0
  383.         dc.b    '         Sentry',0
  384.         dc.b    '  N P G',0
  385.         dc.b    '           F O G',0
  386.         dc.b    '    W E G',0
  387.         dc.b    '           Igloo',0
  388.         dc.b    '        New Trend',0
  389.         dc.b    4
  390.         dc.b    'Senior Dads',0
  391.         dc.b    '     DBA',0
  392.         dc.b    '      STosser Mag',0
  393.         dc.b    '          A D M',0
  394.         dc.b    '  Arnel',0
  395.         dc.b    '        Quasar',0
  396.         dc.b    '  Flinny',0
  397.         dc.b    '     Goodmans PDL',0
  398.         dc.b    '            McFly',0
  399.         dc.b    ' John and his wife',0
  400.         dc.b    -1
  401.  
  402.         even
  403. greetings_palette:
  404.         dc.w    0
  405.         dcb.w    15,$0fff
  406.  
  407.  
  408.  
  409.         rsreset
  410. greet_height:    rs.l    1
  411. greet_speed    rs.l    1
  412.         rs.l    1
  413. old_height1    rs.l    1
  414. old_height2    rs.l    1
  415. textbuffer    rs.l    1
  416. onflag        rs.w    1
  417. bitoffset    rs.w    1
  418.  
  419.  
  420. greet_data_1    ds.b    textbuffer
  421.         dc.l    textbuffer1
  422.         dc.w    1            ;signal new needed
  423.         dc.w    0
  424. greet_data_2    ds.b    textbuffer
  425.         dc.l    textbuffer2
  426.         dc.w    -1
  427.         dc.w    2
  428. greet_data_3    ds.b    textbuffer
  429.         dc.l    textbuffer3
  430.         dc.w    -1
  431.         dc.w    4
  432. greet_data_4    ds.b    textbuffer
  433.         dc.l    textbuffer4
  434.         dc.w    -1
  435.         dc.w    6
  436.  
  437. spconst        equ    $d000
  438. spconst2    equ    $3000
  439.  
  440. greet_height_init:
  441.         dc.l     -8*spconst
  442.         dc.l     +1*spconst2
  443.  
  444.         dc.l     -10*spconst
  445.         dc.l     +2*spconst2
  446.  
  447.         dc.l    -14*spconst
  448.         dc.l     +2*spconst2
  449.  
  450.         dc.l     -9*spconst
  451.         dc.l     +1*spconst2
  452.  
  453.         dc.l     -5*spconst
  454.         dc.l     +1*spconst2/2
  455.  
  456.         dc.l     -10*spconst
  457.         dc.l     +2*spconst2
  458.  
  459.         dc.l    -14*spconst
  460.         dc.l     +2*spconst2
  461.  
  462.         dc.l     -6*spconst
  463.         dc.l     +1*spconst2/2
  464.  
  465.  
  466.         section    bss
  467. random_done        ds.w    1
  468. random_seed        ds.w    3
  469.  
  470.