It is definitely doable in BASIC, but if you prefer the Assembly route, I suggest this:
; mnemonics ;hex code ;notes
bcall(_RclName) ;EFD74A ;Locate Ans in memory
cp 4 ;FE04 ;Compare A to 4. If A=4, z flag is set. (Strings are type 4)
ret nz ;C0 ;"return if not zero". Quit if Ans is not a string
ex de,hl ;EB ;Swap DE and HL, so HL points to the size bytes
ld a,(hl) ;4E ;Now we need to get the size of the string. It should be less than 9, so we only need to read the first byte and check.
inc hl ;23 ;
inc hl ;23 ;HL now points to the data of Ans
cp 8 ;FE08 ;Compare A to 8. If A<=8, c flag is set
jr c,$+4 ;3802 ;skip the next two bytes if c flag is set.
ld a,8 ;3E08 ;If the length of Ans is >8, we only want to take the first 8 bytes
ld de,OP1 ;117884 ;We need to copy the name to OP1
ld c,a ;4F ;A->C
ld b,0 ;0600 ;0->B, BC is now the number of bytes to copy to OP1
ld a,6 ;3E06 ;6->A, We need to put 6 in OP1 to signify it is a protected program name
ld (de),a ;12 ;A is stored to the byte that DE points to (OP1)
inc e ;1C ;Increments E, so now DE points tot he next byte. E is not FF, so we don't need to use INC DE, saving a few cycles
ldir ;EDB0 ;Copy BC number of bytes from HL to DE
xor a ;AF ;An optimised (smaller,faster) way of doing 0->A 'LD A,0'
ld (de),a ;12 ;We need to write a 0 to the end of the name in OP1. DE points to the end of the name...
bcall(_ChkFindSym);EFF142 ;We need to look for the program to see if it already exists.
jr c,$+5 ;3803 ;Skip the next three bytes if the c flag is set (means the program did not exist)
bcall(_DelVarArc);EFC64F ;Delete the program if it exists
ld hl,768+CodeEnd-Code;211103;This is the size of the program that will be created.768 bytes to store the image, plus ** bytes for the code.
bcall(_CreateProtProg);EF6D4E ;Create the protected program named in OP1 with size=HL
ld hl,Code ;21D39D ;HL points to the code to copy to the start of the program
ld bc,CodeEnd-Code;011100 ;This is the number of bytes to copy to the program
inc de ;13 ;
inc de ;13 ;DE now points tot eh data of the new program
ldir ;EDB0 ;copies the code to the program
ld hl,plotSScreen ;214093 ;HL now points to the graph screen
ld b,3 ;0603 ;I cheated. Now BC=768 (BC=B*256+C)
;DE points to the byte after the code that has been copied to the program
ldir ;EDB0 ;Copies the contents of the graph buffer to the program
ret ;C9 ;We have finished.
;This is the code we will put in the created program. It will display the image that we store in it
.db $BB,6Dh ;BB6D ;AsmPrgm header
ld hl,9DA4h ;21A49D ;HL points to the bitmap image
ld bc,768 ;010003 ;BC is the number of bytes to copy
ld de,plotSScreen ;114093 ;DE points tot eh graph buffer
ldir ;EDB0 ;Copy BC number of bytes at (HL) to (DE)
bcall(_GrBufCpy) ;EF6A48 ;Show the screen
ret ;C9 ;Exit the program
Store the name of the program to create in Ans. If the program exists, it will be overwritten! This will create an assembly program with 768+17 bytes of data. When you run the program, it will recall the picture by overwriting the contents of the screen. I do have another version that allows you to choose the drawing logic, but naturally the code is larger. Here is an example of use:
Asm(prgmTTLSCRN0 ;run this as an assembly program to recall the pic
I may have made a typo, so you should make sure you have stuff backed up before running it. .__.