Alright, i will do that thanks for all the tips. Also i have a question about variables. I know of the size difference and the whole getting wiped out after the program or not; but is there any speed difference between using saferam variables or a label as a variable?
lafferjm wrote:
Alright, i will do that thanks for all the tips. Also i have a question about variables. I know of the size difference and the whole getting wiped out after the program or not; but is there any speed difference between using saferam variables or a label as a variable?
None at all. It's all just bytes in RAM.
Well I think then for most things i will stick with saferam.
lafferjm wrote:
Well I think then for most things i will stick with saferam.
Generally you want to use saferam for things that you only need to keep while the program is running, and "labels", as you call them, for things you want to remember between program runs. Examples might be high scores, the player's current level and gold in an RPG, or a saved game if your game has such a thing.
I am really happy, i finally understand the following part of a sprite routine:


Code:

LD     H, 0
    LD     D, H
    LD     E, L
    ADD    HL, HL
    ADD    HL, DE
    ADD    HL, HL
    ADD    HL, HL


I had to do the math in my head but in the end l is multiplied by 12. I also understand why it has to be multiplied. One thing i don't understand though is why the x position needs to be divided by 8.
Well done, that is indeed a multiply by 12, because 12 bytes per row. X needs to be divided by 8 to get the byte in the row that the pixel is in. Since there are 8 pixels per byte, px 0-7 are in byte 0, 8-15 are in byte 1, etc. Thus dividing by 8 gives you the byte, and incidentally the remainder is the offset within the byte.
This is a code snippet copied straight from 28 days:
Code:
  LD     A, E
    OR     A
    JP     M, ClipTo


What exactly is the m flag or is it just a typo?

edit: also why exactly wont this code put my sprite where i want it to, a is x e is y but it draws it in the middle of the screen. Is it because of the window settings?

Code:
.nolist
#include "ti83plus.inc"
#define progstart $9d95
.list
.org progstart - 2
  .db $bb,$6d
  b_call(_grbufclr)
  ld a,0
  ld e,0
  ld b,8
  ld ix,sprite
  call putspr
  b_call(_grbufcpy)
  ret
 
putspr:
  ld h,0
  ld d,h
  ld e,l
  add hl,hl
  add hl,de
  add hl,hl
 
  ld e,a
  srl e
  srl e
  srl e
  add hl,de
 
  ld de,plotsscreen
  add hl,de
 
  and 7
  jr z,_aligned
 
  ld c,a
  ld de,12
 
_rowloop:
  push bc
  ld b,c
  ld c,(ix)
  xor a
 
_shiftloop:
  srl c
  rra
  djnz _shiftloop
 
  inc hl
  xor (hl)
  ld (hl),a
 
  dec hl
  ld a,c
  xor (hl)
  ld (hl),a
 
  add hl,de
  inc ix
  pop bc
  djnz _rowloop
  ret
 
_aligned:
  ld de,12

_putloop:
  ld a,(ix)
  xor (hl)
  ld (hl),a
  inc ix
  add hl,de
  djnz _putloop
  ret
 
sprite:
  .db $ff
  .db $ff
  .db $ff
  .db $ff
  .db $ff
  .db $ff
  .db $ff
  .db $ff 
The sprite routines in 28 days have incorrect inputs listed. Put the y coordinate in L, not E. You can determine this by looking at the code, and seeing that E is overwritten before it's used, meaning its value must be irrelevant.
The M condition stands for Minus, or negative. That just means the the leftmost bit of the value is set. The P condition stands for Plus, which means the leftmost bit is reset. The flag that these two conditions check is called the Sign flag.
I am having some problems writing a program that loops through an array using djnz but for some reason the only output i get is 5. Can someone please point out what i might be doing wrong?


Code:

.nolist
#include "ti83plus.inc"
#define progstart $9d95
.list
.org progstart - 2
  .db $bb, $6d
  b_call(_clrlcdfull)
  b_call(_homeup)
  ld b,0
  ld c, 5
loop:
  push bc
  ld hl,array
  ld d,0
  ld e,c
  add hl,de
  ld b,0
  ld c,(hl)
  ld h,0
  ld l,c
  b_call(_disphl)
  b_call(_newline)
  pop bc
  djnz loop
  ret
array:
  .db 0,1,2,3,4,5,6,7,8,9,10,11,12
You're looping through that 256 times - is that what you're meaning to do? And of course you're always going to get 5 - you aren't changing c.

Edit: Also, you can change
Code:
  ld b,0
  ld c,(hl)
  ld h,0
  ld l,c
to
Code:
  ld l,(hl)
  ld h,0
I wonder how i missed that , now it works and looks like so(not much changed actually): Laughing


Code:

.nolist
#include "ti83plus.inc"
#define progstart $9d95
.list
.org progstart - 2
  .db $bb, $6d
  b_call(_clrlcdfull)
  b_call(_homeup)
  ld b,5
loop:
  push bc
  ld hl,array
  ld d,0
  ld e,b
  add hl,de
  ld l,(hl)
  ld h,0
  b_call(_disphl)
  b_call(_newline)
  pop bc
  djnz loop
  ret
array:
  .db 0,1,2,3,4,5,6,7,8,9,10,11,12
  
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
Page 2 of 2
» 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