Geekboy

Untitled

Feb 1st, 2012
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.30 KB | None | 0 0
  1. ;=============================================================================
  2. Documentation about CaDan's new "Resource Table" structure:
  3.  
  4. There's a nice 256 byte table that points to various resources located
  5. throughout CaDan and the loaded level packages. The purpose of this
  6. table is to limit the amount of hardcoded addresses to help facilitate
  7. relocatability throughout the game environment.
  8.  
  9. The table is structured as such:
  10. ------------------------------------------------------------------------------
  11. 00-0E : byte: Resource index
  12. 0F : byte: Resource EOL
  13. 10-FF : word: Resource fields
  14. ------------------------------------------------------------------------------
  15. Pretty simple, eh? Let's try to further break this one down.
  16.  
  17. Every object that wants resources such as script or graphics must choose a
  18. spot in the first 16 bytes of the table. Their ResourceID is kept by the
  19. object and is directly mapped to the resource table. For example, say you
  20. had an enemy that wanted resources. It would try to search the table for an
  21. empty resource slot, which is indicated by $00. Once a resource slot has been
  22. found, the byte at ResourceID is changed to a byte that refers to the starting
  23. position on the table. If the resource table is empty, then this would be
  24. $10, which is the first byte after the end of the index/EOL.
  25.  
  26. ResourceFields come in addresses, which is the address of the resource in
  27. question. It doesn't actually matter *what* is at that address, as long as the
  28. object can distinguish between possible things that are there.
  29.  
  30. The Resource EOL indicates the last byte that is being used. This is important
  31. when additional resources need to be allocated for another object, or by the
  32. same object. If this byte is $00, then the table is full. If this byte is $10,
  33. then the table is empty.
  34.  
  35. Now, let's look at two enemy objects that are on the table. Keep in mind that
  36. the data in ResourceTableFields is not entirely accurate but rather a
  37. representation of what is there. It will be explained afterward
  38.  
  39. ResourceTableIndex:
  40. 10,14,00,00,00,00,00,00,00,00,00,00,00,00,00 ;
  41. ResourceTableEOL:
  42. 1A
  43. ResourceTableFields:
  44. 4000,A700,8D00,A780,A800,0000,0000,0000
  45. 0000,0000,0000,0000,0000,0000,0000,0000
  46. 0000,0000,0000,0000,0000,0000,0000,0000
  47. 0000,0000,0000,0000,0000,0000,0000,0000
  48. 0000,0000,0000,0000,0000,0000,0000,0000
  49. 0000,0000,0000,0000,0000,0000,0000,0000
  50. 0000,0000,0000,0000,0000,0000,0000,0000
  51. 0000,0000,0000,0000,0000,0000,0000,0000
  52. 0000,0000,0000,0000,0000,0000,0000,0000
  53. 0000,0000,0000,0000,0000,0000,0000,0000
  54. 0000,0000,0000,0000,0000,0000,0000,0000
  55. 0000,0000,0000,0000,0000,0000,0000,0000
  56. 0000,0000,0000,0000,0000,0000,0000,0000
  57. 0000,0000,0000,0000,0000,0000,0000,0000
  58. 0000,0000,0000,0000,0000,0000,0000,0000
  59.  
  60. In this example, an enemy whose ResourceID of 0 shows that its resource field
  61. area starts at address $10. It's length is not known in any way other than
  62. the object that is in front of it. In this case, there is another enemy, where
  63. its ResourceID is 1. That enemy's resource field area starts at $14, which
  64. tells you that the previous entry is 4 bytes long.
  65.  
  66. The EOL is at $1A, which tells you that enemy ResourceID 1's size is 6 bytes.
  67.  
  68. In reading this table, ResourceID 0 will see the address at its resource 0 to
  69. be $4000, whereas ResourceID 1 will see its resource 0 to be $8D00.
  70.  
  71. The table is structured in this manner so that no single object needs to keep
  72. track of what IDs are taken by any other given object.
  73.  
  74. ...
  75. ...
  76. ...
  77. It's quite alright if you didn't understand any of this. I mean, if you did,
  78. then more power to you. But it's just fine. The purpose of this document was
  79. just to help me collect my thoughts about the resource table, since I was
  80. doing it wrong wrt menus vs graphics.
  81.  
  82. ------------------------------------------------------------------------------
  83. MENU SYSTEM WHILE NOT IN GAME MODE
  84.  
  85. MenuID's 0, 1, and 2 are allocated in a very static fasion. The following
  86. MenuIDs are as follows:
  87.  
  88. MID 0 = Menu system core data (i.e. X,Y,etc.)
  89. MID 1 = Menu system text data
  90. MID 2 = Image data
  91.  
  92. ------------------------------------------------------------------------------
  93. RESOURCE TABLES WHILE IN DANMAKU (GAME) MODE
  94.  
  95. That information will be found in "loader.txt", where stage information is
  96. actually loaded to CaDan's 4KB slice of RAM.
Advertisement
Add Comment
Please, Sign In to add comment