mirror of
https://github.com/cc65/cc65.git
synced 2025-01-26 17:36:57 +00:00
Changes to the TGI driver API:
* Removed CIRCLE * Aspect ratio is a new header variable * Removed the reserved bytes - it's easier to bump the API version * Clipping is done completely in the wrapper git-svn-id: svn://svn.cc65.org/cc65/trunk@4398 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
07e629a342
commit
50c1db0331
@ -3,7 +3,6 @@
|
||||
;
|
||||
; Stefan Haubenthal <polluks@sdf.lonestar.org>
|
||||
; Oliver Schmidt <ol.sc@web.de>
|
||||
; Based on Maciej Witkowiak's circle routine
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
@ -69,18 +68,6 @@ X1 := ptr1
|
||||
Y1 := ptr2
|
||||
X2 := ptr3
|
||||
Y2 := ptr4
|
||||
RADIUS := tmp1
|
||||
|
||||
ADDR := tmp1 ; (2) SETPIXELCLIP
|
||||
TEMP := tmp3 ; icmp
|
||||
TEMP2 := tmp4 ; icmp
|
||||
XX := ptr3 ; (2) CIRCLE
|
||||
YY := ptr4 ; (2) CIRCLE
|
||||
TEMP3 := sreg ; CIRCLE
|
||||
TEMP4 := sreg+1 ; CIRCLE
|
||||
MaxO := sreg ; (overwritten by TEMP3+TEMP4, but restored from OG/OU anyway)
|
||||
XS := regsave ; (2) CIRCLE
|
||||
YS := regsave+2 ; (2) CIRCLE
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
@ -99,10 +86,10 @@ yres: .word 192 ; Y resolution
|
||||
.byte 2 ; Number of screens available
|
||||
.byte 8 ; System font X size
|
||||
.byte 8 ; System font Y size
|
||||
.res 4, $00 ; Reserved for future extensions
|
||||
.word $100 ; Aspect ratio
|
||||
|
||||
; Next comes the jump table. Currently all entries must be valid and may point
|
||||
; to an RTS for test versions (function not implemented).
|
||||
; Next comes the jump table. With the exception of IRQ, all entries must be
|
||||
; valid and may point to an RTS for test versions (function not implemented).
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
@ -121,7 +108,6 @@ yres: .word 192 ; Y resolution
|
||||
.addr GETPIXEL
|
||||
.addr LINE
|
||||
.addr BAR
|
||||
.addr CIRCLE
|
||||
.addr TEXTSTYLE
|
||||
.addr OUTTEXT
|
||||
.addr 0 ; IRQ entry is unused
|
||||
@ -138,12 +124,6 @@ ERROR: .res 1 ; Error code
|
||||
Set80: .res 1 ; Set 80 column store
|
||||
.endif
|
||||
|
||||
; Circle stuff
|
||||
|
||||
OGora: .res 2
|
||||
OUkos: .res 2
|
||||
Y3: .res 2
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.rodata
|
||||
@ -389,31 +369,6 @@ SETPIXEL:
|
||||
bit $C080 ; Switch in LC bank 2 for R/O
|
||||
rts
|
||||
|
||||
SETPIXELCLIP:
|
||||
lda Y1+1
|
||||
bmi :+ ; y < 0
|
||||
lda X1+1
|
||||
bmi :+ ; x < 0
|
||||
lda X1
|
||||
ldx X1+1
|
||||
sta ADDR
|
||||
stx ADDR+1
|
||||
ldx #ADDR
|
||||
lda xres
|
||||
ldy xres+1
|
||||
jsr icmp ; ( x < xres ) ...
|
||||
bcs :+
|
||||
lda Y1
|
||||
ldx Y1+1
|
||||
sta ADDR
|
||||
stx ADDR+1
|
||||
ldx #ADDR
|
||||
lda yres
|
||||
ldy yres+1
|
||||
jsr icmp ; ... && ( y < yres )
|
||||
bcc SETPIXEL
|
||||
: rts
|
||||
|
||||
; GETPIXEL: Read the color value of a pixel and return it in A/X. The
|
||||
; coordinates passed to this function are never outside the visible screen
|
||||
; area, so there is no need for clipping inside this function.
|
||||
@ -476,203 +431,6 @@ BAR:
|
||||
bne :-
|
||||
rts
|
||||
|
||||
; CIRCLE: Draw a circle around the center X1/Y1 (= ptr1/ptr2) with the
|
||||
; radius in tmp1 and the current drawing color.
|
||||
; Must set an error code: NO
|
||||
CIRCLE:
|
||||
lda RADIUS
|
||||
bne :+
|
||||
jmp SETPIXELCLIP ; Plot as a point
|
||||
: sta XX
|
||||
|
||||
; x = r
|
||||
lda #$00
|
||||
sta XX+1
|
||||
sta YY
|
||||
sta YY+1
|
||||
sta MaxO
|
||||
sta MaxO+1
|
||||
|
||||
; y = 0, mo = 0
|
||||
lda X1
|
||||
ldx X1+1
|
||||
sta XS
|
||||
stx XS+1
|
||||
lda Y1
|
||||
ldx Y1+1
|
||||
sta YS
|
||||
stx YS+1 ; XS/YS to remember the center
|
||||
|
||||
; while (y < x) {
|
||||
while: ldx #YY
|
||||
lda XX
|
||||
ldy XX+1
|
||||
jsr icmp
|
||||
bcc :+
|
||||
rts
|
||||
|
||||
; Plot points in 8 slices...
|
||||
: lda XS
|
||||
add XX
|
||||
sta X1
|
||||
lda XS+1
|
||||
adc XX+1
|
||||
sta X1+1 ; x1 = xs + x
|
||||
lda YS
|
||||
add YY
|
||||
sta Y1
|
||||
pha
|
||||
lda YS+1
|
||||
adc YY+1
|
||||
sta Y1+1 ; (stack) = ys + y, y1 = (stack)
|
||||
pha
|
||||
jsr SETPIXELCLIP ; plot (xs + x, ys + y)
|
||||
lda YS
|
||||
sub YY
|
||||
sta Y1
|
||||
sta Y3
|
||||
lda YS+1
|
||||
sbc YY+1
|
||||
sta Y1+1 ; y3 = y1 = ys - y
|
||||
sta Y3+1
|
||||
jsr SETPIXELCLIP ; plot (xs + x, ys - y)
|
||||
pla
|
||||
sta Y1+1
|
||||
pla
|
||||
sta Y1 ; y1 = ys + y
|
||||
lda XS
|
||||
sub XX
|
||||
sta X1
|
||||
lda XS+1
|
||||
sbc XX+1
|
||||
sta X1+1
|
||||
jsr SETPIXELCLIP ; plot (xs - x, ys + y)
|
||||
lda Y3
|
||||
sta Y1
|
||||
lda Y3+1
|
||||
sta Y1+1
|
||||
jsr SETPIXELCLIP ; plot (xs - x, ys - y)
|
||||
|
||||
lda XS
|
||||
add YY
|
||||
sta X1
|
||||
lda XS+1
|
||||
adc YY+1
|
||||
sta X1+1 ; x1 = xs + y
|
||||
lda YS
|
||||
add XX
|
||||
sta Y1
|
||||
pha
|
||||
lda YS+1
|
||||
adc XX+1
|
||||
sta Y1+1 ; (stack) = ys + x, y1 = (stack)
|
||||
pha
|
||||
jsr SETPIXELCLIP ; plot (xs + y, ys + x)
|
||||
lda YS
|
||||
sub XX
|
||||
sta Y1
|
||||
sta Y3
|
||||
lda YS+1
|
||||
sbc XX+1
|
||||
sta Y1+1 ; y3 = y1 = ys - x
|
||||
sta Y3+1
|
||||
jsr SETPIXELCLIP ; plot (xs + y, ys - x)
|
||||
pla
|
||||
sta Y1+1
|
||||
pla
|
||||
sta Y1 ; y1 = ys + x(stack)
|
||||
lda XS
|
||||
sub YY
|
||||
sta X1
|
||||
lda XS+1
|
||||
sbc YY+1
|
||||
sta X1+1
|
||||
jsr SETPIXELCLIP ; plot (xs - y, ys + x)
|
||||
lda Y3
|
||||
sta Y1
|
||||
lda Y3+1
|
||||
sta Y1+1
|
||||
jsr SETPIXELCLIP ; plot (xs - y, ys - x)
|
||||
|
||||
; og = mo + y + y + 1
|
||||
lda MaxO
|
||||
ldx MaxO+1
|
||||
add YY
|
||||
tay
|
||||
txa
|
||||
adc YY+1
|
||||
tax
|
||||
tya
|
||||
add YY
|
||||
tay
|
||||
txa
|
||||
adc YY+1
|
||||
tax
|
||||
tya
|
||||
add #$01
|
||||
bcc :+
|
||||
inx
|
||||
: sta OGora
|
||||
stx OGora+1
|
||||
|
||||
; ou = og - x - x + 1
|
||||
sub XX
|
||||
tay
|
||||
txa
|
||||
sbc XX+1
|
||||
tax
|
||||
tya
|
||||
sub XX
|
||||
tay
|
||||
txa
|
||||
sbc XX+1
|
||||
tax
|
||||
tya
|
||||
add #$01
|
||||
bcc :+
|
||||
inx
|
||||
: sta OUkos
|
||||
stx OUkos+1
|
||||
|
||||
; ++y
|
||||
inc YY
|
||||
bne :+
|
||||
inc YY+1
|
||||
|
||||
; if (abs (ou) < abs (og)) {
|
||||
: lda OUkos
|
||||
ldy OUkos+1
|
||||
jsr abs
|
||||
sta TEMP3
|
||||
sty TEMP4
|
||||
lda OGora
|
||||
ldy OGora+1
|
||||
jsr abs
|
||||
ldx #TEMP3
|
||||
jsr icmp
|
||||
bpl :++
|
||||
|
||||
; --x
|
||||
lda XX
|
||||
sub #$01
|
||||
sta XX
|
||||
bcs :+
|
||||
dec XX+1
|
||||
|
||||
; mo = ou }
|
||||
: lda OUkos
|
||||
ldx OUkos+1
|
||||
jmp :++
|
||||
|
||||
; else mo = og
|
||||
: lda OGora
|
||||
ldx OGora+1
|
||||
: sta MaxO
|
||||
stx MaxO+1
|
||||
|
||||
; }
|
||||
jmp while
|
||||
|
||||
; TEXTSTYLE: Set the style used when calling OUTTEXT. Text scaling in X and Y
|
||||
; direction is passend in X/Y, the text direction is passed in A.
|
||||
; Must set an error code: NO
|
||||
@ -730,44 +488,3 @@ OUTTEXT:
|
||||
bne :-
|
||||
: bit $C080 ; Switch in LC bank 2 for R/O
|
||||
rts
|
||||
|
||||
; Copies of some runtime routines
|
||||
|
||||
abs:
|
||||
; A/Y := abs (A/Y)
|
||||
cpy #$00
|
||||
bpl :+
|
||||
clc
|
||||
eor #$FF
|
||||
adc #$01
|
||||
pha
|
||||
tya
|
||||
eor #$FF
|
||||
adc #$00
|
||||
tay
|
||||
pla
|
||||
: rts
|
||||
|
||||
icmp:
|
||||
; Compare A/Y to zp,X
|
||||
sta TEMP ; TEMP/TEMP2 - arg2
|
||||
sty TEMP2
|
||||
lda $00,x
|
||||
pha
|
||||
lda $01,x
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
tya ; X/A - arg1 (a = high)
|
||||
|
||||
sub TEMP2
|
||||
bne :++
|
||||
cpx TEMP
|
||||
beq :+
|
||||
adc #$FF
|
||||
ora #$01
|
||||
: rts
|
||||
: bvc :+
|
||||
eor #$FF
|
||||
ora #$01
|
||||
: rts
|
||||
|
Loading…
x
Reference in New Issue
Block a user