home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / RiscPc / jeux / biohazard.arc / s / AffLine4 < prev    next >
Text File  |  1994-06-27  |  15KB  |  520 lines

  1. ; Use the GET directive to include register definitions as if typed here
  2.  
  3.       KEEP
  4.           GET     h.WolfReg
  5.  
  6. ; Use the GET directive to include a list of SWI names as if typed here
  7.  
  8.           GET     h.SWInames
  9.  
  10. ; Area name C$$code advisable as wanted to link with C output
  11.  
  12.           AREA    |C$$code|, CODE, READONLY
  13.  
  14. ; Export global symbols
  15.  
  16.           IMPORT  |x$stack_overflow|
  17.        EXPORT  |DrawScaledLine|
  18.       EXPORT  |BigRedrawScreen|
  19.  
  20. SmallestHeight
  21.           DCD 0
  22.  
  23. DSLineX   DCB     "DrawScaledLine", 0
  24.           ALIGN
  25. DSLineY   DCD     &ff000000 + DSLineY - DSLineX
  26.  
  27. ;scale line of graphics block to height value.
  28. ;on entry -
  29. ;           r0 = pointer to Plot_Block where :-
  30. ;           0 - 3  = clipped heights of lines to draw
  31. ;           4 - 7  = gradients of lines to draw
  32. ;           8 - 11 = gradient counters (8 bit resolution)
  33. ;           12- 15 = data addresses of graphics data
  34. ;           16     = screen address
  35.  
  36. |DrawScaledLine|
  37.       STMFD   r13!,{r0-r12,link}
  38.  
  39.       LDMIA   r0,{r1-r4}
  40.  
  41.       ;find smallest height, store in r7
  42.       MOV     r7,r1
  43.       CMP     r2,r7
  44.       MOVLT   r7,r2
  45.       CMP     r3,r7
  46.       MOVLT   r7,r3
  47.       CMP     r4,r7
  48.       MOVLT   r7,r4
  49.       ADR     r6,SmallestHeight
  50.       STR     r7,[r6]
  51.  
  52.       ;clear r11 for as null pointer in byteline
  53.       MOV     r11,#0
  54.  
  55.       ;draw upper section of line 1
  56.       LDR     r2,[r0,#16]      ; load gradient of line 1
  57.       LDR     r3,[r0,#32]      ; load gradient counter for line 1
  58.       LDR     r4,[r0,#48]      ; load data address of data for line 1
  59.  
  60.       ADD     r3,r3,r4,LSL #8  ; combine gradient counter & data addr
  61.       SUB     r14,r1,r7        ; get height offset against smallest height
  62.       MOVS    r14,r14,LSR #1
  63.       STREQ   r3,[r0,#32]      ; save gradient counter for line 1
  64.           BEQ     DrawLine2
  65.  
  66.       LDR     r5,[r0,#64]      ; load screen address
  67.       RSB     r6,r1,#255       ; find distance from top of screen
  68.       MOV     r6,r6,LSR #1
  69.       MOV     r8,r6,LSL #6     ; multiply height offset by 64
  70.       ADD     r6,r8,r6,LSL #8  ; add to height offset * *256
  71.       ADD     r5,r5,r6         ; add to screen base
  72.       MOV     r1,r14
  73.       BL      DrawByteLine
  74.       STR     r3,[r0,#32]      ; save gradient counter for line 1
  75.  
  76. DrawLine2
  77.       ;draw upper section of line 2
  78.       LDR     r2,[r0,#20]      ; load gradient of line 2
  79.       LDR     r3,[r0,#36]      ; load gradient counter for line 2
  80.       LDR     r4,[r0,#52]      ; load data address of data for line 2
  81.  
  82.       ADD     r3,r3,r4,LSL #8  ; combine gradient counter & data addr
  83.  
  84.       LDR     r1,[r0,#4]
  85.       SUB     r14,r1,r7        ; get height offset against smallest height
  86.       MOVS    r14,r14,LSR #1
  87.       STREQ   r3,[r0,#36]      ; save gradient counter for line 2
  88.           BEQ     DrawLine3
  89.  
  90.       LDR     r5,[r0,#64]      ; load screen address
  91.       RSB     r6,r1,#255       ; find distance from top of screen
  92.       MOV     r6,r6,LSR #1
  93.       MOV     r8,r6,LSL #6     ; multiply height offset by 64
  94.       ADD     r6,r8,r6,LSL #8  ; add to height offset * 256
  95.       ADD     r5,r5,r6         ; add to screen base
  96.       ADD     r5,r5,#1
  97.       MOV     r1,r14
  98.       BL      DrawByteLine
  99.       STR     r3,[r0,#36]      ; save gradient counter for line 2
  100.  
  101. DrawLine3
  102.       ;draw upper section of line 3
  103.       LDR     r2,[r0,#24]      ; load gradient of line 3
  104.       LDR     r3,[r0,#40]      ; load gradient counter for line 3
  105.       LDR     r4,[r0,#56]      ; load data address of data for line 3
  106.  
  107.       ADD     r3,r3,r4,LSL #8     ; combine gradient counter & data addr
  108.  
  109.       LDR     r1,[r0,#8]
  110.       SUB     r14,r1,r7        ; get height offset against smallest height
  111.       MOVS    r14,r14,LSR #1
  112.       STREQ   r3,[r0,#40]      ; save gradient counter for line 3
  113.           BEQ    DrawLine4
  114.  
  115.       LDR     r5,[r0,#64]      ; load screen address
  116.       RSB     r6,r1,#255       ; find distance from top of screen
  117.       MOV     r6,r6,LSR #1
  118.       MOV     r8,r6,LSL #6     ; multiply height offset by 64
  119.       ADD     r6,r8,r6,LSL #8  ; add to height offset * 256
  120.       ADD     r5,r5,r6         ; add to screen base
  121.       ADD     r5,r5,#2
  122.       MOV     r1,r14
  123.       BL      DrawByteLine
  124.       STR     r3,[r0,#40]      ; save gradient counter for line 3
  125.  
  126. DrawLine4
  127.       ;draw upper section of line 4
  128.       LDR     r1,[r0,#12]
  129.       LDR     r2,[r0,#28]      ; load gradient of line 4
  130.       LDR     r3,[r0,#44]      ; load gradient counter for line 4
  131.       LDR     r4,[r0,#60]      ; load data address of data for line 4
  132.  
  133.       ADD     r3,r3,r4,LSL #8     ; combine gradient counter & data addr
  134.       SUB     r14,r1,r7        ; get height offset against smallest height
  135.       MOVS    r14,r14,LSR #1
  136.       STREQ   r3,[r0,#44]      ; save gradient counter for line 4
  137.           BEQ    DrawMainBlock
  138.  
  139.       LDR     r5,[r0,#64]      ; load screen address
  140.       RSB     r6,r1,#255       ; find distance from top of screen
  141.       MOV     r6,r6,LSR #1
  142.       MOV     r8,r6,LSL #6     ; multiply height offset by 64
  143.       ADD     r6,r8,r6,LSL #8  ; add to height offset * 256
  144.       ADD     r5,r5,r6         ; add to screen base
  145.       ADD     r5,r5,#3
  146.       MOV     r1,r14
  147.       BL      DrawByteLine
  148.       STR     r3,[r0,#44]      ; save gradient counter for line 4
  149.  
  150. DrawMainBlock
  151.  
  152.           ADR     r14,SmallestHeight
  153.           LDR     r14,[r14]
  154.       LDR     r12,[r0,#64]      ; load screen address
  155.  
  156.           ;compute screen address
  157.       LDR     r5,[r0,#64]      ; load screen address
  158.       RSB     r6,r14,#255      ; find distance from top of screen
  159.       MOV     r6,r6,LSR #1
  160.       MOV     r8,r6,LSL #6     ; multiply height offset by 64
  161.       ADD     r6,r8,r6,LSL #8  ; add to height offset * 256
  162.       ADD     r12,r5,r6        ; add to screen base
  163.  
  164.           ADD     r0,r0,#16
  165.       LDMIA   r0!,{r1-r4}      ; load up gradients
  166.       LDMIA      r0,{r5-r8}       ; load up gradient counters + data addrs
  167.       MOV      r11,#0       ; clear r11 for use as base reg
  168.  
  169.       ;decide which routine to use, based on smallest height
  170.       ;CMP     r14,#254
  171.       ;BGE     FourStartPlotBlock
  172.       CMP     r14,#128
  173.       BGE     TwoStartPlotBlock
  174.       
  175. StartPlotBlock
  176.  
  177.  
  178.       LDRB    r10,[r11,r5,LSR #8]
  179.       LDRB    r9,[r11,r6,LSR #8]
  180.       ADD     r10,r10,r9,LSL #8
  181.       LDRB    r9,[r11,r7,LSR #8]
  182.       ADD     r10,r10,r9,LSL #16
  183.       LDRB    r9,[r11,r8,LSR #8]
  184.       ADD     r10,r10,r9,LSL #24
  185.       STR     r10,[r12],#320
  186.       ADD     r5,r5,r1
  187.       ADD     r6,r6,r2
  188.       ADD     r7,r7,r3
  189.       ADD     r8,r8,r4
  190.       SUBS    r14,r14,#1
  191.       BEQ     EndPlotBlock
  192.  
  193.       LDRB    r10,[r11,r5,LSR #8]
  194.       LDRB    r9,[r11,r6,LSR #8]
  195.       ADD     r10,r10,r9,LSL #8
  196.       LDRB    r9,[r11,r7,LSR #8]
  197.       ADD     r10,r10,r9,LSL #16
  198.       LDRB    r9,[r11,r8,LSR #8]
  199.       ADD     r10,r10,r9,LSL #24
  200.       STR     r10,[r12],#320
  201.       ADD     r5,r5,r1
  202.       ADD     r6,r6,r2
  203.       ADD     r7,r7,r3
  204.       ADD     r8,r8,r4
  205.       SUBS    r14,r14,#1
  206.       BEQ     EndPlotBlock
  207.  
  208.       LDRB    r10,[r11,r5,LSR #8]
  209.       LDRB    r9,[r11,r6,LSR #8]
  210.       ADD     r10,r10,r9,LSL #8
  211.       LDRB    r9,[r11,r7,LSR #8]
  212.       ADD     r10,r10,r9,LSL #16
  213.       LDRB    r9,[r11,r8,LSR #8]
  214.       ADD     r10,r10,r9,LSL #24
  215.       STR     r10,[r12],#320
  216.       ADD     r5,r5,r1
  217.       ADD     r6,r6,r2
  218.       ADD     r7,r7,r3
  219.       ADD     r8,r8,r4
  220.       SUBS    r14,r14,#1
  221.       BEQ     EndPlotBlock
  222.  
  223.       LDRB    r10,[r11,r5,LSR #8]
  224.       LDRB    r9,[r11,r6,LSR #8]
  225.       ADD     r10,r10,r9,LSL #8
  226.       LDRB    r9,[r11,r7,LSR #8]
  227.       ADD     r10,r10,r9,LSL #16
  228.       LDRB    r9,[r11,r8,LSR #8]
  229.       ADD     r10,r10,r9,LSL #24
  230.       STR     r10,[r12],#320
  231.       ADD     r5,r5,r1
  232.       ADD     r6,r6,r2
  233.       ADD     r7,r7,r3
  234.       ADD     r8,r8,r4
  235.       SUBS    r14,r14,#1
  236.       BEQ     EndPlotBlock
  237.  
  238.       LDRB    r10,[r11,r5,LSR #8]
  239.       LDRB    r9,[r11,r6,LSR #8]
  240.       ADD     r10,r10,r9,LSL #8
  241.       LDRB    r9,[r11,r7,LSR #8]
  242.       ADD     r10,r10,r9,LSL #16
  243.       LDRB    r9,[r11,r8,LSR #8]
  244.       ADD     r10,r10,r9,LSL #24
  245.       STR     r10,[r12],#320
  246.       ADD     r5,r5,r1
  247.       ADD     r6,r6,r2
  248.       ADD     r7,r7,r3
  249.       ADD     r8,r8,r4
  250.       SUBS    r14,r14,#1
  251.       BEQ     EndPlotBlock
  252.  
  253.       LDRB    r10,[r11,r5,LSR #8]
  254.       LDRB    r9,[r11,r6,LSR #8]
  255.       ADD     r10,r10,r9,LSL #8
  256.       LDRB    r9,[r11,r7,LSR #8]
  257.       ADD     r10,r10,r9,LSL #16
  258.       LDRB    r9,[r11,r8,LSR #8]
  259.       ADD     r10,r10,r9,LSL #24
  260.       STR     r10,[r12],#320
  261.       ADD     r5,r5,r1
  262.       ADD     r6,r6,r2
  263.       ADD     r7,r7,r3
  264.       ADD     r8,r8,r4
  265.       SUBS    r14,r14,#1
  266.        BNE     StartPlotBlock
  267.  
  268.  
  269. EndPlotBlock
  270.  
  271.           STMIA   r0,{r5-r8}       ; save gradient/data combos
  272.           STR     r12,[r0,#32]       ; save screen address
  273.           SUB     r0,r0,#32        ; reset pointer to start of height data
  274.           ADR     r6,SmallestHeight
  275.           LDR     r6,[r6]
  276.  
  277.        ;draw lower section of line 1
  278.        MOV     r5,r12       ; get old screen address
  279.           LDR     r1,[r0]          ; get height of line 1
  280.           SUB     r1,r1,r6         ; length = height - smallest height
  281.           MOVS    r1,r1,LSR #1     ; divide by 2
  282.           BEQ     LowerLine2
  283.        LDR     r2,[r0,#16]      ; load gradient of line 1
  284.       LDR     r3,[r0,#32]      ; load gradient/data combo for line 1
  285.       LDR     r4,[r0,#48]      ; load data address of data for line 1
  286.           BL      DrawByteLine
  287.  
  288. LowerLine2
  289.       ;draw lower section of line 2
  290.       ADD     r5,r12,#1
  291.           LDR     r1,[r0,#4]       ; get height of line 2
  292.           SUB     r1,r1,r6         ; length = height - smallest height
  293.           MOVS    r1,r1,LSR #1     ; divide by 2
  294.           BEQ     LowerLine3
  295.        LDR     r2,[r0,#20]      ; load gradient of line 2
  296.       LDR     r3,[r0,#36]      ; load gradient/data combo for line 2
  297.       LDR     r4,[r0,#52]      ; load data address of data for line 2
  298.           BL      DrawByteLine
  299.  
  300. LowerLine3
  301.       ;draw lower section of line 3
  302.       ADD     r5,r12,#2
  303.           LDR     r1,[r0,#8]       ; get height of line 3
  304.           SUB     r1,r1,r6         ; length = height - smallest height
  305.           MOVS    r1,r1,LSR #1     ; divide by 2
  306.           BEQ     LowerLine4
  307.        LDR     r2,[r0,#24]      ; load gradient of line 3
  308.       LDR     r3,[r0,#40]      ; load gradient/data combo for line 3
  309.       LDR     r4,[r0,#56]      ; load data address of data for line 3
  310.           BL      DrawByteLine
  311.  
  312. LowerLine4
  313.       ;draw lower section of line 4
  314.       ADD     r5,r12,#3
  315.           LDR     r1,[r0,#12]      ; get height of line 1
  316.           SUB     r1,r1,r6         ; length = height - smallest height
  317.           MOVS    r1,r1,LSR #1     ; divide by 2
  318.           BEQ     EndDSLine
  319.        LDR     r2,[r0,#28]      ; load gradient of line 1
  320.       LDR     r3,[r0,#44]      ; load gradient/data combo for line 1
  321.       LDR     r4,[r0,#60]      ; load data address of data for line 1
  322.           BL      DrawByteLine
  323.  
  324. EndDSLine
  325.           LDMFD   r13!,{r0-r12,pc}
  326.  
  327. ;Plot pixels loading one in four
  328. FourStartPlotBlock
  329.  
  330.  
  331.       LDRB    r10,[r11,r5,LSR #8]
  332.       LDRB    r9,[r11,r6,LSR #8]
  333.       ADD     r10,r10,r9,LSL #8
  334.       LDRB    r9,[r11,r7,LSR #8]
  335.       ADD     r10,r10,r9,LSL #16
  336.       LDRB    r9,[r11,r8,LSR #8]
  337.       ADD     r10,r10,r9,LSL #24
  338.       STR     r10,[r12],#320
  339.       STR     r10,[r12],#320
  340.       STR     r10,[r12],#320
  341.       STR     r10,[r12],#320
  342.       ADD     r5,r5,r1,LSL #2
  343.       ADD     r6,r6,r2,LSL #2
  344.       ADD     r7,r7,r3,LSL #2
  345.       ADD     r8,r8,r4,LSL #2
  346.       SUBS    r14,r14,#4
  347.       CMP     r14,#0
  348.       BLE     EndPlotBlock
  349.           B       FourStartPlotBlock
  350.  
  351. ;Plot pixels loading one in two
  352. TwoStartPlotBlock
  353.  
  354.  
  355.       LDRB    r10,[r11,r5,LSR #8]
  356.       LDRB    r9,[r11,r6,LSR #8]
  357.       ADD     r10,r10,r9,LSL #8
  358.       LDRB    r9,[r11,r7,LSR #8]
  359.       ADD     r10,r10,r9,LSL #16
  360.       LDRB    r9,[r11,r8,LSR #8]
  361.       ADD     r10,r10,r9,LSL #24
  362.       STR     r10,[r12],#320
  363.       STR     r10,[r12],#320
  364.       ADD     r5,r5,r1,LSL #1
  365.       ADD     r6,r6,r2,LSL #1
  366.       ADD     r7,r7,r3,LSL #1
  367.       ADD     r8,r8,r4,LSL #1
  368.       SUBS    r14,r14,#2
  369.       CMP     r14,#0
  370.       BLE     EndPlotBlock
  371.           B       TwoStartPlotBlock
  372.  
  373.           
  374. DBLineX   DCB     "DrawByteLine", 0
  375.           ALIGN
  376. DBLineY   DCD     &ff000000 + DBLineY - DBLineX
  377.  
  378. ;scale line of graphics block to height value.
  379. ;on entry -
  380. ;           r1  = length of line to draw
  381. ;           r2  = gradient of line
  382. ;           r3  = gradient counter plus data address
  383. ;        r5  = screen address
  384. ;           r14 = return address
  385. ;
  386. ;on exit -
  387. ;           r1  = zero
  388. ;           r2  = gradient of line
  389. ;           r3  = gradient counter plus data address, updated
  390. ;           r5  = updated screen address
  391. ;           r14 = return address
  392. ;
  393.  
  394. DrawByteLine
  395.  
  396.           LDRB  r10,[r11,r3,LSR #8]
  397.           STRB  r10,[r5],#320
  398.           ADD   r3,r3,r2
  399.       SUBS  r1,r1,#1
  400.       BEQ   EndByteLine
  401.           LDRB  r10,[r11,r3,LSR #8]
  402.           STRB  r10,[r5],#320
  403.           ADD   r3,r3,r2
  404.       SUBS  r1,r1,#1
  405.       BEQ   EndByteLine
  406.           LDRB  r10,[r11,r3,LSR #8]
  407.           STRB  r10,[r5],#320
  408.           ADD   r3,r3,r2
  409.       SUBS  r1,r1,#1
  410.       BEQ   EndByteLine
  411.           LDRB  r10,[r11,r3,LSR #8]
  412.           STRB  r10,[r5],#320
  413.           ADD   r3,r3,r2
  414.       SUBS  r1,r1,#1
  415.           BEQ   EndByteLine
  416.           LDRB  r10,[r11,r3,LSR #8]
  417.           STRB  r10,[r5],#320
  418.           ADD   r3,r3,r2
  419.       SUBS  r1,r1,#1
  420.       BEQ   EndByteLine
  421.           LDRB  r10,[r11,r3,LSR #8]
  422.           STRB  r10,[r5],#320
  423.           ADD   r3,r3,r2
  424.       SUBS  r1,r1,#1
  425.       BEQ   EndByteLine
  426.           LDRB  r10,[r11,r3,LSR #8]
  427.           STRB  r10,[r5],#320
  428.           ADD   r3,r3,r2
  429.       SUBS  r1,r1,#1
  430.       BEQ   EndByteLine
  431.           LDRB  r10,[r11,r3,LSR #8]
  432.           STRB  r10,[r5],#320
  433.           ADD   r3,r3,r2
  434.       SUBS  r1,r1,#1
  435.       BNE   DrawByteLine
  436.  
  437. EndByteLine
  438.  
  439.           MOV   r15,r14            ; return to caller...
  440.  
  441. BRDScreenX DCB     "BigRedrawScreen", 0
  442.            ALIGN
  443. BRDScreenY DCD     &ff000000 + BRDScreenY - BRDScreenX
  444.  
  445. ;draw background graphics.
  446. ;on entry -
  447. ;           r0 = screen address
  448.  
  449. |BigRedrawScreen|
  450.       STMFD   r13!,{r0-r12,link}
  451.  
  452.       ;initial height value
  453.       MOV     r1,#128
  454.  
  455.       ;load initial colour value into r2 & make word sized
  456.       MOV     r2,#44
  457.       ADD     r2,r2,r2,LSL #8
  458.       ADD     r2,r2,r2,LSL #16
  459.  
  460.       ;move into other registers
  461.       MOV     r3,r2
  462.       MOV     r4,r2
  463.       MOV     r5,r2
  464.       MOV     r6,r2
  465.       MOV     r7,r2
  466.       MOV     r8,r2
  467.       MOV     r9,r2
  468.       MOV     r10,r2
  469.       MOV     r11,r2
  470.  
  471.  
  472. BRDloop   STMIA   r0!,{r2-r11} ;plot one line of colour data on screen
  473.       STMIA   r0!,{r2-r11}
  474.       STMIA   r0!,{r2-r11}
  475.       STMIA   r0!,{r2-r11}
  476.       STMIA   r0!,{r3-r11}
  477.       STMIA   r0!,{r2-r11}
  478.       STMIA   r0!,{r2-r11}
  479.       STMIA   r0!,{r2-r11}
  480.  
  481.       SUBS      r1,r1,#1
  482.       BNE     BRDloop
  483.  
  484.       ;next height value
  485.       MOV     r1,#128
  486.  
  487.       ;load next colour value into r2 & make word sized
  488.       MOV     r2,#46
  489.       ADD     r2,r2,r2,LSL #8
  490.       ADD     r2,r2,r2,LSL #16
  491.  
  492.       ;move into other registers
  493.       MOV     r3,r2
  494.       MOV     r4,r2
  495.       MOV     r5,r2
  496.       MOV     r6,r2
  497.       MOV     r7,r2
  498.       MOV     r8,r2
  499.       MOV     r9,r2
  500.       MOV     r10,r2
  501.       MOV     r11,r2
  502.  
  503. BRDloopA  STMIA   r0!,{r2-r11} ;plot one line of colour data on screen
  504.       STMIA   r0!,{r2-r11}
  505.       STMIA   r0!,{r2-r11}
  506.       STMIA   r0!,{r2-r11}
  507.       STMIA   r0!,{r2-r11}
  508.       STMIA   r0!,{r2-r11}
  509.       STMIA   r0!,{r2-r11}
  510.       STMIA   r0!,{r2-r11}
  511.  
  512.       SUBS      r1,r1,#1
  513.       BNE     BRDloopA
  514.  
  515. EndBRDScreen
  516.           LDMFD   r13!,{r0-r12,pc}
  517.  
  518.  
  519.       END
  520.