Need Help...


[Prev][Next][Index][Thread]

Need Help...



I need someone who has programmed with graphics to go through the following
code and privately e-mail me with any errors they may find.  The attachment
is some OShell-82 code which I am trying to work out the bugs.  The screen
(except for the top line) should be completely filled in with pixels.  I
believe my error is in my FIND_PIXEL routine below:

NOTE: (0,0) is the upper-left hand corner of the display (not the lower right)


FIND_PIXEL:                ; Used with RESTORE_PIXEL (sometimes faster)
                           ; (This is equivilent to FIND_PIXEL on ROM page 4)
  push bc                  ; Temporarily store bc on the stack
  srl b                    ; Divide b by 8 (there are 8 pixels across per
  srl b                    ; byte)
  srl b
  ld a,$80                 ; Goto line in display controller
  add a,c                  ; Add $80 + line number to get the true address
  ld ($8011),a             ; Store line for a later restore
  ld a,$20                 ; Goto byte in display controller
  add a,b                  ; B is already calculated, add $20 + byte desired
  ld ($800F),a             ; Store byte for a later restore
  pop bc                   ; Retrieve bc from the stack
(HERE IS WHERE MY PROOFS BELOW WILL BEGIN)
  ld a,b                   ; b -> a
  and %00000111            ; Remove the 5 upper bits to get the bit # desired
                           ;  (we still have to make a = 2^(bit # desired)
                           ;  which is done below)
  push bc                  ; Temporarily store bc on the stack
  add a,1                  ; a = a + 1 (avoids infinite loop with djnz below)
  ld b,a                   ; a -> b
  ld a,%00000001           ; %00000001 -> a
FD_PX_LOOP:
  rra                      ; Rotate a right through carry C -> |7 -> 0| -> C
  djnz FD_PX_LOOP          ; b = b - 1, if b<>0 goto FD_PX_LOOP
  pop bc                   ; Retrieve bc from the stack
  ret                      ; Return to caller

I believe the code is correct.  Here are two proofs:
PROOF 1 (where B = 0):
  ld a,b                   ; a = 0
  and %00000111            ; a = 0
  push bc                  ; Temporarily store bc on the stack
  add a,1                  ; a = 1
  ld b,a                   ; b = 1
  ld a,%00000001           ; a = %00000001
FD_PX_LOOP:
  rra                      ; 1st time through a = %10000000
  djnz FD_PX_LOOP          ; 1st time through b = 0 (END)
  pop bc                   ; Retrieve bc from the stack
  ret                      ; Return to caller


PROOF 2 (where B = 7):
  ld a,b                   ; a = 7
  and %00000111            ; a = 7
  push bc                  ; Temporarily store bc on the stack
  add a,1                  ; a = 8
  ld b,a                   ; b = 8
  ld a,%00000001           ; a = %00000001
FD_PX_LOOP:
  rra                      ; 1st time through a = %10000000
                           ; 2nd time through a = %01000000
                           ; 3nd time through a = %00100000
                           ; 4nd time through a = %00010000
                           ; 5nd time through a = %00001000
                           ; 6nd time through a = %00000100
                           ; 7nd time through a = %00000010
                           ; 8nd time through a = %00000001
  djnz FD_PX_LOOP          ; 1st time through b = 7
                           ; 2nd time through b = 6
                           ; 3nd time through b = 5
                           ; 4nd time through b = 4
                           ; 5nd time through b = 3
                           ; 6nd time through b = 2
                           ; 7nd time through b = 1
                           ; 8nd time through b = 0 (END)
  pop bc                   ; Retrieve bc from the stack
  ret                      ; Return to caller


It seems fine to me, but someone might know something I don't.  I'm just
learning Z80 ASM, so its a little difficult to understand some of the
command set.  Any help would be appreciated.

TIA,

GRPHTEST.82P


Thomas J. Hruska

|----------------------------------------------------|
|             Shining Light Productions              |
|      "Meeting the needs of fellow programmers"     |
|                                                    |
|   C/C++ programs                                   |
|   QBasic programs                                  |
|   JavaScript                                       |
|   TI-82 ASM                                        |
|   TI-Basic                                         |
|   HTML                                             |
|                                                    |
| Search for our web site at                         |
| www.geocities.com/SiliconValley/Heights/8504/      |
|                                                    |
| We use a dynamic web server for most of our        |
| documents!!!                                       |
| Soon to go to a full JavaScript 1.1 web site!      |
|----------------------------------------------------|