1
0
mirror of https://github.com/cc65/cc65.git synced 2025-08-08 06:25:17 +00:00

Use local multiply for cursorzone calculations

This commit is contained in:
Karri Kaksonen
2022-04-06 14:08:03 +03:00
committed by mrdudz
parent 9d4f1a0415
commit 3ba6dd0a4a
2 changed files with 46 additions and 24 deletions

View File

@@ -7,7 +7,7 @@
.export _cputc .export _cputc
.export _textcolor .export _textcolor
.import _gotoxy, _gotox, _gotoy, tosaddax, pusha0 .import _gotoxy, _gotox, _gotoy, pusha0
.import pushax .import pushax
.import _screen .import _screen
.import CURS_X, CURS_Y .import CURS_X, CURS_Y

View File

@@ -30,7 +30,7 @@
.importzp sp .importzp sp
.import _zones .import _zones
.import pusha, incsp1, pusha0, pushax, popax, tosumula0, incax5 .import pusha, incsp1, pusha0, pushax, popax
.include "atari7800.inc" .include "atari7800.inc"
.include "extzp.inc" .include "extzp.inc"
@@ -48,12 +48,34 @@ CURS_Y:
_cursor_visible: _cursor_visible:
.byte 1 .byte 1
.bss
_cursorzone:
.res 2
.code .code
;---------------------------------------------------------------------------
; 8x16 routine
umula0:
ldy #8 ; Number of bits
lda #0
lsr ptr7800 ; Get first bit into carry
@L0: bcc @L1
clc
adc ptrtmp
tax
lda ptrtmp+1 ; hi byte of left op
adc ptr7800+1
sta ptr7800+1
txa
@L1: ror ptr7800+1
ror a
ror ptr7800
dey
bne @L0
tax
lda ptr7800 ; Load the result
rts
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
; Enable/disable cursor ; Enable/disable cursor
; ;
@@ -75,18 +97,23 @@ _cursorzone:
; A = CURS_Y ; A = CURS_Y
.proc calccursorzone .proc calccursorzone
jsr pusha0
lda #11
jsr tosumula0
jsr incax5
clc
adc #<_zones
sta _cursorzone ; calculate new cursorzone
sta ptr7800 sta ptr7800
lda #11
sta ptrtmp
lda #0
sta ptr7800+1
sta ptrtmp+1
jsr umula0
clc
adc #5
bcc @L1
inx
@L1: clc
adc #<_zones
sta cursorzone ; calculate new cursorzone
txa txa
adc #>_zones adc #>_zones
sta _cursorzone+1 sta cursorzone+1
sta ptr7800+1
rts rts
.endproc .endproc
@@ -113,7 +140,7 @@ _cursorzone:
jsr calccursorzone jsr calccursorzone
ldy #1 ldy #1
lda #0 lda #0
sta (ptr7800),y ; disable cursor sta (cursorzone),y ; disable cursor
pla pla
sta CURS_Y sta CURS_Y
jsr calccursorzone jsr calccursorzone
@@ -121,7 +148,7 @@ _cursorzone:
beq @L1 beq @L1
lda #30 ; enable cursor lda #30 ; enable cursor
@L1: ldy #1 @L1: ldy #1
sta (ptr7800),y sta (cursorzone),y
rts rts
.endproc .endproc
@@ -134,18 +161,12 @@ _cursorzone:
.proc _gotox .proc _gotox
sta CURS_X sta CURS_X
tay
lda _cursorzone
ldx _cursorzone+1
sta ptr7800
stx ptr7800+1
tya
ldy #3 ldy #3
clc clc
rol rol
rol rol
rol rol
sta (ptr7800),y sta (cursorzone),y
rts rts
.endproc .endproc
@@ -162,6 +183,7 @@ _cursorzone:
.endproc .endproc
.proc gotoxy .proc gotoxy
jsr popax
jmp _gotoxy jmp _gotoxy
.endproc .endproc
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------