Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: thydowulays on January 09, 2012, 10:14:10 pm

Title: So what next?
Post by: thydowulays on January 09, 2012, 10:14:10 pm
So, I must say I am quite happy to announce that I have successfully completed Hot Dogs ASM tutorial and ASM in 28 days. It's cool and all, but I don't really know where to go from here. Would anyone suggest anything? I don't know how to do sprites yet and ASM in 28 days' tutorial on it is too difficult to understand. If you know anybody that can help with this, could you please? I would really like to start making ASM games, as the ASM section is declining quite badly and I'd like to see more than 1-2 projects in the works :) Also, does anyone have any simple source code for a simple game I can see? Thanks so much everybody here, I am no longer restricted to just BASIC or Axe, but now I know a lot more. Sincerely, thydowulays
Title: Re: So what next?
Post by: Deep Toaster on January 09, 2012, 10:15:18 pm
http://ticalc.org/pub/83plus/asm/source/ has lots of them. Good luck!
Title: Re: So what next?
Post by: thydowulays on January 09, 2012, 10:16:30 pm
Thanks! I didn't even know Ticalc had a section for sources o.o
Title: Re: So what next?
Post by: TIfanx1999 on January 10, 2012, 07:15:39 am
You could also try to write a small game to get your feet wet. If you have any questions (sprites or otherwise) you can always post them <a href=http://www.omnimaga.org/index.php?board=85.0>here,</a> or ask in IRC if some one is around. There are plenty of knowledgeable people willing to help out. ;) <a href=http://wikiti.brandonw.net/index.php?title=WikiTI_Home>WikiTI</a> is also an excellent resource.
Title: Re: So what next?
Post by: chickendude on January 10, 2012, 10:58:55 am
Yay! Another ASM programmer! To start out with, the ion routines should work well, they're easy to use and supported by pretty much all modern shells. If you want, start a few easy projects or two and post them here and i (or we :)) can help you get started, if you have questions on how to do this or that, etc. I've also posted the source to Monopoly (and the RPG i started) and can upload the current source(s) if you want to take a look through it(them), though it might be a little confusing. Later i plan to document everything a lot better, but they're there if you want them and i'd be more than glad to explain anything you don't understand (or if you have questions about the source of another game from ticalc). Reading through the old asm programming help sections on sites like MaxCoderz (or RevSoft, though you'd have to use the wayback machine) can be interesting.

Do you have any ideas of games you'd like to try to write?

EDIT: And if you have any particular questions about sprites, ask away. To copy the graphbuffer (gbuf) to the LCD, i'd just use ion's fastcopy routine.
Title: Re: So what next?
Post by: Xeda112358 on January 10, 2012, 12:13:42 pm
Wow, there isn't a sprite tutorial yet? Well I will say that I much prefer aligned sprites as they are a lot simpler, smaller, and faster. You have a few ways to draw aligned sprites. You can draw them directly to the LCD or to the buffer. Drawing to the buffer is faster, so in this explanation, we will draw there. The screen buffer is set up with 12 bytes per row and 64 rows. If you want to draw 8x8 tiles you will have 12 to fit across and 8 down. So here is a routine I will call DrawTile and it will use a mask of OR (it draws on top of the data like the OS RecallPic ):
Code: [Select]
DrawTile:
;Inputs:
;     A is the tile number (0 to 95, draws columns, then rows)
;     DE points to the sprite data
     sub 96               ;this will set the c flag if the result is negative
     ret nc               ;Exits if the sprite is out of range
     ld bc,96             ;there are 96 bytes in 8 rows
     ld hl,plotSScreen-96 ;the graph buffer minus 96
       add hl,bc          ;Next row down
       add a,12           ;We are eliminating rows
       jr nc,$-3          ;
     ld c,a               ;b is already 0, so do not worry
     add hl,bc            ;BC is the X offset
;HL points to where to draw the sprite
;DE points to the sprite data
     ld bc,080Ch          ;sets C to 12 and B to 8 (the height of th sprite
TileLoop:
        ld a,(de)         ;gets the next byte of the sprite
        or (hl)           ;performs OR logic witht he buffer
        ld (hl),a         ;copies the data to the buffer
        inc de            ;points to the next sprite byte
        ld a,b            ;we are saving B
        ld b,0            ;now BC is 12
        add hl,bc         ;Now HL points tot he next row
        ld b,a            ;restores b
        djnz TileLoop     ;Decrements B, if it is not 0, loop again
      ret
with the "or (hl)" part, you can change that to other forms of logic. Some examples are:
To overwrite the screen data, remove the or (hl)
To use AND logic, replace or (hl) with and (hl)
To use XOR logic, replace or (hl) with xor (hl)
To erase, you need to invert the sprite data and use it asa mask. replace or (hl) with cpl \ and (hl)
Draw the sprite inverted and overwrite the screen data, replace or (hl) with cpl
EDIT: Also, you can easily incorporate that as a subroutine for drawing a tilemap, if you wanted to :)
Title: Re: So what next?
Post by: thepenguin77 on January 10, 2012, 05:07:29 pm
As far as your first project goes, make something really simple that you can complete without too much difficulty. I think a great starting game would be a tunnel game or a snake game, both are relatively simple. For even more simplicity, you could make them homescreen based games. (Be aware that asm is like 100 times faster than basic for homescreen stuff)

Also, most importantly, whatever you make, don't upload it to ticalc.org. You wouldn't want to tarnish your name now would you? (In 6 months, you will laugh at this game and will be glad I told you not to release it)
Title: Re: So what next?
Post by: thydowulays on January 10, 2012, 05:12:04 pm
@Xeda112358, okay I get that! Thanks!

And my game will be super simple, asm still confuses me a little bit, so don't expect much lol

@thepenguin77 Thanks for the advice! Only one thing though, I don't even know how to make a tunnel game in Axe, let alone asm lol. I think my first game will be a homescreen maze game, using ASCII characters. It'll be called ASCIIAdventures lol. Do you know of any tunnel games in Axe that I could look at the source for? I've always wanted to learn how to do that..... thanks! :)
Title: Re: So what next?
Post by: Hot_Dog on January 10, 2012, 05:13:47 pm
You can try this for a sprite tutorial:

http://www.omnimaga.org/index.php?action=dlattach;topic=2076.0;attach=2964

It's a lesson I haven't officially released, but you can at least learn about "Display Image", which is a sweet BCALL for beginners and sprites
Title: Re: So what next?
Post by: thydowulays on January 10, 2012, 05:14:41 pm
Thanks so much! Also, thanks for your amazing tutorial, I would have never learned ASM if it wasn't for it :)
Title: Re: So what next?
Post by: Hot_Dog on January 10, 2012, 05:20:05 pm
You're welcome!  And I'm in agreement with other people on the page.  Start with something small.  Something like "what number am I thinking of" or a tic-tac-toe game
Title: Re: So what next?
Post by: thydowulays on January 10, 2012, 05:48:46 pm
Okay! Wait, what exactly does the SRL instruction do?
Title: Re: So what next?
Post by: Deep Toaster on January 10, 2012, 06:16:02 pm
It shifts the bits of a register to the right. To quote 28 Days (http://eeems.omnimaga.org/Files/Resources/Tutorials/ASMin28Days/ref/z80sr.html):
Quote from: Z80 Instruction Set
The contents of reg8 are shifted right one bit position. The contents of bit 0 are copied to the carry flag and a zero is put into bit 7.
So if E were 01101011 (in binary), SRL E would leave it as 00110101 with the carry flag set.
Title: Re: So what next?
Post by: thydowulays on January 10, 2012, 06:17:44 pm
Ok thanks! I get that. And I am making my game right now, I'm done with the menu screen, now I'm working on the game itself....
Title: Re: So what next?
Post by: Xeda112358 on January 10, 2012, 06:19:53 pm
SRL will shift a register right and load a 0 into bit 7. the original bit 0 will now be in the carry flag :)

Also, Thepenguin77: Great advice and that is too true :)

Also, for a tunnel game, shifting the screen up or down a pixel is rather simple if you use lddr. To shift down and not at all change the first line:
Code: [Select]
    ld de,plotSScreen+2FFh      ;DE points to the last byte of the graphscreen
     ld hl,plotSScreen+2FFh-12  ;HL now points to the last byte in the second to last row
     ld bc,300h-12                   ;this is the size of 63 rows
     lddr                                 ;copies BC bytes at HL to DE going backwards
     ret

EDIT: Aw, ninja'd D:
:D
Title: Re: So what next?
Post by: thydowulays on January 10, 2012, 06:40:02 pm
Cool! Anyways, it turns out I need help real quick with my game. (lol). I figure I might as well post the entire code so far to show you. The problem is that I can't seem to move my character up. I am using a variable called Ypos for the Y position of the character in the penCol. He doesn't move at all. Also, I am using Mimas for this, if that helps any.

Code: [Select]
....
Start:
BCALL ClrLCDFull
LD HL,$02
LD (curRow),HL
LD HL,Str1 ; This is my ASCII Adventures string
BCALL PutS
LD HL,$231E
LD (penCol),HL
LD HL,Str2 ; This is my Version 1.0 string
BCALL VPutS
LD HL,$2D1B
LD (penCol),HL
LD HL,Str3 ; This is my Press any key string
BCALL VPutS
BCALL GetKey ; I would have used GetCSC for this, but that would have required a loop and I want to optimize as much as possible
Game:
BCALL ClrLCDFull
LD A,Xpos ; This gets my variable Xpos.
LD (penRow),A ; This makes it in the penRow
LD A,Ypos
LD (penCol),A
LD HL,Plyr ; This is my Theta string ( I know I could use a character, I just wanted a string.....)
KeyLoop:
BCALL GetCSC
CP 0
JR Z, KeyLoop ; I know. Super n00b way of doing things, but it works.
CP skClear
RET Z
CP skUp
JR Z, MoveUp ; It's in this routine that I'm having trouble with things.
MoveUp:
LD A, Ypos
Sub 1
LD (Ypos),A
JR Game ; Don't know if this is the problem or not
Str1:
DB "ASCII Adventures",0
Str2:
DB "Version 0.1",0
Str3:
DB "Press any key",0
Plyr:
DB "(theta)",0
Xpos EQU 46 ; These could be the problems too
Ypos EQU 26

Thanks for all your help!

Title: Re: So what next?
Post by: Hot_Dog on January 10, 2012, 07:02:05 pm
Ah, I think I've got it:

Line 35 should be "LD A, (YPos)"  You forgot the parenthesis ;D

Also, in line 36, use DEC A.  It's smaller and faster than sub 1.  In addition, use OR A instead of CP 0 in line 26
Title: Re: So what next?
Post by: thydowulays on January 10, 2012, 07:05:04 pm
Okay thanks! I'll try that....
Title: Re: So what next?
Post by: thydowulays on January 10, 2012, 07:22:42 pm
Hmm, it didn't work. I think it's a problem with the variables Xpos and Ypos, because the coordinates (46,26) are in the middle of the screen, and it was over in the top left.
Title: Re: So what next?
Post by: Hot_Dog on January 10, 2012, 07:41:49 pm
Try replacing the last two lines:

Xpos:
 .db 46 ; These could be the problems too
Ypos:
 .db 26
 
EQU turned Xpos and Ypos into constants.  DB will help with making them variables.
Title: Re: So what next?
Post by: thydowulays on January 10, 2012, 07:56:30 pm
Okay let me try that. Oh and for some reason I crashed my calc completely earlier, so I have to rewrite this all over again, ugh.
Title: Re: So what next?
Post by: chickendude on January 11, 2012, 05:27:54 am
Also, check this part here:
Code: [Select]
Game:
BCALL ClrLCDFull
LD A,Xpos ; This gets my variable Xpos.
LD (penRow),A ; This makes it in the penRow
LD A,Ypos
LD (penCol),A
Two things, first: penRow is the row, aka the y position. penCol is the X position. Next, you forgot the parenthesis again. It works initially because you have them defined as equates, so it essentially converts Xpos into the number equated as Xpos. Try making the change Hot_dog proposed (changing the equates into .db statements) and adding in the parenthesis. :)
Title: Re: So what next?
Post by: thydowulays on January 11, 2012, 07:39:18 am
Thanks! Yes, I tried all these. And guess what, it works! By actually using a different method from Xpos and Ypos, I was able to get it (partially) working. The only problem is, it moves up, but it also moves to the right as well. I am not sure why.....
Title: Re: So what next?
Post by: NanoWar on January 11, 2012, 10:21:16 am
Just saying it in other words: In ASM there are no named variables, only registers (very limited set) and memory locations. But there are compiler "variables" like labels and defines. But those only exist before compile time in your code. By doing "Ypos = 26", you define the memory location 26 to a compiler variable named Ypos.

Hardware thinking in ASM!
Title: Re: So what next?
Post by: Hot_Dog on January 11, 2012, 11:18:58 am
Can you post your updated code?