Oliver Schmidt updated the graphics drivers and part of the C library for the
Apple machines. git-svn-id: svn://svn.cc65.org/cc65/trunk@3816 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -48,12 +48,11 @@ apple2lib:
|
||||
done
|
||||
mv apple2/crt0.o apple2.o
|
||||
cp apple2/apple2-auxmem.emd a2.auxmem.emd
|
||||
cp apple2/apple2-lc.emd a2.lc.emd
|
||||
cp apple2/apple2-stdjoy.joy a2.stdjoy.joy
|
||||
cp apple2/apple2-stdmou.mou a2.stdmou.mou
|
||||
cp apple2/apple2-ssc.ser a2.ssc.ser
|
||||
cp apple2/apple2-40-40-16.tgi a2.lo.tgi
|
||||
cp apple2/apple2-280-192-6.tgi a2.hi.tgi
|
||||
cp apple2/apple2-280-192-8.tgi a2.hi.tgi
|
||||
cp apple2/apple2-40-48-16.tgi a2.lo.tgi
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Apple //e
|
||||
@@ -65,12 +64,11 @@ apple2enhlib:
|
||||
done
|
||||
mv apple2enh/crt0.o apple2enh.o
|
||||
cp apple2enh/apple2-auxmem.emd a2e.auxmem.emd
|
||||
cp apple2enh/apple2-lc.emd a2e.lc.emd
|
||||
cp apple2enh/apple2-stdjoy.joy a2e.stdjoy.joy
|
||||
cp apple2enh/apple2-stdmou.mou a2e.stdmou.mou
|
||||
cp apple2enh/apple2-ssc.ser a2e.ssc.ser
|
||||
cp apple2enh/apple2-40-40-16.tgi a2e.lo.tgi
|
||||
cp apple2enh/apple2-280-192-6.tgi a2e.hi.tgi
|
||||
cp apple2enh/apple2-280-192-8.tgi a2e.hi.tgi
|
||||
cp apple2enh/apple2-40-48-16.tgi a2e.lo.tgi
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Atari
|
||||
|
||||
@@ -57,6 +57,7 @@ S_OBJS= _scrsize.o \
|
||||
close.o \
|
||||
clrscr.o \
|
||||
color.o \
|
||||
cout.o \
|
||||
cputc.o \
|
||||
crt0.o \
|
||||
ctype.o \
|
||||
@@ -75,6 +76,7 @@ S_OBJS= _scrsize.o \
|
||||
get_ostype.o \
|
||||
gotoxy.o \
|
||||
gotoy.o \
|
||||
home.o \
|
||||
initcwd.o \
|
||||
joy_stddrv.o \
|
||||
kbhit.o \
|
||||
@@ -85,14 +87,9 @@ S_OBJS= _scrsize.o \
|
||||
oserrlist.o \
|
||||
oserror.o \
|
||||
randomize.o \
|
||||
rcout.o \
|
||||
rdkey.o \
|
||||
read.o \
|
||||
revers.o \
|
||||
rhome.o \
|
||||
rom.o \
|
||||
rpread.o \
|
||||
rrdkey.o \
|
||||
rvtabz.o \
|
||||
rwcommon.o \
|
||||
syschdir.o \
|
||||
sysmkdir.o \
|
||||
@@ -102,6 +99,7 @@ S_OBJS= _scrsize.o \
|
||||
systime.o \
|
||||
sysuname.o \
|
||||
tgi_mode_table.o\
|
||||
vtabz.o \
|
||||
wherex.o \
|
||||
wherey.o \
|
||||
write.o
|
||||
@@ -109,7 +107,7 @@ S_OBJS= _scrsize.o \
|
||||
#--------------------------------------------------------------------------
|
||||
# Drivers
|
||||
|
||||
EMDS = apple2-auxmem.emd apple2-lc.emd
|
||||
EMDS = apple2-auxmem.emd
|
||||
|
||||
JOYS = apple2-stdjoy.joy
|
||||
|
||||
@@ -117,7 +115,7 @@ MOUS = apple2-stdmou.mou
|
||||
|
||||
SERS = apple2-ssc.ser
|
||||
|
||||
TGIS = apple2-40-40-16.tgi apple2-280-192-6.tgi
|
||||
TGIS = apple2-280-192-8.tgi apple2-40-48-16.tgi
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Targets
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
;
|
||||
; Graphics driver for the 280x192x6 mode on the Apple II
|
||||
; Graphics driver for the 280x192x8 mode on the Apple II
|
||||
;
|
||||
; Stefan Haubenthal <polluks@sdf.lonestar.org>
|
||||
; Oliver Schmidt <ol.sc@web.de>
|
||||
; Based on Maciej Witkowiak's circle routine
|
||||
;
|
||||
|
||||
@@ -15,11 +16,23 @@
|
||||
.macpack generic
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; ROM entry points
|
||||
|
||||
; Zero page stuff
|
||||
|
||||
HBASL := $26
|
||||
HMASK := $30
|
||||
PAGE := $E6
|
||||
SCALE := $E7
|
||||
ROT := $F9
|
||||
|
||||
; Graphics entry points, by cbmnut (applenut??) cbmnut@hushmail.com
|
||||
|
||||
TEXT := $F399 ; Return to text screen
|
||||
HGR2 := $F3D8 ; Initialize and clear hi-res page 2.
|
||||
HGR := $F3E2 ; Initialize and clear hi-res page 1.
|
||||
HCLR := $F3F2 ; Clear the current hi-res screen to black.
|
||||
BKGND := $F3F6 ; Clear the current hi-res screen to the
|
||||
; last plotted color (from ($1C).
|
||||
HPOSN := $F411 ; Positions the hi-res cursor without
|
||||
; plotting a point.
|
||||
; Enter with (A) = Y-coordinate, and
|
||||
@@ -33,30 +46,60 @@ HLIN := $F53A ; Draws a line from the last plotted
|
||||
; point or line destination to:
|
||||
; (X,A) = X-coordinate, and
|
||||
; (Y) = Y-coordinate.
|
||||
HFIND := $F5CB ; Converts the hi-res coursor's position
|
||||
; back to X- and Y-coordinates; stores
|
||||
; X-coordinate at $E0,E1 and Y-coordinate
|
||||
; at $E2.
|
||||
DRAW := $F601 ; Draws a shape. Enter with (Y,X) = the
|
||||
; address of the shape table, and (A) =
|
||||
; the rotation factor. Uses the current
|
||||
; color.
|
||||
XDRAW := $F65D ; Draws a shape by inverting the existing
|
||||
; color of the dots the shape draws over.
|
||||
; Same entry parameters as DRAW.
|
||||
SETHCOL := $F6EC ; Set the hi-res color to (X), where (X)
|
||||
; must be between 0 and 7.
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table and constants.
|
||||
|
||||
.segment "JUMPTABLE"
|
||||
; Variables mapped to the zero page segment variables. Some of these are
|
||||
; used for passing parameters to the driver.
|
||||
|
||||
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
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.segment "JUMPTABLE"
|
||||
|
||||
; Header. Includes jump table and constants.
|
||||
|
||||
; First part of the header is a structure that has a magic and defines the
|
||||
; capabilities of the driver
|
||||
|
||||
.byte $74, $67, $69 ; "tgi"
|
||||
.byte TGI_API_VERSION ; TGI API version number
|
||||
xres: .word 280 ; X resolution
|
||||
yres: .word 192 ; Y resolution
|
||||
.byte 8 ; Number of drawing colors
|
||||
.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
|
||||
.byte $74, $67, $69 ; "tgi"
|
||||
.byte TGI_API_VERSION ; TGI API version number
|
||||
xres: .word 280 ; X resolution
|
||||
yres: .word 192 ; Y resolution
|
||||
.byte 8 ; Number of drawing colors
|
||||
.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
|
||||
|
||||
; Next comes the jump table. Currently all entries must be valid and may point
|
||||
; to an RTS for test versions (function not implemented).
|
||||
@@ -81,55 +124,33 @@ yres: .word 192 ; Y resolution
|
||||
.addr CIRCLE
|
||||
.addr TEXTSTYLE
|
||||
.addr OUTTEXT
|
||||
.addr 0 ; IRQ entry is unused
|
||||
.addr 0 ; IRQ entry is unused
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Data.
|
||||
|
||||
; Variables mapped to the zero page segment variables. Some of these are
|
||||
; used for passing parameters to the driver.
|
||||
|
||||
X1 = ptr1
|
||||
Y1 = ptr2
|
||||
X2 = ptr3
|
||||
Y2 = ptr4
|
||||
RADIUS = tmp1
|
||||
|
||||
ADDR = tmp1
|
||||
TEMP = tmp3
|
||||
TEMP2 = tmp4
|
||||
TEMP3 = sreg
|
||||
TEMP4 = sreg+1
|
||||
|
||||
; Circle stuff
|
||||
XX = ptr3 ; (2) CIRCLE
|
||||
YY = ptr4 ; (2) CIRCLE
|
||||
MaxO = sreg ; (overwritten by TEMP3+TEMP4, but restored from OG/OU anyway)
|
||||
XS = regsave ; (2) CIRCLE
|
||||
YS = regsave+2 ; (2) CIRCLE
|
||||
.bss
|
||||
|
||||
; Absolute variables used in the code
|
||||
|
||||
.bss
|
||||
ERROR: .res 1 ; Error code
|
||||
|
||||
ERROR: .res 1 ; Error code
|
||||
.ifdef __APPLE2ENH__
|
||||
Set80: .res 1 ; Set 80 column store
|
||||
.endif
|
||||
|
||||
; Line routine stuff (combined with CIRCLE to save space)
|
||||
; Circle stuff
|
||||
|
||||
OGora: .res 2
|
||||
OUkos: .res 2
|
||||
Y3: .res 2
|
||||
OGora: .res 2
|
||||
OUkos: .res 2
|
||||
Y3: .res 2
|
||||
|
||||
; Text output stuff
|
||||
TEXTMAGX = $E7
|
||||
TEXTMAGY = $E7
|
||||
TEXTDIR = $F9
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.rodata
|
||||
|
||||
; Constants and tables
|
||||
|
||||
.rodata
|
||||
|
||||
DEFPALETTE: .byte $00, $05, $04, $01, $00, $08, $06, $01; 6 unique colors
|
||||
DEFPALETTE: .byte $00, $01, $02, $03, $04, $05, $06, $07
|
||||
|
||||
SHAPE: .byte $64,$01,$D0,$00,$D5,$00,$DA,$00,$E0,$00,$EF,$00,$FE,$00,$0C,$01
|
||||
.byte $19,$01,$1D,$01,$25,$01,$2D,$01,$3D,$01,$46,$01,$4B,$01,$52,$01
|
||||
@@ -215,33 +236,11 @@ SHAPE: .byte $64,$01,$D0,$00,$D5,$00,$DA,$00,$E0,$00,$EF,$00,$FE,$00,$0C,$01
|
||||
.byte $2D,$2D,$35,$3F,$3F,$37,$2D,$2D,$75,$00,$40,$C0,$40,$18,$00,$40
|
||||
.byte $C0,$40,$43,$00,$40,$C0,$40,$08,$00,$19,$00,$00
|
||||
|
||||
.code
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; INSTALL routine. Is called after the driver is loaded into memory. May
|
||||
; initialize anything that has to be done just once. Is probably empty
|
||||
; most of the time.
|
||||
;
|
||||
; Must set an error code: NO
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
.code
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory. May
|
||||
; clean up anything done by INSTALL but is probably empty most of the time.
|
||||
;
|
||||
; Must set an error code: NO
|
||||
;
|
||||
|
||||
UNINSTALL:
|
||||
rts
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; INIT: Changes an already installed device from text mode to graphics
|
||||
; mode.
|
||||
; INIT: Changes an already installed device from text mode to graphics mode.
|
||||
; Note that INIT/DONE may be called multiple times while the driver
|
||||
; is loaded, while INSTALL is only called once, so any code that is needed
|
||||
; to initializes variables and so on must go here. Setting palette and
|
||||
@@ -249,153 +248,152 @@ UNINSTALL:
|
||||
; kernel later.
|
||||
; The graphics kernel will never call INIT when a graphics mode is already
|
||||
; active, so there is no need to protect against that.
|
||||
;
|
||||
; Must set an error code: YES
|
||||
;
|
||||
|
||||
INIT:
|
||||
.ifdef __APPLE2ENH__
|
||||
; Save and clear 80 column store
|
||||
lda RD80COL
|
||||
sta Set80
|
||||
sta CLR80COL
|
||||
.endif
|
||||
|
||||
; Switch into graphics mode
|
||||
|
||||
jsr HGR
|
||||
; Switch into graphics mode
|
||||
bit HIRES
|
||||
bit MIXCLR
|
||||
bit TXTCLR
|
||||
|
||||
; Done, reset the error code
|
||||
|
||||
; Done, reset the error code
|
||||
lda #TGI_ERR_OK
|
||||
sta ERROR
|
||||
|
||||
; Fall through
|
||||
|
||||
; INSTALL routine. Is called after the driver is loaded into memory. May
|
||||
; initialize anything that has to be done just once. Is probably empty
|
||||
; most of the time.
|
||||
; Must set an error code: NO
|
||||
INSTALL:
|
||||
; Fall through
|
||||
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory. May
|
||||
; clean up anything done by INSTALL but is probably empty most of the time.
|
||||
; Must set an error code: NO
|
||||
UNINSTALL:
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; DONE: Will be called to switch the graphics device back into text mode.
|
||||
; The graphics kernel will never call DONE when no graphics mode is active,
|
||||
; so there is no need to protect against that.
|
||||
;
|
||||
; Must set an error code: NO
|
||||
;
|
||||
DONE:
|
||||
; Switch into text mode
|
||||
bit TXTSET
|
||||
bit LOWSCR
|
||||
|
||||
DONE = TEXT
|
||||
.ifdef __APPLE2ENH__
|
||||
; Restore 80 column store
|
||||
lda Set80
|
||||
bpl :+
|
||||
sta SET80COL
|
||||
: bit LORES ; Limit SET80COL-HISCR to text
|
||||
.endif
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; GETERROR: Return the error code in A and clear it.
|
||||
|
||||
GETERROR:
|
||||
ldx #TGI_ERR_OK
|
||||
lda ERROR
|
||||
ldx #TGI_ERR_OK
|
||||
stx ERROR
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; CONTROL: Platform/driver specific entry point.
|
||||
;
|
||||
; Must set an error code: YES
|
||||
;
|
||||
|
||||
CONTROL:
|
||||
lda #TGI_ERR_INV_FUNC
|
||||
sta ERROR
|
||||
; CLEAR: Clears the screen.
|
||||
; Must set an error code: NO
|
||||
CLEAR:
|
||||
bit $C082 ; Switch in ROM
|
||||
jsr HCLR
|
||||
bit $C080 ; Switch in LC bank 2 for R/O
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; CLEAR: Clears the screen.
|
||||
;
|
||||
; Must set an error code: NO
|
||||
;
|
||||
|
||||
CLEAR = HCLR
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETVIEWPAGE: Set the visible page. Called with the new page in A (0..n).
|
||||
; The page number is already checked to be valid by the graphics kernel.
|
||||
;
|
||||
; Must set an error code: NO (will only be called if page ok)
|
||||
;
|
||||
|
||||
SETVIEWPAGE:
|
||||
tax
|
||||
beq @L1
|
||||
bit HISCR
|
||||
rts
|
||||
@L1: bit LOWSCR
|
||||
.assert LOWSCR + 1 = HISCR, error
|
||||
lda LOWSCR,x ; No BIT absolute,X available
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETDRAWPAGE: Set the drawable page. Called with the new page in A (0..n).
|
||||
; The page number is already checked to be valid by the graphics kernel.
|
||||
;
|
||||
; Must set an error code: NO (will only be called if page ok)
|
||||
;
|
||||
|
||||
SETDRAWPAGE:
|
||||
tax
|
||||
beq @L1
|
||||
lda #>$4000 ; Page 2
|
||||
.byte $2C
|
||||
@L1: lda #>$2000 ; Page 1
|
||||
sta $E6
|
||||
beq :+
|
||||
lda #>$4000 ; Page 2
|
||||
.byte $2C ; BIT absolute
|
||||
: lda #>$2000 ; Page 1
|
||||
sta PAGE
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETCOLOR: Set the drawing color (in A). The new color is already checked
|
||||
; to be in a valid range (0..maxcolor-1).
|
||||
;
|
||||
; Must set an error code: NO (will only be called if color ok)
|
||||
;
|
||||
|
||||
SETCOLOR:
|
||||
bit $C082 ; Switch in ROM
|
||||
tax
|
||||
jmp SETHCOL
|
||||
jsr SETHCOL
|
||||
bit $C080 ; Switch in LC bank 2 for R/O
|
||||
rts
|
||||
|
||||
; CONTROL: Platform/driver specific entry point.
|
||||
; Must set an error code: YES
|
||||
CONTROL:
|
||||
; Fall through
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETPALETTE: Set the palette (not available with all drivers/hardware).
|
||||
; A pointer to the palette is passed in ptr1. Must set an error if palettes
|
||||
; are not supported
|
||||
;
|
||||
; Must set an error code: YES
|
||||
;
|
||||
|
||||
SETPALETTE:
|
||||
lda #TGI_ERR_INV_FUNC
|
||||
sta ERROR
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; GETPALETTE: Return the current palette in A/X. Even drivers that cannot
|
||||
; set the palette should return the default palette here, so there's no
|
||||
; way for this function to fail.
|
||||
;
|
||||
; Must set an error code: NO
|
||||
;
|
||||
|
||||
GETPALETTE:
|
||||
; Fall through
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; GETDEFPALETTE: Return the default palette for the driver in A/X. All
|
||||
; drivers should return something reasonable here, even drivers that don't
|
||||
; support palettes, otherwise the caller has no way to determine the colors
|
||||
; of the (not changeable) palette.
|
||||
;
|
||||
; Must set an error code: NO (all drivers must have a default palette)
|
||||
;
|
||||
|
||||
GETDEFPALETTE:
|
||||
lda #<DEFPALETTE
|
||||
ldx #>DEFPALETTE
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; SETPIXEL: Draw one pixel at X1/Y1 = ptr1/ptr2 with the current drawing
|
||||
; color. The coordinates passed to this function are never outside the
|
||||
; visible screen area, so there is no need for clipping inside this function.
|
||||
;
|
||||
; Must set an error code: NO
|
||||
;
|
||||
SETPIXEL:
|
||||
bit $C082 ; Switch in ROM
|
||||
ldx X1
|
||||
ldy X1+1
|
||||
lda Y1
|
||||
jsr HPLOT
|
||||
bit $C080 ; Switch in LC bank 2 for R/O
|
||||
rts
|
||||
|
||||
SETPIXELCLIP:
|
||||
lda Y1+1
|
||||
bmi @finito ; y<0
|
||||
bmi :+ ; y < 0
|
||||
lda X1+1
|
||||
bmi @finito ; x<0
|
||||
bmi :+ ; x < 0
|
||||
lda X1
|
||||
ldx X1+1
|
||||
sta ADDR
|
||||
@@ -404,7 +402,7 @@ SETPIXELCLIP:
|
||||
lda xres
|
||||
ldy xres+1
|
||||
jsr icmp ; ( x < xres ) ...
|
||||
bcs @finito
|
||||
bcs :+
|
||||
lda Y1
|
||||
ldx Y1+1
|
||||
sta ADDR
|
||||
@@ -414,64 +412,33 @@ SETPIXELCLIP:
|
||||
ldy yres+1
|
||||
jsr icmp ; ... && ( y < yres )
|
||||
bcc SETPIXEL
|
||||
@finito:rts
|
||||
: rts
|
||||
|
||||
SETPIXEL:
|
||||
ldx X1
|
||||
ldy X1+1
|
||||
lda Y1
|
||||
jmp HPLOT
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; 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.
|
||||
|
||||
|
||||
GETPIXEL:
|
||||
bit $C082 ; Switch in ROM
|
||||
ldx X1
|
||||
ldy X1+1
|
||||
lda Y1
|
||||
jsr HPOSN ; 1st pixel
|
||||
HBASL = $26
|
||||
HMASK = $30
|
||||
ldx #$00
|
||||
jsr HPOSN
|
||||
lda (HBASL),y
|
||||
and HMASK
|
||||
beq @L1
|
||||
inx
|
||||
@L1: stx tmp1
|
||||
|
||||
lda $E0 ; which neighbour
|
||||
tax
|
||||
and #$01
|
||||
bne @odd
|
||||
asl tmp1
|
||||
inx
|
||||
.byte $24
|
||||
@odd: dex
|
||||
|
||||
ldy $E1
|
||||
lda $E2
|
||||
jsr HPOSN ; 2nd pixel
|
||||
ldx #$00
|
||||
lda (HBASL),y
|
||||
and HMASK
|
||||
beq @L2
|
||||
inx
|
||||
@L2: txa
|
||||
ora tmp1
|
||||
ldx #$00
|
||||
asl
|
||||
beq :+ ; 0 (black)
|
||||
lda #$03 ; 3 (white)
|
||||
: bcc :+
|
||||
adc #$03 ; += 4 (black -> black2, white -> white2)
|
||||
: ldx #$00
|
||||
bit $C080 ; Switch in LC bank 2 for R/O
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; LINE: Draw a line from X1/Y1 to X2/Y2, where X1/Y1 = ptr1/ptr2 and
|
||||
; X2/Y2 = ptr3/ptr4 using the current drawing color.
|
||||
;
|
||||
; Must set an error code: NO
|
||||
;
|
||||
|
||||
LINE:
|
||||
bit $C082 ; Switch in ROM
|
||||
ldx X1
|
||||
ldy X1+1
|
||||
lda Y1
|
||||
@@ -479,9 +446,10 @@ LINE:
|
||||
lda X2
|
||||
ldx X2+1
|
||||
ldy Y2
|
||||
jmp HLIN
|
||||
jsr HLIN
|
||||
bit $C080 ; Switch in LC bank 2 for R/O
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; BAR: Draw a filled rectangle with the corners X1/Y1, X2/Y2, where
|
||||
; X1/Y1 = ptr1/ptr2 and X2/Y2 = ptr3/ptr4 using the current drawing color.
|
||||
; Contrary to most other functions, the graphics kernel will sort and clip
|
||||
@@ -493,13 +461,10 @@ LINE:
|
||||
; (X2 >= 0) && (X2 < XRES)
|
||||
; (Y1 >= 0) && (Y1 < YRES)
|
||||
; (Y2 >= 0) && (Y2 < YRES)
|
||||
;
|
||||
; Must set an error code: NO
|
||||
;
|
||||
|
||||
BAR:
|
||||
inc Y2
|
||||
@L1: lda Y2
|
||||
: lda Y2
|
||||
pha
|
||||
lda Y1
|
||||
sta Y2
|
||||
@@ -508,30 +473,27 @@ BAR:
|
||||
sta Y2
|
||||
inc Y1
|
||||
cmp Y1
|
||||
bne @L1
|
||||
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 @L1
|
||||
bne :+
|
||||
jmp SETPIXELCLIP ; Plot as a point
|
||||
: sta XX
|
||||
|
||||
@L1: sta XX
|
||||
; x = r;
|
||||
; x = r
|
||||
lda #$00
|
||||
sta XX+1
|
||||
sta YY
|
||||
sta YY+1
|
||||
sta MaxO
|
||||
sta MaxO+1
|
||||
; y =0; mo=0;
|
||||
|
||||
; y = 0, mo = 0
|
||||
lda X1
|
||||
ldx X1+1
|
||||
sta XS
|
||||
@@ -541,97 +503,98 @@ CIRCLE:
|
||||
sta YS
|
||||
stx YS+1 ; XS/YS to remember the center
|
||||
|
||||
; while (y<x) {
|
||||
@L013B: ldx #YY
|
||||
; while (y < x) {
|
||||
while: ldx #YY
|
||||
lda XX
|
||||
ldy XX+1
|
||||
jsr icmp
|
||||
bcc @L12
|
||||
bcc :+
|
||||
rts
|
||||
@L12: ; plot points in 8 slices...
|
||||
lda XS
|
||||
|
||||
; Plot points in 8 slices...
|
||||
: lda XS
|
||||
add XX
|
||||
sta X1
|
||||
lda XS+1
|
||||
adc XX+1
|
||||
sta X1+1 ; x1 = xs+x
|
||||
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)
|
||||
sta Y1+1 ; (stack) = ys + y, y1 = (stack)
|
||||
pha
|
||||
jsr SETPIXELCLIP ; plot(xs+x,ys+y)
|
||||
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 Y1+1 ; y3 = y1 = ys - y
|
||||
sta Y3+1
|
||||
jsr SETPIXELCLIP ; plot(xs+x,ys-y)
|
||||
jsr SETPIXELCLIP ; plot (xs + x, ys - y)
|
||||
pla
|
||||
sta Y1+1
|
||||
pla
|
||||
sta Y1 ; y1 = ys+y
|
||||
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)
|
||||
jsr SETPIXELCLIP ; plot (xs - x, ys + y)
|
||||
lda Y3
|
||||
sta Y1
|
||||
lda Y3+1
|
||||
sta Y1+1
|
||||
jsr SETPIXELCLIP ; plot (xs-x,ys-y)
|
||||
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
|
||||
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)
|
||||
sta Y1+1 ; (stack) = ys + x, y1 = (stack)
|
||||
pha
|
||||
jsr SETPIXELCLIP ; plot(xs+y,ys+x)
|
||||
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 Y1+1 ; y3 = y1 = ys - x
|
||||
sta Y3+1
|
||||
jsr SETPIXELCLIP ; plot(xs+y,ys-x)
|
||||
jsr SETPIXELCLIP ; plot (xs + y, ys - x)
|
||||
pla
|
||||
sta Y1+1
|
||||
pla
|
||||
sta Y1 ; y1 = ys+x(stack)
|
||||
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)
|
||||
jsr SETPIXELCLIP ; plot (xs - y, ys + x)
|
||||
lda Y3
|
||||
sta Y1
|
||||
lda Y3+1
|
||||
sta Y1+1
|
||||
jsr SETPIXELCLIP ; plot (xs-y,ys-x)
|
||||
jsr SETPIXELCLIP ; plot (xs - y, ys - x)
|
||||
|
||||
; og = mo+y+y+1
|
||||
; og = mo + y + y + 1
|
||||
lda MaxO
|
||||
ldx MaxO+1
|
||||
add YY
|
||||
@@ -647,11 +610,12 @@ CIRCLE:
|
||||
tax
|
||||
tya
|
||||
add #$01
|
||||
bcc @L0143
|
||||
bcc :+
|
||||
inx
|
||||
@L0143: sta OGora
|
||||
: sta OGora
|
||||
stx OGora+1
|
||||
; ou = og-x-x+1
|
||||
|
||||
; ou = og - x - x + 1
|
||||
sub XX
|
||||
tay
|
||||
txa
|
||||
@@ -665,16 +629,18 @@ CIRCLE:
|
||||
tax
|
||||
tya
|
||||
add #$01
|
||||
bcc @L0146
|
||||
bcc :+
|
||||
inx
|
||||
@L0146: sta OUkos
|
||||
: sta OUkos
|
||||
stx OUkos+1
|
||||
; ++y
|
||||
|
||||
; ++y
|
||||
inc YY
|
||||
bne @L0148
|
||||
bne :+
|
||||
inc YY+1
|
||||
@L0148: ; if (abs(ou)<abs(og))
|
||||
lda OUkos
|
||||
|
||||
; if (abs (ou) < abs (og)) {
|
||||
: lda OUkos
|
||||
ldy OUkos+1
|
||||
jsr abs
|
||||
sta TEMP3
|
||||
@@ -684,52 +650,47 @@ CIRCLE:
|
||||
jsr abs
|
||||
ldx #TEMP3
|
||||
jsr icmp
|
||||
bpl @L0149
|
||||
; { --x;
|
||||
bpl :++
|
||||
|
||||
; --x
|
||||
lda XX
|
||||
sub #$01
|
||||
sta XX
|
||||
bcs @L014E
|
||||
bcs :+
|
||||
dec XX+1
|
||||
@L014E: ; mo = ou; }
|
||||
lda OUkos
|
||||
ldx OUkos+1
|
||||
jmp @L014G
|
||||
; else { mo = og }
|
||||
@L0149: lda OGora
|
||||
ldx OGora+1
|
||||
@L014G: sta MaxO
|
||||
stx MaxO+1
|
||||
; }
|
||||
jmp @L013B
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; 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
|
||||
;
|
||||
|
||||
TEXTSTYLE:
|
||||
stx TEXTMAGX
|
||||
sty TEXTMAGY
|
||||
asl ; 16 <=> 90þ
|
||||
stx SCALE
|
||||
asl ; 16 <=> 90þ
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
sta TEXTDIR
|
||||
sta ROT
|
||||
rts
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; OUTTEXT: Output text at X/Y = ptr1/ptr2 using the current color and the
|
||||
; current text style. The text to output is given as a zero terminated
|
||||
; string with address in ptr3.
|
||||
;
|
||||
; Must set an error code: NO
|
||||
;
|
||||
|
||||
OUTTEXT:
|
||||
bit $C082 ; Switch in ROM
|
||||
ldx X1
|
||||
ldy X1+1
|
||||
lda Y1
|
||||
@@ -742,10 +703,10 @@ OUTTEXT:
|
||||
sta tmp3+1
|
||||
|
||||
ldy #$00
|
||||
@L1: lda (ptr3),y
|
||||
beq @end
|
||||
sub #$1F ; no controls
|
||||
asl ; offset*2
|
||||
: lda (ptr3),y
|
||||
beq :+
|
||||
sub #$1F ; No controls
|
||||
asl ; Offset * 2
|
||||
tax
|
||||
lda SHAPE,x
|
||||
add #<SHAPE
|
||||
@@ -757,26 +718,25 @@ OUTTEXT:
|
||||
pha
|
||||
ldx tmp1
|
||||
ldy tmp1+1
|
||||
lda TEXTDIR
|
||||
lda ROT
|
||||
jsr DRAW
|
||||
ldx tmp3
|
||||
ldy tmp3+1
|
||||
lda TEXTDIR
|
||||
lda ROT
|
||||
jsr DRAW
|
||||
pla
|
||||
tay
|
||||
iny
|
||||
bne @L1
|
||||
@end: rts
|
||||
bne :-
|
||||
: bit $C080 ; Switch in LC bank 2 for R/O
|
||||
rts
|
||||
|
||||
;-------------
|
||||
; copies of some runtime routines
|
||||
; Copies of some runtime routines
|
||||
|
||||
abs:
|
||||
; a/y := abs(a/y)
|
||||
; A/Y := abs (A/Y)
|
||||
cpy #$00
|
||||
bpl @L1
|
||||
; negay
|
||||
bpl :+
|
||||
clc
|
||||
eor #$FF
|
||||
adc #$01
|
||||
@@ -786,10 +746,10 @@ abs:
|
||||
adc #$00
|
||||
tay
|
||||
pla
|
||||
@L1: rts
|
||||
: rts
|
||||
|
||||
icmp:
|
||||
; compare a/y to zp,x
|
||||
; Compare A/Y to zp,X
|
||||
sta TEMP ; TEMP/TEMP2 - arg2
|
||||
sty TEMP2
|
||||
lda $00,x
|
||||
@@ -798,16 +758,16 @@ icmp:
|
||||
tay
|
||||
pla
|
||||
tax
|
||||
tya ; x/a - arg1 (a=high)
|
||||
tya ; X/A - arg1 (a = high)
|
||||
|
||||
sub TEMP2
|
||||
bne @L4
|
||||
bne :++
|
||||
cpx TEMP
|
||||
beq @L3
|
||||
beq :+
|
||||
adc #$FF
|
||||
ora #$01
|
||||
@L3: rts
|
||||
@L4: bvc @L3
|
||||
: rts
|
||||
: bvc :+
|
||||
eor #$FF
|
||||
ora #$01
|
||||
rts
|
||||
: rts
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,9 @@
|
||||
;
|
||||
; Standard joystick driver for the Apple ][. May be used multiple times when
|
||||
; linked to the statically application.
|
||||
; Standard joystick driver for the Apple ][. May be used multiple times
|
||||
; when statically linked to the application.
|
||||
;
|
||||
; Ullrich von Bassewitz, 2003-05-02
|
||||
; Oliver Schmidt, 2008-02-25
|
||||
; Using the readjoy code from Stefan Haubenthal
|
||||
;
|
||||
|
||||
@@ -14,121 +15,117 @@
|
||||
|
||||
.macpack generic
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
; Constants
|
||||
|
||||
OFFS = 10
|
||||
THRESHOLD = 20 ; Deviation from center triggering movement
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
; ROM entry points
|
||||
|
||||
PREAD := $FB1E ; Read paddle in X, return AD conv. value in Y
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table
|
||||
|
||||
.segment "JUMPTABLE"
|
||||
; Header. Includes jump table.
|
||||
|
||||
.segment "JUMPTABLE"
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
.byte $6A, $6F, $79 ; "joy"
|
||||
.byte JOY_API_VERSION ; Driver API version number
|
||||
|
||||
; Button state masks (8 values)
|
||||
|
||||
.byte $40
|
||||
.byte $80
|
||||
.byte $10
|
||||
.byte $20
|
||||
.byte $04
|
||||
.byte $08
|
||||
.byte $00 ; FIRE2 not available
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
.byte $40
|
||||
.byte $80
|
||||
.byte $00 ; Future expansion
|
||||
.byte $00 ; Future expansion
|
||||
|
||||
; Jump table.
|
||||
; Jump table
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr COUNT
|
||||
.addr READJOY
|
||||
.addr 0 ; IRQ not used
|
||||
.addr 0 ; IRQ not used
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
JOY_COUNT = 2 ; Number of joysticks we support
|
||||
.code
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Data.
|
||||
|
||||
|
||||
.code
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; INSTALL routine. Is called after the driver is loaded into memory. If
|
||||
; possible, check if the hardware is present and determine the amount of
|
||||
; memory available.
|
||||
; Must return an JOY_ERR_xx code in a/x.
|
||||
;
|
||||
|
||||
INSTALL:
|
||||
lda #<JOY_ERR_OK
|
||||
ldx #>JOY_ERR_OK
|
||||
; rts ; Run into UNINSTALL instead
|
||||
; Fall through
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
; Can do cleanup or whatever. Must not return anything.
|
||||
;
|
||||
|
||||
UNINSTALL:
|
||||
rts
|
||||
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; COUNT: Return the total number of available joysticks in a/x.
|
||||
;
|
||||
|
||||
COUNT:
|
||||
lda #<JOY_COUNT
|
||||
ldx #>JOY_COUNT
|
||||
lda #$02 ; Number of joysticks we support
|
||||
ldx #$00
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; READ: Read a particular joystick passed in A.
|
||||
;
|
||||
|
||||
READJOY:
|
||||
and #$01 ; Fix joystick number
|
||||
asl a ;
|
||||
tax ; Joystick number (0,2) into X
|
||||
bit $C082 ; Switch in ROM
|
||||
and #$01 ; Restrict joystick number
|
||||
|
||||
; Read joystick
|
||||
|
||||
lda BUTN0,x ; Check fire button
|
||||
and #$80 ; BTN 0 0 0 0 0 0 0
|
||||
; Read horizontal paddle
|
||||
asl ; Joystick number -> paddle number
|
||||
tax ; Set paddle number (0, 2)
|
||||
jsr PREAD ; Read paddle value
|
||||
lda #$00 ; 0 0 0 0 0 0 0 0
|
||||
cpy #127 - THRESHOLD
|
||||
ror ; !LEFT 0 0 0 0 0 0 0
|
||||
cpy #127 + THRESHOLD
|
||||
ror ; RIGHT !LEFT 0 0 0 0 0 0
|
||||
|
||||
; Read vertical paddle
|
||||
pha
|
||||
jsr PREAD ; Read first paddle value
|
||||
inx ; Set paddle number (1, 3)
|
||||
jsr PREAD ; Read paddle value
|
||||
pla
|
||||
cpy #127-OFFS
|
||||
ror a ; /LEFT BTN 0 0 0 0 0 0
|
||||
cpy #127+OFFS
|
||||
ror a ; RIGHT /LEFT BTN 0 0 0 0 0
|
||||
cpy #127 - THRESHOLD
|
||||
ror ; !UP RIGHT !LEFT 0 0 0 0 0
|
||||
cpy #127 + THRESHOLD
|
||||
ror ; DOWN !UP RIGHT !LEFT 0 0 0 0
|
||||
|
||||
inx
|
||||
pha
|
||||
jsr PREAD ; Read second paddle
|
||||
pla
|
||||
cpy #127-OFFS
|
||||
ror a ; /UP RIGHT /LEFT BTN 0 0 0 0
|
||||
cpy #127+OFFS
|
||||
ror a ; DOWN /UP RIGHT /LEFT BTN 0 0 0
|
||||
eor #%01010000 ; DOWN UP RIGHT LEFT BTN 0 0 0
|
||||
; Read primary button
|
||||
tay
|
||||
lda BUTN0-1,x ; Check button (1, 3)
|
||||
asl
|
||||
tya
|
||||
ror ; FIRE DOWN !UP RIGHT !LEFT 0 0 0
|
||||
|
||||
ldx #$00 ; fix X
|
||||
; Read secondary button
|
||||
tay
|
||||
inx
|
||||
txa
|
||||
and #$03 ; IIgs has fourth button at TAPEIN
|
||||
tax
|
||||
lda BUTN0-1,x ; Check button (2, 0)
|
||||
asl
|
||||
tya
|
||||
ror ; FIRE2 FIRE DOWN !UP RIGHT !LEFT 0 0
|
||||
|
||||
; Finalize
|
||||
eor #%00010100 ; FIRE2 FIRE DOWN UP RIGHT LEFT 0 0
|
||||
ldx #$00
|
||||
bit $C080 ; Switch in LC bank 2 for R/O
|
||||
rts
|
||||
|
||||
|
||||
|
||||
@@ -147,31 +147,16 @@ next: inc ptr1+1
|
||||
asl
|
||||
sta yparam+1
|
||||
|
||||
.ifdef __APPLE2ENH__
|
||||
; Save LC read state
|
||||
ldx #<ROMIN
|
||||
bit RDLCRAM
|
||||
bpl :+
|
||||
ldx #<LCBANK1
|
||||
bit RDLCBNK2
|
||||
bpl :+
|
||||
ldx #<LCBANK2
|
||||
: phx
|
||||
|
||||
; The AppleMouse II Card needs the ROM swapped in
|
||||
; The AppleMouse II Card needs the ROM switched in
|
||||
; to be able to detect an Apple //e and use RDVBL
|
||||
sta ROMIN ; STA keeps LC write state
|
||||
.endif
|
||||
bit $C082
|
||||
|
||||
; Reset mouse hardware
|
||||
ldx #INITMOUSE
|
||||
jsr firmware
|
||||
|
||||
.ifdef __APPLE2ENH__
|
||||
; Restore LC read state
|
||||
plx
|
||||
sta $C000,x ; STA keeps LC write state
|
||||
.endif
|
||||
; Switch in LC bank 2 for R/O
|
||||
bit $C080
|
||||
|
||||
; Turn mouse on
|
||||
lda #%00000001
|
||||
|
||||
@@ -34,6 +34,7 @@ KBDSTRB := $C010 ; Clear keyboard strobe
|
||||
; 80 column video switches
|
||||
CLR80COL:= $C000 ; Disable 80 column store
|
||||
SET80COL:= $C001 ; Enable 80 column store
|
||||
RD80COL := $C018 ; >127 if 80 column store enabled
|
||||
RD80VID := $C01F ; >127 if 80 column video enabled
|
||||
|
||||
; Character set switches
|
||||
@@ -49,6 +50,8 @@ LCBANK2 := $C083 ; Swap in LC bank 2
|
||||
LCBANK1 := $C08B ; Swap in LC bank 1
|
||||
|
||||
; Video mode switches
|
||||
TXTCLR := $C050 ; Display graphics
|
||||
TXTSET := $C051 ; Display text
|
||||
MIXCLR := $C052 ; Disable 4 lines of text
|
||||
MIXSET := $C053 ; Enable 4 lines of text
|
||||
LOWSCR := $C054 ; Page 1
|
||||
|
||||
20
libsrc/apple2/cout.s
Normal file
20
libsrc/apple2/cout.s
Normal file
@@ -0,0 +1,20 @@
|
||||
;
|
||||
; Oliver Schmidt, 03.03.2007
|
||||
;
|
||||
; COUT routine
|
||||
;
|
||||
|
||||
.export COUT
|
||||
|
||||
.include "apple2.inc"
|
||||
|
||||
.segment "LOWCODE"
|
||||
|
||||
COUT:
|
||||
; Switch in ROM and call COUT
|
||||
bit $C082
|
||||
jsr $FDED ; Vector to user output routine
|
||||
|
||||
; Switch in LC bank 2 for R/O and return
|
||||
bit $C080
|
||||
rts
|
||||
@@ -8,20 +8,24 @@
|
||||
.import zerobss
|
||||
.import initlib, donelib
|
||||
.import callmain, callirq
|
||||
.import COUT
|
||||
.import __STARTUP_LOAD__, __BSS_LOAD__ ; Linker generated
|
||||
.import __RAM_START__ , __RAM_LAST__ ; Linker generated
|
||||
.import __MOVE_START__, __MOVE_LAST__ ; Linker generated
|
||||
.import __LC_START__ , __LC_LAST__ ; Linker generated
|
||||
.import __BSS_RUN__ , __INIT_SIZE__ ; Linker generated
|
||||
.import __INTERRUPTOR_COUNT__ ; Linker generated
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "apple2.inc"
|
||||
.include "mli.inc"
|
||||
|
||||
.linecont +
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.segment "EXEHDR"
|
||||
|
||||
.addr __STARTUP_LOAD__ ; Start address
|
||||
.word __BSS_LOAD__ - __STARTUP_LOAD__ ; Size
|
||||
.addr __RAM_START__ ; Start address
|
||||
.word __BSS_RUN__ - __RAM_START__ + \
|
||||
__MOVE_LAST__ - __MOVE_START__ ; Size
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
@@ -33,13 +37,64 @@
|
||||
ldx #$FF
|
||||
txs ; Init stack pointer
|
||||
|
||||
; Delegate all further processing to keep STARTUP small
|
||||
; Switch in LC bank 2 for W/O
|
||||
bit $C081
|
||||
bit $C081
|
||||
|
||||
; Set source start address
|
||||
lda #<(__BSS_RUN__ + __INIT_SIZE__)
|
||||
ldy #>(__BSS_RUN__ + __INIT_SIZE__)
|
||||
sta $9B
|
||||
sty $9C
|
||||
|
||||
; Set source last address
|
||||
lda #<(__BSS_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
|
||||
ldy #>(__BSS_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
|
||||
sta $96
|
||||
sty $97
|
||||
|
||||
; Set destination last address
|
||||
lda #<__LC_LAST__
|
||||
ldy #>__LC_LAST__
|
||||
sta $94
|
||||
sty $95
|
||||
|
||||
; Call into Applesoft Block Transfer Utility - which handles zero
|
||||
; sized blocks well - to move content of the LC memory area
|
||||
jsr $D396 ; BLTU + 3
|
||||
|
||||
; Set source start address
|
||||
lda #<__BSS_RUN__
|
||||
ldy #>__BSS_RUN__
|
||||
sta $9B
|
||||
sty $9C
|
||||
|
||||
; Set source last address
|
||||
lda #<(__BSS_RUN__ + __INIT_SIZE__)
|
||||
ldy #>(__BSS_RUN__ + __INIT_SIZE__)
|
||||
sta $96
|
||||
sty $97
|
||||
|
||||
; Set destination last address
|
||||
lda #<__RAM_LAST__
|
||||
ldy #>__RAM_LAST__
|
||||
sta $94
|
||||
sty $95
|
||||
|
||||
; Call into Applesoft Block Transfer Utility - which handles moving
|
||||
; overlapping blocks upwards well - to move the INIT segment
|
||||
jsr $D396 ; BLTU + 3
|
||||
|
||||
; Delegate all further processing to keep the STARTUP segment small
|
||||
jsr init
|
||||
|
||||
; Avoid re-entrance of donelib. This is also the _exit entry
|
||||
_exit: ldx #<exit
|
||||
lda #>exit
|
||||
jsr reset ; Setup RESET vector
|
||||
|
||||
; Switch in ROM in case it wasn't already switched in by a RESET
|
||||
bit $C082
|
||||
|
||||
; Call module destructors
|
||||
jsr donelib
|
||||
@@ -50,7 +105,7 @@ _exit: ldx #<exit
|
||||
|
||||
; Deallocate interrupt vector table entry
|
||||
dec params ; Adjust parameter count
|
||||
jsr ENTRY
|
||||
jsr $BF00 ; MLI call entry point
|
||||
.byte $41 ; Dealloc interrupt
|
||||
.addr params
|
||||
|
||||
@@ -88,6 +143,9 @@ init: ldx #zpspace-1
|
||||
dex
|
||||
bpl :-
|
||||
|
||||
; Clear the BSS data
|
||||
jsr zerobss
|
||||
|
||||
; Save the original RESET vector
|
||||
ldx #$02
|
||||
: lda SOFTEV,x
|
||||
@@ -102,9 +160,6 @@ init: ldx #zpspace-1
|
||||
lda #>_exit
|
||||
jsr reset ; Setup RESET vector
|
||||
|
||||
; Clear the BSS data
|
||||
jsr zerobss
|
||||
|
||||
; Setup the stack
|
||||
lda HIMEM
|
||||
sta sp
|
||||
@@ -116,12 +171,12 @@ init: ldx #zpspace-1
|
||||
beq :+
|
||||
|
||||
; Check for ProDOS
|
||||
lda ENTRY
|
||||
lda $BF00 ; MLI call entry point
|
||||
cmp #$4C ; Is MLI present? (JMP opcode)
|
||||
bne prterr
|
||||
|
||||
; Allocate interrupt vector table entry
|
||||
jsr ENTRY
|
||||
jsr $BF00 ; MLI call entry point
|
||||
.byte $40 ; Alloc interrupt
|
||||
.addr params
|
||||
bcs prterr
|
||||
@@ -133,13 +188,16 @@ init: ldx #zpspace-1
|
||||
; Call module constructors
|
||||
: jsr initlib
|
||||
|
||||
; Switch in LC bank 2 for R/O
|
||||
bit $C080
|
||||
|
||||
; Push arguments and call main()
|
||||
jmp callmain
|
||||
|
||||
; Print error message and return
|
||||
prterr: ldx #msglen-1
|
||||
: lda errmsg,x
|
||||
jsr COUT
|
||||
jsr $FDED ; COUT
|
||||
dex
|
||||
bpl :-
|
||||
rts
|
||||
@@ -184,10 +242,6 @@ intrpt: cld
|
||||
: sec
|
||||
rts
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.code
|
||||
|
||||
; Setup RESET vector
|
||||
reset: stx SOFTEV
|
||||
sta SOFTEV+1
|
||||
@@ -201,8 +255,12 @@ reset: stx SOFTEV
|
||||
|
||||
zpsave: .res zpspace
|
||||
|
||||
rvsave: .res 3
|
||||
|
||||
params: .byte $02 ; Parameter count
|
||||
intnum: .byte $00 ; Interrupt number
|
||||
.addr intrpt ; Interrupt handler
|
||||
.addr intrpt ; Interrupt handler
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
|
||||
.bss
|
||||
|
||||
rvsave: .res 3
|
||||
|
||||
@@ -17,7 +17,6 @@ getfd:
|
||||
cmp #MAX_FDS
|
||||
bcs error
|
||||
|
||||
|
||||
; Convert handle to fdtab slot
|
||||
.assert .sizeof(FD) = 4, error
|
||||
asl
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
;
|
||||
|
||||
.export _gotoxy, _gotox
|
||||
|
||||
.import popa, VTABZ
|
||||
|
||||
.include "apple2.inc"
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
;
|
||||
|
||||
.export _gotoy
|
||||
|
||||
.import VTABZ
|
||||
|
||||
.include "apple2.inc"
|
||||
|
||||
20
libsrc/apple2/home.s
Normal file
20
libsrc/apple2/home.s
Normal file
@@ -0,0 +1,20 @@
|
||||
;
|
||||
; Oliver Schmidt, 03.03.2007
|
||||
;
|
||||
; HOME routine
|
||||
;
|
||||
|
||||
.export HOME
|
||||
|
||||
.include "apple2.inc"
|
||||
|
||||
.segment "LOWCODE"
|
||||
|
||||
HOME:
|
||||
; Switch in ROM and call HOME
|
||||
bit $C082
|
||||
jsr $FC58 ; Clear current text screen
|
||||
|
||||
; Switch in LC bank 2 for R/O and return
|
||||
bit $C080
|
||||
rts
|
||||
@@ -57,9 +57,9 @@ extern char _cwd[FILENAME_MAX];
|
||||
|
||||
|
||||
|
||||
DIR* __fastcall__ opendir (const char* name)
|
||||
DIR* __fastcall__ opendir (register const char* name)
|
||||
{
|
||||
DIR* dir;
|
||||
register DIR* dir;
|
||||
|
||||
/* Alloc DIR */
|
||||
if ((dir = malloc (sizeof (*dir))) == NULL) {
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 2004-06-03
|
||||
;
|
||||
; Rom COUT routine
|
||||
;
|
||||
|
||||
.export COUT
|
||||
|
||||
COUT := $FDED ; Vector to user output routine
|
||||
|
||||
20
libsrc/apple2/rdkey.s
Normal file
20
libsrc/apple2/rdkey.s
Normal file
@@ -0,0 +1,20 @@
|
||||
;
|
||||
; Oliver Schmidt, 03.03.2007
|
||||
;
|
||||
; RDKEY routine
|
||||
;
|
||||
|
||||
.export RDKEY
|
||||
|
||||
.include "apple2.inc"
|
||||
|
||||
.segment "LOWCODE"
|
||||
|
||||
RDKEY:
|
||||
; Switch in ROM and call RDKEY
|
||||
bit $C082
|
||||
jsr $FD0C ; Display prompt and read key from user input routine
|
||||
|
||||
; Switch in LC bank 2 for R/O and return
|
||||
bit $C080
|
||||
rts
|
||||
@@ -43,9 +43,9 @@
|
||||
|
||||
|
||||
|
||||
struct dirent* __fastcall__ readdir (DIR* dir)
|
||||
struct dirent* __fastcall__ readdir (register DIR* dir)
|
||||
{
|
||||
unsigned char* entry;
|
||||
register unsigned char* entry;
|
||||
|
||||
/* Search for the next active directory entry */
|
||||
do {
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
|
||||
|
||||
|
||||
void __fastcall__ rewinddir (DIR* dir)
|
||||
void __fastcall__ rewinddir (register DIR* dir)
|
||||
{
|
||||
/* Rewind directory file */
|
||||
if (lseek (dir->fd, 0, SEEK_SET)) {
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
;
|
||||
; Oliver Schmidt, 30.05.2004
|
||||
;
|
||||
; Apple2 ROM routines
|
||||
;
|
||||
|
||||
.export TEXT
|
||||
.export HGR2
|
||||
.export HGR
|
||||
.export HCLR
|
||||
.export BKGND
|
||||
.export HPOSN
|
||||
.export HPLOT
|
||||
.export HLIN
|
||||
.export HFIND
|
||||
.export DRAW
|
||||
.export XDRAW
|
||||
.export SETHCOL
|
||||
|
||||
; Graphics entry points, by cbmnut (applenut??) cbmnut@hushmail.com
|
||||
TEXT := $F399 ; Return to text screen
|
||||
HGR2 := $F3D8 ; Initialize and clear hi-res page 2.
|
||||
HGR := $F3E2 ; Initialize and clear hi-res page 1.
|
||||
HCLR := $F3F2 ; Clear the current hi-res screen to black.
|
||||
BKGND := $F3F6 ; Clear the current hi-res screen to the
|
||||
; last plotted color (from ($1C).
|
||||
HPOSN := $F411 ; Positions the hi-res cursor without
|
||||
; plotting a point.
|
||||
; Enter with (A) = Y-coordinate, and
|
||||
; (Y,X) = X-coordinate.
|
||||
HPLOT := $F457 ; Calls HPOSN and tries to plot a dot at
|
||||
; the cursor's position. If you are
|
||||
; trying to plot a non-white color at
|
||||
; a complementary color position, no
|
||||
; dot will be plotted.
|
||||
HLIN := $F53A ; Draws a line from the last plotted
|
||||
; point or line destination to:
|
||||
; (X,A) = X-coordinate, and
|
||||
; (Y) = Y-coordinate.
|
||||
HFIND := $F5CB ; Converts the hi-res coursor's position
|
||||
; back to X- and Y-coordinates; stores
|
||||
; X-coordinate at $E0,E1 and Y-coordinate
|
||||
; at $E2.
|
||||
DRAW := $F601 ; Draws a shape. Enter with (Y,X) = the
|
||||
; address of the shape table, and (A) =
|
||||
; the rotation factor. Uses the current
|
||||
; color.
|
||||
XDRAW := $F65D ; Draws a shape by inverting the existing
|
||||
; color of the dots the shape draws over.
|
||||
; Same entry parameters as DRAW.
|
||||
SETHCOL := $F6EC ; Set the hi-res color to (X), where (X)
|
||||
; must be between 0 and 7.
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 2004-06-03
|
||||
;
|
||||
; Rom PREAD routine
|
||||
;
|
||||
|
||||
.export PREAD
|
||||
|
||||
PREAD := $FB1E ; Read paddle in X, return AD conv. value in Y
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 2004-06-03
|
||||
;
|
||||
; Rom RDKEY routine
|
||||
;
|
||||
|
||||
.export RDKEY
|
||||
|
||||
RDKEY := $FD0C ; Display prompt and read key from user input routine
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
;
|
||||
; Ullrich von Bassewitz, 2004-06-03
|
||||
;
|
||||
; Rom VTABZ routine
|
||||
;
|
||||
|
||||
.export VTABZ
|
||||
|
||||
VTABZ := $FC24 ; Generate text base address
|
||||
@@ -14,16 +14,14 @@
|
||||
; BEWARE: The current implementation of tgi_map_mode does not work with tables
|
||||
; larger that 255 bytes!
|
||||
|
||||
.rodata
|
||||
.rodata
|
||||
|
||||
_tgi_mode_table:
|
||||
.ifdef __APPLE2ENH__
|
||||
.byte TGI_MODE_280_192_6, "A2E.HI.TGI", 0
|
||||
.byte TGI_MODE_40_40_16, "A2E.LO.TGI", 0
|
||||
; .byte TGI_MODE_560_192_2, "A2E.DHI.TGI", 0
|
||||
.byte TGI_MODE_280_192_8, "A2E.HI.TGI", 0
|
||||
.byte TGI_MODE_40_48_16, "A2E.LO.TGI", 0
|
||||
.else
|
||||
.byte TGI_MODE_280_192_6, "A2.HI.TGI", 0
|
||||
.byte TGI_MODE_40_40_16, "A2.LO.TGI", 0
|
||||
; .byte TGI_MODE_560_192_2, "A2.DHI.TGI", 0
|
||||
.byte TGI_MODE_280_192_8, "A2.HI.TGI", 0
|
||||
.byte TGI_MODE_40_48_16, "A2.LO.TGI", 0
|
||||
.endif
|
||||
.byte 0 ; End marker
|
||||
.byte 0 ; End marker
|
||||
|
||||
20
libsrc/apple2/vtabz.s
Normal file
20
libsrc/apple2/vtabz.s
Normal file
@@ -0,0 +1,20 @@
|
||||
;
|
||||
; Oliver Schmidt, 03.03.2007
|
||||
;
|
||||
; VTABZ routine
|
||||
;
|
||||
|
||||
.export VTABZ
|
||||
|
||||
.include "apple2.inc"
|
||||
|
||||
.segment "LOWCODE"
|
||||
|
||||
VTABZ:
|
||||
; Switch in ROM and call VTABZ
|
||||
bit $C082
|
||||
jsr $FC24 ; Generate text base address
|
||||
|
||||
; Switch in LC bank 2 and return
|
||||
bit $C080
|
||||
rts
|
||||
@@ -57,6 +57,7 @@ S_OBJS= _scrsize.o \
|
||||
close.o \
|
||||
clrscr.o \
|
||||
color.o \
|
||||
cout.o \
|
||||
cputc.o \
|
||||
crt0.o \
|
||||
ctype.o \
|
||||
@@ -75,6 +76,7 @@ S_OBJS= _scrsize.o \
|
||||
get_ostype.o \
|
||||
gotoxy.o \
|
||||
gotoy.o \
|
||||
home.o \
|
||||
initcwd.o \
|
||||
joy_stddrv.o \
|
||||
kbhit.o \
|
||||
@@ -85,14 +87,9 @@ S_OBJS= _scrsize.o \
|
||||
oserrlist.o \
|
||||
oserror.o \
|
||||
randomize.o \
|
||||
rcout.o \
|
||||
rdkey.o \
|
||||
read.o \
|
||||
revers.o \
|
||||
rhome.o \
|
||||
rom.o \
|
||||
rpread.o \
|
||||
rrdkey.o \
|
||||
rvtabz.o \
|
||||
rwcommon.o \
|
||||
syschdir.o \
|
||||
sysmkdir.o \
|
||||
@@ -103,6 +100,7 @@ S_OBJS= _scrsize.o \
|
||||
sysuname.o \
|
||||
textframe.o \
|
||||
tgi_mode_table.o\
|
||||
vtabz.o \
|
||||
wherex.o \
|
||||
wherey.o \
|
||||
write.o
|
||||
@@ -110,7 +108,7 @@ S_OBJS= _scrsize.o \
|
||||
#--------------------------------------------------------------------------
|
||||
# Drivers
|
||||
|
||||
EMDS = apple2-auxmem.emd apple2-lc.emd
|
||||
EMDS = apple2-auxmem.emd
|
||||
|
||||
JOYS = apple2-stdjoy.joy
|
||||
|
||||
@@ -118,7 +116,7 @@ MOUS = apple2-stdmou.mou
|
||||
|
||||
SERS = apple2-ssc.ser
|
||||
|
||||
TGIS = apple2-40-40-16.tgi apple2-280-192-6.tgi
|
||||
TGIS = apple2-280-192-8.tgi apple2-40-48-16.tgi
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Targets
|
||||
|
||||
Reference in New Issue
Block a user