home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / gamesuite_1 / GameSuite / Examples / BolMaster / !BolMaster / Sources / ReadBack < prev    next >
Encoding:
Text File  |  1995-04-29  |  2.3 KB  |  149 lines

  1. #name ^.Object.ReadBack
  2. #type &ffd
  3.  
  4. #include <Bolmaster$Path>Sources.Structures
  5. #include <Bolmaster$Path>Sources.Variables
  6.  
  7. ;Reads sprite entries from the backdrop file and places their addresses in
  8. ;the backtab
  9.  
  10. ;wipe the backtab table
  11. ADD R11,R12,#v.backtab
  12. MOV R8,#256
  13. MOV R0,#0
  14. .loop4
  15. STR R0,[R11],#4
  16. SUBS R8,R8,#1
  17. BGT loop4
  18. ;point R11 at the sprite file
  19.  
  20. LDR R11,[R12,#v.backdropadr]
  21. CMP R11,#0
  22. BEQ fail
  23. SUB R11,R11,#4
  24. LDR R8,[R11,#4]; number of sprites
  25. CMP R8,#256
  26. BGT fail
  27. LDR R1,[R11,#8]
  28. ADD R11,R11,R1;indirect to first sprite
  29. .loop
  30. .decodenum
  31. MOV R7,#0      ;sprite number to be filled in
  32. LDRB R0,[R11,#4]  ;load first figure
  33. CMP R0,#"0"
  34. BLT skip
  35. CMP R0,#"9"
  36. BGT skip
  37. SUB R0,R0,#"0"
  38. MOV R7,R0
  39.  
  40. LDRB R0,[R11,#5]  ;load second figure
  41. CMP R0,#"0"
  42. BLT decoded
  43. CMP R0,#"9"
  44. BGT decoded
  45. ADD R7,R7,R7,LSL #2 ;} multiply R7 by 10
  46. MOV R7,R7,LSL #1 ;}
  47. SUB R0,R0,#"0"
  48. ADD R7,R7,R0
  49.  
  50. LDRB R0,[R11,#6] ;load third figure
  51. CMP R0,#"0"
  52. BLT decoded
  53. CMP R0,#"9"
  54. BGT decoded
  55. ADD R7,R7,R7,LSL #2 ;} multiply R7 by 10
  56. MOV R7,R7,LSL #1 ;}
  57. SUB R0,R0,#"0"
  58. ADD R7,R7,R0
  59.  
  60. .decoded
  61. ;R7 now contains the number of our sprite
  62. CMP R7,#256
  63. BGE fail
  64.  
  65. LDR R0,[R11,#32]
  66. ADD R0,R0,R11; R0 now points to the sprite data
  67. ADD R1,R12,#v.backtab
  68. STR R0,[R1,R7,LSL #2] ;store the sprite data address in the
  69. ;back table at offset R7
  70.  
  71. .skip
  72. CMP R8,#1
  73. BLE done
  74.  
  75. LDR R0,[R11]
  76. ADD R11,R11,R0;indirect to next sprite
  77. SUB R8,R8,#1
  78. B loop
  79.  
  80. .fail
  81. ADR R0,failtext
  82. MOV R1,PC
  83. ORR R1,R1,#1<<28
  84. TEQP PC,R1
  85. B end
  86. .failtext
  87. DCD &666
  88. DCB "Backdrop file read failed",0
  89. ALIGN
  90.  
  91. .done
  92. ;now fill in the blank entries with the first available sprite
  93.  
  94. ADD R11,R12,#v.backtab
  95. MOV R8,#256
  96. .loop2
  97. LDR R0,[R11],#4
  98. CMP R0,#0
  99. BNE foundfirst
  100. SUBS R8,R8,#1
  101. BGT loop2
  102. B fail
  103.  
  104. .foundfirst
  105. MOV R1,R0
  106. ADD R11,R12,#v.backtab
  107. MOV R8,#256
  108. .loop3
  109. LDR R0,[R11]
  110. CMP R0,#0
  111. STREQ R1,[R11]
  112. ADD R11,R11,#4
  113. SUBS R8,R8,#1
  114. BGT loop3
  115.  
  116. .placehell
  117. LDR R11,[R12,#v.hellcache]
  118. CMP R11,#0
  119. BEQ fail
  120. ADD R10,R12,#v.backtab
  121. MOV R9,#18
  122. .loop6
  123. STR R11,[R10],#4
  124. ADD R11,R11,#32*32
  125. SUBS R9,R9,#1
  126. BGT loop6
  127.  
  128. LDR R11,[R12,#v.backpixadr]
  129. CMP R11,#0
  130. BEQ fail
  131.  
  132. SUB R11,R11,#4
  133. LDR R8,[R11,#4]; number of sprites
  134. CMP R8,#256
  135. BGT fail
  136. LDR R1,[R11,#8]
  137. ADD R11,R11,R1;indirect to first sprite
  138. ADD R10,R12,#v.backpixtab
  139. MOV R9,#9
  140. .loop5
  141. LDR R0,[R11,#32]
  142. ADD R0,R0,R11   ;address of sprite data
  143. STR R0,[R10],#4
  144. SUBS R8,R8,#1
  145. LDRGT R0,[R11]
  146. ADDGT R11,R11,R0
  147. SUBS R9,R9,#1
  148. BGT loop5
  149. .end