| |
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 |
|
| |
Stryyker
Registered: Dec 2001 Posts: 468 |
You could do all the code to move the curson and avoid the kernal for cursor movement. |
| |
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 |
| |
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! |
| |
enthusi
Registered: May 2004 Posts: 677 |
I used quite some kernal routines here:
Georam-Mon 0.10
In case you want to check out... |
| |
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? |
| |
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. |
| |
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. |
| |
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. |
| |
SIDWAVE Account closed
Registered: Apr 2002 Posts: 2238 |
Dont work hard, work smart! |
| |
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.
|
| |
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 |
| |
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 |
| |
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? :)
|
| |
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. |
| |
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 |