Merge remote-tracking branch 'origin/master' into coniopeek

This commit is contained in:
mrdudz
2022-07-24 03:24:45 +02:00
2250 changed files with 195541 additions and 36938 deletions

View File

@@ -7,6 +7,7 @@ CBMS = c128 \
c64 \
cbm510 \
cbm610 \
cx16 \
pet \
plus4 \
vic20
@@ -14,22 +15,28 @@ CBMS = c128 \
GEOS = geos-apple \
geos-cbm
TARGETS = apple2 \
apple2enh \
atari \
atarixl \
atari5200 \
atmos \
$(CBMS) \
$(GEOS) \
gamate \
lynx \
nes \
osic1p \
pce \
sim6502 \
sim65c02 \
supervision
TARGETS = apple2 \
apple2enh \
atari \
atarixl \
atari2600 \
atari5200 \
atari7800 \
atmos \
creativision \
$(CBMS) \
$(GEOS) \
gamate \
lynx \
nes \
none \
osic1p \
pce \
sim6502 \
sim65c02 \
supervision \
sym1 \
telestrat
DRVTYPES = emd \
joy \
@@ -37,13 +44,13 @@ DRVTYPES = emd \
ser \
tgi
OUTPUTDIRS := lib \
$(DRVTYPES) \
targetutil \
asminc \
cfg \
include \
$(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*)))
OUTPUTDIRS := lib \
asminc \
cfg \
include \
$(subst ../,,$(filter-out $(wildcard ../include/*.*),$(wildcard ../include/*))) \
$(subst ../,,$(wildcard ../target/*/drv/*)) \
$(subst ../,,$(wildcard ../target/*/util))
.PHONY: all mostlyclean clean install zip lib $(TARGETS)
@@ -69,7 +76,7 @@ endif
ifndef TARGET
datadir = $(prefix)/share/cc65
datadir = $(PREFIX)/share/cc65
all lib: $(TARGETS)
@@ -77,7 +84,7 @@ mostlyclean:
$(call RMDIR,../libwrk)
clean:
$(call RMDIR,../libwrk ../lib ../targetutil $(addprefix ../,$(DRVTYPES)))
$(call RMDIR,../libwrk ../lib ../target)
ifdef CMD_EXE
@@ -89,9 +96,8 @@ INSTALL = install
define INSTALL_recipe
$(if $(prefix),,$(error variable `prefix' must be set))
$(INSTALL) -d $(DESTDIR)$(datadir)/$(dir)
$(INSTALL) -m644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir)
$(INSTALL) -m0644 ../$(dir)/*.* $(DESTDIR)$(datadir)/$(dir)
endef # INSTALL_recipe
@@ -128,8 +134,7 @@ MKINC = $(GEOS) \
TARGETUTIL = apple2 \
apple2enh \
atari \
geos-apple
atari
GEOSDIRS = common \
conio \
@@ -193,6 +198,7 @@ DEPS = $(OBJS:.o=.d)
EXTRA_SRCPAT = $(SRCDIR)/extra/%.s
EXTRA_OBJPAT = ../lib/$(TARGET)-%.o
EXTRA_OBJS := $(patsubst $(EXTRA_SRCPAT),$(EXTRA_OBJPAT),$(wildcard $(SRCDIR)/extra/*.s))
DEPS += $(EXTRA_OBJS:../lib/%.o=../libwrk/$(TARGET)/%.d)
ZPOBJ = ../libwrk/$(TARGET)/zeropage.o
ifeq ($(TARGET),$(filter $(TARGET),$(EXTZP)))
@@ -212,7 +218,7 @@ define DRVTYPE_template
$1_SRCDIR = $$(SRCDIR)/$1
$1_STCDIR = ../libwrk/$$(TARGET)
$1_DYNDIR = ../libwrk/$$(TARGET)/$1
$1_DRVDIR = ../$1
$1_DRVDIR = ../target/$$(TARGET)/drv/$1
$1_SRCPAT = $$($1_SRCDIR)/$$(OBJPFX)%.s
$1_STCPAT = $$($1_STCDIR)/$$(OBJPFX)%-$1.o
@@ -276,14 +282,14 @@ endef # COMPILE_recipe
../libwrk/$(TARGET)/%.o: %.c | ../libwrk/$(TARGET)
$(COMPILE_recipe)
$(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../lib
$(EXTRA_OBJPAT): $(EXTRA_SRCPAT) | ../libwrk/$(TARGET) ../lib
@echo $(TARGET) - $(<F)
@$(CA65) -t $(TARGET) $(CA65FLAGS) -o $@ $<
@$(CA65) -t $(TARGET) $(CA65FLAGS) --create-dep $(@:../lib/%.o=../libwrk/$(TARGET)/%.d) -o $@ $<
../lib/$(TARGET).lib: $(OBJS) | ../lib
$(AR65) a $@ $?
../libwrk/$(TARGET) ../lib ../targetutil:
../libwrk/$(TARGET) ../lib ../target/$(TARGET)/util:
@$(call MKDIR,$@)
$(TARGET): $(EXTRA_OBJS) ../lib/$(TARGET).lib

81
libsrc/apple2/_sys.s Normal file
View File

@@ -0,0 +1,81 @@
;
; void __fastcall__ _sys (struct regs* r);
;
.export __sys
.import jmpvec
.include "zeropage.inc"
.segment "LOWCODE"
__sys: sta ptr1
stx ptr1+1 ; Save the pointer to r
; Fetch the PC and store it into the jump vector
ldy #5
lda (ptr1),y
sta jmpvec+2
dey
lda (ptr1),y
sta jmpvec+1
; Remember the flags so we can restore them to a known state after calling the
; routine
php
; Get the flags, keep the state of bit 4 and 5 using the other flags from
; the flags value passed by the caller. Push the new flags and push A.
dey
php
pla ; Current flags -> A
eor (ptr1),y
and #%00110000
eor (ptr1),y
pha ; Push new flags value
ldy #0
lda (ptr1),y
pha
; Get and assign X and Y
iny
lda (ptr1),y
tax
iny
lda (ptr1),y
tay
; Switch in ROM
bit $C082
; Set A and the flags, call the machine code routine
pla
plp
jsr jmpvec
; Back from the routine. Save the flags and A.
php
pha
; Switch in LC bank 2 for R/O
bit $C080
; Put the register values into the regs structure
tya
ldy #2
sta (ptr1),y
dey
txa
sta (ptr1),y
dey
pla
sta (ptr1),y
ldy #3
pla
sta (ptr1),y
; Restore the old flags value
plp
; Done
rts

View File

@@ -1,7 +1,7 @@
;
; Ullrich von Bassewitz, 27.09.1998
;
; void set_brk (unsigned Addr);
; void __fastcall__ set_brk (unsigned Addr);
; void reset_brk (void);
;

View File

@@ -6,12 +6,11 @@
;
.export _cclearxy, _cclear
.import popa, _gotoxy, chlinedirect
.import gotoxy, chlinedirect
_cclearxy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _cclear
_cclear:

View File

@@ -6,20 +6,47 @@
; If open_apple key is pressed then the high-bit of the key is set.
;
.export _cgetc
.export _cgetc
.import cursor, putchardirect
.include "apple2.inc"
.include "apple2.inc"
_cgetc:
lda KBD
bpl _cgetc ; If < 128, no key pressed
; Cursor on ?
lda cursor
beq :+
; At this time, the high bit of the key pressed is set
bit KBDSTRB ; Clear keyboard strobe
; Show caret.
.ifdef __APPLE2ENH__
lda #$7F | $80 ; Checkerboard, screen code
.else
lda #' ' | $40 ; Blank, flashing
.endif
jsr putchardirect ; Returns old character in X
; Wait for keyboard strobe.
: inc RNDL ; Increment random counter low
bne :+
inc RNDH ; Increment random counter high
: lda KBD
bpl :-- ; If < 128, no key pressed
; Cursor on ?
ldy cursor
beq :+
; Restore old character.
pha
txa
jsr putchardirect
pla
; At this time, the high bit of the key pressed is set.
: bit KBDSTRB ; Clear keyboard strobe
.ifdef __APPLE2ENH__
bit BUTN0 ; Check if OpenApple is down
bmi done
.endif
and #$7F ; If not down, then clear high bit
done: ldx #$00
done: ldx #>$0000
rts

View File

@@ -6,32 +6,30 @@
;
.export _chlinexy, _chline, chlinedirect
.import popa, _gotoxy, cputdirect
.import gotoxy, cputdirect
.include "zeropage.inc"
.include "apple2.inc"
_chlinexy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _chline
_chline:
.ifdef __APPLE2ENH__
ldx #'S' ; MouseText character
ldy INVFLG
cpy #$FF ; Normal character display mode?
beq chlinedirect
ldx #'_' | $80 ; Underscore, screen code
.else
ldx #'-' | $80 ; Minus, screen code
.endif
ldx #'-' | $80 ; Horizontal line, screen code
chlinedirect:
stx tmp1
cmp #$00 ; Is the length zero?
beq done ; Jump if done
sta tmp1
: txa ; Screen code
sta tmp2
: lda tmp1 ; Screen code
jsr cputdirect ; Direct output
dec tmp1
dec tmp2
bne :-
done: rts

View File

@@ -13,4 +13,4 @@ _textcolor := return1
_bgcolor := return0
_bordercolor := return0
_bordercolor := return0

28
libsrc/apple2/cpeekc.s Normal file
View File

@@ -0,0 +1,28 @@
;
; 2020-07-12, Oliver Schmidt
;
; char cpeekc (void);
;
.export _cpeekc
.include "apple2.inc"
_cpeekc:
ldy CH
.ifdef __APPLE2ENH__
bit RD80VID ; In 80 column mode?
bpl peek ; No, just go ahead
tya
lsr ; Div by 2
tay
bcs peek ; Odd cols are in main memory
bit HISCR ; Assume SET80COL
.endif
peek: lda (BASL),Y ; Get character
.ifdef __APPLE2ENH__
bit LOWSCR ; Doesn't hurt in 40 column mode
.endif
eor #$80 ; Invert high bit
ldx #$00
rts

View File

@@ -9,12 +9,12 @@
.constructor initconio
.endif
.export _cputcxy, _cputc
.export cputdirect, newline, putchar
.import popa, _gotoxy, VTABZ
.export cputdirect, newline, putchar, putchardirect
.import gotoxy, VTABZ
.include "apple2.inc"
.segment "INIT"
.segment "ONCE"
.ifdef __APPLE2ENH__
initconio:
@@ -29,16 +29,15 @@ initconio:
_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy
pla ; Restore C
jsr gotoxy ; Call this one, will pop params
pla ; Restore C and run into _cputc
_cputc:
cmp #$0D ; Test for \r = carrage return
beq left
cmp #$0A ; Test for \n = line feed
beq newline
ora #$80 ; Turn on high bit
eor #$80 ; Invert high bit
.ifndef __APPLE2ENH__
cmp #$E0 ; Test for lowercase
bcc cputdirect
@@ -51,6 +50,7 @@ cputdirect:
lda CH
cmp WNDWDTH
bcc :+
jsr newline
left: lda #$00 ; Goto left edge of screen
sta CH
: rts
@@ -63,32 +63,36 @@ newline:
lda WNDTOP ; Goto top of screen
sta CV
: jmp VTABZ
putchar:
.ifdef __APPLE2ENH__
ldy INVFLG
cpy #$FF ; Normal character display mode?
beq put
beq putchardirect
cmp #$E0 ; Lowercase?
bcc mask
and #$7F ; Inverse lowercase
bra put
bra putchardirect
.endif
mask: and INVFLG ; Apply normal, inverse, flash
put: ldy CH
putchardirect:
pha
ldy CH
.ifdef __APPLE2ENH__
bit RD80VID ; In 80 column mode?
bpl col40 ; No, in 40 cols
pha
bpl put ; No, just go ahead
tya
lsr ; Div by 2
tay
pla
bcs col40 ; Odd cols go in 40 col memory
bcs put ; Odd cols go in main memory
bit HISCR ; Assume SET80COL
sta (BASL),Y
bit LOWSCR ; Assume SET80COL
rts
.endif
col40: sta (BASL),Y
put: lda (BASL),Y ; Get current character
tax ; Return old character for _cgetc
pla
sta (BASL),Y
.ifdef __APPLE2ENH__
bit LOWSCR ; Doesn't hurt in 40 column mode
.endif
rts

View File

@@ -6,16 +6,17 @@
.export _exit, done, return
.export __STARTUP__ : absolute = 1 ; Mark as startup
.import zerobss
.import initlib, donelib
.import callmain
.import zerobss, callmain
.import __ONCE_LOAD__, __ONCE_SIZE__ ; Linker generated
.import __LC_START__, __LC_LAST__ ; Linker generated
.import __INIT_RUN__, __INIT_SIZE__ ; Linker generated
.import __INITBSS_RUN__ ; Linker generated
.include "zeropage.inc"
.include "apple2.inc"
; ------------------------------------------------------------------------
.segment "STARTUP"
; ProDOS TechRefMan, chapter 5.2.1:
@@ -24,57 +25,16 @@
ldx #$FF
txs ; Init stack pointer
; Switch in LC bank 2 for W/O.
bit $C081
bit $C081
; Set the source start address.
lda #<(__INITBSS_RUN__ + __INIT_SIZE__)
ldy #>(__INITBSS_RUN__ + __INIT_SIZE__)
sta $9B
sty $9C
; Set the source last address.
lda #<(__INITBSS_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
ldy #>(__INITBSS_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
sta $96
sty $97
; Set the destination last address.
lda #<__LC_LAST__
ldy #>__LC_LAST__
sta $94
sty $95
; Call into Applesoft Block Transfer Up -- which handles zero-
; sized blocks well -- to move the content of the LC memory area.
jsr $D39A ; BLTU2
; Set the source start address.
lda #<__INITBSS_RUN__
ldy #>__INITBSS_RUN__
sta $9B
sty $9C
; Set the source last address.
lda #<(__INITBSS_RUN__ + __INIT_SIZE__)
ldy #>(__INITBSS_RUN__ + __INIT_SIZE__)
sta $96
sty $97
; Set the destination last address.
lda #<(__INIT_RUN__ + __INIT_SIZE__)
ldy #>(__INIT_RUN__ + __INIT_SIZE__)
sta $94
sty $95
; Call into Applesoft Block Transfer Up -- which handles moving
; overlapping blocks upwards well -- to move the INIT segment.
jsr $D39A ; BLTU2
; Delegate all further processing, to keep the STARTUP segment small.
; Save space by putting some of the start-up code in the ONCE segment,
; which can be re-used by the BSS segment, the heap and the C stack.
jsr init
; Clear the BSS data.
jsr zerobss
; Push the command-line arguments; and, call main().
jsr callmain
; Avoid a re-entrance of donelib. This is also the exit() entry.
_exit: ldx #<exit
lda #>exit
@@ -109,7 +69,9 @@ exit: ldx #$02
; We're done
jmp done
.segment "INIT"
; ------------------------------------------------------------------------
.segment "ONCE"
; Save the zero-page locations that we need.
init: ldx #zpspace-1
@@ -118,9 +80,6 @@ init: ldx #zpspace-1
dex
bpl :-
; Clear the BSS data.
jsr zerobss
; Save the original RESET vector.
ldx #$02
: lda SOFTEV,x
@@ -128,13 +87,6 @@ init: ldx #zpspace-1
dex
bpl :-
; ProDOS TechRefMan, chapter 5.3.5:
; "Your system program should place in the RESET vector the
; address of a routine that ... closes the files."
ldx #<_exit
lda #>_exit
jsr reset ; Setup RESET vector
; Check for ProDOS.
ldy $BF00 ; MLI call entry point
cpy #$4C ; Is MLI present? (JMP opcode)
@@ -164,14 +116,50 @@ basic: lda HIMEM
: sta sp
stx sp+1
; ProDOS TechRefMan, chapter 5.3.5:
; "Your system program should place in the RESET vector the
; address of a routine that ... closes the files."
ldx #<_exit
lda #>_exit
jsr reset ; Setup RESET vector
; Call the module constructors.
jsr initlib
; Switch in LC bank 2 for R/O.
bit $C080
; Switch in LC bank 2 for W/O.
bit $C081
bit $C081
; Push the command-line arguments; and, call main().
jmp callmain
; Set the source start address.
; Aka __LC_LOAD__ iff segment LC exists.
lda #<(__ONCE_LOAD__ + __ONCE_SIZE__)
ldy #>(__ONCE_LOAD__ + __ONCE_SIZE__)
sta $9B
sty $9C
; Set the source last address.
; Aka __LC_LOAD__ + __LC_SIZE__ iff segment LC exists.
lda #<((__ONCE_LOAD__ + __ONCE_SIZE__) + (__LC_LAST__ - __LC_START__))
ldy #>((__ONCE_LOAD__ + __ONCE_SIZE__) + (__LC_LAST__ - __LC_START__))
sta $96
sty $97
; Set the destination last address.
; Aka __LC_RUN__ + __LC_SIZE__ iff segment LC exists.
lda #<__LC_LAST__
ldy #>__LC_LAST__
sta $94
sty $95
; Call into Applesoft Block Transfer Up -- which handles zero-
; sized blocks well -- to move the content of the LC memory area.
jsr $D39A ; BLTU2
; Switch in LC bank 2 for R/O and return.
bit $C080
rts
; ------------------------------------------------------------------------
.code
@@ -187,6 +175,8 @@ quit: jsr $BF00 ; MLI call entry point
.byte $65 ; Quit
.word q_param
; ------------------------------------------------------------------------
.rodata
; MLI parameter list for quit
@@ -196,15 +186,16 @@ q_param:.byte $04 ; param_count
.byte $00 ; reserved
.word $0000 ; reserved
; ------------------------------------------------------------------------
.data
; Final jump when we're done
done: jmp DOSWARM ; Potentially patched at runtime
.segment "INITBSS"
; ------------------------------------------------------------------------
.segment "INIT"
zpsave: .res zpspace
.bss
rvsave: .res 3

View File

@@ -1,161 +0,0 @@
;
; Stefan Haubenthal with minor changes from Ullrich von Bassewitz, 2003-05-02
;
; Character specification table.
;
.include "ctype.inc"
; The tables are readonly, put them into the rodata segment
.rodata
; The following 256 byte wide table specifies attributes for the isxxx type
; of functions. Doing it by a table means some overhead in space, but it
; has major advantages:
;
; * It is fast. If it were'nt for the slow parameter passing of cc65, one
; could even define macros for the isxxx functions (this is usually
; done on other platforms).
;
; * It is highly portable. The only unportable part is the table itself,
; all real code goes into the common library.
;
; * We save some code in the isxxx functions.
__ctype:
.repeat 2
.byte CT_CTRL ; 0/00 ___ctrl_@___
.byte CT_CTRL ; 1/01 ___ctrl_A___
.byte CT_CTRL ; 2/02 ___ctrl_B___
.byte CT_CTRL ; 3/03 ___ctrl_C___
.byte CT_CTRL ; 4/04 ___ctrl_D___
.byte CT_CTRL ; 5/05 ___ctrl_E___
.byte CT_CTRL ; 6/06 ___ctrl_F___
.byte CT_CTRL ; 7/07 ___ctrl_G___
.byte CT_CTRL ; 8/08 ___ctrl_H___
.byte CT_CTRL | CT_OTHER_WS | CT_SPACE_TAB
; 9/09 ___ctrl_I___
.byte CT_CTRL | CT_OTHER_WS ; 10/0a ___ctrl_J___
.byte CT_CTRL | CT_OTHER_WS ; 11/0b ___ctrl_K___
.byte CT_CTRL | CT_OTHER_WS ; 12/0c ___ctrl_L___
.byte CT_CTRL | CT_OTHER_WS ; 13/0d ___ctrl_M___
.byte CT_CTRL ; 14/0e ___ctrl_N___
.byte CT_CTRL ; 15/0f ___ctrl_O___
.byte CT_CTRL ; 16/10 ___ctrl_P___
.byte CT_CTRL ; 17/11 ___ctrl_Q___
.byte CT_CTRL ; 18/12 ___ctrl_R___
.byte CT_CTRL ; 19/13 ___ctrl_S___
.byte CT_CTRL ; 20/14 ___ctrl_T___
.byte CT_CTRL ; 21/15 ___ctrl_U___
.byte CT_CTRL ; 22/16 ___ctrl_V___
.byte CT_CTRL ; 23/17 ___ctrl_W___
.byte CT_CTRL ; 24/18 ___ctrl_X___
.byte CT_CTRL ; 25/19 ___ctrl_Y___
.byte CT_CTRL ; 26/1a ___ctrl_Z___
.byte CT_CTRL ; 27/1b ___ctrl_[___
.byte CT_CTRL ; 28/1c ___ctrl_\___
.byte CT_CTRL ; 29/1d ___ctrl_]___
.byte CT_CTRL ; 30/1e ___ctrl_^___
.byte CT_CTRL ; 31/1f ___ctrl_____
.byte CT_SPACE | CT_SPACE_TAB ; 32/20 ___SPACE___
.byte CT_NONE ; 33/21 _____!_____
.byte CT_NONE ; 34/22 _____"_____
.byte CT_NONE ; 35/23 _____#_____
.byte CT_NONE ; 36/24 _____$_____
.byte CT_NONE ; 37/25 _____%_____
.byte CT_NONE ; 38/26 _____&_____
.byte CT_NONE ; 39/27 _____'_____
.byte CT_NONE ; 40/28 _____(_____
.byte CT_NONE ; 41/29 _____)_____
.byte CT_NONE ; 42/2a _____*_____
.byte CT_NONE ; 43/2b _____+_____
.byte CT_NONE ; 44/2c _____,_____
.byte CT_NONE ; 45/2d _____-_____
.byte CT_NONE ; 46/2e _____._____
.byte CT_NONE ; 47/2f _____/_____
.byte CT_DIGIT | CT_XDIGIT ; 48/30 _____0_____
.byte CT_DIGIT | CT_XDIGIT ; 49/31 _____1_____
.byte CT_DIGIT | CT_XDIGIT ; 50/32 _____2_____
.byte CT_DIGIT | CT_XDIGIT ; 51/33 _____3_____
.byte CT_DIGIT | CT_XDIGIT ; 52/34 _____4_____
.byte CT_DIGIT | CT_XDIGIT ; 53/35 _____5_____
.byte CT_DIGIT | CT_XDIGIT ; 54/36 _____6_____
.byte CT_DIGIT | CT_XDIGIT ; 55/37 _____7_____
.byte CT_DIGIT | CT_XDIGIT ; 56/38 _____8_____
.byte CT_DIGIT | CT_XDIGIT ; 57/39 _____9_____
.byte CT_NONE ; 58/3a _____:_____
.byte CT_NONE ; 59/3b _____;_____
.byte CT_NONE ; 60/3c _____<_____
.byte CT_NONE ; 61/3d _____=_____
.byte CT_NONE ; 62/3e _____>_____
.byte CT_NONE ; 63/3f _____?_____
.byte CT_NONE ; 64/40 _____@_____
.byte CT_UPPER | CT_XDIGIT ; 65/41 _____A_____
.byte CT_UPPER | CT_XDIGIT ; 66/42 _____B_____
.byte CT_UPPER | CT_XDIGIT ; 67/43 _____C_____
.byte CT_UPPER | CT_XDIGIT ; 68/44 _____D_____
.byte CT_UPPER | CT_XDIGIT ; 69/45 _____E_____
.byte CT_UPPER | CT_XDIGIT ; 70/46 _____F_____
.byte CT_UPPER ; 71/47 _____G_____
.byte CT_UPPER ; 72/48 _____H_____
.byte CT_UPPER ; 73/49 _____I_____
.byte CT_UPPER ; 74/4a _____J_____
.byte CT_UPPER ; 75/4b _____K_____
.byte CT_UPPER ; 76/4c _____L_____
.byte CT_UPPER ; 77/4d _____M_____
.byte CT_UPPER ; 78/4e _____N_____
.byte CT_UPPER ; 79/4f _____O_____
.byte CT_UPPER ; 80/50 _____P_____
.byte CT_UPPER ; 81/51 _____Q_____
.byte CT_UPPER ; 82/52 _____R_____
.byte CT_UPPER ; 83/53 _____S_____
.byte CT_UPPER ; 84/54 _____T_____
.byte CT_UPPER ; 85/55 _____U_____
.byte CT_UPPER ; 86/56 _____V_____
.byte CT_UPPER ; 87/57 _____W_____
.byte CT_UPPER ; 88/58 _____X_____
.byte CT_UPPER ; 89/59 _____Y_____
.byte CT_UPPER ; 90/5a _____Z_____
.byte CT_NONE ; 91/5b _____[_____
.byte CT_NONE ; 92/5c _____\_____
.byte CT_NONE ; 93/5d _____]_____
.byte CT_NONE ; 94/5e _____^_____
.byte CT_NONE ; 95/5f _UNDERLINE_
.byte CT_NONE ; 96/60 ___grave___
.byte CT_LOWER | CT_XDIGIT ; 97/61 _____a_____
.byte CT_LOWER | CT_XDIGIT ; 98/62 _____b_____
.byte CT_LOWER | CT_XDIGIT ; 99/63 _____c_____
.byte CT_LOWER | CT_XDIGIT ; 100/64 _____d_____
.byte CT_LOWER | CT_XDIGIT ; 101/65 _____e_____
.byte CT_LOWER | CT_XDIGIT ; 102/66 _____f_____
.byte CT_LOWER ; 103/67 _____g_____
.byte CT_LOWER ; 104/68 _____h_____
.byte CT_LOWER ; 105/69 _____i_____
.byte CT_LOWER ; 106/6a _____j_____
.byte CT_LOWER ; 107/6b _____k_____
.byte CT_LOWER ; 108/6c _____l_____
.byte CT_LOWER ; 109/6d _____m_____
.byte CT_LOWER ; 110/6e _____n_____
.byte CT_LOWER ; 111/6f _____o_____
.byte CT_LOWER ; 112/70 _____p_____
.byte CT_LOWER ; 113/71 _____q_____
.byte CT_LOWER ; 114/72 _____r_____
.byte CT_LOWER ; 115/73 _____s_____
.byte CT_LOWER ; 116/74 _____t_____
.byte CT_LOWER ; 117/75 _____u_____
.byte CT_LOWER ; 118/76 _____v_____
.byte CT_LOWER ; 119/77 _____w_____
.byte CT_LOWER ; 120/78 _____x_____
.byte CT_LOWER ; 121/79 _____y_____
.byte CT_LOWER ; 122/7a _____z_____
.byte CT_NONE ; 123/7b _____{_____
.byte CT_NONE ; 124/7c _____|_____
.byte CT_NONE ; 125/7d _____}_____
.byte CT_NONE ; 126/7e _____~_____
.byte CT_OTHER_WS ; 127/7f ____DEL____
.endrepeat

View File

@@ -5,31 +5,30 @@
; void __fastcall__ cvline (unsigned char length);
;
.export _cvlinexy, _cvline, cvlinedirect
.import popa, _gotoxy, putchar, newline
.export _cvlinexy, _cvline
.import gotoxy, putchar, newline
.include "zeropage.inc"
_cvlinexy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _cvline
_cvline:
.ifdef __APPLE2ENH__
ldx #'|' | $80 ; Vertical line, screen code
ldx #$5F ; Left vertical line MouseText character
.else
ldx #'!' | $80 ; Vertical line, screen code
ldx #'!' | $80 ; Exclamation mark, screen code
.endif
cvlinedirect:
stx tmp1
cmp #$00 ; Is the length zero?
beq done ; Jump if done
sta tmp1
: txa ; Screen code
sta tmp2
: lda tmp1 ; Screen code
jsr putchar ; Write, no cursor advance
jsr newline ; Advance cursor to next line
dec tmp1
dec tmp2
bne :-
done: rts

View File

@@ -5,7 +5,7 @@
;
.export _getdevicedir
.import popax, popa
.import popptr1, popa
.include "zeropage.inc"
.include "errno.inc"
@@ -17,11 +17,10 @@ _getdevicedir:
stx ptr2+1
; Save buf
jsr popax
sta ptr1
stx ptr1+1
jsr popptr1
; Set buf
ldx ptr1+1
sta mliparam + MLI::ON_LINE::DATA_BUFFER
stx mliparam + MLI::ON_LINE::DATA_BUFFER+1
@@ -64,7 +63,7 @@ oserr: jsr __mappederrno
lda (ptr1),y
and #15 ; Max volume name length
sta tmp1
; Add leading slash
lda #'/'
sta (ptr1),y

View File

@@ -26,7 +26,7 @@ dioprolog:
diocommon:
; Call read_block or write_block
ldx #RW_BLOCK_COUNT
jsr callmli
jsr callmli
dioepilog:
; Return success or error

View File

@@ -0,0 +1,21 @@
;
; Oliver Schmidt, 2016-06-05
;
; unsigned char doesclrscrafterexit (void);
;
.export _doesclrscrafterexit
.import done
.include "apple2.inc"
_doesclrscrafterexit:
; If the page we jump to when done equals the page
; of the warmstart vector we'll return to BASIC so
; there's no implicit clrscr() after exit().
lda done+2
sec
sbc #>DOSWARM
ldx #>$0000
rts

View File

@@ -14,10 +14,11 @@
; ProDOS 8 1.6 - $16
; ProDOS 8 1.7 - $17
; ProDOS 8 1.8 - $18
; ProDOS 8 1.9 - $18
; ProDOS 8 1.9 - $18 (!)
; ProDOS 8 2.0.1 - $21
; ProDOS 8 2.0.2 - $22
; ProDOS 8 2.0.3 - $23
; ProDOS 8 2.4.x - $24
;
.constructor initdostype, 25
@@ -30,7 +31,7 @@
; - Apple II ProDOS 8 TechNote #23, ProDOS 8 Changes and Minutia
; - ProDOS TechRefMan, chapter 5.2.4
.segment "INIT"
.segment "ONCE"
initdostype:
lda $BF00
@@ -43,6 +44,6 @@ initdostype:
: sta __dos_type
done: rts
.bss
.data
__dos_type: .res 1
__dos_type: .byte $00

View File

@@ -18,7 +18,7 @@ typerr: lda #$4A ; "Incompatible file format"
; Cleanup name
oserr: jsr popname ; Preserves A
; Set __oserror
jmp __mappederrno
@@ -129,7 +129,7 @@ setbuf: lda #$00 ; Low byte
.assert MLI::OPEN::PATHNAME = MLI::INFO::PATHNAME, error
; Lower file level to avoid program file
; being closed by C libary shutdown code
; being closed by C library shutdown code
ldx LEVEL
stx level
beq :+
@@ -185,13 +185,13 @@ setbuf: lda #$00 ; Low byte
lda #$00 ; '\0'
beq :- ; Branch always
; Call loader stub after C libary shutdown
; Call loader stub after C library shutdown
: lda #<target
ldx #>target
sta done+1
stx done+2
; Initiate C libary shutdown
; Initiate C library shutdown
jmp _exit
.bss
@@ -230,14 +230,13 @@ source: jsr $BF00
; Check for startup filename support
; ProDOS TechRefMan, chapter 5.1.5.1:
; "$2000 is a jump instruction. $2003 and $2004 are $EE."
system: lda $2000
cmp #$4C
system: lda #$4C
cmp $2000
bne jump
lda $2003
cmp #$EE
lda #$EE
cmp $2003
bne jump
lda $2004
cmp #$EE
cmp $2004
bne jump
; Store cmdline in startup filename buffer

View File

@@ -1,16 +1,40 @@
;
; Oliver Schmidt, 2012-06-10
;
; This module supplies a 4 byte DOS 3.3 header
; containing the load address and load length.
; This module supplies an AppleSingle version 2 file header + entry with
; ID 11 according to https://tools.ietf.org/rfc/rfc1740.txt Appendix A.
;
.export __EXEHDR__ : absolute = 1 ; Linker referenced
.import __LOADADDR__, __LOADSIZE__ ; Linker generated
.import __FILETYPE__ ; Linker generated
.import __MAIN_START__, __MAIN_LAST__ ; Linker generated
; ------------------------------------------------------------------------
; Data Fork
ID01_LENGTH = __MAIN_LAST__ - __MAIN_START__
ID01_OFFSET = ID01 - START
; ProDOS File Info
ID11_LENGTH = ID01 - ID11
ID11_OFFSET = ID11 - START
; ------------------------------------------------------------------------
.segment "EXEHDR"
.addr __LOADADDR__ ; Load address
.word __LOADSIZE__ ; Load length
START: .byte $00, $05, $16, $00 ; Magic number
.byte $00, $02, $00, $00 ; Version number
.res 16 ; Filler
.byte 0, 2 ; Number of entries
.byte 0, 0, 0, 1 ; Entry ID 1 - Data Fork
.byte 0, 0, >ID01_OFFSET, <ID01_OFFSET ; Offset
.byte 0, 0, >ID01_LENGTH, <ID01_LENGTH ; Length
.byte 0, 0, 0, 11 ; Entry ID 11 - ProDOS File Info
.byte 0, 0, >ID11_OFFSET, <ID11_OFFSET ; Offset
.byte 0, 0, >ID11_LENGTH, <ID11_LENGTH ; Length
ID11: .byte 0, %11000011 ; Access - Destroy, Rename, Write, Read
.byte >__FILETYPE__, <__FILETYPE__ ; File Type
.byte 0, 0 ; Auxiliary Type high
.byte >__MAIN_START__, <__MAIN_START__ ; Auxiliary Type low
ID01:

View File

@@ -7,18 +7,18 @@
.constructor initiobuf
.export iobuf_alloc, iobuf_free
.import __STARTUP_RUN__
.import incsp2, popax
.import __MAIN_START__
.import incsp2, popptr1
.include "zeropage.inc"
.include "errno.inc"
.include "../filedes.inc"
.segment "INIT"
.segment "ONCE"
initiobuf:
; Convert end address highbyte to table index
lda #>__STARTUP_RUN__
lda #>__MAIN_START__
sec
sbc #>$0800
lsr
@@ -41,9 +41,7 @@ initiobuf:
iobuf_alloc:
; Get and save "memptr"
jsr incsp2
jsr popax
sta ptr1
stx ptr1+1
jsr popptr1
; Search table for free entry
ldx #$00
@@ -90,6 +88,6 @@ iobuf_free:
; ------------------------------------------------------------------------
.bss
.data
table: .res MAX_FDS

View File

@@ -4,13 +4,13 @@
; unsigned char get_ostype (void)
;
.constructor initostype
.constructor initostype, 9
.export _get_ostype
; Identify machine according to:
; Apple II Miscellaneous TechNote #7, Apple II Family Identification
.segment "INIT"
.segment "ONCE"
initostype:
sec
@@ -32,30 +32,30 @@ next: inx
bne :-
beq next ; Branch always
index: .byte $B3, $00 ; Apple ][
.byte $B3, $1E, $00 ; Apple ][+
.byte $B3, $1E, $00 ; Apple /// (emulation)
.byte $B3, $C0, $00 ; Apple //e
.byte $B3, $C0, $DD, $BE, $00 ; Apple //e Option Card
.byte $B3, $C0, $00 ; Apple //e (enhanced)
.byte $B3, $C0, $BF, $00 ; Apple //c
.byte $B3, $C0, $BF, $00 ; Apple //c (3.5 ROM)
.byte $B3, $C0, $BF, $00 ; Apple //c (Mem. Exp.)
.byte $B3, $C0, $BF, $00 ; Apple //c (Rev. Mem. Exp.)
.byte $B3, $C0, $BF, $00 ; Apple //c Plus
index: .byte $B3, $00 ; Apple ][
.byte $B3, $1E, $00 ; Apple ][+
.byte $B3, $1E, $00 ; Apple /// (emulation)
.byte $B3, $C0, $00 ; Apple //e
.byte $B3, $C0, $DD, $00 ; Apple //e Option Card
.byte $B3, $C0, $00 ; Apple //e (enhanced)
.byte $B3, $C0, $BF, $00 ; Apple //c
.byte $B3, $C0, $BF, $00 ; Apple //c (3.5 ROM)
.byte $B3, $C0, $BF, $00 ; Apple //c (Mem. Exp.)
.byte $B3, $C0, $BF, $00 ; Apple //c (Rev. Mem. Exp.)
.byte $B3, $C0, $BF, $00 ; Apple //c Plus
.byte $00
value: .byte $38, $10 ; Apple ][
.byte $EA, $AD, $11 ; Apple ][+
.byte $EA, $8A, $20 ; Apple /// (emulation)
.byte $06, $EA, $30 ; Apple //e
.byte $06, $E0, $02, $00, $40 ; Apple //e Option Card
.byte $06, $E0, $31 ; Apple //e (enhanced)
.byte $06, $00, $FF, $50 ; Apple //c
.byte $06, $00, $00, $51 ; Apple //c (3.5 ROM)
.byte $06, $00, $03, $53 ; Apple //c (Mem. Exp.)
.byte $06, $00, $04, $54 ; Apple //c (Rev. Mem. Exp.)
.byte $06, $00, $05, $55 ; Apple //c Plus
value: .byte $38, $10 ; Apple ][
.byte $EA, $AD, $11 ; Apple ][+
.byte $EA, $8A, $20 ; Apple /// (emulation)
.byte $06, $EA, $30 ; Apple //e
.byte $06, $E0, $02, $32 ; Apple //e Option Card
.byte $06, $E0, $31 ; Apple //e (enhanced)
.byte $06, $00, $FF, $40 ; Apple //c
.byte $06, $00, $00, $41 ; Apple //c (3.5 ROM)
.byte $06, $00, $03, $43 ; Apple //c (Mem. Exp.)
.byte $06, $00, $04, $44 ; Apple //c (Rev. Mem. Exp.)
.byte $06, $00, $05, $45 ; Apple //c Plus
.byte $00
.code
@@ -65,6 +65,6 @@ _get_ostype:
ldx #$00
rts
.bss
.segment "INIT"
ostype: .res 1

View File

@@ -18,7 +18,7 @@ _getfirstdevice:
_getnextdevice:
tax
next: inx
cpx #$FF
cpx #$FF ; INVALID_DEVICE
beq done
; Check for ProDOS 8

63
libsrc/apple2/getres.s Normal file
View File

@@ -0,0 +1,63 @@
;
; Oliver Schmidt, 15.08.2018
;
; int __fastcall__ clock_getres (clockid_t clk_id, struct timespec *res);
;
.import __dos_type
.import incsp1, return0
.include "time.inc"
.include "zeropage.inc"
.include "errno.inc"
.include "mli.inc"
_clock_getres:
sta ptr1
stx ptr1+1
; Cleanup stack
jsr incsp1
; Check for ProDOS 8
lda __dos_type
beq enosys
; Presume day resolution
ldx #<day_res
ldy #>day_res
; Check for realtme clock
lda MACHID
lsr a
bcc :+
; Switch to minute resolution
ldx #<min_res
ldy #>min_res
; Copy timespec
: stx ptr2
sty ptr2+1
ldy #.sizeof(timespec)-1
: lda (ptr2),y
sta (ptr1),y
dey
bpl :-
; Return success
jmp return0
; Load errno code
enosys: lda #ENOSYS
; Set __errno
jmp __directerrno
.rodata
min_res:.dword 60
.dword 0
day_res:.dword 60 * 60 * 24
.dword 0

94
libsrc/apple2/gettime.s Normal file
View File

@@ -0,0 +1,94 @@
;
; Oliver Schmidt, 14.08.2018
;
; int __fastcall__ clock_gettime (clockid_t clk_id, struct timespec *tp);
;
.import pushax, steaxspidx, incsp1, incsp3, return0
.include "time.inc"
.include "zeropage.inc"
.include "errno.inc"
.include "mli.inc"
_clock_gettime:
jsr pushax
; Clear tv_nsec (+ tv_sec)
sta ptr1
stx ptr1+1
lda #$00
ldy #.sizeof(timespec)-1
: sta (ptr1),y
dey
bpl :-
; Update date + time
lda #GET_TIME_CALL
ldx #GET_TIME_COUNT
jsr callmli
bcs oserr
; Get date
lda DATELO+1
lsr
php ; Save month msb
cmp #70 ; Year < 70?
bcs :+ ; No, leave alone
adc #100 ; Move 19xx to 20xx
: sta TM + tm::tm_year
lda DATELO
tax ; Save day
plp ; Restore month msb
ror
lsr
lsr
lsr
lsr
beq erange ; [1..12] allows for validity check
tay
dey ; Move [1..12] to [0..11]
sty TM + tm::tm_mon
txa ; Restore day
and #%00011111
sta TM + tm::tm_mday
; Get time
lda TIMELO+1
sta TM + tm::tm_hour
lda TIMELO
sta TM + tm::tm_min
; Make time_t
lda #<TM
ldx #>TM
jsr _mktime
; Store tv_sec
ldy #timespec::tv_sec
jsr steaxspidx
; Cleanup stack
jsr incsp1
; Return success
jmp return0
; Load errno code
erange: lda #ERANGE
; Cleanup stack
jsr incsp3 ; Preserves A
; Set __errno
jmp __directerrno
; Cleanup stack
oserr: jsr incsp3 ; Preserves A
; Set __oserror
jmp __mappederrno
.bss
TM: .tag tm

View File

@@ -5,11 +5,14 @@
; void __fastcall__ gotox (unsigned char x);
;
.export _gotoxy, _gotox
.export gotoxy, _gotoxy, _gotox
.import popa, VTABZ
.include "apple2.inc"
gotoxy:
jsr popa ; Get Y
_gotoxy:
clc
adc WNDTOP

View File

@@ -37,5 +37,5 @@ initcwd:
; Add terminating zero
lda #$00
sta __cwd,x
done: rts

View File

@@ -2,7 +2,7 @@
; Oliver Schmidt, 10.9.2009
;
; Default ProDOS 8 I/O buffer management
;
;
.export iobuf_alloc, iobuf_free
.import _posix_memalign, _free

View File

@@ -9,7 +9,9 @@
.include "apple2.inc"
.segment "INIT"
.macpack apple2
.segment "ONCE"
initirq:
; Check for ProDOS
@@ -36,17 +38,9 @@ prterr: ldx #msglen-1
jmp _exit
errmsg: .ifdef __APPLE2ENH__
.byte $8D, 't'|$80, 'p'|$80, 'u'|$80, 'r'|$80, 'r'|$80
.byte 'e'|$80, 't'|$80, 'n'|$80, 'i'|$80, ' '|$80, 'c'|$80
.byte 'o'|$80, 'l'|$80, 'l'|$80, 'a'|$80, ' '|$80, 'o'|$80
.byte 't'|$80, ' '|$80, 'd'|$80, 'e'|$80, 'l'|$80, 'i'|$80
.byte 'a'|$80, 'F'|$80, $8D
scrcode $0D, "tpurretni colla ot deliaF", $0D
.else
.byte $8D, 'T'|$80, 'P'|$80, 'U'|$80, 'R'|$80, 'R'|$80
.byte 'E'|$80, 'T'|$80, 'N'|$80, 'I'|$80, ' '|$80, 'C'|$80
.byte 'O'|$80, 'L'|$80, 'L'|$80, 'A'|$80, ' '|$80, 'O'|$80
.byte 'T'|$80, ' '|$80, 'D'|$80, 'E'|$80, 'L'|$80, 'I'|$80
.byte 'A'|$80, 'F'|$80, $8D
scrcode $0D, "TPURRETNI COLLA OT DELIAF", $0D
.endif
msglen = * - errmsg

View File

@@ -19,13 +19,8 @@
; Constants
THRESHOLD = 20 ; Deviation from center triggering movement
; ------------------------------------------------------------------------
; ROM entry points
PREAD := $FB1E ; Read paddle in X, return AD conv. value in Y
LOWER_THRESHOLD = 05
UPPER_THRESHOLD = 85
; ------------------------------------------------------------------------
@@ -44,36 +39,38 @@ PREAD := $FB1E ; Read paddle in X, return AD conv. value in Y
; Library reference
.addr $0000
; Button state masks (8 values)
.byte $10
.byte $20
.byte $04
.byte $08
.byte $40
.byte $80
.byte $00 ; Future expansion
.byte $00 ; Future expansion
libref: .addr $0000
; Jump table
.addr INSTALL
.addr UNINSTALL
.addr COUNT
.addr READJOY
.addr 0 ; IRQ not used
.addr READ
; ------------------------------------------------------------------------
.code
.bss
ostype: .res 1
value0: .res 1
value1: .res 1
; ------------------------------------------------------------------------
.data
; 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 libref
ldx libref+1
sta gettype+1
stx gettype+2
gettype:jsr $0000
sta ostype
lda #<JOY_ERR_OK
ldx #>JOY_ERR_OK
; Fall through
@@ -83,57 +80,94 @@ INSTALL:
UNINSTALL:
rts
; COUNT: Return the total number of available joysticks in a/x.
; ------------------------------------------------------------------------
.code
; COUNT routine. Return the total number of available joysticks in a/x.
COUNT:
lda #$02 ; Number of joysticks we support
ldx #$02
bit ostype
bvc noiic ; Not $4x
dex ; Only one joystick for the //c
noiic: txa ; Number of joysticks we support
ldx #$00
rts
; READ: Read a particular joystick passed in A.
READJOY:
bit $C082 ; Switch in ROM
and #$01 ; Restrict joystick number
; Read horizontal paddle
; READ routine. Read a particular joystick passed in A.
READ:
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
tax
ldy #$00
sty value0
sty value1
; Read vertical paddle
; If IIgs -> set speed to normal
bit ostype
bpl nogs1 ; Not $8x
lda CYAREG
pha
inx ; Set paddle number (1, 3)
jsr PREAD ; Read paddle value
and #%01111111
sta CYAREG
; Read both paddles simultaneously according to:
; Apple IIe Technote #6, The Apple II Paddle Circuits
nogs1: lda PTRIG ; Trigger paddles
loop: lda PADDL0,x ; Read paddle (0 or 2)
bmi set0 ; Cycles: 2 3
nop ; Cycles: 2
bpl nop0 ; Cycles: 3
set0: sty value0 ; Cycles: 4
nop0: ; - -
; Cycles: 7 7
lda PADDL1,x ; Read paddle (1 or 3)
bmi set1 ; Cycles: 2 3
nop ; Cycles: 2
bpl nop1 ; Cycles: 3
set1: sty value1 ; Cycles: 4
nop1: ; - -
; Cycles: 7 7
iny
cpy #UPPER_THRESHOLD+1
bne loop
; If IIgs -> restore speed
bit ostype
bpl nogs2 ; Not $8x
pla
cpy #127 - THRESHOLD
sta CYAREG
; Transform paddle readings to directions
nogs2: lda #$00 ; 0 0 0 0 0 0 0 0
ldy value0
cpy #LOWER_THRESHOLD
ror ; !LEFT 0 0 0 0 0 0 0
cpy #UPPER_THRESHOLD
ror ; RIGHT !LEFT 0 0 0 0 0 0
ldy value1
cpy #LOWER_THRESHOLD
ror ; !UP RIGHT !LEFT 0 0 0 0 0
cpy #127 + THRESHOLD
cpy #UPPER_THRESHOLD
ror ; DOWN !UP RIGHT !LEFT 0 0 0 0
; Read primary button
tay
lda BUTN0-1,x ; Check button (1, 3)
lda BUTN0,x ; Check button (0 or 2)
asl
tya
ror ; FIRE DOWN !UP RIGHT !LEFT 0 0 0
ror ; BTN_1 DOWN !UP RIGHT !LEFT 0 0 0
; Read secondary button
tay
inx
txa
and #$03 ; IIgs has fourth button at TAPEIN
eor #$02 ; IIgs has fourth button at TAPEIN
tax
lda BUTN0-1,x ; Check button (2, 0)
lda TAPEIN,x ; Check button (1 or 3)
asl
tya
ror ; FIRE2 FIRE DOWN !UP RIGHT !LEFT 0 0
ror ; BTN_2 BTN_1 DOWN !UP RIGHT !LEFT 0 0
; Finalize
eor #%00010100 ; FIRE2 FIRE DOWN UP RIGHT LEFT 0 0
eor #%00010100 ; BTN_2 BTN_1 DOWN UP RIGHT LEFT 0 0
ldx #$00
bit $C080 ; Switch in LC bank 2 for R/O
rts

8
libsrc/apple2/joyref.s Normal file
View File

@@ -0,0 +1,8 @@
;
; Oliver Schmidt, 2020-06-04
;
.export joy_libref
.import _get_ostype
joy_libref := _get_ostype

View File

@@ -2,11 +2,10 @@
; Oliver Schmidt, 2013-05-31
;
.export em_libref, joy_libref, mouse_libref, ser_libref, tgi_libref
.export em_libref, mouse_libref, ser_libref, tgi_libref
.import _exit
em_libref := _exit
joy_libref := _exit
mouse_libref := _exit
ser_libref := _exit
tgi_libref := _exit

View File

@@ -5,7 +5,8 @@
;
.export _lseek
.import popax
.import popax, popptr1
.macpack cpu
.include "zeropage.inc"
.include "errno.inc"
@@ -18,11 +19,10 @@ _lseek:
stx tmp2
; Get and save offset
jsr popax
sta ptr1
stx ptr1+1
jsr popptr1
jsr popax
sta ptr2
stx ptr2+1
; Get and process fd
jsr popax
@@ -79,6 +79,9 @@ seek_common:
tya
adc ptr2
sta mliparam + MLI::MARK::POSITION+2
lda #$00
adc ptr2+1
bne einval ; less than 0 or greater than 2^24 - 1
; Set file pointer
lda #SET_MARK_CALL
@@ -86,13 +89,31 @@ seek_common:
jsr callmli
bcs oserr
; Need to return the position in EAX
.if (.cpu .bitand ::CPU_ISET_65SC02)
stz sreg+1
.else
lda #$00
sta sreg+1
.endif
lda mliparam + MLI::MARK::POSITION+2
sta sreg
ldx mliparam + MLI::MARK::POSITION+1
lda mliparam + MLI::MARK::POSITION
rts
; Load errno code
einval: lda #EINVAL
; Set __errno
errno: jmp __directerrno
errno: jsr __directerrno ; leaves -1 in AX
stx sreg ; extend return value to 32 bits
stx sreg+1
rts
; Set __oserror
oserr: jmp __mappederrno
oserr: jsr __mappederrno ; leaves -1 in AX
stx sreg ; extend return value to 32 bits
stx sreg+1
rts

View File

@@ -46,10 +46,10 @@ FNAM_LEN = $280
FNAM = $281
REM = $B2 ; BASIC token-code
; Get possible command-line arguments. Goes into the special INIT segment,
; Get possible command-line arguments. Goes into the special ONCE segment,
; which may be reused after the startup code is run.
.segment "INIT"
.segment "ONCE"
initmainargs:
@@ -83,6 +83,7 @@ initmainargs:
; destroyed.
ldy #$00
sty buffer + BUF_LEN - 1
: lda BASIC_BUF,x
sta buffer,y
inx
@@ -166,14 +167,13 @@ done: lda #<argv
stx __argv+1
rts
; This array is zeroed before initmainargs is called.
; char* argv[MAXARGS+1] = {FNAM};
.data
; char* argv[MAXARGS+1] = {FNAM};
argv: .addr FNAM
.res MAXARGS * 2
.bss
.segment "INIT"
buffer: .res BUF_LEN

View File

@@ -8,13 +8,13 @@
;
.export _mouse_def_callbacks
.include "apple2.inc"
; ------------------------------------------------------------------------
.bss
backup: .res 1
visible:.res 1
@@ -36,7 +36,7 @@ _mouse_def_callbacks:
.data
.ifdef __APPLE2ENH__
cursor = 'B' ; MouseText character
cursor = $42 ; Pointer MouseText character
.else
cursor = '+' | $40 ; Flashing crosshair
.endif

View File

@@ -6,6 +6,7 @@
.import __dos_type
.include "apple2.inc"
.include "mli.inc"
.bss
@@ -23,10 +24,24 @@ callmli:
lda __dos_type
beq oserr
; Call MLI and return
; Save random counter
lda RNDL
pha
lda RNDH
pha
; Call MLI
jsr $BF00 ; MLI call entry point
call: .byte $00
.addr mliparam
; Restore random counter and return
tax
pla
sta RNDH
pla
sta RNDL
txa
rts
; Load oserror code and return

View File

@@ -152,7 +152,7 @@ next: inc ptr1+1
sta xparam+1
sta jump+2
; Disable interrupts now because setting the slot number makes
; Disable interrupts now because setting the slot number makes
; the IRQ handler (maybe called due to some non-mouse IRQ) try
; calling the firmware which isn't correctly set up yet
sei
@@ -167,7 +167,7 @@ next: inc ptr1+1
asl
asl
sta yparam+1
; The AppleMouse II Card needs the ROM switched in
; to be able to detect an Apple //e and use RDVBL
bit $C082
@@ -175,7 +175,7 @@ next: inc ptr1+1
; Reset mouse hardware
ldx #INITMOUSE
jsr firmware
; Switch in LC bank 2 for R/O
bit $C080
@@ -236,12 +236,12 @@ UNINSTALL:
SETBOX:
sta ptr1
stx ptr1+1
; Set x clamps
ldx #$00
ldy #MOUSE_BOX::MINX
jsr :+
; Set y clamps
ldx #$01
ldy #MOUSE_BOX::MINY
@@ -257,7 +257,7 @@ SETBOX:
sta pos1_lo
iny
lda (ptr1),y
sta box,y
sta box,y
sta pos1_hi
; Skip one word
@@ -267,11 +267,11 @@ SETBOX:
; Set high clamp
iny
lda (ptr1),y
sta box,y
sta box,y
sta pos2_lo
iny
lda (ptr1),y
sta box,y
sta box,y
sta pos2_hi
txa

View File

@@ -19,7 +19,7 @@
.include "mli.inc"
.include "filedes.inc"
.segment "INIT"
.segment "ONCE"
raisefilelevel:
; Raise file level

View File

@@ -57,7 +57,7 @@ extern char _cwd[FILENAME_MAX];
DIR* __fastcall__ opendir (register const char* name)
DIR* __fastcall__ opendir (register const char* name)
{
register DIR* dir;

View File

@@ -45,7 +45,7 @@ ErrTab: .byte $01, ENOSYS ; Bad system call number
.byte $47, EEXIST ; Duplicate filename
.byte $48, ENOSPC ; Volume full
.byte $49, ENOSPC ; Volume directory full
; .byte $4A, EUNKNOWN ; Incompatible file format
.byte $4A, ENOEXEC ; Incompatible file format
.byte $4B, EINVAL ; Unsupported storage_type
; .byte $4C, EUNKNOWN ; End of file encountered
.byte $4D, ESPIPE ; Position out of range

View File

@@ -16,14 +16,17 @@
.include "filedes.inc"
.include "apple2.inc"
.segment "INIT"
.segment "ONCE"
initprompt:
; Set prompt <> ']' to let DOS 3.3 know that we're
; not in Applesoft immediate mode and thus keep it
; from scanning our device I/O for DOS commands.
; Set prompt <> ']' and currently executed Applesoft
; line number hibyte <> $FF to let DOS 3.3 (at $A65E)
; know that we're not in Applesoft immediate mode and
; thus keep it from scanning our device I/O for DOS
; commands.
lda #$80 ; Same value used at $D52C
sta PROMPT
sta CURLIN+1 ; Any value <> $FF will do
rts
.code

View File

@@ -10,7 +10,7 @@
_rebootafterexit := return
.segment "INIT"
.segment "ONCE"
initreboot:
; Quit to PWRUP

View File

@@ -3,7 +3,7 @@
;
.export rwprolog, rwcommon, rwepilog
.import popax
.import popax, popptr1
.include "zeropage.inc"
.include "errno.inc"
@@ -17,9 +17,7 @@ rwprolog:
stx ptr2+1
; Get and save buf
jsr popax
sta ptr1
stx ptr1+1
jsr popptr1
; Get and process fd
jsr popax

View File

@@ -44,15 +44,15 @@
.addr $0000
; Jump table
.addr INSTALL
.addr UNINSTALL
.addr OPEN
.addr CLOSE
.addr GET
.addr PUT
.addr STATUS
.addr IOCTL
.addr IRQ
.addr SER_INSTALL
.addr SER_UNINSTALL
.addr SER_OPEN
.addr SER_CLOSE
.addr SER_GET
.addr SER_PUT
.addr SER_STATUS
.addr SER_IOCTL
.addr SER_IRQ
;----------------------------------------------------------------------------
; I/O definitions
@@ -141,23 +141,23 @@ IdTableLen = * - IdValTable
.code
;----------------------------------------------------------------------------
; INSTALL: Is called after the driver is loaded into memory. If possible,
; SER_INSTALL: Is called after the driver is loaded into memory. If possible,
; check if the hardware is present. Must return an SER_ERR_xx code in a/x.
;
; Since we don't have to manage the IRQ vector on the Apple II, this is
; actually the same as:
;
; UNINSTALL: Is called before the driver is removed from memory.
; SER_UNINSTALL: Is called before the driver is removed from memory.
; No return code required (the driver is removed from memory on return).
;
; and:
;
; CLOSE: Close the port and disable interrupts. Called without parameters.
; SER_CLOSE: Close the port and disable interrupts. Called without parameters.
; Must return an SER_ERR_xx code in a/x.
INSTALL:
UNINSTALL:
CLOSE:
SER_INSTALL:
SER_UNINSTALL:
SER_CLOSE:
ldx Index ; Check for open port
beq :+
@@ -172,16 +172,16 @@ CLOSE:
rts
;----------------------------------------------------------------------------
; OPEN: A pointer to a ser_params structure is passed in ptr1.
; SER_OPEN: A pointer to a ser_params structure is passed in ptr1.
; Must return an SER_ERR_xx code in a/x.
OPEN:
SER_OPEN:
ldx #<$C000
stx ptr2
lda #>$C000
ora Slot
sta ptr2+1
; Check Pascal 1.1 Firmware Protocol ID bytes
: ldy IdOfsTable,x
lda IdValTable,x
@@ -190,7 +190,7 @@ OPEN:
inx
cpx #IdTableLen
bcc :-
; Convert slot to I/O register index
lda Slot
asl
@@ -273,11 +273,11 @@ InvBaud:lda #<SER_ERR_BAUD_UNAVAIL
rts
;----------------------------------------------------------------------------
; GET: Will fetch a character from the receive buffer and store it into the
; SER_GET: Will fetch a character from the receive buffer and store it into the
; variable pointed to by ptr1. If no data is available, SER_ERR_NO_DATA is
; returned.
GET:
SER_GET:
ldx Index
ldy SendFreeCnt ; Send data if necessary
iny ; Y == $FF?
@@ -315,10 +315,10 @@ GET:
rts
;----------------------------------------------------------------------------
; PUT: Output character in A.
; SER_PUT: Output character in A.
; Must return an SER_ERR_xx code in a/x.
PUT:
SER_PUT:
ldx Index
; Try to send
@@ -348,10 +348,10 @@ PUT:
rts
;----------------------------------------------------------------------------
; STATUS: Return the status in the variable pointed to by ptr1.
; SER_STATUS: Return the status in the variable pointed to by ptr1.
; Must return an SER_ERR_xx code in a/x.
STATUS:
SER_STATUS:
ldx Index
lda ACIA_STATUS,x
ldx #$00
@@ -360,11 +360,11 @@ STATUS:
rts
;----------------------------------------------------------------------------
; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl
; SER_IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl
; specific data in ptr1, and the ioctl code in A.
; Must return an SER_ERR_xx code in a/x.
IOCTL:
SER_IOCTL:
; Check data msb and code to be 0
ora ptr1+1
bne :+
@@ -384,12 +384,12 @@ IOCTL:
rts
;----------------------------------------------------------------------------
; IRQ: Called from the builtin runtime IRQ handler as a subroutine. All
; SER_IRQ: Called from the builtin runtime IRQ handler as a subroutine. All
; registers are already saved, no parameters are passed, but the carry flag
; is clear on entry. The routine must return with carry set if the interrupt
; was handled, otherwise with carry clear.
IRQ:
SER_IRQ:
ldx Index ; Check for open port
beq Done
lda ACIA_STATUS,x ; Check ACIA status for receive interrupt
@@ -431,7 +431,7 @@ Again: lda SendFreeCnt
lda ACIA_STATUS,x
and #$10
bne Send
bit tmp1 ; Keep trying if must try hard
bit tmp1 ; Keep trying if must try hard
bmi Again
Quit: rts

71
libsrc/apple2/settime.s Normal file
View File

@@ -0,0 +1,71 @@
;
; Oliver Schmidt, 15.08.2018
;
; int __fastcall__ clock_settime (clockid_t clk_id, const struct timespec *tp);
;
.import __dos_type
.import incsp1, return0
.include "time.inc"
.include "zeropage.inc"
.include "errno.inc"
.include "mli.inc"
_clock_settime:
; Cleanup stack
jsr incsp1 ; Preserves A
; Check for ProDOS 8
ldy __dos_type
beq enosys
; Check for realtme clock
tay ; Save A
lda MACHID
lsr a
bcs erange
tya ; Restore A
; Get tm
.assert timespec::tv_sec = 0, error
jsr _localtime
sta ptr1
stx ptr1+1
; Set date
ldy #tm::tm_mon
lda (ptr1),y
clc
adc #$01 ; Move [0..11] to [1..12]
asl
asl
asl
asl
asl
php ; Save month msb
ldy #tm::tm_mday
ora (ptr1),y
sta DATELO
ldy #tm::tm_year
lda (ptr1),y
cmp #100 ; Year since 1900 < 100?
bcc :+ ; Yes, leave alone
sbc #100 ; Move 20xx to 19xx
: plp ; Restore month msb
rol
sta DATELO+1
; Return success
jmp return0
; Load errno code
enosys: lda #ENOSYS
bne errno ; Always
; Load errno code
erange: lda #ERANGE
; Set __errno
errno: jmp __directerrno

View File

@@ -1,63 +0,0 @@
;
; Oliver Schmidt, 22.08.2006
;
; time_t _systime (void);
; /* Similar to time(), but:
; ** - Is not ISO C
; ** - Does not take the additional pointer
; ** - Does not set errno when returning -1
; */
;
.include "time.inc"
.include "zeropage.inc"
.include "mli.inc"
__systime:
; Update time
lda #GET_TIME_CALL
ldx #GET_TIME_COUNT
jsr callmli
bcs err
lda DATELO+1
lsr
php ; Save month msb
cmp #70 ; Year < 70?
bcs :+ ; No, leave alone
adc #100 ; Move 19xx to 20xx
: sta TM + tm::tm_year
lda DATELO
tax ; Save day
plp ; Restore month msb
ror
lsr
lsr
lsr
lsr
beq err ; [1..12] allows for validity check
tay
dey ; Move [1..12] to [0..11]
sty TM + tm::tm_mon
txa ; Restore day
and #%00011111
sta TM + tm::tm_mday
lda TIMELO+1
sta TM + tm::tm_hour
lda TIMELO
sta TM + tm::tm_min
lda #<TM
ldx #>TM
jmp _mktime
err: lda #$FF
tax
sta sreg
sta sreg+1
rts ; Return -1
.bss
TM: .tag tm

View File

@@ -1,9 +1,17 @@
DEPS += ../libwrk/$(TARGET)/loader.d
DEPS += ../libwrk/$(TARGET)/convert.d \
../libwrk/$(TARGET)/loader.d
../libwrk/$(TARGET)/convert.o: $(SRCDIR)/targetutil/convert.c | ../libwrk/$(TARGET)
$(COMPILE_recipe)
../libwrk/$(TARGET)/loader.o: $(SRCDIR)/targetutil/loader.s | ../libwrk/$(TARGET)
$(ASSEMBLE_recipe)
../targetutil/loader.system: ../libwrk/$(TARGET)/loader.o $(SRCDIR)/targetutil/loader.cfg | ../targetutil
../target/$(TARGET)/util/convert.system: ../libwrk/$(TARGET)/convert.o ../lib/$(TARGET).lib | ../target/$(TARGET)/util
$(LD65) -o $@ -C $(TARGET)-system.cfg $^
../target/$(TARGET)/util/loader.system: ../libwrk/$(TARGET)/loader.o $(SRCDIR)/targetutil/loader.cfg | ../target/$(TARGET)/util
$(LD65) -o $@ -C $(filter %.cfg,$^) $(filter-out %.cfg,$^)
$(TARGET): ../targetutil/loader.system
$(TARGET): ../target/$(TARGET)/util/convert.system \
../target/$(TARGET)/util/loader.system

View File

@@ -1,108 +0,0 @@
;
; Oliver Schmidt, 10.03.2004
;
; void __fastcall__ textframexy (unsigned char x, unsigned char y,
; unsigned char width, unsigned char height,
; unsigned char style);
; void __fastcall__ textframe (unsigned char width, unsigned char height,
; unsigned char style);
;
.ifdef __APPLE2ENH__
.export _textframexy, _textframe
.import popa, pusha, _gotoxy
.import chlinedirect, cvlinedirect
.include "zeropage.inc"
.include "apple2.inc"
WIDTH = tmp2
HEIGHT = tmp3
XORIGIN = tmp4
YORIGIN = ptr1
_textframexy:
sec
bra :+
_textframe:
clc
: ldx INVFLG
phx ; Save character display mode
ldx #$FF
stx INVFLG ; Set normal character display mode
pha ; Save index
jsr popa ; Get height
sta HEIGHT
jsr popa ; Get width
sta WIDTH
lda CH
ldx CV
bcc noxy
jsr popa ; Get y
tax
jsr popa ; Get x
noxy: sta XORIGIN
stx YORIGIN
plx ; Restore index
loop: lda XOFFS,x
clc
bpl :+ ; Relative to left edge?
adc WIDTH
: adc XORIGIN
jsr pusha
lda YOFFS,x
clc
bpl :+ ; Relative to top?
adc HEIGHT
: adc YORIGIN
jsr _gotoxy ; Call this one, will pop params
txa
tay
lsr ; Get bit 0 (vline) into carry
lda LENGTH,x
phx ; Save index
ldx CHAR,y
bcc hline
clc
adc HEIGHT
jsr cvlinedirect
bra next
hline: adc WIDTH
jsr chlinedirect
next: plx ; Restore index
inx
txa
and #$03 ; Mask style
bne loop
pla
sta INVFLG ; Restore character display mode
rts
.rodata
; 2 styles with 4 lines each make up 8 entries per table
; - even entry numbers mean horizontal lines
; - odd entry numbers mean vertical lines
; x offset for the line starting point
; - a positive value means relative to the frame left edge
; - a negative value menas relative to the frame right edge
XOFFS: .byte 0, 0, 0, <-2, 1, 0, 1, <-2
; y offset for the line starting point
; - a positive value means relative to the frame top
; - a negative value menas relative to the frame bottom
YOFFS: .byte 0, 1, <-2, 1, 0, 0, <-2, 0
; length of the line relative to the frame size
; - a negative value for hlines means shorter than the width
; - a negative value for vlines menas shorter than the height
LENGTH: .byte 0, <-2, 0, <-2, <-2, 0, <-2, 0
; character to use for drawing the line
; - hibit set means normal printable character
; - hibit clear means MouseText character
CHAR: .byte '_'|$80, '_', 'L', 'Z', 'L', 'Z', '_'|$80, '_'
.endif ; __APPLE2ENH__

View File

@@ -115,7 +115,6 @@ pages: .byte 2 ; Number of screens available
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
.addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
@@ -176,6 +175,10 @@ INIT:
; Switch into graphics mode
bit MIXCLR
bit HIRES
.ifdef __APPLE2ENH__
sta IOUDISON
bit DHIRESOFF
.endif
bit TXTCLR
; Beagle Bros Shape Mechanic fonts don't

View File

@@ -58,8 +58,8 @@ Y2 := ptr4
.word 48 ; Y resolution
.byte 16 ; Number of drawing colors
.byte 1 ; Number of screens available
.byte 8 ; System font X size
.byte 8 ; System font Y size
.byte 0 ; System font X size
.byte 0 ; System font Y size
.word $0198 ; Aspect ratio (based on 4/3 display)
.byte 0 ; TGI driver flags
@@ -85,7 +85,6 @@ Y2 := ptr4
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
.addr 0 ; IRQ entry is unused
; ------------------------------------------------------------------------
@@ -127,6 +126,10 @@ INIT:
bit $C082 ; Switch in ROM
jsr SETGR
bit MIXCLR
.ifdef __APPLE2ENH__
sta IOUDISON
bit DHIRESOFF
.endif
bit $C080 ; Switch in LC bank 2 for R/O
; Done, reset the error code

View File

@@ -16,7 +16,7 @@ _videomode:
; Get and save current videomode flag
bit RD80VID
php
; If we are in 80 column mode then the 80 column firmware is
; known to be active so we can just print the ctrl-char code
; (even if this only means staying in the current videomode)
@@ -29,18 +29,18 @@ _videomode:
; current state of the 80 column firmware nor want to fix it
: cmp #$11 ; Ctrl-char code for 40 cols
beq done
; If we are in 40 column mode and want to set 80 column mode
; then we first presume the 80 column firmware being already
; active and print the ctrl-char code (this causes a garbage
; char to be printed on the screen if isn't already active)
jsr COUT
; If we successfully switched to 80 column mode then the 80
; column firmware was in fact already active and we're done
bit RD80VID
bmi done
; The 80 column firmware isn't already active so we need to
; initialize it - causing the screen to be cleared and thus
; the garbage char printed above to be erased (but for some
@@ -56,13 +56,13 @@ _videomode:
; Switch in LC bank 2 for R/O
bit $C080
; Return ctrl-char code for setting previous
; videomode using the saved videomode flag
done: lda #$11 ; Ctrl-char code for 40 cols
plp
bpl :+
lda #$12 ; Ctrl-char code for 80 cols
inc a ; Ctrl-char code for 80 cols
: rts ; X was preserved all the way
.endif ; __APPLE2ENH__

60
libsrc/apple2/waitvsync.s Normal file
View File

@@ -0,0 +1,60 @@
;
; Oliver Schmidt, 2020-06-14
;
; void waitvsync (void);
;
.ifdef __APPLE2ENH__
.constructor initvsync
.export _waitvsync
.import _get_ostype
.include "apple2.inc"
.segment "ONCE"
initvsync:
jsr _get_ostype
sta ostype
rts
.code
_waitvsync:
bit ostype
bmi iigs ; $8x
bvs iic ; $4x
: bit RDVBLBAR
bpl :- ; Blanking
: bit RDVBLBAR
bmi :- ; Drawing
rts
; Apple IIgs TechNote #40, VBL Signal
iigs: bit RDVBLBAR
bmi iigs ; Blanking
: bit RDVBLBAR
bpl :- ; Drawing
rts
; Apple IIc TechNote #9, Detecting VBL
iic: sei
sta IOUDISOFF
lda RDVBLMSK
bit ENVBL
bit PTRIG ; Reset VBL interrupt flag
: bit RDVBLBAR
bpl :-
asl
bcs :+ ; VBL interrupts were already enabled
bit DISVBL
: sta IOUDISON ; IIc Tech Ref Man: The firmware normally leaves IOUDIS on.
cli
rts
.segment "INIT"
ostype: .res 1
.endif ; __APPLE2ENH__

View File

@@ -111,4 +111,4 @@ errno: jmp __directerrno
; Set __oserror
oserr: jmp __mappederrno

View File

@@ -1,15 +1,12 @@
;
; Christian Groessler, 27-Dec-2002
; Christian Groessler, 02-Apr-2019
;
.export _textcolor, _bgcolor, _bordercolor
.import return1
.export _bgcolor
.include "atari.inc"
_textcolor = return1
_bgcolor:
ldx COLOR2 ; get old value
sta COLOR2 ; set new value
@@ -23,12 +20,3 @@ bright: lda #0
txa
ldx #0 ; fix X
rts
_bordercolor:
ldx COLOR4 ; get old value
sta COLOR4 ; set new value
txa
ldx #0 ; fix X
rts

View File

@@ -0,0 +1,15 @@
;
; Christian Groessler, 02-Apr-2019
;
.export _bordercolor
.include "atari.inc"
_bordercolor:
ldx COLOR4 ; get old value
sta COLOR4 ; set new value
txa
ldx #0 ; fix X
rts

View File

@@ -1,7 +1,7 @@
;
; Christian Groessler, 27-Feb-2000
;
; void set_brk (unsigned Addr);
; void __fastcall__ set_brk (unsigned Addr);
; void reset_brk (void);
;
@@ -63,7 +63,7 @@ L1: lda #<brk_handler ; Set the break vector to our routine
lda #$00
sta oldvec ; Clear the old vector
stx oldvec+1
@L9: rts
@L9: rts
.endproc

View File

@@ -13,7 +13,7 @@
.import start
.export _cas_init
.segment "INIT"
.segment "ONCE"
_cas_init:
.ifdef DEBUG

View File

@@ -6,19 +6,18 @@
;
.export _cclearxy, _cclear
.import popa, _gotoxy, cputdirect
.import gotoxy, cputdirect
.importzp tmp1
_cclearxy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _cclear
_cclear:
cmp #0 ; Is the length zero?
beq L9 ; Jump if done
sta tmp1
sta tmp1
L1: lda #0 ; Blank - screen code
jsr cputdirect ; Direct output
dec tmp1

View File

@@ -6,9 +6,9 @@
;
.include "atari.inc"
.export _cgetc,setcursor
.export _cgetc
.import setcursor
.import KEYBDV_handler
.import cursor,mul40
_cgetc:
jsr setcursor
@@ -29,43 +29,3 @@ _cgetc:
pha
rts
.endif
.proc setcursor
ldy #0
lda OLDCHR
sta (OLDADR),y
lda ROWCRS
jsr mul40
clc
adc SAVMSC ; add start of screen memory
sta OLDADR
txa
adc SAVMSC+1
sta OLDADR+1
lda COLCRS
adc OLDADR
sta OLDADR
bcc nc
inc OLDADR+1
nc: lda (OLDADR),y
sta OLDCHR
ldx cursor ; current cursor setting as requested by the user
beq off
ldx #0
beq cont
off: inx
cont: stx CRSINH ; update system variable
beq turnon
and #$7f ; clear high bit / inverse flag
finish: sta (OLDADR),y ; update on-screen display
rts
turnon: ora #$80 ; set high bit / inverse flag
bne finish
.endproc

View File

@@ -6,19 +6,14 @@
;
.export _chlinexy, _chline
.import popa, _gotoxy, cputdirect, setcursor
.import gotoxy, cputdirect, setcursor
.importzp tmp1
.ifdef __ATARI5200__
CHRCODE = 14
.else
CHRCODE = $12+64
.endif
_chlinexy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length
_chline:

View File

@@ -3,7 +3,7 @@
; originally by Ullrich von Bassewitz and Sidney Cadot
;
; clock_t clock (void);
; unsigned _clocks_per_sec (void);
; clock_t _clocks_per_sec (void);
;
.export _clock, __clocks_per_sec
@@ -30,8 +30,10 @@
.proc __clocks_per_sec
ldx #$00 ; Clear high byte of return value
lda PAL ; use hw register, PALNTS is only supported on XL/XE ROM
ldx #$00 ; Clear byte 1 of return value
stx sreg ; Clear byte 2 of return value
stx sreg+1 ; Clear byte 3 of return value
lda PAL ; Use hw register, PALNTS is only supported on XL/XE ROM
and #$0e
bne @NTSC
lda #50

View File

@@ -1,5 +1,5 @@
;
; Mark Keates, Christian Groessler
; Mark Keates, Christian Groessler, Piotr Fusik
;
; void cputcxy (unsigned char x, unsigned char y, char c);
; void cputc (char c);
@@ -7,7 +7,7 @@
.export _cputcxy, _cputc
.export plot, cputdirect, putchar
.import popa, _gotoxy, mul40
.import gotoxy, _mul40
.importzp tmp4,ptr4
.import _revflag,setcursor
@@ -15,8 +15,7 @@
_cputcxy:
pha ; Save C
jsr popa ; Get Y
jsr _gotoxy ; Set cursor, drop x
jsr gotoxy ; Set cursor, drop x and y
pla ; Restore C
_cputc:
@@ -31,16 +30,13 @@ L4: cmp #$0A ; LF
cmp #ATEOL ; Atari-EOL?
beq newline
tay
rol a
rol a
rol a
rol a
and #3
tax
tya
and #$9f
ora ataint,x
asl a ; shift out the inverse bit
adc #$c0 ; grab the inverse bit; convert ATASCII to screen code
bpl codeok ; screen code ok?
eor #$40 ; needs correction
codeok: lsr a ; undo the shift
bcc cputdirect
eor #$80 ; restore the inverse bit
cputdirect: ; accepts screen code
jsr putchar
@@ -75,8 +71,7 @@ putchar:
sta (OLDADR),y
lda ROWCRS
jsr mul40 ; destroys tmp4
clc
jsr _mul40 ; destroys tmp4, carry is cleared
adc SAVMSC ; add start of screen memory
sta ptr4
txa
@@ -90,6 +85,3 @@ putchar:
ldy COLCRS
sta (ptr4),y
jmp setcursor
.rodata
ataint: .byte 64,0,32,96

View File

@@ -9,12 +9,14 @@
;
.export __STARTUP__ : absolute = 1 ; Mark as startup
.export _exit, start
.export _exit, start, excexit, SP_save
.export __LMARGN_save ; original LMARGN setting
.import initlib, donelib
.import callmain, zerobss
.import __RESERVED_MEMORY__
.import __RAM_START__, __RAM_SIZE__
.import __MAIN_START__, __MAIN_SIZE__
.import __LOWCODE_RUN__, __LOWCODE_SIZE__
.ifdef __ATARIXL__
.import __STACKSIZE__
.import sram_init
@@ -55,19 +57,19 @@ start:
.ifdef __ATARIXL__
lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
lda #<(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
ldx #>(__MAIN_START__ + __MAIN_SIZE__ + __STACKSIZE__)
sta sp
lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
sta sp+1
stx sp+1
.else
; Report the memory usage.
lda APPMHI
ldx APPMHI+1
sta APPMHI_save ; remember old APPMHI value
lda APPMHI+1
sta APPMHI_save+1
stx APPMHI_save+1
sec
lda MEMTOP
@@ -81,14 +83,10 @@ start:
.endif
; Call the module constructors.
jsr initlib
; Set the left margin to 0.
lda LMARGN
sta LMARGN_save
sta __LMARGN_save
ldy #0
sty LMARGN
@@ -103,22 +101,26 @@ start:
dey ; Set Y to $FF
sty CH ; remove keypress which might be in the input buffer
; Call the module constructors.
jsr initlib
; Push the command-line arguments; and, call main().
jsr callmain
; Call the module destructors. This is also the exit() entry.
_exit: jsr donelib ; Run module destructors
_exit: ldx SP_save
txs ; Restore stack pointer
; Restore the system stuff.
ldx SP_save
txs ; Restore stack pointer
excexit:jsr donelib ; Run module destructors; 'excexit' is called from the exec routine
; Restore the left margin.
lda LMARGN_save
lda __LMARGN_save
sta LMARGN
; Restore the kb mode.
@@ -129,9 +131,9 @@ _exit: jsr donelib ; Run module destructors
; Restore APPMHI.
lda APPMHI_save
ldx APPMHI_save+1
sta APPMHI
lda APPMHI_save+1
sta APPMHI+1
stx APPMHI+1
.ifdef __ATARIXL__
@@ -142,9 +144,9 @@ _exit: jsr donelib ; Run module destructors
lda RAMTOP_save
sta RAMTOP
lda MEMTOP_save
ldx MEMTOP_save+1
sta MEMTOP
lda MEMTOP_save+1
sta MEMTOP+1
stx MEMTOP+1
; Issue a GRAPHICS 0 call (copied'n'pasted from the TGI drivers), in
@@ -195,7 +197,15 @@ _exit: jsr donelib ; Run module destructors
SP_save: .res 1
SHFLOK_save: .res 1
LMARGN_save: .res 1
__LMARGN_save: .res 1
.ifndef __ATARIXL__
APPMHI_save: .res 2
.endif
; ------------------------------------------------------------------------
.segment "LOWCODE" ; have at least one (empty) segment of LOWCODE, so that the next line works even if the program doesn't make use of this segment
.assert (__LOWCODE_RUN__ + __LOWCODE_SIZE__ <= $4000 || __LOWCODE_RUN__ > $7FFF || __LOWCODE_SIZE__ = 0), warning, "'lowcode area' reaches into $4000..$7FFF bank memory window"
; check for LOWBSS_SIZE = 0 not needed since the only file which uses LOWBSS (irq.s) also uses LOWCODE
; check for LOWCODE_RUN > $7FFF is mostly for cartridges, where this segment is loaded high (into cart ROM)
; there is a small chance that if the user loads the program really high, LOWCODE is above $7FFF, but LOWBSS is below -- no warning emitted in this case

View File

@@ -1,301 +1,156 @@
; ctype.s
;
; Ullrich von Bassewitz, 02.06.1998
; This file is part of
; cc65 - a freeware C compiler for 6502 based systems
;
; Character specification table.
; https://cc65.github.io
;
; adapted to Atari by Christian Groessler, June 2000
; See "LICENSE" file for legal information.
;
; Atari character specification table.
;
.include "ctypetable.inc"
.export __ctypeidx
; The tables are readonly, put them into the rodata segment
.rodata
; The following 256 byte wide table specifies attributes for the isxxx type
; of functions. Doing it by a table means some overhead in space, but it
; has major advantages:
;
; * It is fast. If it were'nt for the slow parameter passing of cc65, one
; could even define macros for the isxxx functions (this is usually
; done on other platforms).
;
; * It is highly portable. The only unportable part is the table itself,
; all real code goes into the common library.
;
; * We save some code in the isxxx functions.
;
;
; Bit assignments:
;
; 0 - Lower case char
; 1 - Upper case char
; 2 - Numeric digit
; 3 - Hex digit (both, lower and upper)
; 4 - Control character
; 5 - The space character itself
; 6 - Other whitespace (that is: '\f', '\n', '\r', '\t' and '\v')
; 7 - Space or tab character
__ctypeidx:
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 0/00 ___heart____, 1/01 ___l_tee____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 2/02 ___ctrl_B___, 3/03 ___ctrl_C___
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 4/04 ___r_tee____, 5/05 ___ctrl_E___
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 6/06 ___ctrl_F___, 7/07 ___ctrl_G___
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 8/08 ___ctrl_H___, 9/09 ___ctrl_I___
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 10/0a ___ctrl_J___, 11/0b ___ctrl_K___
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 12/0c ___ctrl_L___, 13/0d ___ctrl_M___
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 14/0e ___ctrl_N___, 15/0f ___ctrl_O___
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 16/10 ____club____, 17/11 ___ctrl_Q___
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 18/12 ___h_line___, 19/13 ___ctrl_S___
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 20/14 ____ball____, 21/15 ___ctrl_U___
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 22/16 ___ctrl_V___, 23/17 ___t_tee____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 24/18 ___b_tee____, 25/19 ___ctrl_Y___
ct_mix CT_NONE_IDX, CT_CTRL_IDX ; 26/1a ___ctrl_Z___, 27/1b ____ESC_____
ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 28/1c ___crsr_up__, 29/1d ___crsr_dn__
ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 30/1e ___crsr_lf__, 31/1f ___crsr_rg__
.export __ctype
ct_mix CT_SPACE_SPACETAB_IDX, CT_NONE_IDX ; 32/20 ___SPACE___, 33/21 _____!_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 34/22 _____"_____, 35/23 _____#_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 36/24 _____$_____, 37/25 _____%_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 38/26 _____&_____, 39/27 _____'_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 40/28 _____(_____, 41/29 _____)_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 42/2a _____*_____, 43/2b _____+_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 44/2c _____,_____, 45/2d _____-_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 46/2e _____._____, 47/2f _____/_____
ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 48/30 _____0_____, 49/31 _____1_____
ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 50/32 _____2_____, 51/33 _____3_____
ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 52/34 _____4_____, 53/35 _____5_____
ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 54/36 _____6_____, 55/37 _____7_____
ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 56/38 _____8_____, 57/39 _____9_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 58/3a _____:_____, 59/3b _____;_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 60/3c _____<_____, 61/3d _____=_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 62/3e _____>_____, 63/3f _____?_____
__ctype:
.byte $00 ; 0/00 ___heart____
.byte $00 ; 1/01 ___l_tee____
.byte $00 ; 2/02 ___ctrl_B___
.byte $00 ; 3/03 ___ctrl_C___
.byte $00 ; 4/04 ___r_tee____
.byte $00 ; 5/05 ___ctrl_E___
.byte $00 ; 6/06 ___ctrl_F___
.byte $00 ; 7/07 ___ctrl_G___
.byte $00 ; 8/08 ___ctrl_H___
.byte $00 ; 9/09 ___ctrl_I___
.byte $00 ; 10/0a ___ctrl_J___
.byte $00 ; 11/0b ___ctrl_K___
.byte $00 ; 12/0c ___ctrl_L___
.byte $00 ; 13/0d ___ctrl_M___
.byte $00 ; 14/0e ___ctrl_N___
.byte $00 ; 15/0f ___ctrl_O___
.byte $00 ; 16/10 ____club____
.byte $00 ; 17/11 ___ctrl_Q___
.byte $00 ; 18/12 ___h_line___
.byte $00 ; 19/13 ___ctrl_S___
.byte $00 ; 20/14 ____ball____
.byte $00 ; 21/15 ___ctrl_U___
.byte $00 ; 22/16 ___ctrl_V___
.byte $00 ; 23/17 ___t_tee____
.byte $00 ; 24/18 ___b_tee____
.byte $00 ; 25/19 ___ctrl_Y___
.byte $00 ; 26/1a ___ctrl_Z___
.byte $10 ; 27/1b ____ESC_____
.byte $10 ; 28/1c ___crsr_up__
.byte $10 ; 29/1d ___crsr_dn__
.byte $10 ; 30/1e ___crsr_lf__
.byte $10 ; 31/1f ___crsr_rg__
.byte $A0 ; 32/20 ___SPACE___
.byte $00 ; 33/21 _____!_____
.byte $00 ; 34/22 _____"_____
.byte $00 ; 35/23 _____#_____
.byte $00 ; 36/24 _____$_____
.byte $00 ; 37/25 _____%_____
.byte $00 ; 38/26 _____&_____
.byte $00 ; 39/27 _____'_____
.byte $00 ; 40/28 _____(_____
.byte $00 ; 41/29 _____)_____
.byte $00 ; 42/2a _____*_____
.byte $00 ; 43/2b _____+_____
.byte $00 ; 44/2c _____,_____
.byte $00 ; 45/2d _____-_____
.byte $00 ; 46/2e _____._____
.byte $00 ; 47/2f _____/_____
.byte $0C ; 48/30 _____0_____
.byte $0C ; 49/31 _____1_____
.byte $0C ; 50/32 _____2_____
.byte $0C ; 51/33 _____3_____
.byte $0C ; 52/34 _____4_____
.byte $0C ; 53/35 _____5_____
.byte $0C ; 54/36 _____6_____
.byte $0C ; 55/37 _____7_____
.byte $0C ; 56/38 _____8_____
.byte $0C ; 57/39 _____9_____
.byte $00 ; 58/3a _____:_____
.byte $00 ; 59/3b _____;_____
.byte $00 ; 60/3c _____<_____
.byte $00 ; 61/3d _____=_____
.byte $00 ; 62/3e _____>_____
.byte $00 ; 63/3f _____?_____
ct_mix CT_NONE_IDX, CT_UPPER_XDIGIT_IDX ; 64/40 _____@_____, 65/41 _____A_____
ct_mix CT_UPPER_XDIGIT_IDX, CT_UPPER_XDIGIT_IDX ; 66/42 _____B_____, 67/43 _____C_____
ct_mix CT_UPPER_XDIGIT_IDX, CT_UPPER_XDIGIT_IDX ; 68/44 _____D_____, 69/45 _____E_____
ct_mix CT_UPPER_XDIGIT_IDX, CT_UPPER_IDX ; 70/46 _____F_____, 71/47 _____G_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 72/48 _____H_____, 73/49 _____I_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 74/4a _____J_____, 75/4b _____K_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 76/4c _____L_____, 77/4d _____M_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 78/4e _____N_____, 79/4f _____O_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 80/50 _____P_____, 81/51 _____Q_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 82/52 _____R_____, 83/53 _____S_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 84/54 _____T_____, 85/55 _____U_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 86/56 _____V_____, 87/57 _____W_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 88/58 _____X_____, 89/59 _____Y_____
ct_mix CT_UPPER_IDX, CT_NONE_IDX ; 90/5a _____Z_____, 91/5b _____[_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 92/5c _____\_____, 93/5d _____]_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 94/5e _____^_____, 95/5f _UNDERLINE_
.byte $00 ; 64/40 _____@_____
.byte $0A ; 65/41 _____A_____
.byte $0A ; 66/42 _____B_____
.byte $0A ; 67/43 _____C_____
.byte $0A ; 68/44 _____D_____
.byte $0A ; 69/45 _____E_____
.byte $0A ; 70/46 _____F_____
.byte $02 ; 71/47 _____G_____
.byte $02 ; 72/48 _____H_____
.byte $02 ; 73/49 _____I_____
.byte $02 ; 74/4a _____J_____
.byte $02 ; 75/4b _____K_____
.byte $02 ; 76/4c _____L_____
.byte $02 ; 77/4d _____M_____
.byte $02 ; 78/4e _____N_____
.byte $02 ; 79/4f _____O_____
.byte $02 ; 80/50 _____P_____
.byte $02 ; 81/51 _____Q_____
.byte $02 ; 82/52 _____R_____
.byte $02 ; 83/53 _____S_____
.byte $02 ; 84/54 _____T_____
.byte $02 ; 85/55 _____U_____
.byte $02 ; 86/56 _____V_____
.byte $02 ; 87/57 _____W_____
.byte $02 ; 88/58 _____X_____
.byte $02 ; 89/59 _____Y_____
.byte $02 ; 90/5a _____Z_____
.byte $00 ; 91/5b _____[_____
.byte $00 ; 92/5c _____\_____
.byte $00 ; 93/5d _____]_____
.byte $00 ; 94/5e _____^_____
.byte $00 ; 95/5f _UNDERLINE_
.byte $00 ; 96/60 __diamond__
.byte $09 ; 97/61 _____a_____
.byte $09 ; 98/62 _____b_____
.byte $09 ; 99/63 _____c_____
.byte $09 ; 100/64 _____d_____
.byte $09 ; 101/65 _____e_____
.byte $09 ; 102/66 _____f_____
.byte $01 ; 103/67 _____g_____
.byte $01 ; 104/68 _____h_____
.byte $01 ; 105/69 _____i_____
.byte $01 ; 106/6a _____j_____
.byte $01 ; 107/6b _____k_____
.byte $01 ; 108/6c _____l_____
.byte $01 ; 109/6d _____m_____
.byte $01 ; 110/6e _____n_____
.byte $01 ; 111/6f _____o_____
.byte $01 ; 112/70 _____p_____
.byte $01 ; 113/71 _____q_____
.byte $01 ; 114/72 _____r_____
.byte $01 ; 115/73 _____s_____
.byte $01 ; 116/74 _____t_____
.byte $01 ; 117/75 _____u_____
.byte $01 ; 118/76 _____v_____
.byte $01 ; 119/77 _____w_____
.byte $01 ; 120/78 _____x_____
.byte $01 ; 121/79 _____y_____
.byte $01 ; 122/7a _____z_____
.byte $00 ; 123/7b ___spade___
.byte $00 ; 124/7c __v_line___
.byte $10 ; 125/7d __CLRSCR___
.byte $D0 ; 126/7e __backtab__
.byte $D0 ; 127/7f ____tab____
ct_mix CT_NONE_IDX, CT_LOWER_XDIGIT_IDX ; 96/60 __diamond__, 97/61 _____a_____
ct_mix CT_LOWER_XDIGIT_IDX, CT_LOWER_XDIGIT_IDX ; 98/62 _____b_____, 99/63 _____c_____
ct_mix CT_LOWER_XDIGIT_IDX, CT_LOWER_XDIGIT_IDX ; 100/64 _____d_____, 101/65 _____e_____
ct_mix CT_LOWER_XDIGIT_IDX, CT_LOWER_IDX ; 102/66 _____f_____, 103/67 _____g_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 104/68 _____h_____, 105/69 _____i_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 106/6a _____j_____, 107/6b _____k_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 108/6c _____l_____, 109/6d _____m_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 110/6e _____n_____, 111/6f _____o_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 112/70 _____p_____, 113/71 _____q_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 114/72 _____r_____, 115/73 _____s_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 116/74 _____t_____, 117/75 _____u_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 118/76 _____v_____, 119/77 _____w_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 120/78 _____x_____, 121/79 _____y_____
ct_mix CT_LOWER_IDX, CT_NONE_IDX ; 122/7a _____z_____, 123/7b ___spade___
ct_mix CT_NONE_IDX, CT_CTRL_IDX ; 124/7c __v_line___, 125/7d __CLRSCR___
ct_mix CT_CTRL_WS_SPACETAB_IDX, CT_CTRL_WS_SPACETAB_IDX
; 126/7e __backtab__, 127/7f ____tab____
.byte $00 ; 128/80 _inv_heart___
.byte $00 ; 129/81 _inv_l_tee___
.byte $00 ; 130/82 _inv_ctrl_B__
.byte $00 ; 131/83 _inv_ctrl_C__
.byte $00 ; 132/84 _inv_r_tee___
.byte $00 ; 133/85 _inv_ctrl_E__
.byte $00 ; 134/86 _inv_ctrl_F__
.byte $00 ; 135/87 _inv_ctrl_G__
.byte $00 ; 136/88 _inv_ctrl_H__
.byte $00 ; 137/89 _inv_ctrl_I__
.byte $00 ; 138/8a _inv_ctrl_J__
.byte $00 ; 139/8b _inv_ctrl_K__
.byte $00 ; 140/8c _inv_ctrl_L__
.byte $00 ; 141/8d _inv_ctrl_M__
.byte $00 ; 142/8e _inv_ctrl_N__
.byte $00 ; 143/8f _inv_ctrl_O__
.byte $00 ; 144/90 __inv__club__
.byte $00 ; 145/91 _inv_ctrl_Q__
.byte $00 ; 146/92 _inv_h_line__
.byte $00 ; 147/93 _inv_ctrl_S__
.byte $00 ; 148/94 __inv__ball__
.byte $00 ; 149/95 _inv_ctrl_U__
.byte $00 ; 150/96 _inv_ctrl_V__
.byte $00 ; 151/97 __inv_t_tee__
.byte $00 ; 152/98 __inv_b_tee__
.byte $00 ; 153/99 _inv_ctrl_Y__
.byte $00 ; 154/9a _inv_ctrl_Z__
.byte $50 ; 155/9b _____EOL_____
.byte $10 ; 156/9c ___CLRLINE___
.byte $10 ; 157/9d ___INSLINE___
.byte $10 ; 158/9e ____CLRTAB___
.byte $10 ; 159/9f ____INSTAB___
.byte $A0 ; 160/a0 __inv_SPACE__
.byte $00 ; 161/a1 ___inv_!_____
.byte $00 ; 162/a2 ___inv_"_____
.byte $00 ; 163/a3 ___inv_#_____
.byte $00 ; 164/a4 ___inv_$_____
.byte $00 ; 165/a5 ___inv_%_____
.byte $00 ; 166/a6 ___inv_&_____
.byte $00 ; 167/a7 ___inv_'_____
.byte $00 ; 168/a8 ___inv_(_____
.byte $00 ; 169/a9 ___inv_)_____
.byte $00 ; 170/aa ___inv_*_____
.byte $00 ; 171/ab ___inv_+_____
.byte $00 ; 172/ac ___inv_,_____
.byte $00 ; 173/ad ___inv_-_____
.byte $00 ; 174/ae ___inv_._____
.byte $00 ; 175/af ___inv_/_____
.byte $0C ; 176/b0 ___inv_0_____
.byte $0C ; 177/b1 ___inv_1_____
.byte $0C ; 178/b2 ___inv_2_____
.byte $0C ; 179/b3 ___inv_3_____
.byte $0C ; 180/b4 ___inv_4_____
.byte $0C ; 181/b5 ___inv_5_____
.byte $0C ; 182/b6 ___inv_6_____
.byte $0C ; 183/b7 ___inv_7_____
.byte $0C ; 184/b8 ___inv_8_____
.byte $0C ; 185/b9 ___inv_9_____
.byte $00 ; 186/ba ___inv_:_____
.byte $00 ; 187/bb ___inv_;_____
.byte $00 ; 188/bc ___inv_<_____
.byte $00 ; 189/bd ___inv_=_____
.byte $00 ; 190/be ___inv_>_____
.byte $00 ; 191/bf ___inv_?_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 128/80 _inv_heart___, 129/81 _inv_l_tee___
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 130/82 _inv_ctrl_B__, 131/83 _inv_ctrl_C__
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 132/84 _inv_r_tee___, 133/85 _inv_ctrl_E__
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 134/86 _inv_ctrl_F__, 135/87 _inv_ctrl_G__
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 136/88 _inv_ctrl_H__, 137/89 _inv_ctrl_I__
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 138/8a _inv_ctrl_J__, 139/8b _inv_ctrl_K__
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 140/8c _inv_ctrl_L__, 141/8d _inv_ctrl_M__
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 142/8e _inv_ctrl_N__, 143/8f _inv_ctrl_O__
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 144/90 __inv__club__, 145/91 _inv_ctrl_Q__
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 146/92 _inv_h_line__, 147/93 _inv_ctrl_S__
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 148/94 __inv__ball__, 149/95 _inv_ctrl_U__
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 150/96 _inv_ctrl_V__, 151/97 __inv_t_tee__
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 152/98 __inv_b_tee__, 153/99 _inv_ctrl_Y__
ct_mix CT_NONE_IDX, CT_CTRL_WS_IDX ; 154/9a _inv_ctrl_Z__, 155/9b _____EOL_____
ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 156/9c ___CLRLINE___, 157/9d ___INSLINE___
ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 158/9e ____CLRTAB___, 159/9f ____INSTAB___
.byte $00 ; 192/c0 ___inv_@_____
.byte $0A ; 193/c1 ___inv_A_____
.byte $0A ; 194/c2 ___inv_B_____
.byte $0A ; 195/c3 ___inv_C_____
.byte $0A ; 196/c4 ___inv_D_____
.byte $0A ; 197/c5 ___inv_E_____
.byte $0A ; 198/c6 ___inv_F_____
.byte $02 ; 199/c7 ___inv_G_____
.byte $02 ; 200/c8 ___inv_H_____
.byte $02 ; 201/c9 ___inv_I_____
.byte $02 ; 202/ca ___inv_J_____
.byte $02 ; 203/cb ___inv_K_____
.byte $02 ; 204/cc ___inv_L_____
.byte $02 ; 205/cd ___inv_M_____
.byte $02 ; 206/ce ___inv_N_____
.byte $02 ; 207/cf ___inv_O_____
.byte $02 ; 208/d0 ___inv_P_____
.byte $02 ; 209/d1 ___inv_Q_____
.byte $02 ; 210/d2 ___inv_R_____
.byte $02 ; 211/d3 ___inv_S_____
.byte $02 ; 212/d4 ___inv_T_____
.byte $02 ; 213/d5 ___inv_U_____
.byte $02 ; 214/d6 ___inv_V_____
.byte $02 ; 215/d7 ___inv_W_____
.byte $02 ; 216/d8 ___inv_X_____
.byte $02 ; 217/d9 ___inv_Y_____
.byte $02 ; 218/da ___inv_Z_____
.byte $00 ; 219/db ___inv_[_____
.byte $00 ; 220/dc ___inv_\_____
.byte $00 ; 221/dd ___inv_]_____
.byte $00 ; 222/de ___inv_^_____
.byte $00 ; 223/df _inv_UNDRLIN_
.byte $00 ; 224/e0 _inv_diamond_
.byte $09 ; 225/e1 ___inv_a_____
.byte $09 ; 226/e2 ___inv_b_____
.byte $09 ; 227/e3 ___inv_c_____
.byte $09 ; 228/e4 ___inv_d_____
.byte $09 ; 229/e5 ___inv_e_____
.byte $09 ; 230/e6 ___inv_f_____
.byte $01 ; 231/e7 ___inv_g_____
.byte $01 ; 232/e8 ___inv_h_____
.byte $01 ; 233/e9 ___inv_i_____
.byte $01 ; 234/ea ___inv_j_____
.byte $01 ; 235/eb ___inv_k_____
.byte $01 ; 236/ec ___inv_l_____
.byte $01 ; 237/ed ___inv_m_____
.byte $01 ; 238/ee ___inv_n_____
.byte $01 ; 239/ef ___inv_o_____
.byte $01 ; 240/f0 ___inv_p_____
.byte $01 ; 241/f1 ___inv_q_____
.byte $01 ; 242/f2 ___inv_r_____
.byte $01 ; 243/f3 ___inv_s_____
.byte $01 ; 244/f4 ___inv_t_____
.byte $01 ; 245/f5 ___inv_u_____
.byte $01 ; 246/f6 ___inv_v_____
.byte $01 ; 247/f7 ___inv_w_____
.byte $01 ; 248/f8 ___inv_x_____
.byte $01 ; 249/f9 ___inv_y_____
.byte $01 ; 250/fa ___inv_z_____
.byte $00 ; 251/fb __inv_spade__
.byte $00 ; 252/fc __inv_v_line_
.byte $10 ; 253/fd ____BEEP_____
.byte $10 ; 254/fe ____DELBS____
.byte $10 ; 255/ff ___INSERT____
ct_mix CT_SPACE_SPACETAB_IDX, CT_NONE_IDX ; 160/a0 __inv_SPACE__, 161/a1 ___inv_!_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 162/a2 ___inv_"_____, 163/a3 ___inv_#_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 164/a4 ___inv_$_____, 165/a5 ___inv_%_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 166/a6 ___inv_&_____, 167/a7 ___inv_'_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 168/a8 ___inv_(_____, 169/a9 ___inv_)_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 170/aa ___inv_*_____, 171/ab ___inv_+_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 172/ac ___inv_,_____, 173/ad ___inv_-_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 174/ae ___inv_._____, 175/af ___inv_/_____
ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 176/b0 ___inv_0_____, 177/b1 ___inv_1_____
ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 178/b2 ___inv_2_____, 179/b3 ___inv_3_____
ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 180/b4 ___inv_4_____, 181/b5 ___inv_5_____
ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 182/b6 ___inv_6_____, 183/b7 ___inv_7_____
ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 184/b8 ___inv_8_____, 185/b9 ___inv_9_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 186/ba ___inv_:_____, 187/bb ___inv_;_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 188/bc ___inv_<_____, 189/bd ___inv_=_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 190/be ___inv_>_____, 191/bf ___inv_?_____
ct_mix CT_NONE_IDX, CT_UPPER_XDIGIT_IDX ; 192/c0 ___inv_@_____, 193/c1 ___inv_A_____
ct_mix CT_UPPER_XDIGIT_IDX, CT_UPPER_XDIGIT_IDX ; 194/c2 ___inv_B_____, 195/c3 ___inv_C_____
ct_mix CT_UPPER_XDIGIT_IDX, CT_UPPER_XDIGIT_IDX ; 196/c4 ___inv_D_____, 197/c5 ___inv_E_____
ct_mix CT_UPPER_XDIGIT_IDX, CT_UPPER_IDX ; 198/c6 ___inv_F_____,199/c7 ___inv_G_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 200/c8 ___inv_H_____, 201/c9 ___inv_I_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 202/ca ___inv_J_____, 203/cb ___inv_K_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 204/cc ___inv_L_____, 205/cd ___inv_M_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 206/ce ___inv_N_____, 207/cf ___inv_O_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 208/d0 ___inv_P_____, 209/d1 ___inv_Q_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 210/d2 ___inv_R_____, 211/d3 ___inv_S_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 212/d4 ___inv_T_____, 213/d5 ___inv_U_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 214/d6 ___inv_V_____, 215/d7 ___inv_W_____
ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 216/d8 ___inv_X_____, 217/d9 ___inv_Y_____
ct_mix CT_UPPER_IDX, CT_NONE_IDX ; 218/da ___inv_Z_____, 219/db ___inv_[_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 220/dc ___inv_\_____, 221/dd ___inv_]_____
ct_mix CT_NONE_IDX, CT_NONE_IDX ; 222/de ___inv_^_____, 223/df _inv_UNDRLIN_
ct_mix CT_NONE_IDX, CT_LOWER_XDIGIT_IDX ; 224/e0 _inv_diamond_, 225/e1 ___inv_a_____
ct_mix CT_LOWER_XDIGIT_IDX, CT_LOWER_XDIGIT_IDX ; 226/e2 ___inv_b_____, 227/e3 ___inv_c_____
ct_mix CT_LOWER_XDIGIT_IDX, CT_LOWER_XDIGIT_IDX ; 228/e4 ___inv_d_____, 229/e5 ___inv_e_____
ct_mix CT_LOWER_XDIGIT_IDX, CT_LOWER_IDX ; 230/e6 ___inv_f_____, 231/e7 ___inv_g_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 232/e8 ___inv_h_____, 233/e9 ___inv_i_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 234/ea ___inv_j_____, 235/eb ___inv_k_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 236/ec ___inv_l_____, 237/ed ___inv_m_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 238/ee ___inv_n_____, 239/ef ___inv_o_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 240/f0 ___inv_p_____, 241/f1 ___inv_q_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 242/f2 ___inv_r_____, 243/f3 ___inv_s_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 244/f4 ___inv_t_____, 245/f5 ___inv_u_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 246/f6 ___inv_v_____, 247/f7 ___inv_w_____
ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 248/f8 ___inv_x_____, 249/f9 ___inv_y_____
ct_mix CT_LOWER_IDX, CT_NONE_IDX ; 250/fa ___inv_z_____, 251/fb __inv_spade__
ct_mix CT_NONE_IDX, CT_CTRL_IDX ; 252/fc __inv_v_line_, 253/fd ____BEEP_____
ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 254/fe ____DELBS____, 255/ff ___INSERT____

View File

@@ -5,21 +5,16 @@
; void cvline (unsigned char length);
;
.include "atari.inc"
.export _cvlinexy, _cvline
.import popa, _gotoxy, putchar, setcursor
.import gotoxy, putchar, setcursor
.importzp tmp1
.ifdef __ATARI5200__
CHRCODE = 1 ; exclamation mark
.else
CHRCODE = $7C ; Vertical bar
.endif
_cvlinexy:
pha ; Save the length
jsr popa ; Get y
jsr _gotoxy ; Call this one, will pop params
jsr gotoxy ; Call this one, will pop params
pla ; Restore the length and run into _cvline
_cvline:

View File

@@ -17,16 +17,14 @@
.export _dio_log_to_phys
.include "atari.inc"
.importzp ptr1,ptr2,ptr3
.import popax,__oserror
.import popax,popptr1,__oserror
.proc _dio_log_to_phys
sta ptr2
stx ptr2+1 ; pointer to output structure
jsr popax
sta ptr1
stx ptr1+1 ; save pointer to input data
jsr popptr1 ; save pointer to input data
jsr popax
sta ptr3

View File

@@ -137,7 +137,7 @@ _dio_open:
iny
lda #1
finish: sta (ptr2),y ; set default sector size
finish: sta (ptr2),y ; set default sector size
fini2: lda ptr2
ldx ptr2+1
rts

View File

@@ -12,7 +12,7 @@
.proc _dio_query_sectsize
sta ptr1 ; handle
stx ptr1+1
stx ptr1+1
lda #0
sta __oserror

20
libsrc/atari/doesclrscr.s Normal file
View File

@@ -0,0 +1,20 @@
;
; Christian Groessler, June-2016
;
; unsigned char doesclrscrafterexit (void);
;
; returns 0/1 if after program termination the screen isn't/is cleared
;
.export _doesclrscrafterexit
.import __is_cmdline_dos
.import return1
.ifdef __ATARIXL__
_doesclrscrafterexit = return1 ; the c65 runtime always clears the screen at program termination
.else
_doesclrscrafterexit:
jsr __is_cmdline_dos ; currently (unless a DOS behaving differently is popping up)
eor #$01 ; we can get by with the inverse of __is_cmdline_dos
rts
.endif

View File

@@ -11,7 +11,7 @@
; ------------------------------------------------------------------------
; DOS type detection
.segment "INIT"
.segment "ONCE"
detect: lda DOS
cmp #'S' ; SpartaDOS
@@ -20,6 +20,8 @@ detect: lda DOS
beq mydos
cmp #'X' ; XDOS
beq xdos
cmp #'R' ; RealDOS
beq rdos
lda #$4C ; probably default
ldy #COMTAB
@@ -33,21 +35,35 @@ detect: lda DOS
cmp (DOSVEC),y
beq done
lda #OSADOS
bne set
spdos: lda DOS+3 ; 'B' in BW-DOS
cmp #'B'
bne spdos_real
lda DOS+4 ; 'W' in BW-DOS
cmp #'W'
bne spdos_real
lda #BWDOS
.byte $2C ; BIT <abs>
spdos: lda #SPARTADOS
spdos_real:
lda #SPARTADOS
.byte $2C ; BIT <abs>
mydos: lda #MYDOS
.byte $2C ; BIT <abs>
rdos: lda #REALDOS
.byte $2C ; BIT <abs>
xdos: lda #XDOS
sta __dos_type
set: sta __dos_type
done: rts
; ------------------------------------------------------------------------
; Data
.bss
.data
__dos_type: .res 1 ; default to ATARIDOS
__dos_type: .byte ATARIDOS; default to ATARIDOS

View File

@@ -11,7 +11,7 @@
; Bit 2: bank control
; Bit 1: BASIC on/off
; Bit 0: OS RAM on/off
;
;
; Masks: %11100011 $E3 Bank 0
; %11100111 $E7 Bank 1
; %11101011 $EB Bank 2
@@ -67,7 +67,7 @@
; Constants
BANK = $4000 ; bank window
STACK = $0100 ; stack location
STACK = $0100 ; stack location
PAGES = 256 ; 4 x 16k banks
@@ -93,17 +93,17 @@ stacktest: sei
@2: sta $4000 ; restore
cli
rts
stacktest_end:
stacktest_end:
stackcopy: sei ; disable interrupts
@1: dex ; pre-decrement (full page x=0)
ldy #$FF ; this will be replaced STACK+3
sty $D301 ; set bank
sty $D301 ; set bank
lda $FF00,x ; address to copy from STACK+8,+9
ldy #$FF ; this will be replaced STACK+11
sty $D301
sty $D301
sta $FF00,x ; address to copy to STACK+16,+17
cpx #0
cpx #0
bne @1
ldy #$FF ; portb_save STACK+23
sty $D301
@@ -122,7 +122,7 @@ stackcopy_byte: sei
sty $D301
cli
rts
stackcopy_byte_end:
stackcopy_byte_end:
.data
@@ -186,14 +186,14 @@ setpage:
INSTALL:
lda $D301 ; save state of portb
sta portb_save
tay
tay
jsr install_test ; doesn't touch Y
sty STACK+13
lda $4000 ; test for extended memory
jsr STACK
bcs @1
bcs @1
lda #EM_ERR_OK
rts
@1: lda #EM_ERR_NO_DEVICE
@@ -242,7 +242,7 @@ MAP: jsr setpage ; extract the bank/page
lda banks,x
sta STACK+3 ; set bank to copy from
; lda ptr1
; sta STACK+8
; sta STACK+8
lda ptr1+1
sta STACK+9 ; set copy from address
lda portb_save
@@ -251,10 +251,10 @@ MAP: jsr setpage ; extract the bank/page
lda ptr2
sta STACK+16
lda ptr2+1
sta STACK+17 ; set copy to address
sta STACK+17 ; set copy to address
ldx #0 ; full page copy
jsr STACK ; do the copy!
jsr STACK ; do the copy!
; Return the memory window
@@ -298,7 +298,7 @@ COMMIT: lda curpage ; Get the current page
sta STACK+3 ; set bank to copy from
sta STACK+23 ; set final portb restore
lda ptr1
sta STACK+8
sta STACK+8
lda ptr1+1
sta STACK+9 ; set copy from address
ldx curbank
@@ -307,10 +307,10 @@ COMMIT: lda curpage ; Get the current page
;lda ptr2
;sta STACK+16
lda ptr2+1
sta STACK+17 ; set copy to address
sta STACK+17 ; set copy to address
ldx #0 ; full page copy
jsr STACK ; do the copy!
jsr STACK ; do the copy!
commit_done:
rts
@@ -329,7 +329,7 @@ COPYFROM:
ldy #EM_COPY::OFFS
lda (ptr3),y
sta STACK+7 ; offset goes into BANK low
sta STACK+7 ; offset goes into BANK low
ldy #EM_COPY::PAGE
lda (ptr3),y
@@ -357,9 +357,9 @@ COPYFROM:
add #>BANK ; add to BANK address
sta STACK+8 ; current page in bank
ldx curbank
lda banks,x
sta STACK+2 ; set bank in stack
lda portb_save
lda banks,x
sta STACK+2 ; set bank in stack
lda portb_save
sta STACK+10 ; set bank restore in stack
sta STACK+18 ; set final restore too
@@ -399,7 +399,7 @@ copyfrom_copy:
bne @3
inc STACK+16
@3: jmp copyfrom_copy ; copy another byte
@3: jmp copyfrom_copy ; copy another byte
done:
rts
@@ -418,7 +418,7 @@ COPYTO:
ldy #EM_COPY::OFFS
lda (ptr3),y
sta STACK+15 ; offset goes into BANK low
sta STACK+15 ; offset goes into BANK low
ldy #EM_COPY::PAGE
lda (ptr3),y
@@ -446,9 +446,9 @@ COPYTO:
add #>BANK ; add to BANK address
sta STACK+16 ; current page in bank
ldx curbank
lda banks,x
sta STACK+10 ; set bank in stack
lda portb_save
lda banks,x
sta STACK+10 ; set bank in stack
lda portb_save
sta STACK+2 ; set bank restore in stack
sta STACK+18 ; set final restore too
@@ -488,5 +488,5 @@ copyto_copy:
bne @3
inc STACK+8
@3: jmp copyto_copy ; copy another byte
@3: jmp copyto_copy ; copy another byte

211
libsrc/atari/exec.s Normal file
View File

@@ -0,0 +1,211 @@
;
; Christian Groessler, 12-Jun-2016
;
; int __fastcall__ exec (const char* progname, const char* cmdline);
;
; supports only XDOS at the moment
.export _exec
.import popax
.import __dos_type
.import findfreeiocb
.import incsp2
.import excexit ; from crt0.s
.import SP_save ; from crt0.s
.ifdef UCASE_FILENAME
.import ucase_fn
.import addysp
.endif
.include "zeropage.inc"
.include "errno.inc"
.include "atari.inc"
; area $0100 to $0128 might be in use (e.g. Hias' high speed patch)
CMDLINE_BUFFER = $0129 ; put progname + cmdline as one single string there
; alternatively:
;CMDLINE_BUFFER = $0480 ; put progname + cmdline as one single string there
CMDLINE_MAX = 40+3 ; max. length of drive + progname + cmdline
.code
notsupp:lda #ENOSYS ; "unsupported system call"
.byte $2C ; bit opcode, eats the next 2 bytes
noiocb: lda #EMFILE ; "too many open files"
jsr incsp2 ; clean up stack
seterr: jmp __directerrno
; entry point
_exec:
; save cmdline
sta ptr3
stx ptr3+1
ldy __dos_type
cpy #XDOS
bne notsupp
jsr findfreeiocb
bne noiocb
stx tmp4 ; remember IOCB index
; get program name
jsr popax
.ifdef UCASE_FILENAME
.ifdef DEFAULT_DEVICE
ldy #$80
.else
ldy #$00
.endif
sty tmp2 ; set flag for ucase_fn
jsr ucase_fn
bcc ucok1
invret: lda #EINVAL ; file name is too long
bne seterr
ucok1:
.endif ; defined UCASE_FILENAME
; copy program name and arguments to CMDLINE_BUFFER
sta ptr4 ; ptr4: pointer to program name
stx ptr4+1
ldy #0
; TODO: check stack ptr and and use min(CMDLINE_MAX,available_stack)
copyp: lda (ptr4),y
beq copypd
sta CMDLINE_BUFFER,y
iny
cpy #CMDLINE_MAX
bne copyp
; programe name too long
beq invret
.ifndef UCASE_FILENAME
invret: lda #EINVAL
bne seterr
.endif
; file name copied, check for args
copypd: tya ; put Y into X (index into CMDLINE_BUFFER)
tax
lda ptr3
ora ptr3+1 ; do we have arguments?
beq copycd ; no
ldy #0
lda (ptr3),y ; get first byte of cmdline parameter
beq copycd ; nothing there...
lda #' ' ; add a space btw. progname and cmdline
bne copyc1
; copy args
copyc: lda (ptr3),y
beq copycd
iny
copyc1: sta CMDLINE_BUFFER,x
inx
cpx #CMDLINE_MAX
bne copyc
; progname + arguments too long
beq invret
invexe: jsr close
lda #XNTBIN
bne setmerr
copycd: lda #ATEOL
sta CMDLINE_BUFFER,x
; open the program file, read the first two bytes and compare them to $FF
ldx tmp4 ; get IOCB index
lda ptr4 ; ptr4 points to progname
sta ICBAL,x
lda ptr4+1
sta ICBAH,x
lda #OPNIN ; open for input
sta ICAX1,x
lda #OPEN
sta ICCOM,x
jsr CIOV
tya
.ifdef UCASE_FILENAME
ldy tmp3 ; get size
jsr addysp ; free used space on the stack
; the following 'bpl' depends on 'addysp' restoring A as last command before 'rts'
.endif ; defined UCASE_FILENAME
bpl openok
pha ; remember error code
jsr close ; close the IOCB (required even if open failed)
pla ; put error code back into A
setmerr:jmp __mappederrno ; update errno from OS specific error code in A
openok: lda #>buf
sta ICBAH,x ; set buffer address
lda #<buf
sta ICBAL,x
lda #0 ; set buffer length
sta ICBLH,x
lda #2
sta ICBLL,x
lda #GETCHR ; iocb command code
sta ICCOM,x
jsr CIOV ; read it
bmi invexe ; read operation failed, return error
lda ICBLL,x ; # of bytes read
cmp #2
bne invexe
lda #$FF ; check file format (need $FFFF at the beginning)
cmp buf
bne invexe
cmp buf+1
bne invexe
jsr close ; close program file
; program file appears to be available and good
; here's the point of no return
ldx SP_save
txs ; reset stack pointer to what it was at program entry
lda tmp4 ; get IOCB index
pha ; and save it ('excexit' calls destructors and they might destroy tmp4)
jsr excexit ; on atarixl this will enable the ROM again, making all high variables inaccessible
pla
tax ; IOCB index in X
lda #<CMDLINE_BUFFER
sta ICBAL,x ; address
lda #>CMDLINE_BUFFER
sta ICBAH,x
lda #0
sta ICBLL,x ; length shouldn't be random, but 0 is ok
sta ICBLH,x
sta ICAX1,x
sta ICAX2,x
lda #80 ; XDOS: run DUP command
sta ICCOM,x
jmp CIOV_org ; no way to display an error message in case of failure, and we will return to DOS
; close IOCB, index in X
.proc close
lda #CLOSE
sta ICCOM,x
jmp CIOV ; close IOCB
.endproc
.bss
buf: .res 2

View File

@@ -1,11 +1,11 @@
; This file defines the EXE header and main chunk load header for Atari executables
.export __EXEHDR__: absolute = 1
.import __RAM_START__, __BSS_LOAD__
.import __MAIN_START__, __BSS_LOAD__
.segment "EXEHDR"
.word $FFFF
.segment "MAINHDR"
.word __RAM_START__
.word __MAIN_START__
.word __BSS_LOAD__ - 1

View File

@@ -7,6 +7,8 @@
; startup code but is nevertheless included in the compiled program when
; needed.
; XDOS support added 05/2016 by Christian Groessler
MAXARGS = 16 ; max. amount of arguments in arg. table
CL_SIZE = 64 ; command line buffer size
SPACE = 32 ; SPACE char.
@@ -20,30 +22,32 @@ SPACE = 32 ; SPACE char.
; --------------------------------------------------------------------------
; Get command line
.segment "INIT"
.segment "ONCE"
nargdos:rts
initmainargs:
lda #0
sta __argc
sta __argc+1
sta __argv
sta __argv+1
lda __dos_type ; which DOS?
cmp #ATARIDOS
beq nargdos ; DOS does not support arguments
cmp #MYDOS
bne argdos ; DOS supports arguments
nargdos:rts
cmp #MAX_DOS_WITH_CMDLINE + 1
bcs nargdos
; Initialize ourcl buffer
argdos: lda #ATEOL
sta ourcl+CL_SIZE
argdos: ldy #ATEOL
sty ourcl+CL_SIZE
; Move SpartaDOS command line to our own buffer
; Move SpartaDOS/XDOS command line to our own buffer
lda DOSVEC
cmp #XDOS
bne sparta
lda #<XLINE
sta ptr1
lda #>XLINE
sta ptr1+1
bne cpcl0
sparta: lda DOSVEC
clc
adc #<LBUF
sta ptr1
@@ -51,7 +55,7 @@ argdos: lda #ATEOL
adc #>LBUF
sta ptr1+1
ldy #0
cpcl0: ldy #0
cpcl: lda (ptr1),y
sta ourcl,y
iny
@@ -120,7 +124,7 @@ eopar:
finargs:
lda __argc
asl
asl
tax
lda #0
sta argv,x
@@ -134,7 +138,7 @@ finargs:
; --------------------------------------------------------------------------
; Data
.bss
.segment "INIT"
argv: .res (1 + MAXARGS) * 2

View File

@@ -3,7 +3,11 @@
;
; function to get default device: char *_getdefdev(void);
;
; SpartaDOS:
; AtariDOS/MyDOS:
; Default device number is derived from DUNIT. Therefore "default
; device" is the one the program was loaded from.
;
; SpartaDOS/RealDOS:
; the ZCRNAME routine is only used to get the default drive because
; ZCRNAME has two disadvantages:
; 1. It will convert D: into D1: instead of Dn: (n = default drive)
@@ -27,10 +31,10 @@
__getdefdev:
lda __dos_type ; which DOS?
cmp #ATARIDOS
beq finish
cmp #MYDOS
beq finish
cmp #XDOS
beq xdos ; XDOS detected
; cmp #OSADOS+1 ; (redundant: #OSADOS+1 = #XDOS)
bcs use_DUNIT ; neither XDOS, nor OS/A+ or SpartaDOS
ldy #BUFOFF
lda #0
@@ -60,7 +64,7 @@ __getdefdev:
lda (DOSVEC),y
sta crvec+2
crvec: jsr $FFFF ; will be set to crunch vector
jsr crvec
; Get default device
@@ -69,7 +73,7 @@ crvec: jsr $FFFF ; will be set to crunch vector
sta __defdev
iny
lda (DOSVEC),y
sta __defdev+1
done: sta __defdev+1
; Return pointer to default device
@@ -77,9 +81,43 @@ finish: lda #<__defdev
ldx #>__defdev
rts
; On AtariDOS or MyDOS, use the DUNIT variable to setup the default
; device. The default device will then be the one the program was
; loaded from.
use_DUNIT:
lda DUNIT
clc
adc #'0'
bne done ; jump always
; XDOS default device retrieval
xdos:
; check XDOS version (we need >= 2.4)
lda XGLIN
cmp #$4C ; there needs to be a 'JMP' opcode here
bne finish ; older version, use DEFAULT_DEVICE or D1:
lda XVER ; get BCD encoded version ($24 for 2.4)
cmp #$24
bcc finish ; too old, below 2.4
; good XDOS version, get default drive
lda #ATEOL
sta XLINE ; simulate empty command line
ldy #0
jsr XMOVE ; create an FMS filename (which in this case only contains the drive)
lda XFILE+1
bne done
.data
; Default device
crvec: jmp $FFFF ; target address will be set to crunch vector
; Default device string
__defdev:
.ifdef DEFAULT_DEVICE
@@ -87,4 +125,3 @@ __defdev:
.else
.byte "D1:", 0
.endif

78
libsrc/atari/getdevice.s Normal file
View File

@@ -0,0 +1,78 @@
;
; Oliver Schmidt, 2012-09-04
; Christian Groessler, 2017-12-28
;
; unsigned char getfirstdevice (void);
; unsigned char __fastcall__ getnextdevice (unsigned char device);
;
.include "atari.inc"
.export _getfirstdevice
.export _getnextdevice
MAX_DIO_DEVICES = 8
;------------------------------------------------------------------------------
; _getfirstdevice
_getfirstdevice:
lda #$FF
; Fall through
;------------------------------------------------------------------------------
; _getnextdevice
_getnextdevice:
tax
next: inx
cpx #MAX_DIO_DEVICES
beq none
jsr check_device
bmi next
done: txa
ldx #$00
rts
none: ldx #255 ; INVALID_DEVICE (see include/device.h)
bne done ; jump always
;------------------------------------------------------------------------------
; check_device - checks if a disk device is present
; input: X - device id (0 = D1, 1 = D2, ...)
; output: NF - 0/1 for detected/not detected
; X register preserved
check_device:
txa
pha
lda #SIO_STAT
sta DCOMND ; set command into DCB
lda #%01000000 ; direction value, "receive data"
sta DSTATS ; set data flow directon
lda #15
sta DTIMLO ; value got from DOS source
lda #4
sta DAUX1 ; set sector # (dummy: 4)
sta DBYTLO ; # of bytes to transfer
lda #0
sta DAUX2
sta DBYTHI
lda #>DVSTAT
sta DBUFHI
lda #<DVSTAT
sta DBUFLO ; set buffer address into DCB
lda #DISKID ; SIO bus ID of diskette drive
sta DDEVIC
inx
stx DUNIT ; unit number (1-based)
jsr SIOV ; execute SIO command
pla
tax
lda DSTATS
rts
.end

51
libsrc/atari/getres.s Normal file
View File

@@ -0,0 +1,51 @@
;
; Oliver Schmidt, 15.8.2018
; Christian Groessler, 27.9.2018
;
; int __fastcall__ clock_getres (clockid_t clk_id, struct timespec *res);
;
.include "atari.inc"
.include "time.inc"
.include "errno.inc"
.importzp ptr1
.import incsp1, return0, __dos_type
;----------------------------------------------------------------------------
.code
_clock_getres:
sta ptr1
stx ptr1+1
; Cleanup stack
jsr incsp1
; Check for SpartaDOS-X 4.40 or newer
ldy #SPARTADOS
cpy __dos_type
bne enosys
ldy SDX_VERSION
cpy #$44
bcc enosys
ldy #.sizeof(timespec)-1
@L1: lda time,y
sta (ptr1),y
dey
bpl @L1
jmp return0
enosys: lda #ENOSYS
; Set __errno
jmp __directerrno
;----------------------------------------------------------------------------
; timespec struct with tv_sec set to 1 second
.rodata
time: .dword 1
.dword 0

114
libsrc/atari/gettime.s Normal file
View File

@@ -0,0 +1,114 @@
;
; Oliver Schmidt, 14.08.2018
; Christian Groessler, 25.09.2018
;
; int __fastcall__ clock_gettime (clockid_t clk_id, struct timespec *tp);
;
.import pushax, steaxspidx, incsp1, incsp3, return0
.import __dos_type
.import sdxtry
.include "time.inc"
.include "zeropage.inc"
.include "errno.inc"
.include "atari.inc"
_clock_gettime:
jsr pushax
; clear tp
sta ptr1
stx ptr1+1
lda #$00
ldy #.sizeof(timespec)-1
: sta (ptr1),y
dey
bpl :-
; only supported on SpartaDOS-X >= 4.40
lda #SPARTADOS
cmp __dos_type
bne notsupp
lda SDX_VERSION
cmp #$44
bcc notsupp
; get date/time from system (SD-X call)
; see settime.s for reasons of using sdxtry
lda #0 ; init loop count (256)
sta sdxtry
try_get:lda #SDX_CLK_DEV ; CLK device
sta SDX_DEVICE
ldy #SDX_KD_GETTD ; GETTD function
jsr SDX_KERNEL ; do the call
bcc done
dec sdxtry
bne try_get
lda #EBUSY
bne errexit
; fill timespec
; date
done: lda SDX_DATE ; mday
sta TM + tm::tm_mday
ldx SDX_DATE+1 ; month
dex
stx TM + tm::tm_mon
lda SDX_DATE+2 ; year
cmp #79 ; 1979: the Atari 800 came out
bcs :+
adc #100 ; adjust century
: sta TM + tm::tm_year
; time
lda SDX_TIME
sta TM + tm::tm_hour
lda SDX_TIME+1
sta TM + tm::tm_min
lda SDX_TIME+2
sta TM + tm::tm_sec
; make time_t
lda #<TM
ldx #>TM
jsr _mktime
; store tv_sec into output tp struct
ldy #timespec::tv_sec
jsr steaxspidx
; cleanup stack
jsr incsp1
; return success
jmp return0
; load errno code
notsupp:lda #ENOSYS
; cleanup stack
errexit:jsr incsp3 ; Preserves A
; set __errno
jmp __directerrno
; -------
.bss
TM: .tag tm

View File

@@ -6,14 +6,17 @@
.include "atari.inc"
.export _gotoxy
.export gotoxy, _gotoxy
.import popa
.import setcursor
gotoxy:
jsr popa ; Get Y
_gotoxy: ; Set the cursor position
sta ROWCRS ; Set Y
jsr popa ; Get X
sta COLCRS ; Set X
lda #0
sta COLCRS+1 ;
sta COLCRS+1
jmp setcursor

View File

@@ -13,9 +13,11 @@
; ------------------------------------------------------------------------
.segment "INIT"
.segment "ONCE"
initirq:
lda #$4C ; JMP opcode
sta IRQInd
lda VVBLKD
ldx VVBLKD+1
sta IRQInd+1
@@ -45,17 +47,22 @@ IRQStub:
.ifdef CHARGEN_RELOC
lda CHBAS
pha
.endif
.endif
lda PORTB
pha
and #$FE
sta PORTB ; disable ROM
.ifdef __ATARIXL__
and #$FE ; disable ROM
.endif
ora #$10 ; map main memory into $4000..$7FFF area
sta PORTB
.ifdef __ATARIXL__
set_chbase >__CHARGEN_START__
.endif
jsr callirq ; Call the functions
.ifdef __ATARIXL__
pla
sta PORTB ; restore old ROM setting
sta PORTB ; restore old memory settings
.ifdef __ATARIXL__
.ifdef CHARGEN_RELOC
pla
sta CHBAS
@@ -66,6 +73,8 @@ IRQStub:
; ------------------------------------------------------------------------
.data
.segment "LOWBSS"
IRQInd: jmp $0000
IRQInd: .res 3
.end

View File

@@ -0,0 +1,18 @@
;
; Christian Groessler, May-2016
;
; unsigned char _is_cmdline_dos(void);
;
; returns 0 for non-commandline DOS, 1 for commandline DOS
;
.export __is_cmdline_dos
.import __dos_type
.include "atari.inc"
__is_cmdline_dos:
lda #MAX_DOS_WITH_CMDLINE
cmp __dos_type
lda #0
rol a
rts

View File

@@ -35,24 +35,12 @@
.addr $0000
; Button state masks (8 values)
.byte $02 ; JOY_UP
.byte $04 ; JOY_DOWN
.byte $08 ; JOY_LEFT
.byte $10 ; JOY_RIGHT
.byte $01 ; JOY_FIRE
.byte $00 ; JOY_FIRE2 not available
.byte $00 ; Future expansion
.byte $00 ; Future expansion
; Jump table.
.addr INSTALL
.addr UNINSTALL
.addr COUNT
.addr READJOY
.addr 0 ; IRQ entry not used
; ------------------------------------------------------------------------
; Constants
@@ -107,6 +95,8 @@ COUNT:
;
READJOY:
and #JOY_COUNT-1 ; fix joystick number
tax ; Joystick number into X
asl a
asl a
asl a
@@ -115,10 +105,21 @@ READJOY:
; Read joystick
lda PORTA ; get position
and #%00001111
lda STRIG0 ; get button
asl a
ora TRIG0 ; add button information
eor #%00011111
ldx #0 ; fix X
asl a
asl a
asl a
ora PORTA ; add position information
eor #$1F
cmp oldval,x
beq :+
sta oldval,x
ldx #0
stx ATRACT ; we have interaction, disable "attract mode"
: ldx #0 ; fix X
rts
.bss
oldval: .res JOY_COUNT

View File

@@ -34,24 +34,12 @@
.addr $0000
; Button state masks (8 values)
.byte $01 ; JOY_UP
.byte $02 ; JOY_DOWN
.byte $04 ; JOY_LEFT
.byte $08 ; JOY_RIGHT
.byte $10 ; JOY_FIRE
.byte $00 ; JOY_FIRE2 not available
.byte $00 ; Future expansion
.byte $00 ; Future expansion
; Jump table.
.addr INSTALL
.addr UNINSTALL
.addr COUNT
.addr READJOY
.addr 0 ; IRQ entry not used
; ------------------------------------------------------------------------
; Constants
@@ -105,8 +93,8 @@ _400800:
;
READJOY:
and #3 ; fix joystick number
tax ; Joystick number (0-3) into X
and #JOY_COUNT-1 ; fix joystick number
tax ; Joystick number into X
; Read joystick
@@ -117,5 +105,14 @@ READJOY:
asl a
ora STICK0,x ; add position information
eor #$1F
ldx #0 ; fix X
cmp oldval,x
beq :+
sta oldval,x
ldx #0
stx ATRACT ; we have interaction, disable "attract mode"
: ldx #0 ; fix X
rts
.bss
oldval: .res JOY_COUNT

View File

@@ -2,14 +2,8 @@
; Oliver Schmidt, 2013-05-31
;
.export em_libref, joy_libref, tgi_libref
.export em_libref, joy_libref
.import _exit
em_libref := _exit
joy_libref := _exit
.ifdef __ATARIXL__
.import CIO_handler
tgi_libref := CIO_handler
.else
tgi_libref := _exit
.endif

View File

@@ -176,7 +176,7 @@ seek: jsr ldax0sp ; get lower word of new offset
.endproc
; check, whether seeking is supported
; check whether seeking is supported
; tmp3: iocb
; X: index into fd_table
;
@@ -194,8 +194,12 @@ chk_supp:
; do the test
lda __dos_type
cmp #SPARTADOS
beq :+
cmp #BWDOS
beq :+
cmp #REALDOS
bne ns1
txa
: txa
pha
lda DOS+1 ; get SpartaDOS version
cmp #$40

View File

@@ -180,7 +180,7 @@ update_colors:
; ------------------------------------------------------------------------
.segment "INIT"
.segment "ONCE"
pm_init:
lda #0

View File

@@ -12,7 +12,7 @@
.export _mouse_txt_callbacks
.importzp tmp4
.import mul40,loc_tmp
.import _mul40
.importzp mouse_txt_char ; screen code of mouse cursor
.include "atari.inc"
@@ -74,7 +74,7 @@ prep:
jsr getcursor ; Get character at cursor position
cmp #mouse_txt_char ; "mouse" character
bne overwr ; no, probably program has overwritten it
lda backup ;
lda backup ;
jmp setcursor ; Draw character
overwr: sta backup
rts
@@ -104,22 +104,15 @@ movex:
; Move the mouse cursor y position to the value in A/X.
movey:
tax
ldy tmp4 ; mul40 uses tmp4
lda loc_tmp ; and this local variable
pha
txa ; get parameter back
ldy tmp4 ; mul40 uses tmp4, save in Y
lsr a ; convert y position to character line
lsr a
lsr a
jsr mul40
clc
jsr _mul40 ; carry is cleared by _mul40
adc SAVMSC
sta scrptr
txa
adc SAVMSC+1
sta scrptr+1
pla
sta loc_tmp
sty tmp4
sty tmp4 ; restore tmp4
rts

View File

@@ -89,6 +89,8 @@ YMin: .res 2 ; Y1 value of bounding box
XMax: .res 2 ; X2 value of bounding box
YMax: .res 2 ; Y2 value of bounding box
Buttons: .res 1 ; Button mask
OldDir: .res 1 ; previous direction bits
OldButton: .res 1 ; previous buttons
Temp: .res 1 ; Temporary value used in the int handler
@@ -336,9 +338,24 @@ IRQ:
jsr CPREP
; Check if user activity occurred, and if yes, disable "attract mode"
lda Buttons
cmp OldButton
beq @ChkDir
sta OldButton
lda #0
sta ATRACT ; disable "attract mode"
@ChkDir:lda Temp
cmp OldDir
beq @ChkCnt
sta OldDir
lda #0
sta ATRACT
; Check left/right
lda Temp ; Read joystick #0
@ChkCnt:lda Temp ; Read joystick #0
and #(JOY::LEFT | JOY::RIGHT)
beq @SkipX ;
@@ -437,4 +454,3 @@ IRQ:
@SkipY: jsr CDRAW
clc ; Interrupt not "handled"
rts

View File

@@ -126,6 +126,7 @@ YMin: .res 2 ; Y1 value of bounding box
XMax: .res 2 ; X2 value of bounding box
YMax: .res 2 ; Y2 value of bounding box
Buttons: .res 1 ; Button mask
OldButton: .res 1 ; previous buttons
XPosWrk: .res 2
YPosWrk: .res 2
@@ -133,6 +134,7 @@ YPosWrk: .res 2
irq_enabled: .res 1 ; flag indicating that the high frequency polling interrupt is enabled
old_porta_vbi: .res 1 ; previous PORTA value of the VBI interrupt (IRQ)
how_long: .res 1 ; counter for how many VBI interrupts the mouse hasn't been moved
in_irq: .res 1 ; flag indicating high-frequency polling interrupt is active
.if .defined (AMIGA_MOUSE) .or .defined (ST_MOUSE)
dumx: .res 1
@@ -144,11 +146,11 @@ oldval: .res 1
.endif
.ifndef __ATARIXL__
OldT1: .res 2
OldT2: .res 2
.else
.data
set_VTIMR1_handler:
set_VTIMR2_handler:
.byte $4C, 0, 0
.endif
@@ -225,29 +227,29 @@ INSTALL:
; Setup pointer to wrapper install/deinstall function.
lda libref
sta set_VTIMR1_handler+1
sta set_VTIMR2_handler+1
lda libref+1
sta set_VTIMR1_handler+2
sta set_VTIMR2_handler+2
; Install my handler.
sec
lda #<T1Han
ldx #>T1Han
jsr set_VTIMR1_handler
lda #<T2Han
ldx #>T2Han
jsr set_VTIMR2_handler
.else
lda VTIMR1
sta OldT1
lda VTIMR1+1
sta OldT1+1
lda VTIMR2
sta OldT2
lda VTIMR2+1
sta OldT2+1
php
sei
lda #<T1Han
sta VTIMR1
lda #>T1Han
sta VTIMR1+1
lda #<T2Han
sta VTIMR2
lda #>T2Han
sta VTIMR2+1
plp
.endif
@@ -256,20 +258,12 @@ INSTALL:
sta AUDCTL
lda #0
sta AUDC1
sta AUDC2
lda #15
sta AUDF1
sta AUDF2
sta STIMER
.if 0 ; the IRQ will now be dynamically enabled when the mouse is moved
lda POKMSK
ora #%00000001 ; timer 1 enable
sta POKMSK
sta IRQEN
sta irq_enabled
.endif
lda PORTA
and #$0f
sta old_porta_vbi
@@ -289,23 +283,23 @@ UNINSTALL:
; uninstall timer irq routine
lda POKMSK
and #%11111110 ; timer 1 disable
and #%11111101 ; timer 2 disable
sta IRQEN
sta POKMSK
.ifdef __ATARIXL__
clc
jsr set_VTIMR1_handler
jsr set_VTIMR2_handler
.else
php
sei
lda OldT1
sta VTIMR1
lda OldT1+1
sta VTIMR1+1
lda OldT2
sta VTIMR2
lda OldT2+1
sta VTIMR2+1
plp
.endif
@@ -496,11 +490,13 @@ IRQ: lda PORTA ; mouse port contents
cmp old_porta_vbi
beq @L3 ; no motion
lda #0
sta ATRACT ; disable "attract mode"
; Turn mouse polling IRQ back on
lda POKMSK
ora #%00000001 ; timer 1 enable
ora #%00000010 ; timer 2 enable
sta POKMSK
sta IRQEN
sta irq_enabled
@@ -530,7 +526,7 @@ IRQ: lda PORTA ; mouse port contents
sta irq_enabled
lda POKMSK
and #%11111110 ; timer 1 disable
and #%11111101 ; timer 2 disable
sta IRQEN
sta POKMSK
@@ -544,25 +540,34 @@ IRQ: lda PORTA ; mouse port contents
jsr CPREP
; Disable "attract mode" if button status has changed
lda Buttons
cmp OldButton
beq @L5
sta OldButton
lda #0
sta ATRACT
; Limit the X coordinate to the bounding box
lda XPosWrk+1
@L5: lda XPosWrk+1
ldy XPosWrk
tax
cpy XMin
sbc XMin+1
bpl @L5
bpl @L6
ldy XMin
ldx XMin+1
jmp @L6
jmp @L7
@L5: txa
@L6: txa
cpy XMax
sbc XMax+1
bmi @L6
bmi @L7
ldy XMax
ldx XMax+1
@L6: sty XPos
@L7: sty XPos
stx XPos+1
tya
jsr CMOVEX
@@ -574,18 +579,18 @@ IRQ: lda PORTA ; mouse port contents
tax
cpy YMin
sbc YMin+1
bpl @L7
bpl @L8
ldy YMin
ldx YMin+1
jmp @L8
jmp @L9
@L7: txa
@L8: txa
cpy YMax
sbc YMax+1
bmi @L8
bmi @L9
ldy YMax
ldx YMax+1
@L8: sty YPos
@L9: sty YPos
stx YPos+1
tya
jsr CMOVEY
@@ -595,10 +600,10 @@ IRQ: lda PORTA ; mouse port contents
.ifdef DEBUG
; print on upper right corner 'E' or 'D', indicating the IRQ is enabled or disabled
ldy irq_enabled
beq @L9
beq @L10
lda #37 ; screen code for 'E'
.byte $2c ; bit opcode, eats next 2 bytes
@L9: lda #36 ; screen code for 'D'
@L10: lda #36 ; screen code for 'D'
ldy #39
sta (SAVMSC),y
.endif
@@ -608,13 +613,18 @@ IRQ: lda PORTA ; mouse port contents
;----------------------------------------------------------------------------
; T1Han: Local IRQ routine to poll mouse
; T2Han: Local IRQ routine to poll mouse
;
T1Han: lda CRITIC ; if CRITIC flag is set, disable the
T2Han: lda CRITIC ; if CRITIC flag is set, disable the
bne disable_me ; high frequency polling IRQ, in order
; not to interfere with SIO I/O (e.g.
; floppy access)
; floppy access or serial I/O)
lda in_irq ; handler entered again?
bne skip ; yes, ignore this interrupt
inc in_irq
cli ; enable IRQs so that we don't block them for too long
tya
pha
@@ -791,6 +801,8 @@ mmexit: sty oldval
tax
pla
tay
dec in_irq
skip:
.ifdef __ATARIXL__
rts
.else
@@ -807,7 +819,7 @@ mmexit: sty oldval
disable_me:
lda POKMSK
and #%11111110 ; timer 1 disable
and #%11111101 ; timer 2 disable
sta IRQEN
sta POKMSK
lda #0

View File

@@ -88,6 +88,7 @@ YMin: .res 2 ; Y1 value of bounding box
XMax: .res 2 ; X2 value of bounding box
YMax: .res 2 ; Y2 value of bounding box
Buttons: .res 1 ; Button mask
OldButton: .res 1 ; previous buttons
; Default values for above variables
@@ -337,10 +338,19 @@ IRQ:
ora Buttons
sta Buttons
; Check if button status changed, and disable "attract mode" if yes
@L02: lda Buttons
cmp OldButton
beq @L03
sta OldButton
lda #0
sta ATRACT
; If we read 228 for X or Y positions, we assume the user has lifted the pen
; and don't change the cursor position.
@L02: lda PADDL0
@L03: lda PADDL0
cmp #228
beq @Cont ; CF set if equal
lda PADDL1
@@ -350,12 +360,13 @@ IRQ:
jsr CPREP
plp ; restore CF
bcc @L03
bcc @L04
jmp @Show
@L03: ldx #0
@L04: ldx #0
stx XPos+1
stx YPos+1
stx ATRACT ; disable "attract mode"
; Get cursor position
; -------------------
@@ -382,9 +393,9 @@ IRQ:
clc
adc XPos
sta XPos
bcc @L04
bcc @L05
inc XPos+1
@L04: txa
@L05: txa
lsr a ; port value / 4
lsr a ; port value / 8
tax
@@ -393,18 +404,18 @@ IRQ:
stx XPos
sbc XPos
sta XPos
bcs @L05
bcs @L06
dec XPos+1
@L05: txa
@L06: txa
lsr a ; port value / 16
lsr a ; port value / 32
clc
adc XPos
sta XPos
bcc @L06
bcc @L07
inc XPos+1
@L06: tay
@L07: tay
lda XPos+1
tax
@@ -412,18 +423,18 @@ IRQ:
cpy XMin
sbc XMin+1
bpl @L07
bpl @L08
ldy XMin
ldx XMin+1
jmp @L08
@L07: txa
jmp @L09
@L08: txa
cpy XMax
sbc XMax+1
bmi @L08
bmi @L09
ldy XMax
ldx XMax+1
@L08: sty XPos
@L09: sty XPos
stx XPos+1
; Move the mouse pointer to the new X pos
@@ -456,18 +467,18 @@ IRQ:
cpy YMin
sbc YMin+1
bpl @L09
bpl @L10
ldy YMin
ldx YMin+1
jmp @L10
@L09: txa
jmp @L11
@L10: txa
cpy YMax
sbc YMax+1
bmi @L10
bmi @L11
ldy YMax
ldx YMax+1
@L10: sty YPos
@L11: sty YPos
stx YPos+1
; Move the mouse pointer to the new X pos
@@ -479,4 +490,3 @@ IRQ:
clc ; Interrupt not "handled"
rts

View File

@@ -5,8 +5,8 @@
.export mouse_libref
.ifdef __ATARIXL__
.import set_VTIMR1_handler
mouse_libref := set_VTIMR1_handler
.import set_VTIMR2_handler
mouse_libref := set_VTIMR2_handler
.else
.import _exit
mouse_libref := _exit

View File

@@ -1,35 +0,0 @@
;
; Christian Groessler, June 2000
;
; mul40
; multiplies A by 40 and returns result in AX
; uses tmp4
.importzp tmp4
.export mul40,loc_tmp
.proc mul40
ldx #0
stx tmp4
sta loc_tmp
asl a
rol tmp4
asl a
rol tmp4 ; val * 4
adc loc_tmp
bcc L1
inc tmp4 ; val * 5
L1: asl a
rol tmp4 ; val * 10
asl a
rol tmp4
asl a
rol tmp4 ; val * 40
ldx tmp4
rts
.endproc
.bss
loc_tmp:.res 1

View File

@@ -8,6 +8,7 @@
.include "fcntl.inc"
.include "errno.inc"
.include "fd.inc"
.include "zeropage.inc"
.export _open
.destructor closeallfiles, 5
@@ -19,9 +20,7 @@
.import incsp4
.import ldaxysp,addysp
.import __oserror
.importzp tmp4,tmp2
.ifdef UCASE_FILENAME
.importzp tmp3
.import ucase_fn
.endif
@@ -93,8 +92,10 @@ cont: ldy #3
.ifdef UCASE_FILENAME
.ifdef DEFAULT_DEVICE
ldy #$80
sty tmp2 ; set flag for ucase_fn
.else
ldy #$00
.endif
sty tmp2 ; set flag for ucase_fn
jsr ucase_fn
bcc ucok1
invret: lda #<EINVAL ; file name is too long

View File

@@ -95,7 +95,7 @@ maptable:
.byte EUNKNOWN ; 177 - haven't found documentation
.byte EUNKNOWN ; 178 - haven't found documentation
.byte EUNKNOWN ; 179 - haven't found documentation
.byte EUNKNOWN ; 180 - not a binary file
.byte ENOEXEC ; 180 - not a binary file
.byte EUNKNOWN ; 181 - [MYDOS] invalid address range
.byte EUNKNOWN ; 182 - [XDOS] invalid parameter

View File

@@ -93,7 +93,7 @@ _get_ostype:
asl a
asl a
and #%00111000
ora #%11
ora #%00000011
_fin: ldx #0
disable_rom_save_a
rts
@@ -117,7 +117,7 @@ _1200_11:
lda #%00010000
_1200_fin:
ora #%010
ora #%00000010
bne _fin
; 400/800 ROM

View File

@@ -10,7 +10,7 @@
.include "atari.inc"
__randomize:
__randomize:
ldx VCOUNT ; Use vertical line counter as high byte
lda RTCLOK+2 ; Use clock as low byte
jmp _srand ; Initialize generator

View File

@@ -4,7 +4,7 @@
; unsigned char revers (unsigned char onoff);
;
.include "atari.inc"
.export _revers
.export _revflag

View File

@@ -8,7 +8,7 @@
.include "atari.inc"
.importzp tmp1,tmp4,ptr1,ptr2
.import mul40,_clrscr
.import _mul40,_clrscr
.export __scroll
.proc __scroll
@@ -40,7 +40,7 @@ down_ok:lda SAVMSC
sta ptr2+1
lda tmp1
jsr mul40
jsr _mul40
sta tmp4
lda ptr2
sec
@@ -103,8 +103,7 @@ up: sta tmp1 ; # of lines to scroll
jmp _clrscr
;multiply by 40 (xsize)
up_ok: jsr mul40
clc
up_ok: jsr _mul40 ; carry is cleared by _mul40
adc SAVMSC ; add start of screen mem
sta ptr2
txa

View File

@@ -0,0 +1,9 @@
; .bss variable used by SpartaDOS-X implementations of
; gettime.s and settime.s
.export sdxtry
.bss
sdxtry: .res 1 ; limit of unsuccessful tries to call GETTD/SETTD
; (see settime.s)

47
libsrc/atari/setcursor.s Normal file
View File

@@ -0,0 +1,47 @@
;
; Christian Groessler, November-2002
;
; cursor handling, internal function
.include "atari.inc"
.import cursor,_mul40
.export setcursor
.proc setcursor
ldy #0
lda OLDCHR
sta (OLDADR),y
lda ROWCRS
jsr _mul40 ; function leaves with carry clear!
adc SAVMSC ; add start of screen memory
sta OLDADR
txa
adc SAVMSC+1
sta OLDADR+1
lda COLCRS
adc OLDADR
sta OLDADR
bcc nc
inc OLDADR+1
nc: lda (OLDADR),y
sta OLDCHR
ldx cursor ; current cursor setting as requested by the user
beq off
ldx #0
beq cont
off: inx
cont: stx CRSINH ; update system variable
beq turnon
and #$7f ; clear high bit / inverse flag
finish: sta (OLDADR),y ; update on-screen display
rts
turnon: ora #$80 ; set high bit / inverse flag
bne finish
.endproc

99
libsrc/atari/settime.s Normal file
View File

@@ -0,0 +1,99 @@
;
; Oliver Schmidt, 15.08.2018
; Christian Groessler, 25.09.2018
;
; int __fastcall__ clock_settime (clockid_t clk_id, const struct timespec *tp);
;
.import __dos_type
.import incsp1, return0
.import sdxtry
.include "time.inc"
.include "zeropage.inc"
.include "errno.inc"
.include "atari.inc"
_clock_settime:
; cleanup stack
jsr incsp1 ; preserves AX
; only supported on SpartaDOS-X >= 4.40
ldy #SPARTADOS
cpy __dos_type
bne enosys
ldy SDX_VERSION
cpy #$44
bcc enosys
; create tm from tp (tv_sec) input parameter
.assert timespec::tv_sec = 0, error
jsr _localtime
sta ptr1
stx ptr1+1
; set date
ldy #tm::tm_mday
lda (ptr1),y ; get day of month
sta SDX_DATE ; set day of month
ldy #tm::tm_mon
lda (ptr1),y ; get month (0-based)
tax
inx ; move [0..11] to [1..12]
stx SDX_DATE+1
ldy #tm::tm_year
lda (ptr1),y ; get year (0 = year 1900)
cmp #100
bcc :+
sbc #100
: sta SDX_DATE+2
ldy #tm::tm_hour
lda (ptr1),y ; get hour
sta SDX_TIME
ldy #tm::tm_min
lda (ptr1),y ; get minutes
sta SDX_TIME+1
ldy #tm::tm_sec
lda (ptr1),y ; get seconds
sta SDX_TIME+2
; set new time/date (SD-X call)
; SpartaDOS-X User's Guide (4.48) states at page 145:
; "In the I_GETTD and I_SETTD procedures a set Carry-Flag means that the clock driver is
; busy at the moment. You should call the routine again."
; It goes on to mention that one should provide an upper limit on the number of calls,
; in order not to "hang". We are doing this here...
lda #0 ; init loop count (256)
sta sdxtry
try_set:lda #SDX_CLK_DEV ; CLK device
sta SDX_DEVICE
ldy #SDX_KD_SETTD ; SETTD function
jsr SDX_KERNEL ; do the call
bcc done
dec sdxtry
bne try_set
lda #EBUSY
bne drcter ; jump always
; return success
done: jmp return0
; load errno code
enosys: lda #ENOSYS
drcter: jmp __directerrno

Some files were not shown because too many files have changed in this diff Show More