home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / RiscPc / jeux / biohazard.arc / s / AffLine15 < prev    next >
Text File  |  1994-06-10  |  13KB  |  468 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 #7     ; multiply height offset by 64
  70.       ADD     r6,r8,r6,LSL #9  ; 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 #7     ; multiply height offset by 64
  94.       ADD     r6,r8,r6,LSL #9  ; 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 #7     ; multiply height offset by 64
  119.       ADD     r6,r8,r6,LSL #9  ; 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 #7     ; multiply height offset by 64
  143.       ADD     r6,r8,r6,LSL #9  ; 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 #7     ; multiply height offset by 64
  161.       ADD     r6,r8,r6,LSL #9  ; 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. StartPlotBlock
  170.  
  171.  
  172.       LDRB    r10,[r11,r5,LSR #8]
  173.       LDRB    r9,[r11,r6,LSR #8]
  174.       ADD     r10,r10,r9,LSL #8
  175.       LDRB    r9,[r11,r7,LSR #8]
  176.       ADD     r10,r10,r9,LSL #16
  177.       LDRB    r9,[r11,r8,LSR #8]
  178.       ADD     r10,r10,r9,LSL #24
  179.       STR     r10,[r12],#640
  180.       ADD     r5,r5,r1
  181.       ADD     r6,r6,r2
  182.       ADD     r7,r7,r3
  183.       ADD     r8,r8,r4
  184.       SUBS    r14,r14,#1
  185.       BEQ     EndPlotBlock
  186.  
  187.       LDRB    r10,[r11,r5,LSR #8]
  188.       LDRB    r9,[r11,r6,LSR #8]
  189.       ADD     r10,r10,r9,LSL #8
  190.       LDRB    r9,[r11,r7,LSR #8]
  191.       ADD     r10,r10,r9,LSL #16
  192.       LDRB    r9,[r11,r8,LSR #8]
  193.       ADD     r10,r10,r9,LSL #24
  194.       STR     r10,[r12],#640
  195.       ADD     r5,r5,r1
  196.       ADD     r6,r6,r2
  197.       ADD     r7,r7,r3
  198.       ADD     r8,r8,r4
  199.       SUBS    r14,r14,#1
  200.       BEQ     EndPlotBlock
  201.  
  202.       LDRB    r10,[r11,r5,LSR #8]
  203.       LDRB    r9,[r11,r6,LSR #8]
  204.       ADD     r10,r10,r9,LSL #8
  205.       LDRB    r9,[r11,r7,LSR #8]
  206.       ADD     r10,r10,r9,LSL #16
  207.       LDRB    r9,[r11,r8,LSR #8]
  208.       ADD     r10,r10,r9,LSL #24
  209.       STR     r10,[r12],#640
  210.       ADD     r5,r5,r1
  211.       ADD     r6,r6,r2
  212.       ADD     r7,r7,r3
  213.       ADD     r8,r8,r4
  214.       SUBS    r14,r14,#1
  215.       BEQ     EndPlotBlock
  216.  
  217.       LDRB    r10,[r11,r5,LSR #8]
  218.       LDRB    r9,[r11,r6,LSR #8]
  219.       ADD     r10,r10,r9,LSL #8
  220.       LDRB    r9,[r11,r7,LSR #8]
  221.       ADD     r10,r10,r9,LSL #16
  222.       LDRB    r9,[r11,r8,LSR #8]
  223.       ADD     r10,r10,r9,LSL #24
  224.       STR     r10,[r12],#640
  225.       ADD     r5,r5,r1
  226.       ADD     r6,r6,r2
  227.       ADD     r7,r7,r3
  228.       ADD     r8,r8,r4
  229.       SUBS    r14,r14,#1
  230.       BEQ     EndPlotBlock
  231.  
  232.       LDRB    r10,[r11,r5,LSR #8]
  233.       LDRB    r9,[r11,r6,LSR #8]
  234.       ADD     r10,r10,r9,LSL #8
  235.       LDRB    r9,[r11,r7,LSR #8]
  236.       ADD     r10,r10,r9,LSL #16
  237.       LDRB    r9,[r11,r8,LSR #8]
  238.       ADD     r10,r10,r9,LSL #24
  239.       STR     r10,[r12],#640
  240.       ADD     r5,r5,r1
  241.       ADD     r6,r6,r2
  242.       ADD     r7,r7,r3
  243.       ADD     r8,r8,r4
  244.       SUBS    r14,r14,#1
  245.       BEQ     EndPlotBlock
  246.  
  247.       LDRB    r10,[r11,r5,LSR #8]
  248.       LDRB    r9,[r11,r6,LSR #8]
  249.       ADD     r10,r10,r9,LSL #8
  250.       LDRB    r9,[r11,r7,LSR #8]
  251.       ADD     r10,r10,r9,LSL #16
  252.       LDRB    r9,[r11,r8,LSR #8]
  253.       ADD     r10,r10,r9,LSL #24
  254.       STR     r10,[r12],#640
  255.       ADD     r5,r5,r1
  256.       ADD     r6,r6,r2
  257.       ADD     r7,r7,r3
  258.       ADD     r8,r8,r4
  259.       SUBS    r14,r14,#1
  260.        BNE     StartPlotBlock
  261.  
  262.  
  263. EndPlotBlock
  264.  
  265.           STMIA   r0,{r5-r8}       ; save gradient/data combos
  266.           STR     r12,[r0,#32]       ; save screen address
  267.           SUB     r0,r0,#32        ; reset pointer to start of height data
  268.           ADR     r6,SmallestHeight
  269.           LDR     r6,[r6]
  270.  
  271.        ;draw lower section of line 1
  272.        MOV     r5,r12       ; get old screen address
  273.           LDR     r1,[r0]          ; get height of line 1
  274.           SUB     r1,r1,r6         ; length = height - smallest height
  275.           MOVS    r1,r1,LSR #1     ; divide by 2
  276.           BEQ     LowerLine2
  277.        LDR     r2,[r0,#16]      ; load gradient of line 1
  278.       LDR     r3,[r0,#32]      ; load gradient/data combo for line 1
  279.       LDR     r4,[r0,#48]      ; load data address of data for line 1
  280.           BL      DrawByteLine
  281.  
  282. LowerLine2
  283.       ;draw lower section of line 2
  284.       ADD     r5,r12,#1
  285.           LDR     r1,[r0,#4]       ; get height of line 2
  286.           SUB     r1,r1,r6         ; length = height - smallest height
  287.           MOVS    r1,r1,LSR #1     ; divide by 2
  288.           BEQ     LowerLine3
  289.        LDR     r2,[r0,#20]      ; load gradient of line 2
  290.       LDR     r3,[r0,#36]      ; load gradient/data combo for line 2
  291.       LDR     r4,[r0,#52]      ; load data address of data for line 2
  292.           BL      DrawByteLine
  293.  
  294. LowerLine3
  295.       ;draw lower section of line 3
  296.       ADD     r5,r12,#2
  297.           LDR     r1,[r0,#8]       ; get height of line 3
  298.           SUB     r1,r1,r6         ; length = height - smallest height
  299.           MOVS    r1,r1,LSR #1     ; divide by 2
  300.           BEQ     LowerLine4
  301.        LDR     r2,[r0,#24]      ; load gradient of line 3
  302.       LDR     r3,[r0,#40]      ; load gradient/data combo for line 3
  303.       LDR     r4,[r0,#56]      ; load data address of data for line 3
  304.           BL      DrawByteLine
  305.  
  306. LowerLine4
  307.       ;draw lower section of line 4
  308.       ADD     r5,r12,#3
  309.           LDR     r1,[r0,#12]      ; get height of line 1
  310.           SUB     r1,r1,r6         ; length = height - smallest height
  311.           MOVS    r1,r1,LSR #1     ; divide by 2
  312.           BEQ     EndDSLine
  313.        LDR     r2,[r0,#28]      ; load gradient of line 1
  314.       LDR     r3,[r0,#44]      ; load gradient/data combo for line 1
  315.       LDR     r4,[r0,#60]      ; load data address of data for line 1
  316.           BL      DrawByteLine
  317.  
  318. EndDSLine
  319.           LDMFD   r13!,{r0-r12,pc}
  320.  
  321. DBLineX   DCB     "DrawByteLine", 0
  322.           ALIGN
  323. DBLineY   DCD     &ff000000 + DBLineY - DBLineX
  324.  
  325. ;scale line of graphics block to height value.
  326. ;on entry -
  327. ;           r1  = length of line to draw
  328. ;           r2  = gradient of line
  329. ;           r3  = gradient counter plus data address
  330. ;        r5  = screen address
  331. ;           r14 = return address
  332. ;
  333. ;on exit -
  334. ;           r1  = zero
  335. ;           r2  = gradient of line
  336. ;           r3  = gradient counter plus data address, updated
  337. ;           r5  = updated screen address
  338. ;           r14 = return address
  339. ;
  340.  
  341. DrawByteLine
  342.  
  343.           LDRB  r10,[r11,r3,LSR #8]
  344.           STRB  r10,[r5],#640
  345.           ADD   r3,r3,r2
  346.       SUBS  r1,r1,#1
  347.       BEQ   EndByteLine
  348.           LDRB  r10,[r11,r3,LSR #8]
  349.           STRB  r10,[r5],#640
  350.           ADD   r3,r3,r2
  351.       SUBS  r1,r1,#1
  352.       BEQ   EndByteLine
  353.           LDRB  r10,[r11,r3,LSR #8]
  354.           STRB  r10,[r5],#640
  355.           ADD   r3,r3,r2
  356.       SUBS  r1,r1,#1
  357.       BEQ   EndByteLine
  358.           LDRB  r10,[r11,r3,LSR #8]
  359.           STRB  r10,[r5],#640
  360.           ADD   r3,r3,r2
  361.       SUBS  r1,r1,#1
  362.           BEQ   EndByteLine
  363.           LDRB  r10,[r11,r3,LSR #8]
  364.           STRB  r10,[r5],#640
  365.           ADD   r3,r3,r2
  366.       SUBS  r1,r1,#1
  367.       BEQ   EndByteLine
  368.           LDRB  r10,[r11,r3,LSR #8]
  369.           STRB  r10,[r5],#640
  370.           ADD   r3,r3,r2
  371.       SUBS  r1,r1,#1
  372.       BEQ   EndByteLine
  373.           LDRB  r10,[r11,r3,LSR #8]
  374.           STRB  r10,[r5],#640
  375.           ADD   r3,r3,r2
  376.       SUBS  r1,r1,#1
  377.       BEQ   EndByteLine
  378.           LDRB  r10,[r11,r3,LSR #8]
  379.           STRB  r10,[r5],#640
  380.           ADD   r3,r3,r2
  381.       SUBS  r1,r1,#1
  382.       BNE   DrawByteLine
  383.  
  384. EndByteLine
  385.  
  386.           MOV   r15,r14            ; return to caller...
  387.  
  388. BRDScreenX DCB     "BigRedrawScreen", 0
  389.            ALIGN
  390. BRDScreenY DCD     &ff000000 + BRDScreenY - BRDScreenX
  391.  
  392. ;draw background graphics.
  393. ;on entry -
  394. ;           r0 = screen address
  395.  
  396. |BigRedrawScreen|
  397.       STMFD   r13!,{r0-r12,link}
  398.  
  399.       ;initial height value
  400.       MOV     r1,#127
  401.  
  402.       ;load initial colour value into r2 & make word sized
  403.       MOV     r2,#44
  404.       ADD     r2,r2,r2,LSL #8
  405.       ADD     r2,r2,r2,LSL #16
  406.  
  407.       ;move into other registers
  408.       MOV     r3,r2
  409.       MOV     r4,r2
  410.       MOV     r5,r2
  411.       MOV     r6,r2
  412.       MOV     r7,r2
  413.       MOV     r8,r2
  414.       MOV     r9,r2
  415.       MOV     r10,r2
  416.       MOV     r11,r2
  417.  
  418. BRDloop   STMIA   r0!,{r2-r11} ;plot one line of colour data on screen
  419.       STMIA   r0!,{r2-r11}
  420.       STMIA   r0!,{r2-r11}
  421.       STMIA   r0!,{r2-r11}
  422.       STMIA   r0!,{r2-r11}
  423.       STMIA   r0!,{r2-r11}
  424.       STMIA   r0!,{r2-r11}
  425.       STMIA   r0!,{r2-r11}
  426.  
  427.       SUBS      r1,r1,#1
  428.           ADD     r0,r0,#320
  429.       BNE     BRDloop
  430.  
  431.       ;next height value
  432.       MOV     r1,#127
  433.  
  434.       ;load next colour value into r2 & make word sized
  435.       MOV     r2,#46
  436.       ADD     r2,r2,r2,LSL #8
  437.       ADD     r2,r2,r2,LSL #16
  438.  
  439.       ;move into other registers
  440.       MOV     r3,r2
  441.       MOV     r4,r2
  442.       MOV     r5,r2
  443.       MOV     r6,r2
  444.       MOV     r7,r2
  445.       MOV     r8,r2
  446.       MOV     r9,r2
  447.       MOV     r10,r2
  448.       MOV     r11,r2
  449.  
  450. BRDloopA  STMIA   r0!,{r2-r11} ;plot one line of colour data on screen
  451.       STMIA   r0!,{r2-r11}
  452.       STMIA   r0!,{r2-r11}
  453.       STMIA   r0!,{r2-r11}
  454.       STMIA   r0!,{r2-r11}
  455.       STMIA   r0!,{r2-r11}
  456.       STMIA   r0!,{r2-r11}
  457.       STMIA   r0!,{r2-r11}
  458.  
  459.       SUBS      r1,r1,#1
  460.       ADD     r0,r0,#320
  461.       BNE     BRDloopA
  462.  
  463. EndBRDScreen
  464.           LDMFD   r13!,{r0-r12,pc}
  465.  
  466.  
  467.       END
  468.