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

@@ -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

View File

@@ -22,11 +22,12 @@ SHRAM_HANDLERS = 1
.export CIO_handler
.export SIO_handler
.export SETVBV_handler
.export XMOVE_handler
BUFSZ = 128 ; bounce buffer size
BUFSZ_SIO = 256
.segment "INIT"
.segment "ONCE"
; Turn off ROMs, install system and interrupt wrappers, set new chargen pointer
@@ -736,9 +737,9 @@ fn_cont:jsr get_fn_len
lda #0
sta ICBLH,x
jsr chk_CIO_buf
pla
pla
sta ICBLH,x
pla
pla
sta ICBLL,x
pla
tay
@@ -755,7 +756,7 @@ chk_CIO_buf:
lda ICBAH,x
cmp #$c0
bcc @cont
@ret:
@ret:
.ifdef DEBUG
jsr CIO_buf_noti
.endif
@@ -1085,6 +1086,24 @@ SETVBV_handler:
plp
rts
;---------------------------------------------------------
XMOVE_handler:
pha
lda PORTB
sta cur_XMOVE_PORTB
enable_rom
pla
jsr XMOVE_org
php
pha
disable_rom_val cur_XMOVE_PORTB
pla
plp
rts
CIO_a: .res 1
CIO_x: .res 1
CIO_y: .res 1
@@ -1093,6 +1112,7 @@ cur_CIOV_PORTB: .res 1
cur_SIOV_PORTB: .res 1
cur_KEYBDV_PORTB: .res 1
cur_SETVBV_PORTB: .res 1
cur_XMOVE_PORTB: .res 1
orig_ptr: .res 2
orig_len: .res 2
req_len: .res 2

View File

@@ -11,6 +11,7 @@
SHRAM_HANDLERS = 1
.include "atari.inc"
.include "romswitch.inc"
.import __CHARGEN_START__
.export set_VTIMR1_handler

View File

@@ -0,0 +1,82 @@
;
; Atari XL shadow RAM timer IRQ #2 handler
;
; Christian Groessler, chris@groessler.org, 2019
;
;DEBUG = 1
.ifdef __ATARIXL__
SHRAM_HANDLERS = 1
.include "atari.inc"
.include "romswitch.inc"
.import __CHARGEN_START__
.export set_VTIMR2_handler
.segment "LOWBSS"
VTIMR2_handler: .res 3
.segment "BSS"
old_VTIMR2_handler:
.res 2
.segment "LOWCODE"
; timer interrupt handler:
; disable ROM, call user handler, enable ROM again
my_VTIMR2_handler:
disable_rom_quick
jsr VTIMR2_handler
enable_rom_quick
pla
rti
.segment "CODE"
; install or remove VTIMR2 handler
; input: CF - 0/1 for remove/install handler
; AX - pointer to handler (if CF=1)
; registers destroyed
set_VTIMR2_handler:
bcc @remove
; install vector
stx VTIMR2_handler+2
sta VTIMR2_handler+1 ; save passed vector in low memory
lda #$4C ; "JMP" opcode
sta VTIMR2_handler
lda VTIMR2
sta old_VTIMR2_handler
lda VTIMR2+1
sta old_VTIMR2_handler+1
lda #<my_VTIMR2_handler
php
sei
sta VTIMR2
lda #>my_VTIMR2_handler
sta VTIMR2+1
plp
rts
@remove: php
sei
lda old_VTIMR2_handler
sta VTIMR2
lda old_VTIMR2_handler+1
sta VTIMR2+1
plp
rts
.endif ; .ifdef __ATARIXL__

View File

@@ -16,7 +16,7 @@
.export __sio_call
.include "atari.inc"
.import popa,popax
.import popa,popax,popptr1
.import sectsizetab,__oserror
.importzp ptr1
@@ -31,9 +31,7 @@
sta DAUX1 ; set sector #
stx DAUX2
jsr popax
sta ptr1
stx ptr1+1
jsr popptr1
ldy #sst_flag
lda (ptr1),y

View File

@@ -3,7 +3,7 @@
; Based on on code by Christian Groessler
;
; unsigned char __fastcall__ _syschdir (const char* name);
; for SpartaDOS and MyDOS
; for SpartaDOS, RealDOS, and MyDOS
;
.include "atari.inc"
@@ -65,6 +65,10 @@ ucok1:
lda __dos_type
cmp #SPARTADOS
beq :+
cmp #REALDOS
beq :+
cmp #BWDOS
beq :+
lda #CHDIR_MYDOS
.byte $2C ; BIT <abs>
: lda #CHDIR_SPDOS

View File

@@ -26,11 +26,12 @@
pha
lda __dos_type
beq not_impl ; AtariDOS
cmp #OSADOS+1
bcc do_sparta ; OS/A and SpartaDOS
cmp #MYDOS
bne not_impl ; neither MyDOS, OS/A, nor SpartaDOS
pla
jmp __sysremove ; MyDOS and others (TODO: check XDOS)
jmp __sysremove ; MyDOS
not_impl:
pla

View File

@@ -16,8 +16,7 @@
;DEBUG = 1
.export __SYSTEM_CHECK__: absolute = 1
.import __SYSCHK_LOAD__
.export __SYSTEM_CHECK__, __SYSCHK_END__
.import __STARTADDRESS__
; the following imports are only needed for the 'atari' target version
@@ -25,10 +24,12 @@
.import __STACKSIZE__
.import __RESERVED_MEMORY__
; import our header and trailers
.forceimport __SYSCHKHDR__, __SYSCHKTRL__
.include "zeropage.inc"
.include "atari.inc"
.macro print_string text
.local start, cont
jmp cont
@@ -68,8 +69,41 @@ cont: ldx #0 ; channel 0
.segment "SYSCHK"
rts ; for older DOSes which unconditionally run the first load chunk
.ifdef __ATARIXL__
; check for SpartaDOS and its usage of RAM below ROM
; return CF 0/1 for ok/bad
sdcheck:lda DOS
cmp #'S'
bne sdcrts0 ; not SpartaDOS, assume RAM is not used
; check for BW-DOS, which always reports itself as SpartaDOS, but doesn't use memory under the ROM
lda DOS+3 ; 'B' in BW-DOS
cmp #'B'
bne sdnobw
lda DOS+4 ; 'W' in BW-DOS
cmp #'W'
beq sdcrts0 ; BW-DOS does not use RAM below ROM
sdnobw: lda DOS+1 ; SD version
cmp #$40 ; SD-X has $40 or higher
bcc sdcrts1 ; older versions (except maybe 1.x) always use the RAM under the ROM
ldy #31 ; offset for OSRMFLG
lda (DOSVEC),y ; get OSRMFLG
bne sdcrts1
sdcrts0:clc
rts
sdcrts1:sec
rts
ramrom_txt:
.byte "Memory under ROM is in use.", ATEOL
.byte "Cannot run this program.", ATEOL
ramrom_txt_len = * - ramrom_txt
lmemerrxl_txt:
.byte "Not enough memory to move screen", ATEOL
.byte "memory to low memory. Consider using", ATEOL
@@ -94,8 +128,13 @@ syschk: lda $fcd8 ; from ostype.s
jmp mem_err
sys_ok:
.include "xlmemchk.inc" ; calculate lowest address we will use when we move the screen buffer down
sys_ok: jsr sdcheck ; check for SpartaDOS-X, and if found, whether it uses the RAM under the ROM
bcc sd_ok
print_string2 ramrom_txt, ramrom_txt_len
jmp fail
sd_ok: .include "xlmemchk.inc" ; calculate lowest address we will use when we move the screen buffer down
lda MEMLO
cmp lowadr
@@ -191,25 +230,10 @@ delay1: ldx #0
.endproc
end:
__SYSTEM_CHECK__=syschk
__SYSCHK_END__:
.ifndef __ATARIXL__
tmp: ; outside of the load chunk, some kind of poor man's .bss
.endif
; ------------------------------------------------------------------------
; Chunk header
.segment "SYSCHKHDR"
.word __SYSCHK_LOAD__
.word end - 1
; ------------------------------------------------------------------------
; Chunk "trailer" - sets INITAD
.segment "SYSCHKTRL"
.word INITAD
.word INITAD+1
.word syschk

View File

@@ -0,0 +1,16 @@
;
; Atari startup system check headers
;
; Christian Groessler, chris@groessler.org, 2013
;
.export __SYSCHKHDR__: absolute = 1
.import __SYSCHK_LOAD__, __SYSCHK_END__
; ------------------------------------------------------------------------
; Chunk header
.segment "SYSCHKHDR"
.word __SYSCHK_LOAD__
.word __SYSCHK_END__ - 1

View File

@@ -0,0 +1,17 @@
;
; Atari startup system check headers
;
; Christian Groessler, chris@groessler.org, 2013
;
.export __SYSCHKTRL__: absolute = 1
.import __SYSTEM_CHECK__
.include "atari.inc"
; ------------------------------------------------------------------------
; Chunk "trailer" - sets INITAD
.segment "SYSCHKTRL"
.word INITAD
.word INITAD+1
.word __SYSTEM_CHECK__

View File

@@ -1,28 +0,0 @@
;
; Ullrich von Bassewitz, 12.11.2002
;
; 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
; */
;
.export __systime
.importzp sreg
.code
.proc __systime
lda #$FF
tax
sta sreg
sta sreg+1
rts ; Return -1
.endproc

View File

@@ -3,7 +3,7 @@ DEPS += ../libwrk/$(TARGET)/w2cas.d
../libwrk/$(TARGET)/w2cas.o: $(SRCDIR)/targetutil/w2cas.c | ../libwrk/$(TARGET)
$(COMPILE_recipe)
../targetutil/w2cas.com: ../libwrk/$(TARGET)/w2cas.o ../lib/$(TARGET).lib | ../targetutil
../target/$(TARGET)/util/w2cas.com: ../libwrk/$(TARGET)/w2cas.o ../lib/$(TARGET).lib | ../target/$(TARGET)/util
$(LD65) -o $@ -t $(TARGET) $^
$(TARGET): ../targetutil/w2cas.com
$(TARGET): ../target/$(TARGET)/util/w2cas.com

View File

@@ -14,6 +14,7 @@
#include <errno.h>
#include <6502.h>
#include <atari.h>
#include <cc65.h>
#include <conio.h>
static int verbose = 1;
@@ -21,13 +22,11 @@ static char C_dev[] = "C:";
static struct __iocb *findfreeiocb(void)
{
struct __iocb *iocb = &IOCB; /* first IOCB (#0) */
int i;
for (i = 0; i < 8; i++) {
if (iocb->handler == 0xff)
return iocb;
iocb++;
if (OS.iocb[i].handler == 0xff)
return &OS.iocb[i];
}
return NULL;
}
@@ -43,13 +42,15 @@ int main(int argc, char **argv)
struct __iocb *iocb = findfreeiocb();
int iocb_num;
/* if DOS will automatically clear the screen after the program exits, wait for a keypress... */
if (doesclrscrafterexit())
atexit((void (*)(void))cgetc);
if (! iocb) {
fprintf(stderr, "couldn't find a free iocb\n");
if (_dos_type != 1)
cgetc();
return 1;
}
iocb_num = (iocb - &IOCB) * 16;
iocb_num = (iocb - OS.iocb) * 16;
if (verbose)
printf("using iocb index $%02X ($%04X)\n", iocb_num, iocb);
@@ -57,10 +58,16 @@ int main(int argc, char **argv)
printf("\nfilename: ");
x = fgets(buf, 19, stdin);
printf("\n");
if (! x)
if (! x) {
printf("empty filename, exiting...\n");
return 1;
}
if (*x && *(x + strlen(x) - 1) == '\n')
*(x + strlen(x) - 1) = 0;
if (! strlen(x)) { /* empty filename */
printf("empty filename, exiting...\n");
return 1;
}
filename = x;
}
else {
@@ -74,8 +81,6 @@ int main(int argc, char **argv)
buffer = malloc(buflen);
if (! buffer) {
fprintf(stderr, "cannot alloc %ld bytes -- aborting...\n", (long)buflen);
if (_dos_type != 1)
cgetc();
return 1;
}
}
@@ -87,8 +92,6 @@ int main(int argc, char **argv)
if (! file) {
free(buffer);
fprintf(stderr, "cannot open '%s': %s\n", filename, strerror(errno));
if (_dos_type != 1)
cgetc();
return 1;
}
@@ -101,8 +104,6 @@ int main(int argc, char **argv)
file_err:
fclose(file);
free(buffer);
if (_dos_type != 1)
cgetc();
return 1;
}
if (filen > 32767l) {
@@ -133,8 +134,6 @@ int main(int argc, char **argv)
if (regs.y != 1) {
fprintf(stderr, "CIO call to open cassette returned %d\n", regs.y);
free(buffer);
if (_dos_type != 1)
cgetc();
return 1;
}
@@ -157,8 +156,6 @@ int main(int argc, char **argv)
regs.pc = 0xe456; /* CIOV */
_sys(&regs);
if (_dos_type != 1)
cgetc();
return 1;
}
@@ -173,14 +170,10 @@ int main(int argc, char **argv)
if (regs.y != 1) {
fprintf(stderr, "CIO call to close cassette returned %d\n", regs.y);
if (_dos_type != 1)
cgetc();
return 1;
}
/* all is fine */
printf("success\n");
if (_dos_type != 1)
cgetc();
return 0;
}

View File

@@ -68,7 +68,6 @@ libref: .addr $0000 ; Library reference
.addr BAR
.addr TEXTSTYLE
.addr OUTTEXT
.addr 0 ; IRQ entry is unused
; ******************************************************************************
@@ -1111,11 +1110,8 @@ skipm: ; Loop while --dy > 0
; locals
string := tmp1
cols := tmp3
pixels := tmp4
font := regsave
.rodata
ataint: .byte 64,0,32,96
.bss
rows: .res 1
@@ -1223,32 +1219,31 @@ scvert: ldx x1
.endif
; Draw one character
; Convert to ANTIC code
draw: tay
rol a
rol a
rol a
rol a
and #3
tax
tya
and #$9f
ora ataint,x
; Save and clear inverse video bit
sta inv
and #$7F
draw:
; Extract the inverse mask
ldx #0
asl a
bcc noinv
dex
noinv: stx inv
; Calculate font data address
ldx CHBAS
cmp #$20*2
bpl lowhalf
; Semigraphic or lowercase
inx
inx
lowhalf:
asl a
bcc lowquarter
; Letter
inx
lowquarter:
asl a
sta font
lda #0
sta font + 1
stx font+1
.repeat 3
asl font
rol a
.endrepeat
adc CHBAS
sta font + 1
; Save old coords
bit text_dir
bpl hor
@@ -1274,15 +1269,12 @@ cont: ldy #7
; Put one row of the glyph
putrow: sty rows
lda (font),y
bit inv
bpl noinv
eor #$FF
noinv: sta pixels
lda #7
sta cols
eor inv
sec
rol a
sta pixels
; Put one column of the row
putcol: asl pixels
bcc next_col
putcol: bcc next_col
lda x1
pha
lda x1 + 1
@@ -1318,8 +1310,8 @@ vertinc:
sub mag_x
sta y2
L2:
dec cols
bpl putcol
asl pixels
bne putcol
next_row:
; Go to next row
bit text_dir

View File

@@ -1,8 +0,0 @@
;
; Target-specific black & white values for use by the target-shared TGI kernel
;
.include "tgi-kernel.inc"
.export tgi_color_black:zp = $00
.export tgi_color_white:zp = $01

13
libsrc/atari/tgiref.s Normal file
View File

@@ -0,0 +1,13 @@
;
; Oliver Schmidt, 2013-05-31
;
.export tgi_libref
.ifdef __ATARIXL__
.import CIO_handler
tgi_libref := CIO_handler
.else
.import _exit
tgi_libref := _exit
.endif

View File

@@ -40,7 +40,9 @@
stx ptr4+1
.ifdef DEFAULT_DEVICE
; bit #0 of tmp2 is used as a flag whether device name is present in passed string (1 = present, 0 = not present)
lda tmp2
beq hasdev ; don't fiddle with device part
; bit #0 of tmp2 is used as an additional flag whether device name is present in passed string (1 = present, 0 = not present)
ldy #1
inc tmp2 ; initialize flag: device present
lda #':'
@@ -81,11 +83,11 @@ copy_end:
.ifdef DEFAULT_DEVICE
lda #1
bit tmp2
bit tmp2 ; is a device present in the string?
bne hasdev2 ; yes, don't prepend something
bpl hasdev2
bpl hasdev2 ; check input parameter (tmp2 != $80)
ldy #128+3 ; no, prepend "D:" (or other device)
ldy #128+3 ; no, prepend "Dn:" (__defdev)
sty tmp3 ; adjust stack size used
ldy #3
jsr subysp ; adjust stack pointer

15
libsrc/atari/waitvsync.s Normal file
View File

@@ -0,0 +1,15 @@
;
; Written by Christian Groessler <chris@groessler.org>
;
; void waitvsync (void);
;
.include "atari.inc"
.export _waitvsync
.proc _waitvsync
lda RTCLOK+2
@lp: cmp RTCLOK+2
beq @lp
rts
.endproc

View File

@@ -7,7 +7,7 @@
; It calculates the value to put into RAMTOP for a subsequent
; "GRAPHICS 0" call, and the lowest address which will be used
; by the screen memory afterwards.
;
;
; inputs:
; __STARTADDRESS__ - load address of the program
; outputs: