CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: Dream of Omnimaga on April 01, 2016, 11:09:29 AM

Title: CE Textlib tilemapping hack and April Fools Wolfeinstein 3D prank
Post by: Dream of Omnimaga on April 01, 2016, 11:09:29 AM
In August 2015, DrDnar released CE Textlib, an ASM library to enhance TI-BASIC programs that uses home screen text, by allowing colors in them and drawing rectangles that can be between 1x1 and 26x10 characters large. It featured chaining, so that multiple commands could be called from 1 single Asm(prgmTEXTLIB instruction, to minimize VAT-searching lag.

However, in March 2016, I discovered that CE Textlib did not check if you tried drawing rectangles outside the home screen boundaries or larger than 26x10 characters and also looped through the screen. By abusing this, the rectangles could also be made not aligned with the Output() grid. Because of the chaining feature, this allowed me to make a tile-mapper with actual sprites in BASIC without Doors CE 9 and with good speed, which eventually became First Fantasy II (https://codewalr.us/index.php?topic=1217.0):
(https://img.ourl.ca/ff2.gif)


What follows is an April Fools joke with a fake Wolfeinstein 3D CE Textlib animated screenshot, but the tilemapper above is actually real:

But this was just the beginning, because by taking advantage of how fast CE Textlib can draw multiple rectangles at once, I decided to attempt taking CE Textlib one step further, so I started learning 3D and raycasting. After much hassle, especially this evening,  I have finally managed to achieve something previously thought impossible in hybrid BASIC: Wolfeinstein 3D CE!
(http://img.ourl.ca/wolfeinstein3D.gif)

Currently, this clone of the popular 1993 first-person shooter supports shooting and wall collision, but ammo doesn't work, green doors have no animation (they open instantly) and there is no enemy nor power-ups. Also, for speed reasons the entire screen is erased then redrawn every frame, so some flickering might be noticed from time to time. The walls are drawn using 18 vertical rectangles and the only way to eliminate the flickering would be to update the floor and ceiling using 36 small rectangles, which would be much slower than erasing everything with just one.

While this looks nowhere as good as the real game and that much better graphics could be achieved in C or ASM, I wanted to show off how far CE Textlib limits could be pushed. Unlike First Fantasy II (https://codewalr.us/index.php?action=dlattach;topic=1217.0;attach=936), Wolfeinstein 3D CE isn't available for download yet, as it still needs polishing, but hopefully it can end up into an actual game in the near future!

Doors CE 9 rectangle commands will support chaining. If such speed can be achieved with a non-hook-based library in a raycaster, imagine how fast it would be with xLIBCE chained rectangles.

</End of April fools prank>


However, TI-BASIC raycasting was actually attempted before, by Axcho from United-TI, who released Ionquest Demo in 2004:
http://www.ticalc.org/archives/files/fileinfo/349/34947.html

It runs at 1.5 FPS on a TI-84 Plus CE and could be modified to use CE Textlib or even xLIBCE's chained rectangle commands for faster speed. The April 1st prank above was inspired from his 3D game. Also, pseudo 3D racing games would definitively be possible with CE Textlib, since an xLIB Outrun clone was attempted before for the TI-84 Plus SE (http://img.ourl.ca/screenshot000-5.gif), but the graphics quality would probably be on-par with the fake Wolfeinstein 3D screenshot.
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: novenary on April 01, 2016, 11:41:46 AM
This looks amazing, great job DJ. :D
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: aetios on April 01, 2016, 11:44:38 AM
A bit choppy, but wow that really shows off the capabilities of the CE. Imagine if that was written in C *.*
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: Dudeman313 on April 01, 2016, 01:07:56 PM
Quote from: aeTIos on April 01, 2016, 11:44:38 AM
A bit choppy, but wow that really shows off the capabilities of the CE. Imagine if that was written in C *.*
Yeah, that is pretty cool! Nice utilization of  the CE's  potentials.
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: p4nix on April 01, 2016, 01:20:49 PM
DJO, you have been chosen to be the official BASIC-god-ninja-wizard from now on... Raycasting in basic... oh my god...
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: c4ooo on April 01, 2016, 01:35:20 PM
Obvius april fools joke is obvious.
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: p4nix on April 01, 2016, 01:43:50 PM
He got me :D
EDIT: Totally confused now.
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: aetios on April 01, 2016, 01:49:23 PM
Quote from: c4ooo on April 01, 2016, 01:35:20 PM
Obvius april fools joke is obvious.
I actually don't think so, DJ has been working on this for some time already and he once showed me an early beta via telegram.
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: tr1p1ea on April 01, 2016, 02:09:49 PM
Very elaborate AF's ... I think it looks great :).
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: Dream of Omnimaga on April 01, 2016, 02:10:59 PM
Quote from: c4ooo on April 01, 2016, 01:35:20 PM
Obvius april fools joke is obvious.
You should download the FFII demo in the other topic. Even with more rectangles to draw it still runs at decent speed.
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: Dream of Omnimaga on April 01, 2016, 09:32:12 PM
On a side note, because of how CE Textlib works, I think I might be able to implement special effects such as when you take damage, the screen would flash to a red-ish hue and when picking up items it would flash to green. I have dynamic color palette support in FFII and since Wolfeinstein 3D only draws 1 set of rectangle in the screen (vs 48 for FFII), I can change colors in real time.
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: critor on April 01, 2016, 09:37:20 PM
Wow.

PrimeCaster 3D written in Basic for the much more powerful HP Prime looks very slow in comparison :
https://tiplanet.org/forum/viewtopic.php?t=15033

Calculator :
(https://tiplanet.org/forum/gallery/image.php?mode=medium&image_id=3756)

Software : (faster, thus using smaller rays)
(https://i.imgur.com/VYKCMhbm.png)

I was sure I had made as much optimisations as I could and it couldn't be improved further... seems I was wrong.
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: Dream of Omnimaga on April 01, 2016, 09:49:35 PM
Well, to be fair, your raycaster actually supports variable walls height and stairs, which isn't the case of mine. :P
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: Dudeman313 on April 02, 2016, 02:58:52 AM
Didn't Ben R. 's Nostromo have flying and stuff, and still run pretty fast?
Title: Re: Wolfeinstein 3D - a TI-BASIC raycaster powered by CE Textlib
Post by: Dream of Omnimaga on April 02, 2016, 03:06:14 AM
That was not a raycaster, plus it was written in ASM.
Title: Re: CE Textlib tilemapping hack and April Fools Wolfeinstein 3D prank
Post by: Dream of Omnimaga on April 02, 2016, 06:58:15 AM
Happy belated April Fools day people. :)

However, the 2D tilemapper is actually real, in case you haven't paid attention to the projects section in the last two weeks (see https://codewalr.us/index.php?topic=1217.0 ), and there actually exists a real TI-BASIC raycasting engine for the monochrome calculators called Ionquest Demo (although it doesn't look as good and runs twice slower). You can download it at http://www.ticalc.org/archives/files/fileinfo/349/34947.html and it runs fine on the 84+CE.


Also, I'm contemplating trying to make a bare-bones Outrun engine with CE Textlib, just for kicks, because I managed to do it in xLIB Monochrome back in 2006, so I'm 100% sure that it would be possible, if not faster, with CE Textlib. See this screenshot:

(http://img.ourl.ca/screenshot000-5.gif)

I bet CE Textlib raycasting is possible too. After all, it was attempted in pure BASIC lol. It just probably won't look as good as in the first post.
Title: Re: CE Textlib tilemapping hack and April Fools Wolfeinstein 3D prank
Post by: Dudeman313 on April 03, 2016, 12:23:34 AM
That screenshot is amazing. O.O
Title: Re: CE Textlib tilemapping hack and April Fools Wolfeinstein 3D prank
Post by: Dream of Omnimaga on April 03, 2016, 02:44:01 AM
Thanks. What I was happy with about that engine is that unlike Lotus Turbo Challenge, my background actually scrolled left and right. I did that engine the cheap way, though, by drawing 4 pre-rendered road chunks with extra pixels at the bottom.
Title: Re: CE Textlib tilemapping hack and April Fools Wolfeinstein 3D prank
Post by: Dudeman313 on April 03, 2016, 09:58:53 PM
How about a CE screen shot for speed comparison?  ;)
Title: Re: CE Textlib tilemapping hack and April Fools Wolfeinstein 3D prank
Post by: Dream of Omnimaga on April 04, 2016, 05:40:45 AM
I'll try to make one later. What is interesting is that the speed gain from 15 MHz calcs to this one was not this big,
Title: Re: CE Textlib tilemapping hack and April Fools Wolfeinstein 3D prank
Post by: Dudeman313 on April 04, 2016, 12:25:59 PM
Quote from: DJ Omnimaga on April 04, 2016, 05:40:45 AM
I'll try to make one later. What is interesting is that the speed gain from 15 MHz calcs to this one was not this big,
I wonder why?  :-|
Title: Re: CE Textlib tilemapping hack and April Fools Wolfeinstein 3D prank
Post by: Dream of Omnimaga on April 04, 2016, 06:13:36 PM
I blame the larger display combined with how poorly implemented TI's text routines were. CE Textlib rectangle display is very fast, but just displaying one row of text characters is actually slower than rendering one Wal-Rush CE Textlib frame. This is why in Axe Parser people recommended using your own font display routine rather than using the default text commands.
Title: Re: CE Textlib tilemapping hack and April Fools Wolfeinstein 3D prank
Post by: Dudeman313 on April 04, 2016, 07:53:57 PM
Oh. Good to know. :)