Author |
Message |
|
FloppusMaximus
Advanced Member
Joined: 22 Aug 2008 Posts: 472
|
Posted: 03 Nov 2008 01:05:35 pm Post subject: |
|
|
Well, if "sprite" is a label, then ".dw sprite" stores the address of that label in two consecutive program data bytes. It most certainly does work. It apparently doesn't do what you want it to, though.
In any case, let's step back a bit. What are you trying to do? There is probably a better way to do it. |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 03 Nov 2008 01:23:20 pm Post subject: |
|
|
im buiding a platformer... it draws sprites wich data is at location IX
example:
data of someting animated:
.dw 20 ;ypos (2 byte)
.db 5 ;xpos
.dw sprite ;adress of the sprite
.db %00000011 ;amound of frames (gs, no interupts)
.db more stuff...
when im drawing a sprite:
LD HL,sprite
DOES draw the correct sprite, but
LD H,(ix+4)
LD L,(ix+3)
does not
(or even LD HL,data+3)
Last edited by Guest on 22 Jul 2010 12:04:16 pm; edited 1 time in total |
|
Back to top |
|
|
FloppusMaximus
Advanced Member
Joined: 22 Aug 2008 Posts: 472
|
Posted: 03 Nov 2008 01:53:23 pm Post subject: |
|
|
Well, no, "ld hl,data + 3" is not what you want at all. "ld h,(ix+4) / ld l,(ix+3)", though, is correct. So something else must be going wrong. Are you sure that IX is pointing to the right place? (You aren't, say, calling VPutMap, or some sprite routine that uses IX, are you?) |
|
Back to top |
|
|
magicdanw pcGuru()
Calc Guru
Joined: 14 Feb 2007 Posts: 1110
|
Posted: 03 Nov 2008 02:02:18 pm Post subject: |
|
|
Question: where is IX pointing to? Is it pointing to a table of addresses, or something else? I think you need to show us more of your code, since what you've posted looks okay sofar (assuming IX points correctly).
Oh, here's a tip: the debugger is your friend. If tbewrong values are being loaded into hl, find out what they are. See if they look familiar. See what's at thatmemory location. This will help you get a better grasp on what it is your program is doing. |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 03 Nov 2008 02:19:58 pm Post subject: |
|
|
IX is pointing to the start of the data block, i made my sprite routine so it takes the values in IX+someting
it works for everyting (xpos, ypos, frame...) except the location of the sprite
...
LD IX,stuff
call drawsprite
...
...
stuff:
.dw 20 ;ypos (2 byte)
.db 5 ;xpos
.dw sprite ;adress of the sprite
.db %00000011 ;amound of frames (gs, no interupts)
.db more stuff...
Last edited by Guest on 22 Jul 2010 12:04:42 pm; edited 1 time in total |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 05 Nov 2008 04:12:18 pm Post subject: |
|
|
bump my project is on-hold untill it fixed this.. |
|
Back to top |
|
|
magicdanw pcGuru()
Calc Guru
Joined: 14 Feb 2007 Posts: 1110
|
Posted: 05 Nov 2008 04:22:24 pm Post subject: |
|
|
As I see it, IX+3 and IX+4 point to bytes pointing to the location of the sprite. Suppose the address is 1234h. When you load IX+4 into H and IX+3 into L, HL should store 1234h. Then, if you try to display the sprite starting at (HL), it should work fine. If it's not, I'm going to have to look at your drawsprite routine. |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 05 Nov 2008 04:32:57 pm Post subject: |
|
|
no wait, i solved it -.-
the problem was this:
...
LD HL,sprite
;LD L,(IX+location+1) ;location
;LD H,(IX+location)
ADD HL,DE
...
this works, but as soon as i uncommented those 2 instructions (that SHOULD point to the same data block, it stopped working
a little endian ...
sorry for begging for help
screenies: (yay) running @ 66 FPS
[attachment=2501:attachment]
edit: yes, that is grayscale
Last edited by Guest on 22 Jul 2010 12:05:06 pm; edited 1 time in total |
|
Back to top |
|
|
asdf
Advanced Newbie
Joined: 17 Aug 2008 Posts: 73
|
Posted: 06 Nov 2008 03:22:29 pm Post subject: |
|
|
Well, the code should work if you had it structured like this:
Code: ld IX,location
LD L,(IX+0)
LD H,(IX+1)
ADD HL,DE
location:
.dw sprite
sprite:
;sprite data
If you do IX+location+1, IX does NOT point to the location+1 label in your program, it points to the current value of IX + location+1, although you can only add an 8-bit number to IX, so you would either get a compile-time error or a meaningless number as the lower 8 bits of the value location+1 get added to IX.
Last edited by Guest on 06 Nov 2008 05:29:02 pm; edited 1 time in total |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 06 Nov 2008 03:31:10 pm Post subject: |
|
|
location is equal to 3
IX is equal to the adress where the data is stored |
|
Back to top |
|
|
asdf
Advanced Newbie
Joined: 17 Aug 2008 Posts: 73
|
Posted: 06 Nov 2008 05:30:55 pm Post subject: |
|
|
Err.. looking back it seems you mixed the values up when loading it to HL. L should = location and H should = location+1. |
|
Back to top |
|
|
tr1p1ea
Elite
Joined: 03 Aug 2003 Posts: 870
|
Posted: 07 Nov 2008 12:48:34 am Post subject: |
|
|
Is that a custom grayscale routine or is it RPG or something? If you measured the fps in wabbit and its an interrupt driven grayscale routine you're using then the fps wont be representative of your game. It will be showing you how fast the grayscale rutine is updating the screen.
Looks cool btw . |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 07 Nov 2008 06:39:23 am Post subject: |
|
|
tr1p1ea wrote: Is that a custom grayscale routine or is it RPG or something? If you measured the fps in wabbit and its an interrupt driven grayscale routine you're using then the fps wont be representative of your game. It will be showing you how fast the grayscale rutine is updating the screen.
Looks cool btw .
[post="128551"]<{POST_SNAPBACK}>[/post]
its not grayscale whit an interupt, it just has 2 sprites for the char and alternates them
takes only 30 clocks or someting.. and looks good |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 07 Nov 2008 01:49:47 pm Post subject: |
|
|
another quistion >.>
pressedright:
LD DE,(scrolly)
LD HL,(mapwidth)
OR a ;res carry
SBC HL,DE
jr NZ,skip
LD HL,(scrolly)
INC HL
LD (scrolly),HL
CALL ScrollR
skip:
<input inefficient routine here>
scrolly: .dw 8
mapwidth: .db (14-12)*8
for some reason this fails >.>
the routine does either:
ALWAYS execute scrollR (whit NZ as condition)
NEVER execute scrollR (whit Z as condition)
Last edited by Guest on 22 Jul 2010 12:05:30 pm; edited 1 time in total |
|
Back to top |
|
|
FloppusMaximus
Advanced Member
Joined: 22 Aug 2008 Posts: 472
|
Posted: 07 Nov 2008 02:34:15 pm Post subject: |
|
|
Hmm, well, I'm not sure what you're trying to do there, but if mapwidth is supposed to be a 16-bit variable, it should be a .dw... |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 07 Nov 2008 02:51:09 pm Post subject: |
|
|
a, you are correct >.>
always messing up those small things ... |
|
Back to top |
|
|
darkstone knight
Advanced Member
Joined: 07 Sep 2008 Posts: 438
|
Posted: 10 Nov 2008 10:02:04 am Post subject: |
|
|
yet, another quistion :D
drawR:
LD HL,(scrollY)
or a\ RR H\ RR L ;divide by 8
or a\ RR H\ RR L
or a\ RR H\ RR L
LD DE,12
ADD HL,DE ;add 12
LD DE,tilesprites
ADD HL,DE
EX DE,HL
EXX
LD DE,plotsscreen+13
EXX
LD B,8 ;bitcounter
drawRloop:
push BC
LD a,(DE) ;de is tilemap
LD L,A
LD H,0
ADD HL,HL ;maal 8
ADD HL,HL
ADD HL,HL
LD BC,tilesprites
ADD HL,BC
push HL
EXX
pop HL
CALL putsprite8 ;DE will update self
EXX
LD HL,20 ;tilemap is 20 wide..
ADD HL,DE
EX DE,HL
POP BC
djnz drawRloop
RET
this is the code to draw the RIGHT part of the screen, it is trigered when (scrollY) mod 8 equals zero
im using an 14-bit whide buffer
putsprite8 is just one small routine that does LDI, and advances DE to the next row
Last edited by Guest on 22 Jul 2010 12:03:57 pm; edited 1 time in total |
|
Back to top |
|
|
|