| |
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.... |
| |
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 |
Previous - 1 | 2 - Next |