EDASS-128-ALL-TO-THE-RIGHT-$d010 -------------------------------------------------------------------------------------------------- TOOL: EDASS-128 {Commodore C128 EDITOR & ASSEMBLER} Language: Assembler Extra: - Author: Misel Zivanovic Note: (C) 14th MAY 2026 - www.lived.ch, mzretro.ch --------------------------------------------------------------------------------------------------- When we see $ff it is immediately associated with the #255! Nothing wrong with that, however, the Commodore C128 screen is offering more than that in regard to horizontal resolution. We are talking exactly 0 - 319 pixel horizontal and 0 - 199 vertical resolution. {Now we know why text screens are 40 x 25 characters, right! One byte has 8 pixel {bit} = 8 * 40 = 320 pixels! In high resolution one byte isn't just one byte, a rectangle, existing of 8 bit {0-7) value. No it is actually a matrix of 8 by 8 bit = 64 bit Imagine that, wow... Anyway, here is the routine that will help you to navigate in assembler over the full screen. Horizontally and vertically. Now we can create some additional LAByrinth ESCape content! The routine is checking if $ff was reach and if yes, we can activate the 9th bit in the memory address $d010, dec 53264. This will teleport our sprite to a new dimensions. Of course, also there we need to check if on the right end of the screen was reached, #90, and if we must disable the 9th bit and set the x-position of the sprite to 0 in order to see it appear on the left! Same then for the $00 where we are activating the 9th bit again in order to be able to position our sprite on the very right side #90 {otherwise it would be at $ff and it would take a while to see it again} Well, that it is already. I guess this is not the master solution, but it is what my brain was able to do in order to resolve this. It is working well and smooth. Can't ask for more. EDASS-128 - Assembly Source Code for Commodore C128 ;------------------------------------------------------------------------------- ; ; BASIC START LINES ; *= $1c00 .obj m .bank 15 ; .byte $00,$1a,$1c,$0a,$00,$8f,$20,$28 .byte $43,$29,$20,$57,$57,$57,$2e,$4d .byte $5a,$52,$45,$54,$52,$4f,$2e,$43 .byte $48,$00,$2d,$1c,$14,$00,$8f,$20 .byte $53,$50,$52,$49,$54,$45,$53,$20 .byte $3e,$32,$35,$35,$00,$42,$1c,$1e .byte $00,$8f,$20,$43,$4f,$4d,$4d,$4f .byte $44,$4f,$52,$45,$20,$43,$31,$32 .byte $38,$00,$4d,$1c,$28,$00,$9e,$20 .byte $37,$32,$35,$36,$00,$00,$00,$ff ; ; PROGRAM START ; *= $1c58 ; lda #$00 ;BANK 15 (for RND#) sta $ff00 ; lda #$93 ;clear screen jsr $ffd2 lda #14 ;small charset jsr $ffd2 ; lda #$0e ;screen colors sta $d020 lda #$0a sta $d021 ; lda #$01 ;BASIC IRQ Service OFF sta $12fd ; lda #$01 ;Sprite 0 ON sta $d015 ; lda #$06 ;Sprite Color - Light Blue sta $d027 ; lda #25 sta $d000 ;x position lda #160 sta $d001 ;y position ; lda #142 ;CAPITOL characters jsr $ffd2 ; lda #$ff ;activate RND SEED sta $d40e ;classic one sta $d40f lda #$80 sta $d412 ; ldx #$65 rndsprite lda $d41b ;collect RND dex sta $0e00,x bne rndsprite ; ; rts ; ;------------------------------------------------------------------------------- ;MAIN?LOOP & CONTROL ;------------------------------------------------------------------------------- ; main lda $d4 ;read keyboard cmp #$55 ;input beq left ;all this should be pretty much cmp #$53 ;very clear beq up ;we are reading arrow keys status cmp #$56 ;and are branching accordingly beq right cmp #$54 beq down cmp #$3e ;quit with Q key (EXIT) beq exit ;you can add more if you want jmp main ;main loop ; ; left jmp goleft ;I am using this to avoid facing right jmp goright ;the limitations of the branching up jmp goup ;commands. Which is 127 bytes +- down jmp godown ;from the source jmp main ;------------------------------------------------------------------------------- exit rts ; ;------------------------------------------------------------------------------- ; goleft dec $d000 ;only sprite 0 is controlled here ; dec $d002 ;for this demonstration ; dec $d004 jsr delay lda #$01 ;we went left. this is used to jump back sta direction ;after the collision lda $d000 ;load the x position cmp #$00 ;is it 0? beq msbleft ;yes, then branch jmp main ; msbleft lda $d010 ;check if 9th bit is already active and #$01 cmp #$01 beq msbleftnorm ;yes, then branch lda #$01 ;otherwise continue here sta $d010 ;set the 9th bit lda #90 ;and position sprite 0 at x=90 sta $d000 ;on the right side of the screen jmp main ; msbleftnorm lda #$00 ;9th bit ($d010) was active! sta $d010 ;disable it and place the at the x-pos lda #$ff ;#255, $ff becuase before it was > $ff sta $d000 jmp main ; goright inc $d000 ; inc $d002 ; inc $d004 jsr delay lda #$03 ;we went up sta direction ; lda $d010 ;is 9th bit active? and #$01 cmp #$01 beq msbright ;then branch immediately ; lda $d000 ;otherwise first when $ff, #255 is cmp #$ff ;indicated as x-position beq msbright jmp main ; msbright lda #$01 ;as long as 9th bit is active and sta $d010 ;x-pos isn't >= #90 we are moving lda $d000 ;in 9th bit area = 255 <> #90 cmp #90 ;meaning 256,257,258 etc. beq msbrightnorm jmp main ; msbrightnorm lda #$00 ;#90 was reached! sta $d010 ;then disable 9th bit and place the sta $d000 ;sprite on the very left side of the jmp main ;screen ; goup dec $d001 ; dec $d003 ; dec $d005 jsr delay lda #$02 ;we went right sta direction jmp main ; godown inc $d001 ; inc $d003 ; inc $d005 jsr delay lda #$04 ;we went down sta direction jmp main ; delay ldy slow ;how fast is sprite m0 ldx #$00 m1 dex bne m1 dey bne m0 rts ; delay2 ldy slow2 ;correction delay m2 ldx #$00 m3 dex bne m3 dey bne m2 rts ; ; ;------------------------------------------------------------------------------- ; STORAGE DEPARTMENT LTD. ; ;SPEED BREAKER slow .byte 10 slow2 .byte 50 ; ;DIRECTIONS direction .byte 0