home *** CD-ROM | disk | FTP | other *** search
/ Dream 44 / Amiga_Dream_44.iso / RiscPc / jeux / biohazard.arc / s / AffLine next >
Text File  |  1995-02-19  |  23KB  |  828 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 (13 bit resolution)
  33. ;           12- 15 = data addresses of graphics data
  34. ;           16     = screen address
  35. ;           17     = base address of graphics data
  36. ;           18     = smallest height
  37. ;           19     = screen height
  38. ;           20     = pointer to gradient table
  39. ;           21     = scaling factor
  40.  
  41. |DrawScaledLine|
  42.       STMFD   r13!,{r0-r12,link}
  43.  
  44.           ;outer loop
  45.           ;r0 = pointer to plot block.
  46.           LDMIA   r0,{r1-r3}
  47.           SUB     r1,r1,#16
  48.           SUB     r2,r2,#16
  49.           ADD     r3,r3,#4
  50.           LDR     r4,[r0,#64]
  51.           ADD     r4,r4,#4
  52.           STR     r4,[r0,#64]
  53.           STMFD   r13!,{r1-r4}
  54.  
  55. OuterLoop LDMFD   r13!,{r1-r4}
  56.           ADD     r1,r1,#16
  57.           ADD     r2,r2,#16
  58.           SUBS    r3,r3,#4
  59.           BEQ     EndOuterLoop
  60.  
  61.           ADD     r4,r4,#4
  62.           STR     r4,[r0,#64]
  63.  
  64.           STMFD   r13!,{r1-r4}
  65.  
  66.           STMFD   r13!,{r2}
  67.  
  68.       LDMIA   r1,{r5-r8}
  69.  
  70.           ;shift distances down 17 places
  71.           MOV     r5,r5,LSR #18
  72.           MOV     r6,r6,LSR #18
  73.           MOV     r7,r7,LSR #18
  74.           MOV     r8,r8,LSR #18
  75.  
  76.           ;clear result registers
  77.           MOV     r1,#0
  78.           MOV     r2,#0
  79.           MOV     r3,#0
  80.           MOV     r4,#0
  81.  
  82.           ;compute heights from distances
  83.           ;wrk = temp register
  84.           ;div = divisor (distance)
  85.           ;num = number (64<<10)
  86.           ;res = result
  87.           ;RSBS    wrk,div,num,LSR #bit
  88.           ;ADC     res,res,res
  89.           ;SUBCS   num,num,div,LSR #bit
  90.  
  91.           ;set up working registers
  92.           MOV     r9,#64  ;num
  93.           MOV     r9,r9,LSL #10
  94.  
  95.           RSBS    r14,r5,r9,LSR #16
  96.           ADC     r1,r1,r1
  97.           SUBCS   r9,r9,r5,LSL #16
  98.           RSBS    r14,r5,r9,LSR #15
  99.           ADC     r1,r1,r1
  100.           SUBCS   r9,r9,r5,LSL #15
  101.           RSBS    r14,r5,r9,LSR #14
  102.           ADC     r1,r1,r1
  103.           SUBCS   r9,r9,r5,LSL #14
  104.           RSBS    r14,r5,r9,LSR #13
  105.           ADC     r1,r1,r1
  106.           SUBCS   r9,r9,r5,LSL #13
  107.           RSBS    r14,r5,r9,LSR #12
  108.           ADC     r1,r1,r1
  109.           SUBCS   r9,r9,r5,LSL #12
  110.           RSBS    r14,r5,r9,LSR #11
  111.           ADC     r1,r1,r1
  112.           SUBCS   r9,r9,r5,LSL #11
  113.           RSBS    r14,r5,r9,LSR #10
  114.           ADC     r1,r1,r1
  115.           SUBCS   r9,r9,r5,LSL #10
  116.           RSBS    r14,r5,r9,LSR #9
  117.           ADC     r1,r1,r1
  118.           SUBCS   r9,r9,r5,LSL #9
  119.           RSBS    r14,r5,r9,LSR #8
  120.           ADC     r1,r1,r1
  121.           SUBCS   r9,r9,r5,LSL #8
  122.           RSBS    r14,r5,r9,LSR #7
  123.           ADC     r1,r1,r1
  124.           SUBCS   r9,r9,r5,LSL #7
  125.           RSBS    r14,r5,r9,LSR #6
  126.           ADC     r1,r1,r1
  127.           SUBCS   r9,r9,r5,LSL #6
  128.           RSBS    r14,r5,r9,LSR #5
  129.           ADC     r1,r1,r1
  130.           SUBCS   r9,r9,r5,LSL #5
  131.           RSBS    r14,r5,r9,LSR #4
  132.           ADC     r1,r1,r1
  133.           SUBCS   r9,r9,r5,LSL #4
  134.           RSBS    r14,r5,r9,LSR #3
  135.           ADC     r1,r1,r1
  136.           SUBCS   r9,r9,r5,LSL #3
  137.           RSBS    r14,r5,r9,LSR #2
  138.           ADC     r1,r1,r1
  139.           SUBCS   r9,r9,r5,LSL #2
  140.           RSBS    r14,r5,r9,LSR #1
  141.           ADC     r1,r1,r1
  142.           SUBCS   r9,r9,r5,LSL #1
  143.  
  144.           ;set up working registers
  145.           MOV     r9,#64  ;num
  146.           MOV     r9,r9,LSL #10
  147.  
  148.           RSBS    r14,r6,r9,LSR #16
  149.           ADC     r2,r2,r2
  150.           SUBCS   r9,r9,r6,LSL #16
  151.           RSBS    r14,r6,r9,LSR #15
  152.           ADC     r2,r2,r2
  153.           SUBCS   r9,r9,r6,LSL #15
  154.           RSBS    r14,r6,r9,LSR #14
  155.           ADC     r2,r2,r2
  156.           SUBCS   r9,r9,r6,LSL #14
  157.           RSBS    r14,r6,r9,LSR #13
  158.           ADC     r2,r2,r2
  159.           SUBCS   r9,r9,r6,LSL #13
  160.           RSBS    r14,r6,r9,LSR #12
  161.           ADC     r2,r2,r2
  162.           SUBCS   r9,r9,r6,LSL #12
  163.           RSBS    r14,r6,r9,LSR #11
  164.           ADC     r2,r2,r2
  165.           SUBCS   r9,r9,r6,LSL #11
  166.           RSBS    r14,r6,r9,LSR #10
  167.           ADC     r2,r2,r2
  168.           SUBCS   r9,r9,r6,LSL #10
  169.           RSBS    r14,r6,r9,LSR #9
  170.           ADC     r2,r2,r2
  171.           SUBCS   r9,r9,r6,LSL #9
  172.           RSBS    r14,r6,r9,LSR #8
  173.           ADC     r2,r2,r2
  174.           SUBCS   r9,r9,r6,LSL #8
  175.           RSBS    r14,r6,r9,LSR #7
  176.           ADC     r2,r2,r2
  177.           SUBCS   r9,r9,r6,LSL #7
  178.           RSBS    r14,r6,r9,LSR #6
  179.           ADC     r2,r2,r2
  180.           SUBCS   r9,r9,r6,LSL #6
  181.           RSBS    r14,r6,r9,LSR #5
  182.           ADC     r2,r2,r2
  183.           SUBCS   r9,r9,r6,LSL #5
  184.           RSBS    r14,r6,r9,LSR #4
  185.           ADC     r2,r2,r2
  186.           SUBCS   r9,r9,r6,LSL #4
  187.           RSBS    r14,r6,r9,LSR #3
  188.           ADC     r2,r2,r2
  189.           SUBCS   r9,r9,r6,LSL #3
  190.           RSBS    r14,r6,r9,LSR #2
  191.           ADC     r2,r2,r2
  192.           SUBCS   r9,r9,r6,LSL #2
  193.           RSBS    r14,r6,r9,LSR #1
  194.           ADC     r2,r2,r2
  195.           SUBCS   r9,r9,r6,LSL #1
  196.  
  197.           ;set up working registers
  198.           MOV     r9,#64  ;num
  199.           MOV     r9,r9,LSL #10
  200.  
  201.           RSBS    r14,r7,r9,LSR #16
  202.           ADC     r3,r3,r3
  203.           SUBCS   r9,r9,r7,LSL #16
  204.           RSBS    r14,r7,r9,LSR #15
  205.           ADC     r3,r3,r3
  206.           SUBCS   r9,r9,r7,LSL #15
  207.           RSBS    r14,r7,r9,LSR #14
  208.           ADC     r3,r3,r3
  209.           SUBCS   r9,r9,r7,LSL #14
  210.           RSBS    r14,r7,r9,LSR #13
  211.           ADC     r3,r3,r3
  212.           SUBCS   r9,r9,r7,LSL #13
  213.           RSBS    r14,r7,r9,LSR #12
  214.           ADC     r3,r3,r3
  215.           SUBCS   r9,r9,r7,LSL #12
  216.           RSBS    r14,r7,r9,LSR #11
  217.           ADC     r3,r3,r3
  218.           SUBCS   r9,r9,r7,LSL #11
  219.           RSBS    r14,r7,r9,LSR #10
  220.           ADC     r3,r3,r3
  221.           SUBCS   r9,r9,r7,LSL #10
  222.           RSBS    r14,r7,r9,LSR #9
  223.           ADC     r3,r3,r3
  224.           SUBCS   r9,r9,r7,LSL #9
  225.           RSBS    r14,r7,r9,LSR #8
  226.           ADC     r3,r3,r3
  227.           SUBCS   r9,r9,r7,LSL #8
  228.           RSBS    r14,r7,r9,LSR #7
  229.           ADC     r3,r3,r3
  230.           SUBCS   r9,r9,r7,LSL #7
  231.           RSBS    r14,r7,r9,LSR #6
  232.           ADC     r3,r3,r3
  233.           SUBCS   r9,r9,r7,LSL #6
  234.           RSBS    r14,r7,r9,LSR #5
  235.           ADC     r3,r3,r3
  236.           SUBCS   r9,r9,r7,LSL #5
  237.           RSBS    r14,r7,r9,LSR #4
  238.           ADC     r3,r3,r3
  239.           SUBCS   r9,r9,r7,LSL #4
  240.           RSBS    r14,r7,r9,LSR #3
  241.           ADC     r3,r3,r3
  242.           SUBCS   r9,r9,r7,LSL #3
  243.           RSBS    r14,r7,r9,LSR #2
  244.           ADC     r3,r3,r3
  245.           SUBCS   r9,r9,r7,LSL #2
  246.           RSBS    r14,r7,r9,LSR #1
  247.           ADC     r3,r3,r3
  248.           SUBCS   r9,r9,r7,LSL #1
  249.  
  250.           ;set up working registers
  251.           MOV     r9,#64  ;num
  252.           MOV     r9,r9,LSL #10
  253.  
  254.           RSBS    r14,r8,r9,LSR #16
  255.           ADC     r4,r4,r4
  256.           SUBCS   r9,r9,r8,LSL #16
  257.           RSBS    r14,r8,r9,LSR #15
  258.           ADC     r4,r4,r4
  259.           SUBCS   r9,r9,r8,LSL #15
  260.           RSBS    r14,r8,r9,LSR #14
  261.           ADC     r4,r4,r4
  262.           SUBCS   r9,r9,r8,LSL #14
  263.           RSBS    r14,r8,r9,LSR #13
  264.           ADC     r4,r4,r4
  265.           SUBCS   r9,r9,r8,LSL #13
  266.           RSBS    r14,r8,r9,LSR #12
  267.           ADC     r4,r4,r4
  268.           SUBCS   r9,r9,r8,LSL #12
  269.           RSBS    r14,r8,r9,LSR #11
  270.           ADC     r4,r4,r4
  271.           SUBCS   r9,r9,r8,LSL #11
  272.           RSBS    r14,r8,r9,LSR #10
  273.           ADC     r4,r4,r4
  274.           SUBCS   r9,r9,r8,LSL #10
  275.           RSBS    r14,r8,r9,LSR #9
  276.           ADC     r4,r4,r4
  277.           SUBCS   r9,r9,r8,LSL #9
  278.           RSBS    r14,r8,r9,LSR #8
  279.           ADC     r4,r4,r4
  280.           SUBCS   r9,r9,r8,LSL #8
  281.           RSBS    r14,r8,r9,LSR #7
  282.           ADC     r4,r4,r4
  283.           SUBCS   r9,r9,r8,LSL #7
  284.           RSBS    r14,r8,r9,LSR #6
  285.           ADC     r4,r4,r4
  286.           SUBCS   r9,r9,r8,LSL #6
  287.           RSBS    r14,r8,r9,LSR #5
  288.           ADC     r4,r4,r4
  289.           SUBCS   r9,r9,r8,LSL #5
  290.           RSBS    r14,r8,r9,LSR #4
  291.           ADC     r4,r4,r4
  292.           SUBCS   r9,r9,r8,LSL #4
  293.           RSBS    r14,r8,r9,LSR #3
  294.           ADC     r4,r4,r4
  295.           SUBCS   r9,r9,r8,LSL #3
  296.           RSBS    r14,r8,r9,LSR #2
  297.           ADC     r4,r4,r4
  298.           SUBCS   r9,r9,r8,LSL #2
  299.           RSBS    r14,r8,r9,LSR #1
  300.           ADC     r4,r4,r4
  301.           SUBCS   r9,r9,r8,LSL #1
  302.  
  303.           ;multiply by scaling factor
  304.           LDR     r14,[r0,#84]
  305.           MUL     r1,r14,r1
  306.           MUL     r2,r14,r2
  307.           MUL     r3,r14,r3
  308.           MUL     r4,r14,r4
  309.  
  310.           MOV     r1,r1,LSR #16
  311.           MOV     r2,r2,LSR #16
  312.           MOV     r3,r3,LSR #16
  313.           MOV     r4,r4,LSR #16
  314.  
  315.           ;shift and round
  316.           CMP     r1,#2
  317.           MOVLT   r1,#2
  318.           CMP     r2,#2
  319.           MOVLT   r2,#2
  320.           CMP     r3,#2
  321.           MOVLT   r3,#2
  322.           CMP     r4,#2
  323.           MOVLT   r4,#2
  324.  
  325.           MOV     r1,r1,ASL #1
  326.           MOV     r2,r2,ASL #1
  327.           MOV     r3,r3,ASL #1
  328.           MOV     r4,r4,ASL #1
  329.  
  330.           ;load pointer to gradient table
  331.           LDR     r5,[r0,#80]
  332.  
  333.       ;limit heights
  334.       MOV     r6,#1024
  335.       SUB     r6,r6,#1
  336.       CMP     r1,r6
  337.       MOVGT   r1,r6
  338.           CMP     r2,r6
  339.           MOVGT   r2,r6
  340.           CMP     r3,r6
  341.           MOVGT   r3,r6
  342.           CMP     r4,r6
  343.       MOVGT   r4,r6
  344.  
  345.       MOV     r6,#4
  346.       CMP     r1,r6
  347.       MOVLT   r1,r6
  348.           CMP     r2,r6
  349.           MOVLT   r2,r6
  350.           CMP     r3,r6
  351.           MOVLT   r3,r6
  352.           CMP     r4,r6
  353.       MOVLT   r4,r6
  354.  
  355.           ;load gradients from table
  356.           LDR     r6,[r5,r1,LSL #2]
  357.           LDR     r7,[r5,r2,LSL #2]
  358.           LDR     r8,[r5,r3,LSL #2]
  359.           LDR     r9,[r5,r4,LSL #2]
  360.  
  361.           ADD     r0,r0,#16
  362.           STMIA   r0,{r6-r9}
  363.           SUB     r0,r0,#16
  364.  
  365.           ;load smallest height
  366.           LDR     r5,[r0,#76]
  367.  
  368.           ;modify height values
  369.           SUBS    r14,r4,r5
  370.           MOVPL   r14,r14,LSR #1
  371.           MULPL   r12,r9,r14
  372.           MOVPL   r4,r5
  373.           MOVMI   r12,#0
  374.  
  375.           SUBS    r14,r1,r5
  376.           MOVPL   r14,r14,LSR #1
  377.           MULPL   r9,r6,r14
  378.           MOVPL   r1,r5
  379.           MOVMI   r9,#0
  380.  
  381.           SUBS    r14,r2,r5
  382.           MOVPL   r14,r14,LSR #1
  383.           MULPL   r10,r7,r14
  384.           MOVPL   r2,r5
  385.           MOVMI   r10,#0
  386.  
  387.           SUBS    r14,r3,r5
  388.           MOVPL   r14,r14,LSR #1
  389.           MULPL   r11,r8,r14
  390.           MOVPL   r3,r5
  391.           MOVMI   r11,#0
  392.  
  393.           STMIA   r0,{r1-r4}
  394.  
  395.           ADD     r0,r0,#32
  396.           STMIA   r0,{r9-r12}
  397.           SUB     r0,r0,#32
  398.  
  399.       ;find smallest height, store in r7
  400.       MOV     r7,r1
  401.       CMP     r2,r7
  402.       MOVLT   r7,r2
  403.       CMP     r3,r7
  404.       MOVLT   r7,r3
  405.       CMP     r4,r7
  406.       MOVLT   r7,r4
  407.       STR     r7,[r0,#72]
  408.  
  409.           LDMFD   r13!,{r9}
  410.  
  411.       ;load r11 with graphics data pointer
  412.       LDR     r11,[r0,#68]
  413.  
  414.       ;draw upper section of line 1
  415.       LDR     r2,[r0,#16]      ; load gradient of line 1
  416.       LDR     r3,[r0,#32]      ; load gradient counter for line 1
  417.       LDR     r4,[r9]          ; load data address of data for line 1
  418.  
  419.       ADD     r3,r3,r4,LSL #14 ; combine gradient counter & data addr
  420.       SUB     r14,r1,r7        ; get height offset against smallest height
  421.       MOVS    r14,r14,LSR #1
  422.       STREQ   r3,[r0,#32]      ; save gradient counter for line 1
  423.           BEQ     DrawLine2
  424.  
  425.       LDR     r5,[r0,#64]      ; load screen address
  426.       RSB     r6,r1,#238       ; find distance from top of screen
  427.       MOV     r6,r6,LSR #1
  428.       MOV     r8,r6,LSL #6     ; multiply height offset by 64
  429.       ADD     r6,r8,r6,LSL #8  ; add to height offset * *256
  430.       ADD     r5,r5,r6         ; add to screen base
  431.       MOV     r1,r14
  432.       BL      DrawByteLine
  433.       STR     r3,[r0,#32]      ; save gradient counter for line 1
  434.  
  435. DrawLine2
  436.       ;draw upper section of line 2
  437.       LDR     r2,[r0,#20]      ; load gradient of line 2
  438.       LDR     r3,[r0,#36]      ; load gradient counter for line 2
  439.       LDR     r4,[r9,#4]       ; load data address of data for line 2
  440.  
  441.       ADD     r3,r3,r4,LSL #14 ; combine gradient counter & data addr
  442.  
  443.       LDR     r1,[r0,#4]
  444.       SUB     r14,r1,r7        ; get height offset against smallest height
  445.       MOVS    r14,r14,LSR #1
  446.       STREQ   r3,[r0,#36]      ; save gradient counter for line 2
  447.           BEQ     DrawLine3
  448.  
  449.       LDR     r5,[r0,#64]      ; load screen address
  450.       RSB     r6,r1,#238       ; find distance from top of screen
  451.       MOV     r6,r6,LSR #1
  452.       MOV     r8,r6,LSL #6     ; multiply height offset by 64
  453.       ADD     r6,r8,r6,LSL #8  ; add to height offset * 256
  454.       ADD     r5,r5,r6         ; add to screen base
  455.       ADD     r5,r5,#1
  456.       MOV     r1,r14
  457.       BL      DrawByteLine
  458.       STR     r3,[r0,#36]      ; save gradient counter for line 2
  459.  
  460. DrawLine3
  461.       ;draw upper section of line 3
  462.       LDR     r2,[r0,#24]      ; load gradient of line 3
  463.       LDR     r3,[r0,#40]      ; load gradient counter for line 3
  464.       LDR     r4,[r9,#8]       ; load data address of data for line 3
  465.  
  466.       ADD     r3,r3,r4,LSL #14 ; combine gradient counter & data addr
  467.  
  468.       LDR     r1,[r0,#8]
  469.       SUB     r14,r1,r7        ; get height offset against smallest height
  470.       MOVS    r14,r14,LSR #1
  471.       STREQ   r3,[r0,#40]      ; save gradient counter for line 3
  472.           BEQ    DrawLine4
  473.  
  474.       LDR     r5,[r0,#64]      ; load screen address
  475.       RSB     r6,r1,#238       ; find distance from top of screen
  476.       MOV     r6,r6,LSR #1
  477.       MOV     r8,r6,LSL #6     ; multiply height offset by 64
  478.       ADD     r6,r8,r6,LSL #8  ; add to height offset * 256
  479.       ADD     r5,r5,r6         ; add to screen base
  480.       ADD     r5,r5,#2
  481.       MOV     r1,r14
  482.       BL      DrawByteLine
  483.       STR     r3,[r0,#40]      ; save gradient counter for line 3
  484.  
  485. DrawLine4
  486.       ;draw upper section of line 4
  487.       LDR     r1,[r0,#12]
  488.       LDR     r2,[r0,#28]      ; load gradient of line 4
  489.       LDR     r3,[r0,#44]      ; load gradient counter for line 4
  490.       LDR     r4,[r9,#12]      ; load data address of data for line 4
  491.  
  492.       ADD     r3,r3,r4,LSL #14 ; combine gradient counter & data addr
  493.       SUB     r14,r1,r7        ; get height offset against smallest height
  494.       MOVS    r14,r14,LSR #1
  495.       STREQ   r3,[r0,#44]      ; save gradient counter for line 4
  496.           BEQ    DrawMainBlock
  497.  
  498.       LDR     r5,[r0,#64]      ; load screen address
  499.       RSB     r6,r1,#238       ; find distance from top of screen
  500.       MOV     r6,r6,LSR #1
  501.       MOV     r8,r6,LSL #6     ; multiply height offset by 64
  502.       ADD     r6,r8,r6,LSL #8  ; add to height offset * 256
  503.       ADD     r5,r5,r6         ; add to screen base
  504.       ADD     r5,r5,#3
  505.       MOV     r1,r14
  506.       BL      DrawByteLine
  507.       STR     r3,[r0,#44]      ; save gradient counter for line 4
  508.  
  509. DrawMainBlock
  510.  
  511.       ;get smallest height
  512.           LDR     r14,[r0,#72]
  513.       LDR     r12,[r0,#64]      ; load screen address
  514.  
  515.           ;compute screen address
  516.       LDR     r5,[r0,#64]      ; load screen address
  517.       RSB     r6,r14,#238      ; find distance from top of screen
  518.       MOV     r6,r6,LSR #1
  519.       MOV     r8,r6,LSL #6     ; multiply height offset by 64
  520.       ADD     r6,r8,r6,LSL #8  ; add to height offset * 256
  521.       ADD     r12,r5,r6        ; add to screen base
  522.  
  523.           ADD     r0,r0,#16
  524.       LDMIA   r0!,{r1-r4}      ; load up gradients
  525.       LDMIA      r0,{r5-r8}       ; load up gradient counters + data addrs
  526.  
  527. StartPlotBlock
  528.  
  529.  
  530.       LDRB    r10,[r11,r5,LSR #14]
  531.       LDRB    r9,[r11,r6,LSR #14]
  532.       ADD     r10,r10,r9,LSL #8
  533.       LDRB    r9,[r11,r7,LSR #14]
  534.       ADD     r10,r10,r9,LSL #16
  535.       LDRB    r9,[r11,r8,LSR #14]
  536.       ADD     r10,r10,r9,LSL #24
  537.       STR     r10,[r12],#320
  538.       ADD     r5,r5,r1
  539.       ADD     r6,r6,r2
  540.       ADD     r7,r7,r3
  541.       ADD     r8,r8,r4
  542.       SUBS    r14,r14,#1
  543.       BEQ     EndPlotBlock
  544.  
  545.       LDRB    r10,[r11,r5,LSR #14]
  546.       LDRB    r9,[r11,r6,LSR #14]
  547.       ADD     r10,r10,r9,LSL #8
  548.       LDRB    r9,[r11,r7,LSR #14]
  549.       ADD     r10,r10,r9,LSL #16
  550.       LDRB    r9,[r11,r8,LSR #14]
  551.       ADD     r10,r10,r9,LSL #24
  552.       STR     r10,[r12],#320
  553.       ADD     r5,r5,r1
  554.       ADD     r6,r6,r2
  555.       ADD     r7,r7,r3
  556.       ADD     r8,r8,r4
  557.       SUBS    r14,r14,#1
  558.       BEQ     EndPlotBlock
  559.  
  560.       LDRB    r10,[r11,r5,LSR #14]
  561.       LDRB    r9,[r11,r6,LSR #14]
  562.       ADD     r10,r10,r9,LSL #8
  563.       LDRB    r9,[r11,r7,LSR #14]
  564.       ADD     r10,r10,r9,LSL #16
  565.       LDRB    r9,[r11,r8,LSR #14]
  566.       ADD     r10,r10,r9,LSL #24
  567.       STR     r10,[r12],#320
  568.       ADD     r5,r5,r1
  569.       ADD     r6,r6,r2
  570.       ADD     r7,r7,r3
  571.       ADD     r8,r8,r4
  572.       SUBS    r14,r14,#1
  573.       BEQ     EndPlotBlock
  574.  
  575.       LDRB    r10,[r11,r5,LSR #14]
  576.       LDRB    r9,[r11,r6,LSR #14]
  577.       ADD     r10,r10,r9,LSL #8
  578.       LDRB    r9,[r11,r7,LSR #14]
  579.       ADD     r10,r10,r9,LSL #16
  580.       LDRB    r9,[r11,r8,LSR #14]
  581.       ADD     r10,r10,r9,LSL #24
  582.       STR     r10,[r12],#320
  583.       ADD     r5,r5,r1
  584.       ADD     r6,r6,r2
  585.       ADD     r7,r7,r3
  586.       ADD     r8,r8,r4
  587.       SUBS    r14,r14,#1
  588.       BEQ     EndPlotBlock
  589.  
  590.       LDRB    r10,[r11,r5,LSR #14]
  591.       LDRB    r9,[r11,r6,LSR #14]
  592.       ADD     r10,r10,r9,LSL #8
  593.       LDRB    r9,[r11,r7,LSR #14]
  594.       ADD     r10,r10,r9,LSL #16
  595.       LDRB    r9,[r11,r8,LSR #14]
  596.       ADD     r10,r10,r9,LSL #24
  597.       STR     r10,[r12],#320
  598.       ADD     r5,r5,r1
  599.       ADD     r6,r6,r2
  600.       ADD     r7,r7,r3
  601.       ADD     r8,r8,r4
  602.       SUBS    r14,r14,#1
  603.       BEQ     EndPlotBlock
  604.  
  605.       LDRB    r10,[r11,r5,LSR #14]
  606.       LDRB    r9,[r11,r6,LSR #14]
  607.       ADD     r10,r10,r9,LSL #8
  608.       LDRB    r9,[r11,r7,LSR #14]
  609.       ADD     r10,r10,r9,LSL #16
  610.       LDRB    r9,[r11,r8,LSR #14]
  611.       ADD     r10,r10,r9,LSL #24
  612.       STR     r10,[r12],#320
  613.       ADD     r5,r5,r1
  614.       ADD     r6,r6,r2
  615.       ADD     r7,r7,r3
  616.       ADD     r8,r8,r4
  617.       SUBS    r14,r14,#1
  618.        BNE     StartPlotBlock
  619.  
  620.  
  621. EndPlotBlock
  622.  
  623.           STMIA   r0,{r5-r8}       ; save gradient/data combos
  624.           STR     r12,[r0,#32]       ; save screen address
  625.           SUB     r0,r0,#32        ; reset pointer to start of height data
  626.           LDR     r6,[r0,#72]
  627.  
  628.        ;draw lower section of line 1
  629.        MOV     r5,r12       ; get old screen address
  630.           LDR     r1,[r0]          ; get height of line 1
  631.           SUB     r1,r1,r6         ; length = height - smallest height
  632.           MOVS    r1,r1,LSR #1     ; divide by 2
  633.           BEQ     LowerLine2
  634.        LDR     r2,[r0,#16]      ; load gradient of line 1
  635.       LDR     r3,[r0,#32]      ; load gradient/data combo for line 1
  636.       LDR     r4,[r0,#48]      ; load data address of data for line 1
  637.           BL      DrawByteLine
  638.  
  639. LowerLine2
  640.       ;draw lower section of line 2
  641.       ADD     r5,r12,#1
  642.           LDR     r1,[r0,#4]       ; get height of line 2
  643.           SUB     r1,r1,r6         ; length = height - smallest height
  644.           MOVS    r1,r1,LSR #1     ; divide by 2
  645.           BEQ     LowerLine3
  646.        LDR     r2,[r0,#20]      ; load gradient of line 2
  647.       LDR     r3,[r0,#36]      ; load gradient/data combo for line 2
  648.       LDR     r4,[r0,#52]      ; load data address of data for line 2
  649.           BL      DrawByteLine
  650.  
  651. LowerLine3
  652.       ;draw lower section of line 3
  653.       ADD     r5,r12,#2
  654.           LDR     r1,[r0,#8]       ; get height of line 3
  655.           SUB     r1,r1,r6         ; length = height - smallest height
  656.           MOVS    r1,r1,LSR #1     ; divide by 2
  657.           BEQ     LowerLine4
  658.        LDR     r2,[r0,#24]      ; load gradient of line 3
  659.       LDR     r3,[r0,#40]      ; load gradient/data combo for line 3
  660.       LDR     r4,[r0,#56]      ; load data address of data for line 3
  661.           BL      DrawByteLine
  662.  
  663. LowerLine4
  664.       ;draw lower section of line 4
  665.       ADD     r5,r12,#3
  666.           LDR     r1,[r0,#12]      ; get height of line 1
  667.           SUB     r1,r1,r6         ; length = height - smallest height
  668.           MOVS    r1,r1,LSR #1     ; divide by 2
  669.           BEQ     EndDSLine
  670.        LDR     r2,[r0,#28]      ; load gradient of line 1
  671.       LDR     r3,[r0,#44]      ; load gradient/data combo for line 1
  672.       LDR     r4,[r0,#60]      ; load data address of data for line 1
  673.           BL      DrawByteLine
  674.  
  675. EndDSLine
  676.  
  677.           B       OuterLoop
  678.  
  679. EndOuterLoop
  680.           LDMFD   r13!,{r0-r12,pc}
  681.  
  682. DBLineX   DCB     "DrawByteLine", 0
  683.           ALIGN
  684. DBLineY   DCD     &ff000000 + DBLineY - DBLineX
  685.  
  686. ;scale line of graphics block to height value.
  687. ;on entry -
  688. ;           r1  = length of line to draw
  689. ;           r2  = gradient of line
  690. ;           r3  = gradient counter plus data address
  691. ;        r5  = screen address
  692. ;           r14 = return address
  693. ;
  694. ;on exit -
  695. ;           r1  = zero
  696. ;           r2  = gradient of line
  697. ;           r3  = gradient counter plus data address, updated
  698. ;           r5  = updated screen address
  699. ;           r14 = return address
  700. ;
  701.  
  702. DrawByteLine
  703.  
  704.           LDRB  r10,[r11,r3,LSR #14]
  705.           STRB  r10,[r5],#320
  706.           ADD   r3,r3,r2
  707.       SUBS  r1,r1,#1
  708.       BEQ   EndByteLine
  709.           LDRB  r10,[r11,r3,LSR #14]
  710.           STRB  r10,[r5],#320
  711.           ADD   r3,r3,r2
  712.       SUBS  r1,r1,#1
  713.       BEQ   EndByteLine
  714.           LDRB  r10,[r11,r3,LSR #14]
  715.           STRB  r10,[r5],#320
  716.           ADD   r3,r3,r2
  717.       SUBS  r1,r1,#1
  718.       BEQ   EndByteLine
  719.           LDRB  r10,[r11,r3,LSR #14]
  720.           STRB  r10,[r5],#320
  721.           ADD   r3,r3,r2
  722.       SUBS  r1,r1,#1
  723.           BEQ   EndByteLine
  724.           LDRB  r10,[r11,r3,LSR #14]
  725.           STRB  r10,[r5],#320
  726.           ADD   r3,r3,r2
  727.       SUBS  r1,r1,#1
  728.       BEQ   EndByteLine
  729.           LDRB  r10,[r11,r3,LSR #14]
  730.           STRB  r10,[r5],#320
  731.           ADD   r3,r3,r2
  732.       SUBS  r1,r1,#1
  733.       BEQ   EndByteLine
  734.           LDRB  r10,[r11,r3,LSR #14]
  735.           STRB  r10,[r5],#320
  736.           ADD   r3,r3,r2
  737.       SUBS  r1,r1,#1
  738.       BEQ   EndByteLine
  739.           LDRB  r10,[r11,r3,LSR #14]
  740.           STRB  r10,[r5],#320
  741.           ADD   r3,r3,r2
  742.       SUBS  r1,r1,#1
  743.       BNE   DrawByteLine
  744.  
  745. EndByteLine
  746.  
  747.           MOV   r15,r14            ; return to caller...
  748.  
  749. BRDScreenX DCB     "BigRedrawScreen", 0
  750.            ALIGN
  751. BRDScreenY DCD     &ff000000 + BRDScreenY - BRDScreenX
  752.  
  753. ;draw background graphics.
  754. ;on entry -
  755. ;           r0 = screen address
  756.  
  757. |BigRedrawScreen|
  758.       STMFD   r13!,{r0-r12,link}
  759.  
  760.       ;initial height value
  761.       MOV     r1,#128
  762.  
  763.       ;load initial colour value into r2 & make word sized
  764.       MOV     r2,#44
  765.       ADD     r2,r2,r2,LSL #8
  766.       ADD     r2,r2,r2,LSL #16
  767.  
  768.       ;move into other registers
  769.       MOV     r3,r2
  770.       MOV     r4,r2
  771.       MOV     r5,r2
  772.       MOV     r6,r2
  773.       MOV     r7,r2
  774.       MOV     r8,r2
  775.       MOV     r9,r2
  776.       MOV     r10,r2
  777.       MOV     r11,r2
  778.  
  779.  
  780. BRDloop   STMIA   r0!,{r2-r11} ;plot one line of colour data on screen
  781.       STMIA   r0!,{r2-r11}
  782.       STMIA   r0!,{r2-r11}
  783.       STMIA   r0!,{r2-r11}
  784.       STMIA   r0!,{r3-r11}
  785.       STMIA   r0!,{r2-r11}
  786.       STMIA   r0!,{r2-r11}
  787.       STMIA   r0!,{r2-r11}
  788.  
  789.       SUBS      r1,r1,#1
  790.       BNE     BRDloop
  791.  
  792.       ;next height value
  793.       MOV     r1,#128
  794.  
  795.       ;load next colour value into r2 & make word sized
  796.       MOV     r2,#46
  797.       ADD     r2,r2,r2,LSL #8
  798.       ADD     r2,r2,r2,LSL #16
  799.  
  800.       ;move into other registers
  801.       MOV     r3,r2
  802.       MOV     r4,r2
  803.       MOV     r5,r2
  804.       MOV     r6,r2
  805.       MOV     r7,r2
  806.       MOV     r8,r2
  807.       MOV     r9,r2
  808.       MOV     r10,r2
  809.       MOV     r11,r2
  810.  
  811. BRDloopA  STMIA   r0!,{r2-r11} ;plot one line of colour data on screen
  812.       STMIA   r0!,{r2-r11}
  813.       STMIA   r0!,{r2-r11}
  814.       STMIA   r0!,{r2-r11}
  815.       STMIA   r0!,{r2-r11}
  816.       STMIA   r0!,{r2-r11}
  817.       STMIA   r0!,{r2-r11}
  818.       STMIA   r0!,{r2-r11}
  819.  
  820.       SUBS      r1,r1,#1
  821.       BNE     BRDloopA
  822.  
  823. EndBRDScreen
  824.           LDMFD   r13!,{r0-r12,pc}
  825.  
  826.  
  827.       END
  828.