Added support for the ATARI 8-bit with Dragon Cart.

The actual ATARI-specific code is "inspired" by the IP65 variant published in http://atariage.com/forums/topic/211161-dragoncart-software/?p=2734494. The timer routines are modeled after the ones for the VIC20.
This commit is contained in:
Oliver Schmidt 2015-08-28 15:19:52 +02:00
parent 8960e0bebb
commit cd0506d862
20 changed files with 538 additions and 17 deletions

9
.gitignore vendored
View File

@ -1,9 +1,10 @@
*.bin
*.d64
*.dsk
*.o
*.lib
*.map
*.o
*.prg
*.bin
*.com
*.vicprg
*.d64
*.dsk
*.atr

View File

@ -6,6 +6,7 @@
# a2lancegs.lib : Apple ][ with LANceGS (default slot: #3)
# a2uther2.lib : Apple ][ with Uthernet II (default slot: #3)
# a2combo.lib : Apple ][ with Uthernet or LANceGS or Uthernet II (default slot: #3)
# atrdragon.lib : ATARI 8-bit with Dragon Cart (default base addr: $d500)
# vic20rrnet.lib : VIC20 with RR-Net or clone (default base addr: $980x)
DRIVERS=\
@ -17,6 +18,7 @@ DRIVERS=\
a2lancegs.lib \
a2uther2.lib \
a2combo.lib \
atrdragon.lib \
vic20rrnet.lib
all: $(DRIVERS)
@ -40,6 +42,13 @@ A2OBJS=\
a2filteredinput.o \
a2charconv.o
ATROBJS=\
atrprint.o \
atrtimer.o \
atrkernal.o \
atrinput.o \
atrcharconv.o
VIC20OBJS=\
vic20print.o \
vic20timer.o \
@ -72,6 +81,9 @@ a2uther2.lib: uthernet2.o w5100.o w5100driver.o ethernet.o a2slot.o $(A2OBJS)
a2combo.lib: uthernet.o cs8900a.o lancegs.o lan91c96.o uthernet2.o w5100.o ethernetcombo.o a2slotcombo.o $(A2OBJS)
ar65 a $@ $^
atrdragon.lib: dragoncart.o cs8900a.o cs8900adriver.o ethernet.o $(ATROBJS)
ar65 a $@ $^
vic20rrnet.lib: vic20-rr-net.o cs8900a.o cs8900adriver.o ethernet.o $(VIC20OBJS)
ar65 a $@ $^

31
drivers/atrcharconv.s Normal file
View File

@ -0,0 +1,31 @@
.export ascii_to_native
.export native_to_ascii
; given an Atari Screen Code char in A, return equivalent ASCII
native_to_ascii:
rts
; given an ASCII char in A, return equivalent Atari Screen Code
ascii_to_native:
rts
; -- LICENSE FOR atrcharconv.s --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

91
drivers/atrinput.s Normal file
View File

@ -0,0 +1,91 @@
.export get_key
.export check_for_abort_key
.export get_key_if_available
.export get_key_ip65
.import ip65_process
.data
iocb: .byte 0
kname: .byte "K:",155
.code
; inputs: none
; outputs: A contains ASCII value of key just pressed
get_key:
jsr get_key_if_available
beq get_key
rts
; inputs: none
; outputs: A contains ASCII value of key just pressed (0 if no key pressed)
get_key_if_available:
lda $02fc ; GLOBAL VARIABLE FOR KEYBOARD
cmp #255
beq @nokey
ldx iocb ; K: already open?
bne @read
ldx #$40 ; IOCB to use for keyboard input
stx iocb ; mark K: as open
lda #<kname
sta $344,x ; 1-byte low buffer address
lda #>kname
sta $345,x ; 1-byte high buffer address
lda #3 ; open
sta $342,x ; COMMAND CODE
lda #4 ; open for input (all devices)
sta $34a,x ; 1-byte first auxiliary information
jsr $e456 ; vector to CIO
@read:
lda #0
sta $348,x ; 1-byte low buffer length
sta $349,x ; 1-byte high buffer length
lda #7 ; get character(s)
sta $342,x ; COMMAND CODE
jsr $e456 ; vector to CIO
ldx #255
stx $02fc ; GLOBAL VARIABLE FOR KEYBOARD
rts
@nokey:
lda #0
rts
; process inbound ip packets while waiting for a keypress
get_key_ip65:
jsr ip65_process
jsr get_key_if_available
beq get_key_ip65
rts
;check whether the ??? key is being pressed
;inputs: none
;outputs: sec if ??? pressed, clear otherwise
check_for_abort_key:
; TODO: implement actual check
clc
rts
;-- LICENSE FOR atrinputs.s --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

43
drivers/atrkernal.s Normal file
View File

@ -0,0 +1,43 @@
.include "../inc/common.i"
.export exit_to_basic
.import timer_exit
.import print
.import get_key
.data
press_any_key:
.byte "Press any key to return to DOS ",0
.code
exit_to_basic:
jsr timer_exit
ldax #press_any_key
jsr print
jmp get_key
; -- LICENSE FOR atrkernal.s --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

97
drivers/atrprint.s Normal file
View File

@ -0,0 +1,97 @@
.include "../inc/common.i"
.export print_a
.export print_a_inverse
.export print_cr
.export cls
.export beep
.exportzp screen_current_row
.exportzp screen_current_col
screen_current_col = $55 ; 2-byte cursor column
screen_current_row = $54 ; 1-byte cursor row
.bss
char: .res 1
.code
; use ATARI CIOV function to display 1 char
; inputs: A should be set to ASCII char to display
; outputs: none
print_a:
cmp #10 ; is it a CR?
bne @not_lf
lda #155 ; CR/LF char
@not_lf:
cmp #13 ; is it a LF?
bne @not_cr
lda #155 ; CR/LF char
@not_cr:
sta char
txa
pha
tya
pha
ldax #1
stax $0348 ; 2-byte buffer length
ldax #char
stax $0344 ; 2-byte buffer address
ldx #11 ; put character(s)
stx $0342 ; COMMAND CODE
ldx #0
jsr $e456 ; vector to CIO
pla
tay
pla
tax
rts
; use ATARI CIOV function to move to new line
; inputs: none
; outputs: none
print_cr:
lda #155 ; CR/LF char
jmp print_a
; use ATARI CIOV function to clear the screen
; inputs: none
; outputs: none
cls:
lda #125 ; clear screen
jmp print_a
; use ATARI CIOV function to make a 'beep' noise
; inputs: none
; outputs: none
beep:
lda #253 ; beep char
jmp print_a
print_a_inverse:
ora #$80 ; turn on top bit
jmp print_a
;-- LICENSE FOR atrprint.s --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

132
drivers/atrtimer.s Normal file
View File

@ -0,0 +1,132 @@
; timer routines
;
; the timer should be a 16-bit counter that's incremented by about
; 1000 units per second. it doesn't have to be particularly accurate.
; this Atari implementation requires the routine timer_vbl_handler be called 60 times per second
.include "../inc/common.i"
.export timer_init
.export timer_exit
.export timer_read
.export timer_seconds
.bss
current_time_value: .res 2
current_seconds: .res 1
current_jiffies: .res 1
.data
vbichain: .word 0
.code
; reset timer to 0
; inputs: none
; outputs: none
timer_init:
lda vbichain+1
bne @handler_installed
ldax $222 ; IMMEDIATE VERTICAL BLANK NMI VECTOR
stax vbichain ; save old immediate vector
ldy #<timer_vbl_handler
ldx #>timer_vbl_handler
lda #6 ; STAGE 1 VBI
jsr $e45c ; vector to set VBLANK parameters
@handler_installed:
lda #0
sta current_time_value
sta current_time_value+1
sta current_seconds
sta current_jiffies
rts
timer_exit:
lda vbichain+1
beq @handler_not_installed
ldy vbichain
ldx vbichain+1
lda #6 ; STAGE 1 VBI
jsr $e45c ; vector to set VBLANK parameters
@handler_not_installed:
rts
; read the current timer value
; inputs: none
; outputs: AX = current timer value (roughly equal to number of milliseconds since the last call to 'timer_init')
timer_read:
ldax current_time_value
rts
; tick over the current timer value - should be called 60 times per second
; inputs: none
; outputs: none (all registers preserved, but carry flag can be modified)
timer_vbl_handler:
pha
lda #17 ; 60 HZ =~ 17 ms per 'tick'
clc
adc current_time_value
sta current_time_value
bcc :+
inc current_time_value+1
: inc current_jiffies
lda current_jiffies
cmp #60
bne @done
lda #0
sta current_jiffies
inc current_seconds
; we don't want to mess around with decimal mode in an IRQ handler
lda current_seconds
cmp #$0a
bne :+
lda #$10
: cmp #$1a
bne :+
lda #$20
: cmp #$2a
bne :+
lda #$30
: cmp #$3a
bne :+
lda #$40
: cmp #$4a
bne :+
lda #$50
: cmp #$5a
bne :+
lda #$00
: sta current_seconds
@done:
pla
jmp $e45f ; vector to process immediate VBLANK
timer_seconds:
lda current_seconds
rts
;-- LICENSE FOR atrtimer.s --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

37
drivers/dragoncart.s Normal file
View File

@ -0,0 +1,37 @@
; Dragon Cart driver
.export _cs8900a_driver_name
.export _cs8900a_driver_io_base
.rodata
_cs8900a_driver_name:
.byte "Dragon Cart",0
.data
_cs8900a_driver_io_base:
.word $d500
; -- LICENSE FOR dragoncart.s --
; The contents of this file are subject to the Mozilla Public License
; Version 1.1 (the "License"); you may not use this file except in
; compliance with the License. You may obtain a copy of the License at
; http://www.mozilla.org/MPL/
;
; Software distributed under the License is distributed on an "AS IS"
; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
; License for the specific language governing rights and limitations
; under the License.
;
; The Original Code is ip65.
;
; The Initial Developer of the Original Code is Jonno Downes,
; jonno@jamtronix.com.
; Portions created by the Initial Developer are Copyright (C) 2009
; Jonno Downes. All Rights Reserved.
; -- LICENSE END --

View File

@ -20,6 +20,7 @@ else
C64DRIVERLIB = ../drivers/c64combo.lib
A2DRIVERLIB = ../drivers/a2combo.lib
endif
ATRDRIVERLIB = ../drivers/atrdragon.lib
VICDRIVERLIB = ../drivers/vic20rrnet.lib
UDP =\
@ -46,10 +47,13 @@ $(addsuffix .prg,$(TCP)): IP65LIB = ../ip65/ip65_tcp.lib
$(addsuffix .bin,$(UDP)): IP65LIB = ../ip65/ip65.lib
$(addsuffix .bin,$(TCP)): IP65LIB = ../ip65/ip65_tcp.lib
$(addsuffix .com,$(UDP)): IP65LIB = ../ip65/ip65.lib
$(addsuffix .com,$(TCP)): IP65LIB = ../ip65/ip65_tcp.lib
$(addsuffix .vicprg,$(UDP)): IP65LIB = ../ip65/ip65.lib
$(addsuffix .vicprg,$(TCP)): IP65LIB = ../ip65/ip65_tcp.lib
$(foreach pgm,$(UDP) $(TCP),$(eval $(pgm): $(pgm).prg $(pgm).bin $(pgm).vicprg))
$(foreach pgm,$(UDP) $(TCP),$(eval $(pgm): $(pgm).prg $(pgm).bin $(pgm).com $(pgm).vicprg))
INCFILES =\
../inc/common.i \
@ -60,12 +64,16 @@ prg: $(addsuffix .prg,$(UDP) $(TCP))
bin: $(addsuffix .bin,$(UDP) $(TCP))
com: $(addsuffix .com,$(UDP) $(TCP))
vicprg: $(addsuffix .vicprg,$(UDP) $(TCP))
d64: ip65.d64
dsk: ip65.dsk
atr: ip65.atr
ip65:
make -C ../ip65
@ -81,6 +89,9 @@ drivers:
%.bin: %.o ip65 drivers $(INCFILES)
ld65 -o $*.bin -C apple2.cfg -m $*.a2.map -vm $< $(IP65LIB) $(A2DRIVERLIB) apple2.lib
%.com: %.o ip65 drivers $(INCFILES)
ld65 -o $*.com -C atari.cfg -m $*.atr.map -vm $< $(IP65LIB) $(ATRDRIVERLIB) atari.lib
%.vicprg: %.o ip65 drivers $(INCFILES)
ld65 -o $*.vicprg -C vic20-32k.cfg -m $*.vic.map -vm $< $(IP65LIB) $(VICDRIVERLIB) vic20.lib
@ -108,6 +119,22 @@ ip65.dsk: bin
java -jar $(AC) -cc65 $@ tcp bin < tcp.bin
java -jar $(AC) -cc65 $@ tftp bin < tftp.bin
ip65.atr: com
mkdir atr
cp dos.sys atr/dos.sys
cp dup.sys atr/dup.sys
cp dns.com atr/dns.com
cp dottedquad.com atr/dotquad.com
cp geturl.com atr/geturl.com
cp httpd.com atr/httpd.com
cp parser.com atr/parser.com
cp ping.com atr/ping.com
cp sntp.com atr/sntp.com
cp tcp.com atr/tcp.com
cp tftp.com atr/tftp.com
$(DIR2ATR) -b Dos25 1040 $@ atr
rm -r atr
%-slotscan.o: %.s
ca65 -D A2_SLOT_SCAN -o $@ $<
@ -134,5 +161,5 @@ clean:
make -C ../ip65 clean
make -C ../drivers clean
-rm -f ../supplement/*.o
-rm -f *.o *.prg *.bin *.vicprg *.map
-rm -f ip65.d64 ip65.dsk ip65demo.dsk w5100.dsk
-rm -f *.o *.prg *.bin *.com *.vicprg *.map
-rm -f ip65.d64 ip65.dsk ip65.atr ip65demo.dsk w5100.dsk

View File

@ -2,6 +2,8 @@
.include "../inc/commonprint.i"
.include "../inc/net.i"
.export start
.import exit_to_basic
.import cifs_l1_encode
@ -19,6 +21,7 @@
lda #14
jsr print_a
start:
jsr print_cr
init_ip_via_dhcp

View File

@ -2,6 +2,8 @@
.include "../inc/commonprint.i"
.include "../inc/net.i"
.export start
.import exit_to_basic
.import dns_set_hostname
@ -20,6 +22,7 @@
lda #14
jsr print_a
start:
jsr print_cr
init_ip_via_dhcp
; jsr overwrite_with_hardcoded_dns_server

View File

@ -2,6 +2,8 @@
.include "../inc/commonprint.i"
.include "../inc/net.i"
.export start
.import exit_to_basic
.import parse_dotted_quad
@ -18,6 +20,7 @@
lda #14
jsr print_a
start:
jsr print_cr
ldax #dotted_quad_1

View File

@ -2,6 +2,10 @@
.include "../inc/commonprint.i"
.include "../inc/net.i"
.export start
.import exit_to_basic
.import print_a
.import get_key
.import ascii_to_native
@ -31,6 +35,8 @@ temp_buff = copy_dest
lda #14
jsr print_a
start:
jsr print_cr
init_ip_via_dhcp
jsr print_ip_config
@ -39,7 +45,8 @@ temp_buff = copy_dest
ldax #url_2
; jsr test_url_download
rts
jmp exit_to_basic
test_url_download:
stax temp_url_ptr

View File

@ -2,6 +2,8 @@
.include "../inc/commonprint.i"
.include "../inc/net.i"
.export start
.import exit_to_basic
.import httpd_start
@ -17,6 +19,7 @@
lda #14
jsr print_a ; switch to lower case
start:
ldax #initializing
jsr print
init_ip_via_dhcp

View File

@ -2,6 +2,10 @@
.include "../inc/commonprint.i"
.include "../inc/net.i"
.export start
.import exit_to_basic
.import print_a
.import get_key
.import ascii_to_native
@ -20,6 +24,8 @@
lda #14
jsr print_a
start:
jsr print_cr
ldax #query_1
jsr test_querystring
ldax #query_2
@ -33,7 +39,7 @@
jsr test_querystring
ldax #query_6
jsr test_querystring
rts
jmp exit_to_basic
test_querystring:
stax temp_ax

View File

@ -2,6 +2,10 @@
.include "../inc/commonprint.i"
.include "../inc/net.i"
.export start
.import exit_to_basic
.import print_a
.import get_key
.import ascii_to_native
@ -28,6 +32,8 @@ temp_buff = copy_dest
lda #14
jsr print_a
start:
jsr print_cr
init_ip_via_dhcp
jsr print_ip_config
@ -80,8 +86,10 @@ temp_buff = copy_dest
jsr print_cr
jmp @next_title
@done:
rts
jmp exit_to_basic
test_url_parse:
stax temp_url_ptr

View File

@ -2,6 +2,8 @@
.include "../inc/commonprint.i"
.include "../inc/net.i"
.export start
.import exit_to_basic
.import copymem
@ -22,6 +24,7 @@
lda #14
jsr print_a
start:
jsr print_cr
init_ip_via_dhcp
jsr print_ip_config
@ -44,9 +47,10 @@
jsr print_integer
ldax #ms
jsr print
rts
jmp exit_to_basic
@error:
jmp print_errorcode
jsr print_errorcode
jmp exit_to_basic
.rodata

View File

@ -2,7 +2,10 @@
.include "../inc/commonprint.i"
.include "../inc/net.i"
.export start
.import exit_to_basic
.import dns_set_hostname
.import dns_resolve
.import dns_ip
@ -20,6 +23,8 @@
lda #14
jsr print_a ; switch to lower case
start:
jsr print_cr
init_ip_via_dhcp
jsr print_ip_config

View File

@ -2,7 +2,10 @@
.include "../inc/commonprint.i"
.include "../inc/net.i"
.export start
.import exit_to_basic
.import ascii_to_native
.import parse_dotted_quad
.import dotted_quad_value
@ -44,6 +47,9 @@
lda #14
jsr print_a
start:
jsr print_cr
ldax #$1234
stax acc16
ldax #$1235
@ -196,7 +202,7 @@
ldax #http_get_length
stax tcp_send_data_len
ldax #http_get_msg
jsr tcp_send
jsr tcp_send
jsr check_for_error
; now try to connect to port 80 - should be accepted
@ -217,7 +223,7 @@
ldax #http_get_length
stax tcp_send_data_len
ldax #http_get_msg
jsr tcp_send
jsr tcp_send
jsr check_for_error
@loop_till_end:
@ -226,7 +232,7 @@
cmp cxn_closed
beq @loop_till_end
rts
jmp exit_to_basic
ldax #tcp_callback_routine
stax tcp_callback
@ -255,7 +261,6 @@
@loop_forever:
jsr ip65_process
jmp @loop_forever
rts
tcp_callback_routine:
lda tcp_inbound_data_length

View File

@ -2,6 +2,8 @@
.include "../inc/commonprint.i"
.include "../inc/net.i"
.export start
.import exit_to_basic
.import copymem
@ -26,6 +28,7 @@
lda #14
jsr print_a
start:
jsr print_cr
init_ip_via_dhcp
jsr print_ip_config
@ -58,7 +61,7 @@
jsr tftp_upload_from_memory
bcs @error
print_ok
rts
jmp exit_to_basic
@error:
print_failed