Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Controlling the screen cursor
2009-10-09 08:50
Adam

Registered: Jul 2009
Posts: 323
Controlling the screen cursor

Hello! :)
I am trying to code a screen editor using assembler but cannot recall how to limit the cursor to access specific areas of the screen. For example, let's just say I want to be able to edit the screen using the cursor and cursor keys but only be able to move from $400 to $428, how would I set this up?

Thanks..
..Adam/Onslaught/Sidwave
 
... 10 posts hidden. Click here to view all posts....
 
2009-10-11 19:51
Stranger
Account closed

Registered: Nov 2006
Posts: 6
This is a simple example. When the cursor touch the X char it'll be located to another location. Sorry, if i have understood your question wrong :)

!to"cursor.prg",cbm
*=$0801
!byte $0b,$08,$00,$00,$9e,$32,$30,$36,$31,$00,$00,$00
*=$080d

screen=$0400

jsr$e544 ;Clean Screen

lda#24 ;locate X char to x=5, y=5
sta screen+(5*40)+5

;interrupt routine
sei
lda #$7f
sta $dc0d
lda #$00
sta $dc0e
lda #$01
sta $d01a
lda #$1b
sta $d011
lda #2
sta $d012
lda #<int01
sta $0314
lda #>int01
sta $0315
cli
rts

int01:
jsr xread

inc $d019
jmp $ea31


xread: ;reads cursors x coord from $d3 at zeropage
ldx$d3
cpx#5 ;if x=5 read y coord of cursor from yread
beq yread
rts

yread:
ldy$d6 ; read y coord from $d6 at zeropage
cpy#5 ; if y=5 go restart routine
beq restart
rts

restart: ;set cursor to (0,2) it's under the ready message
ldx#2
ldy#0
clc
jsr$fff0
rts
2009-10-11 21:01
Stranger
Account closed

Registered: Nov 2006
Posts: 6
btw restart routine with disassembly of $FFF0...

restart:
LDX#2
LDY#0
CLC

BCS E513
STX $D6
STY $D3
JSR jt1 ;$E56C
E513: LDX $D6
LDY $D3

jt1: LDX $D6
C:e56e LDA $D3
E570 LDY $D9,X
BMI E57C
CLC
ADC #$28
STA $D3
DEX
BPL E570
E57C: JSR jt2;$E9F0
LDA #$27
INX
E582: LDY $D9,X
BMI E58C
CLC
ADC #$28
INX
BPL E582
E58C: STA $D5
JMP $EA24
CPX $C9
BEQ E598
JMP $E6ED
E598: !byte $60
jt2: LDA $ECF0,X
STA $D1
LDA $D9,X
AND #$03
ORA $0288
STA $D2
RTS
2009-10-11 22:58
Adam

Registered: Jul 2009
Posts: 323
Thank you very much for the posts. I'll defiantly check out all the sources and ASM code (cheers stranger!)
I read jeff's post and went to work making an 8x8 sprite cursor routine which is controlled by the cursor keys. The sprite priority was changed so the chars are behind the sprite and I also added colour cycling to make it flash on/off. Now, how do I locate the char position depending where the sprite is? :)
2009-10-12 10:30
Stryyker

Registered: Dec 2001
Posts: 468
Two ways.

1. Keep a record of equivalent X/Y positions in character co-ordinates when it moves

2. Use the sprite positions and subtract the left/top positions. Factor in $d010 somehow. Now shift right 3 times (divide by 8) assuming you're ysing standard sized characters. Are you using sprite 0? That will enabled some easier code.
2009-10-12 20:48
Angel of Death

Registered: Apr 2008
Posts: 211
* = $1000

screen = $0400
zplo = $02
zphi = $03

calcx ldy #$00
sty zplo
sty zphi
sec
lda $d000
sbc #$18 ;get rid of border-offset
lsr
lsr ;divide by 8
lsr
tay
lda $d010 ;assuming sprite0 is cursor
and #$01 ;check if spritemover crossed
beq + ;boundary
tya
clc
adc #32 ;if so add an offset to x-pos
+ tay
calcy sec
lda $d001
sbc #$32 ;get rid of border-offset
lsr
lsr ;divide by 8
lsr
tax
lda $ecf0,x ;table in kernel containing LSB's of screenline start.
sta zplo
lda $d9,x ;table in zp with MSB's constructed at VIC init.
and #$03
ora #>screen ;add msb of used page (probably always $04)
sta zphi
putchar lda #$2a ;put asterisk on screen as example
sta (zplo),y
rts

You could use the kernel routine at $e56c but it will probably be a bit top-heavy.
Happy coding
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
t0m3000/hf^boom!^ibx
Quetzal/Chrome
Rub_0201
E$G/HF ⭐ 7
iceout/Avatar/HF
fuzzybad
Guests online: 127
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 X-Mas Demo 2024  (9.5)
7 Dawnfall V1.1  (9.5)
8 Rainbow Connection  (9.5)
9 Onscreen 5k  (9.5)
10 Morph  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Fullscreen Graphicians
1 Joe  (9.7)
2 Sulevi  (9.6)
3 The Sarge  (9.6)
4 Veto  (9.6)
5 Facet  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.043 sec.