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
Tyraniek


Member


Joined: 07 Jun 2003
Posts: 133

Posted: 11 Jun 2003 03:35:29 am    Post subject:

How does it work ? I've read that to inverse all the LCD's pixels, I can use this routine (which works perfectly, and very quickly !) :


Code:
   ld hl,plotsscreen
   ld bc,768

inverse:
   ld   a, (hl)
   cpl     ; complement accumulator
   ld   (hl), a
   inc   hl
   dec   bc
   ld   a, b
   or   c
   jr   nz, inverse

   B_CALL(_PDspGrph)
   ret


What's the role of "CPL" ? And by the way, what is "_PDspGrph" exactly ? How does this routine works ?
In fact, the routine just does

Code:
   ld   a, (hl)
   cpl     ; complement accumulator
   ld   (hl), a
   inc   hl

768 times, because there is 768 bytes (96 pixels large, 64 pixels hight, 1 bit for 1 pixel, so 1 byte for 8 pixels), but what does this mysterious complement accumulator do ?
thx
Back to top
62 52 53 53
Formerly known as 62 52 53 53


Active Member


Joined: 30 May 2003
Posts: 607

Posted: 11 Jun 2003 02:24:54 pm    Post subject:

CPL inverts the accumulator
Back to top
NETWizz
Byte by bit


Bandwidth Hog


Joined: 20 May 2003
Posts: 2369

Posted: 11 Jun 2003 02:50:18 pm    Post subject:

As he said, CPL inverts the accumulator.

%11010000
invert
%00101111

As you know, there are 768 bytes per picture, and the plotSScreen contains the picture.

What the routine does is read a byte of the plotscreen and place it in the accumulator. Once in the accumulator, it uses CPL to inverse all the bits; finally, it writes the byte back to the plotSScreen at the same location.

Please note that hl points to a ram address. ld a,(hl) reads the ram address pointed to by hl.

Now, dec BC decrements the byte counter by one to keep track of how many bytes are left to invert.
inc HL points hl to the next byte of the plotSScreen to perform the same task.

ld a,b
or c ;checks if bc=0

If BC is 0, the Z flag will be set.

If the Z flag is not set, BC is not 0; therfore, we have more bytes to invert, and the NZ flag will be set because the Z flag is not set.

Jr nz,inverse continues the inverse function if the nz flag is set (if we have more pixels to invert)

I have no idea what bcall(pdspgrph) does, but I would assume it copies the plotSScreen to the Screen, so the user can see an inverted picture.

If you are a speed freak, and need the pixels changed faster, you could modify ionfast copy to invert all the pixels.
Back to top
Tyraniek


Member


Joined: 07 Jun 2003
Posts: 133

Posted: 12 Jun 2003 06:31:00 am    Post subject:

OK, it's an easy routine in fact !
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