well i was just going to do:


Code:

keypress:
 bcall(_getk)
 bcall(_op2toop1)
 bcall(_convop1)
 cp 34
 jp z,down
 jp nz,keypress
first things first sorry about the double post.i just did it so it would get noticed.

but here is my real problem when i try to assemble this code it runs into an error and i was wondering if anyone can help. the error is unused data with loading 8 into b.


Code:

.nolist
#include "ion.inc"
#include "keyval.inc"
.list
charx =sram+1
chary =sram+2
#ifdef ti83p
 .org progstart-2
 .db $BB,$6D
#else
 .org progstart
#endif
 jr nc,begin
 .db "ION Test",0

begin:
 bcall(_clrlcdfull)
 bcall(_indicatoroff)
 ld a,5
 ld (charx),a
 ld (chary),a
 ld l,a
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 jr keypress

keypress:
 bcall(_getkey)
 cp kright
 jr z,right
 jr nz,keypress

right:
 ld b,8
 ld a,(charx)
 ld l,(chary)
 ld ix,sprite
 call ionputsprite
 ld a,(charx)
 add a,8
 ld (charx),a
 ld l,(chary)
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 jp keypress

quit:
 bcall(_clrlcdfull)
 bcall(_getkey)
 ret

sprite:
 .db %11111111
 .db %10000001
 .db %10000001
 .db %10000001
 .db %10000001
 .db %10000001
 .db %10000001
 .db %11111111

.end
END
It's perfectly acceptable to double post if more than a day has passed. If you had just editted your post nobody would have noticed. Don't worry about it.

Lafferjm, TASM errors are there to help you fix the problem. Part of the error message will give you a specific line number where the error is. If your using a decent IDE (try Notepad++ or Crimson Editor if you're not), than it will have line numbers. Go to the appropriate line (sometimes it's a line or so off), and try to remedy it yourself. As it is, you've given me no line number so I don't have a clue where in the code this is, so I have a much worse chance than you of finding it.

I might be wrong, but I don't think you can do:
Code:
ld l,(chary)
I'm pretty sure you can only directly access ram using hl or a. I'd say that's your problem, except it has nothing to do with b.
so do:
[code]
ld a,(chary)
ld l,a
Yes. Also, why did you do this?
Code:
keypress:
 bcall(_getk)
 bcall(_op2toop1)
 bcall(_convop1)
 cp 34
 jp z,down
 jp nz,keypress
It looks like you're trying to move the keypress from Op2 into A, but it's already in the accumulator! You don't need to do any of the bcalls there, hence why it wasn't working.
well those helped except now i just have to get ion to recognize it as a program
Are you sure that you have the header right and everything? Post the first 20 or so lines of your program.

Code:

.nolist
#include "ion.inc"
#include "keyval.inc"
.list
charx =sram+1
chary =sram+2
#ifdef ti83p
 .org progstart-2
 .db $BB,$6D
#else
 .org progstart
#endif
 jr nc,begin
 .db "ION Test",0

begin:

Code:
.nolist
#include "ion.inc"
#include "keyval.inc"
.list
charx =sram+1
chary =sram+2
#ifdef ti83p
 .org progstart-2
 .db $BB,$6D
#else
 .org progstart
#endif
 ret
 jr nc,begin
 .db "ION Test",0

begin:
thanks. it is always that one line that can mess up anything
Yup, the ret is key there. Smile
well i now have a working sprite moving program. i will get to posting the code later on. now i just have to figure out how to stop it from going off screen.
That's easy - just check the x and y coordinates in the move routines.
alright. oh and here is the version without the stopping from going out of screen. is there anyway i can make it smaller.


Code:

.nolist
#include "ion.inc"
#include "keyval.inc"
.list
charx =sram
chary =sram+2
#ifdef ti83p
 .org progstart-2
 .db $BB,$6D
#else
 .org progstart
#endif
 ret
 jr nc,begin
 .db "ION Sprite Moving Test",0

begin:
 bcall(_clrlcdfull)
 bcall(_indicatoroff)
 ld a,5
 ld (charx),a
 ld (chary),a
 ld l,a
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 jr keypress

keypress:
 bcall(_getkey)
 cp gkright
 jr z,right
 cp gkdel
 jp z,exit
 cp gkleft
 jp z,left
 cp gkup
 jr z,up
 cp gkdown
 jr z,down
 jr nz,keypress

right:
 call erase
 call ionputsprite
 ld a,(chary)
 ld l,a
 ld a,(charx)
 inc a
 ld (charx),a
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 jp keypress

left:
 call erase
 call ionputsprite
 ld a,(chary)
 ld l,a
 ld a,(charx)
 dec a
 ld (charx),a
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 jp keypress

up:
 call erase
 call ionputsprite
 ld a,(chary)
 dec a
 ld (chary),a
 ld l,a
 ld a,(charx)
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 jp keypress

down:
 call erase
 call ionputsprite
 ld a,(chary)
 inc a
 ld (chary),a
 ld l,a
 ld a,(charx)
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 jp keypress

exit:
 bcall(_clrlcdfull)
 ret

sprite:
 .db %11111111
 .db %10000001
 .db %10000001
 .db %10000001
 .db %10000001
 .db %10000001
 .db %10000001
 .db %11111111

erase:
 ld a,(chary)
 ld l,a
 ld a,(charx)
 ld b,8
 ld ix,sprite
 ret

.end
END
1: Why do you have charx as sram and chary as sram+2. You're only storing 1 byte number to it, so you can make chary sram+1.

2: If you do that, you can use hl to more effectively index these coordinates and save a bit of space. For example this:

Code:
 right:
 call erase
 call ionputsprite
 ld a,(chary)
 ld l,a
 ld a,(charx)
 inc a
 ld (charx),a
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 jp keypress

Becomes this:

Code:
 right:
 call erase
 call ionputsprite
 ld hl,chary
 ld l,(hl)
 dec hl
 ld a,(hl)
 inc (hl)
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 jp keypress


3: You could make a display routine to save a few bytes. That way after you set up the coordinates after they press right left or whatever, just call display (which contains the code: ld b,8 / ld ix,sprite / call ionputsprite / call ionfastcopy / ret) instead of having those redundant lines.

4: Everytime you call erase, you call ionputsprite right after, so why not make that part of the erase routine and save a few bytes.

5: Change this:


Code:
keypress:
 bcall(_getkey)
 cp gkright
 jr z,right
 cp gkdel
 jp z,exit
 cp gkleft
 jp z,left
 cp gkup
 jr z,up
 cp gkdown
 jr z,down
 jr nz,keypress
 
 ...
exit:
 bcall(_clrlcdfull)
 ret
 


Into this:


Code:
keypress:
 bcall(_getkey)
 cp gkright
 jr z,right
 cp gkleft
 jp z,left
 cp gkup
 jr z,up
 cp gkdown
 jr z,down
 cp gkdel
 jr nz, keypress
exit:
 bcall(_clrlcdfull)
 ret


6: Get rid of that jr keypress at the end of the 'begin' routine. Just like in BASIC it's not necessary to jump to a lbl if it's the next line.

There are probably some more I missed, but this should get you thinking.
all right here is the new code. i think i did what you suggested. oh and that jr has to be there it is part of the ion header.


Code:

.nolist
#include "ion.inc"
#include "keyval.inc"
.list
charx =sram
chary =sram+1
#ifdef ti83p
 .org progstart-2
 .db $BB,$6D
#else
 .org progstart
#endif
 ret
 jr nc,begin
 .db "ION Sprite Moving Test",0

begin:
 bcall(_clrlcdfull)
 bcall(_indicatoroff)
 ld a,5
 ld (charx),a
 ld (chary),a
 ld l,a
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 jr keypress

keypress:
 bcall(_getkey)
 cp gkright
 jr z,right
 cp gkdel
 jp z,exit
 cp gkleft
 jp z,left
 cp gkup
 jr z,up
 cp gkdown
 jr z,down
 jr nz,keypress

right:
 ld a,(charx)
 cp 86
 jp z,keypress
 call erase
 ld a,(chary)
 ld l,a
 ld a,(charx)
 inc a
 ld (charx),a
 call display
 jp keypress

left:
 ld a,(charx)
 cp 1
 jp z,keypress
 call erase
 ld a,(chary)
 ld l,a
 ld a,(charx)
 dec a
 ld (charx),a
 call display
 jp keypress

up:
 ld a,(chary)
 cp 1
 jp z,keypress
 call erase
 ld a,(chary)
 dec a
 ld (chary),a
 ld l,a
 ld a,(charx)
 call display
 jp keypress

down:
 ld a,(chary)
 cp 54
 jp z,keypress
 call erase
 ld a,(chary)
 inc a
 ld (chary),a
 ld l,a
 ld a,(charx)
 call display
 jp keypress

exit:
 bcall(_clrlcdfull)
 ret

sprite:
 .db %11111111
 .db %10000001
 .db %10000001
 .db %10000001
 .db %10000001
 .db %10000001
 .db %10000001
 .db %11111111

erase:
 ld a,(chary)
 ld l,a
 ld a,(charx)
 ld b,8
 ld ix,sprite
 call ionputsprite
 ret

display:
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 ret
 

.end
END
No, "Jr KeyPress" is the jr I meant. It's under the begin routine. The first Jr Keypress does not need to be their. Also, you didn't change the keypress routine as I had suggested (mine will save memory). Lastly, you decided against using hl to index I guess. It would save quite a bit of memory if you would use it, but I guess it might be too advanced for you at this stage.

Good job. I'd like to see what you do next.
Chipmaster wrote:
2: If you do that, you can use hl to more effectively index these coordinates and save a bit of space. For example this:

Code:
 right:
 call erase
 call ionputsprite
 ld a,(chary)
 ld l,a
 ld a,(charx)
 inc a
 ld (charx),a
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 jp keypress

Becomes this:

Code:
 right:
 call erase
 call ionputsprite
 ld hl,chary
 ld l,(hl)
 dec hl
 ld a,(hl)
 inc (hl)
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 jp keypress
Do you see why that will malfunction badly? Loading the contents of hl into l will modify hl, making 'a' completely invalid, and also making that inc (hl) do some fun randomization of your RAM. After ld hl,chary do ld b,(hl), then do ld l,b right before ld b,8.
Lol, I missed that. Nice catch. Another solution would be to load into a first, and then load into l at the end. It will screw up hl, but at that point it won't matter.
Or how about this?

Code:
right:
 call erase
 call ionputsprite
 ld hl,charx
 ld a,(hl)
 inc (hl)
 inc hl
 ld l,(hl)
 ld b,8
 ld ix,sprite
 call ionputsprite
 call ionfastcopy
 jp keypress
That would probably be the best.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page Previous  1, 2, 3, 4, 5, 6  Next
» View previous topic :: View next topic  
Page 5 of 6
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement