Author Topic: ASM: How do I "scroll" sprites down the screen? (TI 83/83 plus/84plus)  (Read 6474 times)

0 Members and 1 Guest are viewing this topic.

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Title says it all...
I'm making a game in ASM, but I'm really new to programming, and I can't make a proper working piece of scipt that scrolls sprites down the screen.
I'm making a guitar-hero like game, where "O" start at the top of the screen, scroll down at a certain speed, and when the "O" matches an "O" in the bottom of the screen, you must press a certain button.

Requirements are:

- It must be possible to drop down some "O" sprites in a specific order, not just randomly. So I can determine the time between each "O" falling down.
- While the "O" is dropping, the Calc must still respond to a keypress, and execute a script when a button is pressed (to see if you pressed the right button at the right time, and increase/decrease score accordingly).

I hope I've been clear about what i'm trying to do.
If anyone could help me out by giving tips, or making a small script that performs a piece of what I want, it'd be a great help!

Thanks in advance!


79% of all statistics are made up randomly.

Offline mapar007

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 550
  • Rating: +28/-5
  • The Great Mata Mata
    • View Profile
Use the regular putspritexor routine (from the asmin28 tutorial) for the displaying of the O, and increment the y-coordinate of the sprite every time you want it to move down.
(sorry, no time for thinking up examples)
« Last Edit: May 02, 2010, 10:04:03 am by mapar007 »

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
Uhu, but you don't have controle while the "redraw-sprite" routine is going on.
So I'd have to increment the y-coordinate, then check for a button, then inc. Y again ect?
The redraw routine would take very long when there are lots of sprites to redraw, and the keypress of the user wouldn't be registerd on the exact time I put a "check keypress" routine between the redraw routines...
And whats the Key command to check if a button is held down, not just pressed?
The whole "perform scripts while a button is pressed down and do something else if not" concept is unfamiliar to me...

More specifically, how to handle multiple sprites???

Also, there's still the problem of how I manage multiple sprites that way...
I want it to be possible to scroll down a number of sprites in a specific order with a varying time interval between them that I can set.

I hope I'm clear (probably not...) and I appreciate your help.

Thank you for your reply!
« Last Edit: May 03, 2010, 11:32:10 am by Jerros »


79% of all statistics are made up randomly.

Offline mapar007

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 550
  • Rating: +28/-5
  • The Great Mata Mata
    • View Profile
Very long? nononono, it's just a few microseconds (or milliseconds for that matter). You don't notice, normally.

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Jerros, I don't think you have a clear understanding of how that assembly routine works.  First of all, drawing an 8x8 sprite fully clipped onto the buffer literally takes less than a millisecond.  You don't actually have to refresh the screen until you have finished drawing all the sprites.  Your layout should be something like this:

Loop:
<Draw Sprites>
<Refresh Screen>
<Pause For Timing>
<Handle Key Presses>
<Sprite Movement>
jp Loop

It sounds like you're pretty new to assembly.  You might want to start a little slower becasue you're trying to do some complicated things that are going to be very confusing without a lot of experience.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Generally in assembly games the screen buffer is totally cleared, redrawn and copied to LCD each frame.

I agree with Quigibo, that you should review your knowledge of assembly. I suggest to review tutorials (trying one different help) and stop by the IRC channel for a quick question and answer (you have calcmaniac and tr1pe1a, from memory) and forum for more important questions. And do simple experiments with assembly, for example doing a menu routine or other that you think you can do.
Debugging can be frustrating but you learn to avoid a lot of errors.

I needed lots of hours of practise before starting to be a little productive. You are prepared when you can do progress without many errors.
Hobbing in calculator projects.

Offline Jerros

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 137
  • Rating: +9/-0
    • View Profile
First of all, thank you for your kind reply.
It's true that I'm quite new to assembly, but I've managed to do quite much in only about 2 months.
As for the routine suggested byQuigibo, I'll try that out, thanks.

I'm very imatience, so I indeed might be rushing into things I dont have a clear understanding of, but I'm a fast learner n_n.
Just one more thing though, you were talking about a "pause for timing" part, but I guess that's just made of some time-consuming commands that don't actually do something, right? (like some NOP's os something... I'll look into that later).

Thank's a lot, I'll see how far I come now!


79% of all statistics are made up randomly.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
I do not know assembly but welcome to Omnimaga and the whole world of calculator programming :D

And good luck in your learning (and future projects)

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Never use NOP.  You might as well try to make the timing code as small as possible.  If you need medium pauses, use a bunch of HALTs.  For precise and very fast pauses, use a few DJNZ $+0 or something like that.  Don't worry about this now, focus on the main code first and run some tests, then add in some pause time if the game runs too fast.

I was just like you when I started out.  I dove right in and then ran into a bunch of weird problems I could never figure out until I finally learned the inner-workings.   For instance, I remember when the same stack being used for both pushing/popping AND for calls really threw me off when I was trying to pass arguments using push and pop.

If you want some useful routines, check out the Axe Parser commands source code.  It has all the stuff you were asking about like detecting keys directly, drawing sprites, screen scrolling, and even sound/music out of the linkport (since this is a guitar hero clone).  You might even consider using Axe if your goal is just trying to make the game, its a lot easier than assembly, and just as fast.  But if the goal is to learn assembly, then try the "Learn Z80 In 28 Days" tutorial, that helped me the most.
___Axe_Parser___
Today the calculator, tomorrow the world!