Update: Bug fixes
Here's a little line drawing routine I've used for Whiplash Taxi and some other work-in-progress carts.
I wanted to package it up like a drop in tline
replacement.
It's equivalent to regular tline
, but instead of drawing each tile it uses it to lookup a higher resolution 8x8 tile region and draws that instead. The result is a map with 8 times the detail (or 8 times the size, depending on how you look at it).
The demo is a simple go-cart example. You can press X to toggle between the new routine and the regular tline
function.
The actual routine is in tab 1 and consumes 547 tokens.
To use it, you first create some 8x8 "textures" at the top left of your map region:

Then you create corresponding sprites in sprite page 1:

Then use the sprites in page 1 to draw on the map:

Then call the tlinex
function to render the map, the same way you would call the regular tline
.
Some caveats:
- It's slower than tline, because it's calculating and performing multiple tline calls.
- Especially if you zoom out a lot, it will slot down a lot (i.e. large values for the mdx,mdy parameters meaning the tline spans a lot of map cells)
- It doesn't handle
camera
offsets. - It doesn't handle
clip
regions (and resets theclip
region). - There are some occasional visual artifacts.
Perhaps someone will find this useful :)



Here's a slightly simpler version if you only need to draw horizontal lines.
The parameters are: x0,y,x1,mx,my,mdx,mdy,layers
I.e. there's no y1. You're also responsible for making sure x0 < x1, otherwise it won't work correctly.
The tlinex function is 448 tokens.



Hey Tom,
I always get interested when people talk token reduction. 🙂
You can get the tline() function and its helpers down to 422 by taking advantage of some API features, like poke() taking multiple args for instance, and also improve perf a smidge by using shifts and masks where you mul/div/mod by a power of 2.
You'd probably just wanna put your version of the second tab next to mine in a diff program to see what I actually did.
(nice work btw)
[Please log in to post a comment]