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
2009-10-09 09:18
Stryyker

Registered: Dec 2001
Posts: 468
You could do all the code to move the curson and avoid the kernal for cursor movement.
2009-10-09 09:27
Adam

Registered: Jul 2009
Posts: 323
Yeah, I don't want to use kernel routines unless I have to. I just need to know what mem locations the cursor uses and then from those addresses I can (hopefully) control the x/y positioning of the cursor location from there. :))

..Adam/Onslaught/Sidwave
2009-10-09 09:42
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
Well, start the cursor at 0400, and use kernal (ffd2) to print chars. Count the chars! make an index, so you always know where your cursor is.

So if you press right 5 times your counter is 4, if you press down 1 time, you add 40 to the y counter.

Use an X and an Y counter!
2009-10-09 09:47
enthusi

Registered: May 2004
Posts: 677
I used quite some kernal routines here:
Georam-Mon 0.10
In case you want to check out...
2009-10-09 11:18
Krill

Registered: Apr 2002
Posts: 2980
Quote: Yeah, I don't want to use kernel routines unless I have to. I just need to know what mem locations the cursor uses and then from those addresses I can (hopefully) control the x/y positioning of the cursor location from there. :))

..Adam/Onslaught/Sidwave


But you are aware that the cursor is implemented by software and made by just manipulating the character at cursor position?
2009-10-09 12:47
Soren

Registered: Dec 2001
Posts: 547
I myself often use a sprite cursor in my music editors.
Got a routine that calculate the correct sprite positions to match char positions.. I only throw X+Y char positions into it and it works nicely. For me this is very nice as I use a colour flashing cursor and the spritecursor is put behind chars, so I easily can see the char the cursor is placed on.
It's quite easy to do, if one wants something else than a char based cursor.
2009-10-09 13:12
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: Yeah, I don't want to use kernel routines unless I have to. I just need to know what mem locations the cursor uses and then from those addresses I can (hopefully) control the x/y positioning of the cursor location from there. :))

..Adam/Onslaught/Sidwave


You never _have_ to use kernel functions fyi. I suggest you write your own cursor routines like Jeff suggested.
2009-10-10 00:00
Skate

Registered: Jul 2003
Posts: 494
I usually code my own cursor routine for my text editors. But for my very first noter, I remember stealing all the necessery parts from kernel and making some changes like prohibiting page scrolling. I don't recommend this method but it's possible.
2009-10-10 09:33
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
Dont work hard, work smart!
2009-10-10 20:16
Angel of Death

Registered: Apr 2008
Posts: 211
You should take a look at this program:
Characterize V0.03
Source is included.
it's Not made by me but it is chockful of useful (kernal utilising) routines including diskop- and textinput routines.

I made a micro text-editor using kernal routines but it's to simple to release and I have no place to upload it to (yet).
let me know if you're interested.
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
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
Holy Moses/Role
cobbpg
/Panor..
iAN CooG/HVSC
Guests online: 135
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 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (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 Coders
1 Axis  (9.8)
2 Graham  (9.8)
3 Lft  (9.8)
4 Crossbow  (9.8)
5 HCL  (9.8)

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