mattcurrie

Another World draw_sprite_shape customasm rule

Apr 15th, 2021
322
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Draw Shape Opcode:
  2. ;
  3. ;   Bits 7 & 6 - 00: Unknown
  4. ;                01: Draw sprite shape
  5. ;                1X: Draw background shape
  6. ;
  7. ;   When drawing a background shape:
  8. ;   Bits 6 - 0 - High 7 bits of the shape address
  9. ;
  10. ;   When drawing a sprite shape:
  11. ;   Bits 5 & 4 - 00: X coordinate is 16-bits immediate (BE)
  12. ;                01: Read X coordinate from memory indicated by 8-bit immediate
  13. ;                10: X coordinate is 8-bit immediate
  14. ;                11: X coordinate is 8-bit immediate + 256
  15. ;
  16. ;   Bits 3 & 2 - 00: Y coordinate is 16-bits immediate (BE)
  17. ;                01: Read Y coordinate from memory indicated by 8-bit immediate
  18. ;                10: Y coordinate is 8-bit immediate
  19. ;                11: Unknown
  20. ;
  21. ;   Bits 1 & 0 - 00: Zoom is 64
  22. ;                01: Read Zoom from memory indicated by 8-bit immediate
  23. ;                10: Zoom is 8-bit immediate
  24. ;                11: Shape to draw is from shared shapes. Zoom is 64
  25. ;
  26. ;   Operand bytes:
  27. ;       - u16 (offset >> 1)
  28. ;       - u8 or u16 (x)
  29. ;       - u8 or u16 (y)
  30. ;       - u8 zoom (optional)
  31. ;
  32. ;   Instruction Format:
  33. ;       draw_sprite_shape from_shared (0 | 1), offset (u16), x (u8 | [u8] | u16 | u16 < 512), y (u8 | [u8] | u16), zoom (u8 | [u8] | 64)
  34. ;
  35. ;   Examples:
  36. ;       draw_sprite_shape 1, 0x0cba, [0x01], [0x02], 64
  37. ;       draw_sprite_shape 0, 0xde5c, 0x104, [0x34], [0x04]
  38.  
  39.  
  40. draw_sprite_shape {from_shared}, {offset: u16}, [{x: u8}], [{y: u8}], {z: u8} => {
  41.     assert(from_shared == 0)
  42.     assert(z == 64)
  43.     0b01 @ 0b01 @ 0b01 @ 0b00 @ (offset >> 1)`16 @ x`8 @ y`8
  44. }
  45. draw_sprite_shape {from_shared}, {offset: u16}, [{x: u8}], [{y: u8}], [{z: u8}] => {
  46.     assert(from_shared == 0)
  47.     0b01 @ 0b01 @ 0b01 @ 0b01 @ (offset >> 1)`16 @ x`8 @ y`8 @ z`8
  48. }
  49. draw_sprite_shape {from_shared}, {offset: u16}, [{x: u8}], [{y: u8}], {z: u8} => {
  50.     assert(from_shared == 1)
  51.     assert(z == 64)
  52.     0b01 @ 0b01 @ 0b01 @ 0b11 @ (offset >> 1)`16 @ x`8 @ y`8
  53. }
  54. draw_sprite_shape {from_shared}, {offset: u16}, [{x: u8}], {y: u8}, {z: u8} => {
  55.     assert(from_shared == 0)
  56.     assert(z == 64)
  57.     0b01 @ 0b01 @ 0b10 @ 0b00 @ (offset >> 1)`16 @ x`8 @ y`8
  58. }
  59. draw_sprite_shape {from_shared}, {offset: u16}, [{x: u8}], {y: u8}, [{z: u8}] => {
  60.     assert(from_shared == 0)
  61.     0b01 @ 0b01 @ 0b10 @ 0b01 @ (offset >> 1)`16 @ x`8 @ y`8 @ z`8
  62. }
  63.  
  64. etc....
RAW Paste Data