Author Topic: Trio and Niko assembly help  (Read 9239 times)

0 Members and 1 Guest are viewing this topic.

Ashbad

  • Guest
Trio and Niko assembly help
« on: December 14, 2010, 03:54:33 pm »
I just finished a 4 level 8x8 sprite drawing routine, but it does not seem to be working....  the drawing to buffers (appbackupscreen is backbuffer, plotSScreen is front buffer) works, but the coordinate system and address don't work (HL: address to data, b = x position*8, c = y position)

Help?


ALSO, I do know this is rather newbish, but I never really was good at sprite routines :P

Code: [Select]
Drawalignedsprite
push hl
ld a,c
add a,a
add a,c
add a,a
add a,a
ld l,c
        push  af
        ld      a,l
add a,b
        ld      l,a
        pop   af
ld h,0
ld de,appbackupscreen
add hl,de
push de
ld de,plotSScreen
add de,hl
sub a
ld b,8
ld c,16
pop hl
__Drawalignedspriteloop
ld a,(hl)
ex de,hl
ld (hl),a
inc de
add hl,12
ex de,hl
dec c
sub a
cp c
jp z,__Drawalignedspriteend
add 8
cp c
jp z,__Drawalignedspriteloopnext
djnz __Drawalignedspriteloop
__Drawalignedspriteloopnext
ld b,8
pop de
sub a
cp c
jp nz,__Drawalignedspriteloop
__Drawalignedspriteend
ret

EDIT: fixed some bad syntax stuff (this is my incomplete version, left my finished one at school with syntax fixed)  BUT the routine is still dysfunctional :P
« Last Edit: December 14, 2010, 05:10:59 pm by Ashbad »

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: aligned 4 level sprite routine (need help)
« Reply #1 on: December 14, 2010, 04:44:27 pm »
well.. i'm not sure what's wrong with your code but this is what i could come up with. though i wasn't sure what you  meant by b being x position * 8. is x position the number of bytes to the right? that's what i assumed, at least. in which case i assumed x position is a variable i could access. also, this routine xors the sprite.

i'm not 100% sure this routine works, since i haven't taken quigibo's grayscale routine and used it, but it's what i could come up with. it's found here. let me know if it works, if it fails. i haven't programmed in asm in awhile, but this is the routine i made for a little tunnel game i was trying to make. except i modified it to write to appbackupscreen too.
       

       
       


Ashbad

  • Guest
Re: aligned 4 level sprite routine (need help)
« Reply #2 on: December 14, 2010, 05:01:08 pm »
thanks for the help, but I was able to rewrite the routine (that now works) :)

Thanks, though ;)

Maybe I can butcher this thread into a Trio and niko: falling Help-me-plz-thread and I can keep changing the title to get new input on new questions O.o

ALSO: how optimal is my clrbuffers routine?

Code: [Select]
Clrscrn
ld bc,768
ld hl,plotSScreen
ld de,appbackupscreen
sub a
__Clrscrnloop
ld (hl),a
inc hl
ex de,hl
ld (hl),a
inc hl
ex de,hl
dec bc
cp b
jp z,__Clrscrnloop
cp c
jp z,__Clrscrnloop
__Clrscrnend
ret

EDIT: I just realized I can do ld (de),a :P there goes two lines of code:

Code: [Select]
Clrscrn
ld bc,768
ld hl,plotSScreen
ld de,appbackupscreen
sub a
__Clrscrnloop
ld (hl),a
inc hl
ld (de),a
inc de
dec bc
cp b
jp z,__Clrscrnloop
cp c
jp z,__Clrscrnloop
__Clrscrnend
ret
« Last Edit: December 14, 2010, 05:04:34 pm by Ashbad »

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: aligned 4 level sprite routine (need help)
« Reply #3 on: December 14, 2010, 05:08:33 pm »
Yay for special-purpose instructions :)
Code: [Select]
Clrscrn
ld bc,768
ld hl,plotSScreen
ld de,appbackupscreen
sub a
__Clrscrnloop
ld (hl),a
ldi
jp pe,__Clrscrnloop
ret
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Ashbad

  • Guest
Re: aligned 4 level sprite routine (need help)
« Reply #4 on: December 14, 2010, 05:10:11 pm »
O.o  what does the pe flag do?  also, I've seen the po flag used before (ahem quigibo's grayscale routine) can you explain to me the fthe different flags (sorry for wasting your time :()

And, cool usage of the ldi instruction, I usually never use it much O.o

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: aligned 4 level sprite routine (need help)
« Reply #5 on: December 14, 2010, 05:12:08 pm »
O.o  what does the pe flag do?  also, I've seen the po flag used before (ahem quigibo's grayscale routine) can you explain to me the fthe different flags (sorry for wasting your time :()

And, cool usage of the ldi instruction, I usually never use it much O.o
In the case of the ldi/ldd/cpi/cpd instructions, the parity/overflow flag is set to 1 (PE) if BC is non-zero, or 0 (PO) if BC is zero. In this case, we want to loop if BC is not zero.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Trio and Niko assembly help
« Reply #6 on: December 14, 2010, 05:12:32 pm »
In the context of ldi, the p/o flag is set (pe) if bc is not zero, and reset (po) if it is. (ldi decrements bc)
Edit: ninja'd
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Ashbad

  • Guest
Re: Trio and Niko assembly help
« Reply #7 on: December 14, 2010, 05:13:31 pm »
ooh, cool!  thanks for the helpful insight! :D

that really would save a ton of space if I use that more often O.o

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Trio and Niko assembly help
« Reply #8 on: December 14, 2010, 05:14:57 pm »
One thing to keep in mind is that with JR, only the NZ/Z/NC/C conditions are available. For the PO/PE/P/M conditions, JP must be used.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Ashbad

  • Guest
Re: Trio and Niko assembly help
« Reply #9 on: December 16, 2010, 01:56:43 pm »
quick question, for each of may pages, if I want to include some of my routines in let's say, TaNrout.inc, can I put an include on every page, so I won't have to flip pages and lose speed, or copy and paste them and create a mess of code? like in brass:

Code: [Select]
.page 0
#include TaNrout.inc
.page 1
#include TaNrout.inc
.page 2
#include TaNrout.inc

Like that to put the code in the includes into the current location?

Ashbad

  • Guest
Re: Trio and Niko assembly help
« Reply #10 on: December 16, 2010, 07:35:18 pm »
*bump* ^^^

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: Trio and Niko assembly help
« Reply #11 on: December 16, 2010, 09:09:14 pm »
You can. Unless you absolutely need that speed or have the space, though, you might just want to put it on one page.
Also, I'm not sure if you know this or not, so here's a quick tutorial on how to create and format apps: http://benryves.com/bin/brass/tutorials/tiapps.htm
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Ashbad

  • Guest
Re: Trio and Niko assembly help
« Reply #12 on: December 18, 2010, 06:10:17 pm »
Does anybody know of a good gray scale rendering routine, like Dispgraphrr in Axe (and besides the source for that, it doesn't work on it's own)

it would really help me a ton.
« Last Edit: December 18, 2010, 06:47:34 pm by Ashbad »

Ashbad

  • Guest
Re: Trio and Niko assembly help
« Reply #13 on: December 20, 2010, 02:03:41 pm »
bump

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Trio and Niko assembly help
« Reply #14 on: December 20, 2010, 02:09:43 pm »
That was a very well-deserved bump. Have you checked Doors CS SDK?