renderer3.inc 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Rendered v3. In this version, strings are pre-processed to remove ALL of the
  2. // special characters, and linked lists of them are appended to the end of the
  3. // string instead.
  4. // We can probably merge the two formatting phases, there is really no reason
  5. // for them to be separate (assuming I can compact enough data in).
  6. // Colours are stored in a very unique manner (at least I've never seen it
  7. // before). Most people can't tell the difference visually between, say,
  8. // 0x286A44FF and 0x286A45FF (it's hard enough to read the difference). There
  9. // is just one bit different, and that is the LSB of the Blue component, meaning
  10. // that it makes a trivial contribution to the colour displayed. If we use
  11. // these LSBs for something else, then it doesn't matter if they are set or not
  12. // for the display of the colour, and we can instead get 4 bit flags embedded
  13. // within the colour.
  14. enum e_TEXT_RENDER_COLOUR
  15. {
  16. e_TEXT_RENDER_COLOUR_END = 0x01000000, // {/}
  17. e_TEXT_RENDER_COLOUR_FADE = 0x00010000, // {>XXXXXX}
  18. e_TEXT_RENDER_COLOUR_STAR = 0x00000100, // {*}
  19. e_TEXT_RENDER_COLOUR_____ = 0x00000001, // <unused>
  20. e_TEXT_RENDER_COLOUR_MASK = 0xFEFEFEFE
  21. }
  22. // We have
  23. #if 0
  24. // Current specifier position: 10
  25. // Inserted data: 12 characters.
  26. // For each pass after the current one...
  27. {
  28. // Get the current pointer in the linked list.
  29. new
  30. cur = indexes[pass];
  31. // Add the shift on.
  32. str[cur] += addition;
  33. do
  34. {
  35. cur += 2;
  36. }
  37. while
  38. }
  39. Y_TEXT_STATIC stock TextR_UpdatePass(string:str[], indexes[E_TEXT_RENDER_PASSES], addition, nextPos, E_TEXT_RENDER_PASSES:pass)
  40. {
  41. // "pass" is not defined here in "for" so we can skip early passes in the
  42. // update code after they have already been run. The calling code passes
  43. // the CURRENT pass, which is instantly incremented.
  44. while (++pass != E_TEXT_RENDER_PASSES)
  45. {
  46. new
  47. cur = indexes[pass];
  48. if (cur > nextPos)
  49. {
  50. // Also covers cases where there are none left.
  51. indexes[pass] += addition;
  52. }
  53. else
  54. {
  55. // Add the length of the string just formatted (-2) to the offset to
  56. // the next action of the current pass in this string. Get the new
  57. // relative offset to the next item.
  58. new
  59. off = (str[cur] += addition);
  60. // Find the absolute position of the next item, then test if it is
  61. // before "nextPos" (not <=).
  62. while ((cur += off) < nextPos)
  63. {
  64. if ((off = str[cur] & e_TEXT_RENDER_NEXT_MASK))
  65. {
  66. indexes[pass] = cur;
  67. }
  68. else
  69. {
  70. // There are no actions of this rendering pass after
  71. // "nextPos" in the string.
  72. indexes[pass] = 65536;
  73. break;
  74. }
  75. }
  76. }
  77. }
  78. }
  79. #endif