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
Groene07


Member


Joined: 08 Jun 2007
Posts: 150

Posted: 13 Jun 2007 10:17:28 am    Post subject:

Wait what does that routine do? Cool Ima lost
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 13 Jun 2007 10:20:02 am    Post subject:

As it says, it compares hl to de. Similarly to how cp hl, de would work if that were a real instruction.
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 13 Jun 2007 12:38:52 pm    Post subject:

Maybe this is a stupid question, but wouldn't add hl,de modify the flags also?
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 13 Jun 2007 12:44:58 pm    Post subject:

It doesn't affect the Z flag - I think CoBB's tutorial explained why (or at least, how this is useful in most cases - I think the only explanation WHY is "it just doesn't").

It does affect the C flag, but it turns out that this doesn't matter. If the C flag is set when we [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]add hl, de
, this means that we passed the $FFFF-$0000 border when adding de - but this means we had to have passed it going the other way, too, when subtracting, so it should already have been set. By a similar argument, if the C flag is reset when we [font="courier new;font-size:9pt;line-height:100%;color:darkblue"]add hl, de, this means that it was reset before as well.

It clears the N flag, if you care for some reason.

Last edited by Guest on 13 Jun 2007 12:48:46 pm; edited 1 time in total
Back to top
Fallen Ghost


Elite


Joined: 15 Jun 2006
Posts: 955

Posted: 13 Jun 2007 05:23:49 pm    Post subject:

During SBC, all flags except H are changed accordingly. During ADD, only the carry/N is affected

Also, I just found out why I said the other is faster


Code:
or a          ;4T, 1B
sbc hl,de  ;15T, 2B
add hl,de  ;11T, 1B
                ;Total= 30T, 4B


(a modification from the second)

Code:
ld a,h    ;4T, 1B
cp d      ;4T, 1B
jr nz,$+4;12/7T, 2B;the $+4 works in ZDS and maybe TASM, just saying the end of routine
ld a,l      ;4T, 1B
cp e      ;4T, 1B
            ;Total 1: 20T, 5B
            ;Total 2: 23T, 5B


And the second works on any side with any 16 bit register and even mixes of 8 bit ones.


Last edited by Guest on 13 Jun 2007 05:24:29 pm; edited 1 time in total
Back to top
calc84maniac


Elite


Joined: 22 Jan 2007
Posts: 770

Posted: 13 Jun 2007 05:25:45 pm    Post subject:

Mine checks for less than, greater than, overflow, etc. though... Wink
Back to top
Fallen Ghost


Elite


Joined: 15 Jun 2006
Posts: 955

Posted: 13 Jun 2007 05:30:58 pm    Post subject:

Heu, it does compare and have the exact same flags as the cp instruction because it uses the cp instruction. So it checks for all of them too.

And that modification allows you to not need to call/ret from it
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 01 Jul 2008 07:08:08 pm    Post subject:

Better Center Text

Because people generally don't want to count string length... I actually wrote this so a program could be compiled back and forth between MOS and Ion.


Code:
;======================================
; Center Text
;======================================
;
;Inputs:
;   HL points to string
;   acc is row to draw text on
;
;Note: Only include if compiled under a shell without centertext, such as Ion or Nostub (not a shell, but oh well)
;

centertext
 ld (penRow),a  ;row won't change
 
 push hl     ;find string length
 ld c,0     ;c is counter, start at 0
ctloop
 ld a,(hl)
 inc hl
 
 or a    ;test to see if end of string
 jr z,ctend
 
 push bc
 push hl
 ld l,a
 ld h,0
 add hl,hl     ;hl*8 for SFont_Len
 add hl,hl
 add hl,hl
 bcall(_SFont_Len)
 ld a,b
 pop hl
 pop bc
 add a,c
 ld c,a
 jr ctloop
 
ctend
 ld a,96          ;width of screen
 sub c             ;subtract width of string
 rra              ;divide by 2 to be centered
 ld (pencol),a

 pop hl
 
 bcall(_VPutS)

 ret


I know it's unoptimized, but that's for all of you people to do Smile
Back to top
TylerMcL


Member


Joined: 28 May 2008
Posts: 148

Posted: 07 Sep 2008 10:58:21 pm    Post subject:

Time to revive this forum... :D

To create a line

This next bit is just because I had no idea it existed, and i owe it all to the UTI Staff Member Darkerline. I was curious, and did a little bit of research :P


Code:
ld b, (hl) \ inc hl; x1 coordinate
ld c, (hl) \ inc hl; y1 coordinate
ld d, (hl) \ inc hl; x2 coordinate
ld e, (hl) \ inc hl; y2 coordinate
bcall(_DarkLine)


Disable the On button

This bit below does such:


Code:
in   a,($03); disables the "ON" button from inturrupting
   and  %11111110
   out   ($03),a


This next bit re-enables it:


Code:
in   a,($03); Re-enables the "ON" button
   or   %00000001
   out  ($03),a


Last edited by Guest on 07 Sep 2008 11:02:31 pm; edited 1 time in total
Back to top
WikiGuru
ADOS (Attention deficit... Oh! Shiny!)


Elite


Joined: 15 Sep 2005
Posts: 923

Posted: 07 Jan 2009 01:59:57 pm    Post subject:

Would di/ei disable the on interrupt?
Back to top
FloppusMaximus


Advanced Member


Joined: 22 Aug 2008
Posts: 472

Posted: 07 Jan 2009 02:34:30 pm    Post subject:

DI disables all interrupts; it doesn't affect the On key in particular.

The code above will indeed stop the On key from causing interrupts (although it should be noted that the normal TIOS ISR will re-enable it, so I'm not sure in what context it would be useful.)
Back to top
TKD_01


Advanced Newbie


Joined: 20 Feb 2009
Posts: 51

Posted: 10 Apr 2009 09:56:51 am    Post subject:

I know that I'm probably thinking too hard about this, but does anybody have a routine that tells you whether a pixel is turned on or off?
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 10 Apr 2009 10:03:58 am    Post subject:

use getpixel:


Code:
;H=Y
;A=X

GetPixel:
   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

   AND   7

   LD    A, $80
   RET   Z
   LD    B, A
Loop:
   RRCA
   DJNZ   Loop
   RET

test a pixel:
OR (HL)

force a pixel on:
or (HL)
LD (HL),A

force a pixel off:
cpl
and (HL)
LD (hl),A

fip pixel:
xor (HL)
Ld (HL),A
Back to top
TKD_01


Advanced Newbie


Joined: 20 Feb 2009
Posts: 51

Posted: 10 Apr 2009 10:14:02 am    Post subject:

oh, ok. I was thinking to use the 'a' register after running getpixel...but that only returns the bitmask, right? And what exactly does the 'hl' register hold after getpixel (So that I may understand the concept better)?
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 10 Apr 2009 10:18:49 am    Post subject:

TKD_01 wrote:
oh, ok. I was thinking to use the 'a' register after running getpixel...but that only returns the bitmask, right? And what exactly does the 'hl' register hold after getpixel (So that I may understand the concept better)?

The HL register points to the byte in PlotSScreen (the graph buffer) that contains the data for the pixel you want to modify/check.
Back to top
TKD_01


Advanced Newbie


Joined: 20 Feb 2009
Posts: 51

Posted: 10 Apr 2009 11:13:20 am    Post subject:

simplethinker wrote:
TKD_01 wrote:
oh, ok. I was thinking to use the 'a' register after running getpixel...but that only returns the bitmask, right? And what exactly does the 'hl' register hold after getpixel (So that I may understand the concept better)?

The HL register points to the byte in PlotSScreen (the graph buffer) that contains the data for the pixel you want to modify/check.


You say it points to the byte in the plotsscreen. To get an individual pixel, would you have to use an 'and' bitmask on the byte? If that makes sense?
Back to top
simplethinker
snjwffl


Active Member


Joined: 25 Jul 2006
Posts: 700

Posted: 10 Apr 2009 11:37:21 am    Post subject:

TKD_01 wrote:
You say it points to the byte in the plotsscreen. To get an individual pixel, would you have to use an 'and' bitmask on the byte? If that makes sense?

Exactly. If you want to check the status of the pixel, you would use "AND (HL)" and the A register will be zero if the pixel is off, and nonzero if the pixel is on.
Back to top
TKD_01


Advanced Newbie


Joined: 20 Feb 2009
Posts: 51

Posted: 10 Apr 2009 11:48:17 am    Post subject:

Great! So would the following code be correct to check the status of a pixel?


Code:
   ld a,(hl)
   add a,8
   ld e,a
   dec hl
   ld a,(hl)
   add a,4
   call ionGetPixel;
   and (hl)   ;
   or a   ;
   ret nz   ;
Back to top
darkstone knight


Advanced Member


Joined: 07 Sep 2008
Posts: 438

Posted: 10 Apr 2009 11:52:55 am    Post subject:

example:

X=12
Y=2

correct byte on plotsscreen is
12Y+(X/Cool = 25
X mod 8 = 4, so bit 8-4 = 4 is SET:
A=00010000

to test a bits status, HL holds the plotsscreen adres:
say, (HL) is %01101000
AND whit A, gives %0000 0000, so pixel (12,3) is reset
Back to top
TKD_01


Advanced Newbie


Joined: 20 Feb 2009
Posts: 51

Posted: 10 Apr 2009 12:03:54 pm    Post subject:

ok...lightbulb still isn't turning on for me...Could you give an example of some source code to test say a pixel at (10,5)
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
    » Goto page Previous  1, 2, 3, 4, 5  Next
» View previous topic :: View next topic  
Page 4 of 5 » All times are UTC - 5 Hours

 

Advertisement