C128-RASTER-IN-GRAPHIC-SCREEN --------------------------------------------------------------------------------------------------- TOOL: Built-in ML-Monitor {Commodore C128} Language: Machine Language {Assembler} Extra: none Author: Misel Zivanovic Note: (C) 18th of OCTOBER 2026 - www.lived.ch, mzretro.ch Doc Revision: 1.0 Last update: 12:42 21.10.2026 --------------------------------------------------------------------------------------------------- When you try to find a thing about GRAPHICS in assembler on Commodore C128, there is little to nothing available. I guess, if anyone had to deal with it, they all had to walk the path of exploring the area on their own.... And had no desire to share the experience and found knowledge! I am saying it so, because i could find literally nothing about. Especially related to multi-color mode there is ZERO of something available! I had to search the ROM-BASIC-Routines like crazy and then also try out everything. Not to mention how the order of the routines is impacting the final results. For starters, we will create a simple pattern and put it on screen in RASTER MODE. The first 9 lines of the screen will be high resolution graphics and the rest will be shown as a normal text screen. Interesting is, that a deletion color is basically our drawing color. And that is why the screen is flashing. I can't tell if that is the correct procedure, but if nothing else, it works! This could probably need some extra attention in the following episodes! --------------------------------------------------------------------------------------------------- SOURCE CODE IN ASSEMBLER {for the built-in ML-Monitor in C128} - NOT suitable for copy/paste, use ML-Code for that further below. --------------------------------------------------------------------------------------------------- . 01400 20 4d 14 jsr $144d - gosub to settings part . 01403 a0 00 ldy #$00 - y register to zero . 01405 a2 00 ldx #$00 - x register to zero . 01407 b9 66 14 lda $1466,y - read byte definition . 0140a 9d 00 20 sta $2000,x - write to first line of the gfx screen . 0140d 9d a0 20 sta $20a0,x - the same, the remaining 160 bytes . 01410 9d 40 21 sta $2140,x - and repeat all for 9 lines . 01413 9d e0 21 sta $21e0,x . 01416 9d 80 22 sta $2280,x . 01419 9d 20 23 sta $2320,x . 0141c 9d c0 23 sta $23c0,x . 0141f 9d 60 24 sta $2460,x . 01422 9d 00 25 sta $2500,x . 01425 9d a0 25 sta $25a0,x . 01428 9d 40 26 sta $2640,x . 0142b 9d e0 26 sta $26e0,x . 0142e 9d 80 27 sta $2780,x . 01431 9d 20 28 sta $2820,x . 01434 9d c0 28 sta $28c0,x . 01437 9d 60 29 sta $2960,x . 0143a 9d 00 2a sta $2a00,x . 0143d 9d a0 2a sta $2aa0,x . 01440 e8 inx - increase x value . 01441 c8 iny - increase y value . 01442 c0 08 cpy #$08 - end reached? . 01444 d0 c1 bne $1407 - no, go back to $1407 . 01446 a0 00 ldy #$00 - yes, do set y to zero again . 01448 e0 a0 cpx #$a0 - check if x is 160 {half the screen} . 0144a d0 bb bne $1407 - no, then repeat the proces until it is . 0144c 60 rts - back to BASIC when done . 0144d a9 00 lda #$00 - set BANK 15 {$00 is BANK 15} . 0144f 8d 00 ff sta $ff00 - write it to memory register . 01452 a9 60 lda #$60 - set the Graphics Mode 2 {split raster capable} . 01454 85 d8 sta $d8 - write the value to register . 01456 a9 02 lda #$02 - set color {red in our case} . 01458 8d e2 03 sta $03e2 - write it to register used by the hires clear routine . 0145b a9 78 lda #$78 - raster line { ( = line number * 8 ) + 48 = dec 120 or hex #$78 } . 0145d 8d 34 0a sta $0a34 - write it to the register . 01460 20 30 6b jsr $6b30 - clears hires screen . 01463 60 rts - return from the subroutine to . 01403 a0 00 ldy #$00 . 01464 ea nop - space holder . 01465 ea nop - space holder Add also these 8 bytes if you have decided to type this in That are the graphics pattern bytes. By changing them, you can create your own! >01466 ff 83 9f bf bf fb ff ff:........ --------------------------------------------------------------------------------------------------- ML-CODE of the assembly listings above} -This can be copy/pasted and will immediately work. No manual corrections necessary! --------------------------------------------------------------------------------------------------- >01400 20 4d 14 a0 00 a2 00 b9: m.?.B.Y >01408 66 14 9d 00 20 9d a0 20:F... .? >01410 9d 40 21 9d e0 21 9d 80:.@!.?!.. >01418 22 9d 20 23 9d c0 23 9d:". #.?#. >01420 60 24 9d 00 25 9d a0 25:?$..%.?% >01428 9d 40 26 9d e0 26 9d 80:.@&.?&.. >01430 27 9d 20 28 9d c0 28 9d:'. (.?(. >01438 60 29 9d 00 2a 9d a0 2a:?)..*.?* >01440 e8 c8 c0 08 d0 c1 a0 00:HH?.PA?. >01448 e0 a0 d0 bb 60 a9 00 8d:??P??I.. >01450 00 ff a9 60 85 d8 a9 02:.?I?.XI. >01458 8d e2 03 a9 78 8d 34 0a:.B.IX.4. >01460 20 30 6b 60 ea ea ff 83: 0K?JJ?. >01468 9f bf bf fb ff ff 00 00:.?????.. ---------------------------------------------------------------------------------------------------