Okay, first question, I compile this and ran it (on calc) , and it gives me a value greater than 10,000 when I am trying to get a random number using Ion, 1-100. Can't figure it out can anyone help?


Code:

ORG     userMem-2
DB     $BB,$6D
RET
JR     NC,Start
DB     "Rand Program"
Start:
Bcall _Homeup
Var .equ appBackUpScreen
Ld   A,0
Ld   (Var),A
Bcall _ClrLcdFull
ld  B,101
Call $4086
Ld (Var),A
Ld H,0
Ld L,0
Ld Hl,(Var)
Bcall _DispHL
Bcall _Getkey
Ret


[/code]
Why is your code not indented and why are you using call $4086 instead of call iRandom? Try doing LD H,0 \ LD L, A instead of LD (VAR),A \ LD H,0 \ LD L,0 \ LD HL, (VAR).
So many things wrong with that:

1) Use DCS instead of Ion!
2) There's no point in clearing out HL before loading to it from (var)
3) You use var as both an 8-bit and 16-bit variable. That's definitely not right.

Here's what you should do instead:


Code:
.nolist
#include "ti83plus.inc"
#include "dcs7.inc"

Var .equ appBackUpScreen

.list
   .org progstart
#IFDEF TI83P
   .db $BB,$6D
#ENDIF
INIT:
   xor d
   .db $C9
   jr Start
   .dw Description
   .db $07,$00
   .dw $0000 ;no icon
   .dw $0000
   .dw $0000         ;the routine to open files.  DCS will start you here instead of at $9D95
                  ;if a file is pending
Description:
   .db "Random Prgm",0
START:                             ;main routines
   bcall(_homeup)
   ld  b,101
   call iRandom
   ld l,a
   ld h,0
   bcall(_disphl)
   call Pause
   ret


You should compile that with the DCS SDK
I am using Mimas 0.3 to compile my code so I can do it all on Calc, because I don't have enough time to program it on the computer. So I wouldn't use the DCS SDK, unless I was really desperate.
zeldaking wrote:
I am using Mimas 0.3 to compile my code so I can do it all on Calc, because I don't have enough time to program it on the computer. So I wouldn't use the DCS SDK, unless I was really desperate.
Ah, that's fair. My code stands, though, because you can easily write DCS programs with Mimas. Its DCS include file lets you use symbolic routine names like iRandom without resorting to the hex equivalents, as far as I know.
I suggest using whatever shell (or lack thereof) that you want. No reason to force your users into losing an extra 49 thousand bytes for a program like this, especially on an 83+. If you can get away with using only Ion routines, then do it, because most other shells are Ion-compatible, giving your users the choice.

Ion

Code:
.nolist
#include "ti83plus.inc"
#include "ion.inc"
Var .equ appBackUpScreen
.list

   .db $BB,$6D
   .org $9D95
   ret
   jr nc, Start
Description:
   .db "Random Prgm",0
START:                             ;main routines
   bcall(_homeup)
   ld  b,101
   call iRandom
   ld l,a
   ld h,0
   bcall(_disphl)
   bcall(_getKey)
   ret
Way to copy my program and just change the header without mentioning my version. Razz My suggestion was of course motivated by the fact that it's unlikely he's publishing a program that simply calls iRandom, and will expand it to use more shell functions and be much more complex. Better that he has access to a huge range of functions to help his program be smaller and more powerful than artificially limit himself.
Sorry, I thought it was obvious that this version was based on yours. However, if you don't need routines outside of Ion, then use Ion. If you don't need routines outside of MirageOS, use MirageOS. If you need DCS routines, use DCS. Each subsequent shell offers compatibility with the previous, and if you code if for the earliest shell possible, you get maximum compatibility.
Okay, that makes sense, thanks. I do have another question though Smile.
I am trying to get inverted font, and I know for a fact I am doing it wrong. Can someone help give me the correct code? Thanks.

Code:

Start:
  bcall ClrLcdFull
  bcall Homeup
  Ld  (IY+fontflags),7   ;trying to reset the seventh bit so i get inverse font.
  Ld HL,Text
  bcall PutS
  Call Pause
  Ret
Text:
  DB "HELLO THIS FAILED",0

Yeah, don't slap me, I know it is pretty bad.

Code:
set textInverse, (IY + textFlags)
SirCmpwn wrote:

Code:
set textInverse, (IY + textFlags)

This. If you just do LD (IY+fontflags),7 you'll be accidentally setting and resetting all of the other flags in fontflags, which is why you use set, res, and bit when dealing with flags.
Exactly that. Don't forget to res textInverse, (iy+textFlags) afterwards, too. Smile
Does that reset text flags so it go back to normal?
Yes.
I am making a game in asm, called StarPilot. It will be an ion game. Anyways there is a part that I cannot figure out, I am trying to not let the sprite move off th escreen, the sprite you control. I have all of the sides done except one, meaning it stops the sprite on all sides except the left side, here is my code for moving left/disallowing movement off the screen to the left (x !=0). Also it somewhat works, I can push left and it stops but, when it hits xpos=0 it adds one to my ypos, so it goes down when i am pushing left and x hits 0. I hope that made sense.

Code:

Mainloop: ;this isn't my complete mainloop
bcall getscs
CP skLeft
CALL Z,Moveleft
JR mainloop
MoveLeft:
  ld A,(XPos)
  CP 0 ;testingto see if xpos = 0
  Ret Z ;Moveleft was called so using ret birngs me back to mainloop.
  inc A
  inc A
  ld (XPos),A
  CALL Show
  Ret

Can someone help me, see why my code doesn't work?
Does this make sense?
Do I need to add more code? Sad
Why does your move-left code _increment_ the x value instead of decrement it? I'm not sure exactly what the behavior is from what you said.
Oops copied that down wrong it should be dec. I meant that when I push left and it reaches 0 (xpos=0) it stays at xpos=0 but it adds one to the ypos, making it go down. Sad
zeldaking wrote:
Oops copied that down wrong it should be dec. I meant that when I push left and it reaches 0 (xpos=0) it stays at xpos=0 but it adds one to the ypos, making it go down. Sad
You have to give us more code. I can almost guarantee you're doing a bunch of call z,label's.
Yeah, I am doing a bunch of call,z label. how does that effect it?
That there are a lot more routines to check for the problem.
  
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 1 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