[TI Asm] Tron Project

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
User avatar
waeV
New Member
Posts: 74
Joined: Wed 23 Apr, 2008 12:52 am
Location: Maine

[TI Asm] Tron Project

Post by waeV »

Well, I started getting back into assembly (but I'm still too lazy to spend the full 28 days taking the tutorial). I started by making a tron clone in basic, then refining it to make it run as fast as possible. I've reached the limits of Ti-basic, however, and anything with a halfway decent AI is pretty dang slow. Naturally, I turned to assembly.

Here's the pseudocode for what i did in Ti-Basic:

Code: Select all

Lbl A
pxl-on(x1,y1)
pxl-on(x2,y2)

prgmAISUB

getkey
determine direction based on input

inc / dec x and y variables according to direction

check if the pixel about to be turned on is already on, if so goto B
goto A

Lbl B
determine winner/loser
The first problem I see is that I don't know how to display the 1 pixel lightcycle. Can a sprite be defined as one pixel? Ideally there would be a pixel-on and pixel-text command that I could use.
My ethicator machine must have had a built-in moral compromise spectral release phantasmatron! I'm a genius!
Image
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Re: [TI Asm] Tron Project

Post by King Harold »

Well with asm, you don't have to use commands. You can just test/set the pixels directly, making it faster. Day 24 of the 28 days tells you most of what you should know about testing/setting pixels. If the pixel-coordinate is a constant (not likely, but who knows?) you could just use the bit/set instructions. Theoretically it's also possible for non-constant coordinates, but not usually a good plan (smc or a large switch block for something so simple?)

Now that I think about it, maybe smc would be viable alternative..
Maybe something like this?

Code: Select all

CheckPixel:
;returns Z if white, NZ if black
;A = x coordinate
;L = y coordinate
;coordinates must be inside the valid range for the result to make sense
 ld h,0
 ld d,h
 ld e,l
 add hl,hl
 add hl,de
 add hl,hl
 add hl,hl
 ld e,a
 srl e
 srl e
 srl e
 add hl,de
 ld de,PlotScreen
 add hl,de
 and 7
 add a,a
 add a,a
 add a,a
 or $46
 ld (bit+1),a
bit:
 bit 0,(hl)
 ret
Ok maybe not such a good plan after all, this is huge, and mostly a copy of GetPixel.. But no loop (which can only be up to 7 iterations long anyway..)
User avatar
waeV
New Member
Posts: 74
Joined: Wed 23 Apr, 2008 12:52 am
Location: Maine

Re: [TI Asm] Tron Project

Post by waeV »

Oh, ok I don't know why I didn't think to look in day 24, I was milling about in the sprite section. Thanks. :mrgreen:
My ethicator machine must have had a built-in moral compromise spectral release phantasmatron! I'm a genius!
Image
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Re: [TI Asm] Tron Project

Post by cjgone »

Ah... I remember learning sprites in 28 days and being utterly confused for like an extremely long time.

Have fun with that I guess. :P
Post Reply