Last active
September 12, 2018 19:44
-
-
Save gnacu/c5ad52836290c925a93a707a77c7662e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated the file flags, I'd been going from memory.