Last active
September 12, 2018 13:12
-
-
Save gnacu/55114795506b0b3270db1109d8e30957 to your computer and use it in GitHub Desktop.
Sample Code for "screengrab" routine in C64 OS's KERNAL.
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 | |
.text "Screen Capture" | |
.byte 0,0 ;Title Padding | |
.byte 0 ;Title Terminator | |
.text "C64 OS KERNAL" | |
.byte 0,0,0 ;Author Padding | |
.byte 0 ;Author Terminator | |
.text "2018" | |
.word 0,0,0,0,0,0 ;Released Padding | |
.byte 0 ;Released Terminator | |
fname .null "screen.pet" | |
screengrab | |
.block | |
ptr = $fb | |
jsr getsfref+sser ;Get System File Reference | |
#stxy ptr | |
ldy #frefname-1 | |
ldx #$ff | |
next iny | |
inx | |
lda fname,x | |
sta (ptr),y | |
bne next | |
#rdxy ptr | |
lda #ff_w.ff_o | |
jsr fopen | |
;Write the header to file. | |
jsr fwrite | |
.word pethead | |
.word 55 | |
;Write screen memory to file. | |
jsr fwrite | |
.word scrmem | |
.word 1000 | |
;Write color memory to file. | |
jsr fwrite | |
.word colmem | |
.word 1000 | |
;Write VIC background/border registers | |
jsr fwrite | |
.word vic+$20 | |
.word 2 | |
jsr fclose | |
ldx #1 | |
jmp pgfree | |
.bend |
One more correction. The filename "screencapture.pet" was too long. I changed that to "screen.pet"
Tightened up that fname loop. And updated the file flag constants, I was going from memory when I wrote the first version.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Whoops. Updated with the pgfree. I forgot the deallocate the page that was allocated for me by the call to getsfref at the top.