defines.asm 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. ;*************************************************************************
  2. .define DEBUG 1 ;enable debugmenu
  3. ;*************************************************************************
  4. ;*************************************************************************
  5. ;spc interface definitions:
  6. .define SpcFrameSize 144
  7. .define SpcFramesPerBank 455
  8. .define SpcCmdUploadSong $f1 ;indicates that a song is to be uploaded
  9. .define SpcCmdUploadSongT1 $f2 ;indicates that data for transfer1 is on apu ports
  10. .define SpcCmdUploadSongT2 $f3 ;indicates that data for transfer2 is on apu ports
  11. .define SpcCmdUploadSongDone $f4 ;indicates that song upload is complete
  12. .define SpcCmdReceiveStream $f5 ;indicates that 65816 wants to stream brr data to spc
  13. .define SpcCmdSubmitStreamNumber $f7 ;indicates that hdma transfer has started. It's important that bit0 of this command is set.(brr end bit)
  14. .define SpcCmdReceiveStreamComplete $f6 ;spc wants to end stream transmission.
  15. .define SpcCmdUploadSamplePack $f8 ;indicates that a sample pack is to be uploaded. the rest of the commands are taken from normal song upload
  16. .define SpcCmdUploadSamplePackDone $f9 ;indicates that sample pack upload is complete
  17. .define SpcCmdPlaySoundEffect $fa ;play a sound effect
  18. .define SpcCmdStopSong $fb ;stop song or stream
  19. .define SpcCmdSetSongSpeed $fc ;set timer speed of mod playback routine
  20. .define SpcCmdSetSongChMask $fd ;song channel mask
  21. .define SpcCmdReportType $fe ;type of data spc should respond with
  22. .define SpcScanlineWaitCount 5 ;amount of scanlines to wait before frame send
  23. ;spc fifo commands for other routines to write to
  24. .define SpcFifoCmdUploadSong $02 ;arg 0 is song number
  25. .define SpcFifoCmdUploadSamplePack $04 ;arg 0 is song number
  26. .define SpcFifoCmdStreamBrr $06 ;arg 0 is stream frameset number
  27. .define SpcFifoCmdPlaySE $08 ;arg 0 is stream frameset number
  28. .define SpcFifoCmdStopSong $0a ;arg 0 is stream frameset number
  29. .define SpcFifoCmdSetSpeed $0c ;arg 0 is speed
  30. .define SpcFifoCmdSetChMask $0e ;arg 0 is mask
  31. .define SpcFifoCmdSetReportType $10 ;arg 0 is mask
  32. ;*************************************************************************
  33. ;*************************************************************************
  34. ;background settings
  35. .define FontVramOffset $2500 ;$2800 ;vram offset of the font, starting tile index is $180
  36. .define FontTileConfig $20 ;priority bit set, tiles $100+, palette 1
  37. .define TileBufferSizeX 28 ;number of tiles in tilebuffer per x-line
  38. .define TileBufferSizeY 26 ;number of tiles in tilebuffer per y-line
  39. .define TileMapSizeX 31 ;number of tiles in tilebuffer per x-line
  40. .define TileMapSizeY 31 ;number of tiles in tilebuffer per y-line
  41. ;*************************************************************************
  42. ;*************************************************************************
  43. ;fifo buffer entry definitions:
  44. .define DmaFifoEntryLength 8 ;length of an entry in the dma fifo buffer
  45. .define DmaFifoEntryType DmaFifoBuffer &$ffff + $7e0000
  46. .define DmaFifoEntryCount DmaFifoBuffer &$ffff + $7e0000+1
  47. .define DmaFifoEntryTarget DmaFifoBuffer &$ffff + $7e0000+3
  48. .define DmaFifoEntrySrcLo DmaFifoBuffer &$ffff + $7e0000+5
  49. .define DmaFifoEntrySrcHi DmaFifoBuffer &$ffff + $7e0000+6
  50. .define DmaFifoEntrySrcBank DmaFifoBuffer &$ffff + $7e0000+7
  51. .define DmaFifoBytesPerFrame $1000-$220-$200-$200 ;substract oam and cgram transfer sizes
  52. .define DmaFifoMinTransferSize 128
  53. ;*************************************************************************
  54. ;*************************************************************************
  55. ;object buffer entry definitions:
  56. .define ObjectFileSize 32
  57. .define ObjEntryType ObjectList & $ffff ;0 object type designation
  58. ;bit0=X position sign of sprite(usually 0)
  59. ;bit1=Object size flag
  60. ;bit2=collidable
  61. ;bit3=subroutine? if set, this object has its own subroutine that must be executed every frame
  62. ;bit4=animate? if set, this object is animated(a special table for each object specifies the exact animation with commands for tileloading, waiting, animation loop etc)
  63. ;bit5=bg-bound? if set, this object must move in accordance with background layer 0
  64. ;bit6=object active? if set, this object is active and needs to be drawn. if clear, this sprite doesnt need to be drawn, but must be processed, anyway
  65. ;bit7=object present? if set, this slot has an object. if clear, its considered empty and can be overwritten
  66. .define ObjEntryType2 ObjectList & $ffff + 1 ;extra type definitions. msb set=pseudo-3d sprite that has to be moved when scrolling.
  67. ;bit7=pseudo 3d sprite that needs to be moved according to z-value when background moves
  68. ;bit6=don't upload tiles for this sprite. useful for stuff like particles and such where lots of sprites share the same tiles.
  69. ;bit5=don't upload palette for this sprite.
  70. ;bit4=decaying gravity sprite
  71. ;bits0-3: current position in vector angle LUT (didn't fit anywhere else)
  72. .define ObjEntrySubRout ObjectList & $ffff + 2
  73. .define ObjEntryTileset ObjectList & $ffff + 3
  74. .define ObjEntryTilesetFrame ObjectList & $ffff + 4
  75. .define ObjEntryVramTile ObjectList & $ffff + 5 ;vram tile and
  76. .define ObjEntryPalConf ObjectList & $ffff + 6 ;pal config must be in that order because they are accessed word-wise together
  77. .define ObjEntryXPos ObjectList & $ffff + 7 ;word size
  78. .define ObjEntryYPos ObjectList & $ffff + 9 ;word size
  79. .define ObjEntryAniFrame ObjectList & $ffff + 11
  80. .define ObjEntryAniList ObjectList & $ffff + 12
  81. .define ObjEntryListOffset ObjectList & $ffff + 13
  82. .define ObjEntryPalNumber ObjectList & $ffff + 14
  83. .define ObjEntryObjectNumber ObjectList & $ffff + 15 ;number of object type so other routines know what object the`re dealing with. this is not the number of the object in the lookup table, but an arbitrary number that defines certain object types/groups so they can be moved/deleted alltogether.
  84. .define ObjEntryXDisplacement ObjectList & $ffff + 17 ;used only by obj2oam writer to center objects
  85. .define ObjEntryYDisplacement ObjectList & $ffff + 18 ;used only by obj2oam writer to center objects
  86. .define ObjEntryZDisplacement ObjectList & $ffff + 19 ;used to calculate priority. also used as direct z-value in pseudo-3d scenes.
  87. .define ObjEntryAniCmdRepeat ObjectList & $ffff + 20 ;used by animation list processor. allows repeated nops with a single command
  88. .define ObjEntryColliSub ObjectList & $ffff + 21 ;subroutine to execute when mainchara hits this object(only active if object is collidable)
  89. .define ObjEntryVectorSpeed ObjectList & $ffff + 22 ;bit0-2:subpixel speed. bit3-5:pixel speed. bit7 set: target speed met
  90. .define ObjEntryVectorTarSpeed ObjectList & $ffff + 23 ;bit0-2:subpixel speed target. bit3-5:pixel speed target. bit6,7: movement type(direct, linear slow, linear fast, smooth)
  91. .define ObjEntryVectorDir ObjectList & $ffff + 24 ;bit0-5:direction.0=facing up. bit6=turning direction.(set=clockwise) msb set=target direction met.
  92. .define ObjEntryVectorTarDir ObjectList & $ffff + 25 ;bit0-5:target direction.0=facing up. bit6,7: movement type(direct, linear slow, linear fast, smooth)
  93. .define ObjEntryVectorTurnSpeed ObjectList & $ffff + 26 ;bit0-2:vector speed subpixel buffer. bit3-7: direction turn speed sub-pixel buffer.
  94. .define ObjEntryXSpeed ObjectList & $ffff + 22 ;byte, gets added to x-pos every frame. lower 4bit subpixel precision
  95. .define ObjEntryYSpeed ObjectList & $ffff + 23 ;word, gets added to y-pos every frame. lower 4bit subpixel precision. needs to be word because of +/- handling and gravity
  96. .define ObjEntryGravity ObjectList & $ffff + 25 ;byte, gets added to y-speed every frame.
  97. .define ObjEntryLifeCounter ObjectList & $ffff + 26 ;word, decreased every frame
  98. .define ObjEntrySpareVar ObjectList & $ffff + 27 ;5 bytes of data that can be used as a variable depending on the objects needs. for example, npcs uses this to store direction and walk count
  99. ;.define MaxGravObjCount 20 ;maximum amount of allowed particles onscreen
  100. ;zsort buffer definitions:
  101. .define OamZSortBufferSize 6 ;entries:
  102. ;0 - sprite x
  103. ;1 - sprite y
  104. ;2 - sprite config
  105. ;3 - sprite config
  106. ;4 - size/sign bits (bit0,1) bit7 clear: sprite present flag
  107. ;5 - z priority (scanline number)
  108. .define SpriteTileSizeX 8 ;pixel size of one tile for sprite processor
  109. .define SpriteTileSizeY 8 ;pixel size of one tile for sprite processor
  110. ;*************************************************************************
  111. ;*************************************************************************
  112. ;exit & collision definitions
  113. .define ExitFileSize 8
  114. .define ExitTargetMap ExitList & $ffff
  115. .define ExitSubroutine ExitList & $ffff +1 ;bit 7 indicates that an exit is present and is masked off when jumping. it can conveniently be checked by loading the first word and checking for the sign flag
  116. .define ExitXPosition ExitList & $ffff +2
  117. .define ExitYPosition ExitList & $ffff +3
  118. .define ExitXTargetPosition ExitList & $ffff +4
  119. .define ExitYTargetPosition ExitList & $ffff +5
  120. ;collidable objects definitions
  121. .define ColObjFileSize 6
  122. .define ColObjNumber ColObjList & $ffff ;object number in object list
  123. .define ColObjEnableFlagsSub ColObjList & $ffff +1 ;msb is enable flag, lower 7 bits are subroutine number
  124. ;.define ColObjSubroutine ColObjList & $ffff +2
  125. .define ColObjXPos ColObjList & $ffff +2 ;xpos/8
  126. .define ColObjYPos ColObjList & $ffff +4 ;ypos/8
  127. .define NumberOfCollidableObjects 32 ;how far to check into object array to find collidable objects. slows down object processor alot when many people are walking
  128. ;*************************************************************************
  129. ;*************************************************************************
  130. ;hdma buffer definitions
  131. .define HdmaBufferTableEntry HdmaBuffer & $ffff
  132. .define HdmaBufferFlags HdmaBuffer & $ffff +1
  133. .define HdmaBufferBBusTarget HdmaBuffer & $ffff +2
  134. .define HdmaBufferWriteConfig HdmaBuffer & $ffff +3
  135. .define HdmaBufferRomDataTbl HdmaBuffer & $ffff +4
  136. .define HdmaBufferRomCountTbl HdmaBuffer & $ffff +5
  137. .define HdmaBufferSubRout HdmaBuffer & $ffff +6
  138. .define HdmaBufferRamDataPnt HdmaBuffer & $ffff +7 ;2 bytes
  139. .define HdmaBufferRamCountPnt HdmaBuffer & $ffff +9 ;2 bytes
  140. .define HdmaBufferEntryPnt HdmaBuffer & $ffff +11 ;2 bytes simple relative pointer to hdma table in ram to speed up processing
  141. .define HdmaBufferRomDataPnt HdmaBuffer & $ffff +13 ;3 bytes
  142. .define HdmaBufferRomDataLength HdmaBuffer & $ffff +16 ;3 bytes
  143. .define HdmaBufferRomCountPnt HdmaBuffer & $ffff +19 ;3 bytes
  144. .define HdmaBufferTable HdmaBuffer & $ffff +24 ;start of actual table
  145. .define HdmaBufferSize $340
  146. .define HdmaEffectFileSize 6 ;size of a hdma effect file in rom
  147. .define HdmaBufferNumber 6
  148. .define Hdma3dScrollLineNumber 80 ;number of lines to process for this effect.
  149. ;*************************************************************************
  150. ;*************************************************************************
  151. ;Textbox menu definitions:
  152. .define TextBoxMenuSubrout TextBoxMenuBuffer & $ffff ;uses same subroutines as script commands
  153. .define TextBoxMenuFlags TextBoxMenuBuffer & $ffff + 1
  154. .define TextBoxMenuParam1 TextBoxMenuBuffer & $ffff + 2
  155. .define TextBoxMenuParam2 TextBoxMenuBuffer & $ffff + 3
  156. .define TextBoxMenuParam3 TextBoxMenuBuffer & $ffff + 4
  157. .define TextBoxMenuTilePos TextBoxMenuBuffer & $ffff + 5 ;x-pixelposition inside buffer
  158. .define TextBoxMenuLinePos TextBoxMenuBuffer & $ffff + 6 ;y-pixelposition inside buffer
  159. .define TextBoxMenuVoid TextBoxMenuBuffer & $ffff + 7 ;future expansion
  160. .define TextBoxMenuEntrySize 8
  161. ;*************************************************************************
  162. ;*************************************************************************
  163. ;script commands ($00-$1f)
  164. .define StringEnd 0 ;end string and close textbox immediately
  165. .define StringBreak 1
  166. .define StringCls 2
  167. .define StringButtonCls 3
  168. .define StringFontChng 4 ;takes one additional byte
  169. .define StringEndButton 5 ;wait for button press, then end string and close textbox
  170. .define StringMenuEntry 6 ;create menu entry. takes 4 parameters
  171. .define StringMenuWait 7 ;wait for button press/menu decision
  172. .define StringLoadString 8 ;immediately clear screen and load another textstring. takes 2 parameters(15bit textstring number)
  173. .define StringLoadLevel 9 ;immediately clear screen and load another level. takes 3 parameter(8bit level number, 8bit x-pos, 8bit y-pos target/8)
  174. .define StringPlaySong 10 ;upload & play a mod song. arg0: song number
  175. .define StringGotoBattle 11 ;goto battle mode. arg0: battle number arg1: event routine to load after returning from battle. arg2,3: vwf string to load after returning from battle. 0=don't load any textstring at all
  176. .define StringGotoSubstring 12 ;goto substring, returnable, can be nested 16 times. arg0,1: string number(word)
  177. .define StringSubstringReturn 13 ;return to previous string, no argument
  178. .define StringPrintDecimal 14 ;prints byte in decimal mode. uses substring in ram with return to print number. takes 4 parameter bytes, 3-byte adress of number to print, 1 byte for number length(valid values: 1-4). number can be 32bits long. (4294967295/$ffffffff max). if longer than 16bit, store low word first, then high word.
  179. .define StringEndNoCls 15 ;same as end string, but dont clear screen. (used for statusbox)
  180. .define StringSetPosition 16 ;changes tile draw position in vwf buffer. 1 argument, 0-128 valid
  181. .define StringSetSpeed 17 ;set drawing speed. 1 argument: 0=slowest, 7f=fastest. msb set: draw instantly
  182. .define StringClsNoUpload 18 ;clear screen, but don't upload vwf buffer so textbox doesnt flicker.
  183. .define StringGotoEvent 19 ;reset to debug mode
  184. .define StringCondGotoSub 20 ;conditional goto substring. substring is only printed if all bits set in target bitmask are set in target byte. 6 arguments. arg0,1: substring number(word). arg2-4:target byte to check for condition. arg 5:bitmask to check for with target
  185. .define VwfPlotBufferLength 18*16*6 ;tile number * tile length * line count
  186. .define VwfSpriteUpdFlagsLength 16 ;10 sprites to update, upper 5 sprites at $0, lower 5 sprites at $8
  187. ;*************************************************************************
  188. ;*************************************************************************
  189. ;nwarp daisakusen specific stuff:
  190. .define MaleHitpoints 8 ;hp - health
  191. .define SpasmToRespawn 20
  192. .define DefaultBlockCounter 25 ;number of frames to block after trigger
  193. ;player objects:
  194. .define ObjEntryMaleDirection ObjectList & $ffff + 28 ;direction in which the object is currently facing
  195. ;0=down 1=up 2=left 3=right
  196. .define ObjEntryMaleHP ObjectList & $ffff + 29 ;amount of health this player has. 0=dead
  197. .define ObjEntryMaleInvinc ObjectList & $ffff + 30 ;if not zero, player is invincible
  198. .define ObjEntryMaleSpasmCount ObjectList & $ffff + 30 ;this is the revival counter. if a certain value is reached, player is revived with one hp.
  199. .define ObjEntryMaleBlockCounter ObjectList & $ffff + 31 ;this is the revival counter. if a certain value is reached, player is revived with one hp.
  200. .define OamTypeMainCharaCtrl 3 ;main character top/controlling sprite
  201. .define MainCharaHotspotSize 32 ;size of mainchara hotspot square in pixels
  202. .define NPCHotspotSizeX 14 ;size of walking player hotspot square in pixels
  203. .define NPCHotspotSizeY 20 ;size of walking player hotspot square in pixels
  204. .define NPCHitPointSizeX 12
  205. .define NPCHitPointSizeY 20
  206. ;hdma gradient colors
  207. .define CreditsGradientColor 247 ;cgram entry for color gradient
  208. .define TextBoxGradientColor 113 ;cgram entry for color gradient
  209. .define BattleBoxGradientColor 113 ;cgram entry for color gradient
  210. ;*************************************************************************