POINTERS-SOLUTIONS-GFX-DELETION! -------------------------------------------------------------------------------------------------- TOOL: EDASS-128 Editor/Assembler {Commodore C128} Language: Assembler/BASIC 7.0 Extra: - Author: Misel Zivanovic Note: (C) 2nd of April 2026 - www.lived.ch, mzretro.ch --------------------------------------------------------------------------------------------------- This will be a rather unusual way of deleting the graphic screen, but it will show you exactly how things are running during the process. It would be too fast otherwise to see anything! To test this assembly code here, please use this BASIC 7.0 code below. This is also containing the assembly code which is listed below. IMPORTANT: Even if we are using low resolution screen where horizontal resolution is only 160 pixel wide, we still need 320 pixels to delete everything as you will see. The lower resolution is only valid for BASIC commands! BASIC 7.0 listing: 100 fast : graphic 3,1:color 1,15 101 for a=2 to 157 step 2 102 draw 1,a,0 to a,200:next: slow 103 : 110 for a=0 to 21:read a$ 120 poke 4864+a,dec(a$) 130 next 140 rem ------------------------------ 150 sys 4864 : rem initialization 160 rem : of the deletion values 170 rem ------------------------------ 180 rem never do >32 pages loops 190 rem remember 32 x 256 = 8192 200 rem ------------------------------ 210 : for pages=1 to 10: rem deleting 220 ::: for bytes=1 to 256 230 :::: for speed=1to5:next:rem break 240 :::: sys 4877 : rem 256 bytes 250 ::: next 260 : sys 4881 : rem next page 270 : next : rem until 10 280 rem ------------------------------ 290 data "a9","00","a2","20","a0" 300 data "20","84","8d" 310 data "a0","00","84","8c","60" 320 data "91","8c","88" 330 data "60","e6","8d","ca","60" 340 data "00" --------------------------------------------------------------------------------------------------- zeropage.asm -a:0011-a: -e: ;--------------------------------------- ; how could or can you save a byte or ; even more. And is it always a thing of ; being faster, efficient in all cases? ; is it a must to always do things the ; 'right way'?! ;--------------------------------------- ; ; often people are talking about pages! ; that's why it is important to know ; what that is before you start coding. ; we are a bit late here with that, but ; better late than never. ; ; so, one page is 256 bytes (0-255) ; in ideal cases this can be used to ; speed things up! ; ; example: a deletion of the gfx screen! ; that is 8192 bytes or in ; pages, exactly 32! ; to clean it or put a pattern ; in there, you need to repeat ; the process 32 times! ; text screen however is only 1000 bytes ; or 40x25 characters! you can't put 4 ; pages in there because that would be ; 1024 bytes! 1 row, 24 bytes, over the ; border! And right afterwards, a basic ; runtime stack is located! ; = crash if hit! ; ; graphic screen deletion from ; basic! ; ; to be used from basic only ; according to example! ; *= $1300 .obj m .bank 15 ; zeropage.asm -e:0053-a: -e: ; lda #$00 ; delete value ldx #$20 ; cycles ldy #$20 ; highbyte value sty $8d ; highbyte addr. ldy #$00 ; lowbyte value sty $8c ; lowbyte addr. rts ; = $2000, 8192 ; loop1 sta ($8c),y ; write 32x until dey ; x reg is zero! bne loop1 inc $8d dex rts ; ; note and important! ; the pages loop should never exceed ; the value of 32! ; ; ergo, valid is for a=1 to 32 or ; for a=0 to 31 --------------------------------------------------------------------------------------------------- Commodore C128 - Machine Language Monitor listing {assembly} d 1300 ffff . 01300 a9 00 lda #$00 . 01302 a2 20 ldx #$20 . 01304 a0 20 ldy #$20 . 01306 84 8d sty $8d . 01308 a0 00 ldy #$00 . 0130a 84 8c sty $8c . 0130c 60 rts . 0130d 91 8c sta ($8c),y . 0130f 88 dey . 01310 60 rts . 01311 e6 8d inc $8d . 01313 ca dex . 01314 60 rts ML-Listing m 1300 1315 >01300 a9 00 a2 20 a0 20 84 8d:I.B ? .. >01308 a0 00 84 8c 60 91 8c 88:?...?... >01310 60 e6 8d ca 60 60 00 00:?F.J??.. --------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------- Normal version to delete the high resolution graphic screen! {EDAS=128 source code} *= $1300 .obj m .bank 15 ; lda #$00 ; delete value ldx #$20 ; cycles, 32 ldy #$20 ; MSB value sty $8d ; here ldy #$00 ; LSB value sty $8c ; here loop1 sta ($8c),y ; main loop dey ; until x is 0 bne loop1 ; 1 full page inc $8d ; increment MSB dex ; next page bne loop1 ; repeat rts --------------------------------------------------------------------------------------------------- ALTERNATE VERSION MAYBE? The little brother version for those finding zero page pointers to complicated! It is few bytes BIGGER, but hey! Are you complaining here!? Really??? Hehe... This is a C128 Machine Language Code, but it's easy to make a EDASS-128 compatible code out of it! Assembly code to delete the graphic screen! a 01400 a0 00 ldy #$00 loop counter, max 32!!! a 01402 a2 00 ldx #$00 page index/counter a 01404 a9 00 lda #$00 content a 01406 9d 00 20 sta $2000,x gfx start address a 01409 ca dex loop until all 256 bytes/1 page a 0140a d0 fa bne $1406 are through! a 0140c c8 iny next page please a 0140d ee 08 14 inc $1408 increase also the MSB {Most significant Byte, or High Byte} a 01410 c0 20 cpy #$20 do that until all 32 pages, 1 full graphic screen is deleted a 01412 d0 f2 bne $1406 loop a 01414 a9 20 lda #$20 set high byte to 20 again to get the start address of $2000 a 01416 8d 08 14 sta $1408 for the next run! {or the system will/would crash otherwise} a 01419 60 rts back to BASIC or the subroutine! m 1400 1419 >01400 a0 00 a2 00 a9 00 9d 00:?.B.I... >01408 20 ca d0 fa c8 ee 08 14: JPZ.N.. >01410 c0 20 d0 f2 a9 20 8d 08:? PRI .. >01418 14 60 ff ff ff ff 00 00:.?????.. --------------------------------------------------------------------------------------------------- Okay, not so difficult after all, right... And as you can see, no need to get busy with pointers from the beginning! There is always an alternative way to achieve result in assembler {and in BASIC too, of course} We could also bet that you won't notice the speed difference! It will, however, cost you a few bytes more here and there.