home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / _ / 6502xass / !6502-XAss / Docs / Sources / Trans-Run < prev   
Text File  |  1995-12-23  |  4KB  |  144 lines

  1. ;**************************************
  2. ;*            Trans-Run               *
  3. ;*                                    *
  4. ;* press <restore> on C-64 to receive *
  5. ;*      and start a program from      *
  6. ;*          6502/6510 XAss            *
  7. ;*                                    *
  8. ;*    ©1995 by Skoe of Expression     *
  9. ;**************************************
  10.  
  11.  
  12. !base = $cf00        ; first run this program with "SYS xxxxx",
  13.                      ; now you can press <restore> if you want to test a program
  14. !start = $c000       ; transfered program will be started with "JMP start"
  15.  
  16. !bsout = $ffd2       ; print char
  17. !vic_init = $e5a0    ; reset vic
  18. !sound_vol = $d418   ; to avoid noise
  19.  
  20. ; Format of transfered data:
  21. ; --------------------------
  22. ;
  23. ; byte    meaning
  24. ;    0    always 0     \
  25. ;    1    always 255   /  mark for start
  26. ;    4    start address low
  27. ;    5    start address high
  28. ;    6    end address low
  29. ;    7    end address high
  30. ;    8    start address low \
  31. ;    9    start address high \  to be
  32. ;   10    end address low    /  sure...
  33. ;   11    end address high  /
  34. ;   12... datas
  35.  
  36. !DDRB = $dd03
  37. !PRB = $dd01
  38. !PRA = $dd00
  39.  
  40. !wait1ms=$eeb3
  41.  
  42.                 lda #<nmi
  43.                 sta $0318
  44.                 lda #>nmi
  45.                 sta $0319
  46.                 rts
  47. .nmi
  48.                 lda #0
  49.                 sta DDRB                  ; all pins input
  50.                 sta sound_vol             ; silence
  51.                 lda PRA
  52.                 and #252
  53.                 ora #3
  54.                 sta PRA                   ; video bank
  55.                 jsr vic_init
  56. .waitstart_a
  57.                 dec $d020
  58.                 jsr getbyte
  59.                 cmp #0
  60.                 bne waitstart_a
  61. .waitstart_b                                
  62.                 dec $d020
  63.                 jsr getbyte
  64.                 cmp #$ff
  65.                 bne waitstart_b
  66.  
  67.                 jsr getbyte
  68.                 sta startaddress+1
  69.                 jsr getbyte
  70.                 sta startaddress+2
  71.  
  72.                 jsr getbyte
  73.                 sta endlo+1
  74.                 jsr getbyte
  75.                 sta endhi+1
  76.  
  77.                 jsr getbyte
  78.                 cmp startaddress+1
  79.                 bne error
  80.                 jsr getbyte
  81.                 cmp startaddress+2
  82.                 bne error
  83.  
  84.                 jsr getbyte
  85.                 cmp endlo+1
  86.                 bne error
  87.                 jsr getbyte
  88.                 cmp endhi+1
  89.                 bne error
  90.                 
  91.                 ldx #0
  92. .mainloop
  93.                 jsr getbyte
  94.                 sta $d020
  95.                 stx $d020
  96. .startaddress
  97.                 sta $ffff
  98.                 inc startaddress+1
  99.                 bne nohiinc
  100.                 inc startaddress+2
  101. .nohiinc
  102.                 lda startaddress+2
  103. .endhi
  104.                 cmp #0
  105.                 bne nocmplo
  106.                 lda startaddress+1
  107. .endlo
  108.                 cmp #0
  109.                 beq endtransfer
  110. .nocmplo
  111.                 jmp mainloop
  112. .endtransfer
  113.                 lda #$37                  ; use your $01 value here
  114.                 sta z,1
  115.                 lda #15
  116.                 sta $d020
  117.                 jmp start                 ; it's ugly to "leave" an nmi 
  118.                                           ; by using jmp...
  119. ; ------------------------------
  120. .error
  121.                 ldx #0
  122. .err_1
  123.                 lda err_text,x
  124.                 beq err_end
  125.                 jsr bsout
  126.                 inx
  127.                 jmp err_1
  128. .err_end
  129.                 lda PRB                   ; empty port buffer
  130.                 jmp err_end
  131. .err_text
  132.  /tx "?transfer error_try again!_°"       ; '°' is #0, '_' is #13
  133. ; ------------------------------
  134. .getbyte
  135.                 jsr wait1ms               ; C64 must be slower than Archi
  136.                                           ; (one way handshaking)
  137.                                           ; you can try to use a DEX-loop
  138.                                           ; instead of "wait1ms"
  139.                                           ; this version is about 1 kB/sec.
  140.                                           ; fast
  141.                 lda PRB
  142.                 rts
  143.  
  144.