;Zpic v1.2
;11:38 AM 3/12/00
;TI-83+ ASM
;Recalls a pic based on X.
;Recalls pics 1-255 (256 should never be saved as a pic!)
;© (Copyright) 2000 Kevtiva Interactive
;http://calc.kevtiva.com/
;sorry I forgot to include this source in the program...


.nolist

#define bcall(xxxx)	rst 28h \ .dw xxxx
#define bjump(xxxx)	call 50h \ .dw xxxx

_rclX	     .EQU  4AE0h
op1          .equ  8478h
_convoOp1    .equ  4AEFh
tvarpict     .equ  60h
picobj       .equ  07h
_flashtoram  .equ  5017h
_ChkFindSym  .equ  42F1h
_ConvOP1     .EQU  4AEFh
_GrBufCpy    .EQU  486Ah

.LIST
.org 9D95h         ;this is where TI-83+ ASM programs are loaded
                   ;
  bcall(_rclX)     ;recal the value of X
  bcall(_ConvOP1)  ;convert it to a HEX number, and place in DE.
  dec  de          ;make it have the correct pic #
  ex  de , hl      ;pic # => HL
  ld (op1+2),hl    ;Put pic # in OP1
  ld a,tvarpict    ;part of the pic name
  ld (op1+1),a     ;pic object code.
  ld a,picobj      ;
  ld (op1),a       ;Now check to see if it exists.
  bcall(_ChkFindSym)  ;DE = Offset in Archive
  ret c              ;A now contains meaningless stuff.
  ld a,b             ;B contains Rom page # so store that to A
  cp 0               ;See if A=0, if yes, then we jump to rclpic
  jr z,rclpic        ;otherwise we use the FLASHTORAM rom call.
  ld a,b	     ;B->A so A=ROM PAGE
  ld hl,000Eh        ;Data is a little off...
  add hl,de          ;Now HL contains the Offset in the Archive
  ld de,9340h        ;de now Equals the GRAPH
  ld bc,756d         ;size of picture
  bcall(_flashtoram) ;copy it.
  bcall(_GrBufCpy)   ;Display it.
  ret	             ;return!

rclpic:

  ex de,hl            
  inc hl              ;the first 2 bytes of a picture contain
  inc hl              ;meaningless garbage (well not really, but...)
  ld de, 9340h        ;location of the graphscreen
  ld bc,756d          ;number of bytes to be copied.
  ldir                ;copy the picture from its place onto the graph buffer
  bcall(_GrBufCpy)    ;_GRBUFCPY_V    ;now display it.
  ret

.end
END