Skip to content

Instantly share code, notes, and snippets.

View gnacu's full-sized avatar

Gregory Naçu gnacu

View GitHub Profile
pgfetch_ = $1b
; RegPtr -> C64 Memory Buffer to fetch
; C <- Set on failure to fetch
; C <- Clr on successful fetch
pgstash_ = $1e
; RegPtr -> C64 Memory Buffer to stash
; C <- Set on failure to stash
; C <- Clr on successful stash
unldcsum ;--- Unload checksum.lib ---
.block
lda chloaded
beq done ;Not loaded
ldx #"c" ;checksum.lib
ldy #"h"
lda #slunload ;Unload flag
jsr unldlib
chloaded .byte 0
ldchksum ;--- Load checksum.lib ---
.block
lda chloaded
bne done ;Already loaded
ldx #"c" ;checksum.lib
ldy #"h"
lda #3 ;3 pages, no flags
;--- Unload checksum.lib ---
ldx #"c" ;checksum.lib
ldy #"h"
lda #slunload ;Unload flag
jsr unldlib
;--- Load checksum.lib ---
ldx #"c" ;checksum.lib
ldy #"h"
lda #3 ;3 pages, no flags
jsr loadlib
;A <- page address of library
;--- Link checksum.lib ---
maketab .byte $4c,$06,$00 ;maketab_ = $06
initcrc .byte $4c,$09,$00 ;initcrc_ = $09
updc16 .byte $4c,$0f,$00 ;updc16_ = $0f
getcrc .byte $4c,$15,$00 ;getcrc_ = $15
#inc_h "checksum"
maketab jmp maketab_
initcrc jmp initcrc_
updc16 jmp updc16_
getcrc jmp getcrc_
thisdirt #setflag this,dflags,df_dirty
rts
chkdirt lda tkenv+te_flags
and #tf_dirty
bne mkdirt+8
sec ;not dirty
rts
10 print"ascii to petscii converter"
20 print"copyright to whoever wrote it"
30 print
40 input"source file";sf$
50 input"destination file";df$
60 dv=peek(186)
70 open2,dv,2,sf$+",s,r"
80 open3,dv,3,df$+",s,w"
85 rem --------------------------------
90 sys2000
.include "//os/h/:modules.h"
#inc_k "io"
#inc_s "file"
*=2000
loop ldx #2
jsr chkin
jsr chrin