This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's z80 & ez80 Assembly subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. Z80 & 68k Assembly => z80 & ez80 Assembly
Author Message
crabbb622


Newbie


Joined: 29 Mar 2009
Posts: 3

Posted: 29 Mar 2009 11:44:30 pm    Post subject:

My code allegedly generates 99 numbers and either displays an arrow in a random column 1-4 or waits 1-4 counts.

Barely anything happens. I'm at a complete loss because i didn't bother debugging until i had finished.

Ready...set...GO!!


Code:
.nolist
#include "ti83plus.inc"
#define   ProgStart   $9D95
.list
.org   ProgStart - 2
   .db   t2ByteTok, tAsmCmp
   ;DE=COUNTER
   ;$8200=POINTER
   ;$8000-$8099=X POSITIONS
   ;$8100-$8199=Y POSITIONS
   b_call(_ClrScrnFull)
   LD HL, $8000
RANDOM:
   LD    B, A
   LD    A, R
   ADD   A, B
   AND %11;3
   LD R, A
   INC A;4 is now possible, 0 is not
   LD (HL), A
   INC HL
   LD A, L
   AND A;if L is not 0
   JR NZ, RANDOM
   LD A, H
   CP $81;if H is not $81
   JR NZ, RANDOM
;following code is for debugging
;DISP:
;   LD DE, $8000
;   b_call(_HomeUp)
;   LD H, 0
;   LD A, (DE)
;   LD L, A
;   PUSH DE
;   b_call(_DispHL)
;   b_call(_getkey)
;   b_call(_ClrScrnFull)
;   POP DE
;   INC DE
;   LD A, E
;   AND A;if E is not 0
;   JR NZ, DISP
;   LD A, D
;   CP $81;if D is not $81
;   JR NZ, DISP
;   ret
   LD BC, $8100
   LD DE, $8000
MAIN:
   LD BC, ($8200)
   LD A, E
   AND %01;check to see if odd or even
   JR Z, ARROW
   LD A, (DE)
   DEC A
   JR C, INC_DE;if wait is over, then advance DE
   LD (DE), A
INC_DE:
   LD A, (DE)
   INC A
   LD (DE), A
   JR MAIN
ARROW:
   LD A, 63
   PUSH DE
   INC D;adds $100 to DE
   LD (DE), A
   POP DE
GLOBALMOVE:
   LD A, (BC)
   LD L, A
   PUSH BC
   DEC B;B used to be $81, now $80, so it's subracting $100 from BC
   LD A, (BC);get the column
   CP 4
   JR Z, SETRIGHT
   CP 3
   JR Z, SETDOWN
   CP 2
   JR Z, SETUP
   CP 1
   JR Z, SETLEFT
SETRIGHT:
   LD IX, RIGHT
   JR SETBUFFER
SETDOWN:
   LD IX, DOWN
   JR SETBUFFER
SETUP:
   LD IX, UP
   JR SETBUFFER
SETLEFT:
   LD IX, LEFT
   JR SETBUFFER
SETBUFFER:
   ADD A, A
   LD B, 8
   CALL PutSpriteXOR
   POP BC
   LD A, (BC);saving y position of arrow
   DEC A
   LD (BC), A
   AND A;can delete this line, want to make sure LD will set off Z
   CALL Z, INC8200
   INC BC
   INC BC
   LD A, C;if C is greater than E then do not loop
   CP E;checks to see if E is greater than to C
   JR C, ENDLOOP
   JR Z, ENDLOOP
   JR GLOBALMOVE
ENDLOOP:
   INC DE
   CALL SafeCopy
   JR MAIN
   
INC8200:
   LD A, ($8200)
   INC A
   LD ($8200), A
   RET
PutSpriteXOR:
; A = x coordinate
; L = y coordinate
; B = number of rows
; IX = address of sprite
   LD    H, 0
   LD    D, H
   LD    E, L
   ADD   HL, HL
   ADD   HL, DE
   ADD   HL, HL
   ADD   HL, HL

   LD    E, A
   SRL   E
   SRL   E
   SRL   E
   ADD   HL, DE

   LD    DE, PlotSScreen
   ADD   HL, DE
   LD    DE, 12
_PutLoop
   LD    A, (IX)
   XOR   (HL)
   LD    (HL), A
   INC   IX
   ADD   HL, DE
   DJNZ   _PutLoop
   RET
SafeCopy:   
   di
   ld c,$10
setrow:
   in a,(c)
   rla;test 7th bit
   jr c,setrow
   ld a,$80
   out ($10),a
   ld hl,PLOTSSCREEN
   ld de,12
   ld a,$20
col:
   push af;the push and pop are wasted clocks
colwait:;but this only occurs 12 times
   in a,(c)
   rla
   jr c,colwait
   pop af
   out ($10),a
   push af
   ld b,64
row:
   in a,(c)
   rla
   jr c,row
   ld a,(hl)
   out ($11),a
   add hl,de
   djnz row
   pop af
   dec h
   dec h
   dec h
   inc hl
   inc a
   cp $2c
   jr nz,col
   ret
UP:
   .DB %00011000
   .DB %00100100
   .DB %01000010
   .DB %11100111
   .DB %00100100
   .DB %00100100
   .DB %00100100
   .DB %00111100
RIGHT:
   .DB %00001000
   .DB %00001100
   .DB %11111010
   .DB %10000001
   .DB %11000001
   .DB %11111010
   .DB %00001100
   .DB %00001000
DOWN:
   .DB %00111100
   .DB %00100100
   .DB %00100100
   .DB %00100100
   .DB %11100111
   .DB %01000010
   .DB %00100100
   .DB %00011000
LEFT:
   .DB %00010000
   .DB %00110000
   .DB %01011111
   .DB %10000001
   .DB %10000001
   .DB %01011111
   .DB %00110000
.end
.end
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 30 Mar 2009 05:10:56 pm    Post subject:

I suppose you meant 256 random numbers?


Code:
MAIN:
   LD BC, ($8200)
I have no idea what you were trying to do with that... you are essentially destroying BC there.

Also, you aren't preserving the registers you need in the main loop when you call SafeCopy.

Edit:
Same thing with the sprite routine... DE is getting completely destroyed.


Last edited by Guest on 30 Mar 2009 05:12:33 pm; edited 1 time in total
Back to top
crabbb622


Newbie


Joined: 29 Mar 2009
Posts: 3

Posted: 31 Mar 2009 12:24:55 am    Post subject:

alright thanks, that actually helps. I decided to rewrite my code, after reading the tips thingy on here: planning it out before hand in human language Smile
Back to top
tr1p1ea


Elite


Joined: 03 Aug 2003
Posts: 870

Posted: 31 Mar 2009 12:32:47 am    Post subject:

Human language is sometimes good Smile.

DDR?
Back to top
crabbb622


Newbie


Joined: 29 Mar 2009
Posts: 3

Posted: 31 Mar 2009 05:02:49 pm    Post subject:

Yea, how'd you know? :D

It turns out the program requires 10 major steps (depending on interpretation) and i've done half of them, debugging every step of the way. It really helps, and the program is going well so far. 1/2 to go...

Maybe I'll implement a linkport :)

Does anyone know if that's been done yet (with DDR)?

Oh, and @calc84maniac: [s]BC was supposed to refresh[/s] i have no idea what i intended to do with that instruction. [s]Initially, BC was supposed to [/s] yea i have no idea.

And I just realized that $99 does not equal 99. LOL. silly me
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement