;;    THIS IS UNIFINISHED
   .include #macros
   .include #16bit                  /* 1 TAB = three spaces */
                                    /* use 6 for coding     */                 
   .if .not .def TEST
      .vfl_bochum _string1
      .vfl_bochum _string2
   .else

      .include #cio

_string1 == $F0


main:
      dpoke    _string1,buffer1
      dpoke    _string2,headbuf
      jsr      pretty
      print    0,header,255,@p1+@p2+@p3
      dpoke    _string1,buffer2
      jsr      pretty
      print    0,header,255,@p1+@p2+@p3
      brk


header:
      .byte    "Value = "
headbuf:      
      .ds      8
         
buffer1:
      .byte    "12345",0

buffer2:
      .byte    "-00123450",0

      .endif

;; -------------------------------------------------------------
;; Pretties up a ASCII integer, this is useful after having
;; converted something via ITOA. If carry is set, then pretty
;; assumes that in X there is a character that should be put 
;; at the end of the string. The integer can't be longer than
;; 255 characters. This routine does no error checking!!
;; 
;; _STRING1 : ASCII integer
;; -------------------------------------------------------------
      
kill_0lead:
      ldy   #0                ; can't optimize here, sorry
      tya                     ; push EOS append flag on stack
      adc   #0                ; 1 == APPEND, 0 == DON'T
      pha                     
      txa
      pha                     ; push EOS char on stack
      ldx   #0                ; [like to keep STD.L65 ROMamble]
      
:loop
      lda   (_string1),y
      beq   :done
:xloop
      cmp   #'-'              ; ought to be in the front only
      beq   :still
      cmp   #'+'
      beq   :still
      cmp   #'0'        
      beq   :eliminate
      inx  
:still
      sta   (_string2),y
      iny
      bne   :loop

           
:eliminate
      cpx   #1                ; still in the header
      bcs   :still            ; nope ->
      iny
      lda   (_string1),y      ; this the last 0 (was 00000 probably...)
      bne   :xloop            ; try next
      
:done
      pla
      tax
      pla
      beq   :donothing
      rtsa
     
      
      

            
