C128-C64-PLUS4-SCREEN-FILL-IN-SCREENCOPY-SCREEN-PASTE-ROUTINE -------------------------------------------------------------------------------------------------- TOOL: EDASS-128 ASSEMBLER/EDITOR {Commodore C128} Language: Assembly Extra: none Author: Misel Zivanovic Note: (C) 22th of AUGUST 2026 - www.lived.ch, mzretro.ch --------------------------------------------------------------------------------------------------- This routine can do many things with some small modifications! That is however, not the most important feature here! What is, is the usage of exactly 1000 bytes! It means, it will not go over that limit and it will not delete anything beyond the screen area! {Unless you mess up the start addresses!} After the usage, default values are set and the routine can be reused or call again safely. C64: This below is working with EDASS-128 on Commodore C128 To make it usable also with C64, you can use Turbo Macro Pro and remove the lines ".obj m" and "bank 15". The rest of the code is then 100% compatible, incl. labels and the rest {go+1 etc.} You CANNOT use $1300 as the start address! Use $0340 as an example or $0801 {BASIC start address} PLUS/4: If you use Turbo-Assembler-Macro, then basically it is the same as with C64 and in addition you also must set the proper screen address. It is starting at $0c00 {and not $0400} The $2000, dec 8192 {graphic area, is the same}. That's it... $1300 cannot be used as a start address! {well, it could, but on Plus/4, it is in the middle of nowhere} Use $1000 instead {start of the BASIC} You could still later use this code with BASIC, by moving the BASIC START ADDRESS TO $4000 {Can be done with the 100 GRAPHIC 1:GRAPHIC 0, as first lines in your BASIC program} If you would use MERLIN 7501 ASSEMBLER, then you need to add line numbers and adapt label names. As you probably know, MERLIN is using {period} or "." as a prefix. So it is not "final", it is ".final", ".more" and it is not in the same line, it needs a separate line number for the labels. Then also the start address is starting with COM. Example: 100 COM $3000 ***************************************************** EXAMPLE: {MERLIN 7501 ASSEMBLER source code}: 100 com $3000 110 list 120 ldx #$00 130 .loop 140 lda $0c00,x 150 cmp #$20 160 beq .j1st 170 lda #$20 180 sta $0c00,x 190 .ret1 200 lda $0cf0,x ... ***************************************************** Hope all is clear now! Let's start with a simple fill-in routine... Where you will notice how we do not use the zero page pointers & also no several LDA/STA commands! {except when we have to do the reset to default values at the end} --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- Fill a screen with one character or graphics symbol {lda #$51} in our case! --------------------------------------------------------------------------------------------------- ;-------------------------------------- *= $1300 .obj m .bank 15 ;-------------------------------------- more ldx #$00 loop lda #$51 go sta $0400 inx inc go+1 lda go+2 cmp #$07 beq final bne doit final lda go+1 cmp #$e8 beq out doit cpx #$00 bne loop inc go+2 jmp more out lda #$00 sta go+1 lda #$04 sta go+2 rts --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- COPY text screen content from $0400 to $2000 {dec 8192} --------------------------------------------------------------------------------------------------- ;-------------------------------------- *= $1300 .obj m .bank 15 ;-------------------------------------- more ldx #$00 go lda $0400 store sta $2000 inx inc go+1 inc store+1 lda go+2 cmp #$07 beq final bne doit final lda go+1 cmp #$e8 beq out doit cpx #$00 bne go inc go+2 inc store+2 jmp more out lda #$00 sta go+1 sta store+1 lda #$04 sta go+2 lda #$20 sta store+2 rts --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- LOAD text {data} content FROM $2000 {dec 8192} to $0400 {dec 1024}, default screen area! --------------------------------------------------------------------------------------------------- ;-------------------------------------- *= $1300 .obj m .bank 15 ;-------------------------------------- more ldx #$00 go lda $2000 store sta $0400 inx inc go+1 inc store+1 lda go+2 cmp #$23 beq final bne doit final lda go+1 cmp #$e8 beq out doit cpx #$00 bne go inc go+2 inc store+2 jmp more out lda #$00 sta go+1 sta store+1 lda #$20 sta go+2 lda #$04 sta store+2 rts ---------------------------------------------------------------------------------------------------