Skip to content

Commit 2912035

Browse files
committed
Adds Atari 5200 target to the cross-compiler.
This port was started by Vitoco (www.vitoco.cl). Most of the statements are implemented, only missing are PLOT, DRAWTO and support for GTIA modes (9, 10 and 11) in GRAPHICS. Also, there is support for graphic modes 0, 1, 2, 7 to 13 and 15.
1 parent 89502fa commit 2912035

37 files changed

Lines changed: 1487 additions & 47 deletions

Makefile

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ CA65_ROM=-DNO_SMCODE
3737
# Flags added to assembly sources for Floating Point / Integer compilers:
3838
CA65_FP_FLAGS=-D FASTBASIC_FP -I build/gen/fp $(CA65_FLAGS)
3939
CA65_INT_FLAGS=-I build/gen/int $(CA65_FLAGS)
40+
CA65_A5200_FLAGS=-g -t atari5200 -I cc65/asminc -I src -DNO_SMCODE
4041

4142
# Flags for the LD65 linker
4243
LD65_FLAGS=-Ccompiler/fastbasic.cfg
@@ -100,6 +101,7 @@ LIB_INT=build/compiler/fastbasic-int.lib
100101
LIB_FP=build/compiler/fastbasic-fp.lib
101102
LIB_ROM_INT=build/compiler/fastbasic-cart-int.lib
102103
LIB_ROM_FP=build/compiler/fastbasic-cart-fp.lib
104+
LIB_A5200=build/compiler/fastbasic-5200.lib
103105

104106
# Sample programs
105107
SAMPLE_FP_BAS=\
@@ -146,6 +148,7 @@ AS_FOLDERS=\
146148
src/interp/a800\
147149
src/interp/atari\
148150
src/interp/atarifp\
151+
src/interp/a5200\
149152

150153
# ASM files used in the RUNTIME
151154
RT_AS_SRC=\
@@ -211,14 +214,15 @@ BASE_AS_SRC=\
211214
src/interp/pop.asm\
212215
src/interp/print_str.asm\
213216
src/interp/push.asm\
217+
src/interp/put.asm\
218+
src/interp/putbyte.asm\
214219
src/interp/return.asm\
215220
src/interp/saddr.asm\
216221
src/interp/sgn.asm\
217222
src/interp/shl8.asm\
218223
src/interp/strindex.asm\
219224
src/interp/ushl.asm\
220225
src/interp/usr.asm\
221-
src/interp/val.asm\
222226
src/interp/varadd.asm\
223227
src/interp/varaddr.asm\
224228
src/interp/varstore.asm\
@@ -228,6 +232,8 @@ ATARI_AS_SRC=\
228232
src/interp/atari/color.asm\
229233
src/interp/atari/pause.asm\
230234
src/interp/atari/pmgraphics.asm\
235+
src/interp/atari/position.asm\
236+
src/interp/atari/print_tab.asm\
231237
src/interp/atari/rand.asm\
232238
src/interp/atari/soundoff.asm\
233239
src/interp/atari/time.asm\
@@ -241,13 +247,10 @@ A800_AS_SRC=\
241247
src/interp/a800/graphics.asm\
242248
src/interp/a800/input.asm\
243249
src/interp/a800/iochn.asm\
244-
src/interp/a800/position.asm\
245-
src/interp/a800/print_tab.asm\
246-
src/interp/a800/put.asm\
247-
src/interp/a800/putbyte.asm\
248250
src/interp/a800/putchar.asm\
249251
src/interp/a800/str.asm\
250252
src/interp/a800/streol.asm\
253+
src/interp/a800/val.asm\
251254
src/interp/a800/xio.asm\
252255

253256
# FP Interpreter ASM files
@@ -283,6 +286,19 @@ A800_FP_AS_SRC=\
283286
src/interp/atarifp/fpmain.asm\
284287
src/interp/atarifp/mul6.asm\
285288

289+
# Atari 5200 specific code
290+
A5200_AS_SRC=\
291+
$(BASE_AS_SRC)\
292+
$(ATARI_AS_SRC)\
293+
src/a5200cart.asm\
294+
src/interp/a5200/drawto.asm\
295+
src/interp/a5200/getkey.asm\
296+
src/interp/a5200/graphics.asm\
297+
src/interp/a5200/input.asm\
298+
src/interp/a5200/putchar.asm\
299+
src/interp/a5200/str.asm\
300+
src/interp/a5200/val.asm\
301+
286302
# BAS editor source
287303
IDE_BAS_SRC=\
288304
src/editor.bas\
@@ -304,6 +320,7 @@ A800_FP_ROM_OBJS=$(A800_FP_AS_SRC:src/%.asm=build/obj/rom-fp/%.o)
304320
RT_OBJS_INT=$(RT_AS_SRC:src/%.asm=build/obj/int/%.o)
305321
IDE_OBJS_INT=$(IDE_AS_SRC:src/%.asm=build/obj/int/%.o)
306322
A800_OBJS=$(A800_AS_SRC:src/%.asm=build/obj/int/%.o)
323+
A5200_OBJS=$(A5200_AS_SRC:src/%.asm=build/obj/a5200/%.o)
307324
IDE_BAS_OBJS_INT=$(IDE_BAS_SRC:src/%.bas=build/obj/int/%.o)
308325
SAMP_OBJS=$(SAMPLE_BAS:%.bas=build/obj/%.o)
309326
RT_OBJS_ROM_INT=$(RT_AS_SRC:src/%.asm=build/obj/rom-int/%.o)
@@ -315,7 +332,9 @@ COMPILER_COMMON=\
315332
$(LIB_FP)\
316333
$(LIB_ROM_INT)\
317334
$(LIB_ROM_FP)\
335+
$(LIB_A5200)\
318336
build/compiler/fastbasic.cfg\
337+
build/compiler/fastbasic-a5200.cfg\
319338
build/compiler/fastbasic-cart.cfg\
320339
build/compiler/fb$(EXT)\
321340
build/compiler/fb-int$(EXT)\
@@ -325,16 +344,23 @@ COMPILER_COMMON=\
325344
build/compiler/asminc/atari_antic.inc\
326345
build/compiler/asminc/atari_gtia.inc\
327346
build/compiler/asminc/atari.inc\
347+
build/compiler/asminc/atari5200.inc\
328348
build/compiler/asminc/atari_pokey.inc\
349+
build/compiler/asminc/target.inc\
350+
build/compiler/syntax/a5200.syn\
351+
build/compiler/syntax/a800.syn\
329352
build/compiler/syntax/basic.syn\
330353
build/compiler/syntax/dli.syn\
331354
build/compiler/syntax/extended.syn\
332355
build/compiler/syntax/fileio.syn\
333356
build/compiler/syntax/float.syn\
334357
build/compiler/syntax/graphics.syn\
358+
build/compiler/syntax/gr-a5200.syn\
335359
build/compiler/syntax/pm.syn\
336360
build/compiler/syntax/sound.syn\
361+
build/compiler/a5200.tgt\
337362
build/compiler/a800.tgt\
363+
build/compiler/atari-5200.tgt\
338364
build/compiler/atari-cart-fp.tgt\
339365
build/compiler/atari-cart-int.tgt\
340366
build/compiler/atari-fp.tgt\
@@ -536,6 +562,7 @@ SYNTAX_PARSER_SRC=\
536562

537563
# Syntax files for integer version
538564
SYNTAX_INT=\
565+
src/syntax/a800.syn\
539566
src/syntax/basic.syn\
540567
src/syntax/dli.syn\
541568
src/syntax/fileio.syn\
@@ -596,6 +623,7 @@ BUILD_FOLDERS=\
596623
$(AS_FOLDERS:src%=build/obj/int%)\
597624
$(AS_FOLDERS:src%=build/obj/rom-fp%)\
598625
$(AS_FOLDERS:src%=build/obj/rom-int%)\
626+
$(AS_FOLDERS:src%=build/obj/a5200%)\
599627
build/bin\
600628
build/compiler/asminc\
601629
build/compiler/syntax\

cc65/asminc/atari5200.inc

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
;-------------------------------------------------------------------------
2+
; Atari 5200 System Equates
3+
; by Christian Groessler <chris@groessler.org>
4+
; taken from EQUATES.INC from Atari Inc.
5+
;-------------------------------------------------------------------------
6+
7+
;-------------------------------------------------------------------------
8+
; ATASCII CHARACTER DEFS
9+
;-------------------------------------------------------------------------
10+
11+
ATEOL = $9B ; END-OF-LINE, used by CONIO
12+
13+
;-------------------------------------------------------------------------
14+
; CONIO CHARACTER DEFS
15+
;-------------------------------------------------------------------------
16+
17+
CH_ULCORNER = $0B ; '+' sign
18+
CH_URCORNER = $0B
19+
CH_LLCORNER = $0B
20+
CH_LRCORNER = $0B
21+
CH_HLINE = $0D ; dash
22+
CH_VLINE = $01 ; exclamation mark
23+
24+
;-------------------------------------------------------------------------
25+
; Zero Page
26+
;-------------------------------------------------------------------------
27+
28+
POKMSK = $00 ; Mask for Pokey IRQ enable
29+
RTCLOK1 = $01 ; 60 hz. clock (high part)
30+
RTCLOK2 = $02 ; 60 hz. clock (low part)
31+
JUMP = $01
32+
CRITIC = $03 ; Critical section
33+
ATRACT = $04 ; Attract Mode
34+
35+
SDLSTL = $05 ; DLISTL Shadow
36+
SDLSTH = $06 ; DLISTH "
37+
SDMCTL = $07 ; DMACTL "
38+
39+
PCOLR0 = $08 ; COLPM0 Shadow
40+
PCOLR1 = $09 ; COLPM1 "
41+
PCOLR2 = $0A ; COLPM2 "
42+
PCOLR3 = $0B ; COLPM3 "
43+
44+
COLOR0 = $0C ; COLPF0 Shadow
45+
COLOR1 = $0D ; COLPF1 "
46+
COLOR2 = $0E ; COLPF2 "
47+
COLOR3 = $0F ; COLPF3 "
48+
COLOR4 = $10 ; COLBK "
49+
50+
PADDL0 = $11 ; POT0 Shadow
51+
PADDL1 = $12 ; POT1 "
52+
PADDL2 = $13 ; POT2 "
53+
PADDL3 = $14 ; POT3 "
54+
PADDL4 = $15 ; POT4 "
55+
PADDL5 = $16 ; POT5 "
56+
PADDL6 = $17 ; POT6 "
57+
PADDL7 = $18 ; POT7 "
58+
59+
;-------------------------------------------------------------------------
60+
; Page #2
61+
;-------------------------------------------------------------------------
62+
63+
;Interrupt Vectors
64+
65+
VIMIRQ = $0200 ; Immediate IRQ
66+
; Preset $FC03 (SYSIRQ)
67+
VVBLKI = $0202 ; Vblank immediate
68+
; Preset $FCB8 (SYSVBL)
69+
VVBLKD = $0204 ; Vblank deferred
70+
; Preset $FCB2 (XITVBL)
71+
VDSLST = $0206 ; Display List
72+
; Preset $FEA1 (OSDLI)
73+
VKYBDI = $0208 ; Keyboard immediate
74+
; Preset $FD02 (SYSKBD)
75+
VKYBDF = $020A ; Deferred Keyboard
76+
; Preset $FCB2 (XITVBL)
77+
VTRIGR = $020C ; Soft Trigger
78+
VBRKOP = $020E ; BRK Opcode
79+
VSERIN = $0210 ; Serial in Ready
80+
VSEROR = $0212 ; Serial Out Ready
81+
VSEROC = $0214 ; Serial Output complete
82+
VTIMR1 = $0216 ; Pokey Timer 1
83+
VTIMR2 = $0218 ; Pokey Timer 2
84+
VTIMR4 = $021A ; Pokey Timer 4
85+
86+
87+
88+
;-------------------------------------------------------------------------
89+
; CTIA/GTIA Address Equates
90+
;-------------------------------------------------------------------------
91+
92+
GTIA = $C000 ; CTIA/GTIA area
93+
.include "atari_gtia.inc"
94+
95+
;-------------------------------------------------------------------------
96+
; ANTIC Address Equates
97+
;-------------------------------------------------------------------------
98+
99+
ANTIC = $D400 ; ANTIC area
100+
.include "atari_antic.inc"
101+
102+
;-------------------------------------------------------------------------
103+
; POKEY Address Equates
104+
;-------------------------------------------------------------------------
105+
106+
POKEY = $E800 ; POKEY area
107+
.include "atari_pokey.inc"
108+
109+
;-------------------------------------------------------------------------
110+
; conio color defines
111+
;-------------------------------------------------------------------------
112+
113+
COLOR_WHITE = 0
114+
COLOR_RED = 1
115+
COLOR_GREEN = 2
116+
COLOR_BLACK = 3
117+
118+
;-------------------------------------------------------------------------
119+
; Cartridge Parameters
120+
;-------------------------------------------------------------------------
121+
122+
CARTNM = $BFE8 ; Cartridge Name Area
123+
COPYD = $BFFC ; Copyright Decade in Cart
124+
COPYR = $BFFD ; Copyright Year in Cart
125+
; $FF=Diagnostic Cart
126+
GOCART = $BFFE ; Cartridge Start Vector
127+
128+
CHRORG = $F800 ; Character Generator Base

cc65/asminc/target.inc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
;
2+
; FastBasic - Fast basic interpreter for the Atari 8-bit computers
3+
; Copyright (C) 2017-2022 Daniel Serpell
4+
;
5+
; This program is free software; you can redistribute it and/or modify
6+
; it under the terms of the GNU General Public License as published by
7+
; the Free Software Foundation, either version 2 of the License, or
8+
; (at your option) any later version.
9+
;
10+
; This program is distributed in the hope that it will be useful,
11+
; but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
; GNU General Public License for more details.
14+
;
15+
; You should have received a copy of the GNU General Public License along
16+
; with this program. If not, see <http://www.gnu.org/licenses/>
17+
;
18+
19+
; Assembly include file depending on the target
20+
; ---------------------------------------------
21+
22+
.ifdef __ATARI5200__
23+
.include "atari5200.inc"
24+
.global MEMTOP, GPRIOR
25+
.globalzp COLCRS, ROWCRS
26+
.else
27+
.include "atari.inc"
28+
RTCLOK1 = $13
29+
RTCLOK2 = $14
30+
.endif
31+
32+
; vi:syntax=asm_ca65

compiler/a5200.tgt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Atari 5200 console
2+
syntax a5200.syn basic.syn dli.syn pm.syn gr-a5200.syn sound.syn extended.syn
3+
config fastbasic-a5200.cfg
4+
ca65 -tatari5200
5+
library fastbasic-5200.lib
6+
extension .bin
7+

compiler/a800.tgt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Atari 8-bit computers, base file
2-
syntax basic.syn dli.syn fileio.syn pm.syn graphics.syn sound.syn extended.syn
2+
syntax a800.syn basic.syn dli.syn fileio.syn pm.syn graphics.syn sound.syn extended.syn
33
config fastbasic.cfg
44
ca65 -tatari
55
library fastbasic-int.lib

compiler/atari-5200.tgt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Atari 5200 console
2+
include a5200
3+

compiler/fastbasic-a5200.cfg

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#
2+
# FastBasic - Fast basic interpreter for the Atari 8-bit computers
3+
# Copyright (C) 2017-2022 Daniel Serpell
4+
#
5+
# This program is free software; you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 2 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License along
16+
# with this program. If not, see <http://www.gnu.org/licenses/>
17+
#
18+
19+
# Linker configuration file for placing the code in a CARTRIDGE
20+
# -------------------------------------------------------------
21+
22+
SYMBOLS {
23+
__CARTSIZE__: type = weak, value = $8000; # Default to 32KB cartridge
24+
__CART_PAL__: type = weak, value = $02; # Default to PAL
25+
}
26+
27+
28+
MEMORY {
29+
# Interpreter, at the start of usable ZP
30+
INTERP: file = "", start = $001E, size = $0012;
31+
# Non initialized ZP
32+
ZP: define = yes, file = "", start = $0030, size = $00D0;
33+
# Low memory - used for interpreter non-initialized variables
34+
# LOWMEM: define = yes, file = "", start = $021C, size = $00E4;
35+
# Main memory - used for writable DATA
36+
MAIN: define = yes, file = "", start = $0300, size = $3D00;
37+
# Cartridge ROM
38+
ROM: define = yes, file = %O, start = $C000 - __CARTSIZE__, size = __CARTSIZE__ - $19, fill = yes, fillval = $FF;
39+
# Cartridge headers
40+
CARTPAL: file = %O, start = $BFE7, size = $0001;
41+
CARTNAME: file = %O, start = $BFE8, size = $0014, fill = yes, fillval = $40;
42+
CARTYEAR: file = %O, start = $BFFC, size = $0002, fill = yes, fillval = $59;
43+
CARTENTRY: file = %O, start = $BFFE, size = $0002;
44+
}
45+
46+
SEGMENTS {
47+
ZEROPAGE: load = ZP, type = zp, optional = yes;
48+
JUMPTAB: load = ROM, type = ro, define = yes, align = $100;
49+
RUNTIME: load = ROM, type = ro, define = yes;
50+
BYTECODE: load = ROM, type = ro, define = yes;
51+
CODE: load = ROM, type = rw, define = yes;
52+
INTERP: load = ROM, run = INTERP, type = rw, define = yes;
53+
DATA: load = ROM, run = MAIN, type = rw, define = yes;
54+
BSS: load = MAIN, type = bss, optional = yes, define = yes;
55+
HEAP: load = MAIN, type = bss, optional = yes, define = yes, align = $100;
56+
CARTPAL: load = CARTPAL, type = ro;
57+
CARTNAME: load = CARTNAME, type = ro;
58+
CARTYEAR: load = CARTYEAR, type = ro;
59+
CARTENTRY: load = CARTENTRY, type = ro;
60+
}
61+

0 commit comments

Comments
 (0)