Preliminary Atari 2600 support

This commit is contained in:
Karol Stasiak 2018-04-03 23:13:57 +02:00
parent 3296d5a201
commit 7eab7c439e
8 changed files with 170 additions and 1 deletions

View File

@ -2,7 +2,7 @@
## Current version
* Preliminary BBC Micro support.
* Preliminary Atari 2600 and BBC Micro support.
* Added array initialization syntax with `for` (not yet finalized).

View File

@ -28,6 +28,8 @@ For binary releases, see: https://github.com/KarolS/millfork/releases (latest: 0
* Famicom/NES (the second most important target)
* Atari 2600 (experimental)
* Atari 8-bit computers
* BBC Micro

View File

@ -35,6 +35,8 @@ The following platforms are currently supported:
For more complex programs, you need to create your own "platform" definition.
Read [the NES programming guide](./famicom-programming-guide.md) for more info.
* `vcs` Atari VCS (also known as Atari 2600), 4K cartridge (experimental)
* `a8` Atari 8-bit computers
* `bbcmicro` BBC Micro model B (32k RAM)

View File

@ -33,3 +33,7 @@
## Apple II examples
* [Bell](apple2/bell.mfk) a program that goes \*ding!\*
## Atari 2600 examples
* [Colors](vcs/colors.mfk) simple static rasterbars

11
examples/vcs/colors.mfk Normal file
View File

@ -0,0 +1,11 @@
void main() {
byte y
while true {
start_frame()
for y,0,until,192 {
COLUBK = y
wsync()
}
end_frame()
}
}

29
include/vcs.ini Normal file
View File

@ -0,0 +1,29 @@
; an Atari VCS cartridge format without any bankswitching
; output file size: 4096 bytes
[compilation]
arch=nmos
modules=vcs_hardware,default_panic
ro_arrays=true
; use -fzp-register to override this:
zeropage_register=false
[allocation]
zp_pointers=$80,$82,$84,$86,$88,$8a,$8c,$8e,$90,$92,$94,$96,$98,$9a,$9c,$9e,$a0,$a2,$a4
segments=default,prgrom
default_code_segment=prgrom
; last 16 bytes are left for stack
segment_default_start=$80
segment_default_end=$ef
segment_prgrom_start=$f000
segment_prgrom_end=$ffff
[output]
style=single
format=prgrom:$f000:$ffff
extension=bin

112
include/vcs_hardware.mfk Normal file
View File

@ -0,0 +1,112 @@
byte VSYNC @$00
byte VBLANK @$01
byte WSYNC @$02
byte RSYNC @$03
byte NUSIZ0 @$04
byte NUSIZ1 @$05
byte COLUP0 @$06
byte COLUP1 @$07
byte COLUPF @$08
byte COLUBK @$09
byte CTRLPF @$0A
byte REFP0 @$0B
byte REFP1 @$0C
byte PF0 @$0D
byte PF1 @$0E
byte PF2 @$0F
byte RESP0 @$10
byte RESP1 @$11
byte RESM0 @$12
byte RESM1 @$13
byte RESBL @$14
byte AUDC0 @$15
byte AUDC1 @$16
byte AUDF0 @$17
byte AUDF1 @$18
byte AUDV0 @$19
byte AUDV1 @$1A
byte GRP0 @$1B
byte GRP1 @$1C
byte ENAM0 @$1D
byte ENAM1 @$1E
byte ENABL @$1F
byte HMP0 @$20
byte HMP1 @$21
byte HMM0 @$22
byte HMM1 @$23
byte HMBL @$24
byte VDELP0 @$25
byte VDELP1 @$26
byte VDELBL @$27
byte RESMP0 @$28
byte RESMP1 @$29
byte HMOVE @$2A
byte HMCLR @$2B
byte CXCLR @$2C
byte CXM0P @$30
byte CXM1P @$31
byte CXP0FB @$32
byte CXP1FB @$33
byte CXM0FB @$34
byte CXM1FB @$35
byte CXBLPF @$36
byte CXPPMM @$37
byte INPT0 @$38
byte INPT1 @$39
byte INPT2 @$3A
byte INPT3 @$3B
byte INPT4 @$3C
byte INPT5 @$3D
byte SWCHA @$0280
byte SWACNT @$0281
byte SWCHB @$0282
byte SWBCNT @$0283
byte INTIM @$0284
byte INSTAT @$0285
byte TIM1T @$0294
byte TIM8T @$0295
byte TIM64T @$0296
byte T1024T @$0297
macro asm void wsync() {
STA WSYNC
}
macro asm void start_frame() {
LDA #0
STA VBLANK
LDA #2
STA VSYNC
STA WSYNC
STA WSYNC
STA WSYNC
LDA #0
STA VSYNC
LDX #37
start_frame_loop:
STA WSYNC
DEX
BNE start_frame_loop
}
macro asm void end_frame() {
LDA #%01000010
STA VBLANK
LDX #30
end_frame_loop:
STA WSYNC
DEX
BNE end_frame_loop
}
asm void reset_routine() @$FFF4 {
LDX #$FF
TXS
JMP main
}
array __vectors @$FFFA = [
reset_routine.addr.lo, reset_routine.addr.hi,
reset_routine.addr.lo, reset_routine.addr.hi,
reset_routine.addr.lo, reset_routine.addr.hi
]

View File

@ -0,0 +1,9 @@
const byte black = 0
const byte blue = $d2
const byte red = $64
const byte purple = $86
const byte green = $38
const byte cyan = $9a
const byte yellow = $2c
const byte white = $0e