Commit Graph

309 Commits

Author SHA1 Message Date
Lucas Scharenbroich 7af4a216a0 Add modular dispatch for copy routines; add initial support for tile priority bit 2022-06-12 05:28:12 -05:00
Lucas Scharenbroich 955cf4a580 Remove unused memory and start working on priority renderer 2022-06-09 07:41:58 -05:00
Lucas Scharenbroich e5938cb3c7 Change the entry points based on the engine mode 2022-06-08 23:34:15 -05:00
Lucas Scharenbroich 3c41e97b0f Move dispatch table into K bank and save 9 cycles per tile in dispatch 2022-06-08 17:34:23 -05:00
Lucas Scharenbroich 227643d7df Fix H+V sprite stamp renderer 2022-06-08 17:17:28 -05:00
Lucas Scharenbroich 388470c133 Fix left-edge sprite rendering glitch; was an issue with not erasing sprites when they transition to IS_OFFSCREEN status 2022-06-08 14:25:52 -05:00
Lucas Scharenbroich 1de4c0bc7f Make sure all macros add the vbuff offsets 2022-06-07 10:05:52 -05:00
Lucas Scharenbroich 3591c494bf Add three-sprite rendering function 2022-06-07 10:05:40 -05:00
Lucas Scharenbroich 2c409b02a7 Fix lookup tables to fix boundary rendering 2022-06-06 20:10:15 -05:00
Lucas Scharenbroich b6202ca44c Implement framework for adjusting VBuff tables to handle boundary transitions 2022-06-06 11:23:00 -05:00
Lucas Scharenbroich 36d57f7c2d Fix signed calculations for negative sprite X and Y coordinates 2022-06-02 23:02:06 -05:00
Lucas Scharenbroich 783e813dc2 Implement overlapping rendering for two sprites 2022-06-02 13:59:15 -05:00
Lucas Scharenbroich e6251f05a3 Clean up constants and fix bad addressing mode 2022-06-02 13:06:26 -05:00
Lucas Scharenbroich 4f557230c6 Remove some dead code and streamline some addressing. Fix bug in dispatch macro 2022-06-02 12:28:49 -05:00
Lucas Scharenbroich 83ec527b06 Make the test demo more sophisticated; multiple sprites 2022-06-01 22:24:45 -05:00
Lucas Scharenbroich 24ebb1f3af Fix Tile Store lookup initialization bug 2022-06-01 21:12:54 -05:00
Lucas Scharenbroich a938639c1b Fix initialization bug in TileStore 2022-06-01 13:55:04 -05:00
Lucas Scharenbroich b022162036 Fix vertical offset bug; was using the TileStore lookup index, not the TileStore offset 2022-06-01 09:19:28 -05:00
Lucas Scharenbroich cde517bcc9 Fix single-step vertical displacement issue 2022-06-01 07:50:19 -05:00
Lucas Scharenbroich dec50bc6fc Fix several bugs; biggest one in the SpriteStamp routine 2022-05-31 22:53:33 -05:00
Lucas Scharenbroich 98adfe5daa Continuing to tweak and debug 2022-05-31 16:31:44 -05:00
Lucas Scharenbroich bba8929db7 PRoperly initialize Lookup tables 2022-05-31 13:01:09 -05:00
Lucas Scharenbroich 10d6dc5931 Fix crashing when trying to render sprite; sprite not visible but have end-to-end code execution 2022-05-31 09:14:25 -05:00
Lucas Scharenbroich 78d7dafe14 Another checkpoint; converging on the working implementation 2022-05-31 08:43:26 -05:00
Lucas Scharenbroich 7909113a97 Checkpoint 2022-05-26 19:36:40 -05:00
Lucas Scharenbroich 5577105be8 Complete unrolled loop for clearing sprites from the tile store 2022-05-23 15:18:34 -05:00
Lucas Scharenbroich 9da3616c1d Start working to bring sprites rendering back into the pipeline 2022-05-22 23:54:47 -05:00
Lucas Scharenbroich d27b10b6fd Fix nasty RTable initialization bug 2022-05-22 23:52:54 -05:00
Lucas Scharenbroich 8582ecb320 Fix weird search/replace bug 2022-05-22 21:57:52 -05:00
Lucas Scharenbroich 9ac9ea623e More banking fixes 2022-05-19 23:40:45 -05:00
Lucas Scharenbroich fc48330061 Fix bug in tile rendering and tile sheet copying 2022-05-18 22:49:14 -05:00
Lucas Scharenbroich fd07ead8ed Get tile data to display from code field 2022-05-18 21:39:39 -05:00
Lucas Scharenbroich 755ac3fbfd Move most data storage to separate bank; fix many banking bugs 2022-05-18 21:00:06 -05:00
Lucas Scharenbroich 01e92a7b62 Update; tool is compiling while referencing new rederer pipeline 2022-05-18 00:34:25 -05:00
Lucas Scharenbroich 7f6e5d1b1f Work checkpoint 2022-04-29 12:38:04 -05:00
Lucas Scharenbroich 4d6f11a9ba Initialize the graphics screen via the toolset 2022-04-25 17:11:48 -05:00
Lucas Scharenbroich 1522922abe Complete initialization sequence. 2022-04-25 16:35:47 -05:00
Lucas Scharenbroich e5da3991cd Start to split the tiles into high-level and low-level code 2022-04-25 16:34:54 -05:00
Lucas Scharenbroich 5745482ef6 Fix bank setting on toolset entry 2022-04-25 11:32:25 -05:00
Lucas Scharenbroich d107365d79 Break up large source code files to help with dependency ordering 2022-04-25 11:32:06 -05:00
Lucas Scharenbroich 29d70dc567 Break up large source code files to help with dependency ordering 2022-04-25 11:30:24 -05:00
Lucas Scharenbroich 76180b6feb Basic working user tool framework 2022-04-24 14:45:07 -05:00
Lucas Scharenbroich 1f9f2aee0c Thank to Kelvin Sherlock for pointing out that the source files were not setting the register state directive 2022-04-23 15:41:25 -05:00
Lucas Scharenbroich 9692277677 Work on fixing linker / OMF errors 2022-04-23 12:48:13 -05:00
Lucas Scharenbroich e2710ace85 Refactor to support building a tool and new demo to try and use it [not working] 2022-04-23 00:47:13 -05:00
Lucas Scharenbroich 8bb17895a9 Rough outline of streamlined sprite subsystem
* Split the creation of the sprite stamps from adding the
  sprites themselves.  This allows for 48 stamps that can
  be pre-rendered and quickly reassigned to sprites for
  animations.

* Inlined all calls to PushDirtyTile.  This both removed
  significant overhead from calling the small function and,
  since almost all callers we checking multiple tiles, we
  were able to avoid incrementing the count each time and
  just add a single incrments at the end.

* Switched from recording each tile that a sprite intersects
  with each from to only recording the top-left tile and the
  overlap size.  This reduced overhead for larger sprites
  and removed the needs for an end-of-list marker.

* Much more aggressive caching of Sprite and Tile Store
  values in order to streamline the inner tile dispatch
  routines.

* Moving TileStore and Sprites (and other supporting
  data structures) into a separate data bank.  Needed just
  for size purposes and provide micro-optimizations by
  opening up the use of abs,y addressing modes.

* Revamped multi-sprite rendering code to avoid the need to
  copy any masks and all stacked sprites can be drawn
  via a sequence of and [addrX],y; ora (addrX),y where
  addrX is set once per tile.

* General streamlining to reduct overhead. This work was
  focused on removing as much per-tile overhead as possible.
2022-04-20 07:43:16 -05:00
Lucas Scharenbroich df0d0ccada Commit to a huge unrolled loop to do bitfield -> render function 2022-02-25 17:05:32 -06:00
Lucas Scharenbroich ef620e48a3 Remove cached value; too slow to maintain on sprite remove 2022-02-25 17:03:36 -06:00
Lucas Scharenbroich 7bde48e36c Enable all dirty bits to minimize per-frame, per-sprite work 2022-02-23 08:41:02 -06:00
Lucas Scharenbroich 88fba6cd15 Add plb to prevent crash in unimplemented multisprite handler 2022-02-22 21:37:03 -06:00
Lucas Scharenbroich 19ae2b0866 Remove stray pla that prevented more than one sprite from rendering 2022-02-22 21:27:47 -06:00
Lucas Scharenbroich 2507724a49 More sprite streamlining
* Added a TS_LAST_VBUFF cached value in the tile store
* Added a fast path for single sprite w/fast test
* Improved raster timing granularity for visual profiling

All of the code paths are generally good.  Both the _RenderSprites
and _ApplyDirtyTiles functions take a fair bit of raster time. Will
continue to try and streamline the data structures and code to
reduce overhead.`
2022-02-22 02:35:21 -06:00
Lucas Scharenbroich 56bfdc4236 Fix sprite VBUFF offset calculation 2022-02-21 15:58:16 -06:00
Lucas Scharenbroich e0912c8956 More tweaks and fixes
* Adjusted tile calculation when drawing sprites
* Fixed incorred draw order in 16x16 sprite
* Added more early-out checks to save work
2022-02-21 15:45:11 -06:00
Lucas Scharenbroich b4025f11fc Fix stray push instruction 2022-02-21 14:31:05 -06:00
Lucas Scharenbroich 9d401a5861 Fix masking bug in sprite pre-calc 2022-02-21 14:25:55 -06:00
Lucas Scharenbroich 54474bbe5f Add more pre-computed values to the sprite structure 2022-02-21 13:33:39 -06:00
Lucas Scharenbroich 8b9415a7a5 Working through integration bugs
* Gave active list dedicated direct page space
* Change active list bit test from ror to asl to avoid barrel shift
* Various address fixes
2022-02-21 10:31:35 -06:00
Lucas Scharenbroich bb83e7f7c5 Background rendering again 2022-02-18 20:43:55 -06:00
Lucas Scharenbroich 95572fbf49 Fix the mask values when enumerating through the sprite sheet 2022-02-18 16:20:07 -06:00
Lucas Scharenbroich 260b2097c2 Continue fixing code issues; strange relocation error happening 2022-02-18 13:42:37 -06:00
Lucas Scharenbroich 95058fb969 Checkpoint for sprite rewrite
All of the sprite rendering has been deferred down to the level of
the tile drawing. Sprites are no longer drawn/erased, but instead
a sprite sheet is generated in AddSprite and referenced by the
renderer.

Because there is no longer a single off-screen buffer that holds
a copy of all the rendered sprites, the TileStore size must be
expanded to hold a reference to the sprite data address fo each
tile.  This increase in data structure size require the TileStore
to be put into its own bank and appropriate code restructuring.

The benefits to the rewrite are significant:

  1. Sprites are never drawn/erased off-screen.  They are only
     ever drawn directly to the screen or play field.
  2. The concept of "damaged" sprites is gone.  Every dirty tile
     automatically renders just to portion of a sprite that it
     intersects.

These two properties result in a substantial increase in throughput.
2022-02-18 12:12:32 -06:00
Lucas Scharenbroich 397df074ac Sprite state rework; have run out of bank space 2022-02-07 01:19:31 -06:00
Lucas Scharenbroich 89ea425043 Start work on sprite attribute caching 2022-02-04 12:37:05 -06:00
Lucas Scharenbroich 8b852485ac Fix dirty sprite renderer when StartX and StartY are not zero 2022-02-03 23:44:46 -06:00
Lucas Scharenbroich 525f6d9c67 Add specialized erase routines for different sprite sizes 2022-02-03 08:59:10 -06:00
Lucas Scharenbroich d3b61f8de6 Merge branch 'toolbox-conversion' 2022-02-03 08:51:49 -06:00
Lucas Scharenbroich 1b9425b620 Streamline sprite functions; untested conceptual changes 2022-02-03 08:50:11 -06:00
Lucas Scharenbroich 16a3a385a9 Update some comments 2022-02-02 17:24:27 -06:00
Lucas Scharenbroich 5f492fd557 Save 1 cycle per line in the PEA fast-path for odd-aligned blits 2022-02-02 14:30:48 -06:00
Lucas Scharenbroich 1fe02e035c Checkpoint 2022-02-02 10:21:31 -06:00
Lucas Scharenbroich 027f9746ec Checkpoint of work 2022-01-19 20:58:57 -06:00
Lucas Scharenbroich 7d76089215 Remove some dead code 2021-11-22 16:53:47 -06:00
Lucas Scharenbroich 140126afd8 Optimize odd-aligned case in the blitter
The SEP/REP pairs that are used to move in and out
of 8-bit mode to do the single-byte pushed on the left
and right edges of the screen can also be used to clear
the necessary carry and overflow flags.
2021-11-22 16:13:29 -06:00
Lucas Scharenbroich 5bc9cc7ff2 Add a SPRITE_HIDE flag to toggle whether a sprite is drawn or not 2021-11-22 13:26:25 -06:00
Lucas Scharenbroich 2683a91e93 Fix sprite rendering with overlapping sprites. Must erase all sprites first, then re-render 2021-11-20 21:58:09 -06:00
Lucas Scharenbroich 90267e4646 Test updating tile ID in UpdateSprite for a run sequence. 2021-11-20 20:33:27 -06:00
Lucas Scharenbroich 76801c0e5e Simplify all of the remaining tile blitters 2021-11-20 13:58:24 -06:00
Lucas Scharenbroich cd5de05d74 Most of the horizontal flip routines are not needed since the _GetTileAddr function returns the correct tile address. Need to finish auditing other Tile blitters 2021-11-20 13:54:19 -06:00
Lucas Scharenbroich 65ce5cbbc0 Add 16x16 vertical flip routine 2021-11-20 13:26:00 -06:00
Lucas Scharenbroich b607275089 Separate updating a sprite's position with updating it's flags 2021-11-20 12:16:03 -06:00
Lucas Scharenbroich 0cc28f9e6e Generalize _DrawSprite to handle all sizes and flip bits. 2021-11-20 12:00:21 -06:00
Lucas Scharenbroich a7ba1e4b6b Add final tile blitter 2021-11-19 16:48:39 -06:00
Lucas Scharenbroich fd6c686a95 Fix ordering bug that caused /usr/bin/bash0 values to overwrite the sprite 2021-11-19 16:40:21 -06:00
Lucas Scharenbroich 39303041f9 Add priority dynamic tiles + sprite blitter 2021-11-19 16:30:22 -06:00
Lucas Scharenbroich 44cbba3f23 Add in new variants for sprite and priority tiles 2021-11-19 15:07:43 -06:00
Lucas Scharenbroich 5fdb4bcf06 Fix transposed argument in macro definition; dynamic tile + sprite now working 2021-11-19 13:26:19 -06:00
Lucas Scharenbroich b4871efe8f Streamlining tile blitter macros 2021-11-19 13:00:59 -06:00
Lucas Scharenbroich 4c31a0d056 Reorg of exception handling code in the core blitter
* Moved V-flag handling outside of the 32-byte exception handler
* Switched relative branches to JMP to save a cycle per word
* Updated macros to create a full code snippet instead of assuming
  certain values exist in the exception handler buffer
2021-11-19 10:24:09 -06:00
Lucas Scharenbroich 0a9eb76ab5 Checkpoint; have old Dynamic Tile Renderers working 2021-11-18 16:23:44 -06:00
Lucas Scharenbroich ba76b0047c Checkpoint on dynamic tile blitters 2021-11-18 15:36:36 -06:00
Lucas Scharenbroich 9a6eb45b20 Add Masked Sprite Tile blitter and fix some minor issues with the macro 2021-11-15 21:23:15 -06:00
Lucas Scharenbroich 976ab3163b Fix offset for filling wrap-around byte in BG1 2021-11-15 12:32:38 -06:00
Lucas Scharenbroich dfd5549918 Sync up with current WIP 2021-11-15 12:23:38 -06:00
Lucas Scharenbroich cc8e03e6d3 Add SCB binding infrastructure 2021-11-13 19:45:27 -06:00
Lucas Scharenbroich b87e2a8d33 Fix register assignments for dynamic tile renderer 2021-11-13 19:44:30 -06:00
Lucas Scharenbroich 596777da8d Enable non-sprite, solid dynamic tiles 2021-11-12 15:11:29 -06:00
Lucas Scharenbroich bab57f6e43 Add VSYNC toggle 2021-11-12 11:27:43 -06:00
Lucas Scharenbroich de5bdc6041 Rename tile blitters to match internal bit fields and add in the solid prioity blitter 2021-11-12 09:07:51 -06:00
Lucas Scharenbroich 673b97419a Clear sprite flag when erasing sprite 2021-11-11 22:22:10 -06:00
Lucas Scharenbroich dec9a3d106 Fix fast-path return value in PushDirtyTile and correct handling of TS_SPRITE_FLAG 2021-11-11 22:10:54 -06:00
Lucas Scharenbroich 678c9a0563 Initial shell of generalize sprite size support; just for marking the dirty tiles 2021-11-11 17:06:38 -06:00
Lucas Scharenbroich bb5f4493d9 Fully integration simple (8x8) sprites into the render pipeline 2021-11-01 23:36:53 -05:00
Lucas Scharenbroich 631f40da23 Nearly complete integration of sprites into rendering function 2021-10-31 15:42:59 -05:00
Lucas Scharenbroich 2f73b9acf5 Small improvements to sprite prototype to fix dirty tiles getting out of sync 2021-10-30 19:24:23 -05:00
Lucas Scharenbroich b4155dc751 Expose the ApplyTiles subroutine 2021-10-29 00:52:29 -05:00
Lucas Scharenbroich 9ecc262c58 First pass at validating erasing the sprite on update 2021-10-28 22:19:18 -05:00
Lucas Scharenbroich 0a7d9e15c7 Add external entry point to the erase function 2021-10-28 22:18:33 -05:00
Lucas Scharenbroich 7ec1b8bc29 Fix dumb initialization bug in sprite plane 2021-10-28 21:52:48 -05:00
Lucas Scharenbroich 4e46a6af85 WIP: manual sprite rendering showing on screen 2021-10-28 21:41:01 -05:00
Lucas Scharenbroich 2feb6f590b Add address in sprite plane for tile rendering; use in tile dispatcher 2021-10-27 00:14:19 -05:00
Lucas Scharenbroich cc18c67491 Expand tile blitter temp space 2021-10-27 00:11:13 -05:00
Lucas Scharenbroich 82c1a8e2e4 Remember to cacluate the tile address when adding to the dirty tile list 2021-10-26 21:34:38 -05:00
Lucas Scharenbroich 0366c1a0e0 Fix missing index in the dirty tile initializations 2021-10-26 21:21:08 -05:00
Lucas Scharenbroich 3b8bf652e1 Continued bug fixing
* Missed an XBA to swap tile command bits into a proper index range
* Explicitly track the BASE_ADDR
* Fix some register overwriting
* Add an UpdateSprite method
2021-10-23 22:31:38 -05:00
Lucas Scharenbroich 494673416b Fix several incorrect uses of internal API; work toward functional demo 2021-10-22 00:56:12 -05:00
Lucas Scharenbroich 4e779e71d2 Tile rendering reorganization
This significantly simplifies the dispatch process by creating a
proper backing store for the tiles.  Most values that were
calcualted on the fly are now stored as constants in the tile
store.

Also, all tile updated are run through the dirty tile list which
solved a checken-and-egg problem of which order to do sprites vs
new tiles and affords a lot of optimizations since tile rendering
is deferred and each tile is only drawn at most once per frame.
2021-10-21 08:50:07 -05:00
Lucas Scharenbroich c4762888ed Add brief readme to start documenting the internals of GTE 2021-10-21 08:47:17 -05:00
Lucas Scharenbroich 4d224a92d9 Fix pre-shift bug in the tile address calculation 2021-10-11 16:47:38 -05:00
Lucas Scharenbroich 4338b64338 First cut at a non-trivial overlay. Pallettes and tile indexes still to be fixed 2021-10-11 14:09:38 -05:00
Lucas Scharenbroich 2966b1052b Add rendering path for masked dynamic tiles 2021-10-07 23:54:45 -05:00
Lucas Scharenbroich d5421afdbd Fix off-by-one issue in tile IDs and make the entry point consistent in the code field generator 2021-10-07 18:33:06 -05:00
Lucas Scharenbroich 4006f76c02 Fix bcc/bcs typo when initializing timers 2021-10-07 16:38:20 -05:00
Lucas Scharenbroich 87ded17e20 Initial Tiled tile animation export support
* Tiled tile animations read from TSX files
* Hooks for initialization generated by the tiled export tool
* Animated tiles implements with dynamic tiles backed by 2KB of direct
  page space in Bank 00
* Animation resolution limited to 1/60th incremenents

TODO
* Fix crasher in the _DoScriptSequ timer callback
* Fix single-line of garbage on the top line of the dynamic tiles
2021-10-06 07:10:09 -05:00
Lucas Scharenbroich a82c1248db Add untested framework for handling fringe tile rendering 2021-08-30 22:14:04 -05:00
Lucas Scharenbroich f55192436a Final reorg; all projects build into a unified disk image for testing 2021-08-26 17:15:44 -05:00
Lucas Scharenbroich dcf93892a7 Reorg some more files and tweak paths 2021-08-26 16:45:23 -05:00
Lucas Scharenbroich 2e11ba74ee Rename memory init file 2021-08-26 16:43:14 -05:00
Lucas Scharenbroich 1263375095 Move test app into its own demo folder 2021-08-26 16:24:46 -05:00
Lucas Scharenbroich 69c6104742 Small initialization and jsr/jsl updates 2021-08-26 16:12:08 -05:00
Lucas Scharenbroich 4af66fa13a Fix initialization order 2021-08-26 09:45:40 -05:00
Lucas Scharenbroich fe18759759 Refactor original demo driver to use GTE Core; move functions around 2021-08-26 08:52:43 -05:00
Lucas Scharenbroich 7d5f7aa721 Refactor GTE Core to be included as an independent Segment in other projects 2021-08-25 09:38:02 -05:00
Lucas Scharenbroich 23f7e5b0fb Fully flesh out Script execution implementation 2021-08-25 09:28:53 -05:00
Lucas Scharenbroich 740a0f260d Fix bug that causes one-shot timers to loop forever 2021-08-24 15:58:36 -05:00
Lucas Scharenbroich 48bb361730 Early peek at the Timers/Scripting engine 2021-08-24 15:45:33 -05:00
Lucas Scharenbroich 238d2f0a6f Fix banking bug and enable BG1 tile maps 2021-08-20 20:20:47 -05:00
Lucas Scharenbroich e607612344 Add initial build-out of BG1 tile map support 2021-08-19 01:22:36 -05:00
Lucas Scharenbroich 4c5b090afe Fix crashing bug when replacing BG1 tiles with BG0 tiles 2021-08-19 01:21:37 -05:00
Lucas Scharenbroich 07ac2b017f Fix indexing error in Tiled export. Solid tiles are no longer marked as masked 2021-08-19 00:47:34 -05:00
Lucas Scharenbroich 4609b5c4b9 Identify tiles that should be masked from Tiled maps 2021-08-17 16:23:23 -05:00
Lucas Scharenbroich 55e15aa894 Restore full tile dispatcher code 2021-08-17 09:46:45 -05:00
Lucas Scharenbroich b35a2c1e6e Complete masked tile rendering implementation
The core data tables were reworked to pre-reverse all of the
entries to directly match the right-to-left ordering of the code
fields.  This simplified some code but was required for register
reuse in the masked tile renderer.

Also fixed several offset calculation issues in the masked tile
renderer.
2021-08-17 09:33:27 -05:00
Lucas Scharenbroich 5ad95f4609 Use 8-bit accumulator to read softswitches 2021-08-15 09:25:42 -05:00
Lucas Scharenbroich 2540359f60 Fix plx/pla ordering in tile dispatcher 2021-08-14 21:56:08 -05:00
Lucas Scharenbroich 1492ac3b36 Map Tiled Horizontal and Vertical flip flags onto GTE equivalents 2021-08-14 21:22:21 -05:00
Lucas Scharenbroich 232f94d30e Fix layer comparison function 2021-08-14 21:09:35 -05:00
Lucas Scharenbroich d9133a2170 Switch to using exported Tiled project assets 2021-08-14 20:58:37 -05:00
Lucas Scharenbroich ce51563913 Fix small code issues and sync up tool output with code changes. Maps render again with solid tiles 2021-08-13 11:57:41 -05:00
Lucas Scharenbroich 652729081e Stub in more tile rendering functions; does not crash but renders incorrectly 2021-08-13 11:38:06 -05:00