From c8f7f2f161f32ee2d6c19b1b38c947fa38e93f5e Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Sat, 1 Mar 2014 17:20:09 +0100 Subject: [PATCH 01/30] first changes for atari5200 target --- asminc/_antic.inc | 93 ++++++++++++++ asminc/_gtia.inc | 81 ++++++++++++ asminc/_pokey.inc | 44 +++++++ asminc/atari.inc | 241 ++++------------------------------- asminc/atari5200.inc | 100 +++++++++++++++ asminc/atari5200.mac | 59 +++++++++ cfg/atari5200.cfg | 42 ++++++ libsrc/Makefile | 1 + libsrc/atari5200/cartentry.s | 13 ++ libsrc/atari5200/cartname.s | 11 ++ libsrc/atari5200/cartyear.s | 12 ++ libsrc/atari5200/crt0.s | 55 ++++++++ libsrc/atari5200/ctype.s | 5 + libsrc/atari5200/randomize.s | 17 +++ libsrc/atari5200/y2k.inc | 41 ++++++ src/ca65/main.c | 4 + src/cc65/main.c | 4 + src/common/target.c | 2 + src/common/target.h | 1 + 19 files changed, 608 insertions(+), 218 deletions(-) create mode 100644 asminc/_antic.inc create mode 100644 asminc/_gtia.inc create mode 100644 asminc/_pokey.inc create mode 100644 asminc/atari5200.inc create mode 100644 asminc/atari5200.mac create mode 100644 cfg/atari5200.cfg create mode 100644 libsrc/atari5200/cartentry.s create mode 100644 libsrc/atari5200/cartname.s create mode 100644 libsrc/atari5200/cartyear.s create mode 100644 libsrc/atari5200/crt0.s create mode 100644 libsrc/atari5200/ctype.s create mode 100644 libsrc/atari5200/randomize.s create mode 100644 libsrc/atari5200/y2k.inc diff --git a/asminc/_antic.inc b/asminc/_antic.inc new file mode 100644 index 000000000..1eb4c87ef --- /dev/null +++ b/asminc/_antic.inc @@ -0,0 +1,93 @@ +;------------------------------------------------------------------------- +; ANTIC Address Equates +;------------------------------------------------------------------------- + +; Read Addresses + +VCOUNT = ANTIC + $0B ;vertical line counter +PENH = ANTIC + $0C ;light pen horizontal position +PENV = ANTIC + $0D ;light pen vertical position +NMIST = ANTIC + $0F ;NMI interrupt status + +; Write Addresses + +DMACTL = ANTIC + $00 ;DMA control +CHACTL = ANTIC + $01 ;character control +DLISTL = ANTIC + $02 ;low display list address +DLISTH = ANTIC + $03 ;high display list address +HSCROL = ANTIC + $04 ;horizontal scroll +VSCROL = ANTIC + $05 ;vertical scroll +PMBASE = ANTIC + $07 ;player-missile base address +CHBASE = ANTIC + $09 ;character base address +WSYNC = ANTIC + $0A ;wait for HBLANK synchronization +NMIEN = ANTIC + $0E ;NMI enable +NMIRES = ANTIC + $0F ;NMI interrupt reset + + +;------------------------------------------------------------------------- +; Antic opcodes +;------------------------------------------------------------------------- + +; usage example: +; +; ScreenDL: +; .byte DL_BLK8 +; .byte DL_BLK8 +; .byte DL_CHR40x8x1 + DL_LMS + DL_DLI +; .word ScreenAlignment +; .byte DL_BLK1 + DL_DLI +; .byte DL_MAP320x1x1 + DL_LMS +; .word Screen +; +; .repeat 99 +; .byte DL_MAP320x1x1 +; .endrepeat +; .byte DL_MAP320x1x1 + DL_LMS +; .word Screen + 40 * 100 ; 100 lines a 40 byte, 'Screen' has to be aligned correctly! +; .repeat 92 +; .byte DL_MAP320x1x1 +; .endrepeat +; +; .byte DL_JVB + +; absolute instructions (non mode lines) + +DL_JMP = 1 +DL_JVB = 65 + +DL_BLK1 = 0 +DL_BLK2 = 16 +DL_BLK3 = 32 +DL_BLK4 = 48 +DL_BLK5 = 64 +DL_BLK6 = 80 +DL_BLK7 = 96 +DL_BLK8 = 112 + +; absolute instructions (mode lines) + +DL_CHR40x8x1 = 2 ; monochrome, 40 character & 8 scanlines per mode line (GR. 0) +DL_CHR40x10x1 = 3 ; monochrome, 40 character & 10 scanlines per mode line +DL_CHR40x8x4 = 4 ; colour, 40 character & 8 scanlines per mode line (GR. 12) +DL_CHR40x16x4 = 5 ; colour, 40 character & 16 scanlines per mode line (GR. 13) +DL_CHR20x8x2 = 6 ; colour (duochrome per character), 20 character & 8 scanlines per mode line (GR. 1) +DL_CHR20x16x2 = 7 ; colour (duochrome per character), 20 character & 16 scanlines per mode line (GR. 2) + +DL_MAP40x8x4 = 8 ; colour, 40 pixel & 8 scanlines per mode line (GR. 3) +DL_MAP80x4x2 = 9 ; 'duochrome', 80 pixel & 4 scanlines per mode line (GR.4) +DL_MAP80x4x4 = 10 ; colour, 80 pixel & 4 scanlines per mode line (GR.5) +DL_MAP160x2x2 = 11 ; 'duochrome', 160 pixel & 2 scanlines per mode line (GR.6) +DL_MAP160x1x2 = 12 ; 'duochrome', 160 pixel & 1 scanline per mode line (GR.14) +DL_MAP160x2x4 = 13 ; 4 colours, 160 pixel & 2 scanlines per mode line (GR.7) +DL_MAP160x1x4 = 14 ; 4 colours, 160 pixel & 1 scanline per mode line (GR.15) +DL_MAP320x1x1 = 15 ; monochrome, 320 pixel & 1 scanline per mode line (GR.8) + +; modifiers on mode lines... + +DL_HSCROL = 16 +DL_VSCROL = 32 +DL_LMS = 64 + +; general modifier... + +DL_DLI = 128 diff --git a/asminc/_gtia.inc b/asminc/_gtia.inc new file mode 100644 index 000000000..f50583271 --- /dev/null +++ b/asminc/_gtia.inc @@ -0,0 +1,81 @@ +;------------------------------------------------------------------------- +; CTIA/GTIA Address Equates +;------------------------------------------------------------------------- + +; Read/Write Addresses + +CONSOL = GTIA + $1F ;console switches and speaker control + +; Read Addresses + +M0PF = GTIA + $00 ;missile 0 and playfield collision +M1PF = GTIA + $01 ;missile 1 and playfield collision +M2PF = GTIA + $02 ;missile 2 and playfield collision +M3PF = GTIA + $03 ;missile 3 and playfield collision + +P0PF = GTIA + $04 ;player 0 and playfield collision +P1PF = GTIA + $05 ;player 1 and playfield collision +P2PF = GTIA + $06 ;player 2 and playfield collision +P3PF = GTIA + $07 ;player 3 and playfield collision + +M0PL = GTIA + $08 ;missile 0 and player collision +M1PL = GTIA + $09 ;missile 1 and player collision +M2PL = GTIA + $0A ;missile 2 and player collision +M3PL = GTIA + $0B ;missile 3 and player collision + +P0PL = GTIA + $0C ;player 0 and player collision +P1PL = GTIA + $0D ;player 1 and player collision +P2PL = GTIA + $0E ;player 2 and player collision +P3PL = GTIA + $0F ;player 3 and player collision + +TRIG0 = GTIA + $10 ;joystick trigger 0 +TRIG1 = GTIA + $11 ;joystick trigger 1 + +TRIG2 = GTIA + $12 ;cartridge interlock +TRIG3 = GTIA + $13 ;ACMI module interlock + +PAL = GTIA + $14 ;##rev2## PAL/NTSC indicator + +; Write Addresses + +HPOSP0 = GTIA + $00 ;player 0 horizontal position +HPOSP1 = GTIA + $01 ;player 1 horizontal position +HPOSP2 = GTIA + $02 ;player 2 horizontal position +HPOSP3 = GTIA + $03 ;player 3 horizontal position + +HPOSM0 = GTIA + $04 ;missile 0 horizontal position +HPOSM1 = GTIA + $05 ;missile 1 horizontal position +HPOSM2 = GTIA + $06 ;missile 2 horizontal position +HPOSM3 = GTIA + $07 ;missile 3 horizontal position + +SIZEP0 = GTIA + $08 ;player 0 size +SIZEP1 = GTIA + $09 ;player 1 size +SIZEP2 = GTIA + $0A ;player 2 size +SIZEP3 = GTIA + $0B ;player 3 size + +SIZEM = GTIA + $0C ;missile sizes + +GRAFP0 = GTIA + $0D ;player 0 graphics +GRAFP1 = GTIA + $0E ;player 1 graphics +GRAFP2 = GTIA + $0F ;player 2 graphics +GRAFP3 = GTIA + $10 ;player 3 graphics + +GRAFM = GTIA + $11 ;missile graphics + +COLPM0 = GTIA + $12 ;player-missile 0 color/luminance +COLPM1 = GTIA + $13 ;player-missile 1 color/luminance +COLPM2 = GTIA + $14 ;player-missile 2 color/luminance +COLPM3 = GTIA + $15 ;player-missile 3 color/luminance + +COLPF0 = GTIA + $16 ;playfield 0 color/luminance +COLPF1 = GTIA + $17 ;playfield 1 color/luminance +COLPF2 = GTIA + $18 ;playfield 2 color/luminance +COLPF3 = GTIA + $19 ;playfield 3 color/luminance + +COLBK = GTIA + $1A ;background color/luminance + +PRIOR = GTIA + $1B ;priority select +VDELAY = GTIA + $1C ;vertical delay +GRACTL = GTIA + $1D ;graphic control +HITCLR = GTIA + $1E ;collision clear + diff --git a/asminc/_pokey.inc b/asminc/_pokey.inc new file mode 100644 index 000000000..99d192fbd --- /dev/null +++ b/asminc/_pokey.inc @@ -0,0 +1,44 @@ +;------------------------------------------------------------------------- +; POKEY Address Equates +;------------------------------------------------------------------------- + +; Read Addresses + +POT0 = POKEY + $00 ;potentiometer 0 +POT1 = POKEY + $01 ;potentiometer 1 +POT2 = POKEY + $02 ;potentiometer 2 +POT3 = POKEY + $03 ;potentiometer 3 +POT4 = POKEY + $04 ;potentiometer 4 +POT5 = POKEY + $05 ;potentiometer 5 +POT6 = POKEY + $06 ;potentiometer 6 +POT7 = POKEY + $07 ;potentiometer 7 + +ALLPOT = POKEY + $08 ;potentiometer port status +KBCODE = POKEY + $09 ;keyboard code +RANDOM = POKEY + $0A ;random number generator +SERIN = POKEY + $0D ;serial port input +IRQST = POKEY + $0E ;IRQ interrupt status +SKSTAT = POKEY + $0F ;serial port and keyboard status + +; Write Addresses + +AUDF1 = POKEY + $00 ;channel 1 audio frequency +AUDC1 = POKEY + $01 ;channel 1 audio control + +AUDF2 = POKEY + $02 ;channel 2 audio frequency +AUDC2 = POKEY + $03 ;channel 2 audio control + +AUDF3 = POKEY + $04 ;channel 3 audio frequency +AUDC3 = POKEY + $05 ;channel 3 audio control + +AUDF4 = POKEY + $06 ;channel 4 audio frequency +AUDC4 = POKEY + $07 ;channel 4 audio control + +AUDCTL = POKEY + $08 ;audio control +STIMER = POKEY + $09 ;start timers +SKRES = POKEY + $0A ;reset SKSTAT status +POTGO = POKEY + $0B ;start potentiometer scan sequence +SEROUT = POKEY + $0D ;serial port output +IRQEN = POKEY + $0E ;IRQ interrupt enable +SKCTL = POKEY + $0F ;serial port and keyboard control + diff --git a/asminc/atari.inc b/asminc/atari.inc index 7b647fd0a..34465aee9 100644 --- a/asminc/atari.inc +++ b/asminc/atari.inc @@ -762,7 +762,15 @@ DOS = $0700 CARTCS = $BFFA ;##rev2## 2-byte cartridge coldstart address CART = $BFFC ;##rev2## 1-byte cartridge present indicator + ;0=Cart Exists CARTFG = $BFFD ;##rev2## 1-byte cartridge flags + ;D7 0=Not a Diagnostic Cart + ; 1=Is a Diagnostic cart and control is + ; given to cart before any OS is init. + ;D2 0=Init but Do not Start Cart + ; 1=Init and Start Cart + ;D0 0=Do not boot disk + ; 1=Boot Disk CARTAD = $BFFE ;##rev2## 2-byte cartridge start vector ;------------------------------------------------------------------------- @@ -770,83 +778,7 @@ CARTAD = $BFFE ;##rev2## 2-byte cartridge start vector ;------------------------------------------------------------------------- GTIA = $D000 ;CTIA/GTIA area - -; Read/Write Addresses - -CONSOL = $D01F ;console switches and speaker control - -; Read Addresses - -M0PF = $D000 ;missile 0 and playfield collision -M1PF = $D001 ;missile 1 and playfield collision -M2PF = $D002 ;missile 2 and playfield collision -M3PF = $D003 ;missile 3 and playfield collision - -P0PF = $D004 ;player 0 and playfield collision -P1PF = $D005 ;player 1 and playfield collision -P2PF = $D006 ;player 2 and playfield collision -P3PF = $D007 ;player 3 and playfield collision - -M0PL = $D008 ;missile 0 and player collision -M1PL = $D009 ;missile 1 and player collision -M2PL = $D00A ;missile 2 and player collision -M3PL = $D00B ;missile 3 and player collision - -P0PL = $D00C ;player 0 and player collision -P1PL = $D00D ;player 1 and player collision -P2PL = $D00E ;player 2 and player collision -P3PL = $D00F ;player 3 and player collision - -TRIG0 = $D010 ;joystick trigger 0 -TRIG1 = $D011 ;joystick trigger 1 - -TRIG2 = $D012 ;cartridge interlock -TRIG3 = $D013 ;ACMI module interlock - -PAL = $D014 ;##rev2## PAL/NTSC indicator - -; Write Addresses - -HPOSP0 = $D000 ;player 0 horizontal position -HPOSP1 = $D001 ;player 1 horizontal position -HPOSP2 = $D002 ;player 2 horizontal position -HPOSP3 = $D003 ;player 3 horizontal position - -HPOSM0 = $D004 ;missile 0 horizontal position -HPOSM1 = $D005 ;missile 1 horizontal position -HPOSM2 = $D006 ;missile 2 horizontal position -HPOSM3 = $D007 ;missile 3 horizontal position - -SIZEP0 = $D008 ;player 0 size -SIZEP1 = $D009 ;player 1 size -SIZEP2 = $D00A ;player 2 size -SIZEP3 = $D00B ;player 3 size - -SIZEM = $D00C ;missile sizes - -GRAFP0 = $D00D ;player 0 graphics -GRAFP1 = $D00E ;player 1 graphics -GRAFP2 = $D00F ;player 2 graphics -GRAFP3 = $D010 ;player 3 graphics - -GRAFM = $D011 ;missile graphics - -COLPM0 = $D012 ;player-missile 0 color/luminance -COLPM1 = $D013 ;player-missile 1 color/luminance -COLPM2 = $D014 ;player-missile 2 color/luminance -COLPM3 = $D015 ;player-missile 3 color/luminance - -COLPF0 = $D016 ;playfield 0 color/luminance -COLPF1 = $D017 ;playfield 1 color/luminance -COLPF2 = $D018 ;playfield 2 color/luminance -COLPF3 = $D019 ;playfield 3 color/luminance - -COLBK = $D01A ;background color/luminance - -PRIOR = $D01B ;priority select -VDELAY = $D01C ;vertical delay -GRACTL = $D01D ;graphic control -HITCLR = $D01E ;collision clear +.include "_gtia.inc" ;------------------------------------------------------------------------- ; PBI Address Equates @@ -862,6 +794,20 @@ PDVI = $D1FF ;##rev2## parallel device IRQ status PDVS = $D1FF ;##rev2## parallel device select +;------------------------------------------------------------------------- +; POKEY Address Equates +;------------------------------------------------------------------------- + +POKEY = $D200 ;POKEY area +.include "_pokey.inc" + +;------------------------------------------------------------------------- +; ANTIC Address Equates +;------------------------------------------------------------------------- + +ANTIC = $D400 ;ANTIC area +.include "_antic.inc" + ; PBI RAM Address Equates PBIRAM = $D600 ;##rev2## parallel bus interface RAM area @@ -874,52 +820,6 @@ PDIRQV = $D808 ;##rev2## parallel device IRQ vector PDID2 = $D80B ;##rev2## parallel device ID 2 PDVV = $D80D ;##rev2## parallel device vector table -;------------------------------------------------------------------------- -; POKEY Address Equates -;------------------------------------------------------------------------- - -POKEY = $D200 ;POKEY area - -; Read Addresses - -POT0 = $D200 ;potentiometer 0 -POT1 = $D201 ;potentiometer 1 -POT2 = $D202 ;potentiometer 2 -POT3 = $D203 ;potentiometer 3 -POT4 = $D204 ;potentiometer 4 -POT5 = $D205 ;potentiometer 5 -POT6 = $D206 ;potentiometer 6 -POT7 = $D207 ;potentiometer 7 - -ALLPOT = $D208 ;potentiometer port status -KBCODE = $D209 ;keyboard code -RANDOM = $D20A ;random number generator -SERIN = $D20D ;serial port input -IRQST = $D20E ;IRQ interrupt status -SKSTAT = $D20F ;serial port and keyboard status - -; Write Addresses - -AUDF1 = $D200 ;channel 1 audio frequency -AUDC1 = $D201 ;channel 1 audio control - -AUDF2 = $D202 ;channel 2 audio frequency -AUDC2 = $D203 ;channel 2 audio control - -AUDF3 = $D204 ;channel 3 audio frequency -AUDC3 = $D205 ;channel 3 audio control - -AUDF4 = $D206 ;channel 4 audio frequency -AUDC4 = $D207 ;channel 4 audio control - -AUDCTL = $D208 ;audio control -STIMER = $D209 ;start timers -SKRES = $D20A ;reset SKSTAT status -POTGO = $D20B ;start potentiometer scan sequence -SEROUT = $D20D ;serial port output -IRQEN = $D20E ;IRQ interrupt enable -SKCTL = $D20F ;serial port and keyboard control - ;------------------------------------------------------------------------- ; PIA Address Equates ;------------------------------------------------------------------------- @@ -932,33 +832,6 @@ PORTB = $D301 ;port B direction register or memory management PACTL = $D302 ;port A control PBCTL = $D303 ;port B control -;------------------------------------------------------------------------- -; ANTIC Address Equates -;------------------------------------------------------------------------- - -ANTIC = $D400 ;ANTIC area - -; Read Addresses - -VCOUNT = $D40B ;vertical line counter -PENH = $D40C ;light pen horizontal position -PENV = $D40D ;light pen vertical position -NMIST = $D40F ;NMI interrupt status - -; Write Addresses - -DMACTL = $D400 ;DMA control -CHACTL = $D401 ;character control -DLISTL = $D402 ;low display list address -DLISTH = $D403 ;high display list address -HSCROL = $D404 ;horizontal scroll -VSCROL = $D405 ;vertical scroll -PMBASE = $D407 ;player-missile base address -CHBASE = $D409 ;character base address -WSYNC = $D40A ;wait for HBLANK synchronization -NMIEN = $D40E ;NMI enable -NMIRES = $D40F ;NMI interrupt reset - ;------------------------------------------------------------------------- ; Floating Point Package Address Equates ;------------------------------------------------------------------------- @@ -1131,74 +1004,6 @@ MYDOS = 3 XDOS = 4 NODOS = 255 -;------------------------------------------------------------------------- -; Antic opcodes -;------------------------------------------------------------------------- - -; usage example: -; -; ScreenDL: -; .byte DL_BLK8 -; .byte DL_BLK8 -; .byte DL_CHR40x8x1 + DL_LMS + DL_DLI -; .word ScreenAlignment -; .byte DL_BLK1 + DL_DLI -; .byte DL_MAP320x1x1 + DL_LMS -; .word Screen -; -; .repeat 99 -; .byte DL_MAP320x1x1 -; .endrepeat -; .byte DL_MAP320x1x1 + DL_LMS -; .word Screen + 40 * 100 ; 100 lines a 40 byte, 'Screen' has to be aligned correctly! -; .repeat 92 -; .byte DL_MAP320x1x1 -; .endrepeat -; -; .byte DL_JVB - -; absolute instructions (non mode lines) - -DL_JMP = 1 -DL_JVB = 65 - -DL_BLK1 = 0 -DL_BLK2 = 16 -DL_BLK3 = 32 -DL_BLK4 = 48 -DL_BLK5 = 64 -DL_BLK6 = 80 -DL_BLK7 = 96 -DL_BLK8 = 112 - -; absolute instructions (mode lines) - -DL_CHR40x8x1 = 2 ; monochrome, 40 character & 8 scanlines per mode line (GR. 0) -DL_CHR40x10x1 = 3 ; monochrome, 40 character & 10 scanlines per mode line -DL_CHR40x8x4 = 4 ; colour, 40 character & 8 scanlines per mode line (GR. 12) -DL_CHR40x16x4 = 5 ; colour, 40 character & 16 scanlines per mode line (GR. 13) -DL_CHR20x8x2 = 6 ; colour (duochrome per character), 20 character & 8 scanlines per mode line (GR. 1) -DL_CHR20x16x2 = 7 ; colour (duochrome per character), 20 character & 16 scanlines per mode line (GR. 2) - -DL_MAP40x8x4 = 8 ; colour, 40 pixel & 8 scanlines per mode line (GR. 3) -DL_MAP80x4x2 = 9 ; 'duochrome', 80 pixel & 4 scanlines per mode line (GR.4) -DL_MAP80x4x4 = 10 ; colour, 80 pixel & 4 scanlines per mode line (GR.5) -DL_MAP160x2x2 = 11 ; 'duochrome', 160 pixel & 2 scanlines per mode line (GR.6) -DL_MAP160x1x2 = 12 ; 'duochrome', 160 pixel & 1 scanline per mode line (GR.14) -DL_MAP160x2x4 = 13 ; 4 colours, 160 pixel & 2 scanlines per mode line (GR.7) -DL_MAP160x1x4 = 14 ; 4 colours, 160 pixel & 1 scanline per mode line (GR.15) -DL_MAP320x1x1 = 15 ; monochrome, 320 pixel & 1 scanline per mode line (GR.8) - -; modifiers on mode lines... - -DL_HSCROL = 16 -DL_VSCROL = 32 -DL_LMS = 64 - -; general modifier... - -DL_DLI = 128 - ;------------------------------------------------------------------------- ; End of atari.inc ;------------------------------------------------------------------------- diff --git a/asminc/atari5200.inc b/asminc/atari5200.inc new file mode 100644 index 000000000..d6dd5e48e --- /dev/null +++ b/asminc/atari5200.inc @@ -0,0 +1,100 @@ + +;------------------------------------------------------------------------- +; Zero Page +;------------------------------------------------------------------------- + +POKMSK = $00 ;Mask for Pokey IRQ enable +RTCLOK = $01 ;60 hz. clock +JUMP = $01 +CRITIC = $03 ;Critical section +ATRACT = $04 ;Attract Mode + +SDLSTL = $05 ;DLISTL Shadow +SDLSTH = $06 ;DLISTH " +SDMCTL = $07 ;DMACTL " + +PCOLR0 = $08 ;COLPM0 Shadow +PCOLR1 = $09 ;COLPM1 " +PCOLR2 = $0A ;COLPM2 " +PCOLR3 = $0B ;COLPM3 " + +COLOR0 = $0C ;COLPF0 Shadow +COLOR1 = $0D ;COLPF1 " +COLOR2 = $0E ;COLPF2 " +COLOR3 = $0F ;COLPF3 " +COLOR4 = $10 ;COLBK " + +PADDL0 = $11 ;POT0 Shadow +PADDL1 = $12 ;POT1 " +PADDL2 = $13 ;POT2 " +PADDL3 = $14 ;POT3 " +PADDL4 = $15 ;POT4 " +PADDL5 = $16 ;POT5 " +PADDL6 = $17 ;POT6 " +PADDL7 = $18 ;POT7 " + + +;------------------------------------------------------------------------- +; Page #2 +;------------------------------------------------------------------------- + +;Interrupt Vectors + +VIMIRQ = $0200 ;Immediate IRQ + ;Preset $FC03 (SYSIRQ) +VVBLKI = $0202 ;Vblank immediate + ;Preset $FCB8 (SYSVBL) +VVBLKD = $0204 ;Vblank deferred + ;Preset $FCB2 (XITVBL) +VDSLST = $0206 ;Display List + ;Preset $FEA1 (OSDLI) +VKYBDI = $0208 ;Keyboard immediate + ;Preset $FD02 (SYSKBD) +VKYBDF = $020A ;Deferred Keyboard + ;Preset $FCB2 (XITVBL) +VTRIGR = $020C ;Soft Trigger +VBRKOP = $020E ;BRK Opcode +VSERIN = $0210 ;Serial in Ready +VSEROR = $0212 ;Serial Out Ready +VSEROC = $0214 ;Serial Output complete +VTIMR1 = $0216 ;Pokey Timer 1 +VTIMR2 = $0218 ;Pokey Timer 2 +VTIMR4 = $021A ;Pokey Timer 4 + + + +;------------------------------------------------------------------------- +; CTIA/GTIA Address Equates +;------------------------------------------------------------------------- + +GTIA = $C000 ;CTIA/GTIA area +.include "_gtia.inc" + +;------------------------------------------------------------------------- +; ANTIC Address Equates +;------------------------------------------------------------------------- + +ANTIC = $D400 ;ANTIC area +.include "_antic.inc" + +;------------------------------------------------------------------------- +; POKEY Address Equates +;------------------------------------------------------------------------- + +POKEY = $E800 ;POKEY area +.include "_pokey.inc" + + +;------------------------------------------------------------------------- +; Cartridge Parameters +;------------------------------------------------------------------------- + +CARTNM = $BFE8 ;Cartridge Name Area +COPYD = $BFFC ;Copyright Decade in Cart +COPYR = $BFFD ;Copyright Year in Cart + ; $FF=Diagnostic Cart +GOCART = $BFFE ;Cartridge Start Vector + + +CHRORG = $F800 ;Character Generator Base + diff --git a/asminc/atari5200.mac b/asminc/atari5200.mac new file mode 100644 index 000000000..ece654bcc --- /dev/null +++ b/asminc/atari5200.mac @@ -0,0 +1,59 @@ +; Convert characters to screen codes + +; Helper macro that converts and outputs one character +.macro _scrcode char + .if (char >= 0) .and (char <= 31) + .byte (char + 64) + .elseif (char >= 32) .and (char <= 95) + .byte (char + 32) + .elseif (char >= 96) .and (char <= 127) + .byte char + .elseif (char >= 128) .and (char <= 159) + .byte (char + 64) + .elseif (char >= 160) .and (char <= 223) + .byte (char - 32) + .elseif (char >= 224) .and (char <= 255) + .byte char + .else + .error "scrcode: Character constant out of range" + .endif +.endmacro + +.macro scrcode arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 + + ; Bail out if next argument is empty + .if .blank (arg1) + .exitmacro + .endif + + ; Check for a string + .if .match ({arg1}, "") + + ; Walk over all string chars + .repeat .strlen (arg1), i + _scrcode {.strat (arg1, i)} + .endrepeat + + ; Check for a number + .elseif .match (.left (1, {arg1}), 0) + + ; Just output the number + _scrcode arg1 + + ; Check for a character + .elseif .match (.left (1, {arg1}), 'a') + + ; Just output the character + _scrcode arg1 + + ; Anything else is an error + .else + + .error "scrcode: invalid argument type" + + .endif + + ; Call the macro recursively with the remaining args + scrcode arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 +.endmacro + diff --git a/cfg/atari5200.cfg b/cfg/atari5200.cfg new file mode 100644 index 000000000..ff74f2b7c --- /dev/null +++ b/cfg/atari5200.cfg @@ -0,0 +1,42 @@ +SYMBOLS { + __CARTSIZE__: type = weak, value = $4000; # possible values: $4000 and $8000 + __CART_ENTRY__: type = import; + __STACKSIZE__: type = weak, value = $0300; # 3 pages stack +} +MEMORY { + ZP: file = "", start = $0019, size = $00E7, define = yes; + RAM: file = "", start = $021C, size = $4000 - __STACKSIZE__ - $021C, define = yes; + ROM: file = %O, start = $C000 - __CARTSIZE__, size = __CARTSIZE__ - $18, define = yes, fill = yes, fillval = $FF; + CARTNAME: file = %O, start = $BFE8, size = $0014 fill = yes, fillval = $40; + CARTYEAR: file = %O, start = $BFFC, size = $0002 fill = yes, fillval = $59; + CARTENTRY: file = %O, start = $BFFE, size = $0002; +} +SEGMENTS { + STARTUP: load = ROM, type = ro, define = yes, optional = yes; + LOWCODE: load = ROM, type = ro, define = yes, optional = yes; + INIT: load = ROM, type = ro, optional = yes; + CODE: load = ROM, type = ro, define = yes; + RODATA: load = ROM, type = ro, optional = yes; + DATA: load = ROM, run = RAM, type = rw, define = yes, optional = yes; + BSS: load = RAM, type = bss, define = yes, optional = yes; + CARTNAME: load = CARTNAME, type = ro, define = yes; + CARTYEAR: load = CARTYEAR, type = ro, define = yes; + CARTENTRY: load = CARTENTRY, type = ro, define = yes; + ZEROPAGE: load = ZP, type = zp, optional = yes; + EXTZP: load = ZP, type = zp, optional = yes; +} +FEATURES { + CONDES: type = constructor, + label = __CONSTRUCTOR_TABLE__, + count = __CONSTRUCTOR_COUNT__, + segment = INIT; + CONDES: type = destructor, + label = __DESTRUCTOR_TABLE__, + count = __DESTRUCTOR_COUNT__, + segment = RODATA; + CONDES: type = interruptor, + label = __INTERRUPTOR_TABLE__, + count = __INTERRUPTOR_COUNT__, + segment = RODATA, + import = __CALLIRQ__; +} diff --git a/libsrc/Makefile b/libsrc/Makefile index 3d8277ae5..119fe9a05 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -12,6 +12,7 @@ GEOS = geos-apple \ TARGETS = apple2 \ apple2enh \ + atari5200 \ atari \ atarixl \ atmos \ diff --git a/libsrc/atari5200/cartentry.s b/libsrc/atari5200/cartentry.s new file mode 100644 index 000000000..e69426b65 --- /dev/null +++ b/libsrc/atari5200/cartentry.s @@ -0,0 +1,13 @@ +; Cartridge entry point +; +; Christian Groessler, 01-Mar-2014 + +.export __CART_ENTRY__: absolute = 1 +.import __CARTSIZE__, start +.forceimport __CART_YEAR__, __CART_NAME__ + +.segment "CARTENTRY" + + .word start ; entry point + +.assert (__CARTSIZE__ = $4000 || __CARTSIZE__ = $8000), error, "Cartridge size must either be $4000 or $8000" diff --git a/libsrc/atari5200/cartname.s b/libsrc/atari5200/cartname.s new file mode 100644 index 000000000..51a7ca2bd --- /dev/null +++ b/libsrc/atari5200/cartname.s @@ -0,0 +1,11 @@ +; default cartridge name +; +; Christian Groessler, 01-Mar-2014 + +.include "atari5200.mac" + +.export __CART_NAME__: absolute = 1 + +.segment "CARTNAME" + + scrcode " cc65 compiled" diff --git a/libsrc/atari5200/cartyear.s b/libsrc/atari5200/cartyear.s new file mode 100644 index 000000000..85d819632 --- /dev/null +++ b/libsrc/atari5200/cartyear.s @@ -0,0 +1,12 @@ +; Cartridge copyright year +; +; Christian Groessler, 01-Mar-2014 + +.include "atari5200.mac" + +.export __CART_YEAR__: absolute = 1 + +.segment "CARTYEAR" + + scrcode "98" + diff --git a/libsrc/atari5200/crt0.s b/libsrc/atari5200/crt0.s new file mode 100644 index 000000000..3944cd2bf --- /dev/null +++ b/libsrc/atari5200/crt0.s @@ -0,0 +1,55 @@ +; +; Startup code for cc65 (Atari5200 version) +; +; by Christian Groessler (chris@groessler.org), 2014 +; + + .export _exit, start + .export __STARTUP__ : absolute = 1 ; Mark as startup + .import __RAM_START__, __RAM_SIZE__ + .import __RESERVED_MEMORY__ + + .import initlib, donelib, callmain + .import zerobss, copydata + + .include "zeropage.inc" + .include "atari5200.inc" + + +; ------------------------------------------------------------------------ +; Place the startup code in a special segment. + +.segment "STARTUP" + +start: + +; Clear the BSS data + + jsr zerobss + +; initialize data + jsr copydata + +; setup the stack + + lda #<(__RAM_START__ + __RAM_SIZE__) + sta sp + lda #>(__RAM_START__ + __RAM_SIZE__) + sta sp+1 ; Set argument stack ptr + +; Call module constructors + + jsr initlib + +; Push arguments and call main() + + jsr callmain + +; Call module destructors. This is also the _exit entry. + +_exit: jsr donelib ; Run module destructors + +; Reset the NES + + jmp start + diff --git a/libsrc/atari5200/ctype.s b/libsrc/atari5200/ctype.s new file mode 100644 index 000000000..432f46240 --- /dev/null +++ b/libsrc/atari5200/ctype.s @@ -0,0 +1,5 @@ +; Character specification table. +; +; same as for "atari" target + +.include "../atari/ctype.s" diff --git a/libsrc/atari5200/randomize.s b/libsrc/atari5200/randomize.s new file mode 100644 index 000000000..ef462827e --- /dev/null +++ b/libsrc/atari5200/randomize.s @@ -0,0 +1,17 @@ +; +; Christian Groessler, 01-Mar-2014 +; +; void _randomize (void); +; /* Initialize the random number generator */ +; + + .export __randomize + .import _srand + + .include "atari5200.inc" + +__randomize: + ldx VCOUNT ; Use vertical line counter as high byte + lda RTCLOK+1 ; Use clock as low byte + jmp _srand ; Initialize generator + diff --git a/libsrc/atari5200/y2k.inc b/libsrc/atari5200/y2k.inc new file mode 100644 index 000000000..a44d027a1 --- /dev/null +++ b/libsrc/atari5200/y2k.inc @@ -0,0 +1,41 @@ +;----------------------------------------------------------- +; Y2K FIX by Alan Davis, Dennis Debro, and Ronen Habot +;----------------------------------------------------------- +Y2K LDY #$00 ; Copy BIOS opening screen to RAM + LDA #$FD + STA TEMPH + LDA #$58 ; Assume 2 port system + LDX $FD32 + CPX #$E8 ; Is this a 4 port? + BNE Y2K0 ; Jump if not + LDA #$42 ; Yes, 4 port system +Y2K0 STA TEMPL +Y2K1 LDA (TEMPL),Y + STA $0600,Y + INY + BNE Y2K1 + LDY #$50 + INC TEMPH +Y2K2 LDA (TEMPL),Y + STA $0700,Y + DEY + BPL Y2K2 + LDA #$D4 ; Point to copyright string + STA $0724 + LDA #$BF + STA $0725 + LDX #$0B ; Store NOP's @ end + LDA #$EA +Y2K3 STA $0732,X + DEX + BPL Y2K3 + LDA #$60 ; Store RTS opcode @ end + STA $0750 + JSR $0600 ; Show title screen + LDY #$00 ; Clear RAM from $0600-$3FFF + STY $80 + LDA #$06 + STA $81 + JSR CLRRAM + RTS + diff --git a/src/ca65/main.c b/src/ca65/main.c index 4ec98b01d..d4f16d58f 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -205,6 +205,10 @@ static void SetSys (const char* Sys) AbEnd ("Cannot use `module' as a target for the assembler"); break; + case TGT_ATARI5200: + NewSymbol ("__ATARI5200__", 1); + break; + case TGT_ATARI: NewSymbol ("__ATARI__", 1); break; diff --git a/src/cc65/main.c b/src/cc65/main.c index a27822ed8..affaa01b0 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -160,6 +160,10 @@ static void SetSys (const char* Sys) AbEnd ("Cannot use `module' as a target for the compiler"); break; + case TGT_ATARI5200: + DefineNumericMacro ("__ATARI5200__", 1); + break; + case TGT_ATARI: DefineNumericMacro ("__ATARI__", 1); break; diff --git a/src/common/target.c b/src/common/target.c index a4287ee56..8fd3dcf87 100644 --- a/src/common/target.c +++ b/src/common/target.c @@ -125,6 +125,7 @@ static const TargetEntry TargetMap[] = { { "apple2", TGT_APPLE2 }, { "apple2enh", TGT_APPLE2ENH }, { "atari", TGT_ATARI }, + { "atari5200", TGT_ATARI5200 }, { "atarixl", TGT_ATARIXL }, { "atmos", TGT_ATMOS }, { "bbc", TGT_BBC }, @@ -157,6 +158,7 @@ static const TargetProperties PropertyTable[TGT_COUNT] = { { "none", CPU_6502, BINFMT_BINARY, CTNone }, { "module", CPU_6502, BINFMT_O65, CTNone }, { "atari", CPU_6502, BINFMT_BINARY, CTAtari }, + { "atari5200", CPU_6502, BINFMT_BINARY, CTAtari }, { "atarixl", CPU_6502, BINFMT_BINARY, CTAtari }, { "vic20", CPU_6502, BINFMT_BINARY, CTPET }, { "c16", CPU_6502, BINFMT_BINARY, CTPET }, diff --git a/src/common/target.h b/src/common/target.h index e1675ad65..d37713e21 100644 --- a/src/common/target.h +++ b/src/common/target.h @@ -55,6 +55,7 @@ typedef enum { TGT_NONE, TGT_MODULE, TGT_ATARI, + TGT_ATARI5200, TGT_ATARIXL, TGT_VIC20, TGT_C16, From 361da29e51c2eb2a944a0fbfca854a040dd88fdc Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Tue, 4 Mar 2014 16:02:24 +0100 Subject: [PATCH 02/30] add get_tv() --- libsrc/atari5200/get_tv.s | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 libsrc/atari5200/get_tv.s diff --git a/libsrc/atari5200/get_tv.s b/libsrc/atari5200/get_tv.s new file mode 100644 index 000000000..99cac3c48 --- /dev/null +++ b/libsrc/atari5200/get_tv.s @@ -0,0 +1,20 @@ +; +; Christian Groessler, 2014 +; +; unsigned char get_tv (void); +; /* Return the video mode the machine is using */ +; + + .include "get_tv.inc" + + +;-------------------------------------------------------------------------- +; _get_tv + +.proc _get_tv + + lda #TV::NTSC + rts + +.endproc From 889783bedba400a8bb6608d3c95ea278c96603ff Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Tue, 11 Mar 2014 01:17:59 +0100 Subject: [PATCH 03/30] add some conio functions --- libsrc/atari/chline.s | 12 +++++++----- libsrc/atari/cvline.s | 11 +++++++---- libsrc/atari5200/cclear.s | 1 + libsrc/atari5200/chline.s | 1 + libsrc/atari5200/clock.s | 35 +++++++++++++++++++++++++++++++++ libsrc/atari5200/cvline.s | 1 + libsrc/atari5200/sysuname.s | 39 +++++++++++++++++++++++++++++++++++++ 7 files changed, 91 insertions(+), 9 deletions(-) create mode 100644 libsrc/atari5200/cclear.s create mode 100644 libsrc/atari5200/chline.s create mode 100644 libsrc/atari5200/clock.s create mode 100644 libsrc/atari5200/cvline.s create mode 100644 libsrc/atari5200/sysuname.s diff --git a/libsrc/atari/chline.s b/libsrc/atari/chline.s index 46eb0f35d..b6ebba936 100644 --- a/libsrc/atari/chline.s +++ b/libsrc/atari/chline.s @@ -9,6 +9,12 @@ .import popa, _gotoxy, cputdirect, setcursor .importzp tmp1 +.ifndef __ATARI5200__ +CHRCODE = $12+64 +.else +CHRCODE = 14 +.endif + _chlinexy: pha ; Save the length jsr popa ; Get y @@ -19,12 +25,8 @@ _chline: cmp #0 ; Is the length zero? beq L9 ; Jump if done sta tmp1 -L1: lda #$12+64 ; Horizontal line, screen code +L1: lda #CHRCODE ; Horizontal line, screen code jsr cputdirect ; Direct output dec tmp1 bne L1 L9: jmp setcursor - - - - diff --git a/libsrc/atari/cvline.s b/libsrc/atari/cvline.s index 608da23de..5b1c3fd09 100644 --- a/libsrc/atari/cvline.s +++ b/libsrc/atari/cvline.s @@ -10,6 +10,12 @@ .import popa, _gotoxy, putchar, setcursor .importzp tmp1 +.ifndef __ATARI5200__ +CHRCODE = $7C ; Vertical bar +.else +CHRCODE = 1 ; exclamation mark +.endif + _cvlinexy: pha ; Save the length jsr popa ; Get y @@ -22,7 +28,7 @@ _cvline: sta tmp1 L1: lda COLCRS pha - lda #$7C ; Vertical bar + lda #CHRCODE ; Vertical bar jsr putchar ; Write, no cursor advance pla sta COLCRS @@ -30,6 +36,3 @@ L1: lda COLCRS dec tmp1 bne L1 L9: jmp setcursor - - - diff --git a/libsrc/atari5200/cclear.s b/libsrc/atari5200/cclear.s new file mode 100644 index 000000000..4bdc8ddf1 --- /dev/null +++ b/libsrc/atari5200/cclear.s @@ -0,0 +1 @@ +.include "../atari/cclear.s" diff --git a/libsrc/atari5200/chline.s b/libsrc/atari5200/chline.s new file mode 100644 index 000000000..d5872f149 --- /dev/null +++ b/libsrc/atari5200/chline.s @@ -0,0 +1 @@ +.include "../atari/chline.s" diff --git a/libsrc/atari5200/clock.s b/libsrc/atari5200/clock.s new file mode 100644 index 000000000..d70794b8d --- /dev/null +++ b/libsrc/atari5200/clock.s @@ -0,0 +1,35 @@ +; +; from Atari computer version by Christian Groessler, 2014 +; +; clock_t clock (void); +; unsigned _clocks_per_sec (void); +; + + .export _clock, __clocks_per_sec + .importzp sreg + + .include "atari5200.inc" + + +.proc _clock + + ldx #5 ; Synchronize with Antic, so the interrupt won't change RTCLOK + stx WSYNC ; while we're reading it. The synchronization is done same as +@L1: dex ; in SETVBLV function in Atari OS. + bne @L1 + stx sreg+1 ; Byte 3 is always zero + stx sreg ; Byte 2 is always zero, too + lda RTCLOK+1 + ldx RTCLOK + rts + +.endproc + + +.proc __clocks_per_sec + + ldx #$00 ; Clear high byte of return value + lda #60 + rts + +.endproc diff --git a/libsrc/atari5200/cvline.s b/libsrc/atari5200/cvline.s new file mode 100644 index 000000000..d987bcb62 --- /dev/null +++ b/libsrc/atari5200/cvline.s @@ -0,0 +1 @@ +.include "../atari/cvline.s" diff --git a/libsrc/atari5200/sysuname.s b/libsrc/atari5200/sysuname.s new file mode 100644 index 000000000..7fd9281a1 --- /dev/null +++ b/libsrc/atari5200/sysuname.s @@ -0,0 +1,39 @@ +; +; Ullrich von Bassewitz, 2003-08-12 +; +; unsigned char __fastcall__ _sysuname (struct utsname* buf); +; + + .export __sysuname, utsdata + + .import utscopy + + __sysuname = utscopy + +;-------------------------------------------------------------------------- +; Data. We define a fixed utsname struct here and just copy it. + +.rodata + +utsdata: + ; sysname + .asciiz "cc65" + + ; nodename + .asciiz "" + + ; release + .byte ((.VERSION >> 8) & $0F) + '0' + .byte '.' + .byte ((.VERSION >> 4) & $0F) + '0' + .byte $00 + + ; version + .byte (.VERSION & $0F) + '0' + .byte $00 + + ; machine + .asciiz "Atari5200" + + + From 84c655a907a8bd48739ea75a0e5106d32176696d Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Thu, 13 Mar 2014 02:36:10 +0100 Subject: [PATCH 04/30] use __RESERVED_MEMORY__ to reserve memory for the default 20x24 text screen --- cfg/atari5200.cfg | 17 +++++++++-------- libsrc/atari5200/crt0.s | 8 ++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cfg/atari5200.cfg b/cfg/atari5200.cfg index ff74f2b7c..294cad26e 100644 --- a/cfg/atari5200.cfg +++ b/cfg/atari5200.cfg @@ -1,14 +1,15 @@ SYMBOLS { - __CARTSIZE__: type = weak, value = $4000; # possible values: $4000 and $8000 - __CART_ENTRY__: type = import; - __STACKSIZE__: type = weak, value = $0300; # 3 pages stack + __CARTSIZE__: type = weak, value = $4000; # possible values: $4000 and $8000 + __CART_ENTRY__: type = import; + __STACKSIZE__: type = weak, value = $0400; # 4 pages stack + __RESERVED_MEMORY__: type = export, value = $0200; # space for display list and 20x24 screen buffer } MEMORY { - ZP: file = "", start = $0019, size = $00E7, define = yes; - RAM: file = "", start = $021C, size = $4000 - __STACKSIZE__ - $021C, define = yes; - ROM: file = %O, start = $C000 - __CARTSIZE__, size = __CARTSIZE__ - $18, define = yes, fill = yes, fillval = $FF; - CARTNAME: file = %O, start = $BFE8, size = $0014 fill = yes, fillval = $40; - CARTYEAR: file = %O, start = $BFFC, size = $0002 fill = yes, fillval = $59; + ZP: file = "", start = $0019, size = $00E7, define = yes; + RAM: file = "", start = $021C, size = $4000 - __STACKSIZE__ - __RESERVED_MEMORY__ - $021C, define = yes; + ROM: file = %O, start = $C000 - __CARTSIZE__, size = __CARTSIZE__ - $18, define = yes, fill = yes, fillval = $FF; + CARTNAME: file = %O, start = $BFE8, size = $0014 fill = yes, fillval = $40; + CARTYEAR: file = %O, start = $BFFC, size = $0002 fill = yes, fillval = $59; CARTENTRY: file = %O, start = $BFFE, size = $0002; } SEGMENTS { diff --git a/libsrc/atari5200/crt0.s b/libsrc/atari5200/crt0.s index 3944cd2bf..56b58a541 100644 --- a/libsrc/atari5200/crt0.s +++ b/libsrc/atari5200/crt0.s @@ -6,8 +6,8 @@ .export _exit, start .export __STARTUP__ : absolute = 1 ; Mark as startup - .import __RAM_START__, __RAM_SIZE__ - .import __RESERVED_MEMORY__ + .import __RAM_START__, __RAM_SIZE__ + .import __RESERVED_MEMORY__ .import initlib, donelib, callmain .import zerobss, copydata @@ -32,9 +32,9 @@ start: ; setup the stack - lda #<(__RAM_START__ + __RAM_SIZE__) + lda #<(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__) sta sp - lda #>(__RAM_START__ + __RAM_SIZE__) + lda #>(__RAM_START__ + __RAM_SIZE__ - __RESERVED_MEMORY__) sta sp+1 ; Set argument stack ptr ; Call module constructors From 30b418c734011a358d6c8c477dfc314c26f9fb40 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Thu, 13 Mar 2014 02:38:35 +0100 Subject: [PATCH 05/30] add gotox, gotoy, and gotoxy --- asminc/atari5200.inc | 26 ++++++++++++++++++++++++++ libsrc/atari5200/gotox.s | 15 +++++++++++++++ libsrc/atari5200/gotoxy.s | 19 +++++++++++++++++++ libsrc/atari5200/gotoy.s | 13 +++++++++++++ 4 files changed, 73 insertions(+) create mode 100644 libsrc/atari5200/gotox.s create mode 100644 libsrc/atari5200/gotoxy.s create mode 100644 libsrc/atari5200/gotoy.s diff --git a/asminc/atari5200.inc b/asminc/atari5200.inc index d6dd5e48e..d8bf93c7c 100644 --- a/asminc/atari5200.inc +++ b/asminc/atari5200.inc @@ -1,4 +1,26 @@ +;------------------------------------------------------------------------- +; ATASCII CHARACTER DEFS +;------------------------------------------------------------------------- + +ATCLR = $7D ;CLEAR SCREEN CHARACTER +ATRUB = $7E ;BACK SPACE (RUBOUT) +ATTAB = $7F ;TAB +ATEOL = $9B ;END-OF-LINE +ATDELL = $9C ;delete line +ATINSL = $9D ;insert line +ATCTAB = $9E ;clear TAB +ATSTAB = $9F ;set TAB +ATBEL = $FD ;CONSOLE BELL +ATDEL = $FE ;delete char. +ATINS = $FF ;insert char. +ATURW = $1C ;UP-ARROW +ATDRW = $1D ;DOWN-ARROW +ATLRW = $1E ;LEFT-ARROW +ATRRW = $1F ;RIGHT-ARROW +ATESC = $1B ;ESCAPE + + ;------------------------------------------------------------------------- ; Zero Page ;------------------------------------------------------------------------- @@ -34,6 +56,10 @@ PADDL6 = $17 ;POT6 " PADDL7 = $18 ;POT7 " +.importzp COLCRS_5200 +.importzp ROWCRS_5200 + + ;------------------------------------------------------------------------- ; Page #2 ;------------------------------------------------------------------------- diff --git a/libsrc/atari5200/gotox.s b/libsrc/atari5200/gotox.s new file mode 100644 index 000000000..be8cfe540 --- /dev/null +++ b/libsrc/atari5200/gotox.s @@ -0,0 +1,15 @@ +; +; Christian Groessler, 13-Mar-2014 +; +; void gotox (unsigned char x); +; + + .include "atari5200.inc" + .export _gotox + .import setcursor + +_gotox: + sta COLCRS_5200 ; Set X + lda #0 + sta COLCRS_5200+1 + jmp setcursor diff --git a/libsrc/atari5200/gotoxy.s b/libsrc/atari5200/gotoxy.s new file mode 100644 index 000000000..b4c86c95a --- /dev/null +++ b/libsrc/atari5200/gotoxy.s @@ -0,0 +1,19 @@ +; +; Christian Groessler, 13-Mar-2014 +; +; void gotoxy (unsigned char x, unsigned char y); +; + + .include "atari5200.inc" + + .export _gotoxy + .import popa + .import setcursor + +_gotoxy: ; Set the cursor position + sta ROWCRS_5200 ; Set Y + jsr popa ; Get X + sta COLCRS_5200 ; Set X + lda #0 + sta COLCRS_5200+1 ; + jmp setcursor diff --git a/libsrc/atari5200/gotoy.s b/libsrc/atari5200/gotoy.s new file mode 100644 index 000000000..fcdd05e4c --- /dev/null +++ b/libsrc/atari5200/gotoy.s @@ -0,0 +1,13 @@ +; +; Christian Groessler, 13-Mar-2014 +; +; void gotoy (unsigned char y); +; + + .include "atari5200.inc" + .export _gotoy + .import setcursor + +_gotoy: + sta ROWCRS_5200 ; Set Y + jmp setcursor From 92b32d7d0ec65534602e3edd6911ed9a31b673d6 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Fri, 25 Apr 2014 03:02:44 +0200 Subject: [PATCH 06/30] atari5200 update: simple conio "hello world" works now --- asminc/atari5200.inc | 7 +-- cfg/atari5200.cfg | 2 +- libsrc/atari5200/conioscreen.s | 67 ++++++++++++++++++++++++ libsrc/atari5200/cputc.s | 95 ++++++++++++++++++++++++++++++++++ libsrc/atari5200/crt0.s | 13 ++--- libsrc/atari5200/mul20.s | 33 ++++++++++++ libsrc/atari5200/setcursor.s | 49 ++++++++++++++++++ 7 files changed, 252 insertions(+), 14 deletions(-) create mode 100644 libsrc/atari5200/conioscreen.s create mode 100644 libsrc/atari5200/cputc.s create mode 100644 libsrc/atari5200/mul20.s create mode 100644 libsrc/atari5200/setcursor.s diff --git a/asminc/atari5200.inc b/asminc/atari5200.inc index d8bf93c7c..6ae2483d2 100644 --- a/asminc/atari5200.inc +++ b/asminc/atari5200.inc @@ -55,10 +55,11 @@ PADDL5 = $16 ;POT5 " PADDL6 = $17 ;POT6 " PADDL7 = $18 ;POT7 " +; cc65 runtime zero page variables -.importzp COLCRS_5200 -.importzp ROWCRS_5200 - +COLCRS_5200 = $19 +ROWCRS_5200 = $1A +SAVMSC = $1B ; pointer to screen memory (conio) ;------------------------------------------------------------------------- ; Page #2 diff --git a/cfg/atari5200.cfg b/cfg/atari5200.cfg index 294cad26e..fb151d4ec 100644 --- a/cfg/atari5200.cfg +++ b/cfg/atari5200.cfg @@ -5,7 +5,7 @@ SYMBOLS { __RESERVED_MEMORY__: type = export, value = $0200; # space for display list and 20x24 screen buffer } MEMORY { - ZP: file = "", start = $0019, size = $00E7, define = yes; + ZP: file = "", start = $001D, size = $00E3, define = yes; RAM: file = "", start = $021C, size = $4000 - __STACKSIZE__ - __RESERVED_MEMORY__ - $021C, define = yes; ROM: file = %O, start = $C000 - __CARTSIZE__, size = __CARTSIZE__ - $18, define = yes, fill = yes, fillval = $FF; CARTNAME: file = %O, start = $BFE8, size = $0014 fill = yes, fillval = $40; diff --git a/libsrc/atari5200/conioscreen.s b/libsrc/atari5200/conioscreen.s new file mode 100644 index 000000000..c9d95aa51 --- /dev/null +++ b/libsrc/atari5200/conioscreen.s @@ -0,0 +1,67 @@ + + .include "atari5200.inc" + +SCREEN_BUF_SIZE = 20 * 24 +SCREEN_BUF = $4000 - SCREEN_BUF_SIZE + + .code + .export screen_setup_20x24 + +screen_setup_20x24: + + ; initialize SAVMSC + lda #SCREEN_BUF + sta SAVMSC+1 + + ; initialize cursor position + lda #0 + sta COLCRS_5200 + sta ROWCRS_5200 + + ; clear screen buffer + ldy #<(SCREEN_BUF_SIZE-1) + ldx #>(SCREEN_BUF_SIZE-1) +clrscr: sta (SAVMSC),y + dey + cpy #$FF + bne clrscr + dex + cpx #$FF + bne clrscr + + ; set display list + + lda #dlist + sta SDLSTH + + rts + + + .segment "RODATA" + +; display list for 20x24 text mode + +dlist: .repeat 3 + .byte DL_BLK8 + .endrepeat + + .byte DL_CHR20x8x2 | DL_LMS + .word SCREEN_BUF + + .repeat 23 + .byte DL_CHR20x8x2 + .endrepeat + + .byte DL_JVB + .word dlist + +; end of display list + +.assert ((* >> 10) = (dlist >> 10)), error, "Display list crosses 1K boundary" + + + .end diff --git a/libsrc/atari5200/cputc.s b/libsrc/atari5200/cputc.s new file mode 100644 index 000000000..26527535d --- /dev/null +++ b/libsrc/atari5200/cputc.s @@ -0,0 +1,95 @@ +; +; adapted from Atari version +; Christian Groessler, 2014 +; +; void cputcxy (unsigned char x, unsigned char y, char c); +; void cputc (char c); +; + + .include "atari5200.inc" + + .export _cputcxy, _cputc + .export plot, cputdirect, putchar + .import popa, _gotoxy, mul20 + .importzp ptr4 + .import setcursor + + .constructor screen_setup, 26 + .import screen_setup_20x24 +screen_setup = screen_setup_20x24 + + +_cputcxy: + pha ; Save C + jsr popa ; Get Y + jsr _gotoxy ; Set cursor, drop x + pla ; Restore C + +_cputc: + cmp #$0D ; CR + bne L4 + lda #0 + sta COLCRS_5200 + beq plot ; return + +L4: cmp #$0A ; LF + beq newline + cmp #ATEOL ; Atari-EOL? + beq newline + + tay + rol a + rol a + rol a + rol a + and #3 + tax + tya + and #$9f + ora ataint,x + +cputdirect: ; accepts screen code + jsr putchar + +; advance cursor + inc COLCRS_5200 + lda COLCRS_5200 + cmp #40 + bcc plot + lda #0 + sta COLCRS_5200 + + .export newline +newline: + inc ROWCRS_5200 + lda ROWCRS_5200 + cmp #24 + bne plot + lda #0 + sta ROWCRS_5200 +plot: jsr setcursor + ldy COLCRS_5200 + ldx ROWCRS_5200 + rts + +; turn off cursor, update screen, turn on cursor +putchar: + pha ; save char + + lda ROWCRS_5200 + jsr mul20 ; destroys tmp4 + clc + adc SAVMSC ; add start of screen memory + sta ptr4 + txa + adc SAVMSC+1 + sta ptr4+1 + pla ; get char again + + ldy COLCRS_5200 + sta (ptr4),y + jmp setcursor + + .rodata +ataint: .byte 64,0,32,96 + diff --git a/libsrc/atari5200/crt0.s b/libsrc/atari5200/crt0.s index 56b58a541..a62d69703 100644 --- a/libsrc/atari5200/crt0.s +++ b/libsrc/atari5200/crt0.s @@ -1,7 +1,7 @@ ; ; Startup code for cc65 (Atari5200 version) ; -; by Christian Groessler (chris@groessler.org), 2014 +; Christian Groessler (chris@groessler.org), 2014 ; .export _exit, start @@ -15,12 +15,6 @@ .include "zeropage.inc" .include "atari5200.inc" - -; ------------------------------------------------------------------------ -; Place the startup code in a special segment. - -.segment "STARTUP" - start: ; Clear the BSS data @@ -49,7 +43,6 @@ start: _exit: jsr donelib ; Run module destructors -; Reset the NES - - jmp start +; A 5200 program isn't supposed to exit. +halt: jmp halt diff --git a/libsrc/atari5200/mul20.s b/libsrc/atari5200/mul20.s new file mode 100644 index 000000000..fc67b34e4 --- /dev/null +++ b/libsrc/atari5200/mul20.s @@ -0,0 +1,33 @@ +; +; Christian Groessler, April 2014 +; +; mul20 +; multiplies A by 20 and returns result in AX +; uses tmp4 + + .importzp tmp4 + .export mul20,loc_tmp + +.proc mul20 + + 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 ; val * 20 + ldx tmp4 + rts + +.endproc + + .bss +loc_tmp:.res 1 diff --git a/libsrc/atari5200/setcursor.s b/libsrc/atari5200/setcursor.s new file mode 100644 index 000000000..00195f1cf --- /dev/null +++ b/libsrc/atari5200/setcursor.s @@ -0,0 +1,49 @@ + + + .include "atari5200.inc" + .export setcursor + .import cursor ; from conio/_cursor.s + + + +.proc setcursor + + rts + +.if 0 + ldy #0 + + lda ROWCRS_5200 + jsr mul20 + clc +; adc SAVMSC ; add start of screen memory +; sta OLDADR + txa +; adc SAVMSC+1 +; sta OLDADR+1 + lda COLCRS_5200 +; 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 +.endif + +.endproc From 1532ad67925c29d4c64fba830fd65cdfc760d24c Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Mon, 12 May 2014 03:02:17 +0200 Subject: [PATCH 07/30] add dummy irq.s --- libsrc/atari5200/irq.s | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 libsrc/atari5200/irq.s diff --git a/libsrc/atari5200/irq.s b/libsrc/atari5200/irq.s new file mode 100644 index 000000000..2acab1826 --- /dev/null +++ b/libsrc/atari5200/irq.s @@ -0,0 +1,14 @@ +; +; IRQ handling (ATARI 5200 version) +; + + .export initirq, doneirq + .import callirq + + .include "atari5200.inc" + +; Dummy versions for now + +initirq: +doneirq: + rts From 82544b86788769b6c66bfb41784c8b820610f678 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Mon, 12 May 2014 03:03:44 +0200 Subject: [PATCH 08/30] add joystick driver -- trigger buttons are not queried yet --- libsrc/atari5200/joy/atr5200std.s | 130 +++++++++++++++++++++++++++++ libsrc/atari5200/joy_stat_stddrv.s | 12 +++ libsrc/atari5200/libref.s | 8 ++ 3 files changed, 150 insertions(+) create mode 100644 libsrc/atari5200/joy/atr5200std.s create mode 100644 libsrc/atari5200/joy_stat_stddrv.s create mode 100644 libsrc/atari5200/libref.s diff --git a/libsrc/atari5200/joy/atr5200std.s b/libsrc/atari5200/joy/atr5200std.s new file mode 100644 index 000000000..2a506983d --- /dev/null +++ b/libsrc/atari5200/joy/atr5200std.s @@ -0,0 +1,130 @@ +; +; Standard joystick driver for the Atari 5200. +; +; Christian Groessler, 2014-05-12 +; + + .include "zeropage.inc" + + .include "joy-kernel.inc" + .include "joy-error.inc" + .include "atari5200.inc" + + +; ------------------------------------------------------------------------ +; Header. Includes jump table + +.segment "JUMPTABLE" + +; Driver signature + + .byte $6A, $6F, $79 ; "joy" + .byte JOY_API_VERSION ; Driver API version number + +; Library reference + + .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 $20 ; JOY_FIRE2 + .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 + +JOY_COUNT = 4 ; Number of joysticks we support + + +.code + +; ------------------------------------------------------------------------ +; INSTALL routine. Is called after the driver is loaded into memory. If +; possible, check if the hardware is present and determine the amount of +; memory available. +; Must return an JOY_ERR_xx code in a/x. +; + +INSTALL: + lda #JOY_ERR_OK + ldx #0 +; rts ; Run into UNINSTALL instead + +; ------------------------------------------------------------------------ +; UNINSTALL routine. Is called before the driver is removed from memory. +; Can do cleanup or whatever. Must not return anything. +; + +UNINSTALL: + rts + + +; ------------------------------------------------------------------------ +; COUNT: Return the total number of available joysticks in a/x. +; + +COUNT: + lda #JOY_COUNT + ldx #0 + rts + +; ------------------------------------------------------------------------ +; READ: Read a particular joystick passed in A. +; + +CENTER = 228 / 2 +SENSIVITY = 16 + +READJOY: + and #3 ; fix joystick number + asl a + tax ; Joystick number * 2 (0-6) into X, index into ZP shadow registers + lda #0 ; Initialize return value + +; Read joystick + + ldy PADDL0,x ; get horizontal position + cpy #CENTER-SENSIVITY + bcs @chkleft + + ora #4 ; JOY_LEFT + bne @updown + +@chkleft: + cpy #CENTER+SENSIVITY + bcc @updown + + ora #8 ; JOY_RIGHT + +@updown:ldy PADDL0+1,x ; get vertical position + cpy #CENTER-SENSIVITY + bcs @chkdown + + ora #1 ; JOY_UP + bne @buttons + +@chkdown: + cpy #CENTER+SENSIVITY + bcc @buttons + + ora #2 ; JOY_DOWN + +@buttons: + ; @@@ TODO: BOTTON STATE + + rts + diff --git a/libsrc/atari5200/joy_stat_stddrv.s b/libsrc/atari5200/joy_stat_stddrv.s new file mode 100644 index 000000000..9924eab73 --- /dev/null +++ b/libsrc/atari5200/joy_stat_stddrv.s @@ -0,0 +1,12 @@ +; +; Address of the static standard joystick driver +; +; Christian Groessler, 2014-05-12 +; +; const void joy_static_stddrv[]; +; + + .export _joy_static_stddrv + .import _atr5200std_joy + +_joy_static_stddrv := _atr5200std_joy diff --git a/libsrc/atari5200/libref.s b/libsrc/atari5200/libref.s new file mode 100644 index 000000000..8a5fbe4e0 --- /dev/null +++ b/libsrc/atari5200/libref.s @@ -0,0 +1,8 @@ +; +; Christian Groessler, 2014-05-12 +; + + .export joy_libref + .import _exit + +joy_libref := _exit From 8cb68071cd1b338b446956a302f545f8ab3fda2f Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Mon, 12 May 2014 03:05:21 +0200 Subject: [PATCH 09/30] clrscr for Atari 5200 default conio screen --- libsrc/atari5200/clrscr.s | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 libsrc/atari5200/clrscr.s diff --git a/libsrc/atari5200/clrscr.s b/libsrc/atari5200/clrscr.s new file mode 100644 index 000000000..041f34a67 --- /dev/null +++ b/libsrc/atari5200/clrscr.s @@ -0,0 +1,34 @@ +; +; Christian Groessler, May-2014 +; +; void clrscr (void); +; + + .export _clrscr + .include "atari5200.inc" + .importzp ptr1 + +SCRSIZE = 480 ; 20x24: size of default conio atari5200 screen + +_clrscr:lda SAVMSC ; screen memory + sta ptr1 + lda SAVMSC+1 + clc + adc #>(SCRSIZE-1) + sta ptr1+1 + lda #0 ; screen code of space char + ldy #<(SCRSIZE-1) + ldx #>(SCRSIZE-1) +_clr1: sta (ptr1),y + dey + bne _clr1 + sta (ptr1),y + dex + bmi done + dec ptr1+1 + dey + jmp _clr1 + +done: sta COLCRS_5200 + sta ROWCRS_5200 + rts From 0f2f19ef5b2c4773176442d4efb4c9e92fb34707 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Fri, 16 May 2014 02:10:19 +0200 Subject: [PATCH 10/30] some CONIO fixes --- asminc/atari5200.inc | 4 +- libsrc/atari5200/conioscreen.s | 67 ++++++++++++++++++++-------------- libsrc/atari5200/cputc.s | 3 +- libsrc/atari5200/gotox.s | 2 - libsrc/atari5200/gotoxy.s | 2 - 5 files changed, 43 insertions(+), 35 deletions(-) diff --git a/asminc/atari5200.inc b/asminc/atari5200.inc index 6ae2483d2..10b71eba5 100644 --- a/asminc/atari5200.inc +++ b/asminc/atari5200.inc @@ -57,8 +57,8 @@ PADDL7 = $18 ;POT7 " ; cc65 runtime zero page variables -COLCRS_5200 = $19 -ROWCRS_5200 = $1A +ROWCRS_5200 = $19 +COLCRS_5200 = $1A SAVMSC = $1B ; pointer to screen memory (conio) ;------------------------------------------------------------------------- diff --git a/libsrc/atari5200/conioscreen.s b/libsrc/atari5200/conioscreen.s index c9d95aa51..ba47866ce 100644 --- a/libsrc/atari5200/conioscreen.s +++ b/libsrc/atari5200/conioscreen.s @@ -1,44 +1,57 @@ .include "atari5200.inc" -SCREEN_BUF_SIZE = 20 * 24 -SCREEN_BUF = $4000 - SCREEN_BUF_SIZE +SCREEN_BUF_SIZE = 20 * 24 +SCREEN_BUF = $4000 - SCREEN_BUF_SIZE .code .export screen_setup_20x24 screen_setup_20x24: - ; initialize SAVMSC - lda #SCREEN_BUF - sta SAVMSC+1 + ; initialize SAVMSC + lda #SCREEN_BUF + sta SAVMSC+1 - ; initialize cursor position - lda #0 - sta COLCRS_5200 - sta ROWCRS_5200 + ; initialize cursor position + lda #0 + sta COLCRS_5200 + sta ROWCRS_5200 - ; clear screen buffer - ldy #<(SCREEN_BUF_SIZE-1) - ldx #>(SCREEN_BUF_SIZE-1) -clrscr: sta (SAVMSC),y - dey - cpy #$FF - bne clrscr - dex - cpx #$FF - bne clrscr + ; clear screen buffer + ldy #<(SCREEN_BUF_SIZE-1) + ldx #>(SCREEN_BUF_SIZE-1) +clrscr: sta (SAVMSC),y + dey + cpy #$FF + bne clrscr + dex + cpx #$FF + bne clrscr - ; set display list + ; set default colors - lda #dlist - sta SDLSTH + lda #40 + sta COLOR0 + lda #202 + sta COLOR1 + lda #148 + sta COLOR2 + lda #70 + sta COLOR3 + lda #0 + sta COLOR4 - rts + ; set display list + + lda #dlist + sta SDLSTH + + rts .segment "RODATA" diff --git a/libsrc/atari5200/cputc.s b/libsrc/atari5200/cputc.s index 26527535d..976f910f0 100644 --- a/libsrc/atari5200/cputc.s +++ b/libsrc/atari5200/cputc.s @@ -54,7 +54,7 @@ cputdirect: ; accepts screen code ; advance cursor inc COLCRS_5200 lda COLCRS_5200 - cmp #40 + cmp #20 bcc plot lda #0 sta COLCRS_5200 @@ -72,7 +72,6 @@ plot: jsr setcursor ldx ROWCRS_5200 rts -; turn off cursor, update screen, turn on cursor putchar: pha ; save char diff --git a/libsrc/atari5200/gotox.s b/libsrc/atari5200/gotox.s index be8cfe540..99f7cfd22 100644 --- a/libsrc/atari5200/gotox.s +++ b/libsrc/atari5200/gotox.s @@ -10,6 +10,4 @@ _gotox: sta COLCRS_5200 ; Set X - lda #0 - sta COLCRS_5200+1 jmp setcursor diff --git a/libsrc/atari5200/gotoxy.s b/libsrc/atari5200/gotoxy.s index b4c86c95a..a4b7c61d0 100644 --- a/libsrc/atari5200/gotoxy.s +++ b/libsrc/atari5200/gotoxy.s @@ -14,6 +14,4 @@ _gotoxy: ; Set the cursor position sta ROWCRS_5200 ; Set Y jsr popa ; Get X sta COLCRS_5200 ; Set X - lda #0 - sta COLCRS_5200+1 ; jmp setcursor From b8e5a66f29587f3108c107667c8aca767f75e859 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Fri, 16 May 2014 02:12:01 +0200 Subject: [PATCH 11/30] changed version, startup screen now not fine anymore --- asminc/atari5200.mac | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/asminc/atari5200.mac b/asminc/atari5200.mac index ece654bcc..59d7ff29c 100644 --- a/asminc/atari5200.mac +++ b/asminc/atari5200.mac @@ -1,7 +1,14 @@ ; Convert characters to screen codes - + ; Helper macro that converts and outputs one character .macro _scrcode char +.if 1 + .if (char >= 96) .and (char <= 127) + .byte (char) + .else + .byte (char - 32) + .endif +.else .if (char >= 0) .and (char <= 31) .byte (char + 64) .elseif (char >= 32) .and (char <= 95) @@ -17,6 +24,7 @@ .else .error "scrcode: Character constant out of range" .endif +.endif .endmacro .macro scrcode arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 @@ -56,4 +64,3 @@ ; Call the macro recursively with the remaining args scrcode arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 .endmacro - From c382c5957940579ae467996c35ab87419c464644 Mon Sep 17 00:00:00 2001 From: Christian Groessler Date: Fri, 16 May 2014 02:26:20 +0200 Subject: [PATCH 12/30] documentation updates for Atari 5200 --- README.md | 1 + doc/atari5200.sgml | 182 +++++++++++++++++++++++++++++++++++++++++++++ doc/ca65.sgml | 1 + doc/cc65.sgml | 4 + 4 files changed, 188 insertions(+) create mode 100644 doc/atari5200.sgml diff --git a/README.md b/README.md index 39e4ef54c..c36f14c44 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ including - newer PET machines (not 2001). - the Apple ][+ and successors. - the Atari 8 bit machines. +- the Atari 5200 console. - GEOS for the C64 and C128. - the Nintendo Entertainment System (NES). - the Supervision console. diff --git a/doc/atari5200.sgml b/doc/atari5200.sgml new file mode 100644 index 000000000..325602b37 --- /dev/null +++ b/doc/atari5200.sgml @@ -0,0 +1,182 @@ + + +
+ +Atari 5200 specific information for cc65 +<author> +<url url="mailto:chris@groessler.org" name="Christian Groessler"><newline> +<date>2014-05-15 + +<abstract> +An overview over the Atari 5200 runtime system as it is implemented for the +cc65 C compiler. +</abstract> + +<!-- Table of contents --> +<toc> + +<!-- Begin the document --> + +<sect>Overview<p> + +This file contains an overview of the Atari 5200 runtime system as it comes +with the cc65 C compiler. It describes the memory layout, Atari 5200 specific header +files, available drivers, and any pitfalls specific to that platform. + +Please note that Atari 5200 specific functions are just mentioned here, they are +described in detail in the separate <url url="funcref.html" name="function +reference">. Even functions marked as "platform dependent" may be available on +more than one platform. Please see the function reference for more +information. + + +<sect>Binary format<p> + +The standard binary output format generated by the linker for the Atari 5200 target +is a cartridge image. It is of course +possible to change this behaviour by using a modified startup file and linker +config. + +<sect>Memory layout<p> + +cc65 generated programs with the default setup run with the I/O area and a +CHR bank enabled, which gives a usable memory range of $8000 - $FFF3. +All boot ROM entry points may be called directly without additional code. + +Special locations: + +<descrip> + <tag/Text screen/ + The text screen is located at VRAM $2000. + + <tag/Stack/ + The C runtime stack is located at $7FFF and growing downwards. + + <tag/Heap/ + The C heap is located at the end of the program and grows towards the C + runtime stack. + +</descrip><p> + + + +<sect>Platform specific header files<p> + +Programs containing Atari 5200 specific code may use the <tt/atari5200.h/ header file. + + +<sect1>Atari 5200 specific functions<p> + +<itemize> +<item>??? +</itemize> + + + +<sect1>Hardware access<p> + +The following pseudo variables declared in the <tt/nes.inc/ include file do +allow access to hardware located in the address space. + +<descrip> + + <tag><tt/PPU/</tag> + The <tt/PPU/ defines allow access to the PPU chip. + + <tag><tt/APU/</tag> + The <tt/APU/ defines allow access to the APU chip. + +</descrip><p> + + + +<sect>Loadable drivers<p> + +All drivers must be statically linked because no file I/O is available. +The names in the parentheses denote the symbols to be used for static linking of the drivers. + + +<sect1>Graphics drivers<p> + +<descrip> + +No graphics drivers are currently available for the Atari 5200. + +</descrip><p> + + +<sect1>Extended memory drivers<p> + +No extended memory drivers are available for the Atari 5200. + + +<sect1>Joystick drivers<p> + +<descrip> + + <tag><tt/atr5200std.joy (atr5200std_joy)/</tag> + A joystick driver for the standard Atari 5200 joystick is available. Up to four joysticks can be attached. + +</descrip><p> + + +<sect1>Mouse drivers<p> + +No mouse drivers are available for the Atari 5200. + + +<sect1>RS232 device drivers<p> + +No serial drivers are available for the Atari 5200. + + + +<sect>Limitations<p> + +<sect1>Disk I/O<p> + +The existing library for the Atari 5200 doesn't implement C file +I/O. There are no hacks for the <tt/read()/ and <tt/write()/ routines. + +To be more concrete, this limitation means that you cannot use any of the +following functions (and a few others): + +<itemize> +<item>fclose +<item>fopen +<item>fread +<item>fprintf +<item>fputc +<item>fscanf +<item>fwrite +<item>... +</itemize> + + + +<sect>Other hints<p> + + + +<sect>License<p> + +This software is provided 'as-is', without any expressed or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +<enum> +<item> The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +<item> Altered source versions must be plainly marked as such, and must not + be misrepresented as being the original software. +<item> This notice may not be removed or altered from any source + distribution. +</enum> + +</article> diff --git a/doc/ca65.sgml b/doc/ca65.sgml index caf022c16..79dd41092 100644 --- a/doc/ca65.sgml +++ b/doc/ca65.sgml @@ -4396,6 +4396,7 @@ compiler, depending on the target system selected: <itemize> <item><tt/__APPLE2__/ - Target system is <tt/apple2/ or <tt/apple2enh/ <item><tt/__APPLE2ENH__/ - Target system is <tt/apple2enh/ +<item><tt/__ATARI5200__/ - Target system is <tt/atari5200/ <item><tt/__ATARI__/ - Target system is <tt/atari/ or <tt/atarixl/ <item><tt/__ATARIXL__/ - Target system is <tt/atarixl/ <item><tt/__ATMOS__/ - Target system is <tt/atmos/ diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 275a73168..a6b4a07ee 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -709,6 +709,10 @@ The compiler defines several macros at startup: This macro is defined if the target is the enhanced Apple //e (-t apple2enh). + <tag><tt>__ATARI5200__</tt></tag> + + This macro is defined if the target is the Atari 5200 game console. + <tag><tt>__ATARI__</tt></tag> This macro is defined if the target is the Atari 400/800 (-t atari) or the Atari 800XL/130XE (-t atarixl). From f1ece57c057a528509d7041c7992d5f54ccbef0c Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Fri, 16 May 2014 02:27:20 +0200 Subject: [PATCH 13/30] more documentation updates for Atari 5200 --- doc/index.sgml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/index.sgml b/doc/index.sgml index f9eed769d..c77344865 100644 --- a/doc/index.sgml +++ b/doc/index.sgml @@ -107,6 +107,9 @@ <tag><htmlurl url="atari.html" name="atari.html"></tag> Topics specific to the Atari 8-bit machines. + <tag><htmlurl url="atari5200.html" name="atari5200.html"></tag> + Topics specific to the Atari 5200 Game Console. + <tag><htmlurl url="atmos.html" name="atmos.html"></tag> Topics specific to the Oric Atmos. From b6f712ef58631992337e99dc032e162366f0264f Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 27 May 2014 01:47:37 +0200 Subject: [PATCH 14/30] not a dummy implementation anymore... --- libsrc/atari5200/irq.s | 47 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/libsrc/atari5200/irq.s b/libsrc/atari5200/irq.s index 2acab1826..720113f82 100644 --- a/libsrc/atari5200/irq.s +++ b/libsrc/atari5200/irq.s @@ -7,8 +7,53 @@ .include "atari5200.inc" -; Dummy versions for now +; ------------------------------------------------------------------------ + +.segment "INIT" initirq: + lda VVBLKD + ldx VVBLKD+1 + sta IRQInd+1 + stx IRQInd+2 + ldy #<IRQStub + ldx #>IRQStub + jmp SETVBV + +; ------------------------------------------------------------------------ + +.code + doneirq: + ldy IRQInd+1 + ldx IRQInd+2 + ;jmp SETVBV + ; fall thru + +; ------------------------------------------------------------------------ +; Set deferred vertical blank interrupt +; logic copied from Atari computer ROM + +SETVBV: txa + ldx #5 + sta WSYNC ; waste 20 CPU cycles +@1: dex ; to allow VBLANK to happen + bne @1 ; if this is line "7C" + sta VVBLKD+1 + sty VVBLKD rts + +; ------------------------------------------------------------------------ + +.segment "LOWCODE" + +IRQStub: + cld ; Just to be sure + jsr callirq ; Call the functions + jmp IRQInd ; Jump to the saved IRQ vector + +; ------------------------------------------------------------------------ + +.data + +IRQInd: jmp $0000 From d9a8ea3b6c750831d79c782bd53773cffecbabf3 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 27 May 2014 02:43:17 +0200 Subject: [PATCH 15/30] Don't reserve space for display list in __RESERVED_MEMORY__ since the default display list is in ROM. --- cfg/atari5200.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cfg/atari5200.cfg b/cfg/atari5200.cfg index fb151d4ec..4a90303cf 100644 --- a/cfg/atari5200.cfg +++ b/cfg/atari5200.cfg @@ -2,7 +2,7 @@ SYMBOLS { __CARTSIZE__: type = weak, value = $4000; # possible values: $4000 and $8000 __CART_ENTRY__: type = import; __STACKSIZE__: type = weak, value = $0400; # 4 pages stack - __RESERVED_MEMORY__: type = export, value = $0200; # space for display list and 20x24 screen buffer + __RESERVED_MEMORY__: type = export, value = $01E0; # space for 20x24 screen buffer (default display list is in ROM) } MEMORY { ZP: file = "", start = $001D, size = $00E3, define = yes; From 40d7ebd7191877e1ad7172c0c24448910122f7db Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Tue, 27 May 2014 02:44:59 +0200 Subject: [PATCH 16/30] more doc updates for atari5200 --- doc/atari5200.sgml | 60 ++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/doc/atari5200.sgml b/doc/atari5200.sgml index 325602b37..cbddbd928 100644 --- a/doc/atari5200.sgml +++ b/doc/atari5200.sgml @@ -5,7 +5,7 @@ <title>Atari 5200 specific information for cc65 <author> <url url="mailto:chris@groessler.org" name="Christian Groessler"><newline> -<date>2014-05-15 +<date>2014-05-27 <abstract> An overview over the Atari 5200 runtime system as it is implemented for the @@ -39,18 +39,29 @@ config. <sect>Memory layout<p> -cc65 generated programs with the default setup run with the I/O area and a -CHR bank enabled, which gives a usable memory range of $8000 - $FFF3. -All boot ROM entry points may be called directly without additional code. +cc65 generated programs with the default setup use the RAM space from $021C to +$3FFF. If you want to reserve memory for the display list and screen buffer +you should define the __RESERVED_MEMORY__ linker variable. The number +of bytes specified by __RESERVED_MEMORY__ are lowering the top of +memory, therefore the available +RAM memory for the program is $021C to $3FFF-__RESERVED_MEMORY__. +The default linker config file sets __RESERVED_MEMORY__ to $1E0 +to reserve space for an optional CONIO text screen. Special locations: <descrip> <tag/Text screen/ - The text screen is located at VRAM $2000. + The text screen is only enabled if any of the CONIO output routines + is used in the program. Its size is 20x24 characters (Antic mode 6, + BASIC mode 1). The text screen is located at $3E00. The + address of the screen memory is available at runtime in the variable + SAVMSC ($001B).<p> + If the program doesn't use any CONIO output functions it needs to setup its own + display list. <tag/Stack/ - The C runtime stack is located at $7FFF and growing downwards. + The C runtime stack is located at $3FFF-__RESERVED_MEMORY__ and growing downwards. <tag/Heap/ The C heap is located at the end of the program and grows towards the C @@ -68,31 +79,43 @@ Programs containing Atari 5200 specific code may use the <tt/atari5200.h/ header <sect1>Atari 5200 specific functions<p> <itemize> -<item>??? +<item>TBD. </itemize> <sect1>Hardware access<p> -The following pseudo variables declared in the <tt/nes.inc/ include file do -allow access to hardware located in the address space. +The following pseudo variables declared in the <tt/atari5200.h/ header +file do allow access to hardware located in the address space. Some +variables are structures, accessing the struct fields will access the +chip registers. <descrip> - <tag><tt/PPU/</tag> - The <tt/PPU/ defines allow access to the PPU chip. + <tag><tt/GTIA_READ/ and <tt/GTIA_WRITE/</tag> + The <tt/GTIA_READ/ structure allows read access to the GTIA. The + <tt/GTIA_WRITE/ structure allows write access to the GTIA. + See the <tt/_gtia.h/ header file located in the include directory + for the declaration of the structure. - <tag><tt/APU/</tag> - The <tt/APU/ defines allow access to the APU chip. + <tag><tt/POKEY_READ/ and <tt/POKEY_WRITE/</tag> + The <tt/POKEY_READ/ structure allows read access to the POKEY. The + <tt/POKEY_WRITE/ structure allows write access to the POKEY. + See the <tt/_pokey.h/ header file located in the include directory + for the declaration of the structure. + + <tag><tt/ANTIC/</tag> + The <tt/ANTIC/ structure allows read access to the ANTIC. + See the <tt/_antic.h/ header file located in the include directory + for the declaration of the structure. </descrip><p> - <sect>Loadable drivers<p> -All drivers must be statically linked because no file I/O is available. +All drivers must be statically linked because no disk I/O is available. The names in the parentheses denote the symbols to be used for static linking of the drivers. @@ -135,11 +158,8 @@ No serial drivers are available for the Atari 5200. <sect1>Disk I/O<p> -The existing library for the Atari 5200 doesn't implement C file -I/O. There are no hacks for the <tt/read()/ and <tt/write()/ routines. - -To be more concrete, this limitation means that you cannot use any of the -following functions (and a few others): +Disk I/O is not supported by the <tt/atari5200/ target. This means that +you cannot use any of the following functions (and a few others): <itemize> <item>fclose From 803e9904db2f4d260cdfdcc8a0d65e27c89d8b40 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 28 May 2014 00:34:34 +0200 Subject: [PATCH 17/30] small doc update --- doc/atari5200.sgml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/atari5200.sgml b/doc/atari5200.sgml index cbddbd928..e9bff451a 100644 --- a/doc/atari5200.sgml +++ b/doc/atari5200.sgml @@ -52,7 +52,7 @@ Special locations: <descrip> <tag/Text screen/ - The text screen is only enabled if any of the CONIO output routines + The text screen is only enabled if any of the CONIO output functions is used in the program. Its size is 20x24 characters (Antic mode 6, BASIC mode 1). The text screen is located at $3E00. The address of the screen memory is available at runtime in the variable @@ -138,7 +138,8 @@ No extended memory drivers are available for the Atari 5200. <descrip> <tag><tt/atr5200std.joy (atr5200std_joy)/</tag> - A joystick driver for the standard Atari 5200 joystick is available. Up to four joysticks can be attached. + A joystick driver for the standard Atari 5200 joystick is + available. Depending on the version of the 5200 console, two or four joysticks can be attached. </descrip><p> From 98195a516ebad1aa67dedd2b9193e1d6f8848785 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 28 May 2014 00:35:49 +0200 Subject: [PATCH 18/30] check trigger button (TRIGx); correctly report joystick count depending on 5200 console version --- libsrc/atari5200/joy/atr5200std.s | 86 +++++++++++++++---------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/libsrc/atari5200/joy/atr5200std.s b/libsrc/atari5200/joy/atr5200std.s index 2a506983d..929ad09fe 100644 --- a/libsrc/atari5200/joy/atr5200std.s +++ b/libsrc/atari5200/joy/atr5200std.s @@ -1,7 +1,7 @@ ; ; Standard joystick driver for the Atari 5200. ; -; Christian Groessler, 2014-05-12 +; Christian Groessler, 2014-05-28 ; .include "zeropage.inc" @@ -27,14 +27,14 @@ ; 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 $20 ; JOY_FIRE2 - .byte $00 ; Future expansion - .byte $00 ; Future expansion + .byte $01 ; JOY_UP + .byte $02 ; JOY_DOWN + .byte $04 ; JOY_LEFT + .byte $08 ; JOY_RIGHT + .byte $10 ; JOY_FIRE + .byte $20 ; JOY_FIRE2 + .byte $00 ; Future expansion + .byte $00 ; Future expansion ; Jump table. @@ -42,13 +42,7 @@ .addr UNINSTALL .addr COUNT .addr READJOY - .addr 0 ; IRQ entry not used - -; ------------------------------------------------------------------------ -; Constants - -JOY_COUNT = 4 ; Number of joysticks we support - + .addr 0 ; IRQ entry not used .code @@ -78,7 +72,12 @@ UNINSTALL: ; COUNT: - lda #JOY_COUNT + lda $FD32 ; check ROM version + cmp #$E8 + bne @2port + lda #4 + .byte $2C ; bit opcode, eats the next 2 bytes +@2port: lda #2 ldx #0 rts @@ -86,45 +85,46 @@ COUNT: ; READ: Read a particular joystick passed in A. ; -CENTER = 228 / 2 -SENSIVITY = 16 +CENTER = 228 / 2 +SENSIVITY = 16 READJOY: - and #3 ; fix joystick number - asl a + and #3 ; put joystick number in range, just in case + tay + asl a tax ; Joystick number * 2 (0-6) into X, index into ZP shadow registers - lda #0 ; Initialize return value + + lda #0 ; Initialize return value + cmp TRIG0,y + bne @notrg + lda #$10 ; JOY_FIRE ; Read joystick - ldy PADDL0,x ; get horizontal position - cpy #CENTER-SENSIVITY - bcs @chkleft +@notrg: ldy PADDL0,x ; get horizontal position + cpy #CENTER-SENSIVITY + bcs @chkleft - ora #4 ; JOY_LEFT - bne @updown + ora #4 ; JOY_LEFT + bne @updown @chkleft: - cpy #CENTER+SENSIVITY - bcc @updown + cpy #CENTER+SENSIVITY + bcc @updown - ora #8 ; JOY_RIGHT + ora #8 ; JOY_RIGHT -@updown:ldy PADDL0+1,x ; get vertical position - cpy #CENTER-SENSIVITY - bcs @chkdown +@updown:ldy PADDL0+1,x ; get vertical position + cpy #CENTER-SENSIVITY + bcs @chkdown - ora #1 ; JOY_UP - bne @buttons + ora #1 ; JOY_UP + bne @done @chkdown: - cpy #CENTER+SENSIVITY - bcc @buttons + cpy #CENTER+SENSIVITY + bcc @done - ora #2 ; JOY_DOWN - -@buttons: - ; @@@ TODO: BOTTON STATE - - rts + ora #2 ; JOY_DOWN +@done: rts From 8c5aebef815714b4ff5472ccc75479bff7919b80 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 28 May 2014 23:38:22 +0200 Subject: [PATCH 19/30] cleanups and add comments --- libsrc/atari5200/conioscreen.s | 3 +++ libsrc/atari5200/setcursor.s | 46 +++------------------------------- 2 files changed, 7 insertions(+), 42 deletions(-) diff --git a/libsrc/atari5200/conioscreen.s b/libsrc/atari5200/conioscreen.s index ba47866ce..412dd582d 100644 --- a/libsrc/atari5200/conioscreen.s +++ b/libsrc/atari5200/conioscreen.s @@ -1,3 +1,6 @@ +; setup default CONIO screen (20x24, Antic mode 6, BASIC mode 1) +; +; 28-May-2014, Christian Groessler <chris@groessler.org> .include "atari5200.inc" diff --git a/libsrc/atari5200/setcursor.s b/libsrc/atari5200/setcursor.s index 00195f1cf..4cf8ebac7 100644 --- a/libsrc/atari5200/setcursor.s +++ b/libsrc/atari5200/setcursor.s @@ -1,49 +1,11 @@ +; Dummy version, there is no visible cursor in the default CONIO screen +; +; 28-May-2014, Christian Groessler <chris@groessler.org> - - .include "atari5200.inc" - .export setcursor - .import cursor ; from conio/_cursor.s - - + .export setcursor .proc setcursor - rts - -.if 0 - ldy #0 - - lda ROWCRS_5200 - jsr mul20 - clc -; adc SAVMSC ; add start of screen memory -; sta OLDADR - txa -; adc SAVMSC+1 -; sta OLDADR+1 - lda COLCRS_5200 -; 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 -.endif - .endproc From 0bcb615d3346ff9aa661d6638d8eb5e8fd79e204 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Wed, 28 May 2014 23:39:31 +0200 Subject: [PATCH 20/30] remove TABs --- libsrc/atari5200/cartentry.s | 4 ++-- libsrc/atari5200/cartname.s | 4 ++-- libsrc/atari5200/cartyear.s | 4 ++-- libsrc/atari5200/cputc.s | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libsrc/atari5200/cartentry.s b/libsrc/atari5200/cartentry.s index e69426b65..431843a55 100644 --- a/libsrc/atari5200/cartentry.s +++ b/libsrc/atari5200/cartentry.s @@ -3,8 +3,8 @@ ; Christian Groessler, 01-Mar-2014 .export __CART_ENTRY__: absolute = 1 -.import __CARTSIZE__, start -.forceimport __CART_YEAR__, __CART_NAME__ +.import __CARTSIZE__, start +.forceimport __CART_YEAR__, __CART_NAME__ .segment "CARTENTRY" diff --git a/libsrc/atari5200/cartname.s b/libsrc/atari5200/cartname.s index 51a7ca2bd..e8478362b 100644 --- a/libsrc/atari5200/cartname.s +++ b/libsrc/atari5200/cartname.s @@ -2,10 +2,10 @@ ; ; Christian Groessler, 01-Mar-2014 -.include "atari5200.mac" +.include "atari5200.mac" .export __CART_NAME__: absolute = 1 .segment "CARTNAME" - scrcode " cc65 compiled" + scrcode " cc65 compiled" diff --git a/libsrc/atari5200/cartyear.s b/libsrc/atari5200/cartyear.s index 85d819632..3269b5cb3 100644 --- a/libsrc/atari5200/cartyear.s +++ b/libsrc/atari5200/cartyear.s @@ -2,11 +2,11 @@ ; ; Christian Groessler, 01-Mar-2014 -.include "atari5200.mac" +.include "atari5200.mac" .export __CART_YEAR__: absolute = 1 .segment "CARTYEAR" - scrcode "98" + scrcode "98" diff --git a/libsrc/atari5200/cputc.s b/libsrc/atari5200/cputc.s index 976f910f0..4bee0fba2 100644 --- a/libsrc/atari5200/cputc.s +++ b/libsrc/atari5200/cputc.s @@ -14,9 +14,9 @@ .importzp ptr4 .import setcursor - .constructor screen_setup, 26 - .import screen_setup_20x24 -screen_setup = screen_setup_20x24 + .constructor screen_setup, 26 + .import screen_setup_20x24 +screen_setup = screen_setup_20x24 _cputcxy: From 245a69a043f8e798d4e6492edc7c4d7e8d79dfef Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Thu, 29 May 2014 00:18:22 +0200 Subject: [PATCH 21/30] don't use scrcode for numbers --- libsrc/atari5200/cartname.s | 4 +++- libsrc/atari5200/cartyear.s | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/libsrc/atari5200/cartname.s b/libsrc/atari5200/cartname.s index e8478362b..f8e6c6ba2 100644 --- a/libsrc/atari5200/cartname.s +++ b/libsrc/atari5200/cartname.s @@ -8,4 +8,6 @@ .segment "CARTNAME" - scrcode " cc65 compiled" + scrcode " cc" + .byte '6' + 32, '5' + 32 ; use playfield 1 + scrcode " compiled" diff --git a/libsrc/atari5200/cartyear.s b/libsrc/atari5200/cartyear.s index 3269b5cb3..4efb24f5e 100644 --- a/libsrc/atari5200/cartyear.s +++ b/libsrc/atari5200/cartyear.s @@ -2,11 +2,8 @@ ; ; Christian Groessler, 01-Mar-2014 -.include "atari5200.mac" - .export __CART_YEAR__: absolute = 1 .segment "CARTYEAR" - scrcode "98" - + .byte '9' + 32,'8' + 32 ; "98", but using playfield 1 From 8f2c9f0d8ee1860314898d923e0a9612553b7336 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Thu, 29 May 2014 00:18:55 +0200 Subject: [PATCH 22/30] use atari target scrcode macro for atari5200 target, too --- asminc/atari5200.mac | 67 +------------------------------------------- 1 file changed, 1 insertion(+), 66 deletions(-) diff --git a/asminc/atari5200.mac b/asminc/atari5200.mac index 59d7ff29c..1f8fd3727 100644 --- a/asminc/atari5200.mac +++ b/asminc/atari5200.mac @@ -1,66 +1 @@ -; Convert characters to screen codes - -; Helper macro that converts and outputs one character -.macro _scrcode char -.if 1 - .if (char >= 96) .and (char <= 127) - .byte (char) - .else - .byte (char - 32) - .endif -.else - .if (char >= 0) .and (char <= 31) - .byte (char + 64) - .elseif (char >= 32) .and (char <= 95) - .byte (char + 32) - .elseif (char >= 96) .and (char <= 127) - .byte char - .elseif (char >= 128) .and (char <= 159) - .byte (char + 64) - .elseif (char >= 160) .and (char <= 223) - .byte (char - 32) - .elseif (char >= 224) .and (char <= 255) - .byte char - .else - .error "scrcode: Character constant out of range" - .endif -.endif -.endmacro - -.macro scrcode arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 - - ; Bail out if next argument is empty - .if .blank (arg1) - .exitmacro - .endif - - ; Check for a string - .if .match ({arg1}, "") - - ; Walk over all string chars - .repeat .strlen (arg1), i - _scrcode {.strat (arg1, i)} - .endrepeat - - ; Check for a number - .elseif .match (.left (1, {arg1}), 0) - - ; Just output the number - _scrcode arg1 - - ; Check for a character - .elseif .match (.left (1, {arg1}), 'a') - - ; Just output the character - _scrcode arg1 - - ; Anything else is an error - .else - - .error "scrcode: invalid argument type" - - .endif - - ; Call the macro recursively with the remaining args - scrcode arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 -.endmacro +.include "atari.mac" From 497b161d120c12bc59ead0c983e5d7396ea84b40 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Thu, 29 May 2014 00:41:39 +0200 Subject: [PATCH 23/30] fix warning when generating info file --- doc/atari5200.sgml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/atari5200.sgml b/doc/atari5200.sgml index e9bff451a..a19641fe7 100644 --- a/doc/atari5200.sgml +++ b/doc/atari5200.sgml @@ -121,12 +121,8 @@ The names in the parentheses denote the symbols to be used for static linking of <sect1>Graphics drivers<p> -<descrip> - No graphics drivers are currently available for the Atari 5200. -</descrip><p> - <sect1>Extended memory drivers<p> From 2bf580fb89fea1f0932167aeeef49094bd90f909 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Thu, 29 May 2014 00:42:30 +0200 Subject: [PATCH 24/30] remove unneeded ATASCII defs; add header --- asminc/atari5200.inc | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/asminc/atari5200.inc b/asminc/atari5200.inc index 10b71eba5..381a1addb 100644 --- a/asminc/atari5200.inc +++ b/asminc/atari5200.inc @@ -1,24 +1,14 @@ +;------------------------------------------------------------------------- +; Atari 5200 System Equates +; by Christian Groessler <chris@groessler.org> +; taken from EQUATES.INC from Atari Inc. +;------------------------------------------------------------------------- ;------------------------------------------------------------------------- ; ATASCII CHARACTER DEFS ;------------------------------------------------------------------------- - -ATCLR = $7D ;CLEAR SCREEN CHARACTER -ATRUB = $7E ;BACK SPACE (RUBOUT) -ATTAB = $7F ;TAB -ATEOL = $9B ;END-OF-LINE -ATDELL = $9C ;delete line -ATINSL = $9D ;insert line -ATCTAB = $9E ;clear TAB -ATSTAB = $9F ;set TAB -ATBEL = $FD ;CONSOLE BELL -ATDEL = $FE ;delete char. -ATINS = $FF ;insert char. -ATURW = $1C ;UP-ARROW -ATDRW = $1D ;DOWN-ARROW -ATLRW = $1E ;LEFT-ARROW -ATRRW = $1F ;RIGHT-ARROW -ATESC = $1B ;ESCAPE + +ATEOL = $9B ;END-OF-LINE, used by CONIO ;------------------------------------------------------------------------- @@ -57,9 +47,9 @@ PADDL7 = $18 ;POT7 " ; cc65 runtime zero page variables -ROWCRS_5200 = $19 -COLCRS_5200 = $1A -SAVMSC = $1B ; pointer to screen memory (conio) +ROWCRS_5200 = $19 +COLCRS_5200 = $1A +SAVMSC = $1B ; pointer to screen memory (conio) ;------------------------------------------------------------------------- ; Page #2 @@ -124,4 +114,3 @@ GOCART = $BFFE ;Cartridge Start Vector CHRORG = $F800 ;Character Generator Base - From ff31fa3e3fd7f43ef942f0f9a47f364c0389cfcf Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Thu, 29 May 2014 00:42:54 +0200 Subject: [PATCH 25/30] add atari5200.h --- include/atari5200.h | 102 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 include/atari5200.h diff --git a/include/atari5200.h b/include/atari5200.h new file mode 100644 index 000000000..779095217 --- /dev/null +++ b/include/atari5200.h @@ -0,0 +1,102 @@ +/*****************************************************************************/ +/* */ +/* atari5200.h */ +/* */ +/* Atari 5200 system specific definitions */ +/* */ +/* */ +/* */ +/* (C) 2014 Christian Groessler <chris@groessler.org> */ +/* */ +/* */ +/* This software is provided 'as-is', without any expressed or implied */ +/* warranty. In no event will the authors be held liable for any damages */ +/* arising from the use of this software. */ +/* */ +/* Permission is granted to anyone to use this software for any purpose, */ +/* including commercial applications, and to alter it and redistribute it */ +/* freely, subject to the following restrictions: */ +/* */ +/* 1. The origin of this software must not be misrepresented; you must not */ +/* claim that you wrote the original software. If you use this software */ +/* in a product, an acknowledgment in the product documentation would be */ +/* appreciated but is not required. */ +/* 2. Altered source versions must be plainly marked as such, and must not */ +/* be misrepresented as being the original software. */ +/* 3. This notice may not be removed or altered from any source */ +/* distribution. */ +/* */ +/*****************************************************************************/ + + + +#ifndef _ATARI5200_H +#define _ATARI5200_H + + + +/* Check for errors */ +#if !defined(__ATARI5200__) +# error This module may only be used when compiling for the Atari 5200! +#endif + + +/* make GTIA color value */ +#define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1)) + +/* luminance values go from 0 (black) to 7 (white) */ + +/* hue values */ +#define HUE_GREY 0 +#define HUE_GOLD 1 +#define HUE_GOLDORANGE 2 +#define HUE_REDORANGE 3 +#define HUE_ORANGE 4 +#define HUE_MAGENTA 5 +#define HUE_PURPLE 6 +#define HUE_BLUE 7 +#define HUE_BLUE2 8 +#define HUE_CYAN 9 +#define HUE_BLUEGREEN 10 +#define HUE_BLUEGREEN2 11 +#define HUE_GREEN 12 +#define HUE_YELLOWGREEN 13 +#define HUE_YELLOW 14 +#define HUE_YELLOWRED 15 + +/* Color defines, similar to c64 colors (untested) */ +#define COLOR_BLACK _gtia_mkcolor(HUE_GREY,0) +#define COLOR_WHITE _gtia_mkcolor(HUE_GREY,7) +#define COLOR_RED _gtia_mkcolor(HUE_REDORANGE,1) +#define COLOR_CYAN _gtia_mkcolor(HUE_CYAN,3) +#define COLOR_VIOLET _gtia_mkcolor(HUE_PURPLE,4) +#define COLOR_GREEN _gtia_mkcolor(HUE_GREEN,2) +#define COLOR_BLUE _gtia_mkcolor(HUE_BLUE,2) +#define COLOR_YELLOW _gtia_mkcolor(HUE_YELLOW,7) +#define COLOR_ORANGE _gtia_mkcolor(HUE_ORANGE,5) +#define COLOR_BROWN _gtia_mkcolor(HUE_YELLOW,2) +#define COLOR_LIGHTRED _gtia_mkcolor(HUE_REDORANGE,6) +#define COLOR_GRAY1 _gtia_mkcolor(HUE_GREY,2) +#define COLOR_GRAY2 _gtia_mkcolor(HUE_GREY,3) +#define COLOR_LIGHTGREEN _gtia_mkcolor(HUE_GREEN,6) +#define COLOR_LIGHTBLUE _gtia_mkcolor(HUE_BLUE,6) +#define COLOR_GRAY3 _gtia_mkcolor(HUE_GREY,5) + +/* get_tv return values */ +#define AT_NTSC 0 +#define AT_PAL 1 + +/* Define hardware */ +#include <_gtia.h> +#define GTIA_READ (*(struct __gtia_read*)0xC000) +#define GTIA_WRITE (*(struct __gtia_write*)0xC000) + +#include <_pokey.h> +#define POKEY_READ (*(struct __pokey_read*)0xE800) +#define POKEY_WRITE (*(struct __pokey_write*)0xE800) + +#include <_antic.h> +#define ANTIC (*(struct __antic*)0xD400) + +/* End of atari5200.h */ +#endif /* #ifndef _ATARI5200_H */ From 4286e554535867f3ed7a533e6e38824e6b81295b Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Thu, 29 May 2014 01:50:41 +0200 Subject: [PATCH 26/30] fix build error --- libsrc/atari5200/joy/atr5200std.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/atari5200/joy/atr5200std.s b/libsrc/atari5200/joy/atr5200std.s index 929ad09fe..890e1ff61 100644 --- a/libsrc/atari5200/joy/atr5200std.s +++ b/libsrc/atari5200/joy/atr5200std.s @@ -14,7 +14,7 @@ ; ------------------------------------------------------------------------ ; Header. Includes jump table -.segment "JUMPTABLE" +.segment "HEADER" ; Driver signature From f54ef4efe489a4ab61cca3dbd4d55ba32914031a Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Thu, 29 May 2014 13:23:45 +0200 Subject: [PATCH 27/30] provide CLK_TCK and CLOCKS_PER_SEC values for atari5200 --- include/time.h | 3 +++ libsrc/atari5200/clock.s | 11 +---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/include/time.h b/include/time.h index 507d7e29a..3566cb7b5 100644 --- a/include/time.h +++ b/include/time.h @@ -81,6 +81,9 @@ extern struct _timezone { unsigned _clocks_per_sec (void); # define CLK_TCK _clocks_per_sec() # define CLOCKS_PER_SEC _clocks_per_sec() +#elif defined(__ATARI5200__) +# define CLK_TCK 60 /* POSIX */ +# define CLOCKS_PER_SEC 60 /* ANSI */ #elif defined(__ATMOS__) # define CLK_TCK 100 /* POSIX */ # define CLOCKS_PER_SEC 100 /* ANSI */ diff --git a/libsrc/atari5200/clock.s b/libsrc/atari5200/clock.s index d70794b8d..f2ef85b0b 100644 --- a/libsrc/atari5200/clock.s +++ b/libsrc/atari5200/clock.s @@ -5,7 +5,7 @@ ; unsigned _clocks_per_sec (void); ; - .export _clock, __clocks_per_sec + .export _clock .importzp sreg .include "atari5200.inc" @@ -24,12 +24,3 @@ rts .endproc - - -.proc __clocks_per_sec - - ldx #$00 ; Clear high byte of return value - lda #60 - rts - -.endproc From fa7cdf02143487e8756b5faa0e434fe97c24603b Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Fri, 30 May 2014 13:38:29 +0200 Subject: [PATCH 28/30] remove atari5200.mac --- asminc/atari5200.mac | 1 - libsrc/atari5200/cartname.s | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 asminc/atari5200.mac diff --git a/asminc/atari5200.mac b/asminc/atari5200.mac deleted file mode 100644 index 1f8fd3727..000000000 --- a/asminc/atari5200.mac +++ /dev/null @@ -1 +0,0 @@ -.include "atari.mac" diff --git a/libsrc/atari5200/cartname.s b/libsrc/atari5200/cartname.s index f8e6c6ba2..c6a701884 100644 --- a/libsrc/atari5200/cartname.s +++ b/libsrc/atari5200/cartname.s @@ -2,7 +2,7 @@ ; ; Christian Groessler, 01-Mar-2014 -.include "atari5200.mac" +.include "atari.mac" .export __CART_NAME__: absolute = 1 From a4fda71510f4fe45c0e6bf30c1166d23f0155a79 Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Fri, 30 May 2014 13:39:09 +0200 Subject: [PATCH 29/30] move atari5200 behind atari and atarixl in TARGETS list --- libsrc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsrc/Makefile b/libsrc/Makefile index 28f39d8d3..75e5c3681 100644 --- a/libsrc/Makefile +++ b/libsrc/Makefile @@ -16,9 +16,9 @@ GEOS = geos-apple \ TARGETS = apple2 \ apple2enh \ - atari5200 \ atari \ atarixl \ + atari5200 \ atmos \ $(CBMS) \ $(GEOS) \ From df782e9500de2f465507d90625756f4c5e1e077e Mon Sep 17 00:00:00 2001 From: Christian Groessler <chris@groessler.org> Date: Fri, 30 May 2014 22:00:18 +0200 Subject: [PATCH 30/30] rename _antic.inc, _pokey.inc, _gtia.inc to atari_antic.inc, atari_pokey.inc, atari_gtia.inc --- asminc/atari.inc | 6 +++--- asminc/atari5200.inc | 6 +++--- asminc/{_antic.inc => atari_antic.inc} | 0 asminc/{_gtia.inc => atari_gtia.inc} | 0 asminc/{_pokey.inc => atari_pokey.inc} | 0 5 files changed, 6 insertions(+), 6 deletions(-) rename asminc/{_antic.inc => atari_antic.inc} (100%) rename asminc/{_gtia.inc => atari_gtia.inc} (100%) rename asminc/{_pokey.inc => atari_pokey.inc} (100%) diff --git a/asminc/atari.inc b/asminc/atari.inc index 34465aee9..3cce03046 100644 --- a/asminc/atari.inc +++ b/asminc/atari.inc @@ -778,7 +778,7 @@ CARTAD = $BFFE ;##rev2## 2-byte cartridge start vector ;------------------------------------------------------------------------- GTIA = $D000 ;CTIA/GTIA area -.include "_gtia.inc" +.include "atari_gtia.inc" ;------------------------------------------------------------------------- ; PBI Address Equates @@ -799,14 +799,14 @@ PDVS = $D1FF ;##rev2## parallel device select ;------------------------------------------------------------------------- POKEY = $D200 ;POKEY area -.include "_pokey.inc" +.include "atari_pokey.inc" ;------------------------------------------------------------------------- ; ANTIC Address Equates ;------------------------------------------------------------------------- ANTIC = $D400 ;ANTIC area -.include "_antic.inc" +.include "atari_antic.inc" ; PBI RAM Address Equates diff --git a/asminc/atari5200.inc b/asminc/atari5200.inc index 381a1addb..b67c9a8db 100644 --- a/asminc/atari5200.inc +++ b/asminc/atari5200.inc @@ -85,21 +85,21 @@ VTIMR4 = $021A ;Pokey Timer 4 ;------------------------------------------------------------------------- GTIA = $C000 ;CTIA/GTIA area -.include "_gtia.inc" +.include "atari_gtia.inc" ;------------------------------------------------------------------------- ; ANTIC Address Equates ;------------------------------------------------------------------------- ANTIC = $D400 ;ANTIC area -.include "_antic.inc" +.include "atari_antic.inc" ;------------------------------------------------------------------------- ; POKEY Address Equates ;------------------------------------------------------------------------- POKEY = $E800 ;POKEY area -.include "_pokey.inc" +.include "atari_pokey.inc" ;------------------------------------------------------------------------- diff --git a/asminc/_antic.inc b/asminc/atari_antic.inc similarity index 100% rename from asminc/_antic.inc rename to asminc/atari_antic.inc diff --git a/asminc/_gtia.inc b/asminc/atari_gtia.inc similarity index 100% rename from asminc/_gtia.inc rename to asminc/atari_gtia.inc diff --git a/asminc/_pokey.inc b/asminc/atari_pokey.inc similarity index 100% rename from asminc/_pokey.inc rename to asminc/atari_pokey.inc