Skip to content

Instantly share code, notes, and snippets.

@gnacu
Last active September 12, 2018 19:44
Show Gist options
  • Save gnacu/c5ad52836290c925a93a707a77c7662e to your computer and use it in GitHub Desktop.
Save gnacu/c5ad52836290c925a93a707a77c7662e to your computer and use it in GitHub Desktop.
pethead .text "PET" ;Magic
.text "1" ;Version
valid .text "PET1"
petviewer ;RegPtr -> Pointer to a fileref to a PET image
.block
ptr = $fb
lda #ff_r
jsr fopen
;Read in the Magic and Version
jsr fread
.word pethead
.word 4
#stxy ptr
;Validate the Magic and Version
ldx #3
nextv lda pethead,x
cmp valid,x
bne invalid
dex
bpl nextv
;Read 53 more header bytes to /dev/null
ldy #freflfn
lda (ptr),y
tax
jsr chkin
ldx #53
nextr jsr chrin
dex
bne nextr
jsr clrchn
#rdxy ptr
;Read in screen memory
jsr fread
.word scrmem
.word 1000
;Read in color memory
jsr read
.word colmem
.word 1000
;Read VIC background/border registers
jsr fread
.word vic+$20
.word 2
invalid jsr fclose
ldx #1
jmp pgfree
.bend
@gnacu
Copy link
Author

gnacu commented Sep 12, 2018

Updated the file flags, I'd been going from memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment