diff --git a/README.md b/README.md new file mode 100644 index 0000000..3aa4f1c --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# WIP NES emulator written in Rust + +This is a work in progress NES emulator. + +If you find any issues, feel free to open an issue... diff --git a/build.rs b/build.rs index f8b1752..e6f3770 100644 --- a/build.rs +++ b/build.rs @@ -42,17 +42,18 @@ fn main() { let file = file.expect("test"); let file_name = file.file_name(); let file_name = file_name.to_str().unwrap(); - if let Some(file_name) = file_name.strip_suffix(".asm") { - run( - format_args!("asm6f {file_name}"), - Command::new("./asm6f") - .arg(file.file_name()) - .arg(format!("{name}/{file_name}.nes")), - ); - } else if let Some(file_name) = file_name.strip_suffix(".s") { + // if let Some(file_name) = file_name.strip_suffix(".asm") { + // run( + // format_args!("asm6f {file_name}"), + // Command::new("./asm6f") + // .arg(file.file_name()) + // .arg(format!("{name}/{file_name}.nes")), + // ); + // } else + if let Some(file_name) = file_name.strip_suffix(".s") { run( format_args!("ca65 {file_name}"), - Command::new("/home/matthew/cc65/bin/ca65") + Command::new("../../cc65/bin/ca65") .arg("-I") .arg("common") .arg("-o") @@ -61,7 +62,7 @@ fn main() { ); run( format_args!("ld65 {file_name}"), - Command::new("/home/matthew/cc65/bin/ld65") + Command::new("../../cc65/bin/ld65") .arg("-C") .arg("nes.cfg") .arg("-o") diff --git a/cc65/asminc/_file.inc b/cc65/asminc/_file.inc new file mode 100644 index 0000000..a9ac1e3 --- /dev/null +++ b/cc65/asminc/_file.inc @@ -0,0 +1,27 @@ +; +; _file.inc +; +; (C) Copyright 2002 Ullrich von Bassewitz (uz@cc65.org) +; + +; Assembler include file that makes the constants and structures in _file.h +; available for asm code. + +; Struct _FILE +.struct _FILE + f_fd .byte + f_flags .byte + f_pushback .byte +.endstruct + +; Flags field +_FCLOSED = $00 +_FOPEN = $01 +_FEOF = $02 +_FERROR = $04 +_FPUSHBACK = $08 + +; File table +.global __filetab + + diff --git a/cc65/asminc/_heap.inc b/cc65/asminc/_heap.inc new file mode 100644 index 0000000..1bf80ac --- /dev/null +++ b/cc65/asminc/_heap.inc @@ -0,0 +1,35 @@ +; +; _heap.inc +; +; (c) Copyright 2003, Ullrich von Bassewitz (uz@cc65.org) +; + +; Assembler include file that makes the constants and structures in _heap.h +; available for asm code. + +; Struct freeblock +; NOTE: For performance reasons, the asm code often uses increment/decrement +; operators to access other offsets, so just changing offsets here will +; probably not work. +.struct freeblock + size .word + next .addr + prev .addr +.endstruct + +; Struct usedblock +; See notes above +.struct usedblock + size .word + start .addr +.endstruct + +HEAP_MIN_BLOCKSIZE = .sizeof (freeblock) ; Minimum size of an allocated block +HEAP_ADMIN_SPACE = .sizeof (usedblock) ; Additional space for used bock + +; Variables +.global ___heaporg +.global ___heapptr +.global ___heapend +.global ___heapfirst +.global ___heaplast diff --git a/cc65/asminc/accelerator.inc b/cc65/asminc/accelerator.inc new file mode 100644 index 0000000..23a9686 --- /dev/null +++ b/cc65/asminc/accelerator.inc @@ -0,0 +1,80 @@ +; +; Accelerator definitions. +; + +; --------------------------------------------------------------------------- +; Speed definitions for all accelerator, to be used as input for the 'set' +; functions. + + +SPEED_SLOW = $00 +SPEED_FAST = $FF + +SPEED_1X = SPEED_SLOW +SPEED_2X = 2 - 1 +SPEED_3X = 3 - 1 +SPEED_4X = 4 - 1 +SPEED_5X = 5 - 1 +SPEED_6X = 6 - 1 +SPEED_7X = 7 - 1 +SPEED_8X = 8 - 1 +SPEED_10X = 10 - 1 +SPEED_12X = 12 - 1 +SPEED_16X = 16 - 1 +SPEED_20X = 20 - 1 + + +; --------------------------------------------------------------------------- +; C64/C128 Super CPU cartridge + +SuperCPU_Slow := $D07A +SuperCPU_Fast := $D07B +SuperCPU_Speed_Mode := $D0B8 +SuperCPU_Detect := $D0BC + + +; --------------------------------------------------------------------------- +; C64DTV + +C64DTV_Extended_Regs := $D03F + +C64DTV_Slow = $00 +C64DTV_Fast = $03 + + +; --------------------------------------------------------------------------- +; C128 native and C128 in C64 mode + +C128_VICIIE_CLK := $D030 + + +; --------------------------------------------------------------------------- +; C64 Chameleon cartridge + +CHAMELEON_CFGTUR := $D0F3 +CHAMELEON_CFGENA := $D0FE + +CHAMELEON_ENABLE_REGS = $2A +CHAMELEON_DISABLE_REGS = $FF + +CHAMELEON_CFGTUR_LIMIT_1MHZ = %00001100 +CHAMELEON_CFGTUR_LIMIT_NONE = %10000000 + + +; --------------------------------------------------------------------------- +; C65/C64DX in C64 mode + +C65_VICIII_KEY := $D02F +C65_VICIII_CTRL_B := $D031 + +C65_VICIII_UNLOCK_1 = $A5 +C65_VICIII_UNLOCK_2 = $96 + + +; --------------------------------------------------------------------------- +; C64 Turbo Master cartridge + +TURBOMASTER_DETECT := $BF53 + +TURBOMASTER_SPEED_REG := $00 + diff --git a/cc65/asminc/agat.inc b/cc65/asminc/agat.inc new file mode 100644 index 0000000..b96d318 --- /dev/null +++ b/cc65/asminc/agat.inc @@ -0,0 +1,39 @@ + +;----------------------------------------------------------------------------- +; Zero page stuff + +WNDLFT := $20 ; Text window left +WNDWDTH := $21 ; Text window width +WNDTOP := $22 ; Text window top +WNDBTM := $23 ; Text window bottom+1 +CH := $24 ; Cursor horizontal position +CV := $25 ; Cursor vertical position +BASL := $28 ; Text base address low +BASH := $29 ; Text base address high +CURSOR := $2D ; Cursor character +TATTR := $32 ; Text attributes +PROMPT := $33 ; Used by GETLN +VCOUT := $36 ; COUT Subroutine Vector +VCIN := $38 ; CIN Subroutine Vector +RNDL := $4E ; Random counter low +RNDH := $4F ; Random counter high +HIMEM := $73 ; Highest available memory address+1 + +;----------------------------------------------------------------------------- +; Vectors + +DOSWARM := $03D0 ; DOS warmstart vector +BRKVec := $03F0 ; Break vector +SOFTEV := $03F2 ; Vector for warm start +PWREDUP := $03F4 ; This must be = EOR #$A5 of SOFTEV+1 + +;----------------------------------------------------------------------------- +; Hardware + +; Keyboard input +KBD := $C000 ; Read keyboard +KBDSTRB := $C010 ; Clear keyboard strobe + +; Game controller +BUTN0 := $C061 ; Open-Apple Key +BUTN1 := $C062 ; Closed-Apple Key diff --git a/cc65/asminc/apple2.inc b/cc65/asminc/apple2.inc new file mode 100644 index 0000000..bde3838 --- /dev/null +++ b/cc65/asminc/apple2.inc @@ -0,0 +1,95 @@ + +;----------------------------------------------------------------------------- +; Zero page + +WNDLFT := $20 ; Text window left +WNDWDTH := $21 ; Text window width +WNDTOP := $22 ; Text window top +WNDBTM := $23 ; Text window bottom+1 +CH := $24 ; Cursor horizontal position +CV := $25 ; Cursor vertical position +BASL := $28 ; Text base address low +BASH := $29 ; Text base address high +INVFLG := $32 ; Normal/inverse(/flash) +PROMPT := $33 ; Used by GETLN +RNDL := $4E ; Random counter low +RNDH := $4F ; Random counter high +HIMEM := $73 ; Highest available memory address+1 +CURLIN := $75 ; Current line number being executed + +;----------------------------------------------------------------------------- +; Vectors + +DOSWARM := $03D0 ; DOS warmstart vector +BRKVec := $03F0 ; Break vector +SOFTEV := $03F2 ; Vector for warm start +PWREDUP := $03F4 ; This must be = EOR #$A5 of SOFTEV+1 +ROM_RST := $FFFC ; 6502 reset vector +ROM_IRQ := $FFFE ; 6502 IRQ vector + +;----------------------------------------------------------------------------- +; 80 column firmware + +OURCH := $057B ; Cursor horizontal position +OURCV := $05FB ; Cursor vertical position + +;----------------------------------------------------------------------------- +; Hardware + +; Keyboard input +KBD := $C000 ; Read keyboard +KBDSTRB := $C010 ; Clear keyboard strobe + +; 80 column video +CLR80COL:= $C000 ; Disable 80 column store +SET80COL:= $C001 ; Enable 80 column store +RD80COL := $C018 ; >127 if 80 column store enabled +RD80VID := $C01F ; >127 if 80 column video enabled + +; Character set +CLRALTCHAR := $C00E ; Normal Apple II char set +SETALTCHAR := $C00F ; Norm/inv LC, no flash +ALTCHARSET := $C01E ; >127 if alt charset switched in + +; Language card +RDLCBNK2:= $C011 ; >127 if LC bank 2 in use +RDLCRAM := $C012 ; >127 if LC is read enabled +ROMIN := $C081 ; Swap in D000-FFFF ROM +LCBANK2 := $C083 ; Swap in LC bank 2 +LCBANK1 := $C08B ; Swap in LC bank 1 + +; Vertical blanking +RDVBLBAR := $C019 ; >127 if not vertical blanking +RDVBLMSK := $C041 ; >127 if VBL interrupts enabled +DISVBL := $C05A ; Disable VBL interrupts +ENVBL := $C05B ; Enable VBL interrupts + +; Video mode +TXTCLR := $C050 ; Display graphics +TXTSET := $C051 ; Display text +MIXCLR := $C052 ; Disable 4 lines of text +MIXSET := $C053 ; Enable 4 lines of text +LOWSCR := $C054 ; Page 1 +HISCR := $C055 ; Page 2 +LORES := $C056 ; Lores graphics +HIRES := $C057 ; Hires graphics +DHIRESON := $C05E ; Enable double-width graphics +DHIRESOFF := $C05F ; Disable double-width graphics + +; Game controller +TAPEIN := $C060 ; Read casette input / Switch input 3 +BUTN0 := $C061 ; Switch input 0 / Open-Apple key +BUTN1 := $C062 ; Switch input 1 / Closed-Apple key +BUTN2 := $C063 ; Switch input 2 / Shift key +PADDL0 := $C064 ; Analog input 0 +PADDL1 := $C065 ; Analog input 1 +PADDL2 := $C066 ; Analog input 2 +PADDL3 := $C067 ; Analog input 3 +PTRIG := $C070 ; Analog input reset + +; Input/Output Unit +IOUDISON := $C07E ; Disable IOU +IOUDISOFF := $C07F ; Enable IOU + +; Control Your Apple +CYAREG := $C036 ; Bits 0-3=disk detect 4=shadow all banks 7=fast diff --git a/cc65/asminc/apple2.mac b/cc65/asminc/apple2.mac new file mode 100644 index 0000000..c0c9571 --- /dev/null +++ b/cc65/asminc/apple2.mac @@ -0,0 +1,54 @@ +; Convert characters to screen codes + +; Helper macro that converts and outputs one character +.macro _scrcode char + .if (char < 256) + .byte (char + 128) + .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 + + ; Check for an identifier + .elseif .match (.left (1, {arg1}), identifier) + + ; Just output the identifier + _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/cc65/asminc/ascii_charmap.inc b/cc65/asminc/ascii_charmap.inc new file mode 100644 index 0000000..ecbf264 --- /dev/null +++ b/cc65/asminc/ascii_charmap.inc @@ -0,0 +1,287 @@ +;/*****************************************************************************/ +;/* */ +;/* ascii_charmap.inc */ +;/* */ +;/* No translations, encodings are stored as they were typed in the host. */ +;/* */ +;/* */ +;/* 2019-09-07, Greg King */ +;/* */ +;/* 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 must not be removed or altered from any source */ +;/* distribution. */ +;/* */ +;/*****************************************************************************/ + +;/* ASCII */ +.charmap $00, $00 +.charmap $01, $01 +.charmap $02, $02 +.charmap $03, $03 +.charmap $04, $04 +.charmap $05, $05 +.charmap $06, $06 +.charmap $07, $07 +.charmap $08, $08 +.charmap $09, $09 +.charmap $0A, $0A +.charmap $0B, $0B +.charmap $0C, $0C +.charmap $0D, $0D +.charmap $0E, $0E +.charmap $0F, $0F +.charmap $10, $10 +.charmap $11, $11 +.charmap $12, $12 +.charmap $13, $13 +.charmap $14, $14 +.charmap $15, $15 +.charmap $16, $16 +.charmap $17, $17 +.charmap $18, $18 +.charmap $19, $19 +.charmap $1A, $1A +.charmap $1B, $1B +.charmap $1C, $1C +.charmap $1D, $1D +.charmap $1E, $1E +.charmap $1F, $1F +.charmap $20, $20 +.charmap $21, $21 +.charmap $22, $22 +.charmap $23, $23 +.charmap $24, $24 +.charmap $25, $25 +.charmap $26, $26 +.charmap $27, $27 +.charmap $28, $28 +.charmap $29, $29 +.charmap $2A, $2A +.charmap $2B, $2B +.charmap $2C, $2C +.charmap $2D, $2D +.charmap $2E, $2E +.charmap $2F, $2F +.charmap $30, $30 +.charmap $31, $31 +.charmap $32, $32 +.charmap $33, $33 +.charmap $34, $34 +.charmap $35, $35 +.charmap $36, $36 +.charmap $37, $37 +.charmap $38, $38 +.charmap $39, $39 +.charmap $3A, $3A +.charmap $3B, $3B +.charmap $3C, $3C +.charmap $3D, $3D +.charmap $3E, $3E +.charmap $3F, $3F +.charmap $40, $40 +.charmap $41, $41 +.charmap $42, $42 +.charmap $43, $43 +.charmap $44, $44 +.charmap $45, $45 +.charmap $46, $46 +.charmap $47, $47 +.charmap $48, $48 +.charmap $49, $49 +.charmap $4A, $4A +.charmap $4B, $4B +.charmap $4C, $4C +.charmap $4D, $4D +.charmap $4E, $4E +.charmap $4F, $4F +.charmap $50, $50 +.charmap $51, $51 +.charmap $52, $52 +.charmap $53, $53 +.charmap $54, $54 +.charmap $55, $55 +.charmap $56, $56 +.charmap $57, $57 +.charmap $58, $58 +.charmap $59, $59 +.charmap $5A, $5A +.charmap $5B, $5B +.charmap $5C, $5C +.charmap $5D, $5D +.charmap $5E, $5E +.charmap $5F, $5F +.charmap $60, $60 +.charmap $61, $61 +.charmap $62, $62 +.charmap $63, $63 +.charmap $64, $64 +.charmap $65, $65 +.charmap $66, $66 +.charmap $67, $67 +.charmap $68, $68 +.charmap $69, $69 +.charmap $6A, $6A +.charmap $6B, $6B +.charmap $6C, $6C +.charmap $6D, $6D +.charmap $6E, $6E +.charmap $6F, $6F +.charmap $70, $70 +.charmap $71, $71 +.charmap $72, $72 +.charmap $73, $73 +.charmap $74, $74 +.charmap $75, $75 +.charmap $76, $76 +.charmap $77, $77 +.charmap $78, $78 +.charmap $79, $79 +.charmap $7A, $7A +.charmap $7B, $7B +.charmap $7C, $7C +.charmap $7D, $7D +.charmap $7E, $7E +.charmap $7F, $7F + +;/* beyond ASCII */ +.charmap $80, $80 +.charmap $81, $81 +.charmap $82, $82 +.charmap $83, $83 +.charmap $84, $84 +.charmap $85, $85 +.charmap $86, $86 +.charmap $87, $87 +.charmap $88, $88 +.charmap $89, $89 +.charmap $8A, $8A +.charmap $8B, $8B +.charmap $8C, $8C +.charmap $8D, $8D +.charmap $8E, $8E +.charmap $8F, $8F +.charmap $90, $90 +.charmap $91, $91 +.charmap $92, $92 +.charmap $93, $93 +.charmap $94, $94 +.charmap $95, $95 +.charmap $96, $96 +.charmap $97, $97 +.charmap $98, $98 +.charmap $99, $99 +.charmap $9A, $9A +.charmap $9B, $9B +.charmap $9C, $9C +.charmap $9D, $9D +.charmap $9E, $9E +.charmap $9F, $9F +.charmap $A0, $A0 +.charmap $A1, $A1 +.charmap $A2, $A2 +.charmap $A3, $A3 +.charmap $A4, $A4 +.charmap $A5, $A5 +.charmap $A6, $A6 +.charmap $A7, $A7 +.charmap $A8, $A8 +.charmap $A9, $A9 +.charmap $AA, $AA +.charmap $AB, $AB +.charmap $AC, $AC +.charmap $AD, $AD +.charmap $AE, $AE +.charmap $AF, $AF +.charmap $B0, $B0 +.charmap $B1, $B1 +.charmap $B2, $B2 +.charmap $B3, $B3 +.charmap $B4, $B4 +.charmap $B5, $B5 +.charmap $B6, $B6 +.charmap $B7, $B7 +.charmap $B8, $B8 +.charmap $B9, $B9 +.charmap $BA, $BA +.charmap $BB, $BB +.charmap $BC, $BC +.charmap $BD, $BD +.charmap $BE, $BE +.charmap $BF, $BF +.charmap $C0, $C0 +.charmap $C1, $C1 +.charmap $C2, $C2 +.charmap $C3, $C3 +.charmap $C4, $C4 +.charmap $C5, $C5 +.charmap $C6, $C6 +.charmap $C7, $C7 +.charmap $C8, $C8 +.charmap $C9, $C9 +.charmap $CA, $CA +.charmap $CB, $CB +.charmap $CC, $CC +.charmap $CD, $CD +.charmap $CE, $CE +.charmap $CF, $CF +.charmap $D0, $D0 +.charmap $D1, $D1 +.charmap $D2, $D2 +.charmap $D3, $D3 +.charmap $D4, $D4 +.charmap $D5, $D5 +.charmap $D6, $D6 +.charmap $D7, $D7 +.charmap $D8, $D8 +.charmap $D9, $D9 +.charmap $DA, $DA +.charmap $DB, $DB +.charmap $DC, $DC +.charmap $DD, $DD +.charmap $DE, $DE +.charmap $DF, $DF +.charmap $E0, $E0 +.charmap $E1, $E1 +.charmap $E2, $E2 +.charmap $E3, $E3 +.charmap $E4, $E4 +.charmap $E5, $E5 +.charmap $E6, $E6 +.charmap $E7, $E7 +.charmap $E8, $E8 +.charmap $E9, $E9 +.charmap $EA, $EA +.charmap $EB, $EB +.charmap $EC, $EC +.charmap $ED, $ED +.charmap $EE, $EE +.charmap $EF, $EF +.charmap $F0, $F0 +.charmap $F1, $F1 +.charmap $F2, $F2 +.charmap $F3, $F3 +.charmap $F4, $F4 +.charmap $F5, $F5 +.charmap $F6, $F6 +.charmap $F7, $F7 +.charmap $F8, $F8 +.charmap $F9, $F9 +.charmap $FA, $FA +.charmap $FB, $FB +.charmap $FC, $FC +.charmap $FD, $FD +.charmap $FE, $FE +.charmap $FF, $FF diff --git a/cc65/asminc/atari.inc b/cc65/asminc/atari.inc new file mode 100644 index 0000000..c2a210e --- /dev/null +++ b/cc65/asminc/atari.inc @@ -0,0 +1,1169 @@ +;------------------------------------------------------------------------- +; Atari System Equates +; by Freddy Offenga, Christian Groessler, and Christian Krueger +; +; References: +; - Atari 400/800 OS rev.B source code, Atari 1979 +; - Atari OS manual - XL addendum +; - Atari XL/XE rev.2 source code, Atari 1984 +; - Mapping the Atari - revised edition, Ian Chadwick 1985 +; - SpartaDOS-X User Guide (Aug-8-2016) +; +; ##old## old OS rev.B label - moved or deleted +; ##1200xl## new label introduced in 1200XL OS (rev.10/11) +; ##rev2## new label introduced in XL/XE OS rev.2 +;------------------------------------------------------------------------- + +;------------------------------------------------------------------------- +; Configuration Equates +;------------------------------------------------------------------------- + +MAXDEV = 33 ;offset to last possible entry of HATABS +IOCBSZ = 16 ;length of IOCB + +SEIOCB = 0*IOCBSZ ;##rev2## screen editor IOCB index +MAXIOC = 8*IOCBSZ ;first invalid IOCB index + +DSCTSZ = 128 ;##rev2## disk sector size + +LEDGE = 2 ;left edge +REDGE = 39 ;right edge + +INIML = $0700 ;##rev2## initial MEMLO + +ICSORG = $CC00 ;##rev2## international character set origin +DCSORG = $E000 ;##rev2## domestic character set origin + +; IOCB Command Code Equates + +OPEN = $03 ;open +GETREC = $05 ;get record +GETCHR = $07 ;get character(s) +PUTREC = $09 ;put record +PUTCHR = $0B ;put character(s) +CLOSE = $0C ;close +STATIS = $0D ;status +SPECIL = $0E ;special + +; DOS IOCB command codes + +RENAME = $20 ;rename disk file +DELETE = $21 ;delete disk file +LOCKFL = $23 ;lock file (set to read-only) +UNLOCK = $24 ;unlock file +POINT = $25 ;point sector +NOTE = $26 ;note sector +GETFL = $27 ;get file length +CHDIR_MYDOS = $29 ;change directory (MyDOS) +MKDIR = $2A ;make directory (MyDOS/SpartaDOS) +RMDIR = $2B ;remove directory (SpartaDOS) +CHDIR_SPDOS = $2C ;change directory (SpartaDOS) +FORMAT = $FE ;format + +GETCWD = $30 ;get current directory (MyDOS/SpartaDOS) + +; Special Entry Command Equates +; DOS Commands +; Command line table, Index values for (DOSVEC),Y -- COMTAB +; Compatible with OS/A+, DOS XL and SpartaDOS + +COMTAB = 0 ;DOS entry jump vector +ZCRNAME = 3 ;file name crunch routine jump vector +BUFOFF = 10 ;next parameter buffer offset +COMFNAM = 33 ;destination buffer for crunch routine +LBUF = 63 ;command line input buffer + +; Screen IOCB Commands + +DRAWLN = $11 ;draw line +FILLIN = $12 ;draw line with right fill + +; ICAX1 Auxiliary Byte 1 Equates + +APPEND = $01 ;open write append (D:) +DIRECT = $02 ;open for directory access (D:) +OPNIN = $04 ;open for input (all devices) +OPNOT = $08 ;open for output (all devices) +MXDMOD = $10 ;open for mixed mode (E:, S:) +INSCLR = $20 ;open for input without clearing screen + +; Device Code Equates + +CASSET = 'C' ;cassette +DISK = 'D' ;disk +SCREDT = 'E' ;screen editor +KBD = 'K' ;keyboard +PRINTR = 'P' ;printer +DISPLY = 'S' ;screen display + +; SIO Command Code Equates + +SIO_FORMAT = $21 ;format disk (default density) +SIO_FORMATS = $22 ;1050: format medium density +SIO_CONFIG = $44 ;configure drive +SIO_CONFIGSF = $4B ;slow/fast configure drive?? +SIO_RDPERCOM = $4E ;read PERCOM block (XF551) +SIO_WRPERCOM = $4F ;write PERCOM block (XF551) +SIO_WRITE = $50 ;write sector +SIO_READ = $52 ;read sector +SIO_STAT = $53 ;get status information +SIO_VERIFY = $56 ;verify sector +SIO_WRITEV = $57 ;write sector with verify +SIO_WRITETRK = $60 ;write track (Speedy) +SIO_READTRK = $62 ;read track (Speedy) + +; SIO Status Code (DSTATS) +; Input: data direction +; Bit #7 - W (write operation) +; #6 - R (read operation) +; Output: status code +; $01 (001) -- OPERATION COMPLETE (NO ERRORS) +; $8A (138) -- DEVICE TIMEOUT (DOESN'T RESPOND) +; $8B (139) -- DEVICE NAK +; $8C (140) -- SERIAL BUS INPUT FRAMING ERROR +; $8E (142) -- SERIAL BUS DATA FRAME OVERRUN ERROR +; $8F (143) -- SERIAL BUS DATA FRAME CHECKSUM ERROR +; $90 (144) -- DEVICE DONE ERROR + +; Character and Key Code Equates + +CLS = $7D ;##rev2## clear screen +EOL = $9B ;end of line (RETURN) + +HELP = $11 ;##1200xl## key code for HELP +CNTLF1 = $83 ;##1200xl## key code for CTRL-F1 +CNTLF2 = $84 ;##1200xl## key code for CTRL-F2 +CNTLF3 = $93 ;##1200xl## key code for CTRL-F3 +CNTLF4 = $94 ;##1200xl## key code for CTRL-F4 +CNTL1 = $9F ;##1200xl## key code for CTRL-1 + +; Status Code Equates + +SUCCES = 1 ;($01) succesful operation + +BRKABT = 128 ;($80) BREAK key abort +PRVOPN = 129 ;($81) IOCB already open error +NONDEV = 130 ;($82) nonexistent device error +WRONLY = 131 ;($83) IOCB opened for write only error +NVALID = 132 ;($84) invalid command error +NOTOPN = 133 ;($85) device/file not open error +BADIOC = 134 ;($86) invalid IOCB index error +RDONLY = 135 ;($87) IOCB opened for read only error +EOFERR = 136 ;($88) end of file error +TRNRCD = 137 ;($89) truncated record error +TIMOUT = 138 ;($8A) peripheral device timeout error +DNACK = 139 ;($8B) device does not acknowledge command +FRMERR = 140 ;($8C) serial bus framing error +CRSROR = 141 ;($8D) cursor overrange error +OVRRUN = 142 ;($8E) serial bus data overrun error +CHKERR = 143 ;($8F) serial bus checksum error +DERROR = 144 ;($90) device done (operation incomplete) +BADMOD = 145 ;($91) bad screen mode number error +FNCNOT = 146 ;($92) function not implemented in handler +SCRMEM = 147 ;($93) insufficient memory for screen mode + +DSKFMT = 148 ;($94) SpartaDOS: unrecognized disk format +INCVER = 149 ;($95) SpartaDOS: disk was made with incompat. version +DIRNFD = 150 ;($96) SpartaDOS: directory not found +FEXIST = 151 ;($97) SpartaDOS: file exists +NOTBIN = 152 ;($98) SpartaDOS: file not binary +LSYMND = 154 ;($9A) SDX: loader symbol not defined +BADPRM = 156 ;($9C) SDX: bad parameter +OUTOFM = 158 ;($9E) SDX: out of memory +INVDEV = 160 ;($A0) invalid device number +TMOF = 161 ;($A1) too many open files +DSKFLL = 162 ;($A2) disk full +FATLIO = 163 ;($A3) fatal I/O error +FNMSMT = 164 ;($A4) internal file number mismatch +INVFNM = 165 ;($A5) invalid file name +PDLERR = 166 ;($A6) point data length error +EPERM = 167 ;($A7) permission denied +DINVCM = 168 ;($A8) command invalid for disk +DIRFLL = 169 ;($A9) directory full +FNTFND = 170 ;($AA) file not found +PNTINV = 171 ;($AB) point invalid +BADDSK = 173 ;($AD) bad disk +INCFMT = 176 ;($B0) DOS 3: incompatible file system +XNTBIN = 180 ;($B4) XDOS: file not binary + +; DCB Device Bus Equates + +DISKID = $31 ;##rev2## disk bus ID +PDEVN = $40 ;##rev2## printer bus ID +CASET = $60 ;##rev2## cassette bus ID + +; Bus Command Equates + +FOMAT = '!' ;##rev2## format command +PUTSEC = 'P' ;##rev2## put sector command +READ = 'R' ;##rev2## read command +STATC = 'S' ;##rev2## status command +WRITE = 'W' ;##rev2## write command + +; Command Auxiliary Byte Equates + +DOUBLE = 'D' ;##rev2## print 20 characters double width +NORMAL = 'N' ;##rev2## print 40 characters normally +PLOT = 'P' ;##rev2## plot +SIDWAY = 'S' ;##rev2## print 16 characters sideways + +; Bus Response Equates + +ACK = 'A' ;##rev2## device acknowledged +COMPLT = 'C' ;##rev2## device succesfully completed operation +ERROR = 'E' ;##rev2## device incurred error +NACK = 'N' ;##rev2## device did not understand + +; Floating Point Miscellaneous Equates + +FPREC = 6 ;precision + +FMPREC = FPREC-1 ;##rev2## length of mantissa + +; Cassette Record Type Equates + +HDR = $FB ;##rev2## header +DTA = $FC ;##rev2## data record +DT1 = $FA ;##rev2## last data record +EOT = $FE ;##rev2## end of tape (file) + +TONE1 = 2 ;##rev2## record +TONE2 = 1 ;##rev2## playback + +; Cassette Timing Equates + +WLEADN = 1152 ;##rev2## NTSC 19.2 second WRITE file leader +RLEADN = 576 ;##rev2## NTSC 9.6 second READ file leader +WIRGLN = 180 ;##rev2## NTSC 3.0 second WRITE IRG +RIRGLN = 120 ;##rev2## NTSC 2.0 second READ IRG +WSIRGN = 15 ;##rev2## NTSC 0.25 second WRITE short IRG +RSIRGN = 10 ;##rev2## NTSC 0.16 second READ short IRG +BEEPNN = 30 ;##rev2## NTSC 0.5 second beep duration +BEEPFN = 10 ;##rev2## NTSC 0.16 seconrd beep duration + +WLEADP = 960 ;##rev2## PAL 19.2 second WRITE file leader +RLEADP = 480 ;##rev2## PAL 9.6 second READ file leader +WIRGLP = 150 ;##rev2## PAL 3.0 second WRITE IRG +RIRGLP = 100 ;##rev2## PAL 2.0 second READ IRG +WSIRGP = 13 ;##rev2## PAL 0.25 second WRITE short IRG +RSIRGP = 8 ;##rev2## PAL 0.16 second READ short IRG +BEEPNP = 25 ;##rev2## PAL 0.5 second beep duration +BEEPFP = 8 ;##rev2## PAL 0.16 seconrd beep duration + +WIRGHI = 0 ;##rev2## high WRITE IRG +RIRGHI = 0 ;##rev2## high READ IRG + +; Power-up Validation Byte Value Equates + +PUPVL1 = $5C ;##rev2## power-up validation value 1 +PUPVL2 = $93 ;##rev2## power-up validation value 2 +PUPVL3 = $25 ;##rev2## power-up validation value 3 + +; Relocating Loader Miscellaneous Equates + +DATAER = 156 ;##rev2## end of record appears before END +MEMERR = 157 ;##rev2## memory insufficient for load error + +; Miscellaneous Equates + +IOCFRE = $FF ;IOCB free indication + +B19200 = $0028 ;##rev2## 19200 baud POKEY counter value +B00600 = $05CC ;##rev2## 600 baud POKEY counter value + +HITONE = $05 ;##rev2## FSK high freq. POKEY counter value +LOTONE = $07 ;##rev2## FSK low freq. POKEY counter value + +NCOMLO = $34 ;##rev2## PIA lower NOT COMMAND line command +NCOMHI = $3C ;##rev2## PIA raise NOT COMMAND line command + +MOTRGO = $34 ;##rev2## PIA cassette motor ON command +MOTRST = $3C ;##rev2## PIA cassette motor OFF command + +NODAT = $00 ;##rev2## SIO immediate operation +GETDAT = $40 ;##rev2## SIO read data frame +PUTDAT = $80 ;##rev2## SIO write data frame + +CRETRI = 13 ;##rev2## number of command frame retries +DRETRI = 1 ;##rev2## number of device retries +CTIM = 2 ;##rev2## command frame ACK timeout + +NBUFSZ = 40 ;##rev2## print normal buffer size +DBUFSZ = 20 ;##rev2## print double buffer size +SBUFSZ = 29 ;##rev2## print sideways buffer size + +;------------------------------------------------------------------------- +; Page Zero Address Equates +;------------------------------------------------------------------------- + +LINZBS = $00 ;LINBUG RAM (WILL BE REPLACED BY MONITOR RAM) +LNFLG = $00 ;##1200xl## 1-byte LNBUG flag (0 = not LNBUG) +NGFLAG = $01 ;##1200xl## 1-byte memory status (0 = failure) + +; Not Cleared + +CASINI = $02 ;CASSETTE INIT LOCATION +RAMLO = $04 ;RAM POINTER FOR MEMORY TEST +TRAMSZ = $06 ;TEMPORARY REGISTER FOR RAM SIZE +;TSTDAT = $07 ;##old## RAM TEST DATA REGISTER +CMCMD = $07 ;##rev2## 1-byte command communications + +; Cleared upon Coldstart only + +WARMST = $08 ;WARM START FLAG +BOOTQ = $09 ;SUCCESSFUL BOOT FLAG +DOSVEC = $0A ;DISK SOFTWARE START VECTOR +DOSINI = $0C ;DISK SOFTWARE INIT ADDRESS +APPMHI = $0E ;APPLICATIONS MEMORY HI LIMIT + +; Cleared upon Coldstart or Warmstart + +INTZBS = $10 ;INTERRUPT HANDLER + +POKMSK = $10 ;SYSTEM MASK FOR POKEY IRQ ENABLE (shadow of IRQEN) +BRKKEY = $11 ;BREAK KEY FLAG +RTCLOK = $12 ;REAL TIME CLOCK (IN 16 MSEC UNITS> +BUFADR = $15 ;INDIRECT BUFFER ADDRESS REGISTER +ICCOMT = $17 ;COMMAND FOR VECTOR +DSKFMS = $18 ;DISK FILE MANAGER POINTER +DSKUTL = $1A ;DISK UTILITIES POINTER +ABUFPT = $1C ;##1200xl## 4-byte ACMI buffer pointer area + +;PTIMOT = $1C ;##old## PRINTER TIME OUT REGISTER +;PBPNT = $1D ;##old## PRINT BUFFER POINTER +;PBUFSZ = $1E ;##old## PRINT BUFFER SIZE +;PTEMP = $1F ;##old## TEMPORARY REGISTER + +ZIOCB = $20 ;ZERO PAGE I/O CONTROL BLOCK +IOCBAS = $20 ;16-byte page zero IOCB +ICHIDZ = $20 ;HANDLER INDEX NUMBER (FF = IOCB FREE) +ICDNOZ = $21 ;DEVICE NUMBER (DRIVE NUMBER) +ICCOMZ = $22 ;COMMAND CODE +ICSTAZ = $23 ;STATUS OF LAST IOCB ACTION +ICBALZ = $24 ;BUFFER ADDRESS LOW BYTE +ICBAHZ = $25 ;1-byte high buffer address +ICPTLZ = $26 ;PUT BYTE ROUTINE ADDRESS -1 +ICPTHZ = $27 ;1-byte high PUT-BYTE routine address +ICBLLZ = $28 ;BUFFER LENGTH LOW BYTE +ICBLHZ = $29 ;1-byte high buffer length +ICAX1Z = $2A ;AUXILIARY INFORMATION FIRST BYTE +ICAX2Z = $2B ;1-byte second auxiliary information +ICSPRZ = $2C ;4-byte spares + +ENTVEC = $2C ;##rev2## 2-byte (not used) +ICIDNO = $2E ;IOCB NUMBER X 16 +CIOCHR = $2F ;CHARACTER BYTE FOR CURRENT OPERATION + +STATUS = $30 ;INTERNAL STATUS STORAGE +CHKSUM = $31 ;CHECKSUM (SINGLE BYTE SUM WITH CARRY) +BUFRLO = $32 ;POINTER TO DATA BUFFER (LO BYTE) +BUFRHI = $33 ;POINTER TO DATA BUFFER (HI BYTE) +BFENLO = $34 ;NEXT BYTE PAST END OF THE DATA BUFFER LO +BFENHI = $35 ;NEXT BYTE PAST END OF THE DATA BUFFER HI +;CRETRY = $36 ;##old## NUMBER OF COMMAND FRAME RETRIES +;DRETRY = $37 ;##old## NUMBER OF DEVICE RETRIES +LTEMP = $36 ;##1200xl## 2-byte loader temporary +BUFRFL = $38 ;DATA BUFFER FULL FLAG +RECVDN = $39 ;RECEIVE DONE FLAG +XMTDON = $3A ;TRANSMISSION DONE FLAG +CHKSNT = $3B ;CHECKSUM SENT FLAG +NOCKSM = $3C ;NO CHECKSUM FOLLOWS DATA FLAG +BPTR = $3D ;1-byte cassette buffer pointer +FTYPE = $3E ;1-byte cassette IRG type +FEOF = $3F ;1-byte cassette EOF flag (0 = quiet) +FREQ = $40 ;1-byte cassette beep counter +SOUNDR = $41 ;NOISY I/0 FLAG. (ZERO IS QUIET) + +CRITIC = $42 ;DEFINES CRITICAL SECTION (CRITICAL IF NON-Z) + +FMSZPG = $43 ;DISK FILE MANAGER SYSTEM ZERO PAGE + +;CKEY = $4A ;##old## FLAG SET WHEN GAME START PRESSED +ZCHAIN = $4A ;##1200xl## 2-byte handler linkage chain pointer +;CASSBT = $4B ;##old## CASSETTE BOOT FLAG +DSTAT = $4C ;DISPLAY STATUS +ATRACT = $4D ;ATRACT FLAG +DRKMSK = $4E ;DARK ATRACT MASK +COLRSH = $4F ;ATRACT COLOR SHIFTER (EOR'ED WITH PLAYFIELD + + +TMPCHR = $50 ;1-byte temporary character +HOLD1 = $51 ;1-byte temporary +LMARGN = $52 ;left margin (normally 2, cc65 C startup code sets it to 0) +RMARGN = $53 ;right margin (normally 39 if no XEP80 is used) +ROWCRS = $54 ;1-byte cursor row +COLCRS = $55 ;2-byte cursor column +DINDEX = $57 ;1-byte display mode +SAVMSC = $58 ;2-byte saved memory scan counter +OLDROW = $5A ;1-byte prior row +OLDCOL = $5B ;2-byte prior column +OLDCHR = $5D ;DATA UNDER CURSOR +OLDADR = $5E ;2-byte saved cursor memory address +FKDEF = $60 ;##1200xl## 2-byte function key definition table +;NEWROW = $60 ;##old## POINT DRAW GOES TO +;NEWCOL = $61 ;##old## +PALNTS = $62 ;##1200xl## 1-byte PAL/NTSC indicator (0 = NTSC) +LOGCOL = $63 ;POINTS AT COLUMN IN LOGICAL LINE +ADRESS = $64 ;2-byte temporary address + +MLTTMP = $66 ;1-byte temporary +OPNTMP = $66 ;FIRST BYTE IS USED IN OPEN AS TEMP +TOADR = $66 ;##rev2## 2-byte destination address + +SAVADR = $68 ;2-byte saved address +FRMADR = $68 ;##rev2## 2-byte source address + +RAMTOP = $6A ;RAM SIZE DEFINED BY POWER ON LOGIC +BUFCNT = $6B ;BUFFER COUNT +BUFSTR = $6C ;EDITOR GETCH POINTER +BITMSK = $6E ;BIT MASK +SHFAMT = $6F ;1-byte shift amount for pixel justifucation +ROWAC = $70 ;2-byte draw working row +COLAC = $72 ;2-byte draw working column +ENDPT = $74 ;2-byte end point +DELTAR = $76 ;1-byte row difference +DELTAC = $77 ;2-byte column difference +KEYDEF = $79 ;##1200xl## 2-byte key definition table address +;ROWINC = $79 ;##old## +;COLINC = $7A ;##old## +SWPFLG = $7B ;NON-0 1F TXT AND REGULAR RAM IS SWAPPED +HOLDCH = $7C ;CH IS MOVED HERE IN KGETCH BEFORE CNTL & SH +INSDAT = $7D ;1-byte temporary +COUNTR = $7E ;2-byte draw iteration count + +; Floating Point Package Page Zero Address Equates + +FR0 = $D4 ;6-byte register 0 +FR0M = $D5 ;##rev2## 5-byte register 0 mantissa +QTEMP = $D9 ;##rev2## 1-byte temporary + +FRE = $DA ;6-byte (internal) register E + +FR1 = $E0 ;FP REG1 +FR1M = $E1 ;##rev2## 5-byte register 1 mantissa + +FR2 = $E6 ;6-byte (internal) register 2 + +FRX = $EC ;1-byte temporary + +EEXP = $ED ;VALUE OF E + +FRSIGN = $EE ;##rev2## 1-byte floating point sign +NSIGN = $EE ;SIGN OF # + +PLYCNT = $EF ;##rev2## 1-byte polynomial degree +ESIGN = $EF ;SIGN OF EXPONENT + +SGNFLG = $F0 ;##rev2## 1-byte sign flag +FCHRFLG = $F0 ;1ST CHAR FLAG + +XFMFLG = $F1 ;##rev2## 1-byte transform flag +DIGRT = $F1 ;# OF DIGITS RIGHT OF DECIMAL + +CIX = $F2 ;CURRENT INPUT INDEX +INBUFF = $F3 ;POINTS TO USER'S LINE INPUT BUFFER + +ZTEMP1 = $F5 ;2-byte temporary +ZTEMP4 = $F7 ;2-byte temporary +ZTEMP3 = $F9 ;2-byte temporary + +;DEGFLG = $FB ;##old## same as RADFLG +;RADFLG = $FB ;##old## 0=RADIANS, 6=DEGREES + +FLPTR = $FC ;2-byte floating point number pointer +FPTR2 = $FE ;2-byte floating point number pointer + +;------------------------------------------------------------------------- +; Page Two Address Equates +;------------------------------------------------------------------------- + +INTABS = $0200 ;INTERRUPT RAM + +VDSLST = $0200 ;DISPLAY LIST NMI VECTOR +VPRCED = $0202 ;PROCEED LINE IRQ VECTOR +VINTER = $0204 ;INTERRUPT LINE IRQ VECTOR +VBREAK = $0206 ;SOFTWARE BREAK (00) INSTRUCTION IRQ VECTOR +VKEYBD = $0208 ;POKEY KEYBOARD IRQ VECTOR +VSERIN = $020A ;POKEY SERIAL INPUT READY IRQ +VSEROR = $020C ;POKEY SERIAL OUTPUT READY IRQ +VSEROC = $020E ;POKEY SERIAL OUTPUT COMPLETE IRQ +VTIMR1 = $0210 ;POKEY TIMER 1 IRQ +VTIMR2 = $0212 ;POKEY TIMER 2 IRQ +VTIMR4 = $0214 ;POKEY TIMER 4 IRQ +VIMIRQ = $0216 ;IMMEDIATE IRQ VECTOR +CDTMV1 = $0218 ;COUNT DOWN TIMER 1 +CDTMV2 = $021A ;COUNT DOWN TIMER 2 +CDTMV3 = $021C ;COUNT DOWN TIMER 3 +CDTMV4 = $021E ;COUNT DOWN TIMER 4 +CDTMV5 = $0220 ;COUNT DOWN TIMER 5 +VVBLKI = $0222 ;IMMEDIATE VERTICAL BLANK NMI VECTOR +VVBLKD = $0224 ;DEFERRED VERTICAL BLANK NMI VECTOR +CDTMA1 = $0226 ;COUNT DOWN TIMER 1 JSR ADDRESS +CDTMA2 = $0228 ;COUNT DOWN TIMER 2 JSR ADDRESS +CDTMF3 = $022A ;COUNT DOWN TIMER 3 FLAG +SRTIMR = $022B ;SOFTWARE REPEAT TIMER +CDTMF4 = $022C ;COUNT DOWN TIMER 4 FLAG +INTEMP = $022D ;IAN'S TEMP +CDTMF5 = $022E ;COUNT DOWN TIMER FLAG 5 +SDMCTL = $022F ;SAVE DMACTL REGISTER +SDLSTL = $0230 ;SAVE DISPLAY LIST LOW BYTE +SDLSTH = $0231 ;SAVE DISPLAY LIST HI BYTE +SSKCTL = $0232 ;SKCTL REGISTER RAM +LCOUNT = $0233 ;##1200xl## 1-byte relocating loader record +LPENH = $0234 ;LIGHT PEN HORIZONTAL VALUE +LPENV = $0235 ;LIGHT PEN VERTICAL VALUE +BRKKY = $0236 ;BREAK KEY VECTOR +;RELADR = $0238 ;##1200xl## 2-byte relocatable loader address +VPIRQ = $0238 ;##rev2## 2-byte parallel device IRQ vector +CDEVIC = $023A ;COMMAND FRAME BUFFER - DEVICE +CCOMND = $023B ;COMMAND +CAUX1 = $023C ;COMMAND AUX BYTE 1 +CAUX2 = $023D ;COMMAND AUX BYTE 2 + +TEMP = $023E ;TEMPORARY RAM CELL + +ERRFLG = $023F ;ERROR FLAG - ANY DEVICE ERROR EXCEPT TIME OUT + +DFLAGS = $0240 ;DISK FLAGS FROM SECTOR ONE +DBSECT = $0241 ;NUMBER OF DISK BOOT SECTORS +BOOTAD = $0242 ;ADDRESS WHERE DISK BOOT LOADER WILL BE PUT +COLDST = $0244 ;COLDSTART FLAG (1=IN MIDDLE OF COLDSTART> +RECLEN = $0245 ;##1200xl## 1-byte relocating loader record length +DSKTIM = $0246 ;DISK TIME OUT REGISTER +;LINBUF = $0247 ;##old## CHAR LINE BUFFER +PDVMSK = $0247 ;##rev2## 1-byte parallel device selection mask +SHPDVS = $0248 ;##rev2## 1-byte PDVS (parallel device select) +PDIMSK = $0249 ;##rev2## 1-byte parallel device IRQ selection +RELADR = $024A ;##rev2## 2-byte relocating loader relative adr. +PPTMPA = $024C ;##rev2## 1-byte parallel device handler temporary +PPTMPX = $024D ;##rev2## 1-byte parallel device handler temporary + +CHSALT = $026B ;##1200xl## 1-byte character set alternate +VSFLAG = $026C ;##1200xl## 1-byte fine vertical scroll count +KEYDIS = $026D ;##1200xl## 1-byte keyboard disable +FINE = $026E ;##1200xl## 1-byte fine scrolling mode +GPRIOR = $026F ;GLOBAL PRIORITY CELL + +PADDL0 = $0270 ;1-byte potentiometer 0 +PADDL1 = $0271 ;1-byte potentiometer 1 +PADDL2 = $0272 ;1-byte potentiometer 2 +PADDL3 = $0273 ;1-byte potentiometer 3 +PADDL4 = $0274 ;1-byte potentiometer 4 +PADDL5 = $0275 ;1-byte potentiometer 5 +PADDL6 = $0276 ;1-byte potentiometer 6 +PADDL7 = $0277 ;1-byte potentiometer 7 + +STICK0 = $0278 ;1-byte joystick 0 +STICK1 = $0279 ;1-byte joystick 1 +STICK2 = $027A ;1-byte joystick 2 +STICK3 = $027B ;1-byte joystick 3 + +PTRIG0 = $027C ;1-byte paddle trigger 0 +PTRIG1 = $027D ;1-byte paddle trigger 1 +PTRIG2 = $027E ;1-byte paddle trigger 2 +PTRIG3 = $027F ;1-byte paddle trigger 3 +PTRIG4 = $0280 ;1-byte paddle trigger 4 +PTRIG5 = $0281 ;1-byte paddle trigger 5 +PTRIG6 = $0281 ;1-byte paddle trigger 6 +PTRIG7 = $0283 ;1-byte paddle trigger 7 + +STRIG0 = $0284 ;1-byte joystick trigger 0 +STRIG1 = $0285 ;1-byte joystick trigger 1 +STRIG2 = $0286 ;1-byte joystick trigger 2 +STRIG3 = $0287 ;1-byte joystick trigger 3 + +;CSTAT = $0288 ;##old## cassette status register +HIBYTE = $0288 ;##1200xl## 1-byte relocating loader high byte +WMODE = $0289 ;1-byte cassette WRITE mode +BLIM = $028A ;1-byte cassette buffer limit +IMASK = $028B ;##rev2## (not used) +JVECK = $028C ;2-byte jump vector or temporary +NEWADR = $028E ;##1200xl## 2-byte relocating address +TXTROW = $0290 ;TEXT ROWCRS +TXTCOL = $0291 ;TEXT COLCRS +TINDEX = $0293 ;TEXT INDEX +TXTMSC = $0294 ;FOOLS CONVRT INTO NEW MSC +TXTOLD = $0296 ;OLDROW & OLDCOL FOR TEXT (AND THEN SOME) +;TMPX1 = $029C ;##old## 1-byte temporary register +CRETRY = $029C ;##1200xl## 1-byte number of command frame retries +HOLD3 = $029D ;1-byte temporary +SUBTMP = $029E ;1-byte temporary +HOLD2 = $029F ;1-byte (not used) +DMASK = $02A0 ;1-byte display (pixel location) mask +TMPLBT = $02A1 ;1-byte (not used) +ESCFLG = $02A2 ;ESCAPE FLAG +TABMAP = $02A3 ;15-byte (120 bit) tab stop bit map +LOGMAP = $02B2 ;LOGICAL LINE START BIT MAP +INVFLG = $02B6 ;INVERSE VIDEO FLAG (TOGGLED BY ATARI KEY) +FILFLG = $02B7 ;RIGHT FILL FLAG FOR DRAW +TMPROW = $02B8 ;1-byte temporary row +TMPCOL = $02B9 ;2-byte temporary column +SCRFLG = $02BB ;SET IF SCROLL OCCURS +HOLD4 = $02BC ;TEMP CELL USED IN DRAW ONLY +;HOLD5 = $02BD ;##old## DITTO +DRETRY = $02BD ;##1200xl## 1-byte number of device retries +SHFLOK = $02BE ;1-byte shift/control lock flags +BOTSCR = $02BF ;BOTTOM OF SCREEN 24 NORM 4 SPLIT + +PCOLR0 = $02C0 ;1-byte player-missile 0 color/luminance +PCOLR1 = $02C1 ;1-byte player-missile 1 color/luminance +PCOLR2 = $02C2 ;1-byte player-missile 2 color/luminance +PCOLR3 = $02C3 ;1-byte player-missile 3 color/luminance + +COLOR0 = $02C4 ;1-byte playfield 0 color/luminance +COLOR1 = $02C5 ;1-byte playfield 1 color/luminance +COLOR2 = $02C6 ;1-byte playfield 2 color/luminance +COLOR3 = $02C7 ;1-byte playfield 3 color/luminance + +COLOR4 = $02C8 ;1-byte background color/luminance + +PARMBL = $02C9 ;##rev2## 6-byte relocating loader parameter +RUNADR = $02C9 ;##1200xl## 2-byte run address +HIUSED = $02CB ;##1200xl## 2-byte highest non-zero page address +ZHIUSE = $02CD ;##1200xl## 2-byte highest zero page address + +OLDPAR = $02CF ;##rev2## 6-byte relocating loader parameter +GBYTEA = $02CF ;##1200xl## 2-byte GET-BYTE routine address +LOADAD = $02D1 ;##1200xl## 2-byte non-zero page load address +ZLOADA = $02D3 ;##1200xl## 2-byte zero page load address + +DSCTLN = $02D5 ;##1200xl## 2-byte disk sector length +ACMISR = $02D7 ;##1200xl## 2-byte ACMI interrupt service routine +KRPDEL = $02D9 ;##1200xl## 1-byte auto-repeat delay +KEYREP = $02DA ;##1200xl## 1-byte auto-repeat rate +NOCLIK = $02DB ;##1200xl## 1-byte key click disable +HELPFG = $02DC ;##1200xl## 1-byte HELP key flag (0 = no HELP) +DMASAV = $02DD ;##1200xl## 1-byte SDMCTL save/restore +PBPNT = $02DE ;##1200xl## 1-byte printer buffer pointer +PBUFSZ = $02DF ;##1200xl## 1-byte printer buffer size + +GLBABS = $02E0 ;4-byte global variables for non-DOS users +RUNAD = $02E0 ;##map## 2-byte binary file run address +INITAD = $02E2 ;##map## 2-byte binary file initialization address + +RAMSIZ = $02E4 ;RAM SIZE (HI BYTE ONLY) +MEMTOP = $02E5 ;TOP OF AVAILABLE USER MEMORY +MEMLO = $02E7 ;BOTTOM OF AVAILABLE USER MEMORY +HNDLOD = $02E9 ;##1200xl## 1-byte user load flag +DVSTAT = $02EA ;STATUS BUFFER +CBAUDL = $02EE ;1-byte low cassette baud rate +CBAUDH = $02EF ;1-byte high cassette baud rate +CRSINH = $02F0 ;CURSOR INHIBIT (00 = CURSOR ON) +KEYDEL = $02F1 ;KEY DELAY +CH1 = $02F2 ;1-byte prior keyboard character +CHACT = $02F3 ;CHACTL REGISTER RAM +CHBAS = $02F4 ;CHBAS REGISTER RAM + +NEWROW = $02F5 ;##1200xl## 1-byte draw destination row +NEWCOL = $02F6 ;##1200xl## 2-byte draw destination column +ROWINC = $02F8 ;##1200xl## 1-byte draw row increment +COLINC = $02F9 ;##1200xl## 1-byte draw column increment + +CHAR = $02FA ;1-byte internal character +ATACHR = $02FB ;ATASCII CHARACTER +CH = $02FC ;GLOBAL VARIABLE FOR KEYBOARD +FILDAT = $02FD ;RIGHT FILL DATA +DSPFLG = $02FE ;DISPLAY FLAG DISPLAY CNTLS IF NON-ZERO +SSFLAG = $02FF ;START/STOP FLAG FOR PAGING (CNTL 1). CLEARE + +;------------------------------------------------------------------------- +; Page Three Address Equates +;------------------------------------------------------------------------- + +DCB = $0300 ;DEVICE CONTROL BLOCK +DDEVIC = $0300 ;PERIPHERAL UNIT 1 BUS I.D. NUMBER +DUNIT = $0301 ;UNIT NUMBER +DCOMND = $0302 ;BUS COMMAND +DSTATS = $0303 ;COMMAND TYPE/STATUS RETURN +DBUFLO = $0304 ;1-byte low data buffer address +DBUFHI = $0305 ;1-byte high data buffer address +DTIMLO = $0306 ;DEVICE TIME OUT IN 1 SECOND UNITS +DUNUSE = $0307 ;UNUSED BYTE +DBYTLO = $0308 ;1-byte low number of bytes to transfer +DBYTHI = $0309 ;1-byte high number of bytes to transfer +DAUX1 = $030A ;1-byte first command auxiliary +DAUX2 = $030B ;1-byte second command auxiliary + +TIMER1 = $030C ;INITIAL TIMER VALUE +;ADDCOR = $030E ;##old## ADDITION CORRECTION +JMPERS = $030E ;##1200xl## 1-byte jumper options +CASFLG = $030F ;CASSETTE MODE WHEN SET +TIMER2 = $0310 ;2-byte final baud rate timer value +TEMP1 = $0312 ;TEMPORARY STORAGE REGISTER +;TEMP2 = $0314 ;##old## TEMPORARY STORAGE REGISTER +TEMP2 = $0313 ;##1200xl## 1-byte temporary +PTIMOT = $0314 ;##1200xl## 1-byte printer timeout +TEMP3 = $0315 ;TEMPORARY STORAGE REGISTER +SAVIO = $0316 ;SAVE SERIAL IN DATA PORT +TIMFLG = $0317 ;TIME OUT FLAG FOR BAUD RATE CORRECTION +STACKP = $0318 ;SIO STACK POINTER SAVE CELL +TSTAT = $0319 ;TEMPORARY STATUS HOLDER + +HATABS = $031A ;35-byte handler address table (was 38 bytes) +PUPBT1 = $033D ;##1200xl## 1-byte power-up validation byte 1 +PUPBT2 = $033E ;##1200xl## 1-byte power-up validation byte 2 +PUPBT3 = $033F ;##1200xl## 1-byte power-up validation byte 3 + +IOCB = $0340 ;I/O CONTROL BLOCKS +ICHID = $0340 ;HANDLER INDEX NUMBER (FF=IOCB FREE) +ICDNO = $0341 ;DEVICE NUMBER (DRIVE NUMBER) +ICCOM = $0342 ;COMMAND CODE +ICSTA = $0343 ;STATUS OF LAST IOCB ACTION +ICBAL = $0344 ;1-byte low buffer address +ICBAH = $0345 ;1-byte high buffer address +ICPTL = $0346 ;1-byte low PUT-BYTE routine address - 1 +ICPTH = $0347 ;1-byte high PUT-BYTE routine address - 1 +ICBLL = $0348 ;1-byte low buffer length +ICBLH = $0349 ;1-byte high buffer length +ICAX1 = $034A ;1-byte first auxiliary information +ICAX2 = $034B ;1-byte second auxiliary information +ICAX3 = $034C ;1-byte third auxiliary information +ICAX4 = $034D ;1-byte fourth auxiliary information +ICAX5 = $034E ;1-byte fifth auxiliary information +ICSPR = $034F ;SPARE BYTE + +PRNBUF = $03C0 ;PRINTER BUFFER +SUPERF = $03E8 ;##1200xl## 1-byte editor super function flag +CKEY = $03E9 ;##1200xl## 1-byte cassette boot request flag +CASSBT = $03EA ;##1200xl## 1-byte cassette boot flag +CARTCK = $03EB ;##1200xl## 1-byte cartridge equivalence check +DERRF = $03EC ;##rev2## 1-byte screen OPEN error flag + +; Remainder of Page Three Not Cleared upon Reset + +ACMVAR = $03ED ;##1200xl## 11 bytes reserved for ACMI +BASICF = $03F8 ;##rev2## 1-byte BASIC switch flag +MINTLK = $03F9 ;##1200xl## 1-byte ACMI module interlock +GINTLK = $03FA ;##1200xl## 1-byte cartridge interlock +CHLINK = $03FB ;##1200xl## 2-byte loaded handler chain link +CASBUF = $03FD ;CASSETTE BUFFER + +;------------------------------------------------------------------------- +; Page Four/Five Address Equates +;------------------------------------------------------------------------- + +; USER AREA STARTS HERE AND GOES TO END OF PAGE FIVE +USAREA = $0480 ;128 bytes reserved for application + +LBPR1 = $057E ;LBUFF PREFIX 1 +LBPR2 = $057F ;LBUFF PREFIX 2 +LBUFF = $0580 ;128-byte line buffer + +PLYARG = $05E0 ;6-byte floating point polynomial argument +FPSCR = $05E6 ;6-byte floating point temporary +FPSCR1 = $05EC ;6-byte floating point temporary + +;LBFEND = $05FF ;##old## END OF LBUFF + + +DOS = $0700 + +;------------------------------------------------------------------------- +; SpartaDOS-X Definitions +;------------------------------------------------------------------------- + +SDX_FLAG = DOS ; 'S' for SpartaDOS +SDX_VERSION = $0701 ; SD version (e.g. $32 = 3.2, $40 = 4.0) + ; address $0702 contains sub-version, e.g. + ; 8 in case of SDX 4.48 +SDX_KERNEL = $0703 ; SDX kernel entry point +SDX_BLOCK_IO = $0706 ; block I/O entry point +SDX_MISC = $0709 ; "misc" entry point +SDX_DEVICE = $0761 +SDX_DATE = $077B ; day, month, year (3 bytes) +SDX_TIME = $077E ; hour, min, sec (3 bytes) +SDX_DATESET = $0781 +SDX_PATH = $07A0 ; 64 bytes +SDX_IFSYMBOL = $07EB ; only valid on SDX 4.40 or newer +SDX_S_LOOKUP = SDX_IFSYMBOL ; alternative name for SDX_IFSYMBOL + +; values for SDX_DEVICE + +SDX_CLK_DEV = $10 ; clock device + +; clock device functions + +SDX_KD_GETTD = 100 ; get time and date +SDX_KD_SETTD = 101 ; set time and date + +;------------------------------------------------------------------------- +; Cartridge Address Equates +;------------------------------------------------------------------------- + +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 + +;------------------------------------------------------------------------- +; CTIA/GTIA Address Equates +;------------------------------------------------------------------------- + +GTIA = $D000 ;CTIA/GTIA area +.include "atari_gtia.inc" + +;------------------------------------------------------------------------- +; PBI Address Equates +;------------------------------------------------------------------------- + +PBI = $D100 ;##rev2## parallel bus interface area + +; Read Addresses + +PDVI = $D1FF ;##rev2## parallel device IRQ status + +; Write Addresses + +PDVS = $D1FF ;##rev2## parallel device select + +;------------------------------------------------------------------------- +; POKEY Address Equates +;------------------------------------------------------------------------- + +POKEY = $D200 ;POKEY area +.include "atari_pokey.inc" + +; POKEY KBCODE Values + +KEY_NONE = $FF + +KEY_0 = $32 +KEY_1 = $1F +KEY_2 = $1E +KEY_3 = $1A +KEY_4 = $18 +KEY_5 = $1D +KEY_6 = $1B +KEY_7 = $33 +KEY_8 = $35 +KEY_9 = $30 + +KEY_A = $3F +KEY_B = $15 +KEY_C = $12 +KEY_D = $3A +KEY_E = $2A +KEY_F = $38 +KEY_G = $3D +KEY_H = $39 +KEY_I = $0D +KEY_J = $01 +KEY_K = $05 +KEY_L = $00 +KEY_M = $25 +KEY_N = $23 +KEY_O = $08 +KEY_P = $0A +KEY_Q = $2F +KEY_R = $28 +KEY_S = $3E +KEY_T = $2D +KEY_U = $0B +KEY_V = $10 +KEY_W = $2E +KEY_X = $16 +KEY_Y = $2B +KEY_Z = $17 + +KEY_COMMA = $20 +KEY_PERIOD = $22 +KEY_SLASH = $26 +KEY_SEMICOLON = $02 +KEY_PLUS = $06 +KEY_ASTERISK = $07 +KEY_DASH = $0E +KEY_EQUALS = $0F +KEY_LESSTHAN = $36 +KEY_GREATERTHAN = $37 + +KEY_ESC = $1C +KEY_TAB = $2C +KEY_SPACE = $21 +KEY_RETURN = $0C +KEY_DELETE = $34 +KEY_CAPS = $3C +KEY_INVERSE = $27 +KEY_HELP = $11 + +KEY_F1 = $03 +KEY_F2 = $04 +KEY_F3 = $13 +KEY_F4 = $14 + +KEY_SHIFT = $40 +KEY_CTRL = $80 + +; Composed keys + +KEY_EXCLAMATIONMARK = KEY_1 | KEY_SHIFT +KEY_QUOTE = KEY_2 | KEY_SHIFT +KEY_HASH = KEY_3 | KEY_SHIFT +KEY_DOLLAR = KEY_4 | KEY_SHIFT +KEY_PERCENT = KEY_5 | KEY_SHIFT +KEY_AMPERSAND = KEY_6 | KEY_SHIFT +KEY_APOSTROPHE = KEY_7 | KEY_SHIFT +KEY_AT = KEY_8 | KEY_SHIFT +KEY_OPENINGPARAN = KEY_9 | KEY_SHIFT +KEY_CLOSINGPARAN = KEY_0 | KEY_SHIFT +KEY_UNDERLINE = KEY_DASH | KEY_SHIFT +KEY_BAR = KEY_EQUALS | KEY_SHIFT +KEY_COLON = KEY_SEMICOLON | KEY_SHIFT +KEY_BACKSLASH = KEY_PLUS | KEY_SHIFT +KEY_CIRCUMFLEX = KEY_ASTERISK | KEY_SHIFT +KEY_OPENINGBRACKET = KEY_COMMA | KEY_SHIFT +KEY_CLOSINGBRACKET = KEY_PERIOD | KEY_SHIFT +KEY_QUESTIONMARK = KEY_SLASH | KEY_SHIFT +KEY_CLEAR = KEY_LESSTHAN | KEY_SHIFT +KEY_INSERT = KEY_GREATERTHAN | KEY_SHIFT + +KEY_UP = KEY_DASH | KEY_CTRL +KEY_DOWN = KEY_EQUALS | KEY_CTRL +KEY_LEFT = KEY_PLUS | KEY_CTRL +KEY_RIGHT = KEY_ASTERISK | KEY_CTRL + +;------------------------------------------------------------------------- +; ANTIC Address Equates +;------------------------------------------------------------------------- + +ANTIC = $D400 ;ANTIC area +.include "atari_antic.inc" + +; PBI RAM Address Equates + +PBIRAM = $D600 ;##rev2## parallel bus interface RAM area + +; Parallel Device Address Equates + +PDID1 = $D803 ;##rev2## parallel device ID 1 +PDIDV = $D805 ;##rev2## parallel device I/O vector +PDIRQV = $D808 ;##rev2## parallel device IRQ vector +PDID2 = $D80B ;##rev2## parallel device ID 2 +PDVV = $D80D ;##rev2## parallel device vector table + +;------------------------------------------------------------------------- +; PIA Address Equates +;------------------------------------------------------------------------- + +PIA = $D300 ;PIA area + +PORTA = $D300 ;port A direction register or jacks one/two +PORTB = $D301 ;port B direction register or memory management + +PACTL = $D302 ;port A control +PBCTL = $D303 ;port B control + +;------------------------------------------------------------------------- +; Floating Point Package Address Equates +;------------------------------------------------------------------------- + +AFP = $D800 ;convert ASCII to floating point +FASC = $D8E6 ;convert floating point to ASCII +IFP = $D9AA ;convert integer to floating point +FPI = $D9D2 ;convert floating point to integer +ZFR0 = $DA44 ;zero FR0 +ZF1 = $DA46 ;zero floating point number +FSUB = $DA60 ;subtract floating point numbers +FADD = $DA66 ;add floating point numbers +FMUL = $DADB ;multiply floating point numbers +FDIV = $DB28 ;divide floating point numbers +PLYEVL = $DD40 ;evaluate floating point polynomial +FLD0R = $DD89 ;load floating point number +FLD0P = $DD8D ;load floating point number +FLD1R = $DD98 ;load floating point number +PLD1P = $DD9C ;load floating point number +FST0R = $DDA7 ;store floating point number +FST0P = $DDAB ;store floating point number +FMOVE = $DDB6 ;move floating point number +LOG = $DECD ;calculate floating point logarithm +LOG10 = $DED1 ;calculate floating point base 10 logarithm +EXP = $DDC0 ;calculate floating point exponential +EXP10 = $DDCC ;calculate floating point base 10 exponential + +;------------------------------------------------------------------------- +; Device Handler Vector Table Address Equates +;------------------------------------------------------------------------- + +EDITRV = $E400 ;editor handler vector table +SCRENV = $E410 ;screen handler vector table +KEYBDV = $E420 ;keyboard handler vector table +PRINTV = $E430 ;printer handler vector table +CASETV = $E440 ;cassette handler vector table + +;------------------------------------------------------------------------- +; Jump Vector Address Equates +;------------------------------------------------------------------------- + +DISKIV = $E450 ;vector to initialize DIO +DSKINV = $E453 ;vector to DIO +.ifdef __ATARIXL__ +.ifndef SHRAM_HANDLERS +.import CIO_handler, SIO_handler, SETVBV_handler +.endif +.define CIOV CIO_handler +.define SIOV SIO_handler +.define SETVBV SETVBV_handler +CIOV_org = $E456 ;vector to CIO +SIOV_org = $E459 ;vector to SIO +SETVBV_org = $E45C ;vector to set VBLANK parameters +.else +CIOV = $E456 ;vector to CIO +SIOV = $E459 ;vector to SIO +SETVBV = $E45C ;vector to set VBLANK parameters +; aliases in order not to have to sprinkle common code with .ifdefs +CIOV_org = CIOV +SIOV_org = SIOV +SETVBV_org = SETVBV +.endif +SYSVBV = $E45F ;vector to process immediate VBLANK +XITVBV = $E462 ;vector to process deferred VBLANK +SIOINV = $E465 ;vector to initialize SIO +SENDEV = $E468 ;vector to enable SEND +INTINV = $E46B ;vector to initialize interrupt handler +CIOINV = $E46E ;vector to initialize CIO +BLKBDV = $E471 ;vector to power-up display +WARMSV = $E474 ;vector to warmstart +COLDSV = $E477 ;vector to coldstart +RBLOKV = $E47A ;vector to read cassette block +CSOPIV = $E47D ;vector to open cassette for input +VCTABL = $E480 ;RAM vector initial value table +PUPDIV = $E480 ;##rev2## vector to power-up display +SLFTSV = $E483 ;##rev2## vector to self-test +PHENTV = $E486 ;##rev2## vector to enter peripheral handler +PHUNLV = $E489 ;##rev2## vector to unlink peripheral handler +PHINIV = $E48C ;##rev2## vector to initialize peripheral handler +GPDVV = $E48F ;##rev2## generic parallel device handler vector + +; NOTE: OS rom self-test labels are not included in this file + +;------------------------------------------------------------------------- +; Some misc. stuff from the 400/800 rev.B source +;------------------------------------------------------------------------- + +; THE FOLLOWING ARE IN BASIC CARTRIDGE: +SIN = $BD81 ;FR0 <- SIN (FR0) DEGFLG (0=RAD,6=DEG) CARRY +COS = $BD73 ;FR0 <- COS (FR0) CARRY +ATAN = $BE43 ;FR0 <- ATAN(FR0) CARRY +SQR = $BEB1 ;FR0 <- ROOT(FR0) CARRY + +RADON = 0 ;INDICATES RADIANS +DEGON = 6 ;INDICATES DEGREES + +ASCZER = '0' ;ASCII ZERO +COLON = $3A ;ASCII COLON +CR = $9B ;SYSTEM EOL (CARRIAGE RETURN) + +;------------------------------------------------------------------------- +; 6502 +;------------------------------------------------------------------------- + +NMIVEC = $FFFA +RESVEC = $FFFC +IRQVEC = $FFFE + +;------------------------------------------------------------------------- +; BASIC +;------------------------------------------------------------------------- + +LOMEM = $80 ;2-byte low memory pointer +VNTP = $82 ;2-byte variable name table address +VNTD = $84 ;2-byte variable name table end + 1 +VVTP = $86 ;2-byte variable value table +STMTAB = $88 ;2-byte statement table address +STMCUR = $8A ;2-byte current statement pointer +STARP = $8C ;2-byte string and array table pointer +RUNSTK = $8E ;2-byte runtime stack address +BMEMTOP = $90 ;2-byte top of memory pointer +STOPLN = $BA ;2-byte stopped line number +ERRSAVE = $C3 ;1-byte error code +PTABW = $C9 ;1-byte tab width + +;------------------------------------------------------------------------- +; 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 + +;------------------------------------------------------------------------- +; OFFSETS INTO SECTSIZETAB (DIO functions) +;------------------------------------------------------------------------- + +sst_flag = 0 ; length 1 +sst_sectsize = 1 ; 2 +sst_driveno = 3 ; 1 (drive #) +sst_size = 4 ; size of one entry + ; if changed, adapt diopncls.s + +;------------------------------------------------------------------------- +; OFFSETS INTO dio_phys_pos +;------------------------------------------------------------------------- + +diopp_head = 0 ; head +diopp_track = 1 ; track / cylinder +diopp_sector = 3 ; sector +diopp_size = 5 ; size of structure + +;------------------------------------------------------------------------- +; VALUES for dos_type +;------------------------------------------------------------------------- + +SPARTADOS = 0 +REALDOS = 1 +BWDOS = 2 +OSADOS = 3 ; OS/A+ +XDOS = 4 +ATARIDOS = 5 +MYDOS = 6 +NODOS = 255 +; The DOSes with dos_type below or equal MAX_DOS_WITH_CMDLINE do support +; command line arguments. +MAX_DOS_WITH_CMDLINE = XDOS + +;------------------------------------------------------------------------- +; XDOS defines (version 2.4, taken from xdos24.pdf) +;------------------------------------------------------------------------- + +XOPT = $070B ; XDOS options +XCAR = $070C ; XDOS cartridge address (+ $70D) +XPAT = $086F ; XDOS bugfix and patch number +XVER = $0870 ; XDOS version number +XFILE = $087D ; XDOS filename buffer +XLINE = $0880 ; XDOS DUP input line +XGLIN = $0871 ; get line +XSKIP = $0874 ; skip parameter +.ifdef __ATARIXL__ +.ifndef SHRAM_HANDLERS +.import XMOVE_handler +.endif +.define XMOVE XMOVE_handler +XMOVE_org = $0877 ; move filename +.else +XMOVE = $0877 ; move filename +.endif +XGNUM = $087A ; get number + +;------------------------------------------------------------------------- +; End of atari.inc +;------------------------------------------------------------------------- diff --git a/cc65/asminc/atari.mac b/cc65/asminc/atari.mac new file mode 100644 index 0000000..952af87 --- /dev/null +++ b/cc65/asminc/atari.mac @@ -0,0 +1,65 @@ +; 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 + + ; Check for an identifier + .elseif .match (.left (1, {arg1}), identifier) + + ; Just output the identifier + _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/cc65/asminc/atari2600.inc b/cc65/asminc/atari2600.inc new file mode 100644 index 0000000..a20926d --- /dev/null +++ b/cc65/asminc/atari2600.inc @@ -0,0 +1,7 @@ +; Atari 2600 TIA & RIOT read / write registers +; +; Florent Flament (contact@florentflament.com), 2017 + +; TIA & RIOT registers mapping +.include "atari2600_tia.inc" +.include "atari2600_riot.inc" diff --git a/cc65/asminc/atari2600_riot.inc b/cc65/asminc/atari2600_riot.inc new file mode 100644 index 0000000..a2c6ef6 --- /dev/null +++ b/cc65/asminc/atari2600_riot.inc @@ -0,0 +1,20 @@ +; Atari 2600 RIOT read / write registers +; +; Source: DASM - vcs.h +; Details available in: Stella Programmer's Guide by Steve Wright +; +; Florent Flament (contact@florentflament.com), 2017 + +; Read registers +SWCHA := $0280 +SWACNT := $0281 +SWCHB := $0282 +SWBCNT := $0283 +INTIM := $0284 +TIMINT := $0285 + +; Write registers +TIM1T := $0294 +TIM8T := $0295 +TIM64T := $0296 +T1024T := $0297 diff --git a/cc65/asminc/atari2600_tia.inc b/cc65/asminc/atari2600_tia.inc new file mode 100644 index 0000000..57c27ad --- /dev/null +++ b/cc65/asminc/atari2600_tia.inc @@ -0,0 +1,69 @@ +; Atari 2600 TIA read / write registers +; +; Source: DASM - vcs.h +; Details available in: Stella Programmer's Guide by Steve Wright +; +; Florent Flament (contact@florentflament.com), 2017 + +; Read registers +VSYNC := $00 +VBLANK := $01 +WSYNC := $02 +RSYNC := $03 +NUSIZ0 := $04 +NUSIZ1 := $05 +COLUP0 := $06 +COLUP1 := $07 +COLUPF := $08 +COLUBK := $09 +CTRLPF := $0A +REFP0 := $0B +REFP1 := $0C +PF0 := $0D +PF1 := $0E +PF2 := $0F +RESP0 := $10 +RESP1 := $11 +RESM0 := $12 +RESM1 := $13 +RESBL := $14 +AUDC0 := $15 +AUDC1 := $16 +AUDF0 := $17 +AUDF1 := $18 +AUDV0 := $19 +AUDV1 := $1A +GRP0 := $1B +GRP1 := $1C +ENAM0 := $1D +ENAM1 := $1E +ENABL := $1F +HMP0 := $20 +HMP1 := $21 +HMM0 := $22 +HMM1 := $23 +HMBL := $24 +VDELP0 := $25 +VDELP1 := $26 +VDELBL := $27 +RESMP0 := $28 +RESMP1 := $29 +HMOVE := $2A +HMCLR := $2B +CXCLR := $2C + +; Write registers +CXM0P := $00 +CXM1P := $01 +CXP0FB := $02 +CXP1FB := $03 +CXM0FB := $04 +CXM1FB := $05 +CXBLPF := $06 +CXPPMM := $07 +INPT0 := $08 +INPT1 := $09 +INPT2 := $0A +INPT3 := $0B +INPT4 := $0C +INPT5 := $0D diff --git a/cc65/asminc/atari5200.inc b/cc65/asminc/atari5200.inc new file mode 100644 index 0000000..b560c06 --- /dev/null +++ b/cc65/asminc/atari5200.inc @@ -0,0 +1,133 @@ +;------------------------------------------------------------------------- +; Atari 5200 System Equates +; by Christian Groessler +; taken from EQUATES.INC from Atari Inc. +;------------------------------------------------------------------------- + +;------------------------------------------------------------------------- +; ATASCII CHARACTER DEFS +;------------------------------------------------------------------------- + +ATEOL = $9B ; END-OF-LINE, used by CONIO + +;------------------------------------------------------------------------- +; CONIO CHARACTER DEFS +;------------------------------------------------------------------------- + +CH_ULCORNER = $0B ; '+' sign +CH_URCORNER = $0B +CH_LLCORNER = $0B +CH_LRCORNER = $0B +CH_HLINE = $0D ; dash +CH_VLINE = $01 ; exclamation mark + +;------------------------------------------------------------------------- +; 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 " + +; cc65 runtime zero page variables + +ROWCRS_5200 = $19 +COLCRS_5200 = $1A +SAVMSC = $1B ; pointer to screen memory (conio) + +;------------------------------------------------------------------------- +; 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 "atari_gtia.inc" + +;------------------------------------------------------------------------- +; ANTIC Address Equates +;------------------------------------------------------------------------- + +ANTIC = $D400 ; ANTIC area +.include "atari_antic.inc" + +;------------------------------------------------------------------------- +; POKEY Address Equates +;------------------------------------------------------------------------- + +POKEY = $E800 ; POKEY area +.include "atari_pokey.inc" + +;------------------------------------------------------------------------- +; conio color defines +;------------------------------------------------------------------------- + +COLOR_WHITE = 0 +COLOR_RED = 1 +COLOR_GREEN = 2 +COLOR_BLACK = 3 + +;------------------------------------------------------------------------- +; 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/cc65/asminc/atari7800.inc b/cc65/asminc/atari7800.inc new file mode 100644 index 0000000..0f109ba --- /dev/null +++ b/cc65/asminc/atari7800.inc @@ -0,0 +1,14 @@ +; Atari 7800 TIA & RIOT read / write registers +; +; Karri Kaksonen (karri@sipo.fi), 2022 + +; TIA, RIOT & MARIA registers mapping +.include "atari7800_tia.inc" +.include "atari7800_riot.inc" +.include "atari7800_maria.inc" + +; constants for the conio implementation +mono_charsperline = 40 +charsperline = 20 +screenrows = 28 + diff --git a/cc65/asminc/atari7800_maria.inc b/cc65/asminc/atari7800_maria.inc new file mode 100644 index 0000000..39624d2 --- /dev/null +++ b/cc65/asminc/atari7800_maria.inc @@ -0,0 +1,39 @@ +; Atari 7800 MARIA read / write registers +; + +; Read registers +BKGRND := $20 +P0C1 := $21 +P0C2 := $22 +P0C3 := $23 +MWSYNC := $24 +P1C1 := $25 +P1C2 := $26 +P1C3 := $27 +MSTAT := $28 +P2C1 := $29 +P2C2 := $2A +P2C3 := $2B +DPPH := $2C +P3C1 := $2D +P3C2 := $2E +P3C3 := $2F +DPPL := $30 +P4C1 := $31 +P4C2 := $32 +P4C3 := $33 +CHBASE := $34 +P5C1 := $35 +P5C2 := $36 +P5C3 := $37 +OFFSET := $38 +P6C1 := $39 +P6C2 := $3A +P6C3 := $3B +CTRL := $3C +P7C1 := $3D +P7C2 := $3E +P7C3 := $3F + +; Write registers + diff --git a/cc65/asminc/atari7800_riot.inc b/cc65/asminc/atari7800_riot.inc new file mode 100644 index 0000000..780e34d --- /dev/null +++ b/cc65/asminc/atari7800_riot.inc @@ -0,0 +1,20 @@ +; Atari 7800 RIOT read / write registers +; +; Source: DASM - vcs.h +; Details available in: Stella Programmer's Guide by Steve Wright +; +; Florent Flament (contact@florentflament.com), 2017 + +; Read registers +SWCHA := $0280 +CTLSWA := $0281 +SWCHB := $0282 +CTLSWB := $0283 +INTIM := $0284 +TIMINT := $0285 + +; Write registers +TIM1T := $0294 +TIM8T := $0295 +TIM64T := $0296 +T1024T := $0297 diff --git a/cc65/asminc/atari7800_tia.inc b/cc65/asminc/atari7800_tia.inc new file mode 100644 index 0000000..f4439e4 --- /dev/null +++ b/cc65/asminc/atari7800_tia.inc @@ -0,0 +1,69 @@ +; Atari 7800 TIA read / write registers +; +; Source: DASM - vcs.h +; Details available in: Stella Programmer's Guide by Steve Wright +; +; Florent Flament (contact@florentflament.com), 2017 + +; Read registers +VSYNC := $00 +VBLANK := $01 +WSYNC := $02 +RSYNC := $03 +NUSIZ0 := $04 +NUSIZ1 := $05 +COLUP0 := $06 +COLUP1 := $07 +COLUPF := $08 +COLUBK := $09 +CTRLPF := $0A +REFP0 := $0B +REFP1 := $0C +PF0 := $0D +PF1 := $0E +PF2 := $0F +RESP0 := $10 +RESP1 := $11 +RESM0 := $12 +RESM1 := $13 +RESBL := $14 +AUDC0 := $15 +AUDC1 := $16 +AUDF0 := $17 +AUDF1 := $18 +AUDV0 := $19 +AUDV1 := $1A +GRP0 := $1B +GRP1 := $1C +ENAM0 := $1D +ENAM1 := $1E +ENABL := $1F +HMP0 := $20 +HMP1 := $21 +HMM0 := $22 +HMM1 := $23 +HMBL := $24 +VDELP0 := $25 +VDELP1 := $26 +VDELBL := $27 +RESMP0 := $28 +RESMP1 := $29 +HMOVE := $2A +HMCLR := $2B +CXCLR := $2C + +; Write registers +CXM0P := $00 +CXM1P := $01 +CXP0FB := $02 +CXP1FB := $03 +CXM0FB := $04 +CXM1FB := $05 +CXBLPF := $06 +CXPPMM := $07 +INPT0 := $08 +INPT1 := $09 +INPT2 := $0A +INPT3 := $0B +INPT4 := $0C +INPT5 := $0D diff --git a/cc65/asminc/atari_antic.inc b/cc65/asminc/atari_antic.inc new file mode 100644 index 0000000..9a097e0 --- /dev/null +++ b/cc65/asminc/atari_antic.inc @@ -0,0 +1,95 @@ +;------------------------------------------------------------------------- +; 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_BLKn display n empty lines (just background) + +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/cc65/asminc/atari_atascii_charmap.inc b/cc65/asminc/atari_atascii_charmap.inc new file mode 100644 index 0000000..7c6b5e5 --- /dev/null +++ b/cc65/asminc/atari_atascii_charmap.inc @@ -0,0 +1,301 @@ +;/*****************************************************************************/ +;/* */ +;/* atari_atascii_charmap.inc */ +;/* */ +;/* Atari system standard string mapping ISO-8859-1 -> AtASCII */ +;/* */ +;/* */ +;/* */ +;/* C 2016 Christian Krueger */ +;/* */ +;/* */ +;/* 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. */ +;/* */ +;/*****************************************************************************/ + +.charmap $00, $00 +.charmap $01, $01 +.charmap $02, $02 +.charmap $03, $03 +.charmap $04, $04 +.charmap $05, $05 +.charmap $06, $06 +.charmap $07, $FD +.charmap $08, $08 +.charmap $09, $7F +.charmap $0A, $9B +.charmap $0B, $0B +.charmap $0C, $7D +.charmap $0D, $0D +.charmap $0E, $0E +.charmap $0F, $0F + +.charmap $10, $10 +.charmap $11, $11 +.charmap $12, $12 +.charmap $13, $13 +.charmap $14, $14 +.charmap $15, $15 +.charmap $16, $16 +.charmap $17, $17 +.charmap $18, $18 +.charmap $19, $19 +.charmap $1A, $1A +.charmap $1B, $1B +.charmap $1C, $1C +.charmap $1D, $1D +.charmap $1E, $1E +.charmap $1F, $1F + +.charmap $20, $20 +.charmap $21, $21 +.charmap $22, $22 +.charmap $23, $23 +.charmap $24, $24 +.charmap $25, $25 +.charmap $26, $26 +.charmap $27, $27 +.charmap $28, $28 +.charmap $29, $29 +.charmap $2A, $2A +.charmap $2B, $2B +.charmap $2C, $2C +.charmap $2D, $2D +.charmap $2E, $2E +.charmap $2F, $2F + +.charmap $30, $30 +.charmap $31, $31 +.charmap $32, $32 +.charmap $33, $33 +.charmap $34, $34 +.charmap $35, $35 +.charmap $36, $36 +.charmap $37, $37 +.charmap $38, $38 +.charmap $39, $39 +.charmap $3A, $3A +.charmap $3B, $3B +.charmap $3C, $3C +.charmap $3D, $3D +.charmap $3E, $3E +.charmap $3F, $3F + +.charmap $40, $40 +.charmap $41, $41 +.charmap $42, $42 +.charmap $43, $43 +.charmap $44, $44 +.charmap $45, $45 +.charmap $46, $46 +.charmap $47, $47 +.charmap $48, $48 +.charmap $49, $49 +.charmap $4A, $4A +.charmap $4B, $4B +.charmap $4C, $4C +.charmap $4D, $4D +.charmap $4E, $4E +.charmap $4F, $4F + +.charmap $50, $50 +.charmap $51, $51 +.charmap $52, $52 +.charmap $53, $53 +.charmap $54, $54 +.charmap $55, $55 +.charmap $56, $56 +.charmap $57, $57 +.charmap $58, $58 +.charmap $59, $59 +.charmap $5A, $5A +.charmap $5B, $5B +.charmap $5C, $5C +.charmap $5D, $5D +.charmap $5E, $5E +.charmap $5F, $5F + +.charmap $60, $60 +.charmap $61, $61 +.charmap $62, $62 +.charmap $63, $63 +.charmap $64, $64 +.charmap $65, $65 +.charmap $66, $66 +.charmap $67, $67 +.charmap $68, $68 +.charmap $69, $69 +.charmap $6A, $6A +.charmap $6B, $6B +.charmap $6C, $6C +.charmap $6D, $6D +.charmap $6E, $6E +.charmap $6F, $6F + +.charmap $70, $70 +.charmap $71, $71 +.charmap $72, $72 +.charmap $73, $73 +.charmap $74, $74 +.charmap $75, $75 +.charmap $76, $76 +.charmap $77, $77 +.charmap $78, $78 +.charmap $79, $79 +.charmap $7A, $7A +.charmap $7B, $7B +.charmap $7C, $7C +.charmap $7D, $7D +.charmap $7E, $7E +.charmap $7F, $7F + +.charmap $80, $80 +.charmap $81, $81 +.charmap $82, $82 +.charmap $83, $83 +.charmap $84, $84 +.charmap $85, $85 +.charmap $86, $86 +.charmap $87, $87 +.charmap $88, $88 +.charmap $89, $89 +.charmap $8A, $8A +.charmap $8B, $8B +.charmap $8C, $8C +.charmap $8D, $8D +.charmap $8E, $8E +.charmap $8F, $8F + +.charmap $90, $90 +.charmap $91, $91 +.charmap $92, $92 +.charmap $93, $93 +.charmap $94, $94 +.charmap $95, $95 +.charmap $96, $96 +.charmap $97, $97 +.charmap $98, $98 +.charmap $99, $99 +.charmap $9A, $9A +.charmap $9B, $9B +.charmap $9C, $9C +.charmap $9D, $9D +.charmap $9E, $9E +.charmap $9F, $9F + +.charmap $A0, $A0 +.charmap $A1, $A1 +.charmap $A2, $A2 +.charmap $A3, $A3 +.charmap $A4, $A4 +.charmap $A5, $A5 +.charmap $A6, $A6 +.charmap $A7, $A7 +.charmap $A8, $A8 +.charmap $A9, $A9 +.charmap $AA, $AA +.charmap $AB, $AB +.charmap $AC, $AC +.charmap $AD, $AD +.charmap $AE, $AE +.charmap $AF, $AF + +.charmap $B0, $B0 +.charmap $B1, $B1 +.charmap $B2, $B2 +.charmap $B3, $B3 +.charmap $B4, $B4 +.charmap $B5, $B5 +.charmap $B6, $B6 +.charmap $B7, $B7 +.charmap $B8, $B8 +.charmap $B9, $B9 +.charmap $BA, $BA +.charmap $BB, $BB +.charmap $BC, $BC +.charmap $BD, $BD +.charmap $BE, $BE +.charmap $BF, $BF + +.charmap $C0, $C0 +.charmap $C1, $C1 +.charmap $C2, $C2 +.charmap $C3, $C3 +.charmap $C4, $C4 +.charmap $C5, $C5 +.charmap $C6, $C6 +.charmap $C7, $C7 +.charmap $C8, $C8 +.charmap $C9, $C9 +.charmap $CA, $CA +.charmap $CB, $CB +.charmap $CC, $CC +.charmap $CD, $CD +.charmap $CE, $CE +.charmap $CF, $CF + +.charmap $D0, $D0 +.charmap $D1, $D1 +.charmap $D2, $D2 +.charmap $D3, $D3 +.charmap $D4, $D4 +.charmap $D5, $D5 +.charmap $D6, $D6 +.charmap $D7, $D7 +.charmap $D8, $D8 +.charmap $D9, $D9 +.charmap $DA, $DA +.charmap $DB, $DB +.charmap $DC, $DC +.charmap $DD, $DD +.charmap $DE, $DE +.charmap $DF, $DF + +.charmap $E0, $E0 +.charmap $E1, $E1 +.charmap $E2, $E2 +.charmap $E3, $E3 +.charmap $E4, $E4 +.charmap $E5, $E5 +.charmap $E6, $E6 +.charmap $E7, $E7 +.charmap $E8, $E8 +.charmap $E9, $E9 +.charmap $EA, $EA +.charmap $EB, $EB +.charmap $EC, $EC +.charmap $ED, $ED +.charmap $EE, $EE +.charmap $EF, $EF + +.charmap $F0, $F0 +.charmap $F1, $F1 +.charmap $F2, $F2 +.charmap $F3, $F3 +.charmap $F4, $F4 +.charmap $F5, $F5 +.charmap $F6, $F6 +.charmap $F7, $F7 +.charmap $F8, $F8 +.charmap $F9, $F9 +.charmap $FA, $FA +.charmap $FB, $FB +.charmap $FC, $FC +.charmap $FD, $FD +.charmap $FE, $FE +.charmap $FF, $FF diff --git a/cc65/asminc/atari_gtia.inc b/cc65/asminc/atari_gtia.inc new file mode 100644 index 0000000..dd1c877 --- /dev/null +++ b/cc65/asminc/atari_gtia.inc @@ -0,0 +1,119 @@ +;------------------------------------------------------------------------- +; 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 + + +; Hue values + +HUE_GREY = 0 +HUE_GOLD = 1 +HUE_GOLDORANGE = 2 +HUE_REDORANGE = 3 +HUE_ORANGE = 4 +HUE_MAGENTA = 5 +HUE_PURPLE = 6 +HUE_BLUE = 7 +HUE_BLUE2 = 8 +HUE_CYAN = 9 +HUE_BLUEGREEN = 10 +HUE_BLUEGREEN2 = 11 +HUE_GREEN = 12 +HUE_YELLOWGREEN = 13 +HUE_YELLOW = 14 +HUE_YELLOWRED = 15 + +; Color defines, similar to c64 colors (untested) + +GTIA_COLOR_BLACK = (HUE_GREY << 4) +GTIA_COLOR_WHITE = (HUE_GREY << 4 | 7 << 1) +GTIA_COLOR_RED = (HUE_REDORANGE << 4 | 1 << 1) +GTIA_COLOR_CYAN = (HUE_CYAN << 4 | 3 << 1) +GTIA_COLOR_VIOLET = (HUE_PURPLE << 4 | 4 << 1) +GTIA_COLOR_GREEN = (HUE_GREEN << 4 | 2 << 1) +GTIA_COLOR_BLUE = (HUE_BLUE << 4 | 2 << 1) +GTIA_COLOR_YELLOW = (HUE_YELLOW << 4 | 7 << 1) +GTIA_COLOR_ORANGE = (HUE_ORANGE << 4 | 5 << 1) +GTIA_COLOR_BROWN = (HUE_YELLOW << 4 | 2 << 1) +GTIA_COLOR_LIGHTRED = (HUE_REDORANGE << 4 | 6 << 1) +GTIA_COLOR_GRAY1 = (HUE_GREY << 4 | 2 << 1) +GTIA_COLOR_GRAY2 = (HUE_GREY << 4 | 3 << 1) +GTIA_COLOR_LIGHTGREEN = (HUE_GREEN << 4 | 6 << 1) +GTIA_COLOR_LIGHTBLUE = (HUE_BLUE << 4 | 6 << 1) +GTIA_COLOR_GRAY3 = (HUE_GREY << 4 | 5 << 1) diff --git a/cc65/asminc/atari_pokey.inc b/cc65/asminc/atari_pokey.inc new file mode 100644 index 0000000..4174865 --- /dev/null +++ b/cc65/asminc/atari_pokey.inc @@ -0,0 +1,43 @@ +;------------------------------------------------------------------------- +; 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/cc65/asminc/atari_screen_charmap.inc b/cc65/asminc/atari_screen_charmap.inc new file mode 100644 index 0000000..193ea06 --- /dev/null +++ b/cc65/asminc/atari_screen_charmap.inc @@ -0,0 +1,303 @@ +;/*****************************************************************************/ +;/* */ +;/* atari_screen_charmap.inc */ +;/* */ +;/* Atari system internal string mapping ISO-8859-1 -> Internal/Screen-Code */ +;/* */ +;/* */ +;/* */ +;/* C 2016 Christian Krueger */ +;/* */ +;/* */ +;/* 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. */ +;/* */ +;/*****************************************************************************/ + +.charmap $00, $40 +.charmap $01, $41 +.charmap $02, $42 +.charmap $03, $43 +.charmap $04, $44 +.charmap $05, $45 +.charmap $06, $46 +.charmap $07, $FD +.charmap $08, $48 +.charmap $09, $7F +.charmap $0A, $DB +.charmap $0B, $4B +.charmap $0C, $7D +.charmap $0D, $4D +.charmap $0E, $4E +.charmap $0F, $4F + +.charmap $10, $50 +.charmap $11, $51 +.charmap $12, $52 +.charmap $13, $53 +.charmap $14, $54 +.charmap $15, $55 +.charmap $16, $56 +.charmap $17, $57 +.charmap $18, $58 +.charmap $19, $59 +.charmap $1A, $5A +.charmap $1B, $5B +.charmap $1C, $5C +.charmap $1D, $5D +.charmap $1E, $5E +.charmap $1F, $5F + +.charmap $20, $00 + +.charmap $21, $01 +.charmap $22, $02 +.charmap $23, $03 +.charmap $24, $04 +.charmap $25, $05 +.charmap $26, $06 +.charmap $27, $07 +.charmap $28, $08 +.charmap $29, $09 +.charmap $2A, $0A +.charmap $2B, $0B +.charmap $2C, $0C +.charmap $2D, $0D +.charmap $2E, $0E +.charmap $2F, $0F + +.charmap $30, $10 +.charmap $31, $11 +.charmap $32, $12 +.charmap $33, $13 +.charmap $34, $14 +.charmap $35, $15 +.charmap $36, $16 +.charmap $37, $17 +.charmap $38, $18 +.charmap $39, $19 +.charmap $3A, $1A +.charmap $3B, $1B +.charmap $3C, $1C +.charmap $3D, $1D +.charmap $3E, $1E +.charmap $3F, $1F + +.charmap $40, $20 +.charmap $41, $21 +.charmap $42, $22 +.charmap $43, $23 +.charmap $44, $24 +.charmap $45, $25 +.charmap $46, $26 +.charmap $47, $27 +.charmap $48, $28 +.charmap $49, $29 +.charmap $4A, $2A +.charmap $4B, $2B +.charmap $4C, $2C +.charmap $4D, $2D +.charmap $4E, $2E +.charmap $4F, $2F + +.charmap $50, $30 +.charmap $51, $31 +.charmap $52, $32 +.charmap $53, $33 +.charmap $54, $34 +.charmap $55, $35 +.charmap $56, $36 +.charmap $57, $37 +.charmap $58, $38 +.charmap $59, $39 +.charmap $5A, $3A +.charmap $5B, $3B +.charmap $5C, $3C +.charmap $5D, $3D +.charmap $5E, $3E +.charmap $5F, $3F + +.charmap $60, $60 +.charmap $61, $61 +.charmap $62, $62 +.charmap $63, $63 +.charmap $64, $64 +.charmap $65, $65 +.charmap $66, $66 +.charmap $67, $67 +.charmap $68, $68 +.charmap $69, $69 +.charmap $6A, $6A +.charmap $6B, $6B +.charmap $6C, $6C +.charmap $6D, $6D +.charmap $6E, $6E +.charmap $6F, $6F + +.charmap $70, $70 +.charmap $71, $71 +.charmap $72, $72 +.charmap $73, $73 +.charmap $74, $74 +.charmap $75, $75 +.charmap $76, $76 +.charmap $77, $77 +.charmap $78, $78 +.charmap $79, $79 +.charmap $7A, $7A +.charmap $7B, $7B +.charmap $7C, $7C +.charmap $7D, $7D +.charmap $7E, $7E +.charmap $7F, $7F + +.charmap $80, $C0 +.charmap $81, $C1 +.charmap $82, $C2 +.charmap $83, $C3 +.charmap $84, $C4 +.charmap $85, $C5 +.charmap $86, $C6 +.charmap $87, $C7 +.charmap $88, $C8 +.charmap $89, $C9 +.charmap $8A, $CA +.charmap $8B, $CB +.charmap $8C, $CC +.charmap $8D, $CD +.charmap $8E, $CE +.charmap $8F, $CF + +.charmap $90, $D0 +.charmap $91, $D1 +.charmap $92, $D2 +.charmap $93, $D3 +.charmap $94, $D4 +.charmap $95, $D5 +.charmap $96, $D6 +.charmap $97, $D7 +.charmap $98, $D8 +.charmap $99, $D9 +.charmap $9A, $DA +.charmap $9B, $DB +.charmap $9C, $DC +.charmap $9D, $DD +.charmap $9E, $DE +.charmap $9F, $DF + +.charmap $A0, $80 +.charmap $A1, $81 +.charmap $A2, $82 +.charmap $A3, $83 +.charmap $A4, $84 +.charmap $A5, $85 +.charmap $A6, $86 +.charmap $A7, $87 +.charmap $A8, $88 +.charmap $A9, $89 +.charmap $AA, $8A +.charmap $AB, $8B +.charmap $AC, $8C +.charmap $AD, $8D +.charmap $AE, $8E +.charmap $AF, $8F + +.charmap $B0, $90 +.charmap $B1, $91 +.charmap $B2, $92 +.charmap $B3, $93 +.charmap $B4, $94 +.charmap $B5, $95 +.charmap $B6, $96 +.charmap $B7, $97 +.charmap $B8, $98 +.charmap $B9, $99 +.charmap $BA, $9A +.charmap $BB, $9B +.charmap $BC, $9C +.charmap $BD, $9D +.charmap $BE, $9E +.charmap $BF, $9F + +.charmap $C0, $A0 +.charmap $C1, $A1 +.charmap $C2, $A2 +.charmap $C3, $A3 +.charmap $C4, $A4 +.charmap $C5, $A5 +.charmap $C6, $A6 +.charmap $C7, $A7 +.charmap $C8, $A8 +.charmap $C9, $A9 +.charmap $CA, $AA +.charmap $CB, $AB +.charmap $CC, $AC +.charmap $CD, $AD +.charmap $CE, $AE +.charmap $CF, $AF + +.charmap $D0, $B0 +.charmap $D1, $B1 +.charmap $D2, $B2 +.charmap $D3, $B3 +.charmap $D4, $B4 +.charmap $D5, $B5 +.charmap $D6, $B6 +.charmap $D7, $B7 +.charmap $D8, $B8 +.charmap $D9, $B9 +.charmap $DA, $BA +.charmap $DB, $BB +.charmap $DC, $BC +.charmap $DD, $BD +.charmap $DE, $BE +.charmap $DF, $BF + +.charmap $E0, $E0 +.charmap $E1, $E1 +.charmap $E2, $E2 +.charmap $E3, $E3 +.charmap $E4, $E4 +.charmap $E5, $E5 +.charmap $E6, $E6 +.charmap $E7, $E7 +.charmap $E8, $E8 +.charmap $E9, $E9 +.charmap $EA, $EA +.charmap $EB, $EB +.charmap $EC, $EC +.charmap $ED, $ED +.charmap $EE, $EE +.charmap $EF, $EF + +.charmap $F0, $F0 +.charmap $F1, $F1 +.charmap $F2, $F2 +.charmap $F3, $F3 +.charmap $F4, $F4 +.charmap $F5, $F5 +.charmap $F6, $F6 +.charmap $F7, $F7 +.charmap $F8, $F8 +.charmap $F9, $F9 +.charmap $FA, $FA +.charmap $FB, $FB +.charmap $FC, $FC +.charmap $FD, $FD +.charmap $FE, $FE +.charmap $FF, $FF + diff --git a/cc65/asminc/atmos.inc b/cc65/asminc/atmos.inc new file mode 100644 index 0000000..8edcf7d --- /dev/null +++ b/cc65/asminc/atmos.inc @@ -0,0 +1,117 @@ +; +; Oric Atmos definitions +; BASIC 1.1 addresses +; + + +; --------------------------------------------------------------------------- +; Constants + +SCREEN_XSIZE = 40 ; screen columns +SCREEN_YSIZE = 28 ; screen rows + +FUNCTKEY = $A5 + +FNAME_LEN = 16 ; maximum length of file-name + + +; --------------------------------------------------------------------------- +; Zero page + +SCRPTR := $12 +BASIC_BUF := $35 +CHARGOT := $E8 +TXTPTR := $E9 + + +; --------------------------------------------------------------------------- +; Low memory + +MODEKEY := $0209 +CAPSLOCK := $020C ; $7F = not locked, $FF = locked +PATTERN := $0213 +IRQVec := $0245 ; "fast" interrupt vector +JOINFLAG := $025A ; 0 = don't joiu, $4A = join BASIC programs +VERIFYFLAG := $025B ; 0 = load, 1 = verify +CURS_Y := $0268 +CURS_X := $0269 +STATUS := $026A +BACKGRND := $026B +FOREGRND := $026C +TIMER3 := $0276 +CFILE_NAME := $027F +CFOUND_NAME := $0293 +FILESTART := $02A9 +FILEEND := $02AB +AUTORUN := $02AD ; $00 = only load, $C7 = autorun +LANGFLAG := $02AE ; $00 = BASIC, $80 = machine code +LOADERR := $02B1 +KEYBUF := $02DF +PARMERR := $02E0 +PARAM1 := $02E1 ; & $02E2 +PARAM2 := $02E3 ; & $02E4 +PARAM3 := $02E5 ; & $02E6 +BANGVEC := $02F5 + + +; --------------------------------------------------------------------------- +; I/O locations + +; 6522 +.struct VIA ; Versatile Interface Adapter + .res $0300 +PRB .byte ; Port Register B +PRA .byte ; Port Register A +DDRB .byte ; Data Direction Register B +DDRA .byte ; Data Direction Register A +T1 .word ; Timer 1 +T1L .word ; Timer 1 Latch +T2 .word ; Timer 2 +SR .byte ; Shift Register +ACR .byte ; Auxiliary Control Register +PCR .byte ; Peripheral Control Register +IFR .byte ; Interrupt Flags Register +IER .byte ; Interrupt Enable Register +PRA2 .byte ; Port Register A without handshaking +.endstruct + +; 6551 +.struct ACIA ; Asynchronous Communications Interface Adapter + .res $031C +DATA .byte +STATUS .byte +CMD .byte ; Command register +CTRL .byte ; Control register +.endstruct + +SCREEN := $BB80 + + +; --------------------------------------------------------------------------- +; ROM entries + +GETLINE := $C592 +TEXT := $EC21 +HIRES := $EC33 +CURSET := $F0C8 +CURMOV := $F0FD +DRAW := $F110 +CHAR := $F12D +POINT := $F1C8 +PAPER := $F204 +INK := $F210 +PRINT := $F77C + +; Sound Effects +PING := $FA9F +PING1 := $FA85 +SHOOT := $FAB5 +SHOOT1 := $FA9B +EXPLODE := $FACB +EXPLODE1 := $FAB1 +ZAP := $FAE1 +ZAP1 := $FAC7 +TICK := $FB14 +TICK1 := $FAFA +TOCK := $FB2A +TOCK1 := $FB10 diff --git a/cc65/asminc/c128.inc b/cc65/asminc/c128.inc new file mode 100644 index 0000000..749b416 --- /dev/null +++ b/cc65/asminc/c128.inc @@ -0,0 +1,224 @@ +; +; C128 generic definitions. Stolen from Elite128 +; + + +; --------------------------------------------------------------------------- +; Zero page, Commodore stuff + +TXTPTR := $3D ; Pointer into BASIC source code +STATUS := $90 ; Kernal I/O completion status +TIME := $A0 ; 60HZ clock +FNAM_LEN := $B7 ; Length of filename +SECADR := $B9 ; Secondary address +DEVNUM := $BA ; Device number +FNAM := $BB ; Address of filename +FNAM_BANK := $C7 ; Bank for filename +KEY_COUNT := $D0 ; Number of keys in input buffer +FKEY_COUNT := $D1 ; Characters for function key +MODE := $D7 ; 40-/80-column mode (bit 7: 80 columns) +GRAPHM := $D8 ; Graphics mode flags (bits 5-7) +CHARDIS := $D9 ; Bit 2 shadow for location $01 +CURS_X := $EC ; Cursor column +CURS_Y := $EB ; Cursor row +SCREEN_PTR := $E0 ; Pointer to current char in text screen +CRAM_PTR := $E2 ; Pointer to current char in color RAM + +CHARCOLOR := $F1 +RVS := $F3 ; Reverse output flag +SCROLL := $F8 ; Disable scrolling flag + +BASIC_BUF := $0200 ; Location of command-line +BASIC_BUF_LEN = 162 ; Maximum length of command-line + +FETCH := $02A2 ; Fetch subroutine in RAM +FETVEC := $02AA ; Vector patch location for FETCH +STASH := $02AF ; Stash routine in RAM +STAVEC := $02B9 ; Vector patch location for STASH +IRQInd := $02FD ; JMP $0000 -- used as indirect IRQ vector +PALFLAG := $0A03 ; $FF=PAL, $00=NTSC +INIT_STATUS := $0A04 ; Flags: Reset/Restore initiation status +VM2 := $0A2D ; VIC-IIe shadow for $D018 -- graphics mode +FKEY_LEN := $1000 ; Function key lengths +FKEY_TEXT := $100A ; Function key texts + +KBDREPEAT := $028a +KBDREPEATRATE := $028b +KBDREPEATDELAY := $028c + +; --------------------------------------------------------------------------- +; Vectors + +IRQVec := $0314 +BRKVec := $0316 +NMIVec := $0318 +KeyStoreVec := $033C + +; --------------------------------------------------------------------------- +; I/O: VIC + +VIC := $D000 +VIC_SPR0_X := $D000 +VIC_SPR0_Y := $D001 +VIC_SPR1_X := $D002 +VIC_SPR1_Y := $D003 +VIC_SPR2_X := $D004 +VIC_SPR2_Y := $D005 +VIC_SPR3_X := $D006 +VIC_SPR3_Y := $D007 +VIC_SPR4_X := $D008 +VIC_SPR4_Y := $D009 +VIC_SPR5_X := $D00A +VIC_SPR5_Y := $D00B +VIC_SPR6_X := $D00C +VIC_SPR6_Y := $D00D +VIC_SPR7_X := $D00E +VIC_SPR7_Y := $D00F +VIC_SPR_HI_X := $D010 +VIC_SPR_ENA := $D015 +VIC_SPR_EXP_Y := $D017 +VIC_SPR_EXP_X := $D01D +VIC_SPR_MCOLOR := $D01C +VIC_SPR_BG_PRIO := $D01B + +VIC_SPR_MCOLOR0 := $D025 +VIC_SPR_MCOLOR1 := $D026 + +VIC_SPR0_COLOR := $D027 +VIC_SPR1_COLOR := $D028 +VIC_SPR2_COLOR := $D029 +VIC_SPR3_COLOR := $D02A +VIC_SPR4_COLOR := $D02B +VIC_SPR5_COLOR := $D02C +VIC_SPR6_COLOR := $D02D +VIC_SPR7_COLOR := $D02E + +VIC_CTRL1 := $D011 +VIC_CTRL2 := $D016 + +VIC_HLINE := $D012 + +VIC_LPEN_X := $D013 +VIC_LPEN_Y := $D014 + +VIC_VIDEO_ADR := $D018 + +VIC_IRR := $D019 ; Interrupt request register +VIC_IMR := $D01A ; Interrupt mask register + +VIC_BORDERCOLOR := $D020 +VIC_BG_COLOR0 := $D021 +VIC_BG_COLOR1 := $D022 +VIC_BG_COLOR2 := $D023 +VIC_BG_COLOR3 := $D024 + +; 128 stuff: +VIC_KBD_128 := $D02F ; Extended kbd bits (visible in 64 mode) +VIC_CLK_128 := $D030 ; Clock rate register (visible in 64 mode) + + +; --------------------------------------------------------------------------- +; I/O: SID + +SID := $D400 +SID_S1Lo := $D400 +SID_S1Hi := $D401 +SID_PB1Lo := $D402 +SID_PB1Hi := $D403 +SID_Ctl1 := $D404 +SID_AD1 := $D405 +SID_SUR1 := $D406 + +SID_S2Lo := $D407 +SID_S2Hi := $D408 +SID_PB2Lo := $D409 +SID_PB2Hi := $D40A +SID_Ctl2 := $D40B +SID_AD2 := $D40C +SID_SUR2 := $D40D + +SID_S3Lo := $D40E +SID_S3Hi := $D40F +SID_PB3Lo := $D410 +SID_PB3Hi := $D411 +SID_Ctl3 := $D412 +SID_AD3 := $D413 +SID_SUR3 := $D414 + +SID_FltLo := $D415 +SID_FltHi := $D416 +SID_FltCtl := $D417 +SID_Amp := $D418 +SID_ADConv1 := $D419 +SID_ADConv2 := $D41A +SID_Noise := $D41B +SID_Read3 := $D41C + +; --------------------------------------------------------------------------- +; I/O: VDC (128 only) + +VDC_INDEX := $D600 ; register address port +VDC_DATA := $D601 ; data port + +; Registers +VDC_DATA_HI = 18 ; video RAM address (big endian) +VDC_DATA_LO = 19 +VDC_CSET = 28 +VDC_RAM_RW = 31 ; RAM port + +; --------------------------------------------------------------------------- +; I/O: Complex Interface Adapters + +CIA1 := $DC00 +CIA1_PRA := $DC00 ; Port A +CIA1_PRB := $DC01 ; Port B +CIA1_DDRA := $DC02 ; Data direction register for port A +CIA1_DDRB := $DC03 ; Data direction register for port B +CIA1_TA := $DC04 ; 16-bit timer A +CIA1_TB := $DC06 ; 16-bit timer B +CIA1_TOD10 := $DC08 ; Time-of-day tenths of a second +CIA1_TODSEC := $DC09 ; Time-of-day seconds +CIA1_TODMIN := $DC0A ; Time-of-day minutes +CIA1_TODHR := $DC0B ; Time-of-day hours +CIA1_SDR := $DC0C ; Serial data register +CIA1_ICR := $DC0D ; Interrupt control register +CIA1_CRA := $DC0E ; Control register for timer A +CIA1_CRB := $DC0F ; Control register for timer B + +CIA2 := $DD00 +CIA2_PRA := $DD00 +CIA2_PRB := $DD01 +CIA2_DDRA := $DD02 +CIA2_DDRB := $DD03 +CIA2_TA := $DD04 +CIA2_TB := $DD06 +CIA2_TOD10 := $DD08 +CIA2_TODSEC := $DD09 +CIA2_TODMIN := $DD0A +CIA2_TODHR := $DD0B +CIA2_SDR := $DD0C +CIA2_ICR := $DD0D +CIA2_CRA := $DD0E +CIA2_CRB := $DD0F + +; --------------------------------------------------------------------------- +; I/O: MMU + +MMU_CR := $FF00 +MMU_CFG_CC65 := %00001110 ; Bank 0 with kernal ROM +MMU_CFG_RAM0 := %00111111 ; Bank 0 full RAM +MMU_CFG_RAM1 := %01111111 ; Bank 1 full RAM +MMU_CFG_RAM2 := %10111111 ; Bank 2 full RAM +MMU_CFG_RAM3 := %11111111 ; Bank 3 full RAM +MMU_CFG_IFROM := %01010111 ; Bank 1 with Internal Function RAM/ROM +MMU_CFG_EFROM := %01101011 ; Bank 1 with External Function RAM/ROM + +; --------------------------------------------------------------------------- +; Super CPU + +SCPU_VIC_Bank1 := $D075 +SCPU_Slow := $D07A +SCPU_Fast := $D07B +SCPU_EnableRegs := $D07E +SCPU_DisableRegs:= $D07F +SCPU_Detect := $D0BC diff --git a/cc65/asminc/c16.inc b/cc65/asminc/c16.inc new file mode 100644 index 0000000..d99a3c7 --- /dev/null +++ b/cc65/asminc/c16.inc @@ -0,0 +1,9 @@ +; +; C16 generic definitions. +; +; The C16 and Plus/4 are identical, so just include the Plus/4 include file. + + +.include "plus4.inc" + + diff --git a/cc65/asminc/c64.inc b/cc65/asminc/c64.inc new file mode 100644 index 0000000..d131c78 --- /dev/null +++ b/cc65/asminc/c64.inc @@ -0,0 +1,219 @@ +; +; C64 generic definitions. Stolen from Elite128 +; + + +; --------------------------------------------------------------------------- +; Zero page, Commodore stuff + +VARTAB := $2D ; Pointer to start of BASIC variables +MEMSIZE := $37 ; Pointer to highest BASIC RAM location (+1) +TXTPTR := $7A ; Pointer into BASIC source code +STATUS := $90 ; Kernal I/O completion status +TIME := $A0 ; 60 HZ clock +FNAM_LEN := $B7 ; Length of filename +SECADR := $B9 ; Secondary address +DEVNUM := $BA ; Device number +FNAM := $BB ; Pointer to filename +KEY_COUNT := $C6 ; Number of keys in input buffer +RVS := $C7 ; Reverse flag +CURS_FLAG := $CC ; 1 = cursor off +CURS_BLINK := $CD ; Blink counter +CURS_CHAR := $CE ; Character under the cursor +CURS_STATE := $CF ; Cursor blink state +SCREEN_PTR := $D1 ; Pointer to current char in text screen +CURS_X := $D3 ; Cursor column +CURS_Y := $D6 ; Cursor row +CRAM_PTR := $F3 ; Pointer to current char in color RAM +FREKZP := $FB ; Five unused bytes + +BASIC_BUF := $200 ; Location of command-line +BASIC_BUF_LEN = 89 ; Maximum length of command-line + +CHARCOLOR := $286 +CURS_COLOR := $287 ; Color under the cursor +PALFLAG := $2A6 ; $01 = PAL, $00 = NTSC + +KBDREPEAT := $28a +KBDREPEATRATE := $28b +KBDREPEATDELAY := $28c + +; --------------------------------------------------------------------------- +; Vector and other locations + +IRQVec := $0314 +BRKVec := $0316 +NMIVec := $0318 + +; --------------------------------------------------------------------------- +; Screen size + +XSIZE = 40 +YSIZE = 25 + +; --------------------------------------------------------------------------- +; I/O: VIC + +VIC := $D000 +VIC_SPR0_X := $D000 +VIC_SPR0_Y := $D001 +VIC_SPR1_X := $D002 +VIC_SPR1_Y := $D003 +VIC_SPR2_X := $D004 +VIC_SPR2_Y := $D005 +VIC_SPR3_X := $D006 +VIC_SPR3_Y := $D007 +VIC_SPR4_X := $D008 +VIC_SPR4_Y := $D009 +VIC_SPR5_X := $D00A +VIC_SPR5_Y := $D00B +VIC_SPR6_X := $D00C +VIC_SPR6_Y := $D00D +VIC_SPR7_X := $D00E +VIC_SPR7_Y := $D00F +VIC_SPR_HI_X := $D010 +VIC_SPR_ENA := $D015 +VIC_SPR_EXP_Y := $D017 +VIC_SPR_EXP_X := $D01D +VIC_SPR_MCOLOR := $D01C +VIC_SPR_BG_PRIO := $D01B +VIC_SPR_COLL := $D01E +VIC_SPR_BG_COLL := $D01F + +VIC_SPR_MCOLOR0 := $D025 +VIC_SPR_MCOLOR1 := $D026 + +VIC_SPR0_COLOR := $D027 +VIC_SPR1_COLOR := $D028 +VIC_SPR2_COLOR := $D029 +VIC_SPR3_COLOR := $D02A +VIC_SPR4_COLOR := $D02B +VIC_SPR5_COLOR := $D02C +VIC_SPR6_COLOR := $D02D +VIC_SPR7_COLOR := $D02E + +VIC_CTRL1 := $D011 +VIC_CTRL2 := $D016 + +VIC_HLINE := $D012 + +VIC_LPEN_X := $D013 +VIC_LPEN_Y := $D014 + +VIC_VIDEO_ADR := $D018 + +VIC_IRR := $D019 ; Interrupt request register +VIC_IMR := $D01A ; Interrupt mask register + +VIC_BORDERCOLOR := $D020 +VIC_BG_COLOR0 := $D021 +VIC_BG_COLOR1 := $D022 +VIC_BG_COLOR2 := $D023 +VIC_BG_COLOR3 := $D024 + +; 128 stuff: +VIC_KBD_128 := $D02F ; Extended kbd bits (visible in 64 mode) +VIC_CLK_128 := $D030 ; Clock rate register (visible in 64 mode) + + +; --------------------------------------------------------------------------- +; I/O: SID + +SID := $D400 +SID_S1Lo := $D400 +SID_S1Hi := $D401 +SID_PB1Lo := $D402 +SID_PB1Hi := $D403 +SID_Ctl1 := $D404 +SID_AD1 := $D405 +SID_SUR1 := $D406 + +SID_S2Lo := $D407 +SID_S2Hi := $D408 +SID_PB2Lo := $D409 +SID_PB2Hi := $D40A +SID_Ctl2 := $D40B +SID_AD2 := $D40C +SID_SUR2 := $D40D + +SID_S3Lo := $D40E +SID_S3Hi := $D40F +SID_PB3Lo := $D410 +SID_PB3Hi := $D411 +SID_Ctl3 := $D412 +SID_AD3 := $D413 +SID_SUR3 := $D414 + +SID_FltLo := $D415 +SID_FltHi := $D416 +SID_FltCtl := $D417 +SID_Amp := $D418 +SID_ADConv1 := $D419 +SID_ADConv2 := $D41A +SID_Noise := $D41B +SID_Read3 := $D41C + +; --------------------------------------------------------------------------- +; I/O: VDC (128 only) + +VDC_INDEX := $D600 +VDC_DATA := $D601 + +; --------------------------------------------------------------------------- +; I/O: Complex Interface Adapters + +CIA1 := $DC00 +CIA1_PRA := $DC00 ; Port A +CIA1_PRB := $DC01 ; Port B +CIA1_DDRA := $DC02 ; Data direction register for port A +CIA1_DDRB := $DC03 ; Data direction register for port B +CIA1_TA := $DC04 ; 16-bit timer A +CIA1_TB := $DC06 ; 16-bit timer B +CIA1_TOD10 := $DC08 ; Time-of-day tenths of a second +CIA1_TODSEC := $DC09 ; Time-of-day seconds +CIA1_TODMIN := $DC0A ; Time-of-day minutes +CIA1_TODHR := $DC0B ; Time-of-day hours +CIA1_SDR := $DC0C ; Serial data register +CIA1_ICR := $DC0D ; Interrupt control register +CIA1_CRA := $DC0E ; Control register for timer A +CIA1_CRB := $DC0F ; Control register for timer B + +CIA2 := $DD00 +CIA2_PRA := $DD00 +CIA2_PRB := $DD01 +CIA2_DDRA := $DD02 +CIA2_DDRB := $DD03 +CIA2_TA := $DD04 +CIA2_TB := $DD06 +CIA2_TOD10 := $DD08 +CIA2_TODSEC := $DD09 +CIA2_TODMIN := $DD0A +CIA2_TODHR := $DD0B +CIA2_SDR := $DD0C +CIA2_ICR := $DD0D +CIA2_CRA := $DD0E +CIA2_CRB := $DD0F + +; --------------------------------------------------------------------------- +; Super CPU + +SCPU_VIC_Bank1 := $D075 +SCPU_Slow := $D07A +SCPU_Fast := $D07B +SCPU_EnableRegs := $D07E +SCPU_DisableRegs:= $D07F +SCPU_Detect := $D0BC + + +; --------------------------------------------------------------------------- +; Processor Port at $01 + +LORAM = $01 ; Enable the basic rom +HIRAM = $02 ; Enable the kernal rom +IOEN = $04 ; Enable I/O +CASSDATA = $08 ; Cassette data +CASSPLAY = $10 ; Cassette: Play +CASSMOT = $20 ; Cassette motor on +TP_FAST = $80 ; Switch Rossmoeller TurboProcess to fast mode + +RAMONLY = $F8 ; (~(LORAM | HIRAM | IOEN)) & $FF diff --git a/cc65/asminc/c65.inc b/cc65/asminc/c65.inc new file mode 100644 index 0000000..ff3572f --- /dev/null +++ b/cc65/asminc/c65.inc @@ -0,0 +1,239 @@ + +; --------------------------------------------------------------------------- +; Zero page, Commodore stuff + +TXTPTR := $3C ; Pointer into BASIC source code +STATUS := $90 ; Kernal I/O completion status +FNAM_LEN := $B7 ; Length of filename +SECADR := $B9 ; Secondary address +DEVNUM := $BA ; Device number +FNAM := $BB ; Address of filename +FNAM_BANK := $BE ; Bank for filename +KEY_COUNT := $D0 ; Number of keys in input buffer +FKEY_COUNT := $D1 ; Characters for function key +MODE := $D7 ; 40-/80-column mode (bit 7: 80 columns) +GRAPHM := $D8 ; Graphics mode flags (bits 5-7) +CHARDIS := $D9 ; Bit 2 shadow for location $01 +CURS_X := $EC ; Cursor column +CURS_Y := $EB ; Cursor row +SCREEN_PTR := $E0 ; Pointer to current char in text screen +CRAM_PTR := $E2 ; Pointer to current char in color RAM +CHARCOLOR := $F1 +RVS := $F3 ; Reverse output flag +SCROLL := $F8 ; Disable scrolling flag + +BASIC_BUF := $0200 ; Location of command-line +BASIC_BUF_LEN = 161 ; Maximum length of command-line + +FKEY_LEN := $1000 ; Function key lengths +FKEY_TEXT := $100A ; Function key texts + +PALFLAG := $1103 ; $FF=PAL, $00=NTSC +INIT_STATUS := $1104 ; Flags: Reset/Restore initiation status +TIME := $110C ; 60HZ clock + +KBDREPEAT := $111a +KBDREPEATRATE := $111b +KBDREPEATDELAY := $111c + +; --------------------------------------------------------------------------- +; Vectors + +IRQVec := $0314 +BRKVec := $0316 +NMIVec := $0318 + +; --------------------------------------------------------------------------- +; I/O: VIC + +VIC := $D000 +VIC_SPR0_X := $D000 +VIC_SPR0_Y := $D001 +VIC_SPR1_X := $D002 +VIC_SPR1_Y := $D003 +VIC_SPR2_X := $D004 +VIC_SPR2_Y := $D005 +VIC_SPR3_X := $D006 +VIC_SPR3_Y := $D007 +VIC_SPR4_X := $D008 +VIC_SPR4_Y := $D009 +VIC_SPR5_X := $D00A +VIC_SPR5_Y := $D00B +VIC_SPR6_X := $D00C +VIC_SPR6_Y := $D00D +VIC_SPR7_X := $D00E +VIC_SPR7_Y := $D00F +VIC_SPR_HI_X := $D010 +VIC_SPR_ENA := $D015 +VIC_SPR_EXP_Y := $D017 +VIC_SPR_EXP_X := $D01D +VIC_SPR_MCOLOR := $D01C +VIC_SPR_BG_PRIO := $D01B +VIC_SPR_COLL := $D01E +VIC_SPR_BG_COLL := $D01F + +VIC_SPR_MCOLOR0 := $D025 +VIC_SPR_MCOLOR1 := $D026 + +VIC_SPR0_COLOR := $D027 +VIC_SPR1_COLOR := $D028 +VIC_SPR2_COLOR := $D029 +VIC_SPR3_COLOR := $D02A +VIC_SPR4_COLOR := $D02B +VIC_SPR5_COLOR := $D02C +VIC_SPR6_COLOR := $D02D +VIC_SPR7_COLOR := $D02E + +VIC_CTRL1 := $D011 +VIC_CTRL2 := $D016 + +VIC_HLINE := $D012 + +VIC_LPEN_X := $D013 +VIC_LPEN_Y := $D014 + +VIC_VIDEO_ADR := $D018 + +VIC_IRR := $D019 ; Interrupt request register +VIC_IMR := $D01A ; Interrupt mask register + +VIC_BORDERCOLOR := $D020 +VIC_BG_COLOR0 := $D021 +VIC_BG_COLOR1 := $D022 +VIC_BG_COLOR2 := $D023 +VIC_BG_COLOR3 := $D024 + + +; --------------------------------------------------------------------------- +; I/O: FDC + +FDC := $D080 + +; --------------------------------------------------------------------------- +; I/O: SID + +SID1 := $D400 +SID1_S1Lo := $D400 +SID1_S1Hi := $D401 +SID1_PB1Lo := $D402 +SID1_PB1Hi := $D403 +SID1_Ctl1 := $D404 +SID1_AD1 := $D405 +SID1_SUR1 := $D406 + +SID1_S2Lo := $D407 +SID1_S2Hi := $D408 +SID1_PB2Lo := $D409 +SID1_PB2Hi := $D40A +SID1_Ctl2 := $D40B +SID1_AD2 := $D40C +SID1_SUR2 := $D40D + +SID1_S3Lo := $D40E +SID1_S3Hi := $D40F +SID1_PB3Lo := $D410 +SID1_PB3Hi := $D411 +SID1_Ctl3 := $D412 +SID1_AD3 := $D413 +SID1_SUR3 := $D414 + +SID1_FltLo := $D415 +SID1_FltHi := $D416 +SID1_FltCtl := $D417 +SID1_Amp := $D418 +SID1_ADConv1 := $D419 +SID1_ADConv2 := $D41A +SID1_Noise := $D41B +SID1_Read3 := $D41C + +SID2 := $D420 +SID2_S1Lo := $D420 +SID2_S1Hi := $D421 +SID2_PB1Lo := $D422 +SID2_PB1Hi := $D423 +SID2_Ctl1 := $D424 +SID2_AD1 := $D425 +SID2_SUR1 := $D426 + +SID2_S2Lo := $D427 +SID2_S2Hi := $D428 +SID2_PB2Lo := $D429 +SID2_PB2Hi := $D42A +SID2_Ctl2 := $D42B +SID2_AD2 := $D42C +SID2_SUR2 := $D42D + +SID2_S3Lo := $D42E +SID2_S3Hi := $D42F +SID2_PB3Lo := $D430 +SID2_PB3Hi := $D431 +SID2_Ctl3 := $D432 +SID2_AD3 := $D433 +SID2_SUR3 := $D434 + +SID2_FltLo := $D435 +SID2_FltHi := $D436 +SID2_FltCtl := $D437 +SID2_Amp := $D438 +SID2_ADConv1 := $D439 +SID2_ADConv2 := $D43A +SID2_Noise := $D43B +SID2_Read3 := $D43C + +; --------------------------------------------------------------------------- +; I/O: Complex Interface Adapters + +CIA1 := $DC00 +CIA1_PRA := $DC00 ; Port A +CIA1_PRB := $DC01 ; Port B +CIA1_DDRA := $DC02 ; Data direction register for port A +CIA1_DDRB := $DC03 ; Data direction register for port B +CIA1_TA := $DC04 ; 16-bit timer A +CIA1_TB := $DC06 ; 16-bit timer B +CIA1_TOD10 := $DC08 ; Time-of-day tenths of a second +CIA1_TODSEC := $DC09 ; Time-of-day seconds +CIA1_TODMIN := $DC0A ; Time-of-day minutes +CIA1_TODHR := $DC0B ; Time-of-day hours +CIA1_SDR := $DC0C ; Serial data register +CIA1_ICR := $DC0D ; Interrupt control register +CIA1_CRA := $DC0E ; Control register for timer A +CIA1_CRB := $DC0F ; Control register for timer B + +CIA2 := $DD00 +CIA2_PRA := $DD00 +CIA2_PRB := $DD01 +CIA2_DDRA := $DD02 +CIA2_DDRB := $DD03 +CIA2_TA := $DD04 +CIA2_TB := $DD06 +CIA2_TOD10 := $DD08 +CIA2_TODSEC := $DD09 +CIA2_TODMIN := $DD0A +CIA2_TODHR := $DD0B +CIA2_SDR := $DD0C +CIA2_ICR := $DD0D +CIA2_CRA := $DD0E +CIA2_CRB := $DD0F + +; --------------------------------------------------------------------------- +; I/O: DMA + +DMA := $D700 + + +; --------------------------------------------------------------------------- +; Processor Port at $01 + +LORAM = $01 ; Enable the basic rom +HIRAM = $02 ; Enable the kernal rom +IOEN = $04 ; Enable I/O +CASSDATA = $08 ; Cassette data +CASSPLAY = $10 ; Cassette: Play +CASSMOT = $20 ; Cassette motor on +TP_FAST = $80 ; Switch Rossmoeller TurboProcess to fast mode + +RAMONLY = $F8 ; (~(LORAM | HIRAM | IOEN)) & $FF + +; temporary, to get conio working +XSIZE = 80 +YSIZE = 50 diff --git a/cc65/asminc/cbm.mac b/cc65/asminc/cbm.mac new file mode 100644 index 0000000..5c542b2 --- /dev/null +++ b/cc65/asminc/cbm.mac @@ -0,0 +1,56 @@ +; Convert characters to screen codes + +; Macro that converts one character. +; scrbyte() can be used as an instruction operand +.define scrbyte(code) (<(.strat ("h@dbdlhh", code >> 5) << 4) ^ code) + +; Helper macro that stores one character +.macro _scrcode char + .if (char < 256) + .byte scrbyte {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 + + ; Check for an identifier + .elseif .match (.left (1, {arg1}), identifier) + + ; Just output the identifier + _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/cc65/asminc/cbm510.inc b/cc65/asminc/cbm510.inc new file mode 100644 index 0000000..627ba49 --- /dev/null +++ b/cc65/asminc/cbm510.inc @@ -0,0 +1,200 @@ +; +; Zero page variables and I/O definitions for the CBM 510 +; +; Taken from a kernal disassembly done by myself in 2000/2001. +; +; 2001-09-13, Ullrich von Bassewitz +; 2014-04-02, Greg King + + +;----------------------------------------------------------------------------- +; Zeropage stuff + +ExecReg := $00 ; Controls execution memory bank +IndReg := $01 ; Controls indirect indexed load-store bank + +TXTPTR := $85 ; Far pointer into BASIC source code +FNAM := $90 ; Far pointer to LOAD/SAVE file-name +FNAM_SEG := $92 +STATUS := $9C ; Kernal I/O completion status +FNAM_LEN := $9D ; Holds length of file-name + +; --------------------------------------------------------------------------- +; Screen size + +XSIZE = 40 +YSIZE = 25 + +;----------------------------------------------------------------------------- +; I/O Definitions +; Note: These numbers aren't addresses. They are offsets from the start of +; each chip's register set. They are used in the indirect indexed addressing +; mode. + +; I/O $d800: VIC-II + +VIC_SPR0_X = $00 +VIC_SPR0_Y = $01 +VIC_SPR1_X = $02 +VIC_SPR1_Y = $03 +VIC_SPR2_X = $04 +VIC_SPR2_Y = $05 +VIC_SPR3_X = $06 +VIC_SPR3_Y = $07 +VIC_SPR4_X = $08 +VIC_SPR4_Y = $09 +VIC_SPR5_X = $0A +VIC_SPR5_Y = $0B +VIC_SPR6_X = $0C +VIC_SPR6_Y = $0D +VIC_SPR7_X = $0E +VIC_SPR7_Y = $0F +VIC_SPR_HI_X = $10 +VIC_SPR_ENA = $15 +VIC_SPR_EXP_Y = $17 +VIC_SPR_EXP_X = $1D +VIC_SPR_MCOLOR = $1C +VIC_SPR_BG_PRIO = $1B + +VIC_SPR_MCOLOR0 = $25 +VIC_SPR_MCOLOR1 = $26 + +VIC_SPR0_COLOR = $27 +VIC_SPR1_COLOR = $28 +VIC_SPR2_COLOR = $29 +VIC_SPR3_COLOR = $2A +VIC_SPR4_COLOR = $2B +VIC_SPR5_COLOR = $2C +VIC_SPR6_COLOR = $2D +VIC_SPR7_COLOR = $2E + +VIC_CTRL1 = $11 +VIC_CTRL2 = $16 + +VIC_HLINE = $12 + +VIC_LPEN_X = $13 +VIC_LPEN_Y = $14 + +VIC_VIDEO_ADR = $18 + +VIC_IRR = $19 ; Interrupt request register +VIC_IMR = $1A ; Interrupt mask register + +VIC_BORDERCOLOR = $20 +VIC_BG_COLOR0 = $21 +VIC_BG_COLOR1 = $22 +VIC_BG_COLOR2 = $23 +VIC_BG_COLOR3 = $24 + + +; I/O $da00: SID 6581 + +SID_S1Lo = $00 +SID_S1Hi = $01 +SID_PB1Lo = $02 +SID_PB1Hi = $03 +SID_Ctl1 = $04 +SID_AD1 = $05 +SID_SUR1 = $06 + +SID_S2Lo = $07 +SID_S2Hi = $08 +SID_PB2Lo = $09 +SID_PB2Hi = $0A +SID_Ctl2 = $0B +SID_AD2 = $0C +SID_SUR2 = $0D + +SID_S3Lo = $0E +SID_S3Hi = $0F +SID_PB3Lo = $10 +SID_PB3Hi = $11 +SID_Ctl3 = $12 +SID_AD3 = $13 +SID_SUR3 = $14 + +SID_FltLo = $15 +SID_FltHi = $16 +SID_FltCtl = $17 +SID_Amp = $18 +SID_ADConv1 = $19 +SID_ADConv2 = $1A +SID_Noise = $1B +SID_Read3 = $1C + + +; I/O $db00: CIA 6526, Inter Process Communication +; I/O $dc00: CIA 6526 + +.struct CIA + PRA .byte + PRB .byte + DDRA .byte + DDRB .byte + .union + .struct + TALO .byte + TAHI .byte + .endstruct + TA .word + .endunion + .union + .struct + TBLO .byte + TBHI .byte + .endstruct + TB .word + .endunion + TOD10 .byte + TODSEC .byte + TODMIN .byte + TODHR .byte + SDR .byte + ICR .byte + CRA .byte + CRB .byte +.endstruct + + +; I/O $dd00: ACIA 6551 + +.struct ACIA + DATA .byte + STATUS .byte + CMD .byte + CTRL .BYTE +.endstruct + + +; I/O $de00: Triport #1 6525 +; I/O $df00: Triport #2 6525 + +.struct TPI + PRA .byte + PRB .byte + .union + PRC .byte + INT .byte + .endunion + DDRA .byte + DDRB .byte + .union + DDRC .byte + IMR .byte + .endunion + CR .byte + AIR .byte +.endstruct + + +;----------------------------------------------------------------------------- +; Our video memory address + +COLOR_RAM := $D400 ; System bank + + +;----------------------------------------------------------------------------- + +BASIC_BUF := $FB5E ; Bank 0 location of command-line +BASIC_BUF_LEN = 162 ; Maximum length of command-line diff --git a/cc65/asminc/cbm610.inc b/cc65/asminc/cbm610.inc new file mode 100644 index 0000000..b031b2e --- /dev/null +++ b/cc65/asminc/cbm610.inc @@ -0,0 +1,121 @@ +; +; Zero page variables and I/O definitions for the CBM 610 +; +; Taken from a kernal disassembly done by myself in 1987. +; +; 1998-09-28, Ullrich von Bassewitz +; 2014-04-02, Greg King + + +; --------------------------------------------------------------------------- +; Zeropage stuff + +ExecReg := $00 ; Controls execution memory bank +IndReg := $01 ; Controls indirect indexed load-store bank + +TXTPTR := $85 ; Far pointer into BASIC source code +FNAM := $90 ; Far pointer to LOAD/SAVE file-name +FNAM_SEG := $92 +STATUS := $9C ; Kernal I/O completion status +FNAM_LEN := $9D ; Holds length of file-name + +; --------------------------------------------------------------------------- +; Screen size + +XSIZE = 80 +YSIZE = 25 + +; --------------------------------------------------------------------------- +; I/O definitions + + +; I/O $d800: CRTC 6545 + +.struct CRTC + ADDR .byte + DATA .byte +.endstruct + + +; I/O $db00: CIA 6526, Inter Process Communication +; +; IPCcia = $db00 + +.struct CIA + PRA .byte + PRB .byte + DDRA .byte + DDRB .byte + .union + .struct + TALO .byte + TAHI .byte + .endstruct + TA .word + .endunion + .union + .struct + TBLO .byte + TBHI .byte + .endstruct + TB .word + .endunion + TOD10 .byte + TODSEC .byte + TODMIN .byte + TODHR .byte + SDR .byte + ICR .byte + CRA .byte + CRB .byte +.endstruct + + +; I/O $dc00: CIA 6526 +; +; cia = $dc00 + + +; I/O $dd00: ACIA 6551 +; +; acia = $dd00 + +.struct ACIA + DATA .byte + STATUS .byte + CMD .byte + CTRL .BYTE +.endstruct + + +; I/O $de00: Triport #1 6525 +; +; tpi1 = $de00 + +.struct TPI + PRA .byte + PRB .byte + .union + PRC .byte + INT .byte + .endunion + DDRA .byte + DDRB .byte + .union + DDRC .byte + IMR .byte + .endunion + CR .byte + AIR .byte +.endstruct + + +; I/O $df00: Triport #2 6525 + +; tpi2 = $df00 + + +;----------------------------------------------------------------------------- + +BASIC_BUF := $FA5E ; Bank 1 location of command-line +BASIC_BUF_LEN = 162 ; Maximum length of command-line diff --git a/cc65/asminc/cbm_filetype.inc b/cc65/asminc/cbm_filetype.inc new file mode 100644 index 0000000..9e9ba24 --- /dev/null +++ b/cc65/asminc/cbm_filetype.inc @@ -0,0 +1,34 @@ +; +; Definitions for CBM file types. From cbm.h +; +; Ullrich von Bassewitz, 2012-06-03 +; + +; Define bitmapped constants for the table entries + +.enum + CBM_T_REG = $10 ; Bit set for regular files + CBM_T_SEQ = $10 ; Sequential file + CBM_T_PRG = $11 ; Program file + CBM_T_USR = $12 ; User file + CBM_T_REL = $13 ; Relative file + CBM_T_VRP = $14 ; Vorpal fast-loadable format + CBM_T_DEL = $00 ; Deleted file + CBM_T_CBM = $01 ; 1581 sub-partition + CBM_T_DIR = $02 ; IDE64 and CMD sub-directory + CBM_T_LNK = $03 ; IDE64 soft-link + CBM_T_OTHER = $04 ; File-type not recognized + CBM_T_HEADER = $05 ; Disk header / title +.endenum + + +; The following function maps the start character for a file type to +; one of the file types above. Note: 'd' will always mapped to CBM_T_DEL. +; The calling function has to look at the following character to determine +; if the file type is actually CBM_T_DIR. +; +; unsigned char __fastcall__ _cbm_filetype (unsigned char c); + + .global __cbm_filetype + + diff --git a/cc65/asminc/cbm_kernal.inc b/cc65/asminc/cbm_kernal.inc new file mode 100644 index 0000000..f06483a --- /dev/null +++ b/cc65/asminc/cbm_kernal.inc @@ -0,0 +1,248 @@ +; +; Olli Savia +; Greg King +; +; Commodore-compatibles Kernal functions +; + +.if .def(__CX16__) + ; CX16 extended jump table + KBDBUF_PEEK := $FEBD + KBDBUF_GET_MODIFIERS := $FEC0 + KBDBUF_PUT := $FEC3 + I2C_READ_BYTE := $FEC6 + I2C_WRITE_BYTE := $FEC9 + CX_MONITOR := $FECC + ENTROPY_GET := $FECF + CONSOLE_SET_PAGE_MSG := $FED5 + CONSOLE_PUT_IMAGE := $FED8 + CONSOLE_INIT := $FEDB + CONSOLE_PUT_CHAR := $FEDE + CONSOLE_GET_CHAR := $FEE1 + MEMORY_FILL := $FEE4 + MEMORY_COPY := $FEE7 + MEMORY_CRC := $FEEA + MEMORY_DECOMPRESS := $FEED + SPRITE_SET_IMAGE := $FEF0 + SPRITE_SET_POSITION := $FEF3 + FB_INIT := $FEF6 + FB_GET_INFO := $FEF9 + FB_SET_PALETTE := $FEFC + FB_CURSOR_POSITION := $FEFF + FB_CURSOR_NEXT_LINE := $FF02 + FB_GET_PIXEL := $FF05 + FB_GET_PIXELS := $FF08 + FB_SET_PIXEL := $FF0B + FB_SET_PIXELS := $FF0E + FB_SET_8_PIXELS := $FF11 + FB_SET_8_PIXELS_OPAQUE := $FF14 + FB_FILL_PIXELS := $FF17 + FB_FILTER_PIXELS := $FF1A + FB_MOVE_PIXELS := $FF1D + GRAPH_INIT := $FF20 + GRAPH_CLEAR := $FF23 + GRAPH_SET_WINDOW := $FF26 + GRAPH_SET_COLORS := $FF29 + GRAPH_DRAW_LINE := $FF2C + GRAPH_DRAW_RECT := $FF2F + GRAPH_MOVE_RECT := $FF32 + GRAPH_DRAW_OVAL := $FF35 + GRAPH_DRAW_IMAGE := $FF38 + GRAPH_SET_FONT := $FF3B + GRAPH_GET_CHAR_SIZE := $FF3E + GRAPH_PUT_CHAR := $FF41 + MULTI_ACPTR := $FF44 + RESTORE_BASIC := $FF47 + CLOCK_SET_DATE_TIME := $FF4D + CLOCK_GET_DATE_TIME := $FF50 + JOYSTICK_SCAN := $FF53 + JOYSTICK_GET := $FF56 + SCREEN_MODE := $FF5F + SCREEN_SET_CHARSET := $FF62 + MOUSE_CONFIG := $FF68 + MOUSE_GET := $FF6B +.endif + +.if .def (__MEGA65__) + ; extended C65 jump table + +; memory before $ff3b is all $ff in mega65 ROM? +; VERSIONQ := $FF2F +; RESET_RUN := $FF32 +; CURSOR := $FF35 + + SAVEFL := $FF3B + GETIO := $FF41 + GETLFS := $FF44 + KEYLOCKS := $FF47 + ADDKEY := $FF4A +.endif + +.if .def(__C65__) || .def (__MEGA65__) + CURSOR := $E030 ; in editor ROM + + SPIN_SPOUT := $FF4D + CLSALL := $FF50 + C64MODE := $FF53 + MonitorCall := $FF56 + BOOT_SYS := $FF59 + PHOENIX := $FF5C + LKUPLA := $FF5F + LKUPSA := $FF62 + SWAPPER := $FF65 + PFKEY := $FF68 + SETBNK := $FF6B + JSRFAR := $FF6E + JMPFAR := $FF71 + LDA_FAR := $FF74 + STA_FAR := $FF77 + CMP_FAR := $FF7A + PRIMM := $FF7D +.endif + +.if .def(__C128__) + ; C128 extended jump table + C64MODE := $FF4D + SWAPPER := $FF5F + SETBNK := $FF68 +.endif + +.if .def(__C128__) || .def(__CX16__) + ; Extended jump table + CLSALL := $FF4A + LKUPLA := $FF59 + LKUPSA := $FF5C + PFKEY := $FF65 + JSRFAR := $FF6E + INDFET := $FF74 + INDSTA := $FF77 + INDCMP := $FF7A + PRIMM := $FF7D +.endif + +.if .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__) || .def(__C65__) || .def (__MEGA65__) + CINT := $FF81 + IOINIT := $FF84 + RAMTAS := $FF87 +.elseif .def(__VIC20__) + CINT := $E518 ; No entries are in the Kernal jump table of the VIC-20 for these three (3) functions. + IOINIT := $FDF9 ; The entries for these functions have been set to point directly to the functions + RAMTAS := $FD8D ; in the Kernal, to maintain compatibility with the other Commodore platforms. +.elseif .def(__CBM510__) || .def(__CBM610__) + IOINIT := $FF7B + CINT := $FF7E +.endif + +.if .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__) || .def(__C65__) || .def (__MEGA65__) + RESTOR := $FF8A + VECTOR := $FF8D +.elseif .def(__CBM510__) || .def(__CBM610__) + VECTOR := $FF84 + RESTOR := $FF87 +.endif + +.if .def(__CBM510__) || .def(__CBM610__) || .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__) + SETMSG := $FF90 + SECOND := $FF93 + TKSA := $FF96 + MEMTOP := $FF99 + MEMBOT := $FF9C + SCNKEY := $FF9F + SETTMO := $FFA2 +.elseif .def(__C65__) || .def (__MEGA65__) + SETMSG := $FF90 + SECOND := $FF93 + TKSA := $FF96 + MEMTOP := $FF99 + MEMBOT := $FF9C + SCNKEY := $FF9F + MONEXIT := $FFA2 +.endif + +.if .def(__CBM510__) || .def(__CBM610__) || .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__) || .def(__C65__) || .def(__MEGA65__) + ACPTR := $FFA5 + CIOUT := $FFA8 + UNTLK := $FFAB + UNLSN := $FFAE + LISTEN := $FFB1 + TALK := $FFB4 + READST := $FFB7 + SETLFS := $FFBA + SETNAM := $FFBD + OPEN := $FFC0 + CLOSE := $FFC3 +.endif + +; Available on all platforms including PET +CHKIN := $FFC6 +CKOUT := $FFC9 +CHKOUT := $FFC9 +CLRCH := $FFCC +CLRCHN := $FFCC +BASIN := $FFCF +CHRIN := $FFCF +BSOUT := $FFD2 +CHROUT := $FFD2 + +.if .def(__CBM510__) || .def(__CBM610__) || .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__) || .def(__C65__) || .def(__MEGA65__) + LOAD := $FFD5 + SAVE := $FFD8 + SETTIM := $FFDB + RDTIM := $FFDE +.endif + +; Available on all platforms including PET +STOP := $FFE1 +GETIN := $FFE4 +CLALL := $FFE7 + +.if .def(__C65__) || .def(__MEGA65__) +ScanStopKey := $FFEA +.else +UDTIM := $FFEA +.endif + +.if .def(__CBM510__) || .def(__CBM610__) || .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__) || .def(__C65__) || .def(__MEGA65__) + SCREEN := $FFED + PLOT := $FFF0 + IOBASE := $FFF3 +.endif + +; --------------------------------------------------------------------------- +; Kernal routines, direct entries +; +; Unlike the above, these are not standard functions with entries in the jump +; table. They do not exist in all Kernals, and where they do the entry point is +; specific to that particular machine and possibly even Kernal version. +; +; This list is not comprehensive: missing items for particular machines +; should be added as needed. +; +; UPDCRAMPTR: Updates the color RAM pointer to match the screen RAM pointer. +; + +.if .def(__VIC20__) + CLRSCR := $E55F + KBDREAD := $E5CF + UPDCRAMPTR := $EAB2 +.elseif .def(__C64__) + CLRSCR := $E544 ; Clear the screen + KBDREAD := $E5B4 ; Get Character From Keyboard Buffer + NMIEXIT := $FEBC + UPDCRAMPTR := $EA24 ; Update color ram pointer +.elseif .def(__C128__) + CLRSCR := $C142 + KBDREAD := $C006 + NMIEXIT := $FF33 + NEWLINE := $C363 + PRINT := $C322 + CURS_SET := $CD57 + CURS_ON := $CD6F + CURS_OFF := $CD9F +.elseif .def(__C16__) + CLRSCR := $D88B + KBDREAD := $D8C1 +.elseif .def(__C65__) || .def(__MEGA65__) +; CLRSCR := $E0EC ; ??? + KBDREAD := $E006 +.endif diff --git a/cc65/asminc/cbm_petscii_charmap.inc b/cc65/asminc/cbm_petscii_charmap.inc new file mode 100644 index 0000000..525bffb --- /dev/null +++ b/cc65/asminc/cbm_petscii_charmap.inc @@ -0,0 +1,291 @@ +;/*****************************************************************************/ +;/* */ +;/* cbm_petscii_charmap.inc */ +;/* */ +;/* CBM system standard string mapping ISO-8859-1 -> PetSCII */ +;/* */ +;/* */ +;/* 2019-03-10, Greg King */ +;/* */ +;/* 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 must not be removed or altered from any source */ +;/* distribution. */ +;/* */ +;/*****************************************************************************/ + +.charmap $00, $00 +.charmap $01, $01 +.charmap $02, $02 +.charmap $03, $03 +.charmap $04, $04 +.charmap $05, $05 +.charmap $06, $06 +.charmap $07, $07 +.charmap $08, $14 +.charmap $09, $09 +.charmap $0A, $0D +.charmap $0B, $11 +.charmap $0C, $93 +.charmap $0D, $0A +.charmap $0E, $0E +.charmap $0F, $0F +.charmap $10, $10 +.charmap $11, $0B +.charmap $12, $12 +.charmap $13, $13 +.charmap $14, $08 +.charmap $15, $15 +.charmap $16, $16 +.charmap $17, $17 +.charmap $18, $18 +.charmap $19, $19 +.charmap $1A, $1A +.charmap $1B, $1B +.charmap $1C, $1C +.charmap $1D, $1D +.charmap $1E, $1E +.charmap $1F, $1F + +.charmap $20, $20 +.charmap $21, $21 +.charmap $22, $22 +.charmap $23, $23 +.charmap $24, $24 +.charmap $25, $25 +.charmap $26, $26 +.charmap $27, $27 +.charmap $28, $28 +.charmap $29, $29 +.charmap $2A, $2A +.charmap $2B, $2B +.charmap $2C, $2C +.charmap $2D, $2D +.charmap $2E, $2E +.charmap $2F, $2F +.charmap $30, $30 +.charmap $31, $31 +.charmap $32, $32 +.charmap $33, $33 +.charmap $34, $34 +.charmap $35, $35 +.charmap $36, $36 +.charmap $37, $37 +.charmap $38, $38 +.charmap $39, $39 +.charmap $3A, $3A +.charmap $3B, $3B +.charmap $3C, $3C +.charmap $3D, $3D +.charmap $3E, $3E +.charmap $3F, $3F + +.charmap $40, $40 +.charmap $41, $C1 +.charmap $42, $C2 +.charmap $43, $C3 +.charmap $44, $C4 +.charmap $45, $C5 +.charmap $46, $C6 +.charmap $47, $C7 +.charmap $48, $C8 +.charmap $49, $C9 +.charmap $4A, $CA +.charmap $4B, $CB +.charmap $4C, $CC +.charmap $4D, $CD +.charmap $4E, $CE +.charmap $4F, $CF +.charmap $50, $D0 +.charmap $51, $D1 +.charmap $52, $D2 +.charmap $53, $D3 +.charmap $54, $D4 +.charmap $55, $D5 +.charmap $56, $D6 +.charmap $57, $D7 +.charmap $58, $D8 +.charmap $59, $D9 +.charmap $5A, $DA +.charmap $5B, $5B +.charmap $5C, $BF +.charmap $5D, $5D +.charmap $5E, $5E +.charmap $5F, $A4 + +.charmap $60, $AD +.charmap $61, $41 +.charmap $62, $42 +.charmap $63, $43 +.charmap $64, $44 +.charmap $65, $45 +.charmap $66, $46 +.charmap $67, $47 +.charmap $68, $48 +.charmap $69, $49 +.charmap $6A, $4A +.charmap $6B, $4B +.charmap $6C, $4C +.charmap $6D, $4D +.charmap $6E, $4E +.charmap $6F, $4F +.charmap $70, $50 +.charmap $71, $51 +.charmap $72, $52 +.charmap $73, $53 +.charmap $74, $54 +.charmap $75, $55 +.charmap $76, $56 +.charmap $77, $57 +.charmap $78, $58 +.charmap $79, $59 +.charmap $7A, $5A +.charmap $7B, $B3 +.charmap $7C, $DD +.charmap $7D, $AB +.charmap $7E, $B1 +.charmap $7F, $DF + +.charmap $80, $80 +.charmap $81, $81 +.charmap $82, $82 +.charmap $83, $83 +.charmap $84, $84 +.charmap $85, $85 +.charmap $86, $86 +.charmap $87, $87 +.charmap $88, $88 +.charmap $89, $89 +.charmap $8A, $8A +.charmap $8B, $8B +.charmap $8C, $8C +.charmap $8D, $8D +.charmap $8E, $8E +.charmap $8F, $8F +.charmap $90, $90 +.charmap $91, $91 +.charmap $92, $92 +.charmap $93, $0C +.charmap $94, $94 +.charmap $95, $95 +.charmap $96, $96 +.charmap $97, $97 +.charmap $98, $98 +.charmap $99, $99 +.charmap $9A, $9A +.charmap $9B, $9B +.charmap $9C, $9C +.charmap $9D, $9D +.charmap $9E, $9E +.charmap $9F, $9F + +.charmap $A0, $A0 +.charmap $A1, $A1 +.charmap $A2, $A2 +.charmap $A3, $A3 +.charmap $A4, $A4 +.charmap $A5, $A5 +.charmap $A6, $A6 +.charmap $A7, $A7 +.charmap $A8, $A8 +.charmap $A9, $A9 +.charmap $AA, $AA +.charmap $AB, $AB +.charmap $AC, $AC +.charmap $AD, $AD +.charmap $AE, $AE +.charmap $AF, $AF +.charmap $B0, $B0 +.charmap $B1, $B1 +.charmap $B2, $B2 +.charmap $B3, $B3 +.charmap $B4, $B4 +.charmap $B5, $B5 +.charmap $B6, $B6 +.charmap $B7, $B7 +.charmap $B8, $B8 +.charmap $B9, $B9 +.charmap $BA, $BA +.charmap $BB, $BB +.charmap $BC, $BC +.charmap $BD, $BD +.charmap $BE, $BE +.charmap $BF, $BF + +.charmap $C0, $60 +.charmap $C1, $61 +.charmap $C2, $62 +.charmap $C3, $63 +.charmap $C4, $64 +.charmap $C5, $65 +.charmap $C6, $66 +.charmap $C7, $67 +.charmap $C8, $68 +.charmap $C9, $69 +.charmap $CA, $6A +.charmap $CB, $6B +.charmap $CC, $6C +.charmap $CD, $6D +.charmap $CE, $6E +.charmap $CF, $6F +.charmap $D0, $70 +.charmap $D1, $71 +.charmap $D2, $72 +.charmap $D3, $73 +.charmap $D4, $74 +.charmap $D5, $75 +.charmap $D6, $76 +.charmap $D7, $77 +.charmap $D8, $78 +.charmap $D9, $79 +.charmap $DA, $7A +.charmap $DB, $7B +.charmap $DC, $7C +.charmap $DD, $7D +.charmap $DE, $7E +.charmap $DF, $7F + +.charmap $E0, $E0 +.charmap $E1, $E1 +.charmap $E2, $E2 +.charmap $E3, $E3 +.charmap $E4, $E4 +.charmap $E5, $E5 +.charmap $E6, $E6 +.charmap $E7, $E7 +.charmap $E8, $E8 +.charmap $E9, $E9 +.charmap $EA, $EA +.charmap $EB, $EB +.charmap $EC, $EC +.charmap $ED, $ED +.charmap $EE, $EE +.charmap $EF, $EF +.charmap $F0, $F0 +.charmap $F1, $F1 +.charmap $F2, $F2 +.charmap $F3, $F3 +.charmap $F4, $F4 +.charmap $F5, $F5 +.charmap $F6, $F6 +.charmap $F7, $F7 +.charmap $F8, $F8 +.charmap $F9, $F9 +.charmap $FA, $FA +.charmap $FB, $FB +.charmap $FC, $FC +.charmap $FD, $FD +.charmap $FE, $FE +.charmap $FF, $FF diff --git a/cc65/asminc/cbm_screen_charmap.inc b/cc65/asminc/cbm_screen_charmap.inc new file mode 100644 index 0000000..12d0255 --- /dev/null +++ b/cc65/asminc/cbm_screen_charmap.inc @@ -0,0 +1,305 @@ +;/*****************************************************************************/ +;/* */ +;/* cbm_screen_charmap.inc */ +;/* */ +;/* c Copyright 2019, Gerhard W. Gruber (sparhawk@gmx.at) */ +;/* */ +;/* When using CBM mode, this include converts character literals */ +;/* from ASCII to screen-code mapping, so you can write directly */ +;/* to the screen memory. */ +;/* */ +;/* If this include is used, no additional macros are needed. */ +;/* */ +;/*****************************************************************************/ + +; Char $00 -> c + 128 +.charmap $00, $80 + +; Char $01 ... $1A -> c + 128 + 64 control alphabet +.charmap $01, $C1 +.charmap $02, $C2 +.charmap $03, $C3 +.charmap $04, $C4 +.charmap $05, $C5 +.charmap $06, $C6 +.charmap $07, $C7 +.charmap $08, $C8 +.charmap $09, $C9 +.charmap $0A, $CA +.charmap $0B, $CB +.charmap $0C, $CC +.charmap $0D, $CD +.charmap $0E, $CE +.charmap $0F, $CF +.charmap $10, $D0 +.charmap $11, $D1 +.charmap $12, $D2 +.charmap $13, $D3 +.charmap $14, $D4 +.charmap $15, $D5 +.charmap $16, $D6 +.charmap $17, $D7 +.charmap $18, $D8 +.charmap $19, $D9 +.charmap $1A, $DA + +; Char $1B ... $1F -> c + 128 +.charmap $1B, $9B +.charmap $1C, $9C +.charmap $1D, $9D +.charmap $1E, $9E +.charmap $1F, $9F + +; Char $20 ... $3F -> c +.charmap $20, $20 +.charmap $21, $21 +.charmap $22, $22 +.charmap $23, $23 +.charmap $24, $24 +.charmap $25, $25 +.charmap $26, $26 +.charmap $27, $27 +.charmap $28, $28 +.charmap $29, $29 +.charmap $2A, $2A +.charmap $2B, $2B +.charmap $2C, $2C +.charmap $2D, $2D +.charmap $2E, $2E +.charmap $2F, $2F +.charmap $30, $30 +.charmap $31, $31 +.charmap $32, $32 +.charmap $33, $33 +.charmap $34, $34 +.charmap $35, $35 +.charmap $36, $36 +.charmap $37, $37 +.charmap $38, $38 +.charmap $39, $39 +.charmap $3A, $3A +.charmap $3B, $3B +.charmap $3C, $3C +.charmap $3D, $3D +.charmap $3E, $3E +.charmap $3F, $3F + +; Char $40 -> c - 64 +.charmap $40, $00 + +; Char $41 ... $5A -> c upper-case alphabet +.charmap $41, $41 +.charmap $42, $42 +.charmap $43, $43 +.charmap $44, $44 +.charmap $45, $45 +.charmap $46, $46 +.charmap $47, $47 +.charmap $48, $48 +.charmap $49, $49 +.charmap $4A, $4A +.charmap $4B, $4B +.charmap $4C, $4C +.charmap $4D, $4D +.charmap $4E, $4E +.charmap $4F, $4F +.charmap $50, $50 +.charmap $51, $51 +.charmap $52, $52 +.charmap $53, $53 +.charmap $54, $54 +.charmap $55, $55 +.charmap $56, $56 +.charmap $57, $57 +.charmap $58, $58 +.charmap $59, $59 +.charmap $5A, $5A + +; Char $5B ... $5F -> c - 64 +.charmap $5B, $1B +.charmap $5C, $1C +.charmap $5D, $1D +.charmap $5E, $1E +.charmap $5F, $1F + +; Char $60 -> c - 32 +.charmap $60, $40 + +; Char $61 ... $7A -> c - 32 - 64 lower-case alphabet +.charmap $61, $01 +.charmap $62, $02 +.charmap $63, $03 +.charmap $64, $04 +.charmap $65, $05 +.charmap $66, $06 +.charmap $67, $07 +.charmap $68, $08 +.charmap $69, $09 +.charmap $6A, $0A +.charmap $6B, $0B +.charmap $6C, $0C +.charmap $6D, $0D +.charmap $6E, $0E +.charmap $6F, $0F +.charmap $70, $10 +.charmap $71, $11 +.charmap $72, $12 +.charmap $73, $13 +.charmap $74, $14 +.charmap $75, $15 +.charmap $76, $16 +.charmap $77, $17 +.charmap $78, $18 +.charmap $79, $19 +.charmap $7A, $1A + +; Char $7B ... $7F -> c - 32 +.charmap $7B, $5B +.charmap $7C, $5C +.charmap $7D, $5D +.charmap $7E, $5E +.charmap $7F, $5F + +; Char $80 -> c + 64 +.charmap $80, $C0 + +; Char $81 ... $9A -> c control alphabet +.charmap $81, $81 +.charmap $82, $82 +.charmap $83, $83 +.charmap $84, $84 +.charmap $85, $85 +.charmap $86, $86 +.charmap $87, $87 +.charmap $88, $88 +.charmap $89, $89 +.charmap $8A, $8A +.charmap $8B, $8B +.charmap $8C, $8C +.charmap $8D, $8D +.charmap $8E, $8E +.charmap $8F, $8F +.charmap $90, $90 +.charmap $91, $91 +.charmap $92, $92 +.charmap $93, $93 +.charmap $94, $94 +.charmap $95, $95 +.charmap $96, $96 +.charmap $97, $97 +.charmap $98, $98 +.charmap $99, $99 +.charmap $9A, $9A + +; Char $9B ... $9F -> c + 64 +.charmap $9B, $DB +.charmap $9C, $DC +.charmap $9D, $DD +.charmap $9E, $DE +.charmap $9F, $DF + +; Char $A0 ... $BF -> c - 64 +.charmap $A0, $60 +.charmap $A1, $61 +.charmap $A2, $62 +.charmap $A3, $63 +.charmap $A4, $64 +.charmap $A5, $65 +.charmap $A6, $66 +.charmap $A7, $67 +.charmap $A8, $68 +.charmap $A9, $69 +.charmap $AA, $6A +.charmap $AB, $6B +.charmap $AC, $6C +.charmap $AD, $6D +.charmap $AE, $6E +.charmap $AF, $6F +.charmap $B0, $70 +.charmap $B1, $71 +.charmap $B2, $72 +.charmap $B3, $73 +.charmap $B4, $74 +.charmap $B5, $75 +.charmap $B6, $76 +.charmap $B7, $77 +.charmap $B8, $78 +.charmap $B9, $79 +.charmap $BA, $7A +.charmap $BB, $7B +.charmap $BC, $7C +.charmap $BD, $7D +.charmap $BE, $7E +.charmap $BF, $7F + +; Char $C0 ... $DF -> c - 128 +.charmap $C0, $40 + +; Char $C1 ... $DA -> c - 128 - 64 lower-case alphabet +.charmap $C1, $01 +.charmap $C2, $02 +.charmap $C3, $03 +.charmap $C4, $04 +.charmap $C5, $05 +.charmap $C6, $06 +.charmap $C7, $07 +.charmap $C8, $08 +.charmap $C9, $09 +.charmap $CA, $0A +.charmap $CB, $0B +.charmap $CC, $0C +.charmap $CD, $0D +.charmap $CE, $0E +.charmap $CF, $0F +.charmap $D0, $10 +.charmap $D1, $11 +.charmap $D2, $12 +.charmap $D3, $13 +.charmap $D4, $14 +.charmap $D5, $15 +.charmap $D6, $16 +.charmap $D7, $17 +.charmap $D8, $18 +.charmap $D9, $19 +.charmap $DA, $1A + +; Char $DB ... $DF -> c - 128 +.charmap $DB, $5B +.charmap $DC, $5C +.charmap $DD, $5D +.charmap $DE, $5E +.charmap $DF, $5F + +; Char $E0 ... $FF -> c - 128 +.charmap $E0, $60 +.charmap $E1, $61 +.charmap $E2, $62 +.charmap $E3, $63 +.charmap $E4, $64 +.charmap $E5, $65 +.charmap $E6, $66 +.charmap $E7, $67 +.charmap $E8, $68 +.charmap $E9, $69 +.charmap $EA, $6A +.charmap $EB, $6B +.charmap $EC, $6C +.charmap $ED, $6D +.charmap $EE, $6E +.charmap $EF, $6F +.charmap $F0, $70 +.charmap $F1, $71 +.charmap $F2, $72 +.charmap $F3, $73 +.charmap $F4, $74 +.charmap $F5, $75 +.charmap $F6, $76 +.charmap $F7, $77 +.charmap $F8, $78 +.charmap $F9, $79 +.charmap $FA, $7A +.charmap $FB, $7B +.charmap $FC, $7C +.charmap $FD, $7D +.charmap $FE, $7E +.charmap $FF, $7F diff --git a/cc65/asminc/cpu.mac b/cc65/asminc/cpu.mac new file mode 100644 index 0000000..0925191 --- /dev/null +++ b/cc65/asminc/cpu.mac @@ -0,0 +1,4 @@ +; This file is no longer needed as the symbols that were defined here are now +; internal symbols generated by the assembler. It is kept to avoid breaking +; old sources. +.warning "'.macpack cpu' is no longer required" diff --git a/cc65/asminc/creativision.inc b/cc65/asminc/creativision.inc new file mode 100644 index 0000000..a0259ec --- /dev/null +++ b/cc65/asminc/creativision.inc @@ -0,0 +1,66 @@ +;* +;** VTech Creativision Definitions +;* + +;** Screen +SCREEN_ROWS = 24 +SCREEN_COLS = 32 +SCREEN_PTR := $3A +CURSOR_X := $3C +CURSOR_Y := $3D + +;** VDP +VDP_DATA_R := $2000 +VDP_STATUS_R := $2001 +VDP_DATA_W := $3000 +VDP_CONTROL_W := $3001 + +;** PIA +PIA0_DATA := $1000 +PIA0_STATUS := $1001 +PIA1_DATA := $1002 +PIA1_STATUS := $1003 + +;** General +CH_VLINE = 33 +CH_HLINE = 34 +CH_ULCORNER = 35 +CH_URCORNER = 36 +CH_LLCORNER = 37 +CH_LRCORNER = 38 + +;** I/O (Zero-page variables) +ZP_KEYBOARD := $10 +ZP_JOY0_DIR := $11 +ZP_JOY1_DIR := $13 +ZP_JOY0_BUTTONS := $16 +ZP_JOY1_BUTTONS := $17 + +;** Joystick direction values (ZP_JOY0_DIR/ZP_JOY1_DIR) +JOY_N = $49 +JOY_NNE = $48 +JOY_NE = $47 +JOY_ENE = $46 +JOY_E = $45 +JOY_ESE = $44 +JOY_SE = $43 +JOY_SSE = $42 +JOY_S = $41 +JOY_SSW = $40 +JOY_SW = $4F +JOY_WSW = $4E +JOY_W = $4D +JOY_WNW = $4C +JOY_NW = $4B +JOY_NNW = $4A + +;** BIOS routines +BIOS_NMI_RESET_ADDR := $F808 +BIOS_PLAY_TUNE1 := $FBD6 +BIOS_PLAY_SONG := $FBED +BIOS_PLAY_TUNE2 := $FCE6 +BIOS_WRITE_VDP_REG := $FE1F +BIOS_QUIET_PSG := $FE54 +BIOS_POKE_PSG := $FE77 +BIOS_IRQ1_ADDR := $FF3F +BIOS_IRQ2_ADDR := $FF52 diff --git a/cc65/asminc/ctype.inc b/cc65/asminc/ctype.inc new file mode 100644 index 0000000..4d9ae79 --- /dev/null +++ b/cc65/asminc/ctype.inc @@ -0,0 +1,31 @@ +; ctype.inc +; +; This file is part of +; cc65 - a freeware C compiler for 6502 based systems +; +; https://cc65.github.io +; +; See "LICENSE" file for legal information. +; +; Definitions for the character type tables +; +; Ullrich von Bassewitz, 08.09.2001 +; + +; Define bitmapped constants for the table entries + +CT_NONE = %00000000 ; Nothing special +CT_LOWER = %00000001 ; 0 - Lower case char +CT_UPPER = %00000010 ; 1 - Upper case char +CT_DIGIT = %00000100 ; 2 - Numeric digit +CT_XDIGIT = %00001000 ; 3 - Hex digit (both, lower and upper) +CT_CTRL = %00010000 ; 4 - Control character +CT_SPACE = %00100000 ; 5 - The space character itself +CT_OTHER_WS = %01000000 ; 6 - Other whitespace ('\f', '\n', '\r', '\t' and '\v') +CT_SPACE_TAB = %10000000 ; 7 - Space or tab character + +; Combined stuff +CT_ALNUM = (CT_LOWER | CT_UPPER | CT_DIGIT) +CT_ALPHA = (CT_LOWER | CT_UPPER) +CT_CTRL_SPACE = (CT_CTRL | CT_SPACE) +CT_NOT_PUNCT = (CT_SPACE | CT_CTRL | CT_DIGIT | CT_UPPER | CT_LOWER) diff --git a/cc65/asminc/ctype_common.inc b/cc65/asminc/ctype_common.inc new file mode 100644 index 0000000..044c283 --- /dev/null +++ b/cc65/asminc/ctype_common.inc @@ -0,0 +1,91 @@ +; ctype_common.inc +; +; This file is part of +; cc65 - a freeware C compiler for 6502 based systems +; +; https://cc65.github.io +; +; See "LICENSE" file for legal information. +; +; Character specification table for some common targets. +; + + .include "ctypetable.inc" + .export __ctypeidx + +; The tables are readonly, put them into the rodata segment + +.rodata + +__ctypeidx: + ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 0/00 ___ctrl_@___, 1/01 ___ctrl_A___ + ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 2/02 ___ctrl_B___, 3/03 ___ctrl_C___ + ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 4/04 ___ctrl_D___, 5/05 ___ctrl_E___ + ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 6/06 ___ctrl_F___, 7/07 ___ctrl_G___ + ct_mix CT_CTRL_IDX, CT_CTRL_WS_SPACETAB_IDX ; 8/08 ___ctrl_H___, 9/09 ___ctrl_I___ + ct_mix CT_CTRL_WS_IDX, CT_CTRL_WS_IDX ; 10/0a ___ctrl_J___, 11/0b ___ctrl_K___ + ct_mix CT_CTRL_WS_IDX, CT_CTRL_WS_IDX ; 12/0c ___ctrl_L___, 13/0d ___ctrl_M___ + ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 14/0e ___ctrl_N___, 15/0f ___ctrl_O___ + ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 16/10 ___ctrl_P___, 17/11 ___ctrl_Q___ + ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 18/12 ___ctrl_R___, 19/13 ___ctrl_S___ + ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 20/14 ___ctrl_T___, 21/15 ___ctrl_U___ + ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 22/16 ___ctrl_V___, 23/17 ___ctrl_W___ + ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 24/18 ___ctrl_X___, 25/19 ___ctrl_Y___ + ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 26/1a ___ctrl_Z___, 27/1b ___ctrl_[___ + ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 28/1c ___ctrl_\___, 29/1d ___ctrl_]___ + ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 30/1e ___ctrl_^___, 31/1f ___ctrl_____ + + ct_mix CT_SPACE_SPACETAB_IDX, CT_NONE_IDX ; 32/20 ___SPACE___, 33/21 _____!_____ + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 34/22 _____"_____, 35/23 _____#_____ + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 36/24 _____$_____, 37/25 _____%_____ + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 38/26 _____&_____, 39/27 _____'_____ + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 40/28 _____(_____, 41/29 _____)_____ + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 42/2a _____*_____, 43/2b _____+_____ + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 44/2c _____,_____, 45/2d _____-_____ + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 46/2e _____._____, 47/2f _____/_____ + ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 48/30 _____0_____, 49/31 _____1_____ + ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 50/32 _____2_____, 51/33 _____3_____ + ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 52/34 _____4_____, 53/35 _____5_____ + ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 54/36 _____6_____, 55/37 _____7_____ + ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 56/38 _____8_____, 57/39 _____9_____ + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 58/3a _____:_____, 59/3b _____;_____ + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 60/3c _____<_____, 61/3d _____=_____ + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 62/3e _____>_____, 63/3f _____?_____ + + ct_mix CT_NONE_IDX, CT_UPPER_XDIGIT_IDX ; 64/40 _____@_____, 65/41 _____A_____ + ct_mix CT_UPPER_XDIGIT_IDX, CT_UPPER_XDIGIT_IDX ; 66/42 _____B_____, 67/43 _____C_____ + ct_mix CT_UPPER_XDIGIT_IDX, CT_UPPER_XDIGIT_IDX ; 68/44 _____D_____, 69/45 _____E_____ + ct_mix CT_UPPER_XDIGIT_IDX, CT_UPPER_IDX ; 70/46 _____F_____, 71/47 _____G_____ + ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 72/48 _____H_____, 73/49 _____I_____ + ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 74/4a _____J_____, 75/4b _____K_____ + ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 76/4c _____L_____, 77/4d _____M_____ + ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 78/4e _____N_____, 79/4f _____O_____ + ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 80/50 _____P_____, 81/51 _____Q_____ + ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 82/52 _____R_____, 83/53 _____S_____ + ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 84/54 _____T_____, 85/55 _____U_____ + ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 86/56 _____V_____, 87/57 _____W_____ + ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 88/58 _____X_____, 89/59 _____Y_____ + ct_mix CT_UPPER_IDX, CT_NONE_IDX ; 90/5a _____Z_____, 91/5b _____[_____ + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 92/5c _____\_____, 93/5d _____]_____ + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 94/5e _____^_____, 95/5f _UNDERLINE_ + + ct_mix CT_NONE_IDX, CT_LOWER_XDIGIT_IDX ; 96/60 ___grave___, 97/61 _____a_____ + ct_mix CT_LOWER_XDIGIT_IDX, CT_LOWER_XDIGIT_IDX ; 98/62 _____b_____, 99/63 _____c_____ + ct_mix CT_LOWER_XDIGIT_IDX, CT_LOWER_XDIGIT_IDX ; 100/64 _____d_____, 101/65 _____e_____ + ct_mix CT_LOWER_XDIGIT_IDX, CT_LOWER_IDX ; 102/66 _____f_____, 103/67 _____g_____ + ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 104/68 _____h_____, 105/69 _____i_____ + ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 106/6a _____j_____, 107/6b _____k_____ + ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 108/6c _____l_____, 109/6d _____m_____ + ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 110/6e _____n_____, 111/6f _____o_____ + ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 112/70 _____p_____, 113/71 _____q_____ + ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 114/72 _____r_____, 115/73 _____s_____ + ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 116/74 _____t_____, 117/75 _____u_____ + ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 118/76 _____v_____, 119/77 _____w_____ + ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 120/78 _____x_____, 121/79 _____y_____ + ct_mix CT_LOWER_IDX, CT_NONE_IDX ; 122/7a _____z_____, 123/7b _____{_____ + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 124/7c _____|_____, 125/7d _____}_____ + ct_mix CT_NONE_IDX, CT_WS_IDX ; 126/7e _____~_____, 127/7f ____DEL____ + +.repeat 64 + ct_mix CT_NONE_IDX, CT_NONE_IDX ; 128-255 +.endrepeat diff --git a/cc65/asminc/ctypetable.inc b/cc65/asminc/ctypetable.inc new file mode 100644 index 0000000..76c5b92 --- /dev/null +++ b/cc65/asminc/ctypetable.inc @@ -0,0 +1,48 @@ +; ctypetable.inc +; +; This file is part of +; cc65 - a freeware C compiler for 6502 based systems +; +; https://cc65.github.io +; +; See "LICENSE" file for legal information. +; +; Data covering all possible combinations of character flags for target specific definition +; + +.include "ctype.inc" +.export __ctype + +; Table definition covering all possible ctype combinations + +.rodata +__ctype: +ct_none: .byte CT_NONE +ct_lower: .byte CT_LOWER +ct_upper: .byte CT_UPPER +ct_digit_xdigit: .byte CT_DIGIT | CT_XDIGIT +ct_lower_xdigit: .byte CT_LOWER | CT_XDIGIT +ct_upper_xdigit: .byte CT_UPPER | CT_XDIGIT +ct_ctrl: .byte CT_CTRL +ct_ws: .byte CT_OTHER_WS +ct_ctrl_ws: .byte CT_CTRL | CT_OTHER_WS +ct_space_spacetab: .byte CT_SPACE | CT_SPACE_TAB +ct_ctrl_ws_spacetab: .byte CT_CTRL | CT_OTHER_WS | CT_SPACE_TAB + +; build indices out of the table above: + +CT_NONE_IDX = ct_none - __ctype +CT_LOWER_IDX = ct_lower - __ctype +CT_UPPER_IDX = ct_upper - __ctype +CT_DIGIT_XDIGIT_IDX = ct_digit_xdigit - __ctype +CT_LOWER_XDIGIT_IDX = ct_lower_xdigit - __ctype +CT_UPPER_XDIGIT_IDX = ct_upper_xdigit - __ctype +CT_CTRL_IDX = ct_ctrl - __ctype +CT_WS_IDX = ct_ws - __ctype +CT_CTRL_WS_IDX = ct_ctrl_ws - __ctype +CT_SPACE_SPACETAB_IDX = ct_space_spacetab - __ctype +CT_CTRL_WS_SPACETAB_IDX = ct_ctrl_ws_spacetab - __ctype + +.macro ct_mix lower, upper + .byte ((lower) & $0F) | ((upper) << 4) +.endmacro diff --git a/cc65/asminc/cx16.inc b/cc65/asminc/cx16.inc new file mode 100644 index 0000000..d264add --- /dev/null +++ b/cc65/asminc/cx16.inc @@ -0,0 +1,574 @@ +; +; CX16 r39 definitions +; + +; --------------------------------------------------------------------------- +; Constants + +.enum COLOR + BLACK = $00 + WHITE + RED + CYAN + PURPLE + GREEN + BLUE + YELLOW + ORANGE + BROWN + PINK + LIGHTRED = PINK + GRAY1 + GRAY2 + LIGHTGREEN + LIGHTBLUE + GRAY3 +.endenum + +; Special characters +.enum CH +COLOR_SWAP = $01 +STOP = $03 +UNDERLINE +WHITE +BOLD +BELL +BACKSPACE +TAB +LINEFEED +ITALIC +OUTLINE +ENTER +FONT_LOWER +FONT_ISO +F9 +CURS_DOWN +REVERSE +HOME +DEL +F10 +F11 +F12 +SHIFT_TAB +RED = $1C +CURS_RIGHT +GREEN +BLUE +LIRA = $5C +ORANGE = $81 +RUN = $83 +HELP +F1 +F3 +F5 +F7 +F2 +F4 +F6 +F8 +SHIFT_ENTER +FONT_UPPER +FONT_PET +BLACK +CURS_UP +ATTR_CLEAR +SCRN_CLEAR +INS +BROWN +PINK +LIGHTRED = PINK +GRAY1 +GRAY2 +LIGHTGREEN +LIGHTBLUE +GRAY3 +PURPLE +CURS_LEFT +YELLOW +CYAN +SHIFT_SPACE +LTEE = $AB +LLCORNER = $AD +URCORNER +ULCORNER = $B0 +BTEE +TTEE +RTEE +LRCORNER = $BD +HLINE = $C0 +CROSS = $DB +VLINE = $DD +PI +.endenum + +; --------------------------------------------------------------------------- +; Zero page + +; Banking registers +RAM_BANK := $00 +ROM_BANK := $01 + +; GEOS and graphics pseudo-registers +.struct gREG + .org $02 + .union + r0 .word + .struct + r0L .byte + r0H .byte + .endstruct + .endunion + .union + r1 .word + .struct + r1L .byte + r1H .byte + .endstruct + .endunion + .union + r2 .word + .struct + r2L .byte + r2H .byte + .endstruct + .endunion + .union + r3 .word + .struct + r3L .byte + r3H .byte + .endstruct + .endunion + .union + r4 .word + .struct + r4L .byte + r4H .byte + .endstruct + .endunion + .union + r5 .word + .struct + r5L .byte + r5H .byte + .endstruct + .endunion + .union + r6 .word + .struct + r6L .byte + r6H .byte + .endstruct + .endunion + .union + r7 .word + .struct + r7L .byte + r7H .byte + .endstruct + .endunion + .union + r8 .word + .struct + r8L .byte + r8H .byte + .endstruct + .endunion + .union + r9 .word + .struct + r9L .byte + r9H .byte + .endstruct + .endunion + .union + r10 .word + .struct + r10L .byte + r10H .byte + .endstruct + .endunion + .union + r11 .word + .struct + r11L .byte + r11H .byte + .endstruct + .endunion + .union + r12 .word + .struct + r12L .byte + r12H .byte + .endstruct + .endunion + .union + r13 .word + .struct + r13L .byte + r13H .byte + .endstruct + .endunion + .union + r14 .word + .struct + r14L .byte + r14H .byte + .endstruct + .endunion + .union + r15 .word + .struct + r15L .byte + r15H .byte + .endstruct + .endunion +.endstruct + +; Kernal +KTEMP2 := $80 ; 2 bytes for temporary storage +IMPARM := $82 ; Pointer for PRIMM function +FNAM := $8A ; Pointer to filename + +; BASIC +TXTPTR := $EE ; Pointer into BASIC source code + +; Page two + +BASIC_BUF := $0200 ; Location of command-line +BASIC_BUF_LEN = 81 ; Maximum length of command-line + +SCREEN_PTR := $0262 ; Pointer to current row on text screen (16 bits) +STATUS := $0287 ; Status from previous I/O operation +IN_DEV := $028B ; Current input device number +OUT_DEV := $028C ; Current output device number +FNAM_LEN := $028F ; Length of filename +SECADR := $0291 ; Secondary address +DEVNUM := $0292 ; Device number +CURS_COLOR := $0373 ; Color under the cursor +CHARCOLOR := $0376 ; Cursor's color nybbles (high: background, low: foreground) +RVS := $0377 ; Reverse flag +CURS_FLAG := $037B ; 1 = cursor off +CURS_BLINK := $037C ; Blink counter +CURS_CHAR := $037D ; Character under the cursor +CURS_STATE := $037E ; Cursor blink state +CURS_X := $0380 ; Cursor column +CURS_Y := $0383 ; Cursor row +LLEN := $0386 ; Line length +NLINES := $0387 ; Number of screen lines + +; BASIC +VARTAB := $03E1 ; Pointer to start of BASIC variables +MEMSIZE := $0259 ; Pointer to highest BASIC RAM location (+1) + +; --------------------------------------------------------------------------- +; Vector and other locations + +IRQVec := $0314 +BRKVec := $0316 +NMIVec := $0318 + +; --------------------------------------------------------------------------- +; I/O locations + +; 65C22 Versatile Interface Adapter +.struct VIA1 ; Versatile Interface Adapter + .org $9F00 + PRB .byte ; mouse, LED, VIC bus (Port Register B) + PRA .byte ; keyboard, controllers (Port Register A) + DDRB .byte ; (Data Direction Register B) + DDRA .byte ; (Data Direction Register A) + T1 .word ; (Timer 1) + T1L .word ; (Timer 1 Latch) + T2 .word ; (Timer 2) + SR .byte ; (Shift Register) + ACR .byte ; (Auxiliary Control Register) + PCR .byte ; (Peripheral Control Register) + IFR .byte ; (Interrupt Flags Register) + IER .byte ; (Interrupt Enable Register) + PRA2 .byte ; keyboard, controllers (PRA without handshake) +.endstruct + +; 65C22 Versatile Interface Adapter +.struct VIA2 + .org $9F10 + PRB .byte + PRA .byte + DDRB .byte + DDRA .byte + T1 .word + T1L .word + T2 .word + SR .byte + ACR .byte + PCR .byte + IFR .byte + IER .byte + PRA2 .byte +.endstruct + +; Video Enhanced Retro Adapter +; Has audio and SPI. +.scope VERA + + ; External registers + + .struct + .org $9F20 + ADDR .faraddr ; Address for data port access + DATA0 .byte ; First data port + DATA1 .byte ; Second data port + CTRL .byte ; Control register + IRQ_EN .byte ; Interrupt enable bits + IRQ_FLAGS .byte ; Interrupt flags + IRQ_RASTER .byte ; Line where IRQ will occur + .endstruct + .enum ; Address automatic increment amounts + DEC0 = (($00 << 1) | $01) << 3 + DEC1 = (($01 << 1) | $01) << 3 + DEC2 = (($02 << 1) | $01) << 3 + DEC4 = (($03 << 1) | $01) << 3 + DEC8 = (($04 << 1) | $01) << 3 + DEC16 = (($05 << 1) | $01) << 3 + DEC32 = (($06 << 1) | $01) << 3 + DEC64 = (($07 << 1) | $01) << 3 + DEC128 = (($08 << 1) | $01) << 3 + DEC256 = (($09 << 1) | $01) << 3 + DEC512 = (($0A << 1) | $01) << 3 + DEC40 = (($0B << 1) | $01) << 3 + DEC80 = (($0C << 1) | $01) << 3 + DEC160 = (($0D << 1) | $01) << 3 + DEC320 = (($0E << 1) | $01) << 3 + DEC640 = (($0F << 1) | $01) << 3 + INC0 = (($00 << 1) | $00) << 3 + INC1 = (($01 << 1) | $00) << 3 + INC2 = (($02 << 1) | $00) << 3 + INC4 = (($03 << 1) | $00) << 3 + INC8 = (($04 << 1) | $00) << 3 + INC16 = (($05 << 1) | $00) << 3 + INC32 = (($06 << 1) | $00) << 3 + INC64 = (($07 << 1) | $00) << 3 + INC128 = (($08 << 1) | $00) << 3 + INC256 = (($09 << 1) | $00) << 3 + INC512 = (($0A << 1) | $00) << 3 + INC40 = (($0B << 1) | $00) << 3 + INC80 = (($0C << 1) | $00) << 3 + INC160 = (($0D << 1) | $00) << 3 + INC320 = (($0E << 1) | $00) << 3 + INC640 = (($0F << 1) | $00) << 3 + .endenum + .enum ; Interrupt request flags + VERT_SYNC = %00000001 + RASTER_IRQ = %00000010 + SPR_COLLIDED = %00000100 + AUDIO_LOW = %00001000 + .endenum + .scope DISP ; Display controller + SELECT1 = %00000010 + .union + .org $9F29 + .struct + ; These four registers are visible when the DCSEL flag = %0 + VIDEO .byte + HSCALE .byte + VSCALE .byte + FRAME .byte + .endstruct + .struct + ; These four registers are visible when the DCSEL flag = %1 + HSTART .byte + HSTOP .byte + VSTART .byte + VSTOP .byte + .endstruct + .endunion + .enum MODE ; Output mode + DISABLE = $00 + VGA + NTSC + RGB ; Interlaced, composite sync + .endenum + .enum DISABLE + COLOR = %00000100 ; NTSC monochrome + .endenum + .enum ENABLE + LAYER0 = %00010000 + LAYER1 = %00100000 + SPRITES = %01000000 + .endenum + .endscope + .struct L0 ; Display layer 0 + .org $9F2D + CONFIG .byte + MAP_BASE .byte + TILE_BASE .byte + HSCROLL .word + VSCROLL .word + .endstruct + .struct L1 ; Display layer 1 + .org $9F34 + CONFIG .byte + MAP_BASE .byte + TILE_BASE .byte + HSCROLL .word + VSCROLL .word + .endstruct + .enum ; Layer display modes + TILE1BPP = %00000000 | $00 + TILE2BPP + TILE4BPP + TILE8BPP + T256C = %00001000 + BITMAP1BPP = %00000100 | $00 + BITMAP2BPP + BITMAP4BPP + BITMAP8BPP + .endenum + .enum MAP ; Map geometry + WIDTH32 = $00 << 4 + WIDTH64 = $01 << 4 + WIDTH128 = $02 << 4 + WIDTH256 = $03 << 4 + HEIGHT32 = $00 << 6 + HEIGHT64 = $01 << 6 + HEIGHT128 = $02 << 6 + HEIGHT256 = $03 << 6 + .endenum + .enum TILE ; Tile geometry + WIDTH8 = $00 + WIDTH16 = $01 + WIDTH320 = WIDTH8 + WIDTH640 = WIDTH16 + HEIGHT8 = $00 << 1 + HEIGHT16 = $01 << 1 + .endenum + .scope PCM ; Pulse-Code Modulator + .struct + .org $9F3B + CTRL .byte + RATE .byte + DATA .byte + .endstruct + .enum + STEREO = %00010000 + BITS16 = %00100000 + RESET = %10000000 + .endenum + .endscope + .scope SPI + .struct + .org $9F3E + DATA .byte + CTRL .byte + .endstruct + .enum + SELECT = %00000001 + SLOW = %00000010 + .endenum + .endscope + + ; Internal RAM and registers + + .struct + .org $000000 + VRAM .res $020000 ; 128 Kibibytes + .endstruct + .scope PSG ; Programmable Sound Generator + .struct + PITCH .word + VOL .byte ; Right, left sides; volume + WAVEFORM .byte ; Wave shape, pulse width + .endstruct + LEFT = %01 << 6 + RIGHT = %10 << 6 + .enum + PULSE = $00 << 6 + SAWTOOTH = $01 << 6 + TRIANGLE = $02 << 6 + NOISE = $03 << 6 + .endenum + .struct + .org $01F9C0 + VOICES .res $10 * 4 + .endstruct + .endscope + .struct + .org $01FA00 + PALETTE .word $0100 + .endstruct + .scope SPRITE + .struct ; Sprite attributes + ADDR .addr ; Address and color mode + XX .word ; Co-ordinates + YY .word + Z_FLIP .byte ; Collision mask, Z-depth, flip bits + SIZE_PAL .byte + .endstruct + .enum FLIP + NONE = %00000000 + HORIZ + VERT + BOTH + .endenum + .enum DEPTH + DISABLE = $00 << 2 + CANVAS = $01 << 2 + LAYER0 = $02 << 2 + LAYER1 = $03 << 2 + .endenum + .enum ; Sprite geometry + WIDTH8 = $00 << 4 + WIDTH16 = $01 << 4 + WIDTH32 = $02 << 4 + WIDTH64 = $03 << 4 + HEIGHT8 = $00 << 6 + HEIGHT16 = $01 << 6 + HEIGHT32 = $02 << 6 + HEIGHT64 = $03 << 6 + COLORS16 = $00 << 7 + COLORS256 = $01 << 7 + .endenum + .endscope + .struct + .org $01FC00 + SPRITES .res 128 * 8 + .endstruct +.endscope + +; YM2151 audio chip +.struct YM2151 + .org $9F40 + ADDR .byte + .union + DATA .byte + STATUS .byte + .endunion +.endstruct + +; X16 Emulator device +; This device doesn't exist on the real machine. +.struct EMULATOR + .org $9FB0 + DEBUG .byte ; Boolean: debugging enabled + VERALOG .byte ; Boolean: log VERA activity + KEYBOARDLOG .byte ; Boolean: log keyboard data + ECHO .byte ; Type of echo that's enabled + SAVEXIT .byte ; Boolean: save machine state on exit + GIFREC .byte ; Method of recording GIF movie + .res 2 + CYCLECOUNT .dword ; Running count of CPU cycles (Read-Only) + .res 1 + KEYMAP .byte ; Current keyboard layout number (Read-Only) + DETECT .byte 2 ; If is "16" string, then running on emulator (RO) +.endstruct + +; --------------------------------------------------------------------------- +; Banked RAM and ROM + +TIMER := $A03B ; (bank 0) 60 Hz. timer (3 bytes, big-endian) + +.struct BANK + .org $A000 + RAM .res $2000 ; 8 Kibibyte window into 512 Kibibytes or 2048 Kibibytes + ROM .res $4000 ; 16 Kibibyte window into 128 Kibibytes +.endstruct diff --git a/cc65/asminc/em-error.inc b/cc65/asminc/em-error.inc new file mode 100644 index 0000000..e0c8850 --- /dev/null +++ b/cc65/asminc/em-error.inc @@ -0,0 +1,49 @@ +;/*****************************************************************************/ +;/* */ +;/* em-error.inc */ +;/* */ +;/* EM error codes */ +;/* */ +;/* */ +;/* */ +;/* (C) 2002-2012, Ullrich von Bassewitz */ +;/* Roemerstrasse 52 */ +;/* D-70794 Filderstadt */ +;/* EMail: uz@cc65.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. */ +;/* */ +;/*****************************************************************************/ + + + +; Error constants +.enum + EM_ERR_OK ; No error + EM_ERR_NO_DRIVER ; No driver available + EM_ERR_CANNOT_LOAD ; Error loading driver + EM_ERR_INV_DRIVER ; Invalid driver + EM_ERR_NO_DEVICE ; Device (hardware) not found + EM_ERR_INSTALLED ; A driver is already installed + + EM_ERR_COUNT ; Special: Number of error messages +.endenum + + + diff --git a/cc65/asminc/em-kernel.inc b/cc65/asminc/em-kernel.inc new file mode 100644 index 0000000..9e89b6f --- /dev/null +++ b/cc65/asminc/em-kernel.inc @@ -0,0 +1,106 @@ +;/*****************************************************************************/ +;/* */ +;/* em-kernel.inc */ +;/* */ +;/* EM kernel interface */ +;/* */ +;/* */ +;/* */ +;/* (C) 2002-2003 Ullrich von Bassewitz */ +;/* Roemerstrasse 52 */ +;/* D-70794 Filderstadt */ +;/* EMail: uz@cc65.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. */ +;/* */ +;/*****************************************************************************/ + + + +;------------------------------------------------------------------------------ +; The driver header + +.struct EMD_HDR + ID .byte 3 ; Contains 0x65, 0x6d, 0x64 ("emd") + VERSION .byte 1 ; Interface version + LIBREF .addr ; Library reference + JUMPTAB .struct + INSTALL .addr ; INSTALL routine + UNINSTALL .addr ; UNINSTALL routine + PAGECOUNT .addr ; PAGECOUNT routine + MAP .addr ; MAP routine + USE .addr ; USE routine + MAPCLEAN .addr ; MAPCLEAN routine + COPYFROM .addr ; COPYFROM routine + COPYTO .addr ; COPYTO routine + .endstruct +.endstruct + +;------------------------------------------------------------------------------ +; The EMD API version, stored in EMD_HDR::VERSION + +EMD_API_VERSION = $02 + +;------------------------------------------------------------------------------ +; The asm equivalent to the C em_copy structure + +.struct EM_COPY + BUF .addr ; Memory buffer to copy from or to + OFFS .byte ; Offset into page + PAGE .word ; Starting page to copy from or to + COUNT .word ; Number of bytes to copy + UNUSED .byte ; Make the size 8 bytes +.endstruct + +;------------------------------------------------------------------------------ +; Variables + + .global _em_drv ; Pointer to driver + +;------------------------------------------------------------------------------ +; Driver entry points + + .global emd_install + .global emd_uninstall + .global emd_pagecount + .global emd_map + .global emd_use + .global emd_commit + .global emd_copyfrom + .global emd_copyto + +;------------------------------------------------------------------------------ +; ASM functions + + .global em_clear_ptr + +;------------------------------------------------------------------------------ +; C callable functions + + .global _em_load_driver + .global _em_unload + .global _em_install + .global _em_uninstall + .global _em_pagecount + .global _em_map + .global _em_use + .global _em_commit + .global _em_copyfrom + .global _em_copyto + diff --git a/cc65/asminc/errno.inc b/cc65/asminc/errno.inc new file mode 100644 index 0000000..2e876c7 --- /dev/null +++ b/cc65/asminc/errno.inc @@ -0,0 +1,37 @@ +; +; Ullrich von Bassewitz, 16.05.2000 +; + +; Variables and functions + + .global ___errno, ___oserror + .global ___osmaperrno + .global ___seterrno + .global ___directerrno, ___mappederrno + +; Error codes, must match the values in the C headers +.enum + EOK ; No error + ENOENT ; No such file or directory + ENOMEM ; Out of memory + EACCES ; Permission denied + ENODEV ; No such device + EMFILE ; Too many open files + EBUSY ; Device or resource busy + EINVAL ; Invalid argument + ENOSPC ; No space left on device + EEXIST ; File exists + EAGAIN ; Try again + EIO ; I/O error + EINTR ; Interrupted system call + ENOSYS ; Function not implemented + ESPIPE ; Illegal seek + ERANGE ; Range error + EBADF ; Bad file number + ENOEXEC ; Exec format error + EUNKNOWN ; Unknown OS specific error - must be last! + + EMAX = EUNKNOWN ; Highest error code +.endenum + + diff --git a/cc65/asminc/fcntl.inc b/cc65/asminc/fcntl.inc new file mode 100644 index 0000000..5e6333d --- /dev/null +++ b/cc65/asminc/fcntl.inc @@ -0,0 +1,21 @@ +; +; Ullrich von Bassewitz, 05.06.1999 +; + +; Predefined file handles +STDIN_FILENO = 0 +STDOUT_FILENO = 1 +STDERR_FILENO = 2 + +; File mode constants, must match the values in the C headers +O_RDONLY = $01 +O_WRONLY = $02 +O_RDWR = $03 +O_CREAT = $10 +O_TRUNC = $20 +O_APPEND = $40 +O_EXCL = $80 + + + + diff --git a/cc65/asminc/gamate.inc b/cc65/asminc/gamate.inc new file mode 100644 index 0000000..4e7fee2 --- /dev/null +++ b/cc65/asminc/gamate.inc @@ -0,0 +1,64 @@ +;------------------------------------------------------------------------------- +; gamate.inc +; +; Gamate system specific definitions +; +; (w) 2015 Groepaz/Hitmen (groepaz@gmx.net) +; based on technical reference by PeT (mess@utanet.at) +;------------------------------------------------------------------------------- + +; look at gamate.h for comments, they are not duplicated here + +AUDIO_BASE = $4000 + +JOY_DATA = $4400 + +JOY_DATA_UP = $01 +JOY_DATA_DOWN = $02 +JOY_DATA_LEFT = $04 +JOY_DATA_RIGHT = $08 +JOY_DATA_FIRE_A = $10 +JOY_DATA_FIRE_B = $20 +JOY_DATA_START = $40 +JOY_DATA_SELECT = $80 + +LCD_WIDTH = 160 +LCD_HEIGHT = 152 + +LCD_BASE = $5000 +LCD_MODE = $5001 +LCD_XPOS = $5002 +LCD_YPOS = $5003 +LCD_X = $5004 +LCD_Y = $5005 +LCD_READ = $5006 +LCD_DATA = $5007 + +LCD_MODE_INC_X = $00 +LCD_MODE_INC_Y = $40 +LCD_XPOS_PLANE1 = $00 +LCD_XPOS_PLANE2 = $80 + +; constants for the conio implementation +charsperline = (LCD_WIDTH / 8) +screenrows = (LCD_HEIGHT / 8) + +CH_HLINE = 1 +CH_VLINE = 2 + +COLOR_WHITE = 0 +COLOR_GREY2 = 1 +COLOR_GREY1 = 2 +COLOR_BLACK = 3 + +; bios zp usage: +ZP_NMI_4800 = $0a +ZP_IRQ_COUNT = $0b +ZP_IRQ_CTRL = $0c + +ZP_IRQ_CNT1 = $0e +ZP_IRQ_CNT2 = $0f +ZP_IRQ_CNT3 = $10 +ZP_IRQ_CNT4 = $11 + +ZP_NMI_FLAG = $e8 diff --git a/cc65/asminc/generic.mac b/cc65/asminc/generic.mac new file mode 100644 index 0000000..5e5b210 --- /dev/null +++ b/cc65/asminc/generic.mac @@ -0,0 +1,53 @@ + +; add - Add without carry +.macro add Arg1, Arg2 + clc + .if .paramcount = 2 + adc Arg1, Arg2 + .else + adc Arg1 + .endif +.endmacro + +; sub - subtract without borrow +.macro sub Arg1, Arg2 + sec + .if .paramcount = 2 + sbc Arg1, Arg2 + .else + sbc Arg1 + .endif +.endmacro + +; bge - jump if unsigned greater or equal +.macro bge Arg + bcs Arg +.endmacro + +; blt - Jump if unsigned less +.macro blt Arg + bcc Arg +.endmacro + +; bgt - jump if unsigned greater +.macro bgt Arg + beq *+4 + bcs Arg +.endmacro + +; ble - jump if unsigned less or equal +.macro ble Arg + beq Arg + bcc Arg +.endmacro + +; bnz - jump if not zero +.macro bnz Arg + bne Arg +.endmacro + +; bze - jump if zero +.macro bze Arg + beq Arg +.endmacro + diff --git a/cc65/asminc/get_tv.inc b/cc65/asminc/get_tv.inc new file mode 100644 index 0000000..47e0d9c --- /dev/null +++ b/cc65/asminc/get_tv.inc @@ -0,0 +1,22 @@ +; +; get_tv.inc +; +; Ullrich von Bassewitz, 2004-10-15 +; +; Defines for the get_tv function. + + + +; Error codes returned by all functions +.enum TV + NTSC + PAL + OTHER +.endenum + + +; get_tv function + + .global _get_tv + + diff --git a/cc65/asminc/joy-error.inc b/cc65/asminc/joy-error.inc new file mode 100644 index 0000000..5c13386 --- /dev/null +++ b/cc65/asminc/joy-error.inc @@ -0,0 +1,44 @@ +;/*****************************************************************************/ +;/* */ +;/* joy-error.inc */ +;/* */ +;/* Joystick error codes */ +;/* */ +;/* */ +;/* */ +;/* (C) 2002 Ullrich von Bassewitz */ +;/* Wacholderweg 14 */ +;/* D-70597 Stuttgart */ +;/* EMail: uz@musoftware.de */ +;/* */ +;/* */ +;/* 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. */ +;/* */ +;/*****************************************************************************/ + + + +; Error codes +JOY_ERR_OK = 0 ; No error +JOY_ERR_NO_DRIVER = 1 ; No driver available +JOY_ERR_CANNOT_LOAD = 2 ; Error loading driver +JOY_ERR_INV_DRIVER = 3 ; Invalid driver +JOY_ERR_NO_DEVICE = 4 ; Device (hardware) not found + + + diff --git a/cc65/asminc/joy-kernel.inc b/cc65/asminc/joy-kernel.inc new file mode 100644 index 0000000..7919341 --- /dev/null +++ b/cc65/asminc/joy-kernel.inc @@ -0,0 +1,83 @@ +;/*****************************************************************************/ +;/* */ +;/* joy-kernel.inc */ +;/* */ +;/* Internally used joystick functions */ +;/* */ +;/* */ +;/* */ +;/* (C) 2002-2006, Ullrich von Bassewitz */ +;/* Roemerstrasse 52 */ +;/* D-70794 Filderstadt */ +;/* EMail: uz@cc65.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. */ +;/* */ +;/*****************************************************************************/ + + + + + + +;------------------------------------------------------------------------------ +; Driver header stuff + +.struct JOY_HDR + ID .byte 3 ; $6A, $6F, $79 ("joy") + VERSION .byte 1 ; Interface version + LIBREF .addr ; Library reference + JUMPTAB .struct + INSTALL .addr ; INSTALL routine + UNINSTALL .addr ; UNINSTALL routine + COUNT .addr ; COUNT routine + READ .addr ; READ routine + .endstruct +.endstruct + +;------------------------------------------------------------------------------ +; The JOY API version, stored in JOY_HDR::VERSION + +JOY_API_VERSION = $05 + +;------------------------------------------------------------------------------ +; Variables + + .global _joy_drv ; Pointer to driver + .global _joy_masks + +;------------------------------------------------------------------------------ +; Driver entry points + + .global joy_install + .global joy_uninstall + .global joy_count + .global joy_read + +;------------------------------------------------------------------------------ +; C callable functions + + .global _joy_load_driver + .global _joy_unload + .global _joy_install + .global _joy_uninstall + .global _joy_count + .global _joy_read + + .global _joy_clear_ptr diff --git a/cc65/asminc/kim1.inc b/cc65/asminc/kim1.inc new file mode 100644 index 0000000..81e83b8 --- /dev/null +++ b/cc65/asminc/kim1.inc @@ -0,0 +1,31 @@ +; --------------------------------------------------------------------------- +; +; KIM-1 definitions +; +; --------------------------------------------------------------------------- + + +RAMSTART := $0200 ; Entry point + + +; --------------------------------------------------------------------------- +; Monitor Functions +; --------------------------------------------------------------------------- +OUTCHR := $1EA0 ; Output character +INTCHR := $1E5A ; Input character without case conversion +DUMPT := $1800 ; Dump memory to tape +LOADT := $1873 ; Load memory from tape +START := $1C4F ; Enter KIM-1 monitor +SCANDS := $1F1F ; Scan 7-segment display +KEYIN := $1F40 ; Open up keyboard channel +GETKEY := $1F6A ; Return key from keyboard + + +; --------------------------------------------------------------------------- +; System Memory +; --------------------------------------------------------------------------- +SAL := $17F5 ; Tape load address low +SAH := $17F6 ; Tape load address high +EAL := $17F7 ; Tape address end low +EAH := $17F8 ; Tape address end high +ID := $17F9 ; Tape Identification number diff --git a/cc65/asminc/longbranch.mac b/cc65/asminc/longbranch.mac new file mode 100644 index 0000000..d6f6cde --- /dev/null +++ b/cc65/asminc/longbranch.mac @@ -0,0 +1,88 @@ +.macro jeq Target + .if .match(Target, 0) + bne *+5 + jmp Target + .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) + beq Target + .else + bne *+5 + jmp Target + .endif +.endmacro +.macro jne Target + .if .match(Target, 0) + beq *+5 + jmp Target + .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) + bne Target + .else + beq *+5 + jmp Target + .endif +.endmacro +.macro jmi Target + .if .match(Target, 0) + bpl *+5 + jmp Target + .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) + bmi Target + .else + bpl *+5 + jmp Target + .endif +.endmacro +.macro jpl Target + .if .match(Target, 0) + bmi *+5 + jmp Target + .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) + bpl Target + .else + bmi *+5 + jmp Target + .endif +.endmacro +.macro jcs Target + .if .match(Target, 0) + bcc *+5 + jmp Target + .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) + bcs Target + .else + bcc *+5 + jmp Target + .endif +.endmacro +.macro jcc Target + .if .match(Target, 0) + bcs *+5 + jmp Target + .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) + bcc Target + .else + bcs *+5 + jmp Target + .endif +.endmacro +.macro jvs Target + .if .match(Target, 0) + bvc *+5 + jmp Target + .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) + bvs Target + .else + bvc *+5 + jmp Target + .endif +.endmacro +.macro jvc Target + .if .match(Target, 0) + bvs *+5 + jmp Target + .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127) + bvc Target + .else + bvs *+5 + jmp Target + .endif +.endmacro diff --git a/cc65/asminc/lynx.inc b/cc65/asminc/lynx.inc new file mode 100644 index 0000000..150bee6 --- /dev/null +++ b/cc65/asminc/lynx.inc @@ -0,0 +1,460 @@ +; Lynx system hardware includes +; Shawn Jefferson +; June 18th, 2004 +; +; Reference: +; Bastian Schick's Lynx Documentation +; http://www.geocities.ws/SiliconValley/Byte/4242/lynx/ +; + +; *** +; *** Suzy Addresses +; *** + +; Sprite Control Block + +TMPADRL = $FC00 +TMPADRH = $FC01 +TILTACUML = $FC02 +TILTACUMH = $FC03 +HOFFL = $FC04 +HOFFH = $FC05 +VOFFL = $FC06 +VOFFH = $FC07 +VIDBASL = $FC08 +VIDBASH = $FC09 +COLLBASL = $FC0A +COLLBASH = $FC0B +VIDADRL = $FC0C +VIDADRH = $FC0D +COLLADRL = $FC0E +COLLADRH = $FC0F +SCBNEXTL = $FC10 +SCBNEXTH = $FC11 +SPRDLINEL = $FC12 +SPRDLINEH = $FC13 +HPOSSTRTL = $FC14 +HPOSSTRTH = $FC15 +VPOSSTRTL = $FC16 +VPOSSTRTH = $FC17 +SPRHSIZL = $FC18 +SPRHSIZH = $FC19 +SPRVSIZL = $FC1A +SPRVSIZH = $FC1B +STRETCHL = $FC1C +STRETCHH = $FC1D +TILTL = $FC1E +TILTH = $FC1F +SPRDOFFL = $FC20 +SPRDOFFH = $FC21 +SPRVPOSL = $FC22 +SPRVPOSH = $FC23 +COLLOFFL = $FC24 +COLLOFFH = $FC25 +VSIZACUML = $FC26 +VSIZACUMH = $FC27 +HSIZOFFL = $FC28 +HSIZOFFH = $FC29 +VSIZOFFL = $FC2A +VSIZOFFH = $FC2B +SCBADRL = $FC2C +SCBADRH = $FC2D +PROCADRL = $FC2E +PROCADRH = $FC2F + +; Suzy Math + +MATHD = $FC52 +MATHC = $FC53 +MATHB = $FC54 +MATHA = $FC55 +MATHP = $FC56 +MATHN = $FC57 +MATHH = $FC60 +MATHG = $FC61 +MATHF = $FC62 +MATHE = $FC63 +MATHM = $FC6C +MATHL = $FC6D +MATHK = $FC6E +MATHJ = $FC6F + +; Suzy sprite engine + +SPRCTL0 = $FC80 +; Sprite bits-per-pixel definitions +BPP_MASK = %11000000 ; Mask for settings bits per pixel +BPP_1 = %00000000 +BPP_2 = %01000000 +BPP_3 = %10000000 +BPP_4 = %11000000 +; More sprite control 0 bit definitions +HFLIP = %00100000 +VFLIP = %00010000 +; Sprite types - redefined to reflect the reality caused by the shadow error +TYPE_SHADOW = %00000111 +TYPE_XOR = %00000110 +TYPE_NONCOLL = %00000101 ; Non-colliding +TYPE_NORMAL = %00000100 +TYPE_BOUNDARY = %00000011 +TYPE_BSHADOW = %00000010 ; Background shadow +TYPE_BACKNONCOLL = %00000001 ; Background non-colliding +TYPE_BACKGROUND = %00000000 + +SPRCTL1 = $FC81 +LITERAL = %10000000 +PACKED = %00000000 +ALGO3 = %01000000 ; Broken, do not set this bit! +; Sprite reload mask definitions +RELOAD_MASK = %00110000 +RENONE = %00000000 ; Reload nothing +REHV = %00010000 ; Reload hsize, vsize +REHVS = %00100000 ; Reload hsize, vsize, stretch +REHVST = %00110000 ; Reload hsize, vsize, stretch, tilt +; More sprite control 1 bit definitions +REUSEPAL = %00001000 +SKIP = %00000100 +DRAWUP = %00000010 +DRAWLEFT = %00000001 + +SPRCOLL = $FC82 +SPRINIT = $FC83 +SUZYHREV = $FC88 +SUZYSREV = $FC89 +SUZYBUSEN = $FC90 + +SPRGO = $FC91 +; SPRGO bit definitions +SPRITE_GO = %00000001 ; sprite process start bit +EVER_ON = %00000100 ; everon detector enable + +SPRSYS = $FC92 +; SPRSYS bit definitions for write operations +SIGNMATH = %10000000 ; signed math +ACCUMULATE = %01000000 ; accumulate multiplication results +NO_COLLIDE = %00100000 ; do not collide with any sprites (also SPRCOLL bit definition) +VSTRETCH = %00010000 ; stretch v +LEFTHAND = %00001000 +CLR_UNSAFE = %00000100 ; unsafe access reset +SPRITESTOP = %00000010 ; request to stop sprite process +; SPRSYS bit definitions for read operations +MATHWORKING = %10000000 ; math operation in progress +MATHWARNING = %01000000 ; accumulator overflow on multiple or divide by zero +MATHCARRY = %00100000 ; last carry bit +VSTRETCHING = %00010000 +LEFTHANDED = %00001000 +UNSAFE_ACCESS = %00000100 ; unsafe access performed +SPRITETOSTOP = %00000010 ; requested to stop +SPRITEWORKING = %00000001 ; sprite process is active + +JOYSTICK = $FCB0 +; JOYSTICK bit definitions +JOYPAD_UP = %10000000 +JOYPAD_DOWN = %01000000 +JOYPAD_LEFT = %00100000 +JOYPAD_RIGHT = %00010000 +BUTTON_OPTION1 = %00001000 +BUTTON_OPTION2 = %00000100 +BUTTON_INNER = %00000010 +BUTTON_OUTER = %00000001 + +SWITCHES = $FCB1 +; SWITCHES bit definitions +CART1_IO_INACTIVE = %00000100 +CART0_IO_INACTIVE = %00000010 +BUTTON_PAUSE = %00000001 + +RCART0 = $FCB2 +RCART1 = $FCB3 +LEDS = $FCC0 +PARSTATUS = $FCC2 +PARDATA = $FCC3 +HOWIE = $FCC4 + +; +; *** Mikey Addresses +; *** + +; Mikey timers + +; Logical timer names +TIMER0 = $FD00 +TIMER1 = $FD04 +TIMER2 = $FD08 +TIMER3 = $FD0C +TIMER4 = $FD10 +TIMER5 = $FD14 +TIMER6 = $FD18 +TIMER7 = $FD1C +HTIMER = TIMER0 ; horizontal line timer (timer 0) +VTIMER = TIMER2 ; vertical blank timer (timer 2) +STIMER = TIMER7 ; sound timer (timer 7) + +HTIMBKUP = $FD00 ; horizontal line timer (timer 0) +HTIMCTLA = $FD01 +HTIMCNT = $FD02 +HTIMCTLB = $FD03 +VTIMBKUP = $FD08 ; vertical blank timer (timer 2) +VTIMCTLA = $FD09 +VTIMCNT = $FD0A +VTIMCTLB = $FD0B +BAUDBKUP = $FD10 ; serial timer (timer 4) +STIMBKUP = $FD1C ; sound timer (timer 7) +STIMCTLA = $FD1D +STIMCNT = $FD1E +STIMCTLB = $FD1F + +TIM0BKUP = $FD00 +TIM0CTLA = $FD01 +TIM0CNT = $FD02 +TIM0CTLB = $FD03 +TIM1BKUP = $FD04 +TIM1CTLA = $FD05 +TIM1CNT = $FD06 +TIM1CTLB = $FD07 +TIM2BKUP = $FD08 +TIM2CTLA = $FD09 +TIM2CNT = $FD0A +TIM2CTLB = $FD0B +TIM3BKUP = $FD0C +TIM3CTLA = $FD0D +TIM3CNT = $FD0E +TIM3CTLB = $FD0F +TIM4BKUP = $FD10 +TIM4CTLA = $FD11 +TIM4CNT = $FD12 +TIM4CTLB = $FD13 +TIM5BKUP = $FD14 +TIM5CTLA = $FD15 +TIM5CNT = $FD16 +TIM5CTLB = $FD17 +TIM6BKUP = $FD18 +TIM6CTLA = $FD19 +TIM6CNT = $FD1A +TIM6CTLB = $FD1B +TIM7BKUP = $FD1C +TIM7CTLA = $FD1D +TIM7CNT = $FD1E +TIM7CTLB = $FD1F + +; Timer offsets +TIM_BACKUP = 0 +TIM_CONTROLA = 1 +TIM_COUNT = 2 +TIM_CONTROLB = 3 + +; TIM_CONTROLA control bits +ENABLE_INT = %10000000 +RESET_DONE = %01000000 +ENABLE_RELOAD = %00010000 +ENABLE_COUNT = %00001000 +AUD_CLOCK_MASK = %00000111 +; Clock settings +AUD_LINKING = %00000111 +AUD_64 = %00000110 +AUD_32 = %00000101 +AUD_16 = %00000100 +AUD_8 = %00000011 +AUD_4 = %00000010 +AUD_2 = %00000001 +AUD_1 = %00000000 + +; TIM_CONTROLB control bits +TIMER_DONE = %00001000 +LAST_CLOCK = %00000100 +BORROW_IN = %00000010 +BORROW_OUT = %00000001 + +; Mikey Audio + +AUDIO0 = $FD20 ; audio channel 0 +AUDIO1 = $FD28 ; audio channel 1 +AUDIO2 = $FD30 ; audio channel 2 +AUDIO3 = $FD38 ; audio channel 3 + +AUD0VOL = $FD20 +AUD0FEED = $FD21 +AUD0OUT = $FD22 +AUD0SHIFT = $FD23 +AUD0BKUP = $FD24 +AUD0CTLA = $FD25 +AUD0CNT = $FD26 +AUD0CTLB = $FD27 +AUD1VOL = $FD28 +AUD1FEED = $FD29 +AUD1OUT = $FD2A +AUD1SHIFT = $FD2B +AUD1BKUP = $FD2C +AUD1CTLA = $FD2D +AUD1CNT = $FD2E +AUD1CTLB = $FD2F +AUD2VOL = $FD30 +AUD2FEED = $FD31 +AUD2OUT = $FD32 +AUD2SHIFT = $FD33 +AUD2BKUP = $FD34 +AUD2CTLA = $FD35 +AUD2CNT = $FD36 +AUD2CTLB = $FD37 +AUD3VOL = $FD38 +AUD3FEED = $FD39 +AUD3OUT = $FD3A +AUD3SHIFT = $FD3B +AUD3BKUP = $FD3C +AUD3CTLA = $FD3D +AUD3CNT = $FD3E +AUD3CTLB = $FD3F + +; AUD_CONTROL bits are almost identical to TIM_CONTROLA bits. +; See TIM_CONTROLA above for the other definitions +FEEDBACK_7 = %10000000 +ENABLE_INTEGRATE = %00100000 + +; Stereo control registers follow +; Stereo capability does not exist in all Lynxes +; Left and right may be reversed, and if so will be corrected in a later +; release +ATTENREG0 = $FD40 ; Stereo attenuation registers +ATTENREG1 = $FD41 +ATTENREG2 = $FD42 +ATTENREG3 = $FD43 + +MPAN = $FD44 +MSTEREO = $FD50 +; Bit definitions for MPAN and MSTEREO registers +LEFT_ATTENMASK = %11110000 +RIGHT_ATTENMASK = %00001111 +LEFT3_SELECT = %10000000 +LEFT2_SELECT = %01000000 +LEFT1_SELECT = %00100000 +LEFT0_SELECT = %00010000 +RIGHT3_SELECT = %00001000 +RIGHT2_SELECT = %00000100 +RIGHT1_SELECT = %00000010 +RIGHT0_SELECT = %00000001 + +; Mikey interrupts + +INTRST = $FD80 +INTSET = $FD81 + +; Interrupt bits in INTRST and INTSET +TIMER0_INTERRUPT = %00000001 +TIMER1_INTERRUPT = %00000010 +TIMER2_INTERRUPT = %00000100 +TIMER3_INTERRUPT = %00001000 +TIMER4_INTERRUPT = %00010000 +TIMER5_INTERRUPT = %00100000 +TIMER6_INTERRUPT = %01000000 +TIMER7_INTERRUPT = %10000000 + +HBL_INTERRUPT = TIMER0_INTERRUPT +VBL_INTERRUPT = TIMER2_INTERRUPT +SERIAL_INTERRUPT = TIMER4_INTERRUPT +SND_INTERRUPT = TIMER7_INTERRUPT + +MAGRDY0 = $FD84 +MAGRDY1 = $FD85 +AUDIN = $FD86 +SYSCTL1 = $FD87 +; SYSCTL1 bit definitions +POWERON = %00000010 +CART_ADDR_STROBE = %00000001 + +MIKEYHREV = $FD88 +MIKEYSREV = $FD89 + +IODIR = $FD8A +IODAT = $FD8B +; IODIR and IODAT bit definitions +AUDIN_BIT = %00010000 ; Note that there is also the address AUDIN +READ_ENABLE = %00010000 ; Same bit for AUDIN_BIT +RESTLESS = %00001000 +NOEXP = %00000100 ; If set, redeye is not connected +CART_ADDR_DATA = %00000010 +CART_POWER_OFF = %00000010 ; Same bit for CART_ADDR_DATA +EXTERNAL_POWER = %00000001 + +SERCTL = $FD8C +; SERCTL bit definitions for write operations +TXINTEN = %10000000 +RXINTEN = %01000000 +PAREN = %00010000 +RESETERR = %00001000 +TXOPEN = %00000100 +TXBRK = %00000010 +PAREVEN = %00000001 +; SERCTL bit definitions for read operations +TXRDY = %10000000 +RXRDY = %01000000 +TXEMPTY = %00100000 +PARERR = %00010000 +OVERRUN = %00001000 +FRAMERR = %00000100 +RXBRK = %00000010 +PARBIT = %00000001 + +SERDAT = $FD8D +SDONEACK = $FD90 +CPUSLEEP = $FD91 +DISPCTL = $FD92 +; DISPCTL bit definitions +DISP_COLOR = %10000000 ; must be set to 1 +DISP_FOURBIT = %01000000 ; must be set to 1 +DISP_FLIP = %00100000 +DMA_ENABLE = %00010000 ; must be set to 1 + +PBKUP = $FD93 +DISPADRL = $FD94 +DISPADRH = $FD95 + +MTEST0 = $FD9C +; MTEST0 bit definitions +AT_CNT16 = %10000000 +AT_TEST = %01000000 +XCLKEN = %00100000 +UART_TURBO = %00010000 +ROM_SEL = %00001000 +ROM_TEST = %00000100 +M_TEST = %00000010 +CPU_TEST = %00000001 + +MTEST1 = $FD9D +; MTEST1 bit definitions +P_CNT16 = %01000000 +REF_CNT16 = %00100000 +VID_TRIG = %00010000 +REF_TRIG = %00001000 +VID_DMA_DIS = %00000100 +REF_FAST = %00000010 +REF_DIS = %00000001 + +MTEST2 = $FD9E +; MTEST2 bit definitions +V_STROBE = %00010000 +V_ZERO = %00001000 +H_120 = %00000100 +H_ZERO = %00000010 +V_BLANKEF = %00000001 + +PALETTE = $FDA0 ; hardware rgb palette +GCOLMAP = $FDA0 ; hardware rgb palette (green) +RBCOLMAP = $FDB0 ; hardware rgb palette (red-blue) + +; Memory mapping control and 6502 vectors + +MAPCTL = $FFF9 +; MAPCTL bit definitions +TURBO_DISABLE = %10000000 +VECTOR_SPACE = %00001000 ; 1 maps RAM into specified space +ROM_SPACE = %00000100 +MIKEY_SPACE = %00000010 +SUZY_SPACE = %00000001 + +VECTORS = $FFFB +INTVECTL = $FFFE +INTVECTH = $FFFF +RSTVECTL = $FFFC +RSTVECTH = $FFFD +NMIVECTL = $FFFA +NMIVECTH = $FFFB diff --git a/cc65/asminc/mega65.inc b/cc65/asminc/mega65.inc new file mode 100644 index 0000000..79a4e7b --- /dev/null +++ b/cc65/asminc/mega65.inc @@ -0,0 +1,239 @@ + +; --------------------------------------------------------------------------- +; Zero page, Commodore stuff + +TXTPTR := $3C ; Pointer into BASIC source code +STATUS := $90 ; Kernal I/O completion status +FNAM_LEN := $B7 ; Length of filename +SECADR := $B9 ; Secondary address +DEVNUM := $BA ; Device number +FNAM := $BB ; Address of filename +FNAM_BANK := $BE ; Bank for filename +KEY_COUNT := $D0 ; Number of keys in input buffer +FKEY_COUNT := $D1 ; Characters for function key +MODE := $D7 ; 40-/80-column mode (bit 7: 80 columns) +GRAPHM := $D8 ; Graphics mode flags (bits 5-7) +CHARDIS := $D9 ; Bit 2 shadow for location $01 +CURS_X := $EC ; Cursor column +CURS_Y := $EB ; Cursor row +SCREEN_PTR := $E0 ; Pointer to current char in text screen +CRAM_PTR := $E2 ; Pointer to current char in color RAM +CHARCOLOR := $F1 +RVS := $F3 ; Reverse output flag +SCROLL := $F8 ; Disable scrolling flag + +BASIC_BUF := $0200 ; Location of command-line +BASIC_BUF_LEN = 161 ; Maximum length of command-line + +FKEY_LEN := $1000 ; Function key lengths +FKEY_TEXT := $100A ; Function key texts + +PALFLAG := $1103 ; $FF=PAL, $00=NTSC +INIT_STATUS := $1104 ; Flags: Reset/Restore initiation status +TIME := $110C ; 60HZ clock + +KBDREPEAT := $111a +KBDREPEATRATE := $111b +KBDREPEATDELAY := $111c + +; --------------------------------------------------------------------------- +; Vectors + +IRQVec := $0314 +BRKVec := $0316 +NMIVec := $0318 + +; --------------------------------------------------------------------------- +; I/O: VIC + +VIC := $D000 +VIC_SPR0_X := $D000 +VIC_SPR0_Y := $D001 +VIC_SPR1_X := $D002 +VIC_SPR1_Y := $D003 +VIC_SPR2_X := $D004 +VIC_SPR2_Y := $D005 +VIC_SPR3_X := $D006 +VIC_SPR3_Y := $D007 +VIC_SPR4_X := $D008 +VIC_SPR4_Y := $D009 +VIC_SPR5_X := $D00A +VIC_SPR5_Y := $D00B +VIC_SPR6_X := $D00C +VIC_SPR6_Y := $D00D +VIC_SPR7_X := $D00E +VIC_SPR7_Y := $D00F +VIC_SPR_HI_X := $D010 +VIC_SPR_ENA := $D015 +VIC_SPR_EXP_Y := $D017 +VIC_SPR_EXP_X := $D01D +VIC_SPR_MCOLOR := $D01C +VIC_SPR_BG_PRIO := $D01B +VIC_SPR_COLL := $D01E +VIC_SPR_BG_COLL := $D01F + +VIC_SPR_MCOLOR0 := $D025 +VIC_SPR_MCOLOR1 := $D026 + +VIC_SPR0_COLOR := $D027 +VIC_SPR1_COLOR := $D028 +VIC_SPR2_COLOR := $D029 +VIC_SPR3_COLOR := $D02A +VIC_SPR4_COLOR := $D02B +VIC_SPR5_COLOR := $D02C +VIC_SPR6_COLOR := $D02D +VIC_SPR7_COLOR := $D02E + +VIC_CTRL1 := $D011 +VIC_CTRL2 := $D016 + +VIC_HLINE := $D012 + +VIC_LPEN_X := $D013 +VIC_LPEN_Y := $D014 + +VIC_VIDEO_ADR := $D018 + +VIC_IRR := $D019 ; Interrupt request register +VIC_IMR := $D01A ; Interrupt mask register + +VIC_BORDERCOLOR := $D020 +VIC_BG_COLOR0 := $D021 +VIC_BG_COLOR1 := $D022 +VIC_BG_COLOR2 := $D023 +VIC_BG_COLOR3 := $D024 + + +; --------------------------------------------------------------------------- +; I/O: FDC + +FDC := $D080 + +; --------------------------------------------------------------------------- +; I/O: SID + +SID0 := $D400 +SID0_S1Lo := $D400 +SID0_S1Hi := $D401 +SID0_PB1Lo := $D402 +SID0_PB1Hi := $D403 +SID0_Ctl1 := $D404 +SID0_AD1 := $D405 +SID0_SUR1 := $D406 + +SID0_S2Lo := $D407 +SID0_S2Hi := $D408 +SID0_PB2Lo := $D409 +SID0_PB2Hi := $D40A +SID0_Ctl2 := $D40B +SID0_AD2 := $D40C +SID0_SUR2 := $D40D + +SID0_S3Lo := $D40E +SID0_S3Hi := $D40F +SID0_PB3Lo := $D410 +SID0_PB3Hi := $D411 +SID0_Ctl3 := $D412 +SID0_AD3 := $D413 +SID0_SUR3 := $D414 + +SID0_FltLo := $D415 +SID0_FltHi := $D416 +SID0_FltCtl := $D417 +SID0_Amp := $D418 +SID0_ADConv1 := $D419 +SID0_ADConv2 := $D41A +SID0_Noise := $D41B +SID0_Read3 := $D41C + +SID1 := $D420 +SID1_S1Lo := $D420 +SID1_S1Hi := $D421 +SID1_PB1Lo := $D422 +SID1_PB1Hi := $D423 +SID1_Ctl1 := $D424 +SID1_AD1 := $D425 +SID1_SUR1 := $D426 + +SID1_S2Lo := $D427 +SID1_S2Hi := $D428 +SID1_PB2Lo := $D429 +SID1_PB2Hi := $D42A +SID1_Ctl2 := $D42B +SID1_AD2 := $D42C +SID1_SUR2 := $D42D + +SID1_S3Lo := $D42E +SID1_S3Hi := $D42F +SID1_PB3Lo := $D430 +SID1_PB3Hi := $D431 +SID1_Ctl3 := $D432 +SID1_AD3 := $D433 +SID1_SUR3 := $D434 + +SID1_FltLo := $D435 +SID1_FltHi := $D436 +SID1_FltCtl := $D437 +SID1_Amp := $D438 +SID1_ADConv1 := $D439 +SID1_ADConv2 := $D43A +SID1_Noise := $D43B +SID1_Read3 := $D43C + +; --------------------------------------------------------------------------- +; I/O: Complex Interface Adapters + +CIA1 := $DC00 +CIA1_PRA := $DC00 ; Port A +CIA1_PRB := $DC01 ; Port B +CIA1_DDRA := $DC02 ; Data direction register for port A +CIA1_DDRB := $DC03 ; Data direction register for port B +CIA1_TA := $DC04 ; 16-bit timer A +CIA1_TB := $DC06 ; 16-bit timer B +CIA1_TOD10 := $DC08 ; Time-of-day tenths of a second +CIA1_TODSEC := $DC09 ; Time-of-day seconds +CIA1_TODMIN := $DC0A ; Time-of-day minutes +CIA1_TODHR := $DC0B ; Time-of-day hours +CIA1_SDR := $DC0C ; Serial data register +CIA1_ICR := $DC0D ; Interrupt control register +CIA1_CRA := $DC0E ; Control register for timer A +CIA1_CRB := $DC0F ; Control register for timer B + +CIA2 := $DD00 +CIA2_PRA := $DD00 +CIA2_PRB := $DD01 +CIA2_DDRA := $DD02 +CIA2_DDRB := $DD03 +CIA2_TA := $DD04 +CIA2_TB := $DD06 +CIA2_TOD10 := $DD08 +CIA2_TODSEC := $DD09 +CIA2_TODMIN := $DD0A +CIA2_TODHR := $DD0B +CIA2_SDR := $DD0C +CIA2_ICR := $DD0D +CIA2_CRA := $DD0E +CIA2_CRB := $DD0F + +; --------------------------------------------------------------------------- +; I/O: DMA + +DMA := $D700 + + +; --------------------------------------------------------------------------- +; Processor Port at $01 + +LORAM = $01 ; Enable the basic rom +HIRAM = $02 ; Enable the kernal rom +IOEN = $04 ; Enable I/O +CASSDATA = $08 ; Cassette data +CASSPLAY = $10 ; Cassette: Play +CASSMOT = $20 ; Cassette motor on +TP_FAST = $80 ; Switch Rossmoeller TurboProcess to fast mode + +RAMONLY = $F8 ; (~(LORAM | HIRAM | IOEN)) & $FF + +; temporary, to get conio working +XSIZE = 80 +YSIZE = 50 diff --git a/cc65/asminc/modload.inc b/cc65/asminc/modload.inc new file mode 100644 index 0000000..168dd67 --- /dev/null +++ b/cc65/asminc/modload.inc @@ -0,0 +1,78 @@ +;*****************************************************************************/ +;* */ +;* modload.inc */ +;* */ +;* o65 module loader interface for cc65 */ +;* */ +;* */ +;* */ +;* (C) 2002 Ullrich von Bassewitz */ +;* Wacholderweg 14 */ +;* D-70597 Stuttgart */ +;* EMail: uz@musoftware.de */ +;* */ +;* */ +;* 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. */ +;* */ +;*****************************************************************************/ + + + +; Exports structures and functions to load relocatable o65 modules at +; runtime. + + + +; Offsets for the mod_ctrl struct. This struct is passed to the module loader. +; It contains stuff, the loader needs to work, and another area where the +; loader will place informational data if it was successful. You will have to +; check the return code of mod_load before accessing any of these additional +; struct members. +.struct MOD_CTRL + READ .addr + CALLERDATA .word + MODULE .addr ; Pointer to module data + MODULE_SIZE .word ; Total size of loaded module + MODULE_ID .word +.endstruct + +; unsigned char mod_load (struct mod_ctrl* ctrl); +; /* Load a module into memory and relocate it. The function will return an +; * error code (see below). If MLOAD_OK is returned, the outgoing fields in +; * the passed mod_ctrl struct contain information about the module just +; * loaded. +; */ +.global _mod_load + +; void mod_free (void* module); +; /* Free a loaded module. Note: The given pointer is the pointer to the +; * module memory, not a pointer to a control structure. +; */ +.global _mod_free + +; Errors +.enum + MLOAD_OK ; Module load successful + MLOAD_ERR_READ ; Read error + MLOAD_ERR_HDR ; Header error + MLOAD_ERR_OS ; Wrong OS + MLOAD_ERR_FMT ; Data format error + MLOAD_ERR_MEM ; Not enough memory +.endenum + + diff --git a/cc65/asminc/module.mac b/cc65/asminc/module.mac new file mode 100644 index 0000000..d844ec1 --- /dev/null +++ b/cc65/asminc/module.mac @@ -0,0 +1,13 @@ +.ifndef DYN_DRV + DYN_DRV = 1 +.endif + +.macro module_header module_label + .if DYN_DRV + .segment "HEADER" + .else + .data + .export module_label + module_label: + .endif +.endmacro diff --git a/cc65/asminc/mouse-kernel.inc b/cc65/asminc/mouse-kernel.inc new file mode 100644 index 0000000..ab4790d --- /dev/null +++ b/cc65/asminc/mouse-kernel.inc @@ -0,0 +1,184 @@ +;/*****************************************************************************/ +;/* */ +;/* mouse-kernel.inc */ +;/* */ +;/* Mouse API */ +;/* */ +;/* */ +;/* */ +;/* (C) 2003-2009, Ullrich von Bassewitz */ +;/* Roemerstrasse 52 */ +;/* D-70794 Filderstadt */ +;/* EMail: uz@cc65.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. */ +;/* */ +;/*****************************************************************************/ + + + + +;------------------------------------------------------------------------------ +; Error codes + +.enum + MOUSE_ERR_OK ; No error + MOUSE_ERR_NO_DRIVER ; No driver available + MOUSE_ERR_CANNOT_LOAD ; Error loading driver + MOUSE_ERR_INV_DRIVER ; Invalid driver + MOUSE_ERR_NO_DEVICE ; Mouse hardware not found + MOUSE_ERR_INV_IOCTL ; Invalid ioctl code + + MOUSE_ERR_COUNT ; Special: Number of error codes +.endenum + +;------------------------------------------------------------------------------ +; The driver header + +.struct MOUSE_HDR + ID .byte 3 ; Contains 0x6D, 0x6F, 0x75 ("mou") + VERSION .byte 1 ; Interface version + LIBREF .addr ; Library reference + JUMPTAB .struct + INSTALL .addr + UNINSTALL .addr + HIDE .addr + SHOW .addr + SETBOX .addr + GETBOX .addr + MOVE .addr + BUTTONS .addr + POS .addr + INFO .addr + IOCTL .addr + IRQ .addr + .endstruct + FLAGS .byte ; Mouse driver flags + CALLBACKS .struct ; Jump instructions + .byte ; JMP opcode + CHIDE .addr ; Jump address + .byte + CSHOW .addr + .byte + CPREP .addr + .byte + CDRAW .addr + .byte + CMOVEX .addr + .byte + CMOVEY .addr + .endstruct +.endstruct + +;------------------------------------------------------------------------------ +; The mouse callback structure + +.struct MOUSE_CALLBACKS + HIDE .addr ; Hide the mouse cursor + SHOW .addr ; Show the mouse cursor + PREP .addr ; Prepare to move the mouse cursor + DRAW .addr ; Draw the mouse cursor + MOVEX .addr ; Move the mouse cursor to X coord + MOVEY .addr ; Move the mouse cursor to Y coord +.endstruct + +;------------------------------------------------------------------------------ +; The mouse API version, stored in MOUSE_HDR::VERSION + +MOUSE_API_VERSION = $06 + +;------------------------------------------------------------------------------ +; Bitmapped mouse driver flags, stored in MOUSE_HDR::FLAGS. +; Note: If neither of MOUSE_FLAG_XXX_IRQ is set, no interrupts are supplied +; to the driver. If one of the bits is set, the interrupt vector MUST be +; valid. +; Beware: Some of the bits are tested using the BIT instruction, so do not +; change the values without checking the code! + +MOUSE_FLAG_EARLY_IRQ = $40 ; Enable IRQ *before* calling INSTALL +MOUSE_FLAG_LATE_IRQ = $80 ; Enable IRQ *after* calling INSTALL + +;------------------------------------------------------------------------------ +; Mouse button definitions + +MOUSE_BTN_LEFT = $10 +MOUSE_BTN_RIGHT = $01 + +;------------------------------------------------------------------------------ +; Structures used to return data from the mouse driver + +.struct MOUSE_POS + XCOORD .word + YCOORD .word +.endstruct + +.struct MOUSE_INFO + POS .tag MOUSE_POS + BUTTONS .byte +.endstruct + +.struct MOUSE_BOX + MINX .word + MINY .word + MAXX .word + MAXY .word +.endstruct + +;------------------------------------------------------------------------------ +; Variables + + .global _mouse_drv ; Pointer to driver + .global _mouse_hidden ; Counter, 0 = mouse is visible + +;------------------------------------------------------------------------------ +; C callable functions + + .global _mouse_load_driver + .global _mouse_unload + .global _mouse_install + .global _mouse_uninstall + .global _mouse_geterrormsg + .global _mouse_hide + .global _mouse_show + .global _mouse_setbox + .global _mouse_getbox + .global _mouse_move + .global _mouse_buttons + .global _mouse_pos + .global _mouse_info + .global _mouse_ioctl + + .global _mouse_clear_ptr + +;------------------------------------------------------------------------------ +; Driver entry points (asm callable) + + .global mouse_install + .global mouse_uninstall + .global mouse_hide + .global mouse_show + .global mouse_setbox + .global mouse_getbox + .global mouse_move + .global mouse_buttons + .global mouse_pos + .global mouse_info + .global mouse_ioctl diff --git a/cc65/asminc/nes.inc b/cc65/asminc/nes.inc new file mode 100644 index 0000000..cc83d7c --- /dev/null +++ b/cc65/asminc/nes.inc @@ -0,0 +1,93 @@ +; +; NES definitions. By Groepaz/Hitmem. +; + + +;; FIXME: optimize zeropage usage + +SCREEN_PTR = $62 ;2 +CRAM_PTR = $64 ;2 +CHARCOLOR = $66 +BGCOLOR = $67 +RVS = $68 +CURS_X = $69 +CURS_Y = $6a + +tickcount = $6b ;2 + +VBLANK_FLAG = $70 + +ringbuff = $0200 +ringwrite = $71 +ringread = $72 +ringcount = $73 + +ppuhi = $74 +ppulo = $75 +ppuval = $76 + +screenrows = (30-1) +charsperline = 32 +xsize = charsperline + +;; PPU defines + +PPU_CTRL1 = $2000 +PPU_CTRL2 = $2001 +PPU_STATUS = $2002 +PPU_SPR_ADDR = $2003 +PPU_SPR_IO = $2004 +PPU_VRAM_ADDR1 = $2005 +PPU_VRAM_ADDR2 = $2006 +PPU_VRAM_IO = $2007 + +;; APU defines + +APU_PULSE1CTRL = $4000 ; Pulse #1 Control Register (W) +APU_PULSE1RAMP = $4001 ; Pulse #1 Ramp Control Register (W) +APU_PULSE1FTUNE = $4002 ; Pulse #1 Fine Tune (FT) Register (W) +APU_PULSE1CTUNE = $4003 ; Pulse #1 Coarse Tune (CT) Register (W) +APU_PULSE2CTRL = $4004 ; Pulse #2 Control Register (W) +APU_PULSE2RAMP = $4005 ; Pulse #2 Ramp Control Register (W) +APU_PULSE2FTUNE = $4006 ; Pulse #2 Fine Tune Register (W) +APU_PULSE2STUNE = $4007 ; Pulse #2 Coarse Tune Register (W) +APU_TRICTRL1 = $4008 ; Triangle Control Register #1 (W) +APU_TRICTRL2 = $4009 ; Triangle Control Register #2 (?) +APU_TRIFREQ1 = $400A ; Triangle Frequency Register #1 (W) +APU_TRIFREQ2 = $400B ; Triangle Frequency Register #2 (W) +APU_NOISECTRL = $400C ; Noise Control Register #1 (W) +;;APU_ = $400D ; Unused (???) +APU_NOISEFREQ1 = $400E ; Noise Frequency Register #1 (W) +APU_NOISEFREQ2 = $400F ; Noise Frequency Register #2 (W) +APU_MODCTRL = $4010 ; Delta Modulation Control Register (W) +APU_MODDA = $4011 ; Delta Modulation D/A Register (W) +APU_MODADDR = $4012 ; Delta Modulation Address Register (W) +APU_MODLEN = $4013 ; Delta Modulation Data Length Register (W) +APU_SPR_DMA = $4014 ; Sprite DMA Register (W) +APU_CHANCTRL = $4015 ; Sound/Vertical Clock Signal Register (R) +APU_PAD1 = $4016 ; Joypad #1 (RW) +APU_PAD2 = $4017 ; Joypad #2/SOFTCLK (RW) + + +CH_HLINE = 11 +CH_VLINE = 14 +CH_ULCORNER = 176 +CH_URCORNER = 174 +CH_LLCORNER = 173 +CH_LRCORNER = 189 +CH_TTEE = 178 +CH_RTEE = 179 +CH_BTEE = 177 +CH_LTEE = 171 +CH_CROSS = 123 +CH_CURS_UP = 145 +CH_CURS_DOWN = 17 +CH_CURS_LEFT = 157 +CH_CURS_RIGHT = 29 +CH_PI = 126 +CH_DEL = 20 +CH_INS = 148 +CH_ENTER = 10 +CH_STOP = 3 +CH_ESC = 27 + diff --git a/cc65/asminc/o65.inc b/cc65/asminc/o65.inc new file mode 100644 index 0000000..6e0caa7 --- /dev/null +++ b/cc65/asminc/o65.inc @@ -0,0 +1,150 @@ +;*****************************************************************************/ +;* */ +;* o65.inc */ +;* */ +;* Definitions for the o65 file format */ +;* */ +;* */ +;* */ +;* (C) 2002-2009, Ullrich von Bassewitz */ +;* Roemerstrasse 52 */ +;* D-70794 Filderstadt */ +;* EMail: uz@cc65.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. */ +;* */ +;*****************************************************************************/ + + + +; This files exports structures and constants to handle the o65 relocatable +; file format as defined by Andre Fachat. + + + +; The o65 header structure (6502 format) +.struct O65_HDR + MARKER .byte 2 ; Non-C64 marker: $01 $00 + MAGIC .byte 3 ; o65 magic: "o65" + VERSION .byte 1 ; Version number + MODE .word ; Mode word + TBASE .word ; Original text (code) segment address + TLEN .word ; Size of text (code) segment + DBASE .word ; Original data segment address + DLEN .word ; Size of data segment + BBASE .word ; Original bss segment address + BLEN .word ; Size of bss segment + ZBASE .word ; Original zp segment address + ZLEN .word ; Size of zp segment + STACK .word ; Stacksize needed +.endstruct + +; Marker, magic and version number +O65_MARKER_0 = $01 +O65_MARKER_1 = $00 +O65_MAGIC_0 = $6F ; 'o' +O65_MAGIC_1 = $36 ; '6' +O65_MAGIC_2 = $35 ; '5' +O65_VERSION = $00 + +; Defines for the mode word +O65_CPU_65816 = $8000 ; Executable is for 65816 +O65_CPU_6502 = $0000 ; Executable is for the 6502 +O65_CPU_MASK = $8000 ; Mask to extract CPU type + +O65_RELOC_PAGE = $4000 ; Page wise relocation +O65_RELOC_BYTE = $0000 ; Byte wise relocation +O65_RELOC_MASK = $4000 ; Mask to extract relocation type + +O65_SIZE_32BIT = $2000 ; All size words are 32bit +O65_SIZE_16BIT = $0000 ; All size words are 16bit +O65_SIZE_MASK = $2000 ; Mask to extract size + +O65_FTYPE_OBJ = $1000 ; Object file +O65_FTYPE_EXE = $0000 ; Executable file +O65_FTYPE_MASK = $1000 ; Mask to extract type + +O65_ADDR_SIMPLE = $0800 ; Simple addressing +O65_ADDR_DEFAULT = $0000 ; Default addressing +O65_ADDR_MASK = $0800 ; Mask to extract addressing + +O65_CHAIN = $0400 ; Chained file, another one follows +O65_CHAIN_MASK = $0400 ; Mask to extract chain flag + +O65_BSSZERO = $0200 ; BSS segment must be zeroed +O65_BSSZERO_MASK = $0200 ; Mask to extract bss zero flag + +; The following is used if O65_CPU == 6502 +O65_CPU2_6502 = $0000 ; Executable is for 6502 +O65_CPU2_65C02 = $0010 ; Executable is for 65C02 +O65_CPU2_65SC02 = $0020 ; Executable is for 65SC02 +O65_CPU2_65CE02 = $0030 ; Executable is for 65CE02 +O65_CPU2_6502X = $0040 ; Executable is for NMOS 6502 +O65_CPU2_65816_EMU = $0050 ; Executable is for 65816 in emul mode +O65_CPU2_MASK = $00F0 ; Mask to extract CPU2 field + +O65_ALIGN_1 = $0000 ; Bytewise alignment +O65_ALIGN_2 = $0001 ; Align words +O65_ALIGN_4 = $0002 ; Align longwords +O65_ALIGN_256 = $0003 ; Align pages (256 bytes) +O65_ALIGN_MASK = $0003 ; Mask to extract alignment + +; The mode word as generated by the ld65 linker +O65_MODE_CC65 = O65_CPU_6502 | O65_RELOC_BYTE | O65_SIZE_16BIT | O65_FTYPE_EXE | O65_ADDR_SIMPLE | O65_ALIGN_1 + +; Relocation type codes +O65_RTYPE_WORD = $80 +O65_RTYPE_HIGH = $40 +O65_RTYPE_LOW = $20 +O65_RTYPE_SEGADDR = $C0 +O65_RTYPE_SEG = $A0 +O65_RTYPE_MASK = $E0 + +; Segment IDs +O65_SEGID_UNDEF = $00 +O65_SEGID_ABS = $01 +O65_SEGID_TEXT = $02 +O65_SEGID_DATA = $03 +O65_SEGID_BSS = $04 +O65_SEGID_ZP = $05 +O65_SEGID_MASK = $07 + +; Option tags +O65_OPT_FILENAME = 0 +O65_OPT_OS = 1 +O65_OPT_ASM = 2 +O65_OPT_AUTHOR = 3 +O65_OPT_TIMESTAMP = 4 + +; Operating system codes for O65_OPT_OS +O65_OS_OSA65 = 1 +O65_OS_LUNIX = 2 +O65_OS_CC65 = 3 +O65_OS_OPENCBM = 4 + +; Load errors +O65_LOAD_OK = 0 ; Module load successful +O65_LOAD_ERR_READ = 1 ; Read error +O65_LOAD_ERR_HDR = 2 ; Header error +O65_LOAD_ERR_OS = 3 ; Wrong OS +O65_LOAD_ERR_FMT = 4 ; Data format error +O65_LOAD_ERR_MEM = 5 ; Not enough memory + + + diff --git a/cc65/asminc/opcodes.inc b/cc65/asminc/opcodes.inc new file mode 100644 index 0000000..a5406e5 --- /dev/null +++ b/cc65/asminc/opcodes.inc @@ -0,0 +1,514 @@ +; opcodes.inc +; ca65 6502 - opcode definitions, mainly for self modifying code +; +; Christian Krüger, latest change: 18-Sep-2010 +; +; 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. +; + +; Opcode-Table +; ------------ +; Post fix explanation: +; imm = #$00 +; zp = $00 +; zpx = $00,X +; zpy = $00,Y +; izp = ($00) +; izx = ($00,X) +; izy = ($00),Y +; abs = $0000 +; abx = $0000,X +; aby = $0000,Y +; ind = ($0000) +; iax = ($0000,X) +; rel = $0000 (PC-relative) (supressed here) + +OPC_BRK = $00 +OPC_ORA_izx = $01 +OPC_ORA_zp = $05 +OPC_ASL_zp = $06 +OPC_PHP = $08 +OPC_ORA_imm = $09 +OPC_ASL = $0A +OPC_ORA_abs = $0D +OPC_ASL_abs = $0E + +OPC_BPL = $10 +OPC_ORA_izy = $11 +OPC_ORA_zpx = $15 +OPC_ASL_zpx = $16 +OPC_CLC = $18 +OPC_ORA_aby = $19 +OPC_ORA_abx = $1D +OPC_ASL_abx = $1E + +OPC_JSR_abs = $20 +OPC_AND_izx = $21 +OPC_BIT_zp = $24 +OPC_AND_zp = $25 +OPC_ROL_zp = $26 +OPC_PLP = $28 +OPC_AND_imm = $29 +OPC_ROL = $2A +OPC_BIT_abs = $2C +OPC_AND_abs = $2D +OPC_ROL_abs = $2E + +OPC_BMI = $30 +OPC_AND_izy = $31 +OPC_AND_zpx = $35 +OPC_ROL_zpx = $36 +OPC_SEC = $38 +OPC_AND_aby = $39 +OPC_AND_abx = $3D +OPC_ROL_abx = $3E + + +OPC_RTI = $40 +OPC_EOR_izx = $41 +OPC_EOR_zp = $45 +OPC_LSR_zp = $46 +OPC_PHA = $48 +OPC_EOR_imm = $49 +OPC_LSR = $4A +OPC_JMP_abs = $4C +OPC_EOR_abs = $4D +OPC_LSR_abs = $4E + +OPC_BVC = $50 +OPC_EOR_izy = $51 +OPC_EOR_zpx = $55 +OPC_LSR_zpx = $56 +OPC_CLI = $58 +OPC_EOR_aby = $59 +OPC_EOR_abx = $5D +OPC_LSR_abx = $5E + +OPC_RTS = $60 +OPC_ADC_izx = $61 +OPC_ADC_zp = $65 +OPC_ROR_zp = $66 +OPC_PLA = $68 +OPC_ADC_imm = $69 +OPC_ROR = $6A +OPC_JMP_ind = $6C +OPC_ADC_abs = $6D +OPC_ROR_abs = $6E + +OPC_BVS = $70 +OPC_ADC_izy = $71 +OPC_ADC_zpx = $75 +OPC_ROR_zpx = $76 +OPC_SEI = $78 +OPC_ADC_aby = $79 +OPC_ADC_abx = $7D +OPC_ROR_abx = $7E + +OPC_STA_izx = $81 +OPC_STY_zp = $84 +OPC_STA_zp = $85 +OPC_STX_zp = $86 +OPC_DEY = $88 +OPC_TXA = $8A +OPC_STY_abs = $8C +OPC_STA_abs = $8D +OPC_STX_abs = $8E + +OPC_BCC = $90 +OPC_STA_izy = $91 +OPC_STY_zpx = $94 +OPC_STA_zpx = $95 +OPC_STX_zpy = $96 +OPC_TYA = $98 +OPC_STA_aby = $99 +OPC_TXS = $9A +OPC_STA_abx = $9D + +OPC_LDY_imm = $A0 +OPC_LDA_izx = $A1 +OPC_LDX_imm = $A2 +OPC_LDY_zp = $A4 +OPC_LDA_zp = $A5 +OPC_LDX_zp = $A6 +OPC_TAY = $A8 +OPC_LDA_imm = $A9 +OPC_TAX = $AA +OPC_LDY_abs = $AC +OPC_LDA_abs = $AD +OPC_LDX_abs = $AE + +OPC_BCS = $B0 +OPC_LDA_izy = $B1 +OPC_LDY_zpx = $B4 +OPC_LDA_zpx = $B5 +OPC_LDX_zpy = $B6 +OPC_CLV = $B8 +OPC_LDA_aby = $B9 +OPC_TSX = $BA +OPC_LDY_abx = $BC +OPC_LDA_abx = $BD +OPC_LDX_aby = $BE + +OPC_CPY_imm = $C0 +OPC_CMP_izx = $C1 +OPC_CPY_zp = $C4 +OPC_CMP_zp = $C5 +OPC_DEC_zp = $C6 +OPC_INY = $C8 +OPC_CMP_imm = $C9 +OPC_DEX = $CA +OPC_CPY_abs = $CC +OPC_CMP_abs = $CD +OPC_DEC_abs = $CE + +OPC_BNE = $D0 +OPC_CMP_izy = $D1 +OPC_CMP_zpx = $D5 +OPC_DEC_zpx = $D6 +OPC_CLD = $D8 +OPC_CMP_aby = $D9 +OPC_CMP_abx = $DD +OPC_DEC_abx = $DE + +OPC_CPX_imm = $E0 +OPC_SBC_izx = $E1 +OPC_CPX_zp = $E4 +OPC_SBC_zp = $E5 +OPC_INC_zp = $E6 +OPC_INX = $E8 +OPC_SBC_imm = $E9 +OPC_NOP = $EA +OPC_CPX_abs = $EC +OPC_SBC_abs = $ED +OPC_INC_abs = $EE + + +OPC_BEQ = $F0 +OPC_SBC_izy = $F1 +OPC_SBC_zpx = $F5 +OPC_INC_zpx = $F6 +OPC_SED = $F8 +OPC_SBC_aby = $F9 +OPC_SBC_abx = $FD +OPC_INC_abx = $FE + + +.if (.cpu .bitand ::CPU_ISET_65SC02) + +; OPC_NOP = $02 ; doublet +; OPC_NOP = $03 ; doublet +OPC_TSB_zp = $04 +; OPC_NOP = $0B ; doublet +OPC_TSB_abs = $0C + +OPC_ORA_izp = $12 +; OPC_NOP = $13 ; doublet +OPC_TRB_zp = $14 +OPC_INC = $1A +; OPC_NOP = $1B ; doublet +OPC_TRB_abs = $1C + +; OPC_NOP = $22 ; doublet +; OPC_NOP = $23 ; doublet +; OPC_NOP = $2B ; doublet + +OPC_AND_izp = $32 +; OPC_NOP = $33 ; doublet +OPC_BIT_zpx = $34 +OPC_DEC = $3A +; OPC_NOP = $3B ; doublet +OPC_BIT_abx = $3C + +; OPC_NOP = $42 ; doublet +; OPC_NOP = $43 ; doublet +; OPC_NOP = $44 ; doublet +; OPC_NOP = $4B ; doublet + +OPC_EOR_izp = $52 +; OPC_NOP = $53 ; doublet +; OPC_NOP = $54 ; doublet +; OPC_NOP = $5A ; doublet +; OPC_NOP = $5B ; doublet + +; OPC_NOP = $62 ; doublet +; OPC_NOP = $63 ; doublet +OPC_STZ_zp = $64 +; OPC_NOP = $6B ; doublet + +OPC_ADC_izp = $72 +; OPC_NOP = $73 ; doublet +OPC_STZ_zpx = $74 +OPC_PLY = $7A +; OPC_NOP = $7B ; doublet +OPC_JMP_iax = $7C + +OPC_BRA = $80 +; OPC_NOP = $82 ; doublet +; OPC_NOP = $83 ; doublet +OPC_BIT_imm = $89 +; OPC_NOP = $8B ; doublet + +OPC_STA_izp = $92 +; OPC_NOP = $93 ; doublet +; OPC_NOP = $9B ; doublet +OPC_STZ_abs = $9C +OPC_STZ_abx = $9E + +; OPC_NOP = $A3 ; doublet +; OPC_NOP = $AB ; doublet + +OPC_LDA_izp = $B2 +; OPC_NOP = $B3 ; doublet +; OPC_NOP = $BB ; doublet + +; OPC_NOP = $C2 ; doublet +; OPC_NOP = $C3 ; doublet +; OPC_NOP = $CB ; doublet + +OPC_CMP_izp = $D2 +; OPC_NOP = $D3 ; doublet +; OPC_NOP = $D4 ; doublet +OPC_PHX = $DA +; OPC_NOP = $DB ; doublet +; OPC_NOP = $DC ; doublet + +; OPC_NOP = $E2 ; doublet +; OPC_NOP = $E3 ; doublet +; OPC_NOP = $EB ; doublet + +OPC_SBC_izp = $F2 +; OPC_NOP = $F3 ; doublet +; OPC_NOP = $F4 ; doublet +OPC_PLX = $FA +; OPC_NOP = $FB ; doublet +; OPC_NOP = $FC ; doublet + + +.if (.cpu .bitand ::CPU_ISET_65C02) + +; bit instructions for 65C02 + +OPC_RMB0 = $07 +OPC_RMB1 = $17 +OPC_RMB2 = $27 +OPC_RMB3 = $37 +OPC_RMB4 = $47 +OPC_RMB5 = $57 +OPC_RMB6 = $67 +OPC_RMB7 = $77 + +OPC_SMB0 = $87 +OPC_SMB1 = $97 +OPC_SMB2 = $A7 +OPC_SMB3 = $B7 +OPC_SMB4 = $C7 +OPC_SMB5 = $D7 +OPC_SMB6 = $E7 +OPC_SMB7 = $F7 + +OPC_BBR0 = $0F +OPC_BBR1 = $1F +OPC_BBR2 = $2F +OPC_BBR3 = $3F +OPC_BBR4 = $4F +OPC_BBR5 = $5F +OPC_BBR6 = $6F +OPC_BBR7 = $7F + +OPC_BBS0 = $8F +OPC_BBS1 = $9F +OPC_BBS2 = $AF +OPC_BBS3 = $BF +OPC_BBS4 = $CF +OPC_BBS5 = $DF +OPC_BBS6 = $EF +OPC_BBS7 = $FF + +.else + +; no bit instructions for 65SC02 + +; OPC_NOP = $07 ; doublet +; OPC_NOP = $17 ; doublet +; OPC_NOP = $27 ; doublet +; OPC_NOP = $37 ; doublet +; OPC_NOP = $47 ; doublet +; OPC_NOP = $57 ; doublet +; OPC_NOP = $67 ; doublet +; OPC_NOP = $77 ; doublet +; OPC_NOP = $87 ; doublet +; OPC_NOP = $97 ; doublet +; OPC_NOP = $A7 ; doublet +; OPC_NOP = $B7 ; doublet +; OPC_NOP = $C7 ; doublet +; OPC_NOP = $D7 ; doublet +; OPC_NOP = $E7 ; doublet +; OPC_NOP = $F7 ; doublet +; OPC_NOP = $0F ; doublet +; OPC_NOP = $1F ; doublet +; OPC_NOP = $2F ; doublet +; OPC_NOP = $3F ; doublet +; OPC_NOP = $4F ; doublet +; OPC_NOP = $5F ; doublet +; OPC_NOP = $6F ; doublet +; OPC_NOP = $7F ; doublet +; OPC_NOP = $8F ; doublet +; OPC_NOP = $9F ; doublet +; OPC_NOP = $AF ; doublet +; OPC_NOP = $BF ; doublet +; OPC_NOP = $CF ; doublet +; OPC_NOP = $DF ; doublet +; OPC_NOP = $EF ; doublet +; OPC_NOP = $FF ; doublet + +.endif + +.elseif (.cpu .bitand ::CPU_ISET_6502X) + +; stable, undocumented opcodes + +; OPC_KIL = $02 ; unstable +OPC_SLO_izx = $03 +OPC_NOP_zp = $04 +OPC_SLO_zp = $07 +OPC_ANC_imm = $0B +OPC_NOP_abs = $0C +OPC_SLO_abs = $0F + +; OPC_KIL = $12 ; unstable +OPC_SLO_izy = $13 +OPC_NOP_zpx = $14 +OPC_SLO_zpx = $17 +;OPC_NOP = $1A +OPC_SLO_aby = $1B +OPC_NOP_abx = $1C +OPC_SLO_abx = $1F + +; OPC_KIL = $22 ; unstable +OPC_RLA_izx = $23 +OPC_RLA_zp = $27 +OPC_ANC_imm = $2B +OPC_RLA_abs = $2F + +; OPC_KIL = $32 ; unstable +OPC_RLA_izy = $33 +OPC_NOP_zpx = $34 +OPC_RLA_zpx = $37 +; OPC_NOP = $3A ; doublet +OPC_RLA_aby = $3B +OPC_NOP_abx = $3C +OPC_RLA_abx = $3F + +; OPC_KIL = $42 ; unstable +OPC_SRE_izx = $43 +OPC_NOP_zp = $44 +OPC_SRE_zp = $47 +OPC_ALR_imm = $4B +OPC_SRE_abs = $4F + +; OPC_KIL = $52 ; unstable +OPC_SRE_izy = $53 +OPC_NOP_zpx = $54 +OPC_SRE_zpx = $57 +; OPC_NOP = $5A ; doublet +OPC_SRE_aby = $5B +OPC_NOP_abx = $5C +OPC_SRE_abx = $5F + +; OPC_KIL = $62 +OPC_RRA_izx = $63 +OPC_NOP_zp = $64 +OPC_RRA_zp = $67 +OPC_ARR_imm = $6B +OPC_RRA_abs = $6F + +; OPC_KIL = $72 +OPC_RRA_izy = $73 +OPC_NOP_zpx = $74 +OPC_RRA_zpx = $77 +; OPC_NOP = $7A ; doublet +OPC_RRA_aby = $7B +OPC_NOP_abx = $7C +OPC_RRA_abx = $7F + +OPC_NOP_imm = $80 +; OPC_NOP_imm = $82 ; doublet +OPC_SAX_izx = $83 +OPC_SAX_zp = $87 +; OPC_NOP_imm = $89 ; doublet +; OPC_XAA = $8B ; unstable +OPC_SAX_abs = $8F + +; OPC_KIL = $92 ; unstable +; OPC_AHX_izy = $93 ; unstable +OPC_SAX_zpy = $97 +; OPC_TAS_aby = $9B ; unstable +; OPC_SHY_abx = $9C ; unstable +; OPC_SHX_aby = $9E ; unstable +; OPC_AHX_aby = $9F ; unstable + +OPC_LAX_izx = $A3 +OPC_LAX_zp = $A7 +; OPC_LAX_imm = $AB ; unstable +OPC_LAX_abs = $AF + +; OPC_KIL = $B2 ; unstable +OPC_LAX_izy = $B3 +OPC_LAX_zpy = $B7 +OPC_LAS_aby = $BB +OPC_LAX_aby = $BF + +; OPC_NOP_imm = $C2 ; doublet +OPC_DCP_izx = $C3 +OPC_DCP_zp = $C7 +OPC_AXS_imm = $CB +OPC_DCP_abs = $CF + +; OPC_KIL = $D2 ; unstable +OPC_DCP_izy = $D3 +OPC_NOP_zpx = $D4 +OPC_DCP_zpx = $D7 +OPC_NOP_DA = $DA +OPC_DCP_aby = $DB +OPC_NOP_abx = $DC +OPC_DCP_abx = $DF + +; OPC_NOP_imm = $E2 ; doublet +OPC_ISC_izx = $E3 +OPC_ISC_zp = $E7 +; OPC_SBC_imm = $EB ; doublet +OPC_ISC_abs = $EF + +; OPC_KIL = $F2 ; unstable +OPC_ISC_izy = $F3 +OPC_NOP_zpx = $F4 +OPC_ISC_zpx = $F7 +OPC_NOP_FA = $FA +OPC_ISC_aby = $FB +OPC_NOP_abx = $FC +OPC_ISC_abx = $FF + +.if (.cpu .bitand ::CPU_ISET_6502DTV) + +OPC_BRA = $12 +OPC_SAC_imm = $32 +OPC_SIR_imm = $42 + +.endif + +.endif diff --git a/cc65/asminc/pce.inc b/cc65/asminc/pce.inc new file mode 100644 index 0000000..8d141e8 --- /dev/null +++ b/cc65/asminc/pce.inc @@ -0,0 +1,93 @@ +; +; PCE definitions. By Groepaz/Hitmen. +; + +; FIXME: Screen dimensions can change according to the selected video mode. +screenrows = (224/8) +charsperline = 61 + +CH_HLINE = 1 +CH_VLINE = 2 + +; HuC6270 -- Video Display Controller (VDC) + +VDC_MAWR = 0 ; Memory Address Write Register +VDC_MARR = 1 ; Memory Address Read Register +VDC_VWR = 2 ; VRAM Write Register +VDC_VRR = 2 ; VRAM Read Register +VDC_UNK03 = 3 ; (unknown) +VDC_UNK04 = 4 ; (unknown) +VDC_CR = 5 ; Control Register +VDC_RCR = 6 ; Raster Counter Register +VDC_BXR = 7 ; Background X-Scroll Register +VDC_BYR = 8 ; Background Y-Scroll Register +VDC_MWR = 9 ; Memory-access Width Register +VDC_HSR = 10 ; Horizontal Sync Register +VDC_HDR = 11 ; Horizontal Display Register +VDC_VSR = 12 ; Vertical sync Register +VDC_VDR = 13 ; Vertical Display register +VDC_VCR = 14 ; Vertical display END position register +VDC_DCR = 15 ; (DMA) Control Register +VDC_SOUR = 16 ; (DMA) Source Register +VDC_DESR = 17 ; (DMA) Destination Register +VDC_LENR = 18 ; (DMA) Length Register +VDC_SATB = 19 ; Sprite Attribute Table + +; VDC port +; Note: The zero-page addressing mode is redirected to page $20. +; We avoid it by using mirror locations that are outside of the zero page. + +VDC_CTRL := $0200 +VDC_DATA_LO := $0202 +VDC_DATA_HI := $0203 + +; HuC6260 -- Video Color Encoder (VCE) + +; The DAC has a palette of 512 colours. +; The bitmap of that data is 0000000gggrrrbbb (Green, Red, Blue). +; You can read and write the DAC registers. + +VCE := $0400 ; base + +VCE_CTRL := $0400 ; write $00 to reset +VCE_ADDR_LO := $0402 ; LSB of byte offset into palette +VCE_ADDR_HI := $0403 ; MSB of byte offset into palette +VCE_DATA_LO := $0404 ; LSB of 16-bit palette data +VCE_DATA_HI := $0405 ; MSB of 16-bit palette data + +; Programmable Sound Generator (PSG) + +PSG := $0800 ; base + +PSG_CHAN_SELECT := $0800 +PSG_GLOBAL_PAN := $0801 +PSG_FREQ_LO := $0802 +PSG_FREQ_HI := $0803 +PSG_CHAN_CTRL := $0804 +PSG_CHAN_PAN := $0805 +PSG_CHAN_DATA := $0806 +PSG_NOISE := $0807 +PSG_LFO_FREQ := $0808 +PSG_LFO_CTRL := $0809 + +; Timer + +TIMER := $0C00 ; base + +TIMER_COUNT := $0C00 +TIMER_CTRL := $0C01 + +JOY_CTRL := $1000 + +IRQ_MASK := $1402 +IRQ_STATUS := $1403 + +CDR_MEM_DISABLE := $1803 +CDR_MEM_ENABLE := $1807 + +; Write to a VDC register. +.macro VREG arg1, arg2 + st0 #arg1 + st1 #<(arg2) + st2 #>(arg2) +.endmacro diff --git a/cc65/asminc/pet.inc b/cc65/asminc/pet.inc new file mode 100644 index 0000000..c510102 --- /dev/null +++ b/cc65/asminc/pet.inc @@ -0,0 +1,100 @@ +; +; PET generic definitions. +; + + +; --------------------------------------------------------------------------- +; Zero page, Commodore stuff + +VARTAB := $2A ; Pointer to start of BASIC variables +MEMSIZE := $34 ; Size of memory installed +TXTPTR := $77 ; Pointer into BASIC source code +TIME := $8D ; 60HZ clock +STATUS := $96 ; IEC status byte +KEY_COUNT := $9E ; Number of keys in input buffer +RVS := $9F ; Reverse flag +CURS_FLAG := $A7 ; 1 = cursor off +CURS_BLINK := $A8 ; Blink counter +CURS_CHAR := $A9 ; Character under the cursor +CURS_STATE := $AA ; Cursor blink state +SCREEN_PTR := $C4 ; Pointer to current char in text screen +CURS_X := $C6 ; Cursor column +FNLEN := $D1 ; Length of filename +LFN := $D2 ; Current Logical File Number +SECADR := $D3 ; Secondary address +DEVNUM := $D4 ; Device number +SCR_LINELEN := $D5 ; Screen line length +CURS_Y := $D8 ; Cursor row +FNADR := $DA ; Pointer to file name + +; 80-Column CBMs +KBDREPEAT80 := $E4 +KBDRPTRATE80 := $E5 +KBDRPTDELAY80 := $E6 + +BASIC_BUF := $200 ; Location of command-line +BASIC_BUF_LEN = 81 ; Maximum length of command-line + +KEY_BUF := $26F ; Keyboard buffer + +; 40-Column PETs/CBMs +KBDRPTDELAY40 := $3E9 +KBDRPTRATE40 := $3EA +KBDREPEAT40 := $3EE +KBDREPEAT40B := $3F8 + +;---------------------------------------------------------------------------- +; PET ROM type detection + +PET_DETECT := $FFFB +PET_2000 = $CA +PET_3000 = $FC +PET_4000 = $FD + +;---------------------------------------------------------------------------- +; Vector and other locations + +IRQVec := $0090 +BRKVec := $0092 +NMIVec := $0094 + +; --------------------------------------------------------------------------- +; I/O: 6520 PIA1 + +PIA1 := $E810 ; PIA1 base address +PIA1_PORTA := PIA1+$0 ; Port A (PA) and data direction register A (DDRA) +PIA1_PACTL := PIA1+$1 ; Port A control register (CRA) +PIA1_PORTB := PIA1+$2 ; Port B (PB) and data direction register B (DDRB) +PIA1_PBCTL := PIA1+$3 ; Port B control register (CRB) + +; --------------------------------------------------------------------------- +; I/O: 6520 PIA2 + +PIA2 := $E820 ; PIA2 base address +PIA2_PORTA := PIA2+$0 ; Port A (PA) and data direction register A (DDRA) +PIA2_PACTL := PIA2+$1 ; Port A control register (CRA) +PIA2_PORTB := PIA2+$2 ; Port B (PB) and data direction register B (DDRB) +PIA2_PBCTL := PIA2+$3 ; Port B control register (CRB) + +; --------------------------------------------------------------------------- +; I/O: 6522 VIA + +VIA := $E840 ; VIA base address +VIA_PB := VIA+$0 ; Port register B +VIA_PA1 := VIA+$1 ; Port register A +VIA_PRB := VIA+$0 ; *** Deprecated *** +VIA_PRA := VIA+$1 ; *** Deprecated *** +VIA_DDRB := VIA+$2 ; Data direction register B +VIA_DDRA := VIA+$3 ; Data direction register A +VIA_T1CL := VIA+$4 ; Timer 1, low byte +VIA_T1CH := VIA+$5 ; Timer 1, high byte +VIA_T1LL := VIA+$6 ; Timer 1 latch, low byte +VIA_T1LH := VIA+$7 ; Timer 1 latch, high byte +VIA_T2CL := VIA+$8 ; Timer 2, low byte +VIA_T2CH := VIA+$9 ; Timer 2, high byte +VIA_SR := VIA+$A ; Shift register +VIA_CR := VIA+$B ; Auxiliary control register +VIA_PCR := VIA+$C ; Peripheral control register +VIA_IFR := VIA+$D ; Interrupt flag register +VIA_IER := VIA+$E ; Interrupt enable register +VIA_PA2 := VIA+$F ; Port register A w/o handshake diff --git a/cc65/asminc/plus4.inc b/cc65/asminc/plus4.inc new file mode 100644 index 0000000..6c6017a --- /dev/null +++ b/cc65/asminc/plus4.inc @@ -0,0 +1,86 @@ +; +; Plus/4 generic definitions. +; + + +; --------------------------------------------------------------------------- +; Zero page, Commodore stuff + +TMPPTR := $22 ; Temporary ptr used by BASIC +VARTAB := $2D ; Pointer to start of BASIC variables +MEMSIZE := $37 ; Pointer to highest BASIC RAM location (+1) +TXTPTR := $3B ; Pointer into BASIC source code +STATUS := $90 ; Kernal I/O completion status +TIME := $A3 ; 60HZ clock +FNAM_LEN := $AB ; Length of filename +LFN := $AC ; Logical file number +SECADR := $AD ; Secondary address +DEVNUM := $AE ; Device number +FNAM := $AF ; Pointer to filename for OPEN +KEY_COUNT := $EF ; Number of keys in input buffer +RVS := $C2 ; Reverse flag +CURS_X := $CA ; Cursor column +CURS_Y := $CD ; Cursor row +SCREEN_PTR := $C8 ; Pointer to current char in text screen +CRAM_PTR := $EA ; Pointer to current char in color RAM + +BASIC_BUF := $200 ; Location of command-line +BASIC_BUF_LEN = 89 ; Maximum length of command-line + +FNBUF := $25E ; Buffer for filename +FETCH := $494 ; lda (zp),y from RAM +CHARCOLOR := $53B +FKEY_COUNT := $55D ; Characters for function key +FKEY_SPACE := $55F ; Function key definitions +FKEY_ORIG := $F3D2 ; Original definitions + +KBDREPEAT := $540 +KBDREPEATRATE := $541 +KBDREPEATDELAY := $542 + +; --------------------------------------------------------------------------- +; Vector and other locations + +IRQVec := $0314 +BRKVec := $0316 +NMIVec := $0318 + +; --------------------------------------------------------------------------- +; Screen size + +XSIZE = 40 +YSIZE = 25 + +; --------------------------------------------------------------------------- +; I/O + +TED_T1LO := $FF00 +TED_T1HI := $FF01 +TED_T2LO := $FF02 +TED_T2HI := $FF03 +TED_T3LO := $FF04 +TED_T4HI := $FF05 +TED_MULTI1 := $FF07 +TED_KBD := $FF08 +TED_CURSHI := $FF0C +TED_CURSLO := $FF0D +TED_V1FRQLO := $FF0E +TED_V2FRQLO := $FF0F +TED_V2FRQHI := $FF10 +TED_CLK := $FF13 +TED_BGCOLOR := $FF15 +TED_COLOR1 := $FF16 +TED_COLOR2 := $FF17 +TED_COLOR3 := $FF18 +TED_BORDERCOLOR := $FF19 +TED_VLINEHI := $FF1C +TED_VLINELO := $FF1D +TED_HPOS := $FF1E +TED_ROMSEL := $FF3E +TED_RAMSEL := $FF3F + +; --------------------------------------------------------------------------- +; RAM/ROM selection addresses + +ENABLE_ROM := TED_ROMSEL +ENABLE_RAM := TED_RAMSEL diff --git a/cc65/asminc/rp6502.inc b/cc65/asminc/rp6502.inc new file mode 100644 index 0000000..1d850ec --- /dev/null +++ b/cc65/asminc/rp6502.inc @@ -0,0 +1,94 @@ +; Picocomputer 6502 general defines + +; RIA UART +RIA_READY := $FFE0 ; TX=$80 RX=$40 +RIA_TX := $FFE1 +RIA_RX := $FFE2 + +; VSYNC from PIX VGA +RIA_VSYNC := $FFE3 + +; RIA XRAM portal 0 +RIA_RW0 := $FFE4 +RIA_STEP0 := $FFE5 +RIA_ADDR0 := $FFE6 + +; RIA XRAM portal 1 +RIA_RW1 := $FFE8 +RIA_STEP1 := $FFE9 +RIA_ADDR1 := $FFEA + +; RIA OS fastcall +RIA_XSTACK := $FFEC +RIA_ERRNO := $FFED +RIA_OP := $FFEF +RIA_IRQ := $FFF0 +RIA_SPIN := $FFF1 +RIA_BUSY := $FFF2 ; Bit $80 +RIA_A := $FFF4 +RIA_X := $FFF6 +RIA_SREG := $FFF8 + +; RIA OS operation numbers +RIA_OP_EXIT := $FF +RIA_OP_ZXSTACK := $00 +RIA_OP_XREG := $01 +RIA_OP_PHI2 := $02 +RIA_OP_CODE_PAGE := $03 +RIA_OP_LRAND := $04 +RIA_OP_STDIN_OPT := $05 +RIA_OP_ERRNO_OPT := $06 +RIA_OP_CLOCK := $0F +RIA_OP_CLOCK_GETRES := $10 +RIA_OP_CLOCK_GETTIME := $11 +RIA_OP_CLOCK_SETTIME := $12 +RIA_OP_CLOCK_GETTIMEZONE := $13 +RIA_OP_OPEN := $14 +RIA_OP_CLOSE := $15 +RIA_OP_READ_XSTACK := $16 +RIA_OP_READ_XRAM := $17 +RIA_OP_WRITE_XSTACK := $18 +RIA_OP_WRITE_XRAM := $19 +RIA_OP_LSEEK := $1A +RIA_OP_LSEEK_CC65 := $1A +RIA_OP_UNLINK := $1B +RIA_OP_RENAME := $1C +RIA_OP_LSEEK_LLVM := $1D +RIA_OP_SYNCFS := $1E +RIA_OP_STAT := $1F +RIA_OP_OPENDIR := $20 +RIA_OP_READDIR := $21 +RIA_OP_CLOSEDIR := $22 +RIA_OP_TELLDIR := $23 +RIA_OP_SEEKDIR := $24 +RIA_OP_REWINDDIR := $25 +RIA_OP_CHMOD := $26 +RIA_OP_UTIME := $27 +RIA_OP_MKDIR := $28 +RIA_OP_CHDIR := $29 +RIA_OP_CHDRIVE := $2A +RIA_OP_GETCWD := $2B +RIA_OP_SETLABEL := $2C +RIA_OP_GETLABEL := $2D +RIA_OP_GETFREE := $2E + +; 6522 VIA +VIA := $FFD0 ; VIA base address +VIA_PB := VIA+$0 ; Port register B +VIA_PA1 := VIA+$1 ; Port register A +VIA_PRB := VIA+$0 ; *** Deprecated *** +VIA_PRA := VIA+$1 ; *** Deprecated *** +VIA_DDRB := VIA+$2 ; Data direction register B +VIA_DDRA := VIA+$3 ; Data direction register A +VIA_T1CL := VIA+$4 ; Timer 1, low byte +VIA_T1CH := VIA+$5 ; Timer 1, high byte +VIA_T1LL := VIA+$6 ; Timer 1 latch, low byte +VIA_T1LH := VIA+$7 ; Timer 1 latch, high byte +VIA_T2CL := VIA+$8 ; Timer 2, low byte +VIA_T2CH := VIA+$9 ; Timer 2, high byte +VIA_SR := VIA+$A ; Shift register +VIA_CR := VIA+$B ; Auxiliary control register +VIA_PCR := VIA+$C ; Peripheral control register +VIA_IFR := VIA+$D ; Interrupt flag register +VIA_IER := VIA+$E ; Interrupt enable register +VIA_PA2 := VIA+$F ; Port register A w/o handshake diff --git a/cc65/asminc/ser-error.inc b/cc65/asminc/ser-error.inc new file mode 100644 index 0000000..ff4e2b4 --- /dev/null +++ b/cc65/asminc/ser-error.inc @@ -0,0 +1,55 @@ +;**************************************************************************** +;* * +;* ser-error.inc * +;* * +;* Serial communication API * +;* * +;* * +;* * +;* (C) 2003-2012, Ullrich von Bassewitz * +;* Roemerstrasse 52 * +;* D-70794 Filderstadt * +;* EMail: uz@cc65.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. * +;* * +;**************************************************************************** + + + +;------------------------------------------------------------------------------ +; Error codes + +.enum + SER_ERR_OK ; Not an error - relax + SER_ERR_NO_DRIVER ; No driver available + SER_ERR_CANNOT_LOAD ; Error loading driver + SER_ERR_INV_DRIVER ; Invalid driver + SER_ERR_NO_DEVICE ; Device (hardware) not found + SER_ERR_BAUD_UNAVAIL ; Baud rate not available + SER_ERR_NO_DATA ; Nothing to read + SER_ERR_OVERFLOW ; No room in send buffer + SER_ERR_INIT_FAILED ; Initialization failed + SER_ERR_INV_IOCTL ; IOCTL not supported + SER_ERR_INSTALLED ; A driver is already installed + SER_ERR_NOT_OPEN ; Driver not open + + SER_ERR_COUNT ; Special: Number of error codes +.endenum + diff --git a/cc65/asminc/ser-kernel.inc b/cc65/asminc/ser-kernel.inc new file mode 100644 index 0000000..79ace64 --- /dev/null +++ b/cc65/asminc/ser-kernel.inc @@ -0,0 +1,162 @@ +;**************************************************************************** +;* * +;* ser-kernel.inc * +;* * +;* Serial communication API * +;* * +;* * +;* * +;*(C) 2003-2006, Ullrich von Bassewitz * +;* Roemerstrasse 52 * +;* D-70794 Filderstadt * +;*EMail: uz@cc65.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. * +;* * +;**************************************************************************** + + + +;------------------------------------------------------------------------------ +; The driver header + +.struct SER_HDR + ID .byte 3 ; Contains 0x73, 0x65, 0x72 ("ser") + VERSION .byte 1 ; Interface version + LIBREF .addr ; Library reference + JUMPTAB .struct + SER_INSTALL .addr ; SER_INSTALL routine + SER_UNINSTALL .addr ; SER_UNINSTALL routine + SER_OPEN .addr ; SER_OPEN routine + SER_CLOSE .addr ; SER_CLOSE routine + SER_GET .addr ; SER_GET routine + SER_PUT .addr ; SER_PUT routine + SER_STATUS .addr ; SER_STATUS routine + SER_IOCTL .addr ; SER_IOCTL routine + SER_IRQ .addr ; SER_IRQ routine + .endstruct +.endstruct + + +;------------------------------------------------------------------------------ +; The SER API version, stored SER_HDR::VERSION + +SER_API_VERSION = $02 + +;------------------------------------------------------------------------------ +; ser_params + +.struct SER_PARAMS + BAUDRATE .byte ; Baudrate + DATABITS .byte ; Number of data bits + STOPBITS .byte ; Number of stop bits + PARITY .byte ; Parity setting + HANDSHAKE .byte ; Type of handshake to use +.endstruct + +;------------------------------------------------------------------------------ +; Serial parameters + +; Baudrate +SER_BAUD_45_5 = $00 +SER_BAUD_50 = $01 +SER_BAUD_75 = $02 +SER_BAUD_110 = $03 +SER_BAUD_134_5 = $04 +SER_BAUD_150 = $05 +SER_BAUD_300 = $06 +SER_BAUD_600 = $07 +SER_BAUD_1200 = $08 +SER_BAUD_1800 = $09 +SER_BAUD_2400 = $0A +SER_BAUD_3600 = $0B +SER_BAUD_4800 = $0C +SER_BAUD_7200 = $0D +SER_BAUD_9600 = $0E +SER_BAUD_19200 = $0F +SER_BAUD_38400 = $10 +SER_BAUD_57600 = $11 +SER_BAUD_115200 = $12 +SER_BAUD_230400 = $13 +SER_BAUD_31250 = $14 +SER_BAUD_62500 = $15 +SER_BAUD_56_875 = $16 + +; Data bit settings +SER_BITS_5 = $00 +SER_BITS_6 = $01 +SER_BITS_7 = $02 +SER_BITS_8 = $03 + +; Stop bit settings +SER_STOP_1 = $00 +SER_STOP_2 = $01 + +; Parity +SER_PAR_NONE = $00 +SER_PAR_ODD = $01 +SER_PAR_EVEN = $02 +SER_PAR_MARK = $03 +SER_PAR_SPACE = $04 + +; Handshake +SER_HS_NONE = $00 ; No handshake +SER_HS_HW = $01 ; Hardware (RTS/CTS) handshake +SER_HS_SW = $02 ; Software handshake + +; Bit masks to mask out things from the status returned by ser_status +SER_STATUS_PE = $01 ; Parity error +SER_STATUS_FE = $02 ; Framing error +SER_STATUS_OE = $04 ; Overrun error +SER_STATUS_DCD = $20 ; NOT data carrier detect +SER_STATUS_DSR = $40 ; NOT data set ready + +;------------------------------------------------------------------------------ +; Variables + + .global _ser_drv ; Pointer to driver + +;------------------------------------------------------------------------------ +; Driver entry points + + .global ser_install + .global ser_uninstall + .global ser_open + .global ser_close + .global ser_get + .global ser_put + .global ser_status + .global ser_ioctl + .global ser_irq + +;------------------------------------------------------------------------------ +; C callable functions + + .global _ser_load_driver + .global _ser_unload + .global _ser_install + .global _ser_uninstall + .global _ser_open + .global _ser_close + .global _ser_get + .global _ser_put + .global _ser_status + .global _ser_ioctl + + .global _ser_clear_ptr diff --git a/cc65/asminc/signal.inc b/cc65/asminc/signal.inc new file mode 100644 index 0000000..597cad4 --- /dev/null +++ b/cc65/asminc/signal.inc @@ -0,0 +1,57 @@ +;/*****************************************************************************/ +;/* */ +;/* signal.inc */ +;/* */ +;/* Signal handling definitions */ +;/* */ +;/* */ +;/* */ +;/* (C) 2002 Ullrich von Bassewitz */ +;/* Wacholderweg 14 */ +;/* D-70597 Stuttgart */ +;/* EMail: uz@musoftware.de */ +;/* */ +;/* */ +;/* 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. */ +;/* */ +;/*****************************************************************************/ + + + +; Standard signal handling functions +SIG_ERR = $0000 + +; Signal numbers +SIGABRT = 0 +SIGFPE = 1 +SIGILL = 2 +SIGINT = 3 +SIGSEGV = 4 +SIGTERM = 5 +SIGCOUNT = 6 ; Number of signals + +; Table with signal handlers (asm code only) +.global sigtable + +; Function declarations +.global ___sig_ign +.global ___sig_dfl +.global _signal +.global _raise + + diff --git a/cc65/asminc/sim65.inc b/cc65/asminc/sim65.inc new file mode 100644 index 0000000..b8ea264 --- /dev/null +++ b/cc65/asminc/sim65.inc @@ -0,0 +1,75 @@ + +; ******************************************************************************* +; ** ** +; ** sim65.inc : assembler definitions for the sim6502 and sim65c02 targets. ** +; ** ** +; ** Sidney Cadot, January 2025 ** +; ** ** +; ******************************************************************************* + + ; The '_peripherals' symbol is defined in the linker configuration + ; file to correspond to the first address in the periperal memory + ; aparture. + ; + ; We use it here as a base address for all peripheral addresses. + + .import _peripherals + +; ************************************************************** +; ** ** +; ** Define assembler symbols for the "counter" peripheral. ** +; ** ** +; ************************************************************** + +peripheral_counter_base := _peripherals + 0 + +peripheral_counter_latch := peripheral_counter_base + 0 +peripheral_counter_select := peripheral_counter_base + 1 +peripheral_counter_value := peripheral_counter_base + 2 + +; Values for the peripheral_counter_select register. + +COUNTER_SELECT_CLOCKCYCLE_COUNTER = $00 +COUNTER_SELECT_INSTRUCTION_COUNTER = $01 +COUNTER_SELECT_IRQ_COUNTER = $02 +COUNTER_SELECT_NMI_COUNTER = $03 +COUNTER_SELECT_WALLCLOCK_TIME = $80 +COUNTER_SELECT_WALLCLOCK_TIME_SPLIT = $81 + +; ******************************************************************** +; ** ** +; ** Define assembler symbols for the "sim65 control" peripheral. ** +; ** ** +; ******************************************************************** + +peripheral_sim65_base := _peripherals + 10 + +peripheral_sim65_cpu_mode := peripheral_sim65_base + 0 +peripheral_sim65_trace_mode := peripheral_sim65_base + 1 + +; Values for the peripheral_sim65_cpu_mode register. + +SIM65_CPU_MODE_6502 = $00 +SIM65_CPU_MODE_65C02 = $01 +SIM65_CPU_MODE_6502X = $02 + +; Bitfield values for the peripheral_sim65_trace_mode field. + +SIM65_TRACE_MODE_FIELD_INSTR_COUNTER = $40 +SIM65_TRACE_MODE_FIELD_CLOCK_COUNTER = $20 +SIM65_TRACE_MODE_FIELD_PC = $10 +SIM65_TRACE_MODE_FIELD_INSTR_BYTES = $08 +SIM65_TRACE_MODE_FIELD_INSTR_ASSEMBLY = $04 +SIM65_TRACE_MODE_FIELD_CPU_REGISTERS = $02 +SIM65_TRACE_MODE_FIELD_CC65_SP = $01 + +; Values for the peripheral_sim65_trace_mode field that fully disable / enable tracing. + +SIM65_TRACE_MODE_DISABLE = $00 +SIM65_TRACE_MODE_ENABLE_FULL = $7F + +; ************************ +; ** ** +; ** End of sim65.inc ** +; ** ** +; ************************ diff --git a/cc65/asminc/smc.inc b/cc65/asminc/smc.inc new file mode 100644 index 0000000..137c2d4 --- /dev/null +++ b/cc65/asminc/smc.inc @@ -0,0 +1,267 @@ +; smc.mac +; ca65 Macro-Pack for Self Modifying Code (SMC) +; +; (c) Christian Krüger, latest change: 17-Jul-2016 +; +; 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. +; + +.define _SMCDesignator .mid(0, .tcount(label) - 1, label) .ident(.concat(.string(.right(1, label)), "_SMC")) +.define _SMCAlias .mid(0, .tcount(alias) - 1, alias) .ident(.concat(.string(.right(1, alias)), "_SMC")) +.define SMC_AbsAdr $FADE +.define SMC_ZpAdr $00 +.define SMC_Opcode nop +.define SMC_Value $42 + +.macro SMC_OperateOnValue opcode, label + opcode _SMCDesignator+1 +.endmacro + +.macro SMC_OperateOnLowByte opcode, label + SMC_OperateOnValue opcode, label +.endmacro + +.macro SMC_OperateOnHighByte opcode, label + opcode _SMCDesignator + 2 +.endmacro + +.macro SMC_Import alias +.import _SMCAlias +.endmacro + +.macro SMC_Export alias, label +.export _SMCAlias := _SMCDesignator +.endmacro + +.macro SMC label, statement +_SMCDesignator: statement +.endmacro + +.macro SMC_TransferOpcode label, opcode, register +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) + lda #opcode + sta _SMCDesignator +.elseif .match ({register}, x) + ldx #opcode + stx _SMCDesignator +.elseif .match ({register}, y) + ldy #opcode + sty _SMCDesignator +.else + .error "Invalid usage of macro 'SMC_TransferOpcode'" +.endif +.endmacro + +.macro SMC_LoadOpcode label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + lda _SMCDesignator +.elseif .match ({register}, x) + ldx _SMCDesignator +.elseif .match ({register}, y) + ldy _SMCDesignator +.else + .error "Invalid usage of macro 'SMC_LoadOpcode'" +.endif +.endmacro + +.macro SMC_StoreOpcode label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + sta _SMCDesignator +.elseif .match ({register}, x) + stx _SMCDesignator +.elseif .match ({register}, y) + sty _SMCDesignator +.else + .error "Invalid usage of macro 'SMC_StoreOpcode'" +.endif +.endmacro + +.macro SMC_ChangeBranch label, destination, register +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) + lda #(<(destination - _SMCDesignator -2)) + sta _SMCDesignator+1 +.elseif .match ({register}, x) + ldx #(<(destination - _SMCDesignator - 2)) + stx _SMCDesignator+1 +.elseif .match ({register}, y) + ldy #(<(destination - _SMCDesignator - 2)) + sty _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_ChangeBranch'" +.endif +.endmacro + +.macro SMC_TransferValue label, value, register +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) + lda value + sta _SMCDesignator+1 +.elseif .match ({register}, x) + ldx value + stx _SMCDesignator+1 +.elseif .match ({register}, y) + ldy value + sty _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_TransferValue'" +.endif +.endmacro + +.macro SMC_LoadValue label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + lda _SMCDesignator+1 +.elseif .match ({register}, x) + ldx _SMCDesignator+1 +.elseif .match ({register}, y) + ldy _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_LoadValue'" +.endif +.endmacro + +.macro SMC_StoreValue label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + sta _SMCDesignator+1 +.elseif .match ({register}, x) + stx _SMCDesignator+1 +.elseif .match ({register}, y) + sty _SMCDesignator+1 +.else + .error "Invalid usage of macro 'SMC_StoreValue'" +.endif +.endmacro + + +.macro SMC_TransferLowByte label, value, register +SMC_TransferValue label, value, register +.endmacro + +.macro SMC_LoadLowByte label, register +SMC_LoadValue label, register +.endmacro + +.macro SMC_StoreLowByte label, register +SMC_StoreValue label, register +.endmacro + +.macro SMC_TransferHighByte label, value, register +.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, ) + lda value + sta _SMCDesignator+2 +.elseif .match ({register}, x) + ldx value + stx _SMCDesignator+2 +.elseif .match ({register}, y) + ldy value + sty _SMCDesignator+2 +.else + .error "Invalid usage of macro 'SMC_TransferHighByte'" +.endif +.endmacro + +.macro SMC_LoadHighByte label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + lda _SMCDesignator+2 +.elseif .match ({register}, x) + ldx _SMCDesignator+2 +.elseif .match ({register}, y) + ldy _SMCDesignator+2 +.else + .error "Invalid usage of macro 'SMC_LoadHighByte'" +.endif +.endmacro + +.macro SMC_StoreHighByte label, register +.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, ) + sta _SMCDesignator+2 +.elseif .match ({register}, x) + stx _SMCDesignator+2 +.elseif .match ({register}, y) + sty _SMCDesignator+2 +.else + .error "Invalid usage of macro 'SMC_StoreHighByte'" +.endif +.endmacro + +.macro SMC_TransferAddressSingle label, address, register +.if .paramcount = 2 .or .match ((register), a) .or .match ({register}, ) + .if (.match (.left (1, {address}), #)) + ; immediate mode + lda #<(.right (.tcount ({address})-1, {address})) + sta _SMCDesignator+1 + lda #>(.right (.tcount ({address})-1, {address})) + sta _SMCDesignator+2 + .else + ; assume absolute or zero page + lda address + sta _SMCDesignator+1 + lda 1+(address) + sta _SMCDesignator+2 + .endif +.elseif .match ((register), x) + .if (.match (.left (1, {address}), #)) + ; immediate mode + ldx #<(.right (.tcount ({address})-1, {address})) + stx _SMCDesignator+1 + ldx #>(.right (.tcount ({address})-1, {address})) + stx _SMCDesignator+2 + .else + ; assume absolute or zero page + ldx address + stx _SMCDesignator+1 + ldx 1+(address) + stx _SMCDesignator+2 + .endif +.elseif .match ((register), y) + .if (.match (.left (1, {address}), #)) + ; immediate mode + ldy #<(.right (.tcount ({address})-1, {address})) + sty _SMCDesignator+1 + ldy #>(.right (.tcount ({address})-1, {address})) + sty _SMCDesignator+2 + .else + ; assume absolute or zero page + ldy address + sty _SMCDesignator+1 + ldy 1+(address) + sty _SMCDesignator+2 + .endif +.else + .error "Invalid usage of macro 'SMC_TransferAddressSingle'" +.endif +.endmacro + +.macro SMC_TransferAddress label, address +.if (.match (.left (1, {address}), #)) + ; immediate mode + lda #<(.right (.tcount ({address})-1, {address})) + sta _SMCDesignator+1 + ldx #>(.right (.tcount ({address})-1, {address})) + stx _SMCDesignator+2 +.else + ; assume absolute or zero page + lda {address} + sta _SMCDesignator+1 + ldx 1+{address} + stx _SMCDesignator)+2 +.endif +.endmacro + +.macro SMC_StoreAddress label + sta _SMCDesignator+1 + stx _SMCDesignator+2 +.endmacro diff --git a/cc65/asminc/stat.inc b/cc65/asminc/stat.inc new file mode 100644 index 0000000..e5248f0 --- /dev/null +++ b/cc65/asminc/stat.inc @@ -0,0 +1,64 @@ +;**************************************************************************** +;* * +;* stat.inc * +;* * +;* Stat struct * +;* * +;* * +;* * +;*(C) 2023 Colin Leroy-Mira * +;* * +;* * +;*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. * +;* * +;**************************************************************************** + + .include "time.inc" + +;------------------------------------------------------------------------------ +; st_mode values + +S_IFDIR = $01 +S_IFREG = $02 + +;------------------------------------------------------------------------------ +; struct stat + +.struct stat + st_dev .dword + st_ino .dword + st_mode .byte + st_nlink .dword + st_uid .byte + st_gid .byte + st_size .dword + st_atim .tag timespec + st_ctim .tag timespec + st_mtim .tag timespec + .ifdef __APPLE2__ + st_access .byte + st_type .byte + st_auxtype .word + st_storagetype .byte + st_blocks .word + st_mod_date .word + st_mod_time .word + st_create_date .word + st_create_time .word + .endif +.endstruct diff --git a/cc65/asminc/statvfs.inc b/cc65/asminc/statvfs.inc new file mode 100644 index 0000000..8674b04 --- /dev/null +++ b/cc65/asminc/statvfs.inc @@ -0,0 +1,46 @@ +;**************************************************************************** +;* * +;* statvfs.inc * +;* * +;* Statvfs struct * +;* * +;* * +;* * +;*(C) 2023 Colin Leroy-Mira * +;* * +;* * +;*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. * +;* * +;**************************************************************************** + +;------------------------------------------------------------------------------ +; struct statvfs + +.struct statvfs + f_bsize .dword + f_frsize .dword + f_blocks .dword + f_bfree .dword + f_bavail .dword + f_files .dword + f_ffree .dword + f_favail .dword + f_fsid .dword + f_flag .dword + f_namemax .dword +.endstruct diff --git a/cc65/asminc/stdio.inc b/cc65/asminc/stdio.inc new file mode 100644 index 0000000..426389d --- /dev/null +++ b/cc65/asminc/stdio.inc @@ -0,0 +1,74 @@ +;*****************************************************************************/ +;* */ +;* stdio.inc */ +;* */ +;* Mirror definitions for stdio.h */ +;* */ +;* */ +;* */ +;* (C) 2003-2005, Ullrich von Bassewitz */ +;* Roemerstrasse 52 */ +;* D-70794 Filderstadt */ +;* EMail: uz@cc65.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. */ +;* */ +;*****************************************************************************/ + + + +;---------------------------------------------------------------------------- +; Constants + +_IOFBF = 0 +_IOLBF = 1 +_IONBF = 2 +BUFSIZ = 256 +EOF = -1 +.if .defined(__APPLE2__) +FILENAME_MAX = 64+1 +.elseif .defined(__ATARI__) +FILENAME_MAX = 63+1 +.elseif .defined(__CBM__) +FILENAME_MAX = 255 +.elseif .defined(__LUNIX__) +FILENAME_MAX = 80+1 +.elseif .defined(__TELESTRAT__) +FILENAME_MAX = 50+1 +.else +FILENAME_MAX = 16+1 +.endif +L_tmpnam = FILENAME_MAX +SEEK_CUR = 0 +SEEK_END = 1 +SEEK_SET = 2 +TMP_MAX = 256 + +; Maximum number of open files (size of the file table) +FOPEN_MAX = 8 + +;---------------------------------------------------------------------------- +; External variables + + .global _stdin + .global _stdout + .global _stderr + + + diff --git a/cc65/asminc/supervision.inc b/cc65/asminc/supervision.inc new file mode 100644 index 0000000..a1cc212 --- /dev/null +++ b/cc65/asminc/supervision.inc @@ -0,0 +1,75 @@ +; supervision symbols + +; supervision 65c02s +; in cc65 up to 2.9.1 65c02 means 65sc02 + +lcd_addr = $4000 +LCD_LINESIZE = $30 +LCD_WIDTH = 160 +LCD_HEIGHT = 160 +; 2 bit per pixel, packed + +lcd_width = $2000 +lcd_height = $2001 +lcd_xpos = $2002 ; in pixel, bit 0+1 not used +lcd_ypos = $2003 ; weird + +sv_port_r = $2021 +sv_port_w = $2022 + +sv_timer_count = $2023 +; read for quitting +sv_timer_quit = $2024 + +; bit 0 timer, bit 1 dma +sv_irq_source = $2027 +SV_IRQ_REQUEST_TIMER = 1 +SV_IRQ_REQUEST_DMA = 2 + +; bit 5,6,7 select bank at 0x8000 +sv_bank = $2026 +SV_NMI_ENABLE_ON = 1 +SV_IRQ_ENABLE_TIMER = 2 +SV_IRQ_ENABLE_DMA = 4 +SV_LCD_ON = 8 +SV_TIMER_MODE_240Hz = $10 ; else 15360 + + +; low activ/pressed +sv_control = $2020 +SV_RIGHT = 1 +SV_LEFT = 2 +SV_DOWN = 4 +SV_UP = 8 +SV_BUTTONB = $10 +SV_BUTTONA = $20 +SV_SELECT = $40 +SV_START = $80 + +; frequency=125000/counter +sv_audio_right_counter = $2010 ;word +sv_audio_left_counter = $2014 +SV_AUDIO_ON =$40 +;bits 0..3 volume +; bit 4 ? +; bit 5 ? +sv_audio_right_control = $2012 +sv_audio_left_control = $2016 +; write activates tone for x/60 sec (0 means 256) +sv_audio_right_timer = $2013 +sv_audio_left_timer = $2017 + + +;read for irq quitting +sv_dma_quit = $2025 +sv_dma_on = $201c +; bit 7 true start, false stop +sv_dma_start = $2018 ; word +sv_dma_size = $201a ; *32 samples +sv_dma_control = $201b +; bit 0,1 speed: 0 15360, 11 15360/4 +; bit 2,3 volume: 0 silent, 11 loud + +sv_noise_volume = $2028 ; and frequency +sv_noise_timer = $2029 +sv_noise_control = $202a diff --git a/cc65/asminc/sym1.inc b/cc65/asminc/sym1.inc new file mode 100644 index 0000000..b6a6f17 --- /dev/null +++ b/cc65/asminc/sym1.inc @@ -0,0 +1,186 @@ +; --------------------------------------------------------------------------- +; +; SYM-1 definitions +; +; --------------------------------------------------------------------------- + + +RAMSTART := $0200 ; Entry point + + +; --------------------------------------------------------------------------- +; Monitor Functions +; --------------------------------------------------------------------------- +WARM := $8003 ; Monitor entry +SVNMI := $809B ; Save NMI entry +INBYTE := $81D9 ; Get two HEX characters and pack +ASCNIB := $8275 ; Test for carriage-return +INCCMP := $82B2 ; Increment pointer +CHKSAD := $82DD ; Compute checksum +OUTPC := $82EE ; Display program counter +OUTBYT := $82FA ; Print byte as two ASCII characters +OUTS2 := $8319 ; Print pointer +INSTAT := $8386 ; Determine if key is pressed +GETKEY := $88AF ; Get key (disregarding monitor login) +SCAND := $8906 ; Flash LED display (once) +KEYQ := $8923 ; Test for keypress +BEEP := $8972 ; Make a beep +CONFIG := $89A5 ; Configure I/O +OUTDSP := $89C1 ; Output to on-board LED display +INCHR := $8A1B ; Input character and convert to uppercase +OUTCHR := $8A47 ; Output character +INTCHR := $8A58 ; Input character without case conversion +DLYF := $8AE6 ; Delay 1 bit time +DLYH := $8AE9 ; Delay 1/2 bit time +RESET := $8B4A ; Hard reset +ACCESS := $8B86 ; Unlock lowest 4K memory +NACCES := $8B9C ; Lock lowest 4K memory +L8C78 := $8C78 ; Link to tape +DUMPT := $8E87 ; Dump memory to tape +LOADT := $8C78 ; Load memory from tape +TAPEMODE := $00FD ; Top bit on for high-speed + + +; --------------------------------------------------------------------------- +; System Memory +; --------------------------------------------------------------------------- +DISBUF := $A640 ; On-Board Display Buffer +DISBUF0 := $A640 ; Left-Most digit +DISBUF1 := $A641 ; Second digit +DISBUF2 := $A642 ; Third +DISBUF3 := $A643 ; Fourth +DISBUF4 := $A644 ; Fifth +DISBUF5 := $A645 ; Sixth and right-most digit +DISBUF6 := $A646 ; Not-used / right of display (shift buffer) +RDIG := $A645 ; Right-most digit (same as DISBUF5) +P3L := $A64A ; Parameter 3 (low-byte) +P3H := $A64B ; (high-byte) +P2L := $A64C ; Parameter 2 +P2H := $A64D ; +P1L := $A64E ; Parameter 1 +P1H := $A64F +PARNR := $A649 ; Number of Parameters Entered +PADBIT := $A650 ; Pad Bits for Carriage Return +SDBYT := $A651 ; Baud Rate for RS232 (01-4800,06-2400,10-1200,24-600,4C-300,D5-110) +ERCNT := $A652 ; Error Count (Max FF) +TECHO := $A653 ; Terminal Echo (bit-7=ECHO/NO, 6=CTL-O TOGGLE) +TOUTFL := $A654 ; Output Flags (bit-7=CRT IN, 6=TTY IN, 5=TTY OUT, 4=CRT OUT) +KSHFL := $A655 ; Keyboard Shift Flag +TV := $A656 ; Trace Velocity (0=Single Step) +LSTCOM := $A657 ; Last Monitor Command +MAXRC := $A658 ; Maximum Record Length for Memory Dump + + +; --------------------------------------------------------------------------- +; Register Followers +; --------------------------------------------------------------------------- +PCLR := $A659 ; Program Counter (low-byte) +PCHR := $A65A ; (high-byte) +SR := $A65B ; Stack Pointer +FR := $A65C ; Status Register Flags +AR := $A65D ; A Register +XR := $A65E ; X Register +YR := $A65F ; Y Register + + +; --------------------------------------------------------------------------- +; I/O Vectors (3 bytes each) +; --------------------------------------------------------------------------- +INVEC := $A660 ; Input Character +OUTVEC := $A663 ; Output Character +INSVEC := $A666 ; Input Status +URSVEC := $A669 ; Unrecognized Syntax +URCVEC := $A66C ; Unrecognized Command / Error +SCNVEC := $A66F ; Scan On-board Display + + +; --------------------------------------------------------------------------- +; Trace and Interrupt Vectors (2 bytes each) +; --------------------------------------------------------------------------- +EXEVEC := $A672 ; Exec and Alternate InVec +TRCVEC := $A674 ; Trace +UBRKVC := $A676 ; User Break after Monitor +UIRQVC := $A678 ; User non-break IRQ after Monitor +NMIVEC := $A67A ; Non-Maskable Interrupt +RSTVEC := $A67C ; Reset +IRQVEC := $A67E ; Interrupt Request + + +; --------------------------------------------------------------------------- +; I/O Registers +; --------------------------------------------------------------------------- +; +; 6532 (U27) +; +PADA := $A400 ; Keyboard / Display +P3DA := $A402 ; Serial I/O +DDPADA := $A401 ; Data-Direction Register for PADA +DDP3DA := $A403 ; Data-Direction Register for P3DA +WEDRTA := $A404 ; Write-Edge Detect Read Timer A +WEDRFA := $A405 ; Write-Edge Detect Read-Int Flags A +WEDRTB := $A406 ; Write-Edge Detect Read Timer B +WEDRFB := $A407 ; Write-Edge Detect Read-Int Flags B +TIM0001 := $A41C ; Timer / 1 +TIM0008 := $A41D ; Timer / 8 +TIM0064 := $A41E ; Timer / 64 +TIM1024 := $A41F ; Timer / 1024 +; +; 6522 (U25) +; +OR1A := $A001 ; Input / Output Register for 1A +DDR1A := $A003 ; Data-Direction Register for 1A +OR1B := $A000 ; Input / Output Register for 1B +DDR1B := $A002 ; Data-Direction Register for 1B +TIC1L := $A004 ; +TIC1H := $A005 ; +TIL1L := $A006 ; +TIL1H := $A007 ; +T2L1L := $A008 ; +T2C1L := $A008 ; +T2C1H := $A009 ; +SR1 := $A00A ; +ACR1 := $A00B ; +PCR1 := $A00C ; +IFR1 := $A00D ; +IER1 := $A00E ; +DR1A := $A00F ; +; +; 6522 (U28) +; +OR2A := $A801 ; Input / Output Register for 2A +DDR2A := $A803 ; Data-Direction Register for 2A +OR2B := $A800 ; Input / Output Register for 2B +DDR2B := $A802 ; Data-Direction Register for 2B +TIC2L := $A804 ; +TIC2H := $A805 ; +TIL2L := $A806 ; +TIL2H := $A807 ; +T2L2L := $A808 ; +T2C2L := $A808 ; +T2C2H := $A809 ; +SR2 := $A80A ; +ACR2 := $A80B ; +PCR2 := $A80C ; +IFR2 := $A80D ; +IER2 := $A80E ; +DR2A := $A80F ; +; +; 6522 (U29) +; +OR3A := $AC01 ; Write-Protect RAM, Debug On/Off, I/O-3A +DDR3A := $AC03 ; Data-Direction Register for 3A +OR3B := $AC00 ; Input / Output Register for 3B +DDR3B := $AC02 ; Data-Direction Register for 3B +TIC3L := $AC04 ; +TIC3H := $AC05 ; +TIL3L := $AC06 ; +TIL3H := $AC07 ; +T2L3L := $AC08 ; +T2C3L := $AC08 ; +T2C3H := $AC09 ; +SR3 := $AC0A ; +ACR3 := $AC0B ; +PCR3 := $AC0C ; +IFR3 := $AC0D ; +IER3 := $AC0E ; +DR3A := $AC0F ; diff --git a/cc65/asminc/telestrat.inc b/cc65/asminc/telestrat.inc new file mode 100644 index 0000000..bbfabdf --- /dev/null +++ b/cc65/asminc/telestrat.inc @@ -0,0 +1,546 @@ +; +; Oric TELEMON definition +; TELEMON 2.4 & Orix +; For Orix check http://orix.oric.org +; + +; --------------------------------------------------------------------------- +; Constants + +SCREEN_XSIZE = 40 ; Screen columns +SCREEN_YSIZE = 28 ; Screen rows + +FUNCTKEY = $A5 + +FNAME_LEN = 11 ; Maximum length of file-name + +; --------------------------------------------------------------------------- +; I/O Identifier +; Theses identifers are used for channel management +; + +XKBD = $80 ; Keyboard +XRSE = $83 ; RS232 in +XSCR = $88 ; Screen +XRSS = $90 ; RS232 out + +; --------------------------------------------------------------------------- +; Zero page + +; --------------------------------------------------------------------------- +; Page 00 +RES := $00 +RESB := $02 + +DECDEB := $04 +DECFIN := $06 +DECCIB := $08 +DECTRV := $0A + +TR0 := $0C +TR1 := $0D +TR2 := $0E +TR3 := $0F +TR4 := $10 +TR5 := $11 +TR6 := $12 +TR7 := $13 + +DEFAFF := $14 + +IRQSVA := $21 ; Used to save A when a BRK call occurs +IRQSVX := $22 ; Used to save X when a BRK call occurs +IRQSVY := $23 ; Used to save Y when a BRK call occurs +IRQSVP := $24 ; Used to save P when a BRK call occurs + +ADSCR := $26 +SCRNB := $28 ; Id of the current window + +ADKBD := $2A ; Address ASCII conversion table + + +PTR_READ_DEST := $2C ; Used for XFREAD and XWRITE only in Orix + +ADCLK := $40 ; Address for clock display +TIMEUS := $42 +TIMEUD := $44 ; Counter clock (1/10 of a second) + + +HRSX := $46 +HRSY := $47 + +XLPRBI := $48 ; Printer flag (b7) + +HRSX40 := $49 +HRSX6 := $4A + +ADHRS := $4B ; Hires screen address (word) + +HRS1 := $4D +HRS2 := $4F +HRS3 := $51 +HRS4 := $53 +HRS5 := $55 + +HRSFB := $57 + +VABKP1 := $58 + +; RS232T +; b0-b3 : speed +; 1111 => 19200 bps (please note that telestrat can't handle this speed without stopping all IRQ except ACIA's one) +; 1100 => 9600 bps (default from TELEMON) +; 1110 => 4800 bps +; 1010 => 2400 bps +; 1000 => 1200 bps +; 0111 => 600 bps +; 0110 => 300 bps +; 0101 => 150 bps +; 0010 => 75 bps + +; b4 : 0 external clock, 1 internal clock +; b6-b5 : 00 8 bits +; 01 7 bits +; 10 6 bits +; 11 5 bits +; b7 : 0 a stop + +RS232T := $59 + +; RS232C +; b0-b3 : 0 +; b4 : 1 if echo +; b5 : 1 if parity +; b7-b6 : 00 in/out parity odd +; : 01 on/out parity even +; : 10 parity sent, answer not tested +; : 11 SPACE SENT, reception not tested + +RS232C := $5A +INDRS := $5B + +; Float and integer management +ACC1E := $60 +ACC1M := $61 +ACC1S := $65 +ACC1EX := $66 +ACC1J := $67 +ACC2E := $68 +ACC2M := $69 +ACC2S := $6D +ACCPS := $6E +ACC3 := $6F + +ACC4E := $73 +ACC4M := $74 + + +FLDT0 := $74 +FLDT1 := $75 +FLDT2 := $76 +FLSVY := $77 +FLTR0 := $7D +FLTR1 := $7E + +; Menu management +MENDDY := $62 +MENDFY := $63 +MENX := $64 +MENDY := $66 +FLGMEN := $68 +ADMEN := $69 + +FLSGN := $8A +FLINT := $88 +FLSVS := $89 +FLERR := $8B + +VARLNG := $8C +VARAPL := $D0 + +; --------------------------------------------------------------------------- +; Low memory +IRQVec := $02FB ; "fast" interrupt vector + +; --------------------------------------------------------------------------- +; I/O locations + +; 6522 +.struct VIA ; Versatile Interface Adapter + .res $0300 +PRB .byte ; Port Register B +PRA .byte ; Port Register A +DDRB .byte ; Data Direction Register B +DDRA .byte ; Data Direction Register A +T1 .word ; Timer 1 +T1L .word ; Timer 1 Latch +T2 .word ; Timer 2 +SR .byte ; Shift Register +ACR .byte ; Auxiliary Control Register +PCR .byte ; Peripheral Control Register +IFR .byte ; Interrupt Flags Register +IER .byte ; Interrupt Enable Register +PRA2 .byte ; Port Register A without handshaking +.endstruct + + +.struct VIA2 ; Versatile Interface Adapter + .res $0320 +PRB .byte ; Port Register B +PRA .byte ; Port Register A +DDRB .byte ; Data Direction Register B +DDRA .byte ; Data Direction Register A +T1 .word ; Timer 1 +T1L .word ; Timer 1 Latch +T2 .word ; Timer 2 +SR .byte ; Shift Register +ACR .byte ; Auxiliary Control Register +PCR .byte ; Peripheral Control Register +IFR .byte ; Interrupt Flags Register +IER .byte ; Interrupt Enable Register +PRA2 .byte ; Port Register A without handshaking +.endstruct + +; 6551 +.struct ACIA ; Asynchronous Communications Interface Adapter + .res $031C +DATA .byte +STATUS .byte +CMD .byte ; Command register +CTRL .byte ; Control register +.endstruct + +SCREEN := $BB80 + + +; --------------------------------------------------------------------------- +; ROM entries + +; TELEMON primitives (2.4 & 3.x) + +; all values are used to call bank 7 of telestrat cardridge. It works with 'brk value' +XOP0 = $00 ; Open device on channel 0 +XOP1 = $01 ; Open device on channel 1 +XOP2 = $02 ; Open device on channel 2 +XOP3 = $03 ; Open device on channel 3 + +XCL0 = $04 ; Close channel 0 +XCL1 = $05 ; Close channel 1 +XCL2 = $06 ; Close channel 2 +XCL3 = $07 ; Close channel 3 + +XRD0 = $08 +XRDW0 = $0C + +XWR0 = $10 ; Write a char in channel 0 +XWR1 = $11 ; Write a char in channel 1 +XWR2 = $12 ; Write a char in channel 2 +XWR3 = $13 ; Write a char in channel 3 + +XWSTR0 = $14 ; Write a string in text mode channel 0 +XWSTR1 = $15 ; Write a string in text mode channel 1 +XWSTR2 = $16 ; Write a string in text mode channel 2 +XWSTR3 = $17 ; Write a string in text mode channel 3 + +XDECAL = $18 + +XTEXT = $19 +XHIRES = $1A +XEFFHI = $1B ; Clear hires screen +XFILLM = $1C +XMINMA = $1F +XVARS = $24 ; Only in Orix, in TELEMON 2.4, it's XNOMFI ($24) +XCRLF = $25 ; Jump a line and return to the beginning of the line +XDECAY = $26 +XFREAD = $27 ; Only in Orix +XBINDX = $28 ; Convert a number into hex and displays on channel 0 +XDECIM = $29 +XHEXA = $2A ; Convert a number into hex + +XMAINARGS = $2C ; Only available for Orix + +XEDT = $2D ; Launch editor +XINSER = $2E +XGETARGV = $2E ; Only available for Orix + +XSCELG = $2F ; Search a line in editor mode +XOPEN = $30 ; Only in Orix +XECRPR = $33 ; Displays prompt +XCOSCR = $34 ; Switch off cursor +XCSSCR = $35 ; Switch on cursor +XSCRSE = $36 +XSCROH = $37 ; Scroll up text screen +XSCROB = $38 ; Scroll down text screen +XSCRNE = $39 ; Load charset from rom to ram +XCLOSE = $3A ; Only in Orix close file +XFWRITE = $3B ; Only in Orix write file + +; Clock primitive +XRECLK = $3C ; Reset clock +XCLCL = $3D ; Close clock +XWRCLK = $3E ; Displays clock in the address in A & Y registers + +XFSEEK = $3F ; Only in Orix + +; Sound primitives +XSONPS = $40 ; Send data to PSG register (14 values) +XOUPS = $42 ; Send Oups sound into PSG +XPLAY = $43 ; Play a sound +XSOUND = $44 +XMUSIC = $45 +XZAP = $46 ; Send Zap sound to PSG +XSHOOT = $47 + +; Path Management +XGETCWD = $48 ; Get current CWD +XPUTCWD = $49 ; Chdir + +; File management +XMKDIR = $4B ; Create a folder. Only available in Orix + +XHCHRS = $4C ; Hard copy hires + +; File management +XRM = $4D ; Remove a folder or a file. Only available in Orix + +XFWR = $4E ; Put a char on the first screen. Only available in Orix + +; Keyboard primitives +XALLKB = $50 ; Read Keyboard, and populate KBDCOL +XKBDAS = $51 ; Ascii conversion +XGOKBD = $52 ; Swap keyboard type (Qwerty, French ...) + +; Buffer management +XECRBU = $54 ; Write A or AY in the buffer +XLISBU = $55 ; Read A or AY in the buffer +XTSTBU = $56 +XVIDBU = $57 ; Flush the buffer +XINIBU = $58 ; Initialize the buffer X +XDEFBU = $59 ; Reset all value of the buffer +XBUSY = $5A ; Test if the buffer is empty + +XMALLOC = $5B ; Only in Orix + +; RS232 primitives +XSDUMP = $5C ; RS232 input dump +XCONSO = $5D ; Swap screen into RS232 terminal +XSLOAD = $5E ; Read a file from RS232 +XSSAVE = $5F ; Write a file to RS232 + +; Minitel primitives +XMLOAD = $60 ; Read a file from Minitel +XMSAVE = $61 ; Write a file to Minitel + +XFREE = $62 ; Only in Orix + +XEXEC = $63 ; Only in Orix + +; Next Minitel primitives +XWCXFI = $63 ; Wait connection +XLIGNE = $64 ; +XDECON = $65 ; Minitel disconnection +XMOUT = $66 ; Send a byte to minitel (from A) + +XSOUT = $67 ; Send accumulator value (A) to RS232, available in TELEMON 2.4 : if RS232 buffer is full, the Oric Telestrat freezes + +XHRSSE = $8C ; Set hires position cursor +XDRAWA = $8D ; Draw a line absolute +XDRAWR = $8E ; Draw a line (relative) +XCIRCL = $8F ; Draw a circle +XCURSE = $90 ; Plot a pixel +XCURMO = $91 ; Move to x,y pos in Hires +XPAPER = $92 +XINK = $93 +XBOX = $94 ; Draw a box +XABOX = $95 +XFILL = $96 +XCHAR = $97 ; Display a char on the screen in Hires +XSCHAR = $98 ; Draw a string in hires +XEXPLO = $9C ; Send Explode sound to PSG +XPING = $9D ; Send Ping sound to PSG + +; --------------------------------------------------------------------------- +; ROM entries variables + +PWD_PTR = $00 + +; --------------------------------------------------------------------------- +; +BUFTRV := $100 + + +; --------------------------------------------------------------------------- +; Page $200 +BNKST := $200 ; Used to store signature of 8 bank (length : 8 bytes) +TABDRV := $208 + +DRVDEF := $20C +FLGTEL := $20D +KOROM := $20E ; Used to compute the size of all rom bank. The result is store here. The value is in KB +KORAM := $20F ; Used to compute the size of all ram bank. The result is store here. The value is in KB +; Time management +TIMED := $210 ; Clock (1/10 of seconds) +TIMES := $211 +TIMEM := $212 +TIMEH := $213 +FLGCLK := $214 +FLGCLK_FLAG := $215 +FLGCUR := $216 ; Cursor management flag +; screens position managements + +FLGCUR_STATE := $217 ; Cursor state flag + +ADSCRL := $218 +ADSCRH := $21C +SCRX := $220 +SCRY := $224 + +SCRDX := $228 +SCRFX := $22C +SCRDY := $230 +SCRFY := $234 +SCRBAL := $238 +SCRBAH := $23C +SCRCT := $240 +SCRCF := $244 +FLGSCR := $248 +CURSCR := $24C + +HARD_COPY_HIRES := $250 ; Hard copy vector + +SCRTXT := $256 +SCRHIR := $25C +SCRTRA := $262 ; 6 bytes lenfth + +; Keyboard management +KBDCOL := $268 ; 8 bytes length +KBDFLG_KEY := $270 ; 0 if no key pressed +KBDVRR := $272 + +KBDVRL := $273 +FLGKBD := $275 +KBDFCT := $276 +KBDSHT := $278 + +KBDKEY := $279 +KBDCTC := $27E +LPRX := $286 +LPRY := $287 +LPRFX := $288 +LPRFY := $289 +FLGLPR := $28A + +; Joysticks management +FLGJCK := $28C +JCGVAL := $28D +JCDVAL := $28E +JCKTAB := $29D + + +HRSPAT := $2AA ; Hires pattern : it's used to draw pattern for a line or a circle +HRSERR := $2AB + +IOTAB0 := $2AE +IOTAB1 := $2B2 +IOTAB2 := $2B6 +IOTAB3 := $2BA +ADIOB := $2BE ; 48 bytes length +FLGRST := $2EE +CSRND := $2EF +VNMI := $2F4 +ADIODB_VECTOR := $2f7 ; 3 bytes length + +IRQVECTOR := $2FA +VAPLIC := $2FD + +; --------------------------------------------------------------------------- +; Page $400 +EXBNK := $40C +VEXBNK := $414 +BNKCIB := $417 + +; --------------------------------------------------------------------------- +; Page $500 + +DRIVE := $500 +ERRNB := $512 +SAVES := $513 +BUFNOM := $517 +VSALO0 := $528 +VSALO1 := $529 +FTYPE := $52C ; File type +DESALO := $52D +FISALO := $52F +EXSALO := $531 +EXTDEF := $55D ; Default extension. At the start of telemon, it's set to ".COM" +BUFEDT := $590 ; Buffer edition + +MAX_BUFEDT_LENGTH=110 + +; --------------------------------------------------------------------------- +; Hardware +CH376_DATA := $340 +CH376_COMMAND := $341 + +; RAM overlays buffer +BUFBUF := $c080 + +; --------------------------------------------------------------------------- +; Stratsed vectors +; Stratsed is the main OS for Telestrat +XMERGE := $FF0E +XFST := $FF11 +XSPUT := $FF14 +XSTAKE := $FF17 +XTAKE := $FF20 +XOPENS := $FF1A ; XOPEN from Stratsed +XCLOSES := $FF1D ; XCLOSE from Stratsed +XPUT := $FF23 +XREWIN := $FF29 +XJUMP := $FF2C +XLGBUF := $FF2F +XERVEC := $FF32 +XESAVE := $FF35 +XCOPY := $FF38 +XDNAME := $FF3B +XSTATU := $FF3E +XUPDAT := $FF41 +XFORMA := $FF44 +XDELBK := $FF4A +XDELN := $FF4D +XPROT := $FF50 +XUNPRO := $FF53 +XDIRN := $FF56 +XBKP := $FF59 +XINITI := $FF5C +XERREU := $FF5F +XLOAD := $FF62 +XDEFSA := $FF65 +XDEFLO := $FF68 +XSAVE := $FF6B +XNOMDE := $FF6E +XCREAY := $FF71 +XDETSE := $FF74 +XLIBSE := $FF77 +XTRVCA := $FF7A +XTRVNM := $FF7D +XTRVNX := $FF80 +XBUCA := $FF86 +XVBUF1 := $FF89 +XSVSEC := $FF8C +XSAY := $FF8F +XSBUF1 := $FF92 +XSBUF2 := $FF95 +XSBUF3 := $FF98 +XSCAT := $FF9B +XPRSEC := $FFA1 +XPBUF1 := $FFA4 +XPMAP := $FFA7 +XRWTS := $FFAA + +; --------------------------------------------------------------------------- +; MACRO + +.macro BRK_TELEMON value + .byte $00,value +.endmacro diff --git a/cc65/asminc/tgi-error.inc b/cc65/asminc/tgi-error.inc new file mode 100644 index 0000000..a4559bb --- /dev/null +++ b/cc65/asminc/tgi-error.inc @@ -0,0 +1,52 @@ +;*****************************************************************************/ +;* */ +;* tgi-error.inc */ +;* */ +;* TGI error codes */ +;* */ +;* */ +;* */ +;* (C) 2002-2012, Ullrich von Bassewitz */ +;* Roemerstrasse 52 */ +;* D-70794 Filderstadt */ +;* EMail: uz@cc65.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. */ +;* */ +;*****************************************************************************/ + + + +; Error constants +.enum + TGI_ERR_OK ; No error + TGI_ERR_NO_DRIVER ; No driver available + TGI_ERR_CANNOT_LOAD ; Error loading driver or font + TGI_ERR_INV_DRIVER ; Invalid driver + TGI_ERR_INV_MODE ; Mode not supported by driver + TGI_ERR_INV_ARG ; Invalid function argument + TGI_ERR_INV_FUNC ; Function not supported + TGI_ERR_INV_FONT ; Font file is invalid + TGI_ERR_NO_RES ; Out of resources (memory, handles, ...) + TGI_ERR_UNKNOWN ; Unknown error + TGI_ERR_INSTALLED ; A driver is already installed + + TGI_ERR_COUNT ; Special: Number of error messages +.endenum + diff --git a/cc65/asminc/tgi-kernel.inc b/cc65/asminc/tgi-kernel.inc new file mode 100644 index 0000000..fba78af --- /dev/null +++ b/cc65/asminc/tgi-kernel.inc @@ -0,0 +1,233 @@ +;*****************************************************************************/ +;* */ +;* tgi-kernel.inc */ +;* */ +;* TGI kernel interface */ +;* */ +;* */ +;* */ +;* (C) 2002-2012, Ullrich von Bassewitz */ +;* Roemerstrasse 52 */ +;* D-70794 Filderstadt */ +;* EMail: uz@cc65.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. */ +;* */ +;*****************************************************************************/ + + + +;------------------------------------------------------------------------------ +; The driver header + +.struct TGI_HDR + ID .byte 3 ; Contains 0x74, 0x67, 0x69 ("tgi") + VERSION .byte 1 ; Interface version + LIBREF .addr ; Library reference + VARS .struct + XRES .word 1 ; X resolution + YRES .word 1 ; Y resolution + COLORCOUNT .byte 1 ; Number of available colors + PAGECOUNT .byte 1 ; Number of screens available + FONTWIDTH .byte 1 ; System font width in pixel + FONTHEIGHT .byte 1 ; System font height in pixel + ASPECTRATIO .word 1 ; Fixed point 8.8 format + FLAGS .byte 1 ; TGI driver flags + .endstruct + JUMPTAB .struct + INSTALL .addr ; INSTALL routine + UNINSTALL .addr ; UNINSTALL routine + INIT .addr ; INIT routine + DONE .addr ; DONE routine + GETERROR .addr ; GETERROR routine + CONTROL .addr ; CONTROL routine + CLEAR .addr ; CLEAR routine + SETVIEWPAGE .addr ; SETVIEWPAGE routine + SETDRAWPAGE .addr ; SETDRAWPAGE routine + SETCOLOR .addr ; SETCOLOR routine + SETPALETTE .addr ; SETPALETTE routine + GETPALETTE .addr ; GETPALETTE routine + GETDEFPALETTE .addr ; GETDEFPALETTE routine + SETPIXEL .addr ; SETPIXEL routine + GETPIXEL .addr ; GETPIXEL routine + LINE .addr ; LINE routine + BAR .addr ; BAR routine + TEXTSTYLE .addr ; TEXTSTYLE routine + OUTTEXT .addr ; OUTTEXT routine + .endstruct +.endstruct + +;------------------------------------------------------------------------------ +; The TGI API version, stored at TGI_HDR_VERSION + +TGI_API_VERSION = $06 + +;------------------------------------------------------------------------------ +; Bitmapped tgi driver flags, stored in TGI_HDR::VARS::FLAGS. +; Beware: Some of the bits are tested using the BIT instruction, so do not +; change the values without checking the code! + +TGI_BM_FONT_FINESCALE = $80 ; Bitmap fonts are fine grained scalable + +;------------------------------------------------------------------------------ +; Text constants + +TGI_FONT_BITMAP = 0 +TGI_FONT_VECTOR = 1 + +TGI_TEXT_HORIZONTAL = 0 +TGI_TEXT_VERTICAL = 1 + +;---------------------------------------------------------------------------- +; Results of tgi_outcode + +TGI_CLIP_NONE = $00 +TGI_CLIP_LEFT = $01 +TGI_CLIP_RIGHT = $02 +TGI_CLIP_BOTTOM = $04 +TGI_CLIP_TOP = $08 + +;------------------------------------------------------------------------------ +; ASM accessible color constants + + .global tgi_color_black:zp ; Target-specific value for black + .global tgi_color_white:zp ; Target-specific value for white + +;------------------------------------------------------------------------------ +; C accessible variables + + .global _tgi_drv ; Pointer to driver + .global _tgi_error ; Last error code + .global _tgi_gmode ; Flag: graphics mode active + .global _tgi_curx ; Current drawing cursor X + .global _tgi_cury ; Current drawing cursor Y + .global _tgi_color ; Current drawing color + .global _tgi_font ; Which font to use + .global _tgi_textdir ; Current text direction + .global _tgi_vectorfont ; Pointer to vector font + .global _tgi_textscalew ; Text magnification for the width + .global _tgi_textscaleh ; Text magnification for the height + .global _tgi_charwidth ; Width of scaled system font char + .global _tgi_charheight ; Height of scaled system font char + .global _tgi_xres ; X resolution of the current mode + .global _tgi_yres ; Y resolution of the current mode + .global _tgi_xmax ; Maximum X coordinate + .global _tgi_ymax ; Maximum Y coordinate + .global _tgi_colorcount ; Number of available colors + .global _tgi_pagecount ; Number of available screen pages + .global _tgi_fontwidth ; System font width + .global _tgi_fontheight ; System font height + .global _tgi_aspectratio ; Aspect ratio, fixed point 8.8 + .global _tgi_flags ; TGI driver flags + +;------------------------------------------------------------------------------ +; ASM accessible variables + + .global tgi_clip_x1 ; Coordinate for line clipper + .global tgi_clip_y1 ; Coordinate for line clipper + .global tgi_clip_x2 ; Coordinate for line clipper + .global tgi_clip_y2 ; Coordinate for line clipper + +;------------------------------------------------------------------------------ +; Driver entry points + + .global tgi_install + .global tgi_uninstall + .global tgi_init + .global tgi_done + .global tgi_geterror + .global tgi_control + .global tgi_clear + .global tgi_setviewpage + .global tgi_setdrawpage + .global tgi_setcolor + .global tgi_setpalette + .global tgi_getpalette + .global tgi_getdefpalette + .global tgi_setpixel + .global tgi_getpixel + .global tgi_line + .global tgi_bar + .global tgi_textstyle + .global tgi_outtext + +;------------------------------------------------------------------------------ +; ASM functions + + .global tgi_clear_ptr + .global tgi_clippedline + .global tgi_curtoxy + .global tgi_getset + .global tgi_imulround + .global tgi_inv_arg + .global tgi_inv_drv + .global tgi_linepop + .global tgi_outcode + .global tgi_popxy + .global tgi_popxy2 + .global tgi_set_ptr + +;------------------------------------------------------------------------------ +; C callable functions + + .global _tgi_arc + .global _tgi_bar + .global _tgi_circle + .global _tgi_clear + .global _tgi_done + .global _tgi_ellipse + .global _tgi_getaspectratio + .global _tgi_getcolor + .global _tgi_getcolorcount + .global _tgi_getdefpalette + .global _tgi_geterror + .global _tgi_geterrormsg + .global _tgi_getmaxcolor + .global _tgi_getmaxx + .global _tgi_getmaxy + .global _tgi_getpagecount + .global _tgi_getpalette + .global _tgi_getpixel + .global _tgi_gettextheight + .global _tgi_gettextwidth + .global _tgi_getxres + .global _tgi_getyres + .global _tgi_gotoxy + .global _tgi_imulround + .global _tgi_init + .global _tgi_install + .global _tgi_install_vectorfont + .global _tgi_ioctl + .global _tgi_line + .global _tgi_lineto + .global _tgi_load_driver + .global _tgi_outtext + .global _tgi_outtextxy + .global _tgi_pieslice + .global _tgi_setaspectratio + .global _tgi_setcolor + .global _tgi_setdrawpage + .global _tgi_setpalette + .global _tgi_setpixel + .global _tgi_settextdir + .global _tgi_settextscale + .global _tgi_settextstyle + .global _tgi_setviewpage + .global _tgi_uninstall + .global _tgi_unload diff --git a/cc65/asminc/tgi-vectorfont.inc b/cc65/asminc/tgi-vectorfont.inc new file mode 100644 index 0000000..124fe93 --- /dev/null +++ b/cc65/asminc/tgi-vectorfont.inc @@ -0,0 +1,70 @@ +;*****************************************************************************/ +;* */ +;* tgi-vectorfont.inc */ +;* */ +;* TGI vector font definitions */ +;* */ +;* */ +;* */ +;* (C) 2009, Ullrich von Bassewitz */ +;* Roemerstrasse 52 */ +;* D-70794 Filderstadt */ +;* EMail: uz@cc65.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. */ +;* */ +;*****************************************************************************/ + + + +;------------------------------------------------------------------------------ +; Vectorfont constants + +TGI_VF_VERSION = $00 ; File version number +TGI_VF_FIRSTCHAR = $20 ; First char in file +TGI_VF_LASTCHAR = $7E ; Last char in file +TGI_VF_CCOUNT = (TGI_VF_LASTCHAR - TGI_VF_FIRSTCHAR + 1) + +;------------------------------------------------------------------------------ +; TCH file header and font data structures + +; TCH file header +.struct TGI_VF_HDR + MAGIC .byte 3 ; "TCH" + VERSION .byte 1 ; Version number + SIZE .word 1 ; Font data size +.endstruct + +; Font data loaded directly from file +.struct TGI_VECTORFONT + TOP .byte ; Height of char + BOTTOM .byte ; Descender + HEIGHT .byte ; Maximum char height + WIDTHS .byte ::TGI_VF_CCOUNT ; Char widths + CHARS .word ::TGI_VF_CCOUNT ; Pointer to character defs + OPS .byte ; Actually dynamic +.endstruct + +;------------------------------------------------------------------------------ +; C callable functions + + .global _tgi_vectorchar + + + diff --git a/cc65/asminc/time.inc b/cc65/asminc/time.inc new file mode 100644 index 0000000..7c1ab31 --- /dev/null +++ b/cc65/asminc/time.inc @@ -0,0 +1,74 @@ +;/*****************************************************************************/ +;/* */ +;/* time.inc */ +;/* */ +;/* Date and time */ +;/* */ +;/* */ +;/* */ +;/* (C) 2009 Ullrich von Bassewitz */ +;/* Roemerstrasse 52 */ +;/* D-70794 Filderstadt */ +;/* EMail: uz@cc65.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. */ +;/* */ +;/*****************************************************************************/ + + + +;------------------------------------------------------------------------------ +; Struct tm - must match the struct defined in time.h + +.struct tm + tm_sec .word + tm_min .word + tm_hour .word + tm_mday .word + tm_mon .word + tm_year .word + tm_wday .word + tm_yday .word + tm_isdst .word +.endstruct + + +;------------------------------------------------------------------------------ +; Struct timespec - must match the struct defined in time.h + +.struct timespec + tv_sec .dword + tv_nsec .dword +.endstruct + + +;------------------------------------------------------------------------------ +; Exported functions + +.global _clock_getres +.global _clock_gettime +.global _clock_settime +.global _localtime +.global _mktime + + +;------------------------------------------------------------------------------ +; Constants + +CLOCK_REALTIME = 0 diff --git a/cc65/asminc/utsname.inc b/cc65/asminc/utsname.inc new file mode 100644 index 0000000..6d978dd --- /dev/null +++ b/cc65/asminc/utsname.inc @@ -0,0 +1,46 @@ +;/*****************************************************************************/ +;/* */ +;/* utsname.inc */ +;/* */ +;/* Return system information */ +;/* */ +;/* */ +;/* */ +;/* (C) 2003 Ullrich von Bassewitz */ +;/* Roemerstrasse 52 */ +;/* D-70794 Filderstadt */ +;/* EMail: uz@cc65.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. */ +;/* */ +;/*****************************************************************************/ + + + +; Struct utsname +.struct utsname + sysname .byte 17 + nodename .byte 9 + release .byte 9 + version .byte 9 + machine .byte 25 +.endstruct + + + diff --git a/cc65/asminc/vic20.inc b/cc65/asminc/vic20.inc new file mode 100644 index 0000000..7184ab6 --- /dev/null +++ b/cc65/asminc/vic20.inc @@ -0,0 +1,119 @@ +; +; VIC-20 generic definitions. Stolen mostly from c64.inc -- Steve Schmidtke +; + +; --------------------------------------------------------------------------- +; Zero page, Commodore stuff + +VARTAB := $2D ; Pointer to start of BASIC variables +MEMSIZE := $37 ; Pointer to highest BASIC RAM location (+1) +TXTPTR := $7A ; Pointer into BASIC source code +STATUS := $90 ; Kernal I/O completion status +TIME := $A0 ; 60HZ clock +FNAM_LEN := $B7 ; Length of filename +SECADR := $B9 ; Secondary address +DEVNUM := $BA ; Device number +FNAM := $BB ; Pointer to filename +KEY_COUNT := $C6 ; Number of keys in input buffer +RVS := $C7 ; Reverse flag +CURS_FLAG := $CC ; 1 = cursor off +CURS_BLINK := $CD ; Blink counter +CURS_CHAR := $CE ; Character under the cursor +CURS_STATE := $CF ; Cursor blink state +SCREEN_PTR := $D1 ; Pointer to current char in text screen +CURS_X := $D3 ; Cursor column +CURS_Y := $D6 ; Cursor row +CRAM_PTR := $F3 ; Pointer to current char in color RAM + +BASIC_BUF := $200 ; Location of command-line +BASIC_BUF_LEN = 89 ; Maximum length of command-line + +CHARCOLOR := $286 +CURS_COLOR := $287 ; Color under the cursor + +KBDREPEAT := $28a +KBDREPEATRATE := $28b +KBDREPEATDELAY := $28c + +RSSTAT := $297 ; RS-232 device driver status + +; --------------------------------------------------------------------------- +; Screen size + +XSIZE = 22 +YSIZE = 23 + +; --------------------------------------------------------------------------- +; Vector and other locations + +IRQVec := $0314 +BRKVec := $0316 +NMIVec := $0318 + +; --------------------------------------------------------------------------- +; I/O: 6560 VIC + +VIC := $9000 +VIC_CR0 := VIC+$0 +VIC_CR1 := VIC+$1 +VIC_CR2 := VIC+$2 +VIC_CR3 := VIC+$3 +VIC_LINES := VIC+$3 ; Screen lines, bit 7 is bit 0 from VIC_HLINE +VIC_CR4 := VIC+$4 +VIC_HLINE := VIC+$4 ; Rasterline, bits 1-8 +VIC_CR5 := VIC+$5 +VIC_CR6 := VIC+$6 +VIC_CR7 := VIC+$7 +VIC_CR8 := VIC+$8 +VIC_CR9 := VIC+$9 +VIC_CRA := VIC+$A +VIC_CRB := VIC+$B +VIC_CRC := VIC+$C +VIC_CRD := VIC+$D +VIC_CRE := VIC+$E +VIC_CRF := VIC+$F +VIC_COLOR := VIC+$F ; Border and background color + +; --------------------------------------------------------------------------- +; I/O: 6522 VIA1 + +VIA1 := $9110 ; VIA1 base address +VIA1_JOY := VIA1+$0 ; *** Deprecated *** +VIA1_PB := VIA1+$0 ; Port register B +VIA1_PA1 := VIA1+$1 ; Port register A +VIA1_DDRB := VIA1+$2 ; Data direction register B +VIA1_DDRA := VIA1+$3 ; Data direction register A +VIA1_T1CL := VIA1+$4 ; Timer 1, low byte +VIA1_T1CH := VIA1+$5 ; Timer 1, high byte +VIA1_T1LL := VIA1+$6 ; Timer 1 latch, low byte +VIA1_T1LH := VIA1+$7 ; Timer 1 latch, high byte +VIA1_T2CL := VIA1+$8 ; Timer 2, low byte +VIA1_T2CH := VIA1+$9 ; Timer 2, high byte +VIA1_SR := VIA1+$A ; Shift register +VIA1_ACR := VIA1+$B ; Auxiliary control register +VIA1_PCR := VIA1+$C ; Peripheral control register +VIA1_IFR := VIA1+$D ; Interrupt flag register +VIA1_IER := VIA1+$E ; Interrupt enable register +VIA1_PA2 := VIA1+$F ; Port register A w/o handshake + +; --------------------------------------------------------------------------- +; I/O: 6522 VIA2 + +VIA2 := $9120 ; VIA2 base address +VIA2_JOY := VIA2+$0 ; *** Deprecated *** +VIA2_PB := VIA2+$0 ; Port register B +VIA2_PA1 := VIA2+$1 ; Port register A +VIA2_DDRB := VIA2+$2 ; Data direction register B +VIA2_DDRA := VIA2+$3 ; Data direction register A +VIA2_T1CL := VIA2+$4 ; Timer 1, low byte +VIA2_T1CH := VIA2+$5 ; Timer 1, high byte +VIA2_T1LL := VIA2+$6 ; Timer 1 latch, low byte +VIA2_T1LH := VIA2+$7 ; Timer 1 latch, high byte +VIA2_T2CL := VIA2+$8 ; Timer 2, low byte +VIA2_T2CH := VIA2+$9 ; Timer 2, high byte +VIA2_SR := VIA2+$A ; Shift register +VIA2_ACR := VIA2+$B ; Auxiliary control register +VIA2_PCR := VIA2+$C ; Peripheral control register +VIA2_IFR := VIA2+$D ; Interrupt flag register +VIA2_IER := VIA2+$E ; Interrupt enable register +VIA2_PA2 := VIA2+$F ; Port register A w/o handshake diff --git a/cc65/asminc/zeropage.inc b/cc65/asminc/zeropage.inc new file mode 100644 index 0000000..8d508fc --- /dev/null +++ b/cc65/asminc/zeropage.inc @@ -0,0 +1,40 @@ +; +; zeropage.inc +; +; (C) Copyright 2002-2012, Ullrich von Bassewitz (uz@cc65.org) +; + +; Assembler include file that imports the runtime zero page locations used +; by the compiler, ready for usage in asm code. + + + .globalzp c_sp, sreg, regsave + .globalzp ptr1, ptr2, ptr3, ptr4 + .globalzp tmp1, tmp2, tmp3, tmp4 + .globalzp regbank + +; FIXME: there must be a less ugly way to do this +.ifp4510 +.else +.ifp45GS02 +.else + + ; The following symbol is supplied for compatibility reasons only, it + ; will get removed in future versions. Using it will cause a linker + ; warning. + .globalzp sp +.endif +.endif + + +; The size of the register bank +regbanksize = 6 + +; The total amount of zero page space used +zpspace = 26 + +; The amount of space that needs to be saved by an interrupt handler that +; calls C code (does not include the register bank, which is saved by the +; generated C code if required). +zpsavespace = zpspace - regbanksize + diff --git a/cc65/bin/ar65 b/cc65/bin/ar65 new file mode 100755 index 0000000..cd987c1 Binary files /dev/null and b/cc65/bin/ar65 differ diff --git a/cc65/bin/ca65 b/cc65/bin/ca65 new file mode 100755 index 0000000..e4d2d11 Binary files /dev/null and b/cc65/bin/ca65 differ diff --git a/cc65/bin/cc65 b/cc65/bin/cc65 new file mode 100755 index 0000000..1fe990b Binary files /dev/null and b/cc65/bin/cc65 differ diff --git a/cc65/bin/chrcvt65 b/cc65/bin/chrcvt65 new file mode 100755 index 0000000..d0dab42 Binary files /dev/null and b/cc65/bin/chrcvt65 differ diff --git a/cc65/bin/cl65 b/cc65/bin/cl65 new file mode 100755 index 0000000..507118f Binary files /dev/null and b/cc65/bin/cl65 differ diff --git a/cc65/bin/co65 b/cc65/bin/co65 new file mode 100755 index 0000000..1072370 Binary files /dev/null and b/cc65/bin/co65 differ diff --git a/cc65/bin/da65 b/cc65/bin/da65 new file mode 100755 index 0000000..8495dea Binary files /dev/null and b/cc65/bin/da65 differ diff --git a/cc65/bin/grc65 b/cc65/bin/grc65 new file mode 100755 index 0000000..e9e9b93 Binary files /dev/null and b/cc65/bin/grc65 differ diff --git a/cc65/bin/ld65 b/cc65/bin/ld65 new file mode 100755 index 0000000..2e471d1 Binary files /dev/null and b/cc65/bin/ld65 differ diff --git a/cc65/bin/od65 b/cc65/bin/od65 new file mode 100755 index 0000000..6f22e69 Binary files /dev/null and b/cc65/bin/od65 differ diff --git a/cc65/bin/sim65 b/cc65/bin/sim65 new file mode 100755 index 0000000..f817739 Binary files /dev/null and b/cc65/bin/sim65 differ diff --git a/cc65/bin/sp65 b/cc65/bin/sp65 new file mode 100755 index 0000000..59effc2 Binary files /dev/null and b/cc65/bin/sp65 differ